void CMsnContactManager::CreateUsers() { // 遍历所有成员列表,创建用户列表 const std::list<CMembership*>& memberShips = memberShips_->GetMemberShips(); std::list<CMembership*>::const_iterator cit1 = memberShips.begin(); for (; cit1 != memberShips.end(); cit1++) { const char* role = (*cit1)->GetMemberRole(); if (STRING_IS_EMPTY(role)) continue; if (strcmp(role, "Allow") == 0) AddUsers(*cit1); else if (strcmp(role, "Block") == 0) AddUsers(*cit1); else if (strcmp(role, "Reverse") == 0) AddUsers(*cit1); } // 遍历所有联系人列表,补充用户列表的信息 const std::list<CMsnContact*>& contacts = contacts_->GetContacts(); std::list<CMsnContact*>::const_iterator cit2 = contacts.begin(); for (; cit2 != contacts.end(); cit2++) { // 必要性检查 if (STRING_IS_EMPTY((*cit2)->passportName)) continue; if (STRING_IS_EMPTY((*cit2)->contactType)) continue; if (strcasecmp((*cit2)->contactType, "Regular") != 0) continue; Member* member = FindUser((*cit2)->passportName); if (member == NULL) continue; // 设置该成员的联系人对象 member->SetContact(*cit2); } }