Changeset 6338

Show
Ignore:
Timestamp:
06/18/08 23:55:04 (6 months ago)
Author:
flynd
Message:

Added function so we can check if a group exists without locking it.

Location:
trunk/licq
Files:
2 modified

Legend:

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

    r6329 r6338  
    13601360 
    13611361  /** 
     1362   * Check if a group id is valid 
     1363   * 
     1364   * @param gtype Group type 
     1365   * @param groupId Id of group to check for 
     1366   * @return True if the group exists 
     1367   */ 
     1368  bool groupExists(GroupType gtype, unsigned short groupId); 
     1369 
     1370  /** 
    13621371   * Add a user group 
    13631372   * 
  • trunk/licq/src/user.cpp

    r6328 r6338  
    872872  if (group != NULL) 
    873873    group->Unlock(); 
     874} 
     875 
     876bool CUserManager::groupExists(GroupType gtype, unsigned short groupId) 
     877{ 
     878  // Is it a valid system group? 
     879  if (gtype == GROUPS_SYSTEM) 
     880    return (groupId <= NUM_GROUPS_SYSTEM_ALL); 
     881 
     882  // Is it an invalid group type? 
     883  if (gtype != GROUPS_USER) 
     884    return false; 
     885 
     886  // Does the user group exist in the list? 
     887  GroupMap* groups = LockGroupList(LOCK_R); 
     888  GroupMap::const_iterator iter = groups->find(groupId); 
     889  bool found = (iter != groups->end()); 
     890  UnlockGroupList(); 
     891  return found; 
    874892} 
    875893