Changeset 6461 for trunk/console

Show
Ignore:
Timestamp:
07/24/08 03:58:36 (4 months ago)
Author:
flynd
Message:

Fixed some cases where we kept a pointer to the alias string in the daemon user object. Added a few const.

Location:
trunk/console/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/console/src/console.cpp

    r6406 r6461  
    14671467 * CLicqConsole::SaveLastUser 
    14681468 *-------------------------------------------------------------------------*/ 
    1469 void CLicqConsole::SaveLastUser(const char *szId, unsigned long nPPID) 
     1469void CLicqConsole::SaveLastUser(const string& id, unsigned long nPPID) 
    14701470{ 
    14711471  // Save this as the last user 
    1472   if (winMain->sLastContact.szId == 0 || 
    1473       !(strcmp(szId, winMain->sLastContact.szId) == 0 && 
     1472  if (winMain->sLastContact.szId.empty() || 
     1473      !(id == winMain->sLastContact.szId && 
    14741474      nPPID == winMain->sLastContact.nPPID)) 
    14751475  { 
    1476     if (winMain->sLastContact.szId) 
    1477       free(winMain->sLastContact.szId); 
    14781476    winMain->sLastContact.nPPID = nPPID; 
    1479     winMain->sLastContact.szId = strdup(szId); 
     1477    winMain->sLastContact.szId = id; 
    14801478    PrintStatus(); 
    14811479  } 
  • trunk/console/src/console.h

    r6439 r6461  
    154154  void PrintFileStat(CFileTransferManager *); 
    155155  void PrintMacros(); 
    156   void PrintContactPopup(char *); 
     156  void PrintContactPopup(const char* alias); 
    157157 
    158158  static int UserListCallback(EObjectType, void *, void *, chtype); 
     
    215215  bool ParseMacro(char *); 
    216216  std::string GetUserFromArg(char** p_szArg); 
    217   void SaveLastUser(const char *, unsigned long); 
     217  void SaveLastUser(const std::string& id, unsigned long ppid); 
    218218  struct SContact GetContactFromArg(char **); 
    219219}; 
  • trunk/console/src/console_menu.cpp

    r6439 r6461  
    679679  unsigned long nPPID = 0; 
    680680  struct SContact scon; 
    681   scon.szId = NULL; 
    682681  scon.nPPID = 0; 
    683682 
     
    766765  } 
    767766  FOR_EACH_USER_END 
    768   if (scon.szId == NULL) 
     767  if (scon.szId.empty()) 
    769768  { 
    770769    winMain->wprintf("%CInvalid user: %A%s\n", COLOR_RED, A_BOLD, szAlias); 
    771     scon.szId = NULL; 
     770    scon.szId.clear(); 
    772771    scon.nPPID = (unsigned long)-1; 
    773772    return scon; 
     
    787786  struct SContact scon = GetContactFromArg(&sz); 
    788787 
    789   if (!scon.szId && scon.nPPID != (unsigned long)-1) 
     788  if (scon.szId.empty() && scon.nPPID != (unsigned long)-1) 
    790789    winMain->wprintf("%CYou must specify a user to send a message to.\n", COLOR_RED); 
    791790  else if (scon.nPPID != (unsigned long)-1) 
    792     UserCommand_Msg(scon.szId, scon.nPPID, sz); 
     791    UserCommand_Msg(scon.szId.c_str(), scon.nPPID, sz); 
    793792} 
    794793 
     
    853852 
    854853  char *sz = szArg; 
    855   char *szId = NULL; 
     854  string szId; 
    856855  unsigned long nPPID = (unsigned long)-1; 
    857856  struct SContact scon = GetContactFromArg(&sz); 
    858    
    859   if (scon.szId == 0) 
     857 
     858  if (scon.szId.empty()) 
    860859  { 
    861860    // Do nothing if there are no events pending 
     
    884883    } 
    885884    FOR_EACH_USER_END 
    886     if (szId != NULL) 
    887     { 
    888       UserCommand_View(szId, nPPID, NULL); 
    889     } 
    890   } 
    891   else if (scon.szId != NULL) 
    892   { 
    893     UserCommand_View(scon.szId, scon.nPPID, sz); 
     885    if (!szId.empty()) 
     886    { 
     887      UserCommand_View(szId.c_str(), nPPID, NULL); 
     888    } 
     889  } 
     890  else if (!scon.szId.empty()) 
     891  { 
     892    UserCommand_View(scon.szId.c_str(), scon.nPPID, sz); 
    894893  } 
    895894 
     
    988987  struct SContact scon = GetContactFromArg(&sz); 
    989988 
    990   if (gUserManager.FindOwner(scon.szId, scon.nPPID)) 
     989  if (gUserManager.FindOwner(scon.szId.c_str(), scon.nPPID)) 
    991990    winMain->wprintf("%CYou can't remove yourself!\n", COLOR_RED); 
    992   else if (!scon.szId && scon.nPPID != (unsigned long)-1) 
     991  else if (scon.szId.empty() && scon.nPPID != (unsigned long)-1) 
    993992    winMain->wprintf("%CYou must specify a user to remove.\n", COLOR_RED); 
    994993  else 
    995     UserCommand_Remove(scon.szId, scon.nPPID, sz); 
     994    UserCommand_Remove(scon.szId.c_str(), scon.nPPID, sz); 
    996995} 
    997996 
     
    10051004  struct SContact scon = GetContactFromArg(&sz); 
    10061005 
    1007   if (!scon.szId && scon.nPPID != (unsigned long)-1) 
     1006  if (scon.szId.empty() && scon.nPPID != (unsigned long)-1) 
    10081007    winMain->wprintf("%CYou must specify a user to view history.\n", COLOR_RED); 
    10091008  else if (scon.nPPID != (unsigned long)-1) 
    1010     UserCommand_History(scon.szId, scon.nPPID, sz); 
     1009    UserCommand_History(scon.szId.c_str(), scon.nPPID, sz); 
    10111010} 
    10121011 
  • trunk/console/src/console_print.cpp

    r6439 r6461  
    149149    strcpy(szMsgStr, "No Messages"); 
    150150 
    151   if (winMain->sLastContact.szId != 0) 
    152   { 
    153     ICQUser *u = gUserManager.FetchUser(winMain->sLastContact.szId, 
     151  if (!winMain->sLastContact.szId.empty()) 
     152  { 
     153    ICQUser* u = gUserManager.FetchUser(winMain->sLastContact.szId.c_str(), 
    154154      winMain->sLastContact.nPPID, LOCK_R); 
    155155    if (u == NULL) 
     
    466466 * CLicqConsole::PrintContactPopup 
    467467 *-------------------------------------------------------------------------*/ 
    468 void CLicqConsole::PrintContactPopup(char *_szAlias) 
     468void CLicqConsole::PrintContactPopup(const char* _szAlias) 
    469469{ 
    470470  char title[256]; 
  • trunk/console/src/window.cpp

    r6372 r6461  
    8383 
    8484  myLastId.clear(); 
    85   sLastContact.szId = 0; 
    8685  sLastContact.nPPID = 0; 
    8786  nLastHistory = 1; 
     
    9089CWindow::~CWindow() 
    9190{ 
    92    if (sLastContact.szId) 
    93      free(sLastContact.szId); 
    9491   delwin(win); 
    9592} 
  • trunk/console/src/window.h

    r6372 r6461  
    3838struct SContact 
    3939{ 
    40   char *szId; 
     40  std::string szId; 
    4141  unsigned long nPPID; 
    4242};