Changeset 6277
- Timestamp:
- 06/13/08 03:16:28 (7 months ago)
- Location:
- trunk/licq
- Files:
-
- 4 modified
-
include/licq_icqd.h (modified) (1 diff)
-
include/licq_user.h (modified) (1 diff)
-
src/icqd-srv.cpp (modified) (3 diffs)
-
src/user.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/licq/include/licq_icqd.h
r6227 r6277 481 481 482 482 // Visible/Invisible/Ignore list functions 483 /** 484 * Set visible list status for a contact 485 * 486 * @param id User id 487 * @param ppid User protocol id 488 * @param visible True to add user to visible list or false to remove 489 */ 490 void ProtoSetInVisibleList(const char* id, unsigned long ppid, bool visible); 491 492 /** 493 * Set invisible list status for a contact 494 * 495 * @param id User id 496 * @param ppid User protocol id 497 * @param invisible True to add user to invisible list or false to remove 498 */ 499 void ProtoSetInInvisibleList(const char* id, unsigned long ppid, bool invisible); 500 501 /** 502 * Set invisible list status for a contact 503 * 504 * @param id User id 505 * @param ppid User protocol id 506 * @param ignore True to add user to ignore list or false to remove 507 */ 508 void ProtoSetInIgnoreList(const char* id, unsigned long ppid, bool ignore); 509 483 510 void ProtoToggleInvisibleList(const char *_szId, unsigned long _nPPID); 484 511 void ProtoToggleVisibleList(const char *_szId, unsigned long _nPPID); -
trunk/licq/include/licq_user.h
r6248 r6277 1128 1128 unsigned short GenerateSID(); 1129 1129 1130 /** 1131 * Set user group membership and (optionally) update server 1132 * 1133 * @param id User id 1134 * @param ppid User protocol id 1135 * @param groupType Group type 1136 * @param groupId Group id 1137 * @param inGroup True to add user to group or false to remove 1138 * @param updateServer True if server list should be updated 1139 */ 1140 void SetUserInGroup(const char* id, unsigned long ppid, GroupType groupType, 1141 unsigned short groupId, bool inGroup, bool updateServer = true); 1142 1143 // Deprecated group manipulation functions 1130 1144 void AddUserToGroup(unsigned long _nUin, unsigned short _nGroup); 1131 1145 void RemoveUserFromGroup(unsigned long _nUin, unsigned short _nGroup); 1132 void AddUserToGroup(const char *, unsigned long, unsigned short); 1133 void RemoveUserFromGroup(const char *, unsigned long, unsigned short); 1146 1147 /** 1148 * Add user to a group and update server group 1149 * 1150 * @param id User id 1151 * @param ppid User protocol id 1152 * @param groupId Group id 1153 */ 1154 void AddUserToGroup(const char* id, unsigned long ppid, unsigned short groupId) 1155 { SetUserInGroup(id, ppid, GROUPS_USER, groupId, true, true); } 1156 1157 /** 1158 * Remove user from a group 1159 * 1160 * @param id User id 1161 * @param ppid User protocol id 1162 * @param groupId Group id 1163 */ 1164 void RemoveUserFromGroup(const char* id, unsigned long ppid, unsigned short groupId) 1165 { SetUserInGroup(id, ppid, GROUPS_USER, groupId, false); } 1166 1134 1167 void SaveAllUsers(); 1135 1168 -
trunk/licq/src/icqd-srv.cpp
r6246 r6277 1320 1320 bool b = u->VisibleList(); 1321 1321 gUserManager.DropUser(u); 1322 1323 if (b) 1322 ProtoSetInVisibleList(_szId, _nPPID, !b); 1323 } 1324 1325 void CICQDaemon::ProtoSetInVisibleList(const char* _szId, unsigned long _nPPID, bool visible) 1326 { 1327 if (!visible) 1324 1328 if (_nPPID == LICQ_PPID) 1325 1329 icqRemoveFromVisibleList(_szId, _nPPID); … … 1349 1353 bool b = u->InvisibleList(); 1350 1354 gUserManager.DropUser(u); 1351 1352 if (b) 1355 ProtoSetInInvisibleList(_szId, _nPPID, !b); 1356 } 1357 1358 void CICQDaemon::ProtoSetInInvisibleList(const char* _szId, unsigned long _nPPID, bool invisible) 1359 { 1360 if (!invisible) 1353 1361 if (_nPPID == LICQ_PPID) 1354 1362 icqRemoveFromInvisibleList(_szId, _nPPID); … … 1378 1386 bool b = u->IgnoreList(); 1379 1387 gUserManager.DropUser(u); 1380 1388 ProtoSetInIgnoreList(_szId, _nPPID, b); 1389 } 1390 1391 void CICQDaemon::ProtoSetInIgnoreList(const char* _szId, unsigned long _nPPID, bool b) 1392 { 1381 1393 if (_nPPID == LICQ_PPID) 1382 1394 { -
trunk/licq/src/user.cpp
r6271 r6277 1602 1602 } 1603 1603 1604 /*--------------------------------------------------------------------------- 1605 * CUserManager::AddUserToGroup 1606 *-------------------------------------------------------------------------*/ 1607 void CUserManager::AddUserToGroup(const char *szId, unsigned long nPPID, 1608 unsigned short _nGroup) 1609 { 1610 //TODO: For other protocols 1611 ICQUser *u = FetchUser(szId, nPPID, LOCK_W); 1612 if (u == NULL) return; 1613 u->AddToGroup(GROUPS_USER, _nGroup); 1614 int nGSID = u->GetGSID(); 1615 DropUser(u); 1616 if (gLicqDaemon && nPPID == LICQ_PPID) 1617 gLicqDaemon->icqChangeGroup(szId, nPPID, _nGroup, 1618 nGSID, ICQ_ROSTxNORMAL, ICQ_ROSTxNORMAL); 1604 void CUserManager::SetUserInGroup(const char* id, unsigned long ppid, 1605 GroupType groupType, unsigned short groupId, bool inGroup, bool updateServer) 1606 { 1607 ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_W); 1608 if (u == NULL) 1609 return; 1610 1611 int gsid = u->GetGSID(); 1612 1613 if (!inGroup && u->GetSID() != 0 && GetGroupFromID(gsid) == groupId) 1614 { 1615 // Don't remove user from local group if member of the same server group 1616 gUserManager.DropUser(u); 1617 return; 1618 } 1619 1620 // Update user object 1621 u->SetInGroup(groupType, groupId, inGroup); 1622 gUserManager.DropUser(u); 1623 1624 // Notify server 1625 if (updateServer && gLicqDaemon != NULL) 1626 { 1627 if (groupType == GROUPS_SYSTEM) 1628 { 1629 if (groupId == GROUP_VISIBLE_LIST) 1630 gLicqDaemon->ProtoSetInVisibleList(id, ppid, inGroup); 1631 1632 else if (groupId == GROUP_INVISIBLE_LIST) 1633 gLicqDaemon->ProtoSetInInvisibleList(id, ppid, inGroup); 1634 1635 else if (groupId == GROUP_IGNORE_LIST) 1636 gLicqDaemon->ProtoSetInIgnoreList(id, ppid, inGroup); 1637 } 1638 else 1639 { 1640 // Server group currently only supported for ICQ protocol 1641 // Group can only be changed, not removed 1642 if (ppid == LICQ_PPID && inGroup) 1643 gLicqDaemon->icqChangeGroup(id, ppid, groupId, gsid, 1644 ICQ_ROSTxNORMAL, ICQ_ROSTxNORMAL); 1645 } 1646 } 1619 1647 } 1620 1648 1621 1649 void CUserManager::AddUserToGroup(unsigned long _nUin, unsigned short _nGroup) 1622 1650 { 1623 ICQUser *u = FetchUser(_nUin, LOCK_W); 1624 if (u == NULL) return; 1625 u->AddToGroup(GROUPS_USER, _nGroup); 1626 int nGSID = u->GetGSID(); 1627 DropUser(u); 1628 if (gLicqDaemon) 1629 gLicqDaemon->icqChangeGroup(_nUin, _nGroup, nGSID, ICQ_ROSTxNORMAL, 1630 ICQ_ROSTxNORMAL); 1631 } 1632 1633 1634 /*--------------------------------------------------------------------------- 1635 * CUserManager::RemoveUserFromGroup 1636 *-------------------------------------------------------------------------*/ 1637 void CUserManager::RemoveUserFromGroup(const char *szId, unsigned long nPPID, 1638 unsigned short _nGroup) 1639 { 1640 ICQUser *u = FetchUser(szId, nPPID, LOCK_W); 1641 if (u == NULL) return; 1642 u->RemoveFromGroup(GROUPS_USER, _nGroup); 1643 DropUser(u); 1644 } 1645 1651 char id[13]; 1652 snprintf(id, 12, "%lu", _nUin); 1653 id[12] = '\0'; 1654 AddUserToGroup(id, LICQ_PPID, _nGroup); 1655 } 1646 1656 1647 1657 void CUserManager::RemoveUserFromGroup(unsigned long _nUin, unsigned short _nGroup) 1648 1658 { 1649 ICQUser *u = FetchUser(_nUin, LOCK_W); 1650 if (u == NULL) return; 1651 u->RemoveFromGroup(GROUPS_USER, _nGroup); 1652 DropUser(u); 1653 } 1654 1659 char id[13]; 1660 snprintf(id, 12, "%lu", _nUin); 1661 id[12] = '\0'; 1662 RemoveUserFromGroup(id, LICQ_PPID, _nGroup); 1663 } 1655 1664 1656 1665 void CUserManager::SetDefaultUserEncoding(const char* defaultEncoding)
