本文整理汇总了C++中QXmppPresence::from方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppPresence::from方法的具体用法?C++ QXmppPresence::from怎么用?C++ QXmppPresence::from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppPresence
的用法示例。
在下文中一共展示了QXmppPresence::from方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotPresenceReceived
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);
}
示例2: slotPresenceReceived
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);
}
示例3: slotPresenceReceived
void xmppClient::slotPresenceReceived(const QXmppPresence &presence)
{
// 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;
// start the call and connect to the its signals
m_recipientFullJid = presence.from();
startCall();
}
示例4: slotPresenceReceived
void rpcClient::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 (QXmppUtils::jidToBareJid(configuration().jid()) == recipient ||
QXmppUtils::jidToBareJid(presence.from()) != recipient ||
presence.type() != QXmppPresence::Available)
return;
// invoke the remote method in 1 second
m_remoteJid = presence.from();
QTimer::singleShot(1000, this, SLOT(slotInvokeRemoteMethod()));
}
示例5: slotChangedPresence
//好友出席状态改变
void CFrmUserList::slotChangedPresence(const QXmppPresence &presence)
{
LOG_MODEL_DEBUG("Roster", "CFrmUserList::ChangedPresence jid:%s;status:%d;status text:%s",
qPrintable(presence.from()),
presence.availableStatusType(),
qPrintable(presence.statusText())
);
QString bareJid = QXmppUtils::jidToBareJid(presence.from());
QMap<QString, CRoster*>::iterator it = m_Rosters.find(bareJid);
if(m_Rosters.end() != it)
{
it.value()->ChangedPresence(presence.from(), presence.availableStatusType());
}
}
示例6: testPresenceWithCapability
void TestPackets::testPresenceWithCapability()
{
const QByteArray xml(
"<presence to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\">"
"<show>away</show>"
"<status>In a meeting</status>"
"<priority>5</priority>"
"<x xmlns=\"vcard-temp:x:update\">"
"<photo>73b908bc</photo>"
"</x>"
"<c xmlns=\"http://jabber.org/protocol/caps\" hash=\"sha-1\" node=\"http://code.google.com/p/qxmpp\" ver=\"QgayPKawpkPSDYmwT/WM94uAlu0=\"/>"
"</presence>");
QXmppPresence presence;
parsePacket(presence, xml);
QCOMPARE(presence.to(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.from(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.status().type(), QXmppPresence::Status::Away);
QCOMPARE(presence.status().statusText(), QString("In a meeting"));
QCOMPARE(presence.status().priority(), 5);
QCOMPARE(presence.photoHash(), QByteArray::fromHex("73b908bc"));
QCOMPARE(presence.vCardUpdateType(), QXmppPresence::VCardUpdateValidPhoto);
QCOMPARE(presence.capabilityHash(), QString("sha-1"));
QCOMPARE(presence.capabilityNode(), QString("http://code.google.com/p/qxmpp"));
QCOMPARE(presence.capabilityVer(), QByteArray::fromBase64("QgayPKawpkPSDYmwT/WM94uAlu0="));
serializePacket(presence, xml);
}
示例7: presenceReceived
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;
}
}
示例8: _q_presenceReceived
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;
}
}
示例9: presenceReceived
void MyXmppClient::presenceReceived( const QXmppPresence & presence ) {
QString bareJid = getBareJidByJid(presence.from());
QString resource = getResourceByJid(presence.from());
QString myResource = xmppClient->configuration().resource();
if ((presence.from().indexOf( m_myjid ) >= 0 && resource == myResource) || (bareJid == "" && resource == "")) {
if (presence.type() == QXmppPresence::Unavailable) m_status = Offline;
else {
switch (presence.availableStatusType()) {
case QXmppPresence::Online: m_status = Online; break;
case QXmppPresence::Chat: m_status = Chat; break;
case QXmppPresence::Away: m_status = Away; break;
case QXmppPresence::XA: m_status = XA; break;
case QXmppPresence::DND: m_status = DND; break;
}
}
emit statusChanged(m_accountId);
}
}
示例10: slotPresenceReceived
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;
// start the call and connect to the its signals
QXmppCall *call = callManager->call(presence.from());
bool check = connect(call, SIGNAL(connected()), this, SLOT(slotConnected()));
Q_ASSERT(check);
check = connect(call, SIGNAL(finished()), this, SLOT(slotFinished()));
Q_ASSERT(check);
}
示例11: testPresence
void TestPackets::testPresence()
{
const QByteArray xml(
"<presence to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\">"
"<x xmlns=\"vcard-temp:x:update\"/></presence>");
QXmppPresence presence;
parsePacket(presence, xml);
QCOMPARE(presence.to(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.from(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.photoHash(), QByteArray(""));
QCOMPARE(presence.vCardUpdateType(), QXmppPresence::VCardUpdateNotReady);
serializePacket(presence, xml);
}
示例12: presenceReceived
void JabberContactAvatarService::presenceReceived(const QXmppPresence &presence)
{
auto jid = Jid::parse(presence.from());
auto contactId = ContactId{jid.bare().toUtf8()};
switch (presence.vCardUpdateType())
{
case QXmppPresence::VCardUpdateNoPhoto:
emit removed(contactId);
break;
case QXmppPresence::VCardUpdateValidPhoto:
emit available({contactId, presence.photoHash()});
break;
default:
break;
}
}
示例13: testPresenceFull
void TestPackets::testPresenceFull()
{
const QByteArray xml(
"<presence to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\">"
"<show>away</show>"
"<status>In a meeting</status>"
"<priority>5</priority>"
"</presence>");
QXmppPresence presence;
parsePacket(presence, xml);
QCOMPARE(presence.to(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.from(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.status().type(), QXmppPresence::Status::Away);
QCOMPARE(presence.status().statusText(), QString("In a meeting"));
QCOMPARE(presence.status().priority(), 5);
QCOMPARE(presence.vCardUpdateType(), QXmppPresence::VCardUpdateNone);
serializePacket(presence, xml);
}
示例14: presenceReceived
void Xmpp_client::presenceReceived(const QXmppPresence& presence)
{
qDebug() << "Xmpp_client::presenceReceived !!!";
QString from = presence.from();
QString message;
switch(presence.type())
{
case QXmppPresence::Subscribe:
{
QXmppPresence subscribed;
subscribed.setTo(from);
subscribed.setType(QXmppPresence::Subscribed);
this->sendPacket(subscribed);
// reciprocal subscription
QXmppPresence subscribe;
subscribe.setTo(from);
subscribe.setType(QXmppPresence::Subscribe);
this->sendPacket(subscribe);
return;
}
break;
case QXmppPresence::Subscribed:
message = "<B>%1</B> accepted your request";
break;
case QXmppPresence::Unsubscribe:
message = "<B>%1</B> unsubscribe";
break;
case QXmppPresence::Unsubscribed:
message = "<B>%1</B> unsubscribed";
break;
default:
return;
break;
}
if(message.isEmpty())
return;
}
示例15: testPresenceWithVCardUpdate
void TestPackets::testPresenceWithVCardUpdate()
{
const QByteArray xml(
"<presence to=\"[email protected]/QXmpp\" from=\"[email protected]/QXmpp\">"
"<show>away</show>"
"<status>In a meeting</status>"
"<priority>5</priority>"
"<x xmlns=\"vcard-temp:x:update\">"
"<photo>73b908bc</photo>"
"</x>"
"</presence>");
QXmppPresence presence;
parsePacket(presence, xml);
QCOMPARE(presence.to(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.from(), QString("[email protected]/QXmpp"));
QCOMPARE(presence.status().type(), QXmppPresence::Status::Away);
QCOMPARE(presence.status().statusText(), QString("In a meeting"));
QCOMPARE(presence.status().priority(), 5);
QCOMPARE(presence.photoHash(), QByteArray::fromHex("73b908bc"));
QCOMPARE(presence.vCardUpdateType(), QXmppPresence::VCardUpdateValidPhoto);
serializePacket(presence, xml);
}