Changeset 6372 for trunk/console/src/console_menu.cpp
- Timestamp:
- 07/01/08 05:59:12 (5 months ago)
- Files:
-
- 1 modified
-
trunk/console/src/console_menu.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/console/src/console_menu.cpp
r6361 r6372 3 3 4 4 #include <ctype.h> 5 #include <string> 6 7 using std::string; 5 8 6 9 const unsigned short NUM_COMMANDS = 24; … … 539 542 if (nStatus == ICQ_STATUS_OFFLINE) 540 543 { 541 gUserManager.DropOwner( nPPID);544 gUserManager.DropOwner(o); 542 545 licqDaemon->ProtoLogoff(nPPID); 543 546 continue; … … 548 551 // call the right function 549 552 bool b = o->StatusOffline(); 550 gUserManager.DropOwner( nPPID);553 gUserManager.DropOwner(o); 551 554 if (b) 552 555 { … … 591 594 * CLicqConsole::GetUinFromArg 592 595 *-------------------------------------------------------------------------*/ 593 unsigned long CLicqConsole::GetUinFromArg(char **p_szArg)596 string CLicqConsole::GetUserFromArg(char** p_szArg) 594 597 { 595 598 char *szAlias, *szCmd; 596 unsigned long nUin = 0;599 string id; 597 600 bool bCheckUin = true; 598 601 char *szArg = *p_szArg; … … 611 614 { 612 615 winMain->wprintf("%CUnbalanced quotes.\n", COLOR_RED); 613 return (unsigned long)-1;616 return "-"; 614 617 } 615 618 *szCmd++ = '\0'; … … 619 622 { 620 623 *p_szArg = NULL; 621 return gUserManager.Owner Uin();624 return gUserManager.OwnerId(LICQ_PPID); 622 625 } 623 626 else if (szArg[0] == '$') 624 627 { 625 628 *p_szArg = NULL; 626 return winMain-> nLastUin;629 return winMain->myLastId; 627 630 } 628 631 else … … 639 642 *p_szArg = szCmd; 640 643 641 // Find the user 642 // See if all the chars are digits 643 if (bCheckUin) 644 { 645 char *sz = szAlias; 646 while (isdigit(*sz)) sz++; 647 if (*sz == '\0') nUin = atol(szAlias); 648 } 649 650 if (nUin == 0) 651 { 652 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 653 { 654 if (strcasecmp(szAlias, pUser->GetAlias()) == 0) 655 { 656 nUin = pUser->Uin(); 657 FOR_EACH_USER_BREAK; 658 } 659 } 660 FOR_EACH_PROTO_USER_END 661 if (nUin == 0) 662 { 663 winMain->wprintf("%CInvalid user: %A%s\n", COLOR_RED, A_BOLD, szAlias); 664 return (unsigned long)-1; 665 } 666 } 667 else 668 { 669 if (!gUserManager.IsOnList(nUin)) 670 { 671 winMain->wprintf("%CInvalid uin: %A%lu\n", COLOR_RED, A_BOLD, nUin); 672 return (unsigned long)-1; 673 } 644 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 645 { 646 if (strcasecmp(szAlias, pUser->GetAlias()) == 0 || 647 (bCheckUin && strcasecmp(szAlias, pUser->IdString()) == 0)) 648 { 649 id = pUser->IdString(); 650 FOR_EACH_USER_BREAK; 651 } 652 } 653 FOR_EACH_PROTO_USER_END 654 655 if (id.empty()) 656 { 657 winMain->wprintf("%CInvalid user: %A%s\n", COLOR_RED, A_BOLD, szAlias); 658 return "-"; 674 659 } 675 660 676 661 // Save this as the last user 677 if (winMain-> nLastUin != nUin)678 { 679 winMain-> nLastUin = nUin;662 if (winMain->myLastId != id) 663 { 664 winMain->myLastId = id; 680 665 PrintStatus(); 681 666 } 682 667 683 return nUin;668 return id; 684 669 } 685 670 … … 738 723 { 739 724 *p_szArg = NULL; 740 ICQOwner *o = gUserManager.FetchOwner(LOCK_R);725 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 741 726 scon.szId = o->IdString(); 742 scon.nPPID = o->PPID(); 743 gUserManager.DropOwner( );727 scon.nPPID = o->PPID(); 728 gUserManager.DropOwner(o); 744 729 return scon; 745 730 } … … 815 800 { 816 801 char *sz = szArg; 817 unsigned long nUin = GetUinFromArg(&sz);818 819 if ( nUin == gUserManager.OwnerUin())802 string id = GetUserFromArg(&sz); 803 804 if (gUserManager.FindOwner(id.c_str(), LICQ_PPID) != NULL) 820 805 winMain->wprintf("%CSetting personal info not implemented yet.\n", COLOR_RED); 821 else if (nUin == 0) { 822 char szUin[24]; 823 sprintf(szArg, "%lu", gUserManager.OwnerUin()); 824 UserCommand_Info(szUin, LICQ_PPID, sz); 825 } else if (nUin != (unsigned long)-1) 826 sprintf(szArg, "%lu", nUin); 827 UserCommand_Info(szArg, LICQ_PPID, sz); 806 else if (id.empty()) 807 UserCommand_Info(gUserManager.OwnerId(LICQ_PPID).c_str(), LICQ_PPID, sz); 808 else if (id != "-") 809 UserCommand_Info(id.c_str(), LICQ_PPID, sz); 828 810 } 829 811 … … 836 818 { 837 819 char *sz = szArg; 838 unsigned long nUin = GetUinFromArg(&sz);839 840 if ( nUin == gUserManager.OwnerUin())820 string id = GetUserFromArg(&sz); 821 822 if (gUserManager.FindOwner(id.c_str(), LICQ_PPID) != NULL) 841 823 winMain->wprintf("%CYou can't send URLs to yourself!\n", COLOR_RED); 842 else if ( nUin == 0)824 else if (id.empty()) 843 825 winMain->wprintf("%CYou must specify a user to send a URL to.\n", COLOR_RED); 844 else if (nUin != (unsigned long)-1) 845 sprintf(szArg, "%lu", nUin); 846 UserCommand_Url(szArg, LICQ_PPID, sz); 847 826 else if (id != "-") 827 UserCommand_Url(id.c_str(), LICQ_PPID, sz); 848 828 } 849 829 … … 856 836 { 857 837 char *sz = szArg; 858 unsigned long nUin = GetUinFromArg(&sz);859 860 if ( nUin == 0)838 string id = GetUserFromArg(&sz); 839 840 if (id.empty()) 861 841 winMain->wprintf("%CInvalid user\n", COLOR_RED); 862 else if (nUin != (unsigned long)-1) 863 { 864 sprintf(szArg, "%lu", nUin); 865 UserCommand_Sms(szArg, LICQ_PPID, sz); 866 } 842 else if (id != "-") 843 UserCommand_Sms(id.c_str(), LICQ_PPID, sz); 867 844 } 868 845 … … 887 864 ICQOwner *o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 888 865 unsigned short nNumMsg = o->NewMessages(); 889 gUserManager.DropOwner( );866 gUserManager.DropOwner(o); 890 867 if (nNumMsg > 0) 891 868 { 892 869 //TODO which owner? 893 char szUin[24]; 894 sprintf(szUin, "%lu", gUserManager.OwnerUin()); 895 UserCommand_View(szUin, LICQ_PPID, NULL); 870 UserCommand_View(gUserManager.OwnerId(LICQ_PPID).c_str(), LICQ_PPID, NULL); 896 871 return; 897 872 } … … 927 902 { 928 903 char *sz = szArg; 929 unsigned long nUin = GetUinFromArg(&sz);930 931 if ( nUin == gUserManager.OwnerUin())904 string id = GetUserFromArg(&sz); 905 906 if (gUserManager.FindOwner(id.c_str(), LICQ_PPID) != NULL) 932 907 winMain->wprintf("%CYou can't establish a secure connection to yourself!\n", COLOR_RED); 933 else if ( nUin == 0)908 else if (id.empty()) 934 909 winMain->wprintf("%CYou must specify a user to talk to.\n", COLOR_RED); 935 else if (nUin != (unsigned long)-1) 936 { 937 sprintf(szArg, "%lu", nUin); 938 UserCommand_Secure(szArg, LICQ_PPID, sz); 939 } 910 else if (id != "-") 911 UserCommand_Secure(id.c_str(), LICQ_PPID, sz); 940 912 } 941 913 … … 947 919 { 948 920 char *sz = szArg; 949 unsigned long nUin = GetUinFromArg(&sz);950 951 if ( nUin == gUserManager.OwnerUin())921 string id = GetUserFromArg(&sz); 922 923 if (gUserManager.FindOwner(id.c_str(), LICQ_PPID) != NULL) 952 924 winMain->wprintf("%CYou can't send files to yourself!\n", COLOR_RED); 953 else if ( nUin == 0)925 else if (id.empty()) 954 926 { 955 927 bool bNum = false; … … 970 942 } 971 943 } 972 else if (nUin != (unsigned long)-1) 973 { 974 sprintf(szArg, "%lu", nUin); 975 UserCommand_SendFile(szArg, LICQ_PPID, sz); 976 } 944 else if (id != "-") 945 UserCommand_SendFile(id.c_str(), LICQ_PPID, sz); 977 946 } 978 947 … … 984 953 { 985 954 char *sz = szArg; 986 unsigned long nUin = GetUinFromArg(&sz);987 988 if ( nUin == gUserManager.OwnerUin())955 string id = GetUserFromArg(&sz); 956 957 if (gUserManager.FindOwner(id.c_str(), LICQ_PPID) != NULL) 989 958 { 990 959 wattron(winMain->Win(), A_BOLD); … … 995 964 winMain->wprintf("%B%CAuto response:\n%b%s\n", 996 965 COLOR_WHITE, o->AutoResponse()); 997 gUserManager.DropOwner( );966 gUserManager.DropOwner(o); 998 967 wattron(winMain->Win(), A_BOLD); 999 968 for (unsigned short i = 0; i < winMain->Cols() - 10; i++) … … 1003 972 wattroff(winMain->Win(), A_BOLD); 1004 973 } 1005 else if ( nUin == 0)974 else if (id.empty()) 1006 975 UserCommand_SetAutoResponse(NULL, LICQ_PPID, sz); 1007 else if ( nUin != (unsigned long)-1)976 else if (id != "-") 1008 977 UserCommand_FetchAutoResponse(NULL, LICQ_PPID, sz); 1009 978 }
