1 #include "messages_methods.h"
4 #include "stg_message.h"
7 //------------------------------------------------------------------------------
9 void METHOD_MESSAGE_SEND::execute(xmlrpc_c::paramList const & paramList,
10 xmlrpc_c::value * const retvalPtr)
12 std::string cookie = paramList.getString(0);
13 std::vector<xmlrpc_c::value> logins(paramList.getArray(1));
14 std::map<std::string, xmlrpc_c::value> msgInfo(paramList.getStruct(2));
15 paramList.verifyEnd(3);
19 if (config->GetAdminInfo(cookie, &adminInfo))
21 *retvalPtr = xmlrpc_c::value_boolean(false);
27 std::map<std::string, xmlrpc_c::value>::iterator it;
29 if ((it = msgInfo.find("version")) == msgInfo.end())
31 message.header.ver = 1; // Default value
35 message.header.ver = xmlrpc_c::value_int(it->second);
38 if ((it = msgInfo.find("type")) == msgInfo.end())
40 message.header.type = 1; // default value
44 message.header.type = xmlrpc_c::value_int(it->second);
47 if ((it = msgInfo.find("repeat")) == msgInfo.end())
49 *retvalPtr = xmlrpc_c::value_boolean(false);
52 message.header.repeat = xmlrpc_c::value_int(it->second);
54 if ((it = msgInfo.find("repeat_period")) == msgInfo.end())
56 *retvalPtr = xmlrpc_c::value_boolean(false);
59 message.header.repeatPeriod = xmlrpc_c::value_int(it->second);
61 if ((it = msgInfo.find("show_time")) == msgInfo.end())
63 *retvalPtr = xmlrpc_c::value_boolean(false);
66 message.header.showTime = xmlrpc_c::value_int(it->second);
68 if ((it = msgInfo.find("text")) == msgInfo.end())
70 *retvalPtr = xmlrpc_c::value_boolean(false);
73 message.text = IconvString(xmlrpc_c::value_string(it->second), "UTF-8", "CP1251");
75 message.header.creationTime = stgTime;
76 message.header.lastSendTime = 0;
78 std::vector<xmlrpc_c::value>::iterator lit;
79 for (lit = logins.begin(); lit != logins.end(); ++lit)
82 if (users->FindByName(xmlrpc_c::value_string(*lit), &ui))
84 printfd(__FILE__, "METHOD_MESSAGE_SEND::execute(): 'User '%s' not found'\n", std::string(xmlrpc_c::value_string(*lit)).c_str());
88 ui->AddMessage(&message);
92 *retvalPtr = xmlrpc_c::value_boolean(true);