void devTcp4Client_Interface::client_create(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {

	ACE_TRACE("devTcp4Client_Interface::create");

	std::string devname = static_cast<std::string>(paramList.getString(0));

	if (devices::instance()->exists(devname)) {
		throw Exception("Device with that name already exists.");
	}

	std::string address = IPv4Addr::IPv4_Any;
	int port = 0;

	devTcp4Client* tcp4_dev = new devTcp4Client(devname, this);
	devices::instance()->add(tcp4_dev);

	if (paramList.size() > 1) {
		address = static_cast<std::string>(paramList.getString(2));
		tcp4_dev->setAddress(address);
	}
	if (paramList.size() > 2) {
		port = static_cast<int>(paramList.getInt(3));
		tcp4_dev->setPort(port);
		if (port > 0) tcp4_dev->openConnection();
	}

	*retvalP = xmlrpc_c::value_nil();
}
예제 #2
0
void RegisterDeviceHandler::execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value * const retvalP){
	std::string device(paramList.getString(0));

	LOG_INFO("Register device: " << device);

	*retvalP = xmlrpc_c::value_int(1337);
}
예제 #3
0
파일: log.cpp 프로젝트: tempbottle/fawkes
/** Execute method.
 * @param params parameters
 * @param result result value
 */
void
XmlRpcLogMethods::log_log::execute(xmlrpc_c::paramList const& params,
					xmlrpc_c::value *   const  result)
{
  std::string component = params.getString(0);
  std::string message   = params.getString(1);
  __logger->log(__log_level, component.c_str(), "%s", message.c_str());
  *result = xmlrpc_c::value_nil();
}
void devTcp4Client_Interface::client_get_address(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devTcp4Client_Interface::get_address");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devTcp4Client* tcp4_dev = dynamic_cast<devTcp4Client*>(devices::instance()->device(devname));

	std::string address = tcp4_dev->getAddress();
	*retvalP = xmlrpc_c::value_string(address);
}
/*
void devTcp4Client_Interface::client_remove(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {

	ACE_TRACE("devTcp4Client_Interface::remove");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devices::instance()->remove(devname);

	CEcfg::instance()->get("Devices").remove(devname);

	*retvalP = xmlrpc_c::value_nil();
}
*/
void devTcp4Client_Interface::client_is_connected(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devTcp4Client_Interface::is_connected");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devTcp4Client* tcp4_dev = dynamic_cast<devTcp4Client*>(devices::instance()->device(devname));

	bool isConnected = tcp4_dev->isConnected();
	*retvalP = xmlrpc_c::value_boolean(isConnected);
}
void devTcp4Client_Interface::client_get_ms_between_attempts(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devTcp4Client_Interface::client_get_ms_between_attempts");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devTcp4Client* tcp4_dev = dynamic_cast<devTcp4Client*>(devices::instance()->device(devname));

	int ms = tcp4_dev->getMsBetweenAttempts();
	*retvalP = xmlrpc_c::value_int(ms);
}
void devTcp4Client_Interface::client_open_connection(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devTcp4Client_Interface::openConnection");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devTcp4Client* tcp4_dev = dynamic_cast<devTcp4Client*>(devices::instance()->device(devname));

	tcp4_dev->openConnection();
	*retvalP = xmlrpc_c::value_nil();
}
void devTcp4Client_Interface::client_get_port(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devTcp4Client_Interface::get_port");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devTcp4Client* tcp4_dev = dynamic_cast<devTcp4Client*>(devices::instance()->device(devname));

	int port = tcp4_dev->getPort();
	*retvalP = xmlrpc_c::value_int(port);
}
예제 #9
0
void devUdp4_Interface::dev_udp_bind(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devUdp4_Interface::get_port");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devUdp4* udp4_dev = dynamic_cast<devUdp4*>(devices::instance()->device(devname));

	udp4_dev->bindSocket();
	*retvalP = xmlrpc_c::value_nil();
}
예제 #10
0
void devUdp4_Interface::dev_udp_set_port(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devUdp4_Interface::set_port");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	int port = static_cast<int>(paramList.getInt(1));
	devUdp4* udp4_dev = dynamic_cast<devUdp4*>(devices::instance()->device(devname));

	udp4_dev->setPort(port);
	*retvalP = xmlrpc_c::value_nil();
}
예제 #11
0
/*
void devUdp4_Interface::dev_udp_remove(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {

	ACE_TRACE("devUdp4_Interface::remove");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	devices::instance()->remove(devname);

	CEcfg::instance()->get("Devices").remove(devname);

	*retvalP = xmlrpc_c::value_nil();
}
*/
void devUdp4_Interface::dev_udp_set_address(xmlrpc_c::paramList const& paramList,
	xmlrpc_c::value* retvalP) {
	ACE_TRACE("devUdp4_Interface::set_address");

	std::string devname = static_cast<std::string>(paramList.getString(0));
	std::string address = static_cast<std::string>(paramList.getString(1));
	devUdp4* udp4_dev = dynamic_cast<devUdp4*>(devices::instance()->device(devname));

	udp4_dev->setAddress(address);
	*retvalP = xmlrpc_c::value_nil();
}
예제 #12
0
		void execute(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
		{
			chair = paramList.getInt(0);
			symbol_name = paramList.getString(1);

			SetEvent(symbol_need);
			DWORD wait_result;
			wait_result = WaitForSingleObject(symbol_ready, INFINITE);
			if(WAIT_OBJECT_0 == wait_result)
			{
				*retvalP = xmlrpc_c::value_double(symbol_value);
			} else {
				msg(L"Something went wrong.", L"openholdem-xmlrpc-dll");
			}
		}
예제 #13
0
/** Execute method.
 * @param params parameters
 * @param result result value
 */
void
XmlRpcPluginMethods::plugin_unload::execute(xmlrpc_c::paramList const& params,
					  xmlrpc_c::value *   const  result)
{
  try {
    std::string plugin_name = params.getString(0);
    __plugin_manager->unload(plugin_name.c_str());
  } catch (girerr::error &e) {
    throw xmlrpc_c::fault(e.what(), xmlrpc_c::fault::CODE_UNSPECIFIED);
  } catch (fawkes::Exception &e) {
    __logger->log_warn("XML-RPC plugin.unload", e);
    *result = xmlrpc_c::value_boolean(false);
  }

  *result = xmlrpc_c::value_boolean(true);
}
예제 #14
0
void METHOD_MESSAGE_SEND::execute(xmlrpc_c::paramList const & paramList,
                                  xmlrpc_c::value *   const   retvalPtr)
{
std::string cookie = paramList.getString(0);
std::vector<xmlrpc_c::value> logins(paramList.getArray(1));
std::map<std::string, xmlrpc_c::value> msgInfo(paramList.getStruct(2));
paramList.verifyEnd(3);

ADMIN_INFO adminInfo;

if (config->GetAdminInfo(cookie, &adminInfo))
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }

STG_MSG message;

std::map<std::string, xmlrpc_c::value>::iterator it;

if ((it = msgInfo.find("version")) == msgInfo.end())
    {
    message.header.ver = 1; // Default value
    }
else
    {
    message.header.ver = xmlrpc_c::value_int(it->second);
    }

if ((it = msgInfo.find("type")) == msgInfo.end())
    {
    message.header.type = 1; // default value
    }
else
    {
    message.header.type = xmlrpc_c::value_int(it->second);
    }

if ((it = msgInfo.find("repeat")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.repeat = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("repeat_period")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.repeatPeriod = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("show_time")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.header.showTime = xmlrpc_c::value_int(it->second);

if ((it = msgInfo.find("text")) == msgInfo.end())
    {
    *retvalPtr = xmlrpc_c::value_boolean(false);
    return;
    }
message.text = IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "CP1251");

message.header.creationTime = static_cast<int>(stgTime);
message.header.lastSendTime = 0;

std::vector<xmlrpc_c::value>::iterator lit;
for (lit = logins.begin(); lit != logins.end(); ++lit)
    {
    USER_PTR ui;
    if (users->FindByName(xmlrpc_c::value_string(*lit), &ui))
        {
        printfd(__FILE__, "METHOD_MESSAGE_SEND::execute(): 'User '%s' not found'\n", std::string(xmlrpc_c::value_string(*lit)).c_str());
        }
    else
        {
        ui->AddMessage(&message);
        }
    }

*retvalPtr = xmlrpc_c::value_boolean(true);
}