本文整理汇总了C++中QXmppVCardIq类的典型用法代码示例。如果您正苦于以下问题:C++ QXmppVCardIq类的具体用法?C++ QXmppVCardIq怎么用?C++ QXmppVCardIq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmppVCardIq类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateUserInfo
int CUserInfoXmpp::UpdateUserInfo(const QXmppVCardIq &vCard, QString jid)
{
//if(!vCard.fullName().isEmpty())
// m_szName = vCard.fullName();
m_szNick = vCard.nickName();
m_Birthday = vCard.birthday();
m_szEmail = vCard.email();
m_szDescription = vCard.description();
if(!jid.isEmpty() && m_szJid.isEmpty())
m_szJid = jid;
//保存头像
QByteArray photo = vCard.photo();
QBuffer buffer;
buffer.setData(photo);
buffer.open(QIODevice::ReadOnly);
QImageReader imageReader(&buffer);
m_imgPhoto = imageReader.read();
buffer.close();
//保存头像到本地
QImageWriter imageWriter(CGlobal::Instance()->GetFileUserAvatar(GetId()), "png");
if(!imageWriter.write(GetPhoto()))
LOG_MODEL_ERROR("CUserInfo", "Save avater error, %s", imageWriter.errorString().toStdString().c_str());
return 0;
}
示例2: SetVCard
void EntryBase::SetVCard (const QXmppVCardIq& vcard, bool initial)
{
VCardIq_ = vcard;
VCardPhotoHash_ = VCardIq_.photo ().isEmpty () ?
QByteArray () :
QCryptographicHash::hash (VCardIq_.photo (), QCryptographicHash::Sha1);
QString text = FormatRawInfo (vcard);
if (!text.isEmpty ())
text = QString ("gloox VCard:\n") + text;
SetRawInfo (text);
if (!vcard.photo ().isEmpty ())
{
SetAvatar (vcard.photo ());
Core::Instance ().GetAvatarsStorage ()->StoreAvatar (Avatar_, VCardPhotoHash_.toHex ());
}
if (VCardDialog_)
VCardDialog_->UpdateInfo (vcard);
if (!initial)
Core::Instance ().ScheduleSaveRoster (10000);
emit vcardUpdated ();
}
示例3: updateVCard
void MainWindow::updateVCard(const QString &bareJid)
{
// 获取全名
const QXmppVCardIq vCard = m_xmppClient->vCardManager().clientVCard();
QString fullName = vCard.fullName();
if (fullName.isEmpty())
fullName = bareJid;
// 获取头像
//...
// 更新用户信息
if (bareJid == m_xmppClient->configuration().jidBare())
{
// 更新自己的信息
ui->nameLb->setText(bareJid);
ui->signatureLb->setText(fullName);
}
else
{
// 更新其他用户信息
// m_rosterItemModel.updateAvatar(bareJid, avatar);
// m_rosterItemModel.updateName(bareJid, fullName);
}
}
示例4: dirVCards
void vCardCache::loadFromFile()
{
m_mapBareJidVcard.clear();
QDir dirVCards(getSettingsDir(m_client->configuration().jidBare())+ "vCards/");
if(dirVCards.exists())
{
QStringList list = dirVCards.entryList(QStringList("*.xml"));
foreach(QString fileName, list)
{
QFile file(getSettingsDir(m_client->configuration().jidBare())+ "vCards/" + fileName);
QString bareJid = fileName;
bareJid.chop(4);
if(file.open(QIODevice::ReadOnly))
{
QDomDocument doc;
if(doc.setContent(&file, true))
{
QXmppVCardIq vCardIq;
vCardIq.parse(doc.documentElement());
m_mapBareJidVcard[bareJid] = vCardIq;
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
}
}
示例5: SetVCard
void EntryBase::SetVCard (const QXmppVCardIq& vcard, bool initial)
{
#if QXMPP_VERSION >= 0x000801
if (vcard == VCardIq_)
return;
#endif
VCardIq_ = vcard;
VCardPhotoHash_ = VCardIq_.photo ().isEmpty () ?
QByteArray () :
QCryptographicHash::hash (VCardIq_.photo (), QCryptographicHash::Sha1);
if (!vcard.photo ().isEmpty ())
{
SetAvatar (vcard.photo ());
Core::Instance ().GetAvatarsStorage ()->StoreAvatar (Avatar_, VCardPhotoHash_.toHex ());
}
if (VCardDialog_)
VCardDialog_->UpdateInfo (vcard);
if (!initial &&
GetEntryType () == ICLEntry::EntryType::Chat)
Core::Instance ().ScheduleSaveRoster (10000);
emit vcardUpdated ();
}
示例6: createVCardFromXmppFormat
VCard GetVCard::createVCardFromXmppFormat(QXmppVCardIq card)
{
VCard vCard;
vCard.setId(card.id());
vCard.setStatus(card.description());
vCard.setAvatar(createImageFromBytes(card.photo()));
return vCard;
}
示例7: vCardReceived
void Xmpp::vCardReceived (const QXmppVCardIq& vCard)
{
QByteArray photo = vCard.photo();
QBuffer buffer;
buffer.setData (photo);
buffer.open (QIODevice::ReadOnly);
QImageReader imageReader (&buffer);
QImage image = imageReader.read();
if (image.isNull())
image = QImage (":/faces/faces/generic-user.png");
jids.append (vCard.from());
users.append (vCard.fullName());
emit newUser (vCard.fullName(), vCard.from(), image);
}
示例8: SetNickFromVCard
void EntryBase::SetNickFromVCard (const QXmppVCardIq& vcard)
{
if (!vcard.nickName ().isEmpty ())
{
SetEntryName (vcard.nickName ());
return;
}
if (!vcard.fullName ().isEmpty ())
{
SetEntryName (vcard.fullName ());
return;
}
const QString& fn = vcard.firstName ();
const QString& mn = vcard.middleName ();
const QString& ln = vcard.lastName ();
QString name = fn;
if (!fn.isEmpty ())
name += " ";
name += mn;
if (!mn.isEmpty ())
name += " ";
name += ln;
name = name.trimmed ();
if (!name.isEmpty ())
SetEntryName (name);
}
示例9: slotvCardReceived
//得到好友形象信息
void CFrmUserList::slotvCardReceived(const QXmppVCardIq& vCard)
{
QString jid = QXmppUtils::jidToBareJid(vCard.from());
QMap<QString, CRoster*>::iterator it = m_Rosters.find(jid);
if(m_Rosters.end() != it)
{
it.value()->SetVCard(vCard);
}
}
示例10: handleStanza
bool QXmppVCardManager::handleStanza(const QDomElement &element)
{
if(element.tagName() == "iq" && QXmppVCardIq::isVCard(element))
{
QXmppVCardIq vCardIq;
vCardIq.parse(element);
if(vCardIq.from().isEmpty())
{
m_clientVCard = vCardIq;
m_isClientVCardReceived = true;
emit clientVCardReceived();
}
emit vCardReceived(vCardIq);
return true;
}
return false;
}
示例11: UpdateInfo
void VCardDialog::UpdateInfo (const QXmppVCardIq& vcard)
{
setWindowTitle (tr ("VCard for %1")
.arg (vcard.nickName()));
Ui_.EditRealName_->setText (vcard.fullName ());
Ui_.EditNick_->setText (vcard.nickName ());
const QDate& date = vcard.birthday ();
if (date.isValid ())
Ui_.EditBirthday_->setDate (date);
Ui_.EditBirthday_->setVisible (date.isValid ());
Ui_.EditPhone_->setText ("<phones not supported yet>");
Ui_.EditURL_->setText (vcard.url ());
QPixmap px = QPixmap::fromImage (QImage::fromData (vcard.photo ()));
if (!px.isNull ())
{
const QSize& maxPx = Ui_.LabelPhoto_->maximumSize ();
if (px.width () > maxPx.width () ||
px.height () > maxPx.height ())
px = px.scaled (maxPx, Qt::KeepAspectRatio, Qt::SmoothTransformation);
Ui_.LabelPhoto_->setPixmap (px);
}
else
Ui_.LabelPhoto_->setText (tr ("No photo"));
}
示例12: vCardReceived
void vCardCache::vCardReceived(const QXmppVCardIq& vcard)
{
QString from = vcard.from();
if(from.isEmpty() && m_client)
from = m_client->configuration().jidBare();
m_mapBareJidVcard[from] = vcard;
saveToFile(from);
emit vCardReadyToUse(from);
}
示例13: initVCard
void MyXmppClient::initVCard(const QXmppVCardIq &vCard)
{
QString bareJid = vCard.from();
RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid );
vCardData dataVCard;
if( item != 0 )
{
/* set nickname */
QXmppRosterIq::Item itemRoster = rosterManager->getRosterEntry( bareJid );
QString nickName = vCard.nickName();
if( (!nickName.isEmpty()) && (!nickName.isNull()) && (itemRoster.name().isEmpty()) ) {
qDebug() << "MyXmppClient::initPresence: updating name for"<< bareJid;
item->setContactName( nickName );
}
/* avatar */
bool isAvatarCreated = true;
QString avatarFile = cacheIM->getAvatarCache( bareJid );
if( (avatarFile.isEmpty() || avatarFile == "qrc:/avatar") && vCard.photo() != "" && !disableAvatarCaching) {
isAvatarCreated = cacheIM->setAvatarCache( bareJid, vCard.photo() );
}
item->setAvatar(cacheIM->getAvatarCache(bareJid));
dataVCard.nickName = nickName;
dataVCard.firstName = vCard.firstName();
dataVCard.fullName = vCard.fullName();;
dataVCard.middleName = vCard.middleName();
dataVCard.lastName = vCard.lastName();
dataVCard.url = vCard.url();
dataVCard.eMail = vCard.email();
cacheIM->setVCard( bareJid, dataVCard );
}
}
示例14: xml
void TestPackets::testVCard()
{
const QByteArray xml(
"<iq id=\"vcard1\" type=\"set\">"
"<vCard xmlns=\"vcard-temp\">"
"<BDAY>1983-09-14</BDAY>"
"<EMAIL><INTERNET/><USERID>[email protected]</USERID></EMAIL>"
"<FN>Foo Bar!</FN>"
"<NICKNAME>FooBar</NICKNAME>"
"<N><GIVEN>Foo</GIVEN><FAMILY>Wiz</FAMILY><MIDDLE>Baz</MIDDLE></N>"
"<PHOTO>"
"<TYPE>image/png</TYPE>"
"<BINVAL>"
"iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
"UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
"WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"
"</BINVAL>"
"</PHOTO>"
"</vCard>"
"</iq>");
QXmppVCardIq vcard;
parsePacket(vcard, xml);
QCOMPARE(vcard.birthday(), QDate(1983, 9, 14));
QCOMPARE(vcard.email(), QLatin1String("[email protected]"));
QCOMPARE(vcard.nickName(), QLatin1String("FooBar"));
QCOMPARE(vcard.fullName(), QLatin1String("Foo Bar!"));
QCOMPARE(vcard.firstName(), QLatin1String("Foo"));
QCOMPARE(vcard.middleName(), QLatin1String("Baz"));
QCOMPARE(vcard.lastName(), QLatin1String("Wiz"));
QCOMPARE(vcard.photo(), QByteArray::fromBase64(
"iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
"UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
"WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"));
QCOMPARE(vcard.photoType(), QLatin1String("image/png"));
serializePacket(vcard, xml);
}
示例15: vCardDownloaded
void JabberPersonalInfoService::vCardDownloaded(bool ok, const QXmppVCardIq &vCard)
{
if (!ok)
return;
CurrentBuddy.setNickName(vCard.nickName());
CurrentBuddy.setFirstName(vCard.fullName());
CurrentBuddy.setFamilyName(vCard.middleName());
QDate bday = vCard.birthday();
if (bday.isValid() && !bday.isNull())
CurrentBuddy.setBirthYear(bday.year());
if (!vCard.addresses().isEmpty())
CurrentBuddy.setCity(vCard.addresses().at(0).locality());
if (!vCard.emails().isEmpty())
CurrentBuddy.setEmail(vCard.emails().at(0).address());
CurrentBuddy.setWebsite(vCard.url());
emit personalInfoAvailable(CurrentBuddy);
}