Changeset 6364

Show
Ignore:
Timestamp:
07/01/08 03:07:09 (2 months ago)
Author:
flynd
Message:

Removed the user list since there is no need to have both a list and a map.

Location:
trunk/licq
Files:
2 modified

Legend:

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

    r6363 r6364  
    3333  {                                                      \ 
    3434    ICQUser *pUser;                                      \ 
    35     UserList *_ul_ = gUserManager.LockUserList(LOCK_R); \ 
    36     for (UserList::iterator _i_ = _ul_->begin();         \ 
     35    const UserMap* _ul_ = gUserManager.LockUserList(LOCK_R); \ 
     36    for (UserMap::const_iterator _i_ = _ul_->begin();    \ 
    3737         _i_ != _ul_->end(); _i_++)                      \ 
    3838    {                                                    \ 
    39       pUser = *_i_;                                      \ 
     39      pUser = _i_->second;                               \ 
    4040      pUser->Lock(x);                                    \ 
    4141      { 
     
    4444  {                                                      \ 
    4545    ICQUser *pUser;                                      \ 
    46     UserList *_ul_ = gUserManager.LockUserList(LOCK_R); \ 
    47     for (UserList::iterator _i_ = _ul_->begin();         \ 
     46    const UserMap* _ul_ = gUserManager.LockUserList(LOCK_R); \ 
     47    for (UserMap::const_iterator _i_ = _ul_->begin();    \ 
    4848         _i_ != _ul_->end(); _i_++)                      \ 
    4949    {                                                    \ 
    50       pUser = *_i_;                                      \ 
    51       if (pUser->PPID() == x)                            \ 
    52       {                                                  \ 
    53         pUser->Lock(y);                                  \ 
    54         { 
     50      if (_i_->first.second != x)                        \ 
     51        continue;                                        \ 
     52      pUser = _i_->second;                               \ 
     53      pUser->Lock(y);                                    \ 
     54      { 
    5555 
    5656#define FOR_EACH_OWNER_START(x)                           \ 
     
    8585  } 
    8686 
    87 #define FOR_EACH_PROTO_USER_END        \ 
    88         }                                \ 
    89         pUser->Unlock();                 \ 
    90       }                                  \ 
    91     }                                    \ 
    92     gUserManager.UnlockUserList();       \ 
    93   } 
     87#define FOR_EACH_PROTO_USER_END FOR_EACH_USER_END 
    9488 
    9589#define FOR_EACH_USER_BREAK              \ 
     
    178172  {                                                      \ 
    179173    unsigned long nUin;                                  \ 
    180     UserList *_ul_ = gUserManager.LockUserList(LOCK_R); \ 
    181     for (UserList::iterator _i_ = _ul_->begin();         \ 
     174    const UserMap* _ul_ = gUserManager.LockUserList(LOCK_R); \ 
     175    for (UserMap::const_iterator _i_ = _ul_->begin();    \ 
    182176         _i_ != _ul_->end(); _i_++)                      \ 
    183177    {                                                    \ 
    184       nUin = (*_i_)->Uin();                              \ 
     178      nUin = _i_->second->Uin();                         \ 
    185179      { 
    186180 
     
    188182  {                                                      \ 
    189183    char *szId;                                          \ 
    190     UserList *_ul_ = gUserManager.LockUserList(LOCK_R);  \ 
    191     for (UserList::iterator _i_ = _ul_->begin();         \ 
     184    UserMap* _ul_ = gUserManager.LockUserList(LOCK_R);   \ 
     185    for (UserMap::const_iterator _i_ = _ul_->begin();    \ 
    192186         _i_ != _ul_->end(); _i_++)                      \ 
    193187    {                                                    \ 
    194       if ((*_i_)->PPID() == x)                           \ 
    195       {                                                  \ 
    196         szId = (*_i_)->IdString();                       \ 
    197         { 
     188      if (_i_->first.second != x)                        \ 
     189        continue;                                        \ 
     190      szId = (*_i_)->IdString();                         \ 
     191      { 
    198192 
    199193#define FOR_EACH_UIN_END                 \ 
     
    203197  } 
    204198 
    205 #define FOR_EACH_PROTO_ID_END            \ 
    206         }                                \ 
    207       }                                  \ 
    208     }                                    \ 
    209     gUserManager.UnlockUserList();       \ 
    210   } 
     199#define FOR_EACH_PROTO_ID_END FOR_EACH_UIN_END 
    211200 
    212201#define FOR_EACH_UIN_BREAK               \ 
     
    236225typedef std::pair<std::string, unsigned long> UserMapKey; 
    237226typedef std::map<UserMapKey, class ICQUser*> UserMap; 
    238 typedef std::list<ICQUser *> UserList; 
    239227typedef std::list<class ICQOwner *> OwnerList; 
    240228typedef std::set<unsigned short> UserGroupList; 
     
    12901278  bool IsOnList(unsigned long nUin); 
    12911279 
    1292   UserList *LockUserList(unsigned short); 
     1280  /** 
     1281   * Lock user list for access 
     1282   * call UnlockUserList when lock is no longer needed 
     1283   * 
     1284   * @param lockType Type of lock (LOCK_R or LOCK_W) 
     1285   * @return Map of all users indexed by UserMapKey 
     1286   */ 
     1287  UserMap* LockUserList(unsigned short lockType); 
     1288 
     1289  /** 
     1290   * Release user list lock 
     1291   */ 
    12931292  void UnlockUserList(); 
    12941293 
     
    14861485 
    14871486  GroupMap myGroups; 
    1488   UserList m_vpcUsers; 
    14891487  UserMap myUsers; 
    14901488  OwnerList m_vpcOwners; 
  • trunk/licq/src/user.cpp

    r6363 r6364  
    510510CUserManager::~CUserManager() 
    511511{ 
    512   UserList::iterator iter; 
    513   for (iter = m_vpcUsers.begin(); iter != m_vpcUsers.end(); ++iter) 
    514   { 
    515     delete *iter; 
    516   } 
     512  UserMap::iterator iter; 
     513  for (iter = myUsers.begin(); iter != myUsers.end(); ++iter) 
     514    delete iter->second; 
    517515 
    518516  GroupMap::iterator g_iter; 
     
    681679    u->AddToContactList(); 
    682680    myUsers[UserMapKey(szId, nPPID)] = u; 
    683     m_vpcUsers.push_back(u); 
    684681  } 
    685682  UnlockUserList(); 
     
    715712  // Store the user in the lookup map 
    716713  myUsers[UserMapKey(_szId, _nPPID)] = pUser; 
    717   // Reorder the user to the correct place 
    718   m_vpcUsers.push_back(pUser); 
    719714 
    720715  UnlockUserList(); 
     
    728723    u->RemoveFiles(); 
    729724  LockUserList(LOCK_W); 
    730   UserList::iterator iter = m_vpcUsers.begin(); 
    731   while (iter != m_vpcUsers.end() && u != (*iter)) ++iter; 
    732   if (iter == m_vpcUsers.end()) 
    733     gLog.Warn("%sInteral Error: CUserManager::RemoveUser():\n" 
    734               "%sUser \"%s\" (%s) not found in vector.\n", 
    735               L_WARNxSTR, L_BLANKxSTR, u->GetAlias(), u->IdString()); 
    736   else 
    737     m_vpcUsers.erase(iter); 
    738   DropUser(u); 
    739725  myUsers.erase(UserMapKey(_szId, _nPPID)); 
    740726  UnlockUserList(); 
     727  DropUser(u); 
    741728  delete u; 
    742729} 
     
    14401427{ 
    14411428  //LockUserList(LOCK_R); 
    1442   unsigned short n = m_vpcUsers.size(); 
     1429  unsigned short n = myUsers.size(); 
    14431430  //UnlockUserList(); 
    14441431  return n; 
     
    14721459 * Locks the entire user list for iterating through... 
    14731460 *-------------------------------------------------------------------------*/ 
    1474 UserList *CUserManager::LockUserList(unsigned short _nLockType) 
     1461UserMap* CUserManager::LockUserList(unsigned short _nLockType) 
    14751462{ 
    14761463  switch (_nLockType) 
     
    14871474  } 
    14881475  m_nUserListLockType = _nLockType; 
    1489   return &m_vpcUsers; 
     1476  return &myUsers; 
    14901477} 
    14911478