Changeset 4197 for trunk/console

Show
Ignore:
Timestamp:
08/27/05 08:17:33 (3 years ago)
Author:
phatfil
Message:

this does three things:
- saves the last user correctly when using the F10 menu
- adds support for specifying a users protocol (when not using the F10 menu) - ie. /message foo.Licq or /message foo.MSN (sf task id 115776)
- removes \t's from source

Location:
trunk/console/src
Files:
5 modified

Legend:

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

    r4192 r4197  
    257257    scrollok(winCon[i]->Win(), true); 
    258258    winCon[i]->fProcessInput = &CLicqConsole::InputCommand; 
    259     winCon[i]->data = NULL; 
     259    winCon[i]->data = NULL; 
    260260  } 
    261261  winCon[0]->fProcessInput = &CLicqConsole::InputLogWindow; 
     
    14521452} 
    14531453 
    1454  
    1455  
     1454/*--------------------------------------------------------------------------- 
     1455 * CLicqConsole::SaveLastUser 
     1456 *-------------------------------------------------------------------------*/ 
     1457void CLicqConsole::SaveLastUser(const char *szId, unsigned long nPPID) 
     1458{ 
     1459  // Save this as the last user 
     1460  if (winMain->sLastContact.szId == 0 || 
     1461      !(strcmp(szId, winMain->sLastContact.szId) == 0 && 
     1462      nPPID == winMain->sLastContact.nPPID)) 
     1463  { 
     1464    if (winMain->sLastContact.szId) 
     1465      free(winMain->sLastContact.szId); 
     1466    winMain->sLastContact.nPPID = nPPID; 
     1467    winMain->sLastContact.szId = strdup(szId); 
     1468    PrintStatus(); 
     1469  } 
     1470} 
    14561471 
    14571472/*--------------------------------------------------------------------------- 
     
    20722087 
    20732088      winMain->event = licqDaemon->icqFileTransfer(strtoul(data->szId, (char **)NULL, 10), 
    2074               data->szFileName, data->szDescription, lFileList, ICQ_TCPxMSG_NORMAL, 
     2089              data->szFileName, data->szDescription, lFileList, ICQ_TCPxMSG_NORMAL, 
    20752090                       !bDirect); 
    20762091      break; 
     
    29602975            } 
    29612976 
    2962         winMain->state = STATE_QUERY; 
    2963         winMain->wprintf("\nSave password? (y/N) "); 
     2977            winMain->state = STATE_QUERY; 
     2978            winMain->wprintf("\nSave password? (y/N) "); 
    29642979          } 
    29652980          break; 
     
    30083023 
    30093024            // Passwords match if we are this far, now set up the new user 
    3010         winMain->wprintf("Registration complete for user %s\n",data->szUin); 
     3025            winMain->wprintf("Registration complete for user %s\n",data->szUin); 
    30113026            gUserManager.SetOwnerUin(atol(data->szUin)); 
    30123027            ICQOwner *owner = gUserManager.FetchOwner(LOCK_W); 
     
    30143029            gUserManager.DropOwner(); 
    30153030 
    3016         winMain->wprintf("Save password? (y/N) "); 
    3017         winMain->state = STATE_QUERY; 
     3031            winMain->wprintf("Save password? (y/N) "); 
     3032            winMain->state = STATE_QUERY; 
    30183033          } 
    30193034          break; 
  • trunk/console/src/console.h

    r4175 r4197  
    209209  bool ParseMacro(char *); 
    210210  unsigned long GetUinFromArg(char **); 
     211  void SaveLastUser(const char *, unsigned long); 
    211212  struct SContact GetContactFromArg(char **); 
    212213}; 
  • trunk/console/src/console_menu.cpp

    r4143 r4197  
    1111    "Force a refresh of the contact list." }, 
    1212  { "console", &CLicqConsole::MenuSwitchConsole, NULL, 
    13     " %B%ccons%bole <num>", 
    14     "Switch to a console." }, 
     13    " %B%ccons%bole <num>", 
     14    "Switch to a console." }, 
    1515  { "group", &CLicqConsole::MenuGroup, NULL, 
    1616    " %B%cg%broup [ %B#%b ]", 
     
    2626    "Authorize grant or refuse  the given user." }, 
    2727  { "history", &CLicqConsole::MenuHistory, &CLicqConsole::TabUser, 
    28     " %B%chi%bstory %B<user>%b [ %B#%b,%B#%b ]", 
     28    " %B%chi%bstory %B<user>[.protocol]%b [ %B#%b,%B#%b ]", 
    2929    "Print the given range of events from the history.\n" 
    3030    "'$' represents the last message, and +/- can be used to specify " 
     
    4242    "...\n" }, 
    4343  { "message", &CLicqConsole::MenuMessage, &CLicqConsole::TabUser, 
    44     " %B%cm%bessage %B<user>%b", 
     44    " %B%cm%bessage %B<user>[.protocol]%b", 
    4545    "Send a message to a user." }, 
    4646  { "url", &CLicqConsole::MenuUrl, &CLicqConsole::TabUser, 
     
    5757    "Display user information." }, 
    5858  { "view", &CLicqConsole::MenuView, &CLicqConsole::TabUser, 
    59     " %B%cv%biew [ %B<user>%b ]", 
     59    " %B%cv%biew [ %B<user>[.protocol]%b ]", 
    6060    "View an incoming event." }, 
    6161  { "secure", &CLicqConsole::MenuSecure, &CLicqConsole::TabUser, 
     
    6666    "View a user's auto-reponse or set your own (use #)." }, 
    6767  { "remove", &CLicqConsole::MenuRemove, &CLicqConsole::TabUser, 
    68     " %B%cr%bemove %B<user>%b", 
     68    " %B%cr%bemove %B<user>[.protocol]%b", 
    6969    "Remove a user from your contact list." }, 
    7070  { "status", &CLicqConsole::MenuStatus, &CLicqConsole::TabStatus, 
     
    150150            break; 
    151151        } 
    152       } 
    153       break; 
     152      } 
     153      SaveLastUser((*it)->szId, (*it)->nPPID); 
     154      break; 
    154155    } 
    155156  } 
     
    189190  { 
    190191    list <SScrollUser *>::iterator it; 
    191     for (it = m_lScrollUsers.begin(); it != m_lScrollUsers.end(); it++) 
     192    for (it = m_lScrollUsers.begin(); it != m_lScrollUsers.end(); it++) 
    192193    { 
    193194      if ((*it)->pos == userSelected) 
     
    205206          UserCommand_Msg((*it)->szId, (*it)->nPPID, NULL); 
    206207        } 
     208        SaveLastUser((*it)->szId, (*it)->nPPID); 
    207209        break; 
    208210      } 
     
    274276    PrintBoxLeft(); 
    275277    winMain->wprintf("[%3d] %s v%s", (*pit)->Id(), (*pit)->Name(), 
    276              (*pit)->Version()); 
     278             (*pit)->Version()); 
    277279    PrintBoxRight(70); 
    278280  } 
     
    692694  char *szAlias, *szCmd; 
    693695  char *szArg = *p_szArg; 
     696  unsigned long nPPID = 0; 
    694697  struct SContact scon; 
    695698  scon.szId = NULL; 
     
    698701    return scon; 
    699702  } 
     703 
     704  string strArg(szArg); 
     705  string::size_type nPos = strArg.find_last_of("."); 
     706  if (nPos != string::npos) 
     707  { 
     708    string strProtocol(strArg, nPos + 1, strArg.size()); 
     709    ProtoPluginsList pl; 
     710    ProtoPluginsListIter it; 
     711    licqDaemon->ProtoPluginList(pl); 
     712    for (it = pl.begin(); it != pl.end(); it++) 
     713    { 
     714      if (strcasecmp((*it)->Name(), strProtocol.c_str()) == 0) 
     715      { 
     716        nPPID = (*it)->PPID(); 
     717        szArg[strArg.find_last_of(".")] = '\0'; 
     718        break; 
     719      } 
     720    } 
     721  } 
     722  
    700723 
    701724  // Check if the alias is quoted 
     
    741764  FOR_EACH_USER_START(LOCK_R) 
    742765  { 
    743     if (strcasecmp(szAlias, pUser->GetAlias()) == 0) 
     766    if ((nPPID && pUser->PPID() == nPPID && strcasecmp(szAlias, pUser->GetAlias()) == 0) || 
     767        (!nPPID && strcasecmp(szAlias, pUser->GetAlias()) == 0)) 
    744768    { 
    745769      scon.szId = pUser->IdString(); 
     
    747771      FOR_EACH_PROTO_USER_BREAK; 
    748772    } 
    749     else if (strcasecmp(szAlias, pUser->IdString()) == 0) 
     773    else if ((nPPID && pUser->PPID() == nPPID && strcasecmp(szAlias, pUser->IdString()) == 0) || 
     774             (!nPPID && strcasecmp(szAlias, pUser->IdString()) == 0)) 
    750775    { 
    751776      scon.szId = pUser->IdString(); 
     
    762787    return scon; 
    763788  } 
    764   
    765   // Save this as the last user 
    766   if (winMain->sLastContact.szId == 0 || 
    767       !(strcmp(scon.szId, winMain->sLastContact.szId) == 0 && 
    768       scon.nPPID == winMain->sLastContact.nPPID)) 
    769   { 
    770     if (winMain->sLastContact.szId) 
    771       free(winMain->sLastContact.szId); 
    772     winMain->sLastContact.nPPID = scon.nPPID; 
    773     winMain->sLastContact.szId = strdup(scon.szId); 
    774     PrintStatus(); 
    775   } 
    776  
     789  SaveLastUser(scon.szId, scon.nPPID); 
    777790  return scon; 
    778791} 
     
    890903      { 
    891904        szId = pUser->IdString(); 
    892     nPPID = pUser->PPID(); 
     905        nPPID = pUser->PPID(); 
    893906        t = pUser->Touched(); 
    894907      } 
  • trunk/console/src/console_print.cpp

    r4185 r4197  
    336336 
    337337    // Create the line to printout now 
    338     if (pUser->NewMessages() > 0) 
     338    if (pUser->NewMessages() > 0) 
    339339    { 
    340340      s->szLine = new char[strlen(szTmp) + 19]; 
    341341      snprintf(s->szLine, strlen(szTmp) + 19, "</%d></K>%s<!K><!%d>", s->color->nColor - 6, szTmp ? szTmp : "", s->color->nColor - 6); 
    342342      s->szLine[strlen(szTmp) + 18] = '\0'; 
    343     } else { 
     343    } else { 
    344344      s->szLine = new char[strlen(szTmp) + 11]; 
    345       snprintf(s->szLine, strlen(szTmp) + 11, "</%d>%s<!%d>", s->color->nColor, szTmp ? szTmp : "", s->color->nColor); 
     345      snprintf(s->szLine, strlen(szTmp) + 11, "</%d>%s<!%d>", s->color->nColor, szTmp ? szTmp : "", s->color->nColor); 
    346346      s->szLine[strlen(szTmp) + 10] = '\0'; 
    347     } 
     347    } 
    348348    free(szTmp); 
    349349     
     
    385385  { 
    386386    s = new SScrollUser; 
    387     s->pos = i; 
    388     s->nPPID = (*it)->nPPID; 
     387    s->pos = i; 
     388    s->nPPID = (*it)->nPPID; 
    389389        s->color = (*it)->color; 
    390     sprintf(s->szId, "%s", (*it)->szId); 
    391      
     390    sprintf(s->szId, "%s", (*it)->szId); 
     391 
    392392    m_lScrollUsers.push_back(s); 
    393393    ulist[i++] = copyChar((*it)->szLine); 
  • trunk/console/src/window.cpp

    r3922 r4197  
    6363  else 
    6464  { 
    65     win = newwin(rows, cols, y, x); 
     65    win = newwin(rows, cols, y, x); 
    6666    wmove(win, 0, 0); 
    6767  } 
     
    7373  if (_useCDK) 
    7474  {  
    75     initCDKColor(); 
     75    initCDKColor(); 
    7676    cdkscreen = initCDKScreen(win); 
    7777    if (cdkscreen == NULL) 
     
    8181    } 
    8282  } 
    83      
     83 
    8484  nLastUin = 0; 
    8585  sLastContact.szId = 0;