本文整理汇总了C++中QXmppPresence::setTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppPresence::setTo方法的具体用法?C++ QXmppPresence::setTo怎么用?C++ QXmppPresence::setTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppPresence
的用法示例。
在下文中一共展示了QXmppPresence::setTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: acceptSubscription
bool QXmppRosterManager::acceptSubscription(const QString &bareJid)
{
QXmppPresence presence;
presence.setTo(bareJid);
presence.setType(QXmppPresence::Subscribed);
return client()->sendPacket(presence);
}
示例3: unsubscribe
bool QXmppRosterManager::unsubscribe(const QString &bareJid)
{
QXmppPresence packet;
packet.setTo(QXmppUtils::jidToBareJid(bareJid));
packet.setType(QXmppPresence::Unsubscribe);
return client()->sendPacket(packet);
}
示例4: rosterIqReceived
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;
}
}
示例5: 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);
}
示例6: 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);
}
示例7: leaveRoom
bool QXmppMucManager::leaveRoom(const QString &roomJid)
{
if (!m_nickNames.contains(roomJid))
return false;
QString nickName = m_nickNames.take(roomJid);
QXmppPresence packet;
packet.setTo(roomJid + "/" + nickName);
packet.setType(QXmppPresence::Unavailable);
return client()->sendPacket(packet);
}
示例8: 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;
}
示例9: SendGWPresence
void GlooxCLEntry::SendGWPresence (QXmppPresence::Type type)
{
const auto& variant = sender ()->property ("Azoth/Xoox/Variant").toString ();
QString jid = GetJID ();
if (!variant.isEmpty ())
jid += '/' + variant;
QXmppPresence avail (type);
avail.setTo (jid);
Account_->GetClientConnection ()->GetClient ()->sendPacket (avail);
}
示例10: joinRoom
bool QXmppMucManager::joinRoom(const QString &roomJid, const QString &nickName, const QString &password)
{
QXmppPresence packet;
packet.setTo(roomJid + "/" + nickName);
packet.setType(QXmppPresence::Available);
QXmppElement x;
x.setTagName("x");
x.setAttribute("xmlns", ns_muc);
if (!password.isEmpty())
{
QXmppElement p;
p.setTagName("password");
p.setValue(password);
x.appendChild(p);
}
packet.setExtensions(x);
if (client()->sendPacket(packet))
{
m_nickNames[roomJid] = nickName;
return true;
} else {
return false;
}
}