MCPcopy Create free account
hub / github.com/amule-project/amule / ProcessCommand

Method ProcessCommand

src/TextClient.cpp:233–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233int CamulecmdApp::ProcessCommand(int CmdId)
234{
235 wxString args = GetCmdArgs();
236 CECPacket *request = 0;
237 std::list<CECPacket *> request_list;
238 int tmp_int = 0;
239 EC_SEARCH_TYPE search_type = EC_SEARCH_KAD;
240
241 // Implementation of the deprecated command 'SetIPFilter'.
242 if (CmdId == CMD_ID_SET_IPFILTER) {
243 if ( ! args.IsEmpty() ) {
244 if (args.IsSameAs("ON", false)) {
245 CmdId = CMD_ID_SET_IPFILTER_ON;
246 } else if (args.IsSameAs("OFF", false)) {
247 CmdId = CMD_ID_SET_IPFILTER_OFF;
248 } else {
249 return CMD_ERR_INVALID_ARG;
250 }
251 } else {
252 CmdId = CMD_ID_GET_IPFILTER_STATE;
253 }
254 }
255
256 switch (CmdId) {
257 case CMD_ID_STATUS:
258 request_list.push_back(new CECPacket(EC_OP_STAT_REQ, EC_DETAIL_CMD));
259 break;
260
261 case CMD_ID_SHUTDOWN:
262 request_list.push_back(new CECPacket(EC_OP_SHUTDOWN));
263 break;
264
265 case CMD_ID_CONNECT:
266 if ( !args.IsEmpty() ) {
267 unsigned int ip[4];
268 unsigned int port;
269 // Not much we can do against this unicode2char.
270 int result = sscanf(unicode2char(args), "%3d.%3d.%3d.%3d:%5d", &ip[0], &ip[1], &ip[2], &ip[3], &port);
271 if (result != 5) {
272 // Try to resolve DNS -- good for dynamic IP servers
273 wxString serverName(args.BeforeFirst(':'));
274 long lPort;
275 bool ok = args.AfterFirst(':').ToLong(&lPort);
276 port = (unsigned int)lPort;
277 amuleIPV4Address a;
278 a.Hostname(serverName);
279 a.Service(port);
280 result = sscanf(unicode2char(a.IPAddress()), "%3d.%3d.%3d.%3d", &ip[0], &ip[1], &ip[2], &ip[3]);
281 if (serverName.IsEmpty() || !ok || (result != 4)) {
282 Show(_("Invalid IP format. Use xxx.xxx.xxx.xxx:xxxx\n"));
283 return 0;
284 }
285 }
286 EC_IPv4_t addr;
287 addr.m_ip[0] = ip[0];
288 addr.m_ip[1] = ip[1];
289 addr.m_ip[2] = ip[2];
290 addr.m_ip[3] = ip[3];

Callers

nothing calls this directly

Calls 15

ParseSearchFiltersFunction · 0.85
CEC_Search_TagClass · 0.85
CFormatClass · 0.85
IsSameAsMethod · 0.80
ServiceMethod · 0.80
IPAddressMethod · 0.80
PartMetNameMethod · 0.80
StartsWithMethod · 0.80
resizeMethod · 0.80
CECTagClass · 0.70
unicode2charFunction · 0.50
IsEmptyMethod · 0.45

Tested by

no test coverage detected