Changeset 3473 for branches/protocol_plugin_1_3_0
- Timestamp:
- 05/01/03 14:14:19 (6 years ago)
- Location:
- branches/protocol_plugin_1_3_0/licq/src
- Files:
-
- 2 modified
-
icqd-srv.cpp (modified) (8 diffs)
-
icqpacket.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/protocol_plugin_1_3_0/licq/src/icqd-srv.cpp
r3469 r3473 128 128 129 129 // Export users on a per group basis for the update group packet to work 130 U inList doneUin;130 UserStringList doneUsers; 131 131 for (unsigned int j = 1; j <= g->size(); j++) 132 132 { 133 U inList uins;134 FOR_EACH_ USER_START(LOCK_R)133 UserStringList users; 134 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 135 135 { 136 136 if (pUser->GetInGroup(GROUPS_USER, j) && pUser->GetSID() == 0 && 137 137 !pUser->IgnoreList()) 138 138 { 139 U inList::const_iterator p = std::find(doneUin.begin(), doneUin.end(),140 pUser-> Uin());141 142 if (p == doneU in.end())143 { 144 u ins.push_back(pUser->Uin());145 doneU in.push_back(pUser->Uin());139 UserStringList::const_iterator p = std::find(doneUsers.begin(), doneUsers.end(), 140 pUser->IdString()); 141 142 if (p == doneUsers.end()) 143 { 144 users.push_back(strdup(pUser->IdString())); 145 doneUsers.push_back(strdup(pUser->IdString())); 146 146 147 147 pthread_mutex_lock(&mutex_modifyserverusers); 148 m_lszModifyServerUsers.push_back(strdup(pUser-> UinString()));148 m_lszModifyServerUsers.push_back(strdup(pUser->IdString())); 149 149 pthread_mutex_unlock(&mutex_modifyserverusers); 150 150 } 151 151 } 152 152 } 153 FOR_EACH_USER_END 154 155 if (uins.size()) 156 icqExportUsers(uins, ICQ_ROSTxNORMAL); 157 } 153 FOR_EACH_PROTO_USER_END 154 155 if (users.size()) 156 icqExportUsers(users, ICQ_ROSTxNORMAL); 157 } 158 159 UserStringList::iterator it; 160 for (it = doneUsers.begin(); it != doneUsers.end(); it++) 161 free(*it); 158 162 159 163 // Export visible/invisible/ignore list 160 U inList visibleUins, invisibleUins, ignoredUins;161 FOR_EACH_ USER_START(LOCK_R)164 UserStringList visibleUsers, invisibleUsers, ignoredUsers; 165 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 162 166 { 163 167 if (pUser->IgnoreList() && pUser->GetSID() == 0) 164 168 { 165 ignoredU ins.push_back(pUser->Uin());169 ignoredUsers.push_back(strdup(pUser->IdString())); 166 170 167 171 pthread_mutex_lock(&mutex_modifyserverusers); 168 m_lszModifyServerUsers.push_back(strdup(pUser-> UinString()));172 m_lszModifyServerUsers.push_back(strdup(pUser->IdString())); 169 173 pthread_mutex_unlock(&mutex_modifyserverusers); 170 174 } … … 173 177 if (pUser->InvisibleList() && pUser->GetInvisibleSID() == 0) 174 178 { 175 invisibleU ins.push_back(pUser->Uin());179 invisibleUsers.push_back(strdup(pUser->IdString())); 176 180 177 181 pthread_mutex_lock(&mutex_modifyserverusers); 178 m_lszModifyServerUsers.push_back(strdup(pUser-> UinString()));182 m_lszModifyServerUsers.push_back(strdup(pUser->IdString())); 179 183 pthread_mutex_unlock(&mutex_modifyserverusers); 180 184 } … … 182 186 if (pUser->VisibleList() && pUser->GetVisibleSID() == 0) 183 187 { 184 visibleU ins.push_back(pUser->Uin());188 visibleUsers.push_back(strdup(pUser->IdString())); 185 189 186 190 pthread_mutex_lock(&mutex_modifyserverusers); 187 m_lszModifyServerUsers.push_back(strdup(pUser-> UinString()));191 m_lszModifyServerUsers.push_back(strdup(pUser->IdString())); 188 192 pthread_mutex_unlock(&mutex_modifyserverusers); 189 193 } 190 194 } 191 195 } 192 FOR_EACH_ USER_END193 194 if (visibleU ins.size())195 icqExportUsers(visibleU ins, ICQ_ROSTxVISIBLE);196 197 if (invisibleU ins.size())198 icqExportUsers(invisibleU ins, ICQ_ROSTxINVISIBLE);199 200 if (ignoredU ins.size())201 icqExportUsers(ignoredU ins, ICQ_ROSTxIGNORE);196 FOR_EACH_PROTO_USER_END 197 198 if (visibleUsers.size()) 199 icqExportUsers(visibleUsers, ICQ_ROSTxVISIBLE); 200 201 if (invisibleUsers.size()) 202 icqExportUsers(invisibleUsers, ICQ_ROSTxINVISIBLE); 203 204 if (ignoredUsers.size()) 205 icqExportUsers(ignoredUsers, ICQ_ROSTxIGNORE); 202 206 } 203 207 204 208 //-----icqExportUsers----------------------------------------------------------- 205 void CICQDaemon::icqExportUsers(U inList &uins, unsigned short _nType)209 void CICQDaemon::icqExportUsers(UserStringList &users, unsigned short _nType) 206 210 { 207 211 if (!UseServerContactList()) return; … … 210 214 SendEvent_Server(pStart); 211 215 212 CSrvPacketTcp *pExport = new CPU_ExportToServerList(u ins, _nType);216 CSrvPacketTcp *pExport = new CPU_ExportToServerList(users, _nType); 213 217 gLog.Info("%sExporting users to server contact list...\n", L_SRVxSTR); 214 218 SendExpectEvent_Server(0L, pExport, NULL); … … 827 831 { 828 832 unsigned short n = 0; 829 U inList uins;830 FOR_EACH_ USER_START(LOCK_W)833 UserStringList users; 834 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_W) 831 835 { 832 836 n++; 833 u ins.push_back(pUser->Uin());837 users.push_back(strdup(pUser->IdString())); 834 838 if (n == m_nMaxUsersPerPacket) 835 839 { 836 CSrvPacketTcp *p = new CPU_GenericUinList(u ins, ICQ_SNACxFAM_BUDDY, ICQ_SNACxBDY_ADDxTOxLIST);840 CSrvPacketTcp *p = new CPU_GenericUinList(users, ICQ_SNACxFAM_BUDDY, ICQ_SNACxBDY_ADDxTOxLIST); 837 841 gLog.Info("%sUpdating contact list (#%ld)...\n", L_SRVxSTR, p->Sequence()); 838 842 SendEvent_Server(p); 839 u ins.erase(uins.begin(), uins.end());843 users.erase(users.begin(), users.end()); 840 844 n = 0; 841 845 } … … 843 847 if (!pUser->StatusOffline()) ChangeUserStatus(pUser, ICQ_STATUS_OFFLINE); 844 848 } 845 FOR_EACH_ USER_END849 FOR_EACH_PROTO_USER_END 846 850 if (n != 0) 847 851 { 848 CSrvPacketTcp *p = new CPU_GenericUinList(u ins, ICQ_SNACxFAM_BUDDY, ICQ_SNACxBDY_ADDxTOxLIST);852 CSrvPacketTcp *p = new CPU_GenericUinList(users, ICQ_SNACxFAM_BUDDY, ICQ_SNACxBDY_ADDxTOxLIST); 849 853 gLog.Info("%sUpdating contact list (#%ld)...\n", L_SRVxSTR, p->Sequence()); 850 854 SendEvent_Server(p); … … 858 862 // Go through the entire list of users, checking if each one is on 859 863 // the visible list 860 U inList uins;861 FOR_EACH_ USER_START(LOCK_R)864 UserStringList users; 865 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 862 866 { 863 867 if (pUser->GetInGroup(GROUPS_SYSTEM, GROUP_VISIBLE_LIST) ) 864 u ins.push_back(pUser->Uin());865 } 866 FOR_EACH_ USER_END867 CSrvPacketTcp* p = new CPU_GenericUinList(u ins, ICQ_SNACxFAM_BOS, ICQ_SNACxBOS_ADDxVISIBLExLIST);868 users.push_back(strdup(pUser->IdString())); 869 } 870 FOR_EACH_PROTO_USER_END 871 CSrvPacketTcp* p = new CPU_GenericUinList(users, ICQ_SNACxFAM_BOS, ICQ_SNACxBOS_ADDxVISIBLExLIST); 868 872 gLog.Info("%sSending visible list (#%ld)...\n", L_SRVxSTR, p->Sequence()); 869 873 SendEvent_Server(p); … … 874 878 void CICQDaemon::icqSendInvisibleList() 875 879 { 876 U inList uins;877 FOR_EACH_ USER_START(LOCK_R)880 UserStringList users; 881 FOR_EACH_PROTO_USER_START(LICQ_PPID, LOCK_R) 878 882 { 879 883 if (pUser->GetInGroup(GROUPS_SYSTEM, GROUP_INVISIBLE_LIST) ) 880 u ins.push_back(pUser->Uin());881 } 882 FOR_EACH_ USER_END883 884 CSrvPacketTcp* p = new CPU_GenericUinList(u ins, ICQ_SNACxFAM_BOS, ICQ_SNACxBOS_ADDxINVISIBxLIST);884 users.push_back(strdup(pUser->IdString())); 885 } 886 FOR_EACH_PROTO_USER_END 887 888 CSrvPacketTcp* p = new CPU_GenericUinList(users, ICQ_SNACxFAM_BOS, ICQ_SNACxBOS_ADDxINVISIBxLIST); 885 889 gLog.Info("%sSending invisible list (#%ld)...\n", L_SRVxSTR, p->Sequence()); 886 890 SendEvent_Server(p); -
branches/protocol_plugin_1_3_0/licq/src/icqpacket.cpp
r3469 r3473 917 917 } 918 918 919 CPU_GenericUinList::CPU_GenericUinList(UserStringList &users, unsigned short family, unsigned short Subtype) 920 : CPU_CommonFamily(family, Subtype) 921 { 922 char len[2]; 923 len[1] = '\0'; 924 int nLen = 0; 925 UserStringList::iterator it; 926 for (it = users.begin(); it != users.end(); it++) 927 nLen += strlen(*it)+1; 928 929 char *contacts = new char[nLen+1]; 930 contacts[0] = '\0'; 931 932 for (it = users.begin(); it != users.end(); it++) { 933 len[0] = strlen(*it); 934 strcat(contacts, len); 935 strcat(contacts, *it); 936 free (*it); 937 } 938 939 m_nSize += strlen(contacts); 940 InitBuffer(); 941 942 buffer->Pack(contacts, strlen(contacts)); 943 } 944 919 945 CPU_GenericUinList::CPU_GenericUinList(const char *szId, unsigned short family, unsigned short Subtype) 920 946 : CPU_CommonFamily(family, Subtype) … … 1787 1813 1788 1814 //-----ExportToServerList------------------------------------------------------- 1789 CPU_ExportToServerList::CPU_ExportToServerList(U inList &uins,1815 CPU_ExportToServerList::CPU_ExportToServerList(UserStringList &users, 1790 1816 unsigned short _nType) 1791 1817 : CPU_CommonFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_ROSTxADD) … … 1795 1821 int nSize = 0; 1796 1822 1797 U inList::iterator i;1798 for (i = u ins.begin(); i != uins.end(); i++)1799 { 1800 ICQUser *pUser = gUserManager.FetchUser(*i, L OCK_R);1823 UserStringList::iterator i; 1824 for (i = users.begin(); i != users.end(); i++) 1825 { 1826 ICQUser *pUser = gUserManager.FetchUser(*i, LICQ_PPID, LOCK_R); 1801 1827 if (pUser) 1802 1828 { 1803 char szTmp[13]; 1804 szTmp[12] = '\0'; 1805 1806 nSize += snprintf(szTmp, 12, "%lu", *i); 1829 nSize += strlen(*i); 1807 1830 nSize += 10; 1808 1831 … … 1820 1843 InitBuffer(); 1821 1844 1822 for (i = uins.begin(); i != uins.end(); i++) 1823 { 1824 char szUin[13]; 1825 szUin[12] = '\0'; 1845 for (i = users.begin(); i != users.end(); i++) 1846 { 1826 1847 int nLen; 1827 1848 int nAliasSize = 0; … … 1831 1852 1832 1853 // Save the SID 1833 ICQUser *u = gUserManager.FetchUser(*i, L OCK_W);1854 ICQUser *u = gUserManager.FetchUser(*i, LICQ_PPID, LOCK_W); 1834 1855 switch (_nType) 1835 1856 { … … 1878 1899 SetExtraInfo(m_nGSID); 1879 1900 1880 nLen = s nprintf(szUin, 12, "%lu",*i);1901 nLen = strlen(*i); 1881 1902 buffer->PackUnsignedShortBE(nLen); 1882 buffer->Pack( szUin, nLen);1903 buffer->Pack(*i, nLen); 1883 1904 buffer->PackUnsignedShortBE(m_nGSID); 1884 1905 buffer->PackUnsignedShortBE(m_nSID); … … 1897 1918 if (szUnicodeName) 1898 1919 delete [] szUnicodeName; 1920 1921 free(*i); 1899 1922 } 1900 1923 }
