| 4141 | | unsigned short nPacketCount; |
| 4142 | | unsigned long nTime; |
| 4143 | | |
| 4144 | | if (nFlags & 0x0001) |
| 4145 | | { |
| 4146 | | if (!hasServerEvent(nSubSequence)) |
| 4147 | | gLog.Warn(tr("%sContact list without request.\n"), L_SRVxSTR); |
| 4148 | | else |
| 4149 | | gLog.Info(tr("%sReceived contact list.\n"), L_SRVxSTR); |
| 4150 | | } |
| 4151 | | else |
| 4152 | | { |
| 4153 | | // This is the last packet so mark it as done |
| 4154 | | ICQEvent *e = DoneServerEvent(nSubSequence, EVENT_SUCCESS); |
| 4155 | | |
| 4156 | | if (e == NULL) |
| 4157 | | { |
| 4158 | | // Try acking it, even if we didn't expect it |
| 4159 | | //gLog.Warn(tr("%sContact list without request.\n"), L_SRVxSTR); |
| 4160 | | gLog.Info(tr("%sActivate server contact list.\n"), L_SRVxSTR); |
| 4161 | | CSrvPacketTcp *p = new CPU_GenericFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_ROSTxACK); |
| 4162 | | SendEvent_Server(p); |
| 4163 | | //This packet had the user list in it, but we didn't ask for it. |
| 4164 | | //Nonetheless, it appears we won't get a second chance for this packet, so process it |
| 4165 | | //break; |
| 4166 | | } |
| 4167 | | |
| 4168 | | /* This isn't used anymore. At least with SSI Version 0. |
| 4169 | | if (e->SNAC() == MAKESNAC(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_REQUESTxRIGHTS) || |
| 4170 | | e->SNAC() == MAKESNAC(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_REQUESTxROST)) |
| 4171 | | { |
| 4172 | | packet.UnpackUnsignedLong(); |
| 4173 | | packet.UnpackUnsignedLong(); |
| 4174 | | } |
| 4175 | | */ |
| 4176 | | |
| 4177 | | gLog.Info(tr("%sReceived end of contact list.\n"), L_SRVxSTR); |
| 4178 | | } |
| 4192 | | szId = packet.UnpackStringBE(); |
| 4193 | | nTag = packet.UnpackUnsignedShortBE(); |
| 4194 | | nID = packet.UnpackUnsignedShortBE(); |
| 4195 | | nType = packet.UnpackUnsignedShortBE(); |
| 4196 | | nByteLen = packet.UnpackUnsignedShortBE(); |
| 4197 | | |
| 4198 | | char *szUnicodeName = gTranslator.FromUnicode(szId); |
| | 4151 | char* szId = packet.UnpackStringBE(); |
| | 4152 | unsigned short nTag = packet.UnpackUnsignedShortBE(); |
| | 4153 | unsigned short nID = packet.UnpackUnsignedShortBE(); |
| | 4154 | unsigned short nType = packet.UnpackUnsignedShortBE(); |
| | 4155 | |
| | 4156 | unsigned short nByteLen = packet.UnpackUnsignedShortBE(); |
| 4218 | | if (!UseServerContactList()) break; |
| 4219 | | |
| 4220 | | char *szNewName = packet.UnpackStringTLV(0x0131); |
| 4221 | | char *szSMSNumber = packet.UnpackStringTLV(0x013A); |
| 4222 | | bool bAwaitingAuth = packet.hasTLV(0x0066); |
| 4223 | | |
| 4224 | | bool isOnList = true; |
| 4225 | | if (szId && !gUserManager.IsOnList(szId, LICQ_PPID)) |
| | 4176 | if (!UseServerContactList()) |
| | 4177 | break; |
| | 4178 | |
| | 4179 | std::pair<ContactUserListIter, bool> ret = |
| | 4180 | receivedUserList.insert(make_pair(szId, (CUserProperties*)NULL)); |
| | 4181 | |
| | 4182 | ContactUserListIter iter = ret.first; |
| | 4183 | if (ret.second) // we inserted a new NULL pair |
| | 4184 | iter->second = new CUserProperties(); |
| | 4185 | |
| | 4186 | CUserProperties* data = iter->second; |
| | 4187 | |
| | 4188 | #define COPYTLV(type, var) \ |
| | 4189 | if (packet.hasTLV(type)) \ |
| | 4190 | data->var.reset(packet.UnpackStringTLV(type)) |
| | 4191 | |
| | 4192 | COPYTLV(0x0131, newAlias); |
| | 4193 | COPYTLV(0x013A, newCellular); |
| | 4194 | #undef COPYTLV |
| | 4195 | if (packet.hasTLV(0x0066)) |
| | 4196 | data->awaitingAuth = true; |
| | 4197 | |
| | 4198 | if (nTag != 0) |
| | 4199 | data->groupId = nTag; |
| | 4200 | |
| | 4201 | if (nType == ICQ_ROSTxIGNORE) |
| | 4202 | data->inIgnoreList = true; |
| | 4203 | |
| | 4204 | if (nID != 0) |
| 4227 | | isOnList = false; |
| 4228 | | AddUserToList(szId, LICQ_PPID, false); // Don't notify server |
| 4229 | | } |
| 4230 | | |
| 4231 | | ICQUser *u = gUserManager.FetchUser(szId, LICQ_PPID, LOCK_W); |
| 4232 | | if (u) |
| 4233 | | { |
| 4234 | | // For now, just save all the TLVs. We should change this to have awaiting auth check |
| 4235 | | // for the 0x0066 TLV, SMS number if it has the 0x013A TLV, etc |
| 4236 | | TLVList tlvList = packet.getTLVList(); |
| 4237 | | TLVListIter iter; |
| 4238 | | for (iter = tlvList.begin(); iter != tlvList.end(); ++iter) |
| | 4206 | if (nType == ICQ_ROSTxVISIBLE) |
| 4382 | | gLog.Info(tr("%sActivate server contact list.\n"), L_SRVxSTR); |
| 4383 | | CSrvPacketTcp *p = new CPU_GenericFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_ROSTxACK); |
| 4384 | | SendEvent_Server(p); |
| 4385 | | |
| 4386 | | |
| | 4294 | if (nFlags & 0x0001) |
| | 4295 | { |
| | 4296 | if (!hasServerEvent(nSubSequence)) |
| | 4297 | gLog.Warn(tr("%sContact list without request.\n"), L_SRVxSTR); |
| | 4298 | else |
| | 4299 | gLog.Info(tr("%sReceived contact list.\n"), L_SRVxSTR); |
| | 4300 | } |
| | 4301 | else |
| | 4302 | { |
| | 4303 | // This is the last packet so mark it as done |
| | 4304 | DoneServerEvent(nSubSequence, EVENT_SUCCESS); |
| | 4305 | |
| | 4306 | gLog.Info(tr("%sReceived end of contact list.\n"), L_SRVxSTR); |
| | 4307 | |
| | 4308 | ProcessUserList(); |
| | 4309 | |
| | 4310 | gLog.Info(tr("%sActivating server contact list.\n"), L_SRVxSTR); |
| | 4311 | CSrvPacketTcp *p = new CPU_GenericFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_ROSTxACK); |
| | 4312 | SendEvent_Server(p); |
| | 4313 | } |
| | 4314 | |
| | 6324 | void CICQDaemon::ProcessUserList() |
| | 6325 | { |
| | 6326 | if (receivedUserList.empty()) |
| | 6327 | return; |
| | 6328 | |
| | 6329 | ContactUserListIter iter; |
| | 6330 | |
| | 6331 | for (iter = receivedUserList.begin(); iter != receivedUserList.end(); iter++) |
| | 6332 | { |
| | 6333 | const char* id = iter->first.c_str(); |
| | 6334 | CUserProperties* data = iter->second; |
| | 6335 | |
| | 6336 | if (id == NULL || id[0] == '\0') |
| | 6337 | { |
| | 6338 | gLog.Warn(tr("%sEmpty User ID was received in the contact list.\n"), |
| | 6339 | L_SRVxSTR); |
| | 6340 | continue; |
| | 6341 | } |
| | 6342 | |
| | 6343 | bool isOnList = gUserManager.IsOnList(id, LICQ_PPID); |
| | 6344 | |
| | 6345 | if (!isOnList) |
| | 6346 | { |
| | 6347 | AddUserToList(id, LICQ_PPID, false, false); // Don't notify server |
| | 6348 | gLog.Info(tr("%sAdded %s (%s) to list from server.\n"), |
| | 6349 | L_SRVxSTR, (data->newAlias ? data->newAlias.get() : id), id); |
| | 6350 | } |
| | 6351 | |
| | 6352 | ICQUser* u = gUserManager.FetchUser(id, LICQ_PPID, LOCK_W); |
| | 6353 | if (u == NULL) |
| | 6354 | continue; |
| | 6355 | |
| | 6356 | if (data->newAlias != NULL) |
| | 6357 | u->SetAlias(data->newAlias.get()); |
| | 6358 | |
| | 6359 | u->SetSID(data->normalSid); |
| | 6360 | u->SetGSID(data->groupId); |
| | 6361 | u->SetVisibleSID(data->visibleSid); |
| | 6362 | u->SetVisibleList(data->visibleSid != 0); |
| | 6363 | u->SetInvisibleSID(data->invisibleSid); |
| | 6364 | u->SetInvisibleList(data->invisibleSid != 0); |
| | 6365 | u->SetIgnoreList(data->inIgnoreList); |
| | 6366 | |
| | 6367 | u->AddToGroup(GROUPS_USER, gUserManager.GetGroupFromID(data->groupId)); |
| | 6368 | |
| | 6369 | u->SetAwaitingAuth(data->awaitingAuth); |
| | 6370 | |
| | 6371 | if (!isOnList) |
| | 6372 | { |
| | 6373 | // They aren't a new user if we added them to a server list |
| | 6374 | u->SetNewUser(false); |
| | 6375 | } |
| | 6376 | |
| | 6377 | if (data->newCellular != NULL) |
| | 6378 | { |
| | 6379 | char* tmp = gTranslator.FromUnicode(data->newCellular.get()); |
| | 6380 | if (tmp != NULL) |
| | 6381 | { |
| | 6382 | u->SetCellularNumber(tmp); |
| | 6383 | delete[] tmp; |
| | 6384 | } |
| | 6385 | } |
| | 6386 | |
| | 6387 | // For now, just save all the TLVs. We should change this to have awaiting auth check |
| | 6388 | // for the 0x0066 TLV, SMS number if it has the 0x013A TLV, etc |
| | 6389 | TLVListIter tlvIter; |
| | 6390 | for (tlvIter = data->tlvs.begin(); tlvIter != data->tlvs.end(); tlvIter++) |
| | 6391 | { |
| | 6392 | TLVPtr tlv = tlvIter->second; |
| | 6393 | u->AddTLV(tlv); |
| | 6394 | } |
| | 6395 | |
| | 6396 | // Save GSID, SID and group memberships |
| | 6397 | u->SaveLicqInfo(); |
| | 6398 | gUserManager.DropUser(u); |
| | 6399 | |
| | 6400 | PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_GENERAL, id, LICQ_PPID)); |
| | 6401 | } |
| | 6402 | |
| | 6403 | receivedUserList.clear(); |
| | 6404 | } |
| | 6405 | |