Changeset 6372
- Timestamp:
- 07/01/08 05:59:12 (2 months ago)
- Location:
- trunk/console/src
- Files:
-
- 6 modified
-
console.cpp (modified) (12 diffs)
-
console.h (modified) (2 diffs)
-
console_menu.cpp (modified) (18 diffs)
-
console_print.cpp (modified) (4 diffs)
-
window.cpp (modified) (1 diff)
-
window.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/console/src/console.cpp
r6361 r6372 299 299 if (o->Password()[0] == '\0') 300 300 { 301 gUserManager.DropOwner( );301 gUserManager.DropOwner(o); 302 302 UserSelect(); 303 303 } 304 304 else 305 gUserManager.DropOwner( );305 gUserManager.DropOwner(o); 306 306 } 307 307 … … 517 517 for (unsigned short i = 0; i < MAX_CON; i++) 518 518 { 519 if (s-> Uin() == winCon[i]->nLastUin)520 winCon[i]-> nLastUin = 0;519 if (s->Id() == winCon[i]->myLastId) 520 winCon[i]->myLastId.clear(); 521 521 } 522 522 } … … 639 639 // Needs to be better dealt with... 640 640 // How's this then? 641 winMain->wprintf("Registration complete!\nYour UIN is %ld\n",642 gUserManager.OwnerUin());641 winMain->wprintf("Registration complete!\nYour UIN is %s\n", 642 gUserManager.OwnerId(LICQ_PPID).c_str()); 643 643 winMain->fProcessInput = &CLicqConsole::InputCommand; 644 644 PrintStatus(); … … 815 815 if (e->SubResult() == ICQ_TCPxACK_RETURN) 816 816 { 817 u = gUserManager.FetchUser(e-> Uin(), LOCK_R);817 u = gUserManager.FetchUser(e->Id(), e->PPID(), LOCK_R); 818 818 win->wprintf("%s is in %s mode:\n%s\n[Send \"urgent\" ('.u') to ignore]\n", 819 819 u->GetAlias(), u->StatusStr(), u->AutoResponse()); … … 822 822 else if (e->SubResult() == ICQ_TCPxACK_REFUSE) 823 823 { 824 u = gUserManager.FetchUser(e-> Uin(), LOCK_R);824 u = gUserManager.FetchUser(e->Id(), e->PPID(), LOCK_R); 825 825 win->wprintf("%s refused %s.\n", 826 826 u->GetAlias(), ue->Description()); … … 839 839 if(!ea->Accepted()) 840 840 { 841 u = gUserManager.FetchUser(e-> Uin(), LOCK_R);841 u = gUserManager.FetchUser(e->Id(), e->PPID(), LOCK_R); 842 842 win->wprintf("%s refused file: %s\n", 843 843 u->GetAlias(), ea->Response()); … … 906 906 else 907 907 { 908 u = gUserManager.FetchUser(e-> Uin(), LOCK_R);908 u = gUserManager.FetchUser(e->Id(), e->PPID(), LOCK_R); 909 909 if (u != NULL && u->Away() && u->ShowAwayMsg()) 910 910 { … … 2149 2149 { 2150 2150 *sz = '\0'; 2151 ICQOwner *o = gUserManager.FetchOwner(LOCK_W);2151 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); 2152 2152 o->SetAutoResponse(data->szRsp); 2153 gUserManager.DropOwner( );2153 gUserManager.DropOwner(o); 2154 2154 winMain->wprintf("%C%AAuto-response set.\n", 2155 2155 m_cColorInfo->nColor, m_cColorInfo->nAttr); … … 3037 3037 winMain->wprintf("Registration complete for user %s\n",data->szUin); 3038 3038 gUserManager.SetOwnerUin(atol(data->szUin)); 3039 ICQOwner *owner = gUserManager.FetchOwner(LOCK_W);3039 ICQOwner* owner = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); 3040 3040 owner->SetPassword(data->szPassword1); 3041 gUserManager.DropOwner( );3041 gUserManager.DropOwner(owner); 3042 3042 3043 3043 winMain->wprintf("Save password? (y/N) "); … … 3052 3052 break; 3053 3053 } 3054 3054 3055 3055 case STATE_QUERY: 3056 3056 { 3057 ICQOwner *o = gUserManager.FetchOwner(LOCK_W);3057 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); 3058 3058 o->SetSavePassword(tolower(cIn) == 'y'); 3059 gUserManager.DropOwner( );3060 3059 gUserManager.DropOwner(o); 3060 3061 3061 if (data->szOption[0] == '1') 3062 3062 { … … 3251 3251 winMain->state = STATE_LE; 3252 3252 3253 char sz[20];3254 3253 //TODO which owner 3255 sprintf(sz, "%lu", gUserManager.OwnerUin()); 3256 3257 winMain->data = new DataUserSelect(sz, LICQ_PPID); 3258 3259 ICQOwner *o = gUserManager.FetchOwner(LOCK_R); 3254 winMain->data = new DataUserSelect(gUserManager.OwnerId(LICQ_PPID).c_str(), LICQ_PPID); 3255 3256 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 3260 3257 winMain->wprintf("%A%CEnter your password for %s (%s):%C%Z\n", A_BOLD, 3261 3258 COLOR_GREEN, o->GetAlias(), o->IdString(), COLOR_WHITE, A_BOLD); 3262 gUserManager.DropOwner( );3259 gUserManager.DropOwner(o); 3263 3260 } 3264 3261 … … 3288 3285 case STATE_QUERY: 3289 3286 { 3290 ICQOwner *o = gUserManager.FetchOwner(LOCK_W);3287 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_W); 3291 3288 o->SetSavePassword(tolower(cIn) == 'y'); 3292 3289 o->SetPassword(data->szPassword); 3293 gUserManager.DropOwner( );3290 gUserManager.DropOwner(o); 3294 3291 3295 3292 if (winMain->data) -
trunk/console/src/console.h
r6180 r6372 11 11 #include "licq_user.h" 12 12 13 #include <string> 13 14 using namespace std; 14 15 … … 209 210 void InputUserSelect(int cIn); 210 211 bool ParseMacro(char *); 211 unsigned long GetUinFromArg(char **);212 std::string GetUserFromArg(char** p_szArg); 212 213 void SaveLastUser(const char *, unsigned long); 213 214 struct SContact GetContactFromArg(char **); -
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 } -
trunk/console/src/console_print.cpp
r6359 r6372 131 131 132 132 unsigned short nNumOwnerEvents = 0; 133 ICQOwner *o = gUserManager.FetchOwner(LOCK_R);133 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 134 134 if (o) 135 135 { 136 136 nNumOwnerEvents = o->NewMessages(); 137 gUserManager.DropOwner( );137 gUserManager.DropOwner(o); 138 138 } 139 139 … … 161 161 szLastUser = strdup("<None>"); 162 162 163 o = gUserManager.FetchOwner(L OCK_R);163 o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 164 164 wbkgdset(winStatus->Win(), COLOR_PAIR(COLOR_WHITE)); 165 165 mvwhline(winStatus->Win(), 0, 0, ACS_HLINE, COLS); … … 176 176 53, szMsgStr, 29, 53, 177 177 szLastUser, 29); 178 gUserManager.DropOwner( );179 } 180 178 gUserManager.DropOwner(o); 179 } 180 181 181 wclrtoeol(winStatus->Win()); 182 182 winStatus->RefreshWin(); … … 775 775 { 776 776 // Get the user's name 777 ICQUser *u = gUserManager.FetchUser(ftman->Uin(), LOCK_R);777 ICQUser* u = gUserManager.FetchUser(ftman->Id(), LICQ_PPID, LOCK_R); 778 778 779 779 // Make the title -
trunk/console/src/window.cpp
r6176 r6372 82 82 } 83 83 84 nLastUin = 0;84 myLastId.clear(); 85 85 sLastContact.szId = 0; 86 86 sLastContact.nPPID = 0; -
trunk/console/src/window.h
r6176 r6372 3 3 4 4 #include <iostream> 5 #include <string> 5 6 extern "C" { 6 7 #include <cdk.h> … … 69 70 InputState state; 70 71 CData *data; 71 unsigned long nLastUin;72 std::string myLastId; 72 73 struct SContact sLastContact; 73 74 unsigned short nLastHistory;
