QString StatusIcons::iconKeyByJid(const Jid &AStreamJid, const Jid &AContactJid) const { bool ask = false; int show = IPresence::Offline; QString subscription = SUBSCRIPTION_NONE; IPresence *presence = FPresenceManager!=NULL ? FPresenceManager->findPresence(AStreamJid) : NULL; if (AStreamJid == AContactJid) { subscription = SUBSCRIPTION_BOTH; show = presence!=NULL ? presence->show() : show; } else if (AStreamJid && AContactJid) { subscription = SUBSCRIPTION_BOTH; show = presence!=NULL ? presence->findItem(AContactJid).show : show; } else { IRoster *roster = FRosterManager!=NULL ? FRosterManager->findRoster(AStreamJid) : NULL; IRosterItem ritem = roster!=NULL ? roster->findItem(AContactJid) : IRosterItem(); ask = !ritem.subscriptionAsk.isEmpty(); subscription = ritem.subscription; show = presence!=NULL ? presence->findItem(AContactJid).show : show; } return iconKeyByStatus(show,subscription,ask); }
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 SchedulerItemDialog::onAccountSelected(int AIndex) { ui->cmbContact->clear(); Jid streamJid(ui->cmbAccount->itemData(AIndex).toString()); IRoster *roster = FRosterManager->findRoster(streamJid); if (roster) { IPresence *presence = FPresenceManager->findPresence(streamJid); if (presence) { QHash<Jid, QString> contacts; QList<Jid> items = presence->itemsJid(); for (QList<Jid>::ConstIterator it=items.constBegin(); it!=items.constEnd(); ++it) { IRosterItem rosterItem = roster->findItem(*it); QString name = (rosterItem.name.isEmpty()?(*it).full():QString("%1 <%2>").arg(rosterItem.name).arg((*it).full())); contacts.insert(*it, name); } for (QHash<Jid, QString>::ConstIterator it=contacts.constBegin(); it!=contacts.constEnd(); ++it) ui->cmbContact->addItem(it.value(), it.key().full()); } } }
void ClientInfo::showClientInfo(const Jid &AStreamJid, const Jid &AContactJid, int AInfoTypes) { if (AStreamJid.isValid() && AContactJid.isValid() && AInfoTypes>0) { ClientInfoDialog *dialog = FClientInfoDialogs.value(AContactJid,NULL); if (!dialog) { QString contactName = AContactJid.uNode(); if (FDiscovery!=NULL && FDiscovery->discoInfo(AStreamJid,AContactJid.bare()).identity.value(0).category=="conference") contactName = AContactJid.resource(); if (contactName.isEmpty()) contactName = FDiscovery!=NULL ? FDiscovery->discoInfo(AStreamJid,AContactJid).identity.value(0).name : AContactJid.domain(); if (FRosterManager) { IRoster *roster = FRosterManager->findRoster(AStreamJid); if (roster) { IRosterItem ritem = roster->findItem(AContactJid); if (!ritem.name.isEmpty()) contactName = ritem.name; } } dialog = new ClientInfoDialog(this,AStreamJid,AContactJid,!contactName.isEmpty() ? contactName : AContactJid.uFull(),AInfoTypes); connect(dialog,SIGNAL(clientInfoDialogClosed(const Jid &)),SLOT(onClientInfoDialogClosed(const Jid &))); FClientInfoDialogs.insert(AContactJid,dialog); dialog->show(); } else { dialog->setInfoTypes(dialog->infoTypes() | AInfoTypes); WidgetManager::showActivateRaiseWindow(dialog); } } }