Changeset 6402

Show
Ignore:
Timestamp:
07/03/2008 05:54:19 AM (12 months ago)
Author:
flynd
Message:

More uin calls removed or rewritten.

Location:
trunk/licq
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/include/licq_icqd.h

    r6390 r6402  
    243243     unsigned short nLevel, bool bMultipleRecipients = false, 
    244244     CICQColor *pColor = NULL); 
    245  
    246   unsigned long ProtoSendContactList(const char *szId, unsigned long nPPID, 
    247      UinList &uins, bool bOnline, unsigned short nLevel, 
    248      bool bMultipleRecipients = false, CICQColor *pColor = NULL); 
    249245 
    250246  unsigned long ProtoFetchAutoResponseServer(const char *szId, unsigned long nPPID); 
     
    551547  void CancelEvent(unsigned long ); 
    552548  void CancelEvent(ICQEvent *); 
    553   bool OpenConnectionToUser(unsigned long nUin, TCPSocket *sock, 
     549  bool OpenConnectionToUser(const char* id, TCPSocket *sock, 
    554550     unsigned short nPort); 
    555551  bool OpenConnectionToUser(const char *szAlias, unsigned long nIp, 
     
    677673     unsigned long nMsgID2, unsigned short nSequence, 
    678674     TCPSocket *pSock); 
    679   bool WaitForReverseConnection(unsigned short id, unsigned long uin); 
     675  bool WaitForReverseConnection(unsigned short id, const char* userId); 
    680676 
    681677protected: 
     
    841837  void ProcessFifo(char *); 
    842838 
    843   static bool Handshake_Send(TCPSocket *, unsigned long, unsigned short, 
     839  static bool Handshake_Send(TCPSocket *, const char* id, unsigned short, 
    844840                             unsigned short, bool = true, unsigned long = 0); 
    845841  static bool Handshake_SendConfirm_v7(TCPSocket *); 
     
    848844  int ConnectToServer(const char* server, unsigned short port); 
    849845  int ConnectToLoginServer(); 
    850   int ConnectToUser(unsigned long, unsigned char); 
    851   int ReverseConnectToUser(unsigned long nUin, unsigned long nIp, 
     846  int ConnectToUser(const char* id, unsigned char channel); 
     847  int ReverseConnectToUser(const char* id, unsigned long nIp, 
    852848     unsigned short nPort, unsigned short nVersion, unsigned short nFailedPort, 
    853849     unsigned long nId, unsigned long nMsgID1, unsigned long nMsgID2); 
    854   int RequestReverseConnection(unsigned long, unsigned long, unsigned long, 
     850  int RequestReverseConnection(const char* id, unsigned long, unsigned long, 
    855851                               unsigned short, unsigned short); 
    856852 
     
    898894{ 
    899895public: 
    900   CReverseConnectToUserData(unsigned long uin, unsigned long id, 
     896  CReverseConnectToUserData(const char* idString, unsigned long id, 
    901897      unsigned long data, unsigned long ip, unsigned short port, 
    902898      unsigned short version, unsigned short failedport, unsigned long msgid1, 
     
    904900  ~CReverseConnectToUserData(); 
    905901 
    906   unsigned long nUin; 
     902  std::string myIdString; 
    907903  unsigned long nId; 
    908904  unsigned long nData; 
  • trunk/licq/include/licq_packets.h

    r6347 r6402  
    727727{ 
    728728public: 
    729   CPU_ReverseConnectFailed(unsigned long nUin, unsigned long nMsgID1, 
     729  CPU_ReverseConnectFailed(const char* id, unsigned long nMsgID1, 
    730730                           unsigned long nMsgID2, unsigned short nFailedPort, 
    731731                           unsigned short nOurPort, unsigned long nConnectID); 
  • trunk/licq/src/icqd-chat.cpp

    r6401 r6402  
    816816 
    817817    // try reverse connect 
    818     int nId = licqDaemon->RequestReverseConnection(c->m_nUin, c->m_nSession, 
     818    int nId = licqDaemon->RequestReverseConnection(c->m_szId, c->m_nSession, 
    819819                                                 nIp, LocalPort(), c->m_nPort); 
    820820    if (nId != -1) 
     
    854854 
    855855  // Send handshake packet: 
    856   if (!CICQDaemon::Handshake_Send(&u->sock, c->m_nUin, LocalPort(), 
     856  if (!CICQDaemon::Handshake_Send(&u->sock, c->m_szId, LocalPort(), 
    857857     VersionToUse(c->m_nVersion), false)) 
    858858    return false; 
     
    985985                         iter != licqDaemon->m_lReverseConnect.end();  ++iter) 
    986986        { 
    987           if ((*iter)->nUin == u->uin) 
     987          if ((*iter)->myIdString == u->Id()) 
    988988          { 
    989989            bFound = true; 
     
    24642464  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 
    24652465  gLog.Info("%sChat: Waiting for reverse connection.\n", L_TCPxSTR); 
    2466   bool bConnected = d->WaitForReverseConnection(rc->nId, rc->u->Uin()); 
     2466  bool bConnected = d->WaitForReverseConnection(rc->nId, rc->u->Id()); 
    24672467  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 
    24682468 
  • trunk/licq/src/icqd-filetransfer.cpp

    r6371 r6402  
    1717#include <sys/types.h> 
    1818#include <fcntl.h> 
     19#include <string> 
    1920#include <string.h> 
    2021#include <sys/time.h> 
     
    4344const unsigned short FT_STATE_CONFIRMINGxFILE = 8; 
    4445 
     46using std::string; 
    4547 
    4648 
     
    352354  { 
    353355    gLog.Info("%sFile Transfer: Connecting to server.\n", L_TCPxSTR); 
    354     bSuccess = licqDaemon->OpenConnectionToUser(m_nUin, &ftSock, nPort); 
     356    bSuccess = licqDaemon->OpenConnectionToUser(myId, &ftSock, nPort); 
    355357   } 
    356358 
     
    363365 
    364366    // try reverse connect 
    365     int nId = licqDaemon->RequestReverseConnection(m_nUin, 0, nIp, LocalPort(), 
     367    int nId = licqDaemon->RequestReverseConnection(myId, 0, nIp, LocalPort(), 
    366368                                                                        nPort); 
    367369 
     
    393395  unsigned short nVersion = u->ConnectionVersion(); 
    394396  gUserManager.DropUser(u); 
    395   if (!CICQDaemon::Handshake_Send(&ftSock, m_nUin, LocalPort(), nVersion, false)) 
     397  if (!CICQDaemon::Handshake_Send(&ftSock, myId, LocalPort(), nVersion, false)) 
    396398    return false; 
    397399 
     
    481483                          iter != licqDaemon->m_lReverseConnect.end();  ++iter) 
    482484        { 
    483           if ((*iter)->nId == nId && (*iter)->nUin == m_nUin) 
     485          if ((*iter)->nId == nId && (*iter)->myIdString == myId) 
    484486          { 
    485487            bFound = true; 
     
    12551257 
    12561258  CICQDaemon *d; 
    1257   unsigned long nUin; 
    12581259  unsigned short nPort; 
    12591260  struct SFileReverseConnectInfo *rc = (struct SFileReverseConnectInfo *)arg; 
     
    12651266  pthread_cleanup_pop(0); 
    12661267  d = rc->m->licqDaemon; 
    1267   nUin = rc->m->Uin(); 
     1268  string id = rc->m->Id(); 
    12681269  nPort = rc->m->m_nPort; 
    12691270  pthread_mutex_unlock(cancel_mutex); 
     
    12711272  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 
    12721273  gLog.Info("%sFile Transfer: Waiting for reverse connection.\n", L_TCPxSTR); 
    1273   bool bConnected = d->WaitForReverseConnection(rc->nId, nUin); 
     1274  bool bConnected = d->WaitForReverseConnection(rc->nId, id.c_str()); 
    12741275  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 
    12751276 
     
    12971298                                                                    L_TCPxSTR); 
    12981299  TCPSocket s; 
    1299   bConnected = d->OpenConnectionToUser(nUin, &s, nPort); 
     1300  bConnected = d->OpenConnectionToUser(id.c_str(), &s, nPort); 
    13001301  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 
    13011302 
  • trunk/licq/src/icqd-srv.cpp

    r6394 r6402  
    20832083int CICQDaemon::ConnectToServer(const char* server, unsigned short port) 
    20842084{ 
    2085   SrvSocket *s = new SrvSocket(gUserManager.icqOwnerUin()); 
     2085  SrvSocket* s = new SrvSocket(gUserManager.OwnerId(LICQ_PPID).c_str(), LICQ_PPID); 
    20862086 
    20872087  if (m_bProxyEnabled) 
     
    21792179    ParseDigits(szParsedNumber2, szCellular, 15); 
    21802180    if (!strcmp(szParsedNumber1, szParsedNumber2)) 
    2181       nUin = pUser->Uin(); 
     2181      nUin = strtoul(pUser->IdString(), NULL, 10); 
    21822182  } 
    21832183  FOR_EACH_USER_END 
     
    31153115        if ((*iter)->nId == nSubSequence) 
    31163116        { 
    3117           ICQUser *u = gUserManager.FetchUser((*iter)->nUin, LOCK_R); 
     3117          ICQUser* u = gUserManager.FetchUser((*iter)->myIdString.c_str(), LICQ_PPID, LOCK_R); 
    31183118          if (u == NULL) 
    3119             gLog.Warn("%sReverse connection from %lu failed.\n", L_WARNxSTR, 
    3120                       (*iter)->nUin); 
     3119            gLog.Warn("%sReverse connection from %s failed.\n", L_WARNxSTR, 
     3120                (*iter)->myIdString.c_str()); 
    31213121          else 
    31223122          { 
     
    32983298          nPort = nPort2; 
    32993299 
     3300        char id[16]; 
     3301        snprintf(id, 15, "%lu", nUin); 
     3302 
    33003303        pthread_t t; 
    33013304        CReverseConnectToUserData *data = new CReverseConnectToUserData( 
    3302                                nUin, nId, ICQ_CHNxUNKNOWN, nIp, nPort, 
     3305            id, nId, ICQ_CHNxUNKNOWN, nIp, nPort, 
    33033306                               nVersion, nFailedPort, nMsgID[0], nMsgID[1]); 
    33043307        pthread_create(&t, NULL, &ReverseConnectToUser_tep, data); 
     
    39083911        nFormat = packet.UnpackUnsignedShortBE(); 
    39093912        nUin = packet.UnpackUinString(); 
    3910  
    3911         u = gUserManager.FetchUser(nUin, LOCK_W); 
     3913      char id[16]; 
     3914      snprintf(id, 15, "%lu", nUin); 
     3915 
     3916      u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    39123917        if (u == NULL) 
    39133918        { 
     
    39233928                                           ++iter) 
    39243929    { 
    3925       if ((*iter)->nId == nMsgID && (*iter)->nUin == nUin) 
    3926       { 
     3930        if ((*iter)->nId == nMsgID && (*iter)->myIdString == id) 
     3931        { 
    39273932        gLog.Warn("%sReverse connection from %s failed.\n", L_WARNxSTR, 
    39283933                  u->GetAlias()); 
     
    65796584} 
    65806585 
    6581 int CICQDaemon::RequestReverseConnection(unsigned long nUin, 
     6586int CICQDaemon::RequestReverseConnection(const char* id, 
    65826587                                         unsigned long nData, 
    65836588                                         unsigned long nLocalIP, 
     
    65856590                                         unsigned short nRemotePort) 
    65866591{ 
    6587   if (nUin == gUserManager.icqOwnerUin()) 
     6592  if (gUserManager.FindOwner(id, LICQ_PPID) != NULL) 
    65886593    return -1; 
    65896594 
    6590   ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); 
     6595  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    65916596  if (u == NULL) return -1; 
    65926597 
     
    65986603  pthread_mutex_lock(&mutex_reverseconnect); 
    65996604 
    6600   m_lReverseConnect.push_back( 
    6601             new CReverseConnectToUserData(nUin, nId, nData, nLocalIP, 
    6602                                           nLocalPort, ICQ_VERSION_TCP, 
    6603                                           nRemotePort, 0, nId)); 
     6605  m_lReverseConnect.push_back(new CReverseConnectToUserData(id, nId, nData, 
     6606      nLocalIP, nLocalPort, ICQ_VERSION_TCP, nRemotePort, 0, nId)); 
    66046607  pthread_mutex_unlock(&mutex_reverseconnect); 
    66056608 
  • trunk/licq/src/icqd-tcp.cpp

    r6382 r6402  
    12131213 * Shake hands on the given socket with the given user. 
    12141214 *-------------------------------------------------------------------------*/ 
    1215 bool CICQDaemon::Handshake_Send(TCPSocket *s, unsigned long nUin, 
     1215bool CICQDaemon::Handshake_Send(TCPSocket *s, const char* id, 
    12161216   unsigned short nPort, unsigned short nVersion, bool bConfirm, 
    12171217   unsigned long nId) 
    12181218{ 
    12191219  s->SetVersion(nVersion); 
    1220   s->SetOwner(nUin); 
     1220  s->SetOwner(id, LICQ_PPID); 
     1221 
     1222  unsigned long nUin = strtoul(id, NULL, 10); 
    12211223 
    12221224  switch (nVersion) 
     
    13591361 * to the global socket manager and to the user. 
    13601362 *----------------------------------------------------------------------------*/ 
    1361 int CICQDaemon::ConnectToUser(unsigned long nUin, unsigned char nChannel) 
    1362 { 
    1363   ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); 
     1363int CICQDaemon::ConnectToUser(const char* id, unsigned char nChannel) 
     1364{ 
     1365  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    13641366  if (u == NULL) return -1; 
    13651367 
     
    13701372  { 
    13711373    gUserManager.DropUser(u); 
    1372     gLog.Warn(tr("%sConnection attempted to already connected user (%ld).\n"), 
    1373        L_WARNxSTR, nUin); 
     1374    gLog.Warn(tr("%sConnection attempted to already connected user (%s).\n"), 
     1375       L_WARNxSTR, id); 
    13741376    return sd; 
    13751377  } 
     
    13871389    struct timeval tv = { 2, 0 }; 
    13881390    if (select(0, NULL, NULL, NULL, &tv) == -1 && errno == EINTR) return -1; 
    1389     u = gUserManager.FetchUser(nUin, LOCK_W); 
     1391    u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    13901392    if (u == NULL) return -1; 
    13911393  } 
     
    13951397  if (sd != -1) return sd; 
    13961398 
    1397   TCPSocket *s = new TCPSocket(nUin); 
    1398   if (!OpenConnectionToUser(nUin, s, nPort)) 
    1399   { 
    1400     u = gUserManager.FetchUser(nUin, LOCK_W); 
     1399  TCPSocket* s = new TCPSocket(id, LICQ_PPID); 
     1400  if (!OpenConnectionToUser(id, s, nPort)) 
     1401  { 
     1402    u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    14011403    if (u != NULL) u->SetConnectionInProgress(false); 
    14021404    gUserManager.DropUser(u); 
     
    14051407  } 
    14061408  s->SetChannel(nChannel); 
    1407    
    1408   gLog.Info(tr("%sShaking hands with %s (%ld) [v%d].\n"), L_TCPxSTR, 
    1409      szAlias, nUin, nVersion); 
     1409 
     1410  gLog.Info(tr("%sShaking hands with %s (%s) [v%d].\n"), L_TCPxSTR, 
     1411     szAlias, id, nVersion); 
    14101412  nPort = s->LocalPort(); 
    14111413 
    1412   if (!Handshake_Send(s, nUin, 0, nVersion)) 
    1413   { 
    1414     u = gUserManager.FetchUser(nUin, LOCK_W); 
     1414  if (!Handshake_Send(s, id, 0, nVersion)) 
     1415  { 
     1416    u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    14151417    if (u != NULL) u->SetConnectionInProgress(false); 
    14161418    gUserManager.DropUser(u); 
     
    14221424 
    14231425  // Set the socket descriptor in the user 
    1424   u = gUserManager.FetchUser(nUin, LOCK_W); 
     1426  u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    14251427  if (u == NULL) return -1; 
    14261428  u->SetSocketDesc(s); 
     
    14451447 * Connects a socket to a given user on a given port. 
    14461448 *----------------------------------------------------------------------------*/ 
    1447 bool CICQDaemon::OpenConnectionToUser(unsigned long nUin, TCPSocket *sock, 
     1449bool CICQDaemon::OpenConnectionToUser(const char* id, TCPSocket *sock, 
    14481450                                      unsigned short nPort) 
    14491451{ 
    1450   ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     1452  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    14511453  if (u == NULL) return false; 
    14521454 
     
    15321534 * to the global socket manager and to the user. 
    15331535 *----------------------------------------------------------------------------*/ 
    1534 int CICQDaemon::ReverseConnectToUser(unsigned long nUin, unsigned long nIp, 
     1536int CICQDaemon::ReverseConnectToUser(const char* id, unsigned long nIp, 
    15351537   unsigned short nPort, unsigned short nVersion, unsigned short nFailedPort, 
    15361538   unsigned long nId, unsigned long nMsgID1, unsigned long nMsgID2) 
     
    15511553  } 
    15521554 
    1553   TCPSocket *s = new TCPSocket(nUin); 
     1555  TCPSocket* s = new TCPSocket(id, LICQ_PPID); 
    15541556  char buf[32]; 
    15551557 
    1556   gLog.Info(tr("%sReverse connecting to %lu at %s:%d.\n"), L_TCPxSTR, nUin, 
     1558  gLog.Info(tr("%sReverse connecting to %s at %s:%d.\n"), L_TCPxSTR, id, 
    15571559            ip_ntoa(nIp, buf), nPort); 
    15581560 
     
    15631565  { 
    15641566    char buf[128]; 
    1565     gLog.Warn(tr("%sReverse connect to %lu failed:\n%s%s.\n"), L_WARNxSTR, 
    1566               nUin, L_BLANKxSTR, s->ErrorStr(buf, 128)); 
    1567                
    1568     CPU_ReverseConnectFailed *p = new CPU_ReverseConnectFailed(nUin, nMsgID1, 
    1569                                                      nMsgID2, nPort, 
    1570                                                      nFailedPort, nId); 
     1567    gLog.Warn(tr("%sReverse connect to %s failed:\n%s%s.\n"), L_WARNxSTR, 
     1568        id, L_BLANKxSTR, s->ErrorStr(buf, 128)); 
     1569 
     1570    CPU_ReverseConnectFailed* p = new CPU_ReverseConnectFailed(id, nMsgID1, 
     1571        nMsgID2, nPort, nFailedPort, nId); 
    15711572    SendEvent_Server(p); 
    15721573    return -1; 
    15731574  } 
    15741575 
    1575   gLog.Info(tr("%sReverse shaking hands with %lu.\n"), L_TCPxSTR, nUin); 
     1576  gLog.Info(tr("%sReverse shaking hands with %s.\n"), L_TCPxSTR, id); 
    15761577  bool bConfirm = ftm == NULL && cm == NULL; 
    15771578 
     
    15791580  nVersion = VersionToUse(nVersion); 
    15801581 
    1581   if (!Handshake_Send(s, nUin, 0, nVersion, bConfirm, nId)) 
     1582  if (!Handshake_Send(s, id, 0, nVersion, bConfirm, nId)) 
    15821583  { 
    15831584    delete s; 
     
    16051606  { 
    16061607    // Set the socket descriptor in the user if this user is on our list 
    1607     ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); 
     1608    ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    16081609    if (u != NULL) 
    16091610    { 
     
    16251626bool CICQDaemon::ProcessTcpPacket(TCPSocket *pSock) 
    16261627{ 
    1627   unsigned long nUin, senderIp, localIp, 
     1628  unsigned long senderIp, localIp, 
    16281629                senderPort, junkLong, nPort, nPortReversed; 
    16291630  unsigned short version, command, junkShort, newCommand, messageLen, 
     
    16321633  bool errorOccured = false; 
    16331634  char *message = 0; 
     1635  char id[16] = ""; 
    16341636 
    16351637  // only used for v7,v8 
     
    16471649    case 3: 
    16481650    { 
     1651      unsigned long nUin; 
    16491652      packet >> nUin 
    16501653             >> version 
     
    16551658             >> messageLen   // length of incoming message 
    16561659      ; 
     1660      snprintf(id, 15, "%lu", nUin); 
    16571661      break; 
    16581662    } 
     
    16671671        return false; 
    16681672      } 
     1673      unsigned long nUin; 
    16691674      packet >> nUin 
    16701675             >> version 
     
    16761681             >> messageLen   // length of incoming message 
    16771682      ; 
     1683      snprintf(id, 15, "%lu", nUin); 
    16781684      break; 
    16791685    } 
    16801686    case 6: 
    16811687    { 
    1682       nUin = pSock->Owner(); 
     1688      strncpy(id, pSock->OwnerId(), 15); id[15] = '\0'; 
    16831689      if (!Decrypt_Client(&packet, 6)) 
    16841690      { 
     
    17031709    case 8: 
    17041710    { 
    1705       nUin = pSock->Owner(); 
     1711      strncpy(id, pSock->OwnerId(), 15); id[15] = '\0'; 
    17061712      if (!Decrypt_Client(&packet, nInVersion)) 
    17071713      { 
     
    17251731        msgFlags = packet.UnpackUnsignedShort(); 
    17261732        packet >> messageLen; 
    1727          
     1733 
    17281734        // Stupid AOL 
    1729         ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     1735        ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    17301736        if (u && (u->LicqVersion() == 0 || u->LicqVersion() >= 1022)) 
    17311737        { 
     
    17511757 
    17521758  // Some simple validation of the packet 
    1753   if (nUin == 0 || command == 0) 
     1759  if (id[0] == '\0' || command == 0) 
    17541760  { 
    17551761    char *buf; 
    1756     gLog.Unknown("%sInvalid TCP packet (uin: %08lx, cmd: %04x):\n%s\n", 
    1757                  L_UNKNOWNxSTR, nUin, command, packet.print(buf)); 
     1762    gLog.Unknown("%sInvalid TCP packet (uin: %s, cmd: %04x):\n%s\n", 
     1763        L_UNKNOWNxSTR, id, command, packet.print(buf)); 
    17581764    delete [] buf; 
    17591765    return false; 
    17601766  } 
    17611767 
    1762   if (nUin == gUserManager.icqOwnerUin() || nUin != pSock->Owner()) 
     1768  if (gUserManager.FindOwner(id, LICQ_PPID) != NULL || strcmp(id, pSock->OwnerId()) != 0) 
    17631769  { 
    17641770    char *buf; 
    1765     if (nUin == gUserManager.icqOwnerUin()) 
     1771    if (gUserManager.FindOwner(id, LICQ_PPID) != NULL) 
    17661772      gLog.Warn(tr("%sTCP message from self (probable spoof):\n%s\n"), L_WARNxSTR, packet.print(buf)); 
    17671773    else 
    1768       gLog.Warn(tr("%sTCP message from invalid UIN (%ld, expect %ld):\n%s\n"), 
    1769                 L_WARNxSTR, nUin, pSock->Owner(), packet.print(buf)); 
     1774      gLog.Warn(tr("%sTCP message from invalid UIN (%s, expect %s):\n%s\n"), 
     1775          L_WARNxSTR, id, pSock->OwnerId(), packet.print(buf)); 
    17701776    delete [] buf; 
    17711777    return false; 
     
    17791785  // find which user was sent 
    17801786  bool bNewUser = false; 
    1781   ICQUser *u = gUserManager.FetchUser(nUin, LOCK_W); 
     1787  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); 
    17821788  if (u == NULL) 
    17831789  { 
    1784     u = new ICQUser(nUin); 
     1790    u = new ICQUser(id, LICQ_PPID); 
    17851791    u->SetSocketDesc(pSock); 
    17861792    bNewUser = true; 
     
    19231929                nMask |= licqVersion; 
    19241930                if (licqChar == 'L') 
    1925                     gLog.Info(tr("%sMessage from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), 
    1926              nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    1927                 else 
    1928                     gLog.Info(tr("%sMessage from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); 
     1931            gLog.Info(tr("%sMessage from %s (%s) [Licq %s].\n"), L_TCPxSTR, 
     1932                u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     1933      else 
     1934            gLog.Info(tr("%sMessage from %s (%s).\n"), L_TCPxSTR, u->GetAlias(), id); 
    19291935 
    19301936        CPT_AckGeneral p(newCommand, theSequence, true, bAccept, u); 
     
    19511957            // FIXME should either refuse the event or have a special auto response 
    19521958            // for rejected events instead of pretending to accept the user 
    1953             RejectEvent(nUin, e); 
     1959              RejectEvent(id, e); 
    19541960            break; 
    19551961          } 
     
    19821988        packet >> licqChar >> licqVersion; 
    19831989        if (licqChar == 'L') 
    1984           gLog.Info(tr("%s%s (%ld) requested auto response [Licq %s].\n"), L_TCPxSTR, 
    1985              u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    1986         else 
    1987           gLog.Info(tr("%s%s (%ld) requested auto response.\n"), L_TCPxSTR, u->GetAlias(), nUin); 
     1990            gLog.Info(tr("%s%s (%s) requested auto response [Licq %s].\n"), L_TCPxSTR, 
     1991                u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     1992          else 
     1993            gLog.Info(tr("%s%s (%s) requested auto response.\n"), L_TCPxSTR, u->GetAlias(), id); 
    19881994 
    19891995        CPT_AckGeneral p(newCommand, theSequence, true, false, u); 
     
    19931999        u->SetLastCheckedAutoResponse(); 
    19942000 
    1995         PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_EVENTS, nUin)); 
     2001          PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_EVENTS, id, LICQ_PPID)); 
    19962002        break; 
    19972003      } 
     
    20212027        nMask |= licqVersion; 
    20222028        if (licqChar == 'L') 
    2023           gLog.Info(tr("%sURL from %s (%ld) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), 
    2024             nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2025         else 
    2026           gLog.Info(tr("%sURL from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); 
     2029            gLog.Info(tr("%sURL from %s (%s) [Licq %s].\n"), L_TCPxSTR, u->GetAlias(), 
     2030                id, CUserEvent::LicqVersionToString(licqVersion)); 
     2031          else 
     2032            gLog.Info(tr("%sURL from %s (%s).\n"), L_TCPxSTR, u->GetAlias(), id); 
    20272033 
    20282034        CEventUrl *e = CEventUrl::Parse(message, ICQ_CMDxTCP_START, TIME_NOW, nMask); 
     
    20542060          if (Ignore(IGNORE_NEWUSERS)) 
    20552061          { 
    2056             RejectEvent(nUin, e); 
     2062              RejectEvent(id, e); 
    20572063            break; 
    20582064          } 
     
    20902096        nMask |= licqVersion; 
    20912097        if (licqChar == 'L') 
    2092           gLog.Info(tr("%sContact list from %s (%ld) [Licq %s].\n"), L_TCPxSTR, 
    2093              u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2094         else 
    2095           gLog.Info(tr("%sContact list from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), 
    2096              nUin); 
     2098            gLog.Info(tr("%sContact list from %s (%s) [Licq %s].\n"), L_TCPxSTR, 
     2099               u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     2100          else 
     2101            gLog.Info(tr("%sContact list from %s (%s).\n"), L_TCPxSTR, 
     2102                u->GetAlias(), id); 
    20972103 
    20982104        CEventContactList *e = CEventContactList::Parse(message, ICQ_CMDxTCP_START, TIME_NOW, nMask); 
     
    21242130          if (Ignore(IGNORE_NEWUSERS)) 
    21252131          { 
    2126             RejectEvent(nUin, e); 
     2132              RejectEvent(id, e); 
    21272133            break; 
    21282134          } 
     
    21572163 
    21582164        if (licqChar == 'L') 
    2159           gLog.Info(tr("%sChat request from %s (%ld) [Licq %s].\n"), L_TCPxSTR, 
    2160              u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2161         else 
    2162           gLog.Info(tr("%sChat request from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), 
    2163              nUin); 
     2165            gLog.Info(tr("%sChat request from %s (%s) [Licq %s].\n"), L_TCPxSTR, 
     2166               u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     2167          else 
     2168            gLog.Info(tr("%sChat request from %s (%s).\n"), L_TCPxSTR, 
     2169                u->GetAlias(), id); 
    21642170 
    21652171        // translating string with translation table 
     
    21732179          if (Ignore(IGNORE_NEWUSERS)) 
    21742180          { 
    2175             RejectEvent(nUin, e); 
     2181              RejectEvent(id, e); 
    21762182            break; 
    21772183          } 
     
    22112217 
    22122218        if (licqChar == 'L') 
    2213           gLog.Info(tr("%sFile transfer request from %s (%ld) [Licq %s].\n"), 
    2214              L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2215         else 
    2216           gLog.Info(tr("%sFile transfer request from %s (%ld).\n"), L_TCPxSTR, 
    2217              u->GetAlias(), nUin); 
     2219            gLog.Info(tr("%sFile transfer request from %s (%s) [Licq %s].\n"), 
     2220                L_TCPxSTR, u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     2221          else 
     2222            gLog.Info(tr("%sFile transfer request from %s (%s).\n"), L_TCPxSTR, 
     2223                u->GetAlias(), id); 
    22182224 
    22192225        ConstFileList filelist; 
     
    22302236          if (Ignore(IGNORE_NEWUSERS)) 
    22312237          { 
    2232             RejectEvent(nUin, e); 
     2238              RejectEvent(id, e); 
    22332239            break; 
    22342240          } 
     
    22972303                    packet.incDataPosRead(2); // reversed port (BE) 
    22982304 
    2299                     gLog.Info(tr("%sFile transfer request from %s (%ld).\n"), L_TCPxSTR, 
    2300                                         u->GetAlias(), nUin); 
     2305              gLog.Info(tr("%sFile transfer request from %s (%s).\n"), 
     2306                  L_TCPxSTR, u->GetAlias(), id); 
    23012307 
    23022308                    ConstFileList filelist; 
     
    23112317                        if (Ignore(IGNORE_NEWUSERS)) 
    23122318                        { 
    2313                             RejectEvent(nUin, e); 
     2319                  RejectEvent(id, e); 
    23142320                            break; 
    23152321                        } 
     
    23322338                        nPort = nPortReversed; 
    23332339 
    2334                     gLog.Info(tr("%sChat request from %s (%ld).\n"), L_TCPxSTR, 
    2335                                         u->GetAlias(), nUin); 
    2336                      
     2340              gLog.Info(tr("%sChat request from %s (%s).\n"), L_TCPxSTR, 
     2341                  u->GetAlias(), id); 
     2342 
    23372343                    // translating string with translation table 
    23382344                    gTranslator.ServerToClient(szMessage); 
     
    23432349                        if (Ignore(IGNORE_NEWUSERS)) 
    23442350                        { 
    2345                             RejectEvent(nUin, e); 
     2351                  RejectEvent(id, e); 
    23462352                            break; 
    23472353                        } 
     
    23562362                case ICQ_CMDxSUB_URL: 
    23572363                { 
    2358                     gLog.Info(tr("%sURL from %s (%ld).\n"), L_TCPxSTR, u->GetAlias(), nUin); 
     2364              gLog.Info(tr("%sURL from %s (%s).\n"), L_TCPxSTR, u->GetAlias(), id); 
    23592365                    CEventUrl *e = CEventUrl::Parse(szMessage, ICQ_CMDxTCP_START, 
    23602366                                                                                    TIME_NOW, nMask); 
     
    23732379                        if (Ignore(IGNORE_NEWUSERS)) 
    23742380                        { 
    2375                             RejectEvent(nUin, e); 
     2381                  RejectEvent(id, e); 
    23762382                            break; 
    23772383                        } 
     
    23862392                case ICQ_CMDxSUB_CONTACTxLIST: 
    23872393                { 
    2388                     gLog.Info(tr("%sContact list from %s (%ld).\n"), L_TCPxSTR, 
    2389                                         u->GetAlias(), nUin); 
     2394              gLog.Info(tr("%sContact list from %s (%s).\n"), L_TCPxSTR, 
     2395                  u->GetAlias(), id); 
    23902396                    CEventContactList *e = CEventContactList::Parse(szMessage, 
    23912397                                                                                                                    ICQ_CMDxTCP_START, 
     
    24052411                        if (Ignore(IGNORE_NEWUSERS)) 
    24062412                        { 
    2407                             RejectEvent(nUin, e); 
     2413                  RejectEvent(id, e); 
    24082414                            break; 
    24092415                        } 
     
    24242430      case ICQ_CMDxSUB_SECURExOLD: 
    24252431      { 
    2426         gLog.Info(tr("%sReceived old-style key request from %s (%ld) but we do not support it.\n"), 
    2427            L_TCPxSTR, u->GetAlias(), nUin); 
     2432          gLog.Info(tr("%sReceived old-style key request from %s (%s) but we do not support it.\n"), 
     2433              L_TCPxSTR, u->GetAlias(), id); 
    24282434        // Send the nack back 
    24292435        CPT_AckOldSecureChannel p(theSequence, u); 
     
    24492455 
    24502456        if (licqChar == 'L') 
    2451           gLog.Info(tr("%sSecure channel request from %s (%ld) [Licq %s].\n"), 
    2452            L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2453         else 
    2454           gLog.Info(tr("%sSecure channel request from %s (%ld).\n"), L_TCPxSTR, 
    2455            u->GetAlias(), nUin); 
     2457            gLog.Info(tr("%sSecure channel request from %s (%s) [Licq %s].\n"), 
     2458                L_TCPxSTR, u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     2459          else 
     2460            gLog.Info(tr("%sSecure channel request from %s (%s).\n"), L_TCPxSTR, 
     2461                u->GetAlias(), id); 
    24562462 
    24572463        CPT_AckOpenSecureChannel p(theSequence, true, u); 
     
    24752481 
    24762482        u->SetSendServer(false); 
    2477         PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 1)); 
    2478  
    2479         gLog.Info(tr("%sSecure channel established with %s (%ld).\n"), 
    2480          L_SSLxSTR, u->GetAlias(), nUin); 
     2483          PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 1)); 
     2484 
     2485          gLog.Info(tr("%sSecure channel established with %s (%s).\n"), 
     2486              L_SSLxSTR, u->GetAlias(), id); 
    24812487 
    24822488        break; 
    24832489 
    24842490#else // We do not support OpenSSL 
    2485        gLog.Info(tr("%sReceived secure channel request from %s (%ld) but we do not support OpenSSL.\n"), 
    2486            L_TCPxSTR, u->GetAlias(), nUin); 
     2491          gLog.Info(tr("%sReceived secure channel request from %s (%s) but we do not support OpenSSL.\n"), 
     2492              L_TCPxSTR, u->GetAlias(), id); 
    24872493        // Send the nack back 
    24882494        CPT_AckOpenSecureChannel p(theSequence, false, u); 
     
    25102516 
    25112517        if (licqChar == 'L') 
    2512           gLog.Info(tr("%sSecure channel closed by %s (%ld) [Licq %s].\n"), 
    2513            L_TCPxSTR, u->GetAlias(), nUin, CUserEvent::LicqVersionToString(licqVersion)); 
    2514         else 
    2515           gLog.Info(tr("%sSecure channel closed by %s (%ld).\n"), L_TCPxSTR, 
    2516            u->GetAlias(), nUin); 
     2518            gLog.Info(tr("%sSecure channel closed by %s (%s) [Licq %s].\n"), 
     2519                L_TCPxSTR, u->GetAlias(), id, CUserEvent::LicqVersionToString(licqVersion)); 
     2520          else 
     2521            gLog.Info(tr("%sSecure channel closed by %s (%s).\n"), L_TCPxSTR, 
     2522                u->GetAlias(), id); 
    25172523 
    25182524        // send ack 
     
    25222528        pSock->SecureStop(); 
    25232529        u->SetSecure(false); 
    2524         PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 0)); 
     2530          PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 0)); 
    25252531        break; 
    25262532 
    25272533#else // We do not support OpenSSL 
    2528         gLog.Info(tr("%sReceived secure channel close from %s (%ld) but we do not support OpenSSL.\n"), 
    2529            L_TCPxSTR, u->GetAlias(), nUin); 
     2534          gLog.Info(tr("%sReceived secure channel close from %s (%s) but we do not support OpenSSL.\n"), 
     2535              L_TCPxSTR, u->GetAlias(), id); 
    25302536        // Send the nack back 
    25312537        CPT_AckCloseSecureChannel p(theSequence, u); 
     
    27362742        if (licqChar == 'L') sprintf(l, " [Licq %s]", 
    27372743         CUserEvent::LicqVersionToString(licqVersion)); 
    2738         gLog.Info(tr("%sSecure channel response from %s (%ld)%s.\n"), L_TCPxSTR, 
    2739          u->GetAlias(), nUin, l); 
     2744          gLog.Info(tr("%sSecure channel response from %s (%s)%s.\n"), L_TCPxSTR, 
     2745              u->GetAlias(), id, l); 
    27402746 
    27412747        ICQEvent *e = NULL; 
     
    27442750        if (message[0] == '\0') 
    27452751        { 
    2746           gLog.Info(tr("%s%s (%ld) does not support OpenSSL.\n"), L_TCPxSTR, 
    2747              u->GetAlias(), nUin); 
     2752            gLog.Info(tr("%s%s (%s) does not support OpenSSL.\n"), L_TCPxSTR, 
     2753                u->GetAlias(), id); 
    27482754          u->SetSecure(false); 
    2749           PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 0)); 
     2755            PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 0)); 
    27502756          // find the event, fail it 
    27512757          e = DoneEvent(sockfd, theSequence, EVENT_FAILED); 
     
    27592765          if (e == NULL) 
    27602766          { 
    2761             gLog.Warn(tr("%sSecure channel response from %s (%ld) when no request in progress.\n"), 
    2762                L_WARNxSTR, u->GetAlias(), nUin); 
     2767              gLog.Warn(tr("%sSecure channel response from %s (%s) when no request in progress.\n"), 
     2768                  L_WARNxSTR, u->GetAlias(), id); 
    27632769            // Close the connection as we are in trouble 
    27642770            u->SetSecure(false); 
    27652771            gUserManager.DropUser(u); 
    2766             PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 0)); 
     2772              PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 0)); 
    27672773            return false; 
    27682774          } 
     
    27752781          else 
    27762782          { 
    2777             gLog.Info(tr("%sSecure channel established with %s (%ld).\n"), L_SSLxSTR, 
    2778                u->GetAlias(), nUin); 
     2783              gLog.Info(tr("%sSecure channel established with %s (%s).\n"), 
     2784                  L_SSLxSTR, u->GetAlias(), id); 
    27792785            u->SetSecure(true); 
    2780             PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 1)); 
     2786              PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 1)); 
    27812787          } 
    27822788        } 
     
    28082814        char l[32] = ""; 
    28092815        if (licqChar == 'L') sprintf(l, " [Licq %s]", CUserEvent::LicqVersionToString(licqVersion)); 
    2810         gLog.Info(tr("%sSecure channel with %s (%ld) closed %s.\n"), L_TCPxSTR, 
    2811          u->GetAlias(), nUin, l); 
     2816          gLog.Info(tr("%sSecure channel with %s (%s) closed %s.\n"), L_TCPxSTR, 
     2817              u->GetAlias(), id, l); 
    28122818 
    28132819        // Find the event, succeed it 
     
    28262832        u->SetSecure(false); 
    28272833        gUserManager.DropUser(u); 
    2828         PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, nUin, 0)); 
     2834          PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_SECURITY, id, LICQ_PPID, 0)); 
    28292835 
    28302836        // finish up 
     
    29322938      case ICQ_CMDxSUB_CHAT: 
    29332939      { 
    2934         gLog.Info(tr("%sChat request from %s (%ld) cancelled.\n"), L_TCPxSTR, 
    2935                  u->GetAlias(), nUin); 
     2940          gLog.Info(tr("%sChat request from %s (%s) cancelled.\n"), L_TCPxSTR, 
     2941              u->GetAlias(), id); 
    29362942        if (nInVersion <= 4) 
    29372943        { 
     
    29582964      case ICQ_CMDxSUB_FILE: 
    29592965      { 
    2960         gLog.Info(tr("%sFile transfer request from %s (%ld) cancelled.\n"), 
    2961                  L_TCPxSTR, u->GetAlias(), nUin); 
     2966          gLog.Info(tr("%sFile transfer request from %s (%s) cancelled.\n"), 
     2967              L_TCPxSTR, u->GetAlias(), id); 
    29622968        if (nInVersion <= 4) 
    29632969        { 
     
    37273733  unsigned long nUin = 0; 
    37283734  unsigned short nVersion = 0; 
     3735  char id[16]; 
    37293736 
    37303737  switch (VersionToUse(nVersionMajor)) 
     
    37363743      CPacketTcp_Handshake_v7 p_in(&b); 
    37373744      nUin = p_in.SourceUin(); 
    3738  
    3739       ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     3745      snprintf(id, 16, "%lu", nUin); 
     3746 
     3747      ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    37403748      if (u == NULL && !bChat) 
    37413749      { 
     
    37493757      { 
    37503758        char ipbuf[32]; 
    3751         gLog.Warn("%sSpoofed connection from %s as uin %lu.\n", L_WARNxSTR, 
    3752                   s->RemoteIpStr(ipbuf), nUin); 
     3759        gLog.Warn("%sSpoofed connection from %s as uin %s.\n", L_WARNxSTR, 
     3760            s->RemoteIpStr(ipbuf), id); 
    37533761        return false; 
    37543762      } 
     
    38023810              return false; 
    38033811            } 
    3804             if ((*iter)->nId == p_in.Id() && (*iter)->nUin == nUin) 
     3812            if ((*iter)->nId == p_in.Id() && (*iter)->myIdString == id) 
    38053813            { 
    38063814              s->SetChannel((*iter)->nData); 
     
    38293837      CPacketTcp_Handshake_v6 p_in(&b); 
    38303838      nUin = p_in.SourceUin(); 
    3831  
    3832       ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     3839      snprintf(id, 16, "%lu", nUin); 
     3840 
     3841      ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    38333842      if (u == NULL) 
    38343843      { 
     
    38423851      { 
    38433852        char ipbuf[32]; 
    3844         gLog.Warn("%sSpoofed connection from %s as uin %lu.\n", L_WARNxSTR, 
    3845                   s->RemoteIpStr(ipbuf), nUin); 
     3853        gLog.Warn("%sSpoofed connection from %s as uin %s.\n", L_WARNxSTR, 
     3854            s->RemoteIpStr(ipbuf), id); 
    38463855        return false; 
    38473856      } 
     
    38763885      { 
    38773886        // For v6 there is no connection id, so just use uin 
    3878         if ((*iter)->nUin == nUin) 
     3887        if ((*iter)->myIdString == id) 
    38793888        { 
    38803889          (*iter)->bSuccess = true; 
     
    38933902      b.UnpackUnsignedLong(); // port number 
    38943903      nUin = b.UnpackUnsignedLong(); 
     3904      snprintf(id, 16, "%lu", nUin); 
    38953905      nVersion = VersionToUse(nVersionMajor); 
    38963906 
    3897       ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     3907      ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    38983908      if (u == NULL) 
    38993909      { 
     
    39113921        char ipbuf[32]; 
    39123922        return false; 
    3913         gLog.Warn("%sConnection from %s as %lu possible spoof.\n", L_WARNxSTR, 
    3914                   s->RemoteIpStr(ipbuf), nUin); 
     3923        gLog.Warn("%sConnection from %s as %s possible spoof.\n", L_WARNxSTR, 
     3924            s->RemoteIpStr(ipbuf), id); 
    39153925        return false; 
    39163926      } 
    3917        
     3927 
    39183928      pthread_mutex_lock(&mutex_reverseconnect); 
    39193929      std::list<CReverseConnectToUserData *>::iterator iter; 
     
    39223932      { 
    39233933        // For v4 there is no connection id, so just use uin 
    3924         if ((*iter)->nUin == nUin) 
     3934        if ((*iter)->myIdString == id) 
    39253935        { 
    39263936          (*iter)->bSuccess = true; 
     
    39403950      b.UnpackUnsignedLong(); // port number 
    39413951      nUin = b.UnpackUnsignedLong(); 
     3952      snprintf(id, 16, "%lu", nUin); 
    39423953      nVersion = 2; 
    3943        
    3944       ICQUser *u = gUserManager.FetchUser(nUin, LOCK_R); 
     3954 
     3955      ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    39453956      if (u == NULL) 
    39463957      { 
     
    39583969        char ipbuf[32]; 
    39593970        return false; 
    3960         gLog.Warn("%sConnection from %s as %lu possible spoof.\n", L_WARNxSTR, 
    3961                   s->RemoteIpStr(ipbuf), nUin); 
     3971        gLog.Warn("%sConnection from %s as %s possible spoof.\n", L_WARNxSTR, 
     3972            s->RemoteIpStr(ipbuf), id); 
    39623973        return false; 
    39633974      } 
     
    39693980      { 
    39703981        // For v2 there is no connection id, so just use uin 
    3971         if ((*iter)->nUin == nUin) 
     3982        if ((*iter)->myIdString == id) 
    39723983        { 
    39733984          (*iter)->bSuccess = true; 
     
    39914002  } 
    39924003 
    3993   char szUin[13]; 
    3994   snprintf(szUin, 12, "%lu", nUin); 
    3995   s->SetOwner(szUin, LICQ_PPID); 
     4004  s->SetOwner(id, LICQ_PPID); 
    39964005  s->SetVersion(nVersion); 
    39974006 
  • trunk/licq/src/icqd-threads.cpp

    r6401 r6402  
    384384  if (e->m_nSocketDesc == -1) 
    385385  { 
    386     unsigned long nDestinationUin = e->m_nDestinationUin; 
     386    string id = e->Id(); 
     387    unsigned long ppid = e->PPID(); 
    387388    unsigned char nChannel = e->Channel(); 
    388389    pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 
    389     
    390     ICQUser *u = gUserManager.FetchUser(nDestinationUin, LOCK_R); 
     390 
     391    ICQUser* u = gUserManager.FetchUser(id.c_str(), ppid, LOCK_R); 
    391392    if (u == NULL) 
    392393    { 
     
    416417    if (!bSendIntIp && nVersion > 6 && nMode != MODE_DIRECT) 
    417418    { 
    418       int nId = d->RequestReverseConnection(nDestinationUin, nChannel, nIP, 
    419                                             nLocalPort, nRemotePort); 
     419      int nId = d->RequestReverseConnection(id.c_str(), nChannel, nIP, nLocalPort, nRemotePort); 
    420420      if (nId != -1) 
    421421      { 
    422         d->WaitForReverseConnection(nId, nDestinationUin); 
    423         u = gUserManager.FetchUser(nDestinationUin, LOCK_R); 
     422        d->WaitForReverseConnection(nId, id.c_str()); 
     423        u = gUserManager.FetchUser(id.c_str(), LICQ_PPID, LOCK_R); 
    424424        if (u == NULL) 
    425425        { 
     
    445445        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 
    446446 
    447         socket = d->ConnectToUser(nDestinationUin, nChannel); 
     447        socket = d->ConnectToUser(id.c_str(), nChannel); 
    448448      } 
    449449    } 
    450450    else 
    451451    { 
    452       socket = d->ConnectToUser(nDestinationUin, nChannel); 
     452      socket = d->ConnectToUser(id.c_str(), nChannel); 
    453453 
    454454      // if we failed, try through server 
     
    459459        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 
    460460 
    461         int nId = d->RequestReverseConnection(nDestinationUin, nChannel, nIP, 
     461        int nId = d->RequestReverseConnection(id.c_str(), nChannel, nIP, 
    462462                                              nLocalPort, nRemotePort); 
    463463        if (nId != -1) 
    464464        { 
    465           d->WaitForReverseConnection(nId, nDestinationUin); 
    466           u = gUserManager.FetchUser(nDestinationUin, LOCK_R); 
     465          d->WaitForReverseConnection(nId, id.c_str()); 
     466          u = gUserManager.FetchUser(id.c_str(), LICQ_PPID, LOCK_R); 
    467467          if (u == NULL) 
    468468          { 
     
    604604  CReverseConnectToUserData *p = (CReverseConnectToUserData *)v; 
    605605 
    606   gLicqDaemon->ReverseConnectToUser(p->nUin, p->nIp, p->nPort, p->nVersion, 
    607     p->nFailedPort, p->nId, p->nMsgID1, p->nMsgID2); 
     606  gLicqDaemon->ReverseConnectToUser(p->myIdString.c_str(), p->nIp, p->nPort, 
     607      p->nVersion, p->nFailedPort, p->nId, p->nMsgID1, p->nMsgID2); 
    608608 
    609609  delete p; 
  • trunk/licq/src/icqd.cpp

    r6390 r6402  
    27222722} 
    27232723 
    2724 bool CICQDaemon::WaitForReverseConnection(unsigned short id, unsigned long uin) 
     2724bool CICQDaemon::WaitForReverseConnection(unsigned short id, const char* userId) 
    27252725{ 
    27262726  bool bSuccess = false; 
     
    27312731    ++iter) 
    27322732  { 
    2733     if ((*iter)->nId == id && (*iter)->nUin == uin) 
     2733    if ((*iter)->nId == id && (*iter)->myIdString == userId) 
    27342734      break; 
    27352735  } 
     
    27572757        goto done; 
    27582758      } 
    2759       if ((*iter)->nId == id && (*iter)->nUin == uin) 
     2759      if ((*iter)->nId == id && (*iter)->myIdString == userId) 
    27602760      { 
    27612761        if ((*iter)->bFinished) 
     
    27752775    ++iter) 
    27762776  { 
    2777     if ((*iter)->nId == id && (*iter)->nUin == uin) 
     2777    if ((*iter)->nId == id && (*iter)->myIdString == userId) 
    27782778    { 
    27792779      delete *iter; 
     
    27882788} 
    27892789 
    2790 CReverseConnectToUserData::CReverseConnectToUserData(unsigned long uin, unsigned long id, 
     2790CReverseConnectToUserData::CReverseConnectToUserData(const char* idString, unsigned long id, 
    27912791      unsigned long data, unsigned long ip, unsigned short port, 
    27922792      unsigned short version, unsigned short failedport, unsigned long msgid1, 
    27932793      unsigned long msgid2) : 
    2794   nUin(uin), nId(id), nData(data), nIp(ip), nPort(port), 
     2794  myIdString(idString), nId(id), nData(data), nIp(ip), nPort(port), 
    27952795  nFailedPort(failedport), nVersion(version), nMsgID1(msgid1), 
    27962796  nMsgID2(msgid2), bSuccess(false), bFinished(false) 
  • trunk/licq/src/icqpacket.cpp

    r6387 r6402  
    17611761  CPU_Type2Message::InitBuffer(); 
    17621762 
    1763   ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 
    1764  
    1765   buffer->PackUnsignedLong(o->Uin()); 
     1763  buffer->PackUnsignedLong(gUserManager.icqOwnerUin()); 
    17661764  buffer->PackUnsignedLong(nLocalIP); 
    17671765  buffer->PackUnsignedLong(nLocalPort); 
     
    17741772  buffer->PackUnsignedLong(m_nSubSequence); 
    17751773//  buffer->PackUnsignedLongBE(0x00030000); 
    1776   gUserManager.DropOwner(o); 
    1777 } 
    1778  
    1779 CPU_ReverseConnectFailed::CPU_ReverseConnectFailed(unsigned long nUin, 
     1774} 
     1775 
     1776CPU_ReverseConnectFailed::CPU_ReverseConnectFailed(const char* szUin, 
    17801777                                                   unsigned long nMsgID1, 
    17811778                                                   unsigned long nMsgID2, 
     
    17851782  : CPU_CommonFamily(ICQ_SNACxFAM_MESSAGE, ICQ_SNACxMSG_SERVERxREPLYxMSG) 
    17861783{ 
    1787   char szUin[13]; 
    1788   int nUinLen = snprintf(szUin, 12, "%lu", nUin); 
     1784  int nUinLen = strlen(szUin); 
    17891785 
    17901786  m_nSize += 8 + 2 + 1 + nUinLen + 2 + 4 + 4 + 4 + 2 + 4; 
    17911787 
    17921788  InitBuffer(); 
    1793  
    1794   ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 
    17951789 
    17961790  buffer->PackUnsignedLongBE(nMsgID1); 
     
    18001794  buffer->Pack(szUin, nUinLen); 
    18011795  buffer->PackUnsignedShortBE(0x0003); 
    1802   buffer->PackUnsignedLong(o->Uin()); 
     1796  buffer->PackUnsignedLong(gUserManager.icqOwnerUin()); 
    18031797  buffer->PackUnsignedLong(nFailedPort); 
    18041798  buffer->PackUnsignedLong(nOurPort); 
    18051799  buffer->PackUnsignedShort(ICQ_VERSION_TCP); 
    18061800  buffer->PackUnsignedLong(nConnectID); 
    1807  
    1808   gUserManager.DropOwner(o); 
    18091801} 
    18101802 
     
    44324424  buffer->PackUnsignedLong(nLocalPort == 0 ? s_nLocalPort : nLocalPort); 
    44334425 
    4434   ICQUser *u = gUserManager.FetchUser(nDestinationUin, LOCK_R); 
     4426  char id[16]; 
     4427  snprintf(id, 16, "%lu", nDestinationUin); 
     4428  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    44354429  if (u) 
    44364430  { 
     
    44894483  buffer->PackUnsignedLong(nLocalPort == 0 ? s_nLocalPort : nLocalPort); 
    44904484 
    4491   ICQUser *u = gUserManager.FetchUser(nDestinationUin, LOCK_R); 
     4485  char id[16]; 
     4486  snprintf(id, 16, "%lu", nDestinationUin); 
     4487  ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_R); 
    44924488  if (u) 
    44934489  { 
  • trunk/licq/src/oscarservice.cpp

    r6401 r6402  
    447447 
    448448  ChangeStatus(STATUS_CONNECTED); 
    449   SrvSocket *s = new SrvSocket(gUserManager.icqOwnerUin()); 
     449  SrvSocket* s = new SrvSocket(gUserManager.OwnerId(LICQ_PPID).c_str(), LICQ_PPID); 
    450450  gLog.Info(tr("%sConnecting to separate server for service 0x%02X.\n"), 
    451451            L_SRVxSTR, myFam);