int CUserInfoXmpp::UpdateUserInfo(const QXmppRosterIq::Item &rosterItem) { if(m_szJid.isEmpty()) m_szJid = rosterItem.bareJid(); m_Groups = rosterItem.groups(); SetName(rosterItem.name()); m_subscriptionType = FromQxmppSubscriptionType(rosterItem.subscriptionType()); return 0; }
void CFrmUserList::slotItemChanged(const QString &bareJid) { LOG_MODEL_DEBUG("Roster", "CFrmUserList::itemChanged jid:%s", qPrintable(bareJid)); QMap<QString, CRoster*>::iterator it; it = m_Rosters.find(QXmppUtils::jidToBareJid(bareJid)); if(m_Rosters.end() != it) { CRoster* pRoster = it.value(); QXmppRosterIq::Item item = CGlobal::Instance()->GetXmppClient()->rosterManager().getRosterEntry(bareJid); pRoster->UpdateItems(item); UpdateGroup(pRoster, item.groups()); } }
int CFrmUserList::InsertUser(QXmppRosterIq::Item rosterItem) { int nRet = 0; CRoster* pRoster = NULL; QMap<QString, CRoster*>::iterator itRosters; itRosters = m_Rosters.find(rosterItem.bareJid()); if(m_Rosters.end() == itRosters) { //新建好友对象实例 pRoster = new CRoster(rosterItem); m_Rosters.insert(pRoster->BareJid(), pRoster); } else { LOG_MODEL_ERROR("Roster", qPrintable("Error:User had existed")); return -1; } nRet = UpdateGroup(pRoster, rosterItem.groups()); return nRet; }