void Gateways::resolveNickName(const Jid &AStreamJid, const Jid &AContactJid) { IRoster *roster = FRosterManager!=NULL ? FRosterManager->findRoster(AStreamJid) : NULL; IRosterItem ritem = roster!=NULL ? roster->findItem(AContactJid) : IRosterItem(); if (!ritem.isNull() && roster->isOpen()) { if (FVCardManager->hasVCard(ritem.itemJid)) { static const QList<QString> nickFields = QList<QString>() << VVN_NICKNAME << VVN_FULL_NAME << VVN_GIVEN_NAME << VVN_FAMILY_NAME; LOG_STRM_INFO(AStreamJid,QString("Resolving contact nick name from vCard, jid=%1").arg(AContactJid.bare())); IVCard *vcard = FVCardManager->getVCard(ritem.itemJid); foreach(const QString &field, nickFields) { QString nick = vcard->value(field); if (!nick.isEmpty()) { if (ritem.name != nick) roster->renameItem(ritem.itemJid,nick); break; } } vcard->unlock(); } else {
void ExchangeApproveDialog::appendRequestItems(const QList<IRosterExchangeItem> &AItems) { for (QList<IRosterExchangeItem>::const_iterator it=AItems.constBegin(); it!=AItems.constEnd(); ++it) { QString actionText; IRosterItem ritem = FRoster->findItem(it->itemJid); if (it->action == ROSTEREXCHANGE_ACTION_ADD) { if (ritem.isNull()) { if (it->groups.isEmpty()) actionText = tr("Add new contact '%1 <%2>'").arg(it->name,it->itemJid.uBare()); else actionText = tr("Add new contact '%1 <%2>' to the group: %3").arg(it->name,it->itemJid.uBare(),groupSetToString(it->groups)); ui.chbSubscribe->setVisible(true); } else if (!it->groups.isEmpty()) { actionText = tr("Copy contact '%1' to the group: %2").arg(contactName(it->itemJid),groupSetToString(it->groups-ritem.groups)); } } else if (!ritem.isNull() && it->action == ROSTEREXCHANGE_ACTION_DELETE) { QSet<QString> oldGroups = it->groups; oldGroups.intersect(ritem.groups); if (it->groups.isEmpty()) actionText = tr("Remove contact '%1' from contact list").arg(contactName(it->itemJid)); else actionText = tr("Remove contact '%1' from the group: %2").arg(contactName(it->itemJid),groupSetToString(oldGroups)); } else if (!ritem.isNull() && it->action == ROSTEREXCHANGE_ACTION_MODIFY) { QSet<QString> newGroups = it->groups - ritem.groups; QSet<QString> oldGroups = ritem.groups - it->groups; if (it->name != ritem.name) { actionText = tr("Rename contact '%1' to '%2'").arg(contactName(it->itemJid),it->name); } if (!newGroups.isEmpty()) { if (!actionText.isEmpty()) actionText += "; "; actionText += tr("Copy contact '%1' to the group: %2").arg(contactName(it->itemJid),groupSetToString(newGroups)); } if (!oldGroups.isEmpty()) { if (!actionText.isEmpty()) actionText += "; "; actionText += tr("Remove contact '%1' from the group: %2").arg(contactName(it->itemJid),groupSetToString(oldGroups)); } } if (!actionText.isEmpty()) { QTableWidgetItem *actionItem = new QTableWidgetItem; actionItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable); actionItem->setCheckState(Qt::Checked); actionItem->setText(actionText); ui.tbwItems->setRowCount(ui.tbwItems->rowCount()+1); ui.tbwItems->setItem(ui.tbwItems->rowCount()-1,COL_ACTION,actionItem); ui.tbwItems->verticalHeader()->SETRESIZEMODE(actionItem->row(),QHeaderView::ResizeToContents); FItems.insert(actionItem,*it); } } }