Upstream tarball 10114
[amule.git] / src / TextClient.cpp
blob0d4857255d7caa4f0a8aca5b7148cfa6d04cbb72
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #ifdef HAVE_CONFIG_H
28 #include "config.h" // Needed for VERSION
29 #endif
31 #include <common/ClientVersion.h>
33 #include "TextClient.h"
35 #ifndef __WXMSW__
36 #include <unistd.h> // Do_not_auto_remove
37 #endif
40 //-------------------------------------------------------------------
43 //-------------------------------------------------------------------
45 #include <ec/cpp/ECSpecialTags.h>
47 #include <wx/tokenzr.h>
49 #include <common/Format.h> // Needed for CFormat
50 #include "OtherFunctions.h"
51 #include "KnownFile.h" // Needed for Priority Levels
52 #include "DataToText.cpp" // Needed for PriorityToStr
54 #define APP_INIT_SIZE_X 640
55 #define APP_INIT_SIZE_Y 480
57 #define theApp (*((CamulecmdApp*)wxTheApp))
59 //-------------------------------------------------------------------
61 enum {
62 CMD_ID_STATUS,
63 CMD_ID_RESUME,
64 CMD_ID_PAUSE,
65 CMD_ID_PRIORITY_LOW,
66 CMD_ID_PRIORITY_NORMAL,
67 CMD_ID_PRIORITY_HIGH,
68 CMD_ID_PRIORITY_AUTO,
69 CMD_ID_CANCEL,
70 CMD_ID_CONNECT,
71 CMD_ID_CONNECT_ED2K,
72 CMD_ID_CONNECT_KAD,
73 CMD_ID_DISCONNECT,
74 CMD_ID_DISCONNECT_ED2K,
75 CMD_ID_DISCONNECT_KAD,
76 CMD_ID_RELOAD_SHARED,
77 CMD_ID_RELOAD_IPFILTER_LOCAL,
78 CMD_ID_RELOAD_IPFILTER_NET,
79 CMD_ID_SET_IPFILTER_ON,
80 CMD_ID_SET_IPFILTER_OFF,
81 CMD_ID_SET_IPFILTER_CLIENTS_ON,
82 CMD_ID_SET_IPFILTER_CLIENTS_OFF,
83 CMD_ID_SET_IPFILTER_SERVERS_ON,
84 CMD_ID_SET_IPFILTER_SERVERS_OFF,
85 CMD_ID_SET_IPFILTER_LEVEL,
86 CMD_ID_GET_IPFILTER,
87 CMD_ID_GET_IPFILTER_STATE,
88 CMD_ID_GET_IPFILTER_STATE_CLIENTS,
89 CMD_ID_GET_IPFILTER_STATE_SERVERS,
90 CMD_ID_GET_IPFILTER_LEVEL,
91 CMD_ID_SHOW_UL,
92 CMD_ID_SHOW_DL,
93 CMD_ID_SHOW_LOG,
94 CMD_ID_SHOW_SERVERS,
95 CMD_ID_SHOW_SHARED,
96 CMD_ID_RESET_LOG,
97 CMD_ID_SHUTDOWN,
98 CMD_ID_ADDLINK,
99 CMD_ID_SET_BWLIMIT_UP,
100 CMD_ID_SET_BWLIMIT_DOWN,
101 CMD_ID_GET_BWLIMITS,
102 CMD_ID_STATTREE,
103 CMD_ID_SEARCH,
104 CMD_ID_SEARCH_GLOBAL,
105 CMD_ID_SEARCH_LOCAL,
106 CMD_ID_SEARCH_KAD,
107 CMD_ID_SEARCH_RESULTS,
108 CMD_ID_SEARCH_PROGRESS,
109 CMD_ID_DOWNLOAD,
110 // IDs for deprecated commands
111 CMD_ID_SET_IPFILTER
115 // method to create a SearchFile
116 SearchFile::SearchFile(CEC_SearchFile_Tag *tag)
118 nHash = tag->FileHash();
119 sHash = nHash.Encode();
120 sFileName = tag->FileName();
121 lFileSize = tag->SizeFull();
122 lSourceCount = tag->SourceCount();
123 bPresent = tag->AlreadyHave();
126 //-------------------------------------------------------------------
127 IMPLEMENT_APP (CamulecmdApp)
128 //-------------------------------------------------------------------
130 void CamulecmdApp::OnInitCmdLine(wxCmdLineParser& parser)
132 CaMuleExternalConnector::OnInitCmdLine(parser, "amulecmd");
133 parser.AddOption(wxT("c"), wxT("command"),
134 _("Execute <str> and exit."),
135 wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
138 bool CamulecmdApp::OnCmdLineParsed(wxCmdLineParser& parser)
140 m_HasCmdOnCmdLine = parser.Found(wxT("command"), &m_CmdString);
141 if (m_CmdString.Lower().StartsWith(wxT("help")))
143 OnInitCommandSet();
144 printf("%s %s\n", m_appname, (const char *)unicode2char(GetMuleVersion()));
145 Parse_Command(m_CmdString);
146 exit(0);
148 m_interactive = !m_HasCmdOnCmdLine;
149 return CaMuleExternalConnector::OnCmdLineParsed(parser);
152 void CamulecmdApp::TextShell(const wxString& prompt)
154 if (m_HasCmdOnCmdLine)
155 Parse_Command(m_CmdString);
156 else
157 CaMuleExternalConnector::TextShell(prompt);
160 int CamulecmdApp::ProcessCommand(int CmdId)
162 wxString args = GetCmdArgs();
163 CECPacket *request = 0;
164 std::list<CECPacket *> request_list;
165 int tmp_int = 0;
166 EC_SEARCH_TYPE search_type = EC_SEARCH_KAD;
168 // Implementation of the deprecated command 'SetIPFilter'.
169 if (CmdId == CMD_ID_SET_IPFILTER) {
170 if ( ! args.IsEmpty() ) {
171 if (args.IsSameAs(wxT("ON"), false)) {
172 CmdId = CMD_ID_SET_IPFILTER_ON;
173 } else if (args.IsSameAs(wxT("OFF"), false)) {
174 CmdId = CMD_ID_SET_IPFILTER_OFF;
175 } else {
176 return CMD_ERR_INVALID_ARG;
178 } else {
179 CmdId = CMD_ID_GET_IPFILTER_STATE;
183 switch (CmdId) {
184 case CMD_ID_STATUS:
185 request_list.push_back(new CECPacket(EC_OP_STAT_REQ, EC_DETAIL_CMD));
186 break;
188 case CMD_ID_SHUTDOWN:
189 request_list.push_back(new CECPacket(EC_OP_SHUTDOWN));
190 break;
192 case CMD_ID_CONNECT:
193 if ( !args.IsEmpty() ) {
194 unsigned int ip[4];
195 unsigned int port;
196 // Not much we can do against this unicode2char.
197 int result = sscanf(unicode2char(args), "%d.%d.%d.%d:%d", &ip[0], &ip[1], &ip[2], &ip[3], &port);
198 if (result != 5) {
199 // Try to resolve DNS -- good for dynamic IP servers
200 wxString serverName(args.BeforeFirst(wxT(':')));
201 long lPort;
202 bool ok = args.AfterFirst(wxT(':')).ToLong(&lPort);
203 port = (unsigned int)lPort;
204 wxIPV4address a;
205 a.Hostname(serverName);
206 a.Service(port);
207 result = sscanf(unicode2char(a.IPAddress()), "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]);
208 if (serverName.IsEmpty() || !ok || (result != 4)) {
209 Show(_("Invalid IP format. Use xxx.xxx.xxx.xxx:xxxx\n"));
210 return 0;
213 EC_IPv4_t addr;
214 addr.m_ip[0] = ip[0];
215 addr.m_ip[1] = ip[1];
216 addr.m_ip[2] = ip[2];
217 addr.m_ip[3] = ip[3];
218 addr.m_port = port;
219 request = new CECPacket(EC_OP_SERVER_CONNECT);
220 request->AddTag(CECTag(EC_TAG_SERVER, addr));
221 request_list.push_back(request);
222 } else {
223 request_list.push_back(new CECPacket(EC_OP_CONNECT));
225 break;
227 case CMD_ID_CONNECT_ED2K:
228 request_list.push_back(new CECPacket(EC_OP_SERVER_CONNECT));
229 break;
231 case CMD_ID_CONNECT_KAD:
232 request_list.push_back(new CECPacket(EC_OP_KAD_START));
233 break;
235 case CMD_ID_DISCONNECT:
236 request_list.push_back(new CECPacket(EC_OP_DISCONNECT));
237 break;
239 case CMD_ID_DISCONNECT_ED2K:
240 request_list.push_back(new CECPacket(EC_OP_SERVER_DISCONNECT));
241 break;
243 case CMD_ID_DISCONNECT_KAD:
244 request_list.push_back(new CECPacket(EC_OP_KAD_STOP));
245 break;
247 case CMD_ID_RELOAD_SHARED:
248 request_list.push_back(new CECPacket(EC_OP_SHAREDFILES_RELOAD));
249 break;
251 case CMD_ID_RELOAD_IPFILTER_LOCAL:
252 request_list.push_back(new CECPacket(EC_OP_IPFILTER_RELOAD));
253 break;
255 case CMD_ID_RELOAD_IPFILTER_NET:
256 request = new CECPacket(EC_OP_IPFILTER_UPDATE);
257 request->AddTag(EC_TAG_STRING, args);
258 request_list.push_back(request);
259 break;
261 case CMD_ID_SET_IPFILTER_ON:
262 case CMD_ID_SET_IPFILTER_CLIENTS_ON:
263 case CMD_ID_SET_IPFILTER_SERVERS_ON:
264 tmp_int = 1;
265 case CMD_ID_SET_IPFILTER_OFF:
266 case CMD_ID_SET_IPFILTER_CLIENTS_OFF:
267 case CMD_ID_SET_IPFILTER_SERVERS_OFF:
269 if (CmdId == CMD_ID_SET_IPFILTER_CLIENTS_ON || CmdId == CMD_ID_SET_IPFILTER_CLIENTS_OFF) {
270 CmdId = CMD_ID_GET_IPFILTER_STATE_CLIENTS;
271 } else if (CmdId == CMD_ID_SET_IPFILTER_SERVERS_ON || CmdId == CMD_ID_SET_IPFILTER_SERVERS_OFF) {
272 CmdId = CMD_ID_GET_IPFILTER_STATE_SERVERS;
273 } else {
274 CmdId = CMD_ID_GET_IPFILTER_STATE;
277 request = new CECPacket(EC_OP_SET_PREFERENCES);
278 CECEmptyTag prefs(EC_TAG_PREFS_SECURITY);
279 if (CmdId != CMD_ID_GET_IPFILTER_STATE_SERVERS) {
280 prefs.AddTag(CECTag(EC_TAG_IPFILTER_CLIENTS, (uint8)tmp_int));
282 if (CmdId != CMD_ID_GET_IPFILTER_STATE_CLIENTS) {
283 prefs.AddTag(CECTag(EC_TAG_IPFILTER_SERVERS, (uint8)tmp_int));
285 request->AddTag(prefs);
286 request_list.push_back(request);
288 case CMD_ID_GET_IPFILTER:
289 case CMD_ID_GET_IPFILTER_STATE:
290 case CMD_ID_GET_IPFILTER_STATE_CLIENTS:
291 case CMD_ID_GET_IPFILTER_STATE_SERVERS:
292 request = new CECPacket(EC_OP_GET_PREFERENCES);
293 request->AddTag(CECTag(EC_TAG_SELECT_PREFS, (uint32)EC_PREFS_SECURITY));
294 request_list.push_back(request);
295 break;
297 case CMD_ID_SET_IPFILTER_LEVEL:
298 if (!args.IsEmpty()) // This 'if' must stay as long as we support the deprecated 'IPLevel' command.
300 unsigned long int level = 0;
301 if (args.ToULong(&level) == true && level < 256) {
302 request = new CECPacket(EC_OP_SET_PREFERENCES);
303 CECEmptyTag prefs(EC_TAG_PREFS_SECURITY);
304 prefs.AddTag(CECTag(EC_TAG_IPFILTER_LEVEL, (uint8)level));
305 request->AddTag(prefs);
306 request_list.push_back(request);
307 } else {
308 return CMD_ERR_INVALID_ARG;
311 CmdId = CMD_ID_GET_IPFILTER_LEVEL;
312 case CMD_ID_GET_IPFILTER_LEVEL:
313 request = new CECPacket(EC_OP_GET_PREFERENCES);
314 request->AddTag(CECTag(EC_TAG_SELECT_PREFS, (uint32)EC_PREFS_SECURITY));
315 request_list.push_back(request);
316 break;
318 case CMD_ID_PAUSE:
319 case CMD_ID_CANCEL:
320 case CMD_ID_RESUME:
322 if ( args.IsEmpty() ) {
323 Show(_("This command requires an argument. Valid arguments: 'all', filename, or a number.\n"));
324 return 0;
325 } else {
326 wxStringTokenizer argsTokenizer(args);
327 wxString token;
328 CMD4Hash hash;
330 // Grab the entire dl queue right away
331 CECPacket request_all(EC_OP_GET_DLOAD_QUEUE, EC_DETAIL_CMD);
332 const CECPacket *reply_all = SendRecvMsg_v2(&request_all);
334 if (reply_all) {
335 switch(CmdId) {
336 case CMD_ID_PAUSE:
337 request = new CECPacket(EC_OP_PARTFILE_PAUSE); break;
338 case CMD_ID_CANCEL:
339 request = new CECPacket(EC_OP_PARTFILE_DELETE); break;
340 case CMD_ID_RESUME:
341 request = new CECPacket(EC_OP_PARTFILE_RESUME); break;
342 default: wxFAIL;
345 // We loop through all the arguments
346 while(argsTokenizer.HasMoreTokens()) {
347 token=argsTokenizer.GetNextToken();
349 // If the user requested all, then we select all files and exit the loop
350 // since there is little point to add anything more to "everything"
351 if( token == wxT("all") ) {
352 for (CECPacket::const_iterator it = reply_all->begin(); it != reply_all->end(); it++) {
353 CEC_PartFile_Tag *tag = (CEC_PartFile_Tag *) & *it;
354 request->AddTag(CECTag(EC_TAG_PARTFILE, tag->FileHash()));
356 break;
357 } else if ( hash.Decode(token.Trim(false).Trim(true)) ) {
358 if ( !hash.IsEmpty() ) {
359 Show(_("Processing by hash: "+token+wxT("\n")));
360 request->AddTag(CECTag(EC_TAG_PARTFILE, hash));
362 } else {
363 // Go through the dl queue and look at each filename
364 for (CECPacket::const_iterator it = reply_all->begin(); it != reply_all->end(); it++) {
365 CEC_PartFile_Tag *tag = (CEC_PartFile_Tag *) & *it;
366 wxString partmetname = tag->PartMetName();
368 // We check for filename, XXX.pat.met, XXX.part, XXX
369 if( tag->FileName() == token ||
370 partmetname == token ||
371 partmetname.Truncate(partmetname.Len()-4) == token ||
372 partmetname.Truncate(partmetname.Len()-5) == token) {
373 Show(_("Processing by filename: "+token+wxT("\n")));
374 request->AddTag(CECTag(EC_TAG_PARTFILE, tag->FileHash()));
377 } // End of filename check else
378 } // End of argument token loop
380 request_list.push_back(request);
382 delete reply_all;
384 } // End of dl queue processing
386 } // end of command processing
387 break;
390 case CMD_ID_PRIORITY_LOW:
391 case CMD_ID_PRIORITY_NORMAL:
392 case CMD_ID_PRIORITY_HIGH:
393 case CMD_ID_PRIORITY_AUTO:
394 if ( args.IsEmpty() ) {
395 Show(_("This command requires an argument. Valid arguments: a file hash.\n"));
396 return 0;
397 } else {
398 CMD4Hash hash;
399 if (hash.Decode(args.Trim(false).Trim(true))) {
400 if (!hash.IsEmpty()) {
401 request = new CECPacket(EC_OP_PARTFILE_PRIO_SET);
402 CECTag hashtag(EC_TAG_PARTFILE, hash);
403 switch(CmdId) {
404 case CMD_ID_PRIORITY_LOW:
405 hashtag.AddTag(CECTag(EC_TAG_PARTFILE_PRIO, (uint8)PR_LOW));
406 break;
407 case CMD_ID_PRIORITY_NORMAL:
408 hashtag.AddTag(CECTag(EC_TAG_PARTFILE_PRIO, (uint8)PR_NORMAL));
409 break;
410 case CMD_ID_PRIORITY_HIGH:
411 hashtag.AddTag(CECTag(EC_TAG_PARTFILE_PRIO, (uint8)PR_HIGH));
412 break;
413 case CMD_ID_PRIORITY_AUTO:
414 hashtag.AddTag(CECTag(EC_TAG_PARTFILE_PRIO, (uint8)PR_AUTO));
415 break;
416 default: wxFAIL;
418 request->AddTag(hashtag);
419 request_list.push_back(request);
420 } else {
421 Show(_("Not a valid number\n"));
422 return 0;
424 } else {
425 Show(_("Not a valid hash (length should be exactly 32 chars)\n"));
426 return 0;
429 break;
431 case CMD_ID_SHOW_UL:
432 request_list.push_back(new CECPacket(EC_OP_GET_ULOAD_QUEUE));
433 break;
435 case CMD_ID_SHOW_DL:
436 request_list.push_back(new CECPacket(EC_OP_GET_DLOAD_QUEUE));
437 break;
439 case CMD_ID_SHOW_LOG:
440 request_list.push_back(new CECPacket(EC_OP_GET_LOG));
441 break;
443 case CMD_ID_SHOW_SERVERS:
444 request_list.push_back(new CECPacket(EC_OP_GET_SERVER_LIST, EC_DETAIL_CMD));
445 break;
447 case CMD_ID_RESET_LOG:
448 request_list.push_back(new CECPacket(EC_OP_RESET_LOG));
449 break;
451 case CMD_ID_ADDLINK:
452 if (args.compare(0, 7, wxT("ed2k://")) == 0) {
453 //aMule doesn't like AICH links without |/| in front of h=
454 if (args.Find(wxT("|h=")) > -1 && args.Find(wxT("|/|h=")) == -1) {
455 args.Replace(wxT("|h="),wxT("|/|h="));
458 request = new CECPacket(EC_OP_ADD_LINK);
459 request->AddTag(CECTag(EC_TAG_STRING, args));
460 request_list.push_back(request);
461 break;
463 case CMD_ID_SET_BWLIMIT_UP:
464 tmp_int = EC_TAG_CONN_MAX_UL - EC_TAG_CONN_MAX_DL;
465 case CMD_ID_SET_BWLIMIT_DOWN:
466 tmp_int += EC_TAG_CONN_MAX_DL;
468 unsigned long int limit;
469 if (args.ToULong(&limit)) {
470 request = new CECPacket(EC_OP_SET_PREFERENCES);
471 CECEmptyTag prefs(EC_TAG_PREFS_CONNECTIONS);
472 prefs.AddTag(CECTag(tmp_int, (uint16)limit));
473 request->AddTag(prefs);
474 request_list.push_back(request);
475 } else {
476 return CMD_ERR_INVALID_ARG;
479 case CMD_ID_GET_BWLIMITS:
480 request = new CECPacket(EC_OP_GET_PREFERENCES);
481 request->AddTag(CECTag(EC_TAG_SELECT_PREFS, (uint32)EC_PREFS_CONNECTIONS));
482 request_list.push_back(request);
483 break;
485 case CMD_ID_STATTREE:
486 request = new CECPacket(EC_OP_GET_STATSTREE);
487 if (!args.IsEmpty()) {
488 unsigned long int max_versions;
489 if (args.ToULong(&max_versions)) {
490 if (max_versions < 256) {
491 request->AddTag(CECTag(EC_TAG_STATTREE_CAPPING, (uint8)max_versions));
492 } else {
493 delete request;
494 return CMD_ERR_INVALID_ARG;
496 } else {
497 delete request;
498 return CMD_ERR_INVALID_ARG;
501 request_list.push_back(request);
502 break;
503 case CMD_ID_SEARCH_GLOBAL:
504 search_type = EC_SEARCH_GLOBAL;
505 case CMD_ID_SEARCH_LOCAL:
506 if (search_type != EC_SEARCH_GLOBAL){
507 search_type = EC_SEARCH_LOCAL;
509 case CMD_ID_SEARCH_KAD:
510 if (search_type != EC_SEARCH_GLOBAL && search_type != EC_SEARCH_LOCAL){
511 search_type = EC_SEARCH_KAD;
513 if (!args.IsEmpty())
515 wxString search = args;
516 wxString type = wxT("");
517 wxString extention = wxT("");
518 uint32 avail = 0;
519 uint32 min_size = 0;
520 uint32 max_size = 0;
522 request = new CECPacket(EC_OP_SEARCH_START);
523 request->AddTag(CEC_Search_Tag (search, search_type, type, extention, avail, min_size, max_size));
524 request_list.push_back(request);
526 break;
527 case CMD_ID_SEARCH:
528 printf("No search type defined.\nType 'help search' to get more help.\n");
529 break;
532 case CMD_ID_SEARCH_RESULTS:
533 request_list.push_back(new CECPacket(EC_OP_SEARCH_RESULTS, EC_DETAIL_FULL));
534 break;
536 case CMD_ID_SEARCH_PROGRESS:
537 request_list.push_back(new CECPacket(EC_OP_SEARCH_PROGRESS));
538 break;
540 case CMD_ID_DOWNLOAD:
541 if (!args.IsEmpty())
543 unsigned long int id = 0;
544 if (args.ToULong(&id) == true && id < m_Results_map.size()) {
546 SearchFile* file = m_Results_map[id];
547 printf("Download File: %lu %s\n", id, (const char*)unicode2char(file->sFileName));
548 request = new CECPacket(EC_OP_DOWNLOAD_SEARCH_RESULT);
549 // get with id the hash and category=0
550 uint32 category = 0;
551 CECTag hashtag(EC_TAG_PARTFILE, file->nHash);
552 hashtag.AddTag(CECTag(EC_TAG_PARTFILE_CAT, category));
553 request->AddTag(hashtag);
554 request_list.push_back(request);
555 } else {
556 return CMD_ERR_INVALID_ARG;
559 break;
561 default:
562 return CMD_ERR_PROCESS_CMD;
565 m_last_cmd_id = CmdId;
567 if ( ! request_list.empty() ) {
568 std::list<CECPacket *>::iterator it = request_list.begin();
569 while ( it != request_list.end() ) {
570 CECPacket *curr = *it++;
571 const CECPacket *reply = SendRecvMsg_v2(curr);
572 delete curr;
573 if ( reply ) {
574 Process_Answer_v2(reply);
575 delete reply;
578 request_list.resize(0);
581 if (CmdId == CMD_ID_SHUTDOWN)
582 return CMD_ID_QUIT;
583 else
584 return CMD_OK;
588 * Method to show the results in the console
590 void CamulecmdApp::ShowResults(CResultMap results_map)
592 unsigned int name_max = 80;
593 unsigned int mb_max = 5;
594 unsigned int nr_max = 5;
595 unsigned long int id = 0;
596 wxString output, name, sources, mb , kb;
598 printf("Nr. Filename: Size(MB): Sources: \n");
599 printf("-----------------------------------------------------------------------------------------------------------\n");
601 for( std::map<unsigned long int,SearchFile*>::iterator iter = results_map.begin(); iter != results_map.end(); iter++ ) {
602 id = (*iter).first;
603 SearchFile* file = (*iter).second;
605 output.Printf(wxT("%i. "), id);
606 output = output.SubString(0, nr_max).Append(file->sFileName).Append(' ', name_max);
607 mb.Printf(wxT(" %d"), file->lFileSize/1024/1024);
608 kb.Printf(wxT(".%d"), file->lFileSize/1024%1024);
609 output = output.SubString(0, nr_max + name_max + mb_max - mb.Length() ).Append(mb).Append(kb);
610 printf("%s %ld\n",(const char*)unicode2char(output), file->lSourceCount );
615 // Formats a statistics (sub)tree to text
616 wxString StatTree2Text(CEC_StatTree_Node_Tag *tree, int depth)
618 if (!tree) {
619 return wxEmptyString;
621 wxString result = wxString(wxChar(' '), depth) + tree->GetDisplayString() + wxT("\n");
622 for (CECTag::const_iterator it = tree->begin(); it != tree->end(); it++) {
623 CEC_StatTree_Node_Tag *tmp = (CEC_StatTree_Node_Tag*) & *it;
624 if (tmp->GetTagName() == EC_TAG_STATTREE_NODE) {
625 result += StatTree2Text(tmp, depth + 1);
628 return result;
632 * Format EC packet into text form for output to console
634 void CamulecmdApp::Process_Answer_v2(const CECPacket *response)
636 wxString s;
637 wxString msgFailedUnknown(_("Request failed with an unknown error."));
638 wxASSERT(response);
639 switch (response->GetOpCode()) {
640 case EC_OP_NOOP:
641 s << _("Operation was successful.");
642 break;
643 case EC_OP_FAILED:
645 const CECTag *tag = response->GetFirstTagSafe();
646 if (tag->IsString()) {
647 s << CFormat(_("Request failed with the following error: %s")) % wxGetTranslation(tag->GetStringData());
648 } else {
649 s << msgFailedUnknown;
652 break;
653 case EC_OP_SET_PREFERENCES:
655 const CECTag *tab = response->GetTagByNameSafe(EC_TAG_PREFS_SECURITY);
656 const CECTag *ipfilterLevel = tab->GetTagByName(EC_TAG_IPFILTER_LEVEL);
657 if (ipfilterLevel) {
658 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
659 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
660 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_CLIENTS) {
661 s << wxString::Format(_("IP filtering for clients is %s.\n"),
662 (tab->GetTagByName(EC_TAG_IPFILTER_CLIENTS) == NULL) ? _("OFF") : _("ON"));
664 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
665 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
666 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_SERVERS) {
667 s << wxString::Format(_("IP filtering for servers is %s.\n"),
668 (tab->GetTagByName(EC_TAG_IPFILTER_SERVERS) == NULL) ? _("OFF") : _("ON"));
670 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
671 m_last_cmd_id == CMD_ID_GET_IPFILTER_LEVEL) {
672 s << CFormat(_("Current IPFilter Level is %d.\n")) % ipfilterLevel->GetInt();
675 tab = response->GetTagByNameSafe(EC_TAG_PREFS_CONNECTIONS);
676 const CECTag *connMaxUL = tab->GetTagByName(EC_TAG_CONN_MAX_UL);
677 const CECTag *connMaxDL = tab->GetTagByName(EC_TAG_CONN_MAX_DL);
678 if (connMaxUL && connMaxDL) {
679 s << CFormat(_("Bandwidth limits: Up: %u kB/s, Down: %u kB/s.\n"))
680 % connMaxUL->GetInt() % connMaxDL->GetInt();
683 break;
684 case EC_OP_STRINGS:
685 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
686 const CECTag &tag = *it;
687 s << tag.GetStringData() << wxT("\n");
689 break;
690 case EC_OP_STATS: {
691 CEC_ConnState_Tag *connState = (CEC_ConnState_Tag*)response->GetTagByName(EC_TAG_CONNSTATE);
692 if (connState) {
693 s << _("eD2k") << wxT(": ");
694 if (connState->IsConnectedED2K()) {
695 CECTag *server = connState->GetTagByName(EC_TAG_SERVER);
696 CECTag *serverName = server ? server->GetTagByName(EC_TAG_SERVER_NAME) : NULL;
697 if (server && serverName) {
698 s << CFormat(_("Connected to %s %s %s")) %
699 serverName->GetStringData() %
700 server->GetIPv4Data().StringIP() %
701 (connState->HasLowID() ? _("with LowID") : _("with HighID"));
703 } else if (connState->IsConnectingED2K()) {
704 s << _("Now connecting");
705 } else {
706 s << _("Not connected");
708 s << wxT('\n') << _("Kad") << wxT(": ");
709 if (connState->IsKadRunning()) {
710 if (connState->IsConnectedKademlia()) {
711 s << _("Connected") << wxT(" (");
712 if (connState->IsKadFirewalled()) {
713 s << _("firewalled");
714 } else {
715 s << _("ok");
717 s << wxT(')');
718 } else {
719 s << _("Not connected");
721 } else {
722 s << _("Not running");
724 s << wxT('\n');
726 const CECTag *tmpTag;
727 if ((tmpTag = response->GetTagByName(EC_TAG_STATS_DL_SPEED)) != 0) {
728 s << CFormat(_("\nDownload:\t%s")) % CastItoSpeed(tmpTag->GetInt());
730 if ((tmpTag = response->GetTagByName(EC_TAG_STATS_UL_SPEED)) != 0) {
731 s << CFormat(_("\nUpload:\t%s")) % CastItoSpeed(tmpTag->GetInt());
733 if ((tmpTag = response->GetTagByName(EC_TAG_STATS_UL_QUEUE_LEN)) != 0) {
734 s << CFormat(_("\nClients in queue:\t%d\n")) % tmpTag->GetInt();
736 if ((tmpTag = response->GetTagByName(EC_TAG_STATS_TOTAL_SRC_COUNT)) != 0) {
737 s << CFormat(_("\nTotal sources:\t%d\n")) % tmpTag->GetInt();
739 break;
741 case EC_OP_DLOAD_QUEUE:
742 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
743 CEC_PartFile_Tag *tag = (CEC_PartFile_Tag *) & *it;
744 uint64 filesize, donesize;
745 filesize = tag->SizeFull();
746 donesize = tag->SizeDone();
747 s << tag->FileHashString() << wxT(" ") <<
748 tag->FileName() <<
749 wxString::Format(wxT("\n\t [%.1f%%] %4i/%4i "),
750 ((float)donesize) / ((float)filesize)*100.0,
751 (int)tag->SourceCount() - (int)tag->SourceNotCurrCount(),
752 (int)tag->SourceCount()) <<
753 ((int)tag->SourceCountA4AF() ? wxString::Format(wxT("+%2.2i "),(int)tag->SourceCountA4AF()) : wxString(wxT(" "))) <<
754 ((int)tag->SourceXferCount() ? wxString::Format(wxT("(%2.2i) - "),(int)tag->SourceXferCount()) : wxString(wxT(" - "))) <<
755 tag->GetFileStatusString();
756 s << wxT(" - ") << tag->PartMetName();
757 if (tag->DownPrio() < 10) {
758 s << wxT(" - ") << PriorityToStr((int)tag->DownPrio(), 0);
759 } else {
760 s << wxT(" - ") << PriorityToStr((tag->DownPrio() - 10), 1);
762 if ( tag->SourceXferCount() > 0) {
763 s << wxT(" - ") + CastItoSpeed(tag->Speed());
765 s << wxT("\n");
767 break;
768 case EC_OP_ULOAD_QUEUE:
769 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
770 const CECTag *tag = & *it;
771 const CECTag *clientName = tag->GetTagByName(EC_TAG_CLIENT_NAME);
772 const CECTag *partfileName = tag->GetTagByName(EC_TAG_PARTFILE_NAME);
773 const CECTag *partfileSizeXfer = tag->GetTagByName(EC_TAG_PARTFILE_SIZE_XFER);
774 const CECTag *partfileSpeed = tag->GetTagByName(EC_TAG_CLIENT_UP_SPEED);
775 if (clientName && partfileName && partfileSizeXfer && partfileSpeed) {
776 s << wxT("\n") <<
777 CFormat(wxT("%10u ")) % tag->GetInt() <<
778 clientName->GetStringData() << wxT(" ") <<
779 partfileName->GetStringData() << wxT(" ") <<
780 CastItoXBytes(partfileSizeXfer->GetInt()) << wxT(" ") <<
781 CastItoSpeed(partfileSpeed->GetInt());
784 break;
785 case EC_OP_LOG:
786 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
787 const CECTag &tag = *it;
788 s << tag.GetStringData() << wxT("\n");
790 break;
791 case EC_OP_SERVER_LIST:
792 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
793 const CECTag &tag = *it;
794 const CECTag *serverName = tag.GetTagByName(EC_TAG_SERVER_NAME);
795 if (serverName) {
796 wxString ip = tag.GetIPv4Data().StringIP();
797 ip.Append(' ', 24 - ip.Length());
798 s << ip << serverName->GetStringData() << wxT("\n");
801 break;
802 case EC_OP_STATSTREE:
803 s << StatTree2Text((CEC_StatTree_Node_Tag*)response->GetTagByName(EC_TAG_STATTREE_NODE), 0);
804 break;
806 case EC_OP_SEARCH_RESULTS:
808 int i = 0;
809 m_Results_map.clear();
810 s << CFormat(_("Number of search results: %i\n")) % response->GetTagCount();
811 for (CECPacket::const_iterator it = response->begin(); it != response->end(); it++) {
812 CEC_SearchFile_Tag *tag = (CEC_SearchFile_Tag *) & *it;
813 //printf("Tag FileName: %s \n",(const char*)unicode2char(tag->FileName()));
814 m_Results_map[i++] = new SearchFile(tag);
816 ShowResults(m_Results_map);
817 break;
819 case EC_OP_SEARCH_PROGRESS:
820 s << _("TODO - show progress of a search");
821 // gives compilation error!!
822 // const CECTag *tab = response->GetTagByNameSafe(EC_TAG_SEARCH_STATUS);
823 //s << wxString::Format(_("Search progress: %u %% \n"),(const char*)unicode2char(tab->GetStringData()));
824 break;
825 default:
826 s << wxString::Format(_("Received an unknown reply from the server, OpCode = %#x."), response->GetOpCode());
828 Process_Answer(s);
831 void CamulecmdApp::OnInitCommandSet()
833 CCommandTree *tmp;
834 CCommandTree *tmp2;
835 CCommandTree *tmp3;
837 CaMuleExternalConnector::OnInitCommandSet();
839 m_commands.AddCommand(wxT("Status"), CMD_ID_STATUS, wxTRANSLATE("Show short status information."),
840 wxTRANSLATE("Show connection status, current up/download speeds, etc.\n"), CMD_PARAM_NEVER);
842 m_commands.AddCommand(wxT("Statistics"), CMD_ID_STATTREE, wxTRANSLATE("Show full statistics tree."),
843 wxTRANSLATE("Optionally, a number in the range 0-255 can be passed as an argument to this\ncommand, which tells how many entries of the client version subtrees should be\nshown. Passing 0 or omitting it means 'unlimited'.\n\nExample: 'statistics 5' will show only the top 5 versions for each client type.\n"));
845 m_commands.AddCommand(wxT("Shutdown"), CMD_ID_SHUTDOWN, wxTRANSLATE("Shut down aMule."),
846 wxTRANSLATE("Shut down the remote running core (amule/amuled).\nThis will also shut down the text client, since it is unusable without a\nrunning core.\n"), CMD_PARAM_NEVER);
848 tmp = m_commands.AddCommand(wxT("Reload"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Reload the given object."), wxEmptyString, CMD_PARAM_NEVER);
849 tmp->AddCommand(wxT("Shared"), CMD_ID_RELOAD_SHARED, wxTRANSLATE("Reload shared files list."), wxEmptyString, CMD_PARAM_NEVER);
851 tmp2 = tmp->AddCommand(wxT("IPFilter"), CMD_ID_RELOAD_IPFILTER_LOCAL, wxTRANSLATE("Reload IP filtering table."), wxEmptyString, CMD_PARAM_OPTIONAL);
852 tmp2->AddCommand(wxT("File"), CMD_ID_RELOAD_IPFILTER_LOCAL, wxTRANSLATE("Reload current IP filtering table."), wxEmptyString, CMD_PARAM_NEVER);
853 tmp2->AddCommand(wxT("Net"), CMD_ID_RELOAD_IPFILTER_NET, wxTRANSLATE("Update IP filtering table from URL."),
854 wxTRANSLATE("If URL is omitted the URL from the preferences is used."), CMD_PARAM_OPTIONAL);
856 tmp = m_commands.AddCommand(wxT("Connect"), CMD_ID_CONNECT, wxTRANSLATE("Connect to the network."),
857 wxTRANSLATE("This will connect to all networks that are enabled in Preferences.\nYou may also optionally specify a server address in IP:Port form, to connect to\nthat server only. The IP must be a dotted decimal IPv4 address,\nor a resolvable DNS name."), CMD_PARAM_OPTIONAL);
858 tmp->AddCommand(wxT("ED2K"), CMD_ID_CONNECT_ED2K, wxTRANSLATE("Connect to eD2k only."), wxEmptyString, CMD_PARAM_NEVER);
859 tmp->AddCommand(wxT("Kad"), CMD_ID_CONNECT_KAD, wxTRANSLATE("Connect to Kad only."), wxEmptyString, CMD_PARAM_NEVER);
861 tmp = m_commands.AddCommand(wxT("Disconnect"), CMD_ID_DISCONNECT, wxTRANSLATE("Disconnect from the network."),
862 wxTRANSLATE("This will disconnect from all networks that are currently connected.\n"), CMD_PARAM_NEVER);
863 tmp->AddCommand(wxT("ED2K"), CMD_ID_DISCONNECT_ED2K, wxTRANSLATE("Disconnect from eD2k only."), wxEmptyString, CMD_PARAM_NEVER);
864 tmp->AddCommand(wxT("Kad"), CMD_ID_DISCONNECT_KAD, wxTRANSLATE("Disconnect from Kad only."), wxEmptyString, CMD_PARAM_NEVER);
866 m_commands.AddCommand(wxT("Add"), CMD_ID_ADDLINK, wxTRANSLATE("Add an eD2k or magnet link to core."),
867 wxTRANSLATE("The eD2k link to be added can be:\n*) a file link (ed2k://|file|...), it will be added to the download queue,\n*) a server link (ed2k://|server|...), it will be added to the server list,\n*) or a serverlist link, in which case all servers in the list will be added to the\n server list.\n\nThe magnet link must contain the eD2k hash and file length.\n"), CMD_PARAM_ALWAYS);
869 tmp = m_commands.AddCommand(wxT("Set"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Set a preference value."),
870 wxEmptyString, CMD_PARAM_NEVER);
872 tmp2 = tmp->AddCommand(wxT("IPFilter"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Set IP filtering preferences."), wxEmptyString, CMD_PARAM_NEVER);
873 tmp2->AddCommand(wxT("On"), CMD_ID_SET_IPFILTER_ON, wxTRANSLATE("Turn IP filtering on for both clients and servers."), wxEmptyString, CMD_PARAM_NEVER);
874 tmp2->AddCommand(wxT("Off"), CMD_ID_SET_IPFILTER_OFF, wxTRANSLATE("Turn IP filtering off for both clients and servers."), wxEmptyString, CMD_PARAM_NEVER);
875 tmp3 = tmp2->AddCommand(wxT("Clients"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Enable/Disable IP filtering for clients."), wxEmptyString, CMD_PARAM_NEVER);
876 tmp3->AddCommand(wxT("On"), CMD_ID_SET_IPFILTER_CLIENTS_ON, wxTRANSLATE("Turn IP filtering on for clients."), wxEmptyString, CMD_PARAM_NEVER);
877 tmp3->AddCommand(wxT("Off"), CMD_ID_SET_IPFILTER_CLIENTS_OFF, wxTRANSLATE("Turn IP filtering off for clients."), wxEmptyString, CMD_PARAM_NEVER);
878 tmp3 = tmp2->AddCommand(wxT("Servers"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Enable/Disable IP filtering for servers."), wxEmptyString, CMD_PARAM_NEVER);
879 tmp3->AddCommand(wxT("On"), CMD_ID_SET_IPFILTER_SERVERS_ON, wxTRANSLATE("Turn IP filtering on for servers."), wxEmptyString, CMD_PARAM_NEVER);
880 tmp3->AddCommand(wxT("Off"), CMD_ID_SET_IPFILTER_SERVERS_OFF, wxTRANSLATE("Turn IP filtering off for servers."), wxEmptyString, CMD_PARAM_NEVER);
881 tmp2->AddCommand(wxT("Level"), CMD_ID_SET_IPFILTER_LEVEL, wxTRANSLATE("Select IP filtering level."),
882 wxTRANSLATE("Valid filtering levels are in the range 0-255, and it's default (initial)\nvalue is 127.\n"), CMD_PARAM_ALWAYS);
884 tmp2 = tmp->AddCommand(wxT("BwLimit"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Set bandwidth limits."),
885 wxTRANSLATE("The value given to these commands has to be in kilobytes/sec.\n"), CMD_PARAM_NEVER);
886 tmp2->AddCommand(wxT("Up"), CMD_ID_SET_BWLIMIT_UP, wxTRANSLATE("Set upload bandwidth limit."),
887 wxT("The given value must be in kilobytes/sec.\n"), CMD_PARAM_ALWAYS);
888 tmp2->AddCommand(wxT("Down"), CMD_ID_SET_BWLIMIT_DOWN, wxTRANSLATE("Set download bandwidth limit."),
889 wxT("The given value must be in kilobytes/sec.\n"), CMD_PARAM_ALWAYS);
891 tmp = m_commands.AddCommand(wxT("Get"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Get and display a preference value."),
892 wxEmptyString, CMD_PARAM_NEVER);
894 tmp2 = tmp->AddCommand(wxT("IPFilter"), CMD_ID_GET_IPFILTER, wxTRANSLATE("Get IP filtering preferences."), wxEmptyString, CMD_PARAM_NEVER);
895 tmp3 = tmp2->AddCommand(wxT("State"), CMD_ID_GET_IPFILTER_STATE, wxTRANSLATE("Get IP filtering state for both clients and servers."), wxEmptyString, CMD_PARAM_NEVER);
896 tmp3->AddCommand(wxT("Clients"), CMD_ID_GET_IPFILTER_STATE_CLIENTS, wxTRANSLATE("Get IP filtering state for clients only."), wxEmptyString, CMD_PARAM_NEVER);
897 tmp3->AddCommand(wxT("Servers"), CMD_ID_GET_IPFILTER_STATE_SERVERS, wxTRANSLATE("Get IP filtering state for servers only."), wxEmptyString, CMD_PARAM_NEVER);
898 tmp2->AddCommand(wxT("Level"), CMD_ID_GET_IPFILTER_LEVEL, wxTRANSLATE("Get IP filtering level."), wxEmptyString, CMD_PARAM_NEVER);
900 tmp->AddCommand(wxT("BwLimits"), CMD_ID_GET_BWLIMITS, wxTRANSLATE("Get bandwidth limits."), wxEmptyString, CMD_PARAM_NEVER);
902 tmp = m_commands.AddCommand(wxT("Search"), CMD_ID_SEARCH, wxTRANSLATE("Execute a search."),
903 wxTRANSLATE("A search type has to be specified by giving the type:\n GLOBAL\n LOCAL\n KAD\nExample: 'search kad file' will execute a kad search for \"file\".\n"), CMD_PARAM_ALWAYS);
904 tmp->AddCommand(wxT("global"), CMD_ID_SEARCH_GLOBAL, wxTRANSLATE("Execute a global search."), wxEmptyString, CMD_PARAM_ALWAYS);
905 tmp->AddCommand(wxT("local"), CMD_ID_SEARCH_LOCAL, wxTRANSLATE("Execute a local search"), wxEmptyString, CMD_PARAM_ALWAYS);
906 tmp->AddCommand(wxT("kad"), CMD_ID_SEARCH_KAD, wxTRANSLATE("Execute a kad search"), wxEmptyString, CMD_PARAM_ALWAYS);
908 m_commands.AddCommand(wxT("Results"), CMD_ID_SEARCH_RESULTS, wxTRANSLATE("Show the results of the last search."),
909 wxTRANSLATE("Return the results of the previous search.\n"), CMD_PARAM_NEVER);
911 m_commands.AddCommand(wxT("Progress"), CMD_ID_SEARCH_PROGRESS, wxTRANSLATE("Show the progress of a search."),
912 wxTRANSLATE("Show the progress of a search.\n"), CMD_PARAM_NEVER);
914 m_commands.AddCommand(wxT("Download"), CMD_ID_DOWNLOAD, wxTRANSLATE("Start downloading a file"),
915 wxTRANSLATE("The number of a file from the last search has to be given.\nExample: 'download 12' will start to download the file with the number 12 of the previous search.\n"), CMD_PARAM_ALWAYS);
919 // TODO: These commands below need implementation and/or rewrite!
922 m_commands.AddCommand(wxT("Pause"), CMD_ID_PAUSE, wxTRANSLATE("Pause download."),
923 wxEmptyString, CMD_PARAM_ALWAYS);
925 m_commands.AddCommand(wxT("Resume"), CMD_ID_RESUME, wxTRANSLATE("Resume download."),
926 wxEmptyString, CMD_PARAM_ALWAYS);
928 m_commands.AddCommand(wxT("Cancel"), CMD_ID_CANCEL, wxTRANSLATE("Cancel download."),
929 wxEmptyString, CMD_PARAM_ALWAYS);
931 tmp = m_commands.AddCommand(wxT("Priority"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Set download priority."),
932 wxTRANSLATE("Set priority of a download to Low, Normal, High or Auto.\n"), CMD_PARAM_ALWAYS);
933 tmp->AddCommand(wxT("Low"), CMD_ID_PRIORITY_LOW, wxTRANSLATE("Set priority to low."), wxEmptyString, CMD_PARAM_ALWAYS);
934 tmp->AddCommand(wxT("Normal"), CMD_ID_PRIORITY_NORMAL, wxTRANSLATE("Set priority to normal."), wxEmptyString, CMD_PARAM_ALWAYS);
935 tmp->AddCommand(wxT("High"), CMD_ID_PRIORITY_HIGH, wxTRANSLATE("Set priority to high."), wxEmptyString, CMD_PARAM_ALWAYS);
936 tmp->AddCommand(wxT("Auto"), CMD_ID_PRIORITY_AUTO, wxTRANSLATE("Set priority to auto."), wxEmptyString, CMD_PARAM_ALWAYS);
938 tmp = m_commands.AddCommand(wxT("Show"), CMD_ERR_INCOMPLETE, wxTRANSLATE("Show queues/lists."),
939 wxTRANSLATE("Show upload/download queue, server list or shared files list.\n"), CMD_PARAM_ALWAYS);
940 tmp->AddCommand(wxT("UL"), CMD_ID_SHOW_UL, wxTRANSLATE("Show upload queue."), wxEmptyString, CMD_PARAM_NEVER);
941 tmp->AddCommand(wxT("DL"), CMD_ID_SHOW_DL, wxTRANSLATE("Show download queue."), wxEmptyString, CMD_PARAM_NEVER);
942 tmp->AddCommand(wxT("Log"), CMD_ID_SHOW_LOG, wxTRANSLATE("Show log."), wxEmptyString, CMD_PARAM_NEVER);
943 tmp->AddCommand(wxT("Servers"), CMD_ID_SHOW_SERVERS, wxTRANSLATE("Show servers list."), wxEmptyString, CMD_PARAM_NEVER);
944 // tmp->AddCommand(wxT("Shared"), CMD_ID_SHOW_SHARED, wxTRANSLATE("Show shared files list."), wxEmptyString, CMD_PARAM_NEVER);
946 m_commands.AddCommand(wxT("Reset"), CMD_ID_RESET_LOG, wxTRANSLATE("Reset log."), wxEmptyString, CMD_PARAM_NEVER);
949 // Deprecated commands, kept for backwards compatibility only.
952 #define DEPRECATED(OLDCMD, ID, NEWCMD, PARAM) \
953 m_commands.AddCommand(wxT(OLDCMD), CMD_ID_##ID | CMD_DEPRECATED, CFormat(wxTRANSLATE("Deprecated command, use '%s' instead.")) % wxT(NEWCMD), \
954 CFormat(wxTRANSLATE("This is a deprecated command, and may be removed in the future.\nUse '%s' instead.\n")) % wxT(NEWCMD), CMD_PARAM_##PARAM)
956 DEPRECATED("Stats", STATUS, "Status", NEVER);
957 DEPRECATED("SetIPFilter", SET_IPFILTER, "Set IPFilter", OPTIONAL);
958 DEPRECATED("GetIPLevel", GET_IPFILTER_LEVEL, "Get IPFilter Level", NEVER);
959 DEPRECATED("SetIPLevel", SET_IPFILTER_LEVEL, "Set IPFilter Level", ALWAYS);
960 DEPRECATED("IPLevel", SET_IPFILTER_LEVEL, "Get/Set IPFilter Level", OPTIONAL);
961 DEPRECATED("Servers", SHOW_SERVERS, "Show Servers", NEVER);
962 DEPRECATED("GetBWLimits", GET_BWLIMITS, "Get BwLimits", NEVER);
963 DEPRECATED("SetUpBWLimit", SET_BWLIMIT_UP, "Set BwLimit Up", ALWAYS);
964 DEPRECATED("SetDownBWLimit", SET_BWLIMIT_DOWN, "Set BwLimit Down", ALWAYS);
967 int CamulecmdApp::OnRun()
969 ConnectAndRun(wxT("aMulecmd"), wxT(VERSION));
970 return 0;
973 // Dummy functions for EC logging
974 bool ECLogIsEnabled()
976 return false;
979 void DoECLogLine(const wxString &)
982 // File_checked_for_headers