本文整理汇总了C++中QXmppPresence类的典型用法代码示例。如果您正苦于以下问题:C++ QXmppPresence类的具体用法?C++ QXmppPresence怎么用?C++ QXmppPresence使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmppPresence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acceptSubscription
bool QXmppRosterManager::acceptSubscription(const QString &bareJid)
{
QXmppPresence presence;
presence.setTo(bareJid);
presence.setType(QXmppPresence::Subscribed);
return client()->sendPacket(presence);
}
示例2: unsubscribe
bool QXmppRosterManager::unsubscribe(const QString &bareJid)
{
QXmppPresence packet;
packet.setTo(QXmppUtils::jidToBareJid(bareJid));
packet.setType(QXmppPresence::Unsubscribe);
return client()->sendPacket(packet);
}
示例3: Q_UNUSED
void QFileTrans::slotPresenceReceived(const QXmppPresence &presence)
{
bool check;
Q_UNUSED(check);
// if we don't have a recipient, or if the presence is not from the recipient,
// do nothing
if (m_recipient.isEmpty() ||
QXmppUtils::jidToBareJid(presence.from()) != m_recipient ||
presence.type() != QXmppPresence::Available)
return;
// send the file and connect to the job's signals
QXmppTransferJob *job = transferManager->sendFile(presence.from(), ":/example_3_transferHandling.cpp", "example source code");
check = connect(job, SIGNAL(error(QXmppTransferJob::Error)),
this, SLOT(slotError(QXmppTransferJob::Error)));
Q_ASSERT(check);
check = connect(job, SIGNAL(finished()),
this, SLOT(slotFinished()));
Q_ASSERT(check);
check = connect(job, SIGNAL(progress(qint64,qint64)),
this, SLOT(slotProgress(qint64,qint64)));
Q_ASSERT(check);
}
示例4: WriteDownPhotoHash
void EntryBase::CheckVCardUpdate (const QXmppPresence& pres)
{
auto conn = Account_->GetClientConnection ();
if (!conn->GetInfoReqPolicyManager ()->IsRequestAllowed (InfoRequest::VCard, this))
return;
const auto& vcardUpdate = pres.vCardUpdateType ();
if (vcardUpdate == QXmppPresence::VCardUpdateNoPhoto)
{
if (!VCardPhotoHash_.isEmpty ())
{
VCardPhotoHash_.clear ();
WriteDownPhotoHash ();
emit avatarChanged (this);
}
}
else if (vcardUpdate == QXmppPresence::VCardUpdateValidPhoto)
{
if (pres.photoHash () != VCardPhotoHash_)
{
VCardPhotoHash_ = pres.photoHash ();
WriteDownPhotoHash ();
emit avatarChanged (this);
}
}
}
示例5: ptr
void EntryBase::CheckVCardUpdate (const QXmppPresence& pres)
{
auto conn = Account_->GetClientConnection ();
if (!conn->GetInfoReqPolicyManager ()->IsRequestAllowed (InfoRequest::VCard, this))
return;
auto fetchVCard = [this, conn] () -> void
{
QPointer<EntryBase> ptr (this);
conn->FetchVCard (GetJID (),
[ptr] (const QXmppVCardIq& iq) { if (ptr) ptr->SetVCard (iq); });
};
const auto& vcardUpdate = pres.vCardUpdateType ();
if (vcardUpdate == QXmppPresence::VCardUpdateNoPhoto)
{
if (!Avatar_.isNull ())
{
Avatar_ = QImage ();
emit avatarChanged (GetAvatar ());
}
}
else if (vcardUpdate == QXmppPresence::VCardUpdateValidPhoto)
{
if (pres.photoHash () != VCardPhotoHash_)
fetchVCard ();
}
else if (pres.type () == QXmppPresence::Available && !HasBlindlyRequestedVCard_)
{
fetchVCard ();
HasBlindlyRequestedVCard_ = true;
}
}
示例6: EntryStatus
EntryStatus GlooxCLEntry::GetStatus (const QString& variant) const
{
if (ODS_)
return EntryStatus ();
if (AuthRequested_)
return EntryStatus (SOnline, QString ());
QXmppRosterManager& rm = Account_->
GetClientConnection ()->GetClient ()->rosterManager ();
if (!rm.isRosterReceived ())
return EntryBase::GetStatus (variant);
const QMap<QString, QXmppPresence>& press = rm.getAllPresencesForBareJid (GetJID ());
if (!press.size ())
return EntryBase::GetStatus (variant);
QXmppPresence max = press.begin ().value ();
Q_FOREACH (const QString& resource, press.keys ())
{
if (!variant.isEmpty () && variant == resource)
{
max = press [resource];
break;
}
const QXmppPresence& pres = press [resource];
if (pres.priority () > max.priority ())
max = pres;
}
return EntryStatus (static_cast<State> (max.availableStatusType () + 1),
max.statusText ());
}
示例7: switch
void QXmppRosterManager::_q_presenceReceived(const QXmppPresence& presence)
{
const QString jid = presence.from();
const QString bareJid = QXmppUtils::jidToBareJid(jid);
const QString resource = QXmppUtils::jidToResource(jid);
if (bareJid.isEmpty())
return;
switch(presence.type())
{
case QXmppPresence::Available:
d->presences[bareJid][resource] = presence;
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Unavailable:
d->presences[bareJid].remove(resource);
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Subscribe:
if (client()->configuration().autoAcceptSubscriptions())
{
// accept subscription request
acceptSubscription(bareJid);
// ask for reciprocal subscription
subscribe(bareJid);
} else {
emit subscriptionReceived(bareJid);
}
break;
default:
break;
}
}
示例8: recipient
void xmppClient::slotPresenceReceived(const QXmppPresence &presence)
{
const QLatin1String recipient("[email protected]");
// if we are the recipient, or if the presence is not from the recipient,
// do nothing
if (jidToBareJid(configuration().jid()) == recipient ||
jidToBareJid(presence.from()) != recipient ||
presence.type() != QXmppPresence::Available)
return;
// send the file and connect to the job's signals
QXmppTransferJob *job = transferManager->sendFile(presence.from(), "xmppClient.cpp");
bool check = connect( job, SIGNAL(error(QXmppTransferJob::Error)),
this, SLOT(slotError(QXmppTransferJob::Error)) );
Q_ASSERT(check);
check = connect( job, SIGNAL(finished()),
this, SLOT(slotFinished()) );
Q_ASSERT(check);
check = connect( job, SIGNAL(progress(qint64,qint64)),
this, SLOT(slotProgress(qint64,qint64)) );
Q_ASSERT(check);
}
示例9: PresenceToStatus
EntryStatus PresenceToStatus (const QXmppPresence& pres)
{
EntryStatus st (static_cast<State> (pres.availableStatusType () + 1), pres.statusText ());
if (pres.type () == QXmppPresence::Unavailable)
st.State_ = SOffline;
return st;
}
示例10: presenceToStatusText
QString presenceToStatusText(const QXmppPresence& presence)
{
QString statusText = presence.statusText();
if(statusText.isEmpty())
{
if(presence.type() == QXmppPresence::Available)
{
switch(presence.availableStatusType())
{
case QXmppPresence::Invisible:
statusText = "Offline";
break;
case QXmppPresence::Online:
case QXmppPresence::Chat:
statusText = "Available";
break;
case QXmppPresence::Away:
case QXmppPresence::XA:
statusText = "Idle";
break;
case QXmppPresence::DND:
statusText = "Busy";
break;
}
}
else
statusText = "Offline";
}
return statusText;
}
示例11: jidToBareJid
void QXmppRosterManager::presenceReceived(const QXmppPresence& presence)
{
QString jid = presence.from();
QString bareJid = jidToBareJid(jid);
QString resource = jidToResource(jid);
if (bareJid.isEmpty())
return;
switch(presence.type())
{
case QXmppPresence::Available:
m_presences[bareJid][resource] = presence;
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Unavailable:
m_presences[bareJid].remove(resource);
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Subscribe:
if (m_stream->configuration().autoAcceptSubscriptions())
{
QXmppPresence presence;
presence.setTo(jid);
presence.setType(QXmppPresence::Subscribed);
m_stream->sendPacket(presence);
}
break;
default:
break;
}
}
示例12: switch
void QXmppRosterManager::rosterIqReceived(const QXmppRosterIq& rosterIq)
{
bool isInitial = (m_rosterReqId == rosterIq.id());
switch(rosterIq.type())
{
case QXmppIq::Set:
{
// send result iq
QXmppIq returnIq(QXmppIq::Result);
returnIq.setId(rosterIq.id());
m_stream->sendPacket(returnIq);
// store updated entries and notify changes
const QList<QXmppRosterIq::Item> items = rosterIq.items();
for (int i = 0; i < items.count(); i++)
{
QString bareJid = items.at(i).bareJid();
m_entries[bareJid] = items.at(i);
emit rosterChanged(bareJid);
}
// when contact subscribes user...user sends 'subscribed' presence
// then after recieving following iq user requests contact for subscription
// check the "from" is newly added in the roster...and remove this ask thing...and do this for all items
QXmppRosterIq::Item item = items.at(0);
if (!item.bareJid().isEmpty() &&
item.subscriptionType() == QXmppRosterIq::Item::From &&
item.subscriptionStatus().isEmpty())
{
QXmppPresence presence;
presence.setTo(item.bareJid());
presence.setType(QXmppPresence::Subscribe);
m_stream->sendPacket(presence);
}
}
break;
case QXmppIq::Result:
{
QList<QXmppRosterIq::Item> items = rosterIq.items();
for(int i = 0; i < items.count(); ++i)
{
QString bareJid = items.at(i).bareJid();
m_entries[bareJid] = items.at(i);
if (!isInitial)
emit rosterChanged(bareJid);
}
if (isInitial)
{
m_isRosterReceived = true;
emit rosterReceived();
}
break;
}
default:
break;
}
}
示例13: subscribe
bool QXmppRosterManager::subscribe(const QString &bareJid, const QString &reason)
{
QXmppPresence packet;
packet.setTo(QXmppUtils::jidToBareJid(bareJid));
packet.setType(QXmppPresence::Subscribe);
packet.setStatusText(reason);
return client()->sendPacket(packet);
}
示例14: refuseSubscription
bool QXmppRosterManager::refuseSubscription(const QString &bareJid, const QString &reason)
{
QXmppPresence presence;
presence.setTo(bareJid);
presence.setType(QXmppPresence::Unsubscribed);
presence.setStatusText(reason);
return client()->sendPacket(presence);
}
示例15: addProperCapability
void QXmppClientPrivate::addProperCapability(QXmppPresence& presence)
{
QXmppDiscoveryManager* ext = q->findExtension<QXmppDiscoveryManager>();
if(ext) {
presence.setCapabilityHash("sha-1");
presence.setCapabilityNode(ext->clientCapabilitiesNode());
presence.setCapabilityVer(ext->capabilities().verificationString());
}
}