本文整理汇总了C++中QXmppPresence::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppPresence::setType方法的具体用法?C++ QXmppPresence::setType怎么用?C++ QXmppPresence::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppPresence
的用法示例。
在下文中一共展示了QXmppPresence::setType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: acceptSubscription
bool QXmppRosterManager::acceptSubscription(const QString &bareJid, const QString &reason)
{
QXmppPresence presence;
presence.setTo(bareJid);
presence.setType(QXmppPresence::Subscribed);
presence.setStatusText(reason);
return client()->sendPacket(presence);
}
示例2: unsubscribe
bool QXmppRosterManager::unsubscribe(const QString &bareJid, const QString &reason)
{
QXmppPresence packet;
packet.setTo(QXmppUtils::jidToBareJid(bareJid));
packet.setType(QXmppPresence::Unsubscribe);
packet.setStatusText(reason);
return client()->sendPacket(packet);
}
示例3: 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);
}
示例4: 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;
}
示例5: setStatus
void MyXmppClient::setStatus( StatusXmpp __status) {
if (__status != m_status || xmppClient->state() == QXmppClient::ConnectingState) {
QXmppPresence myPresence = xmppClient->clientPresence();
if (__status != Offline) {
if( xmppClient->state() == QXmppClient::DisconnectedState )
this->connectToXmppServer();
myPresence.setType( QXmppPresence::Available );
} else {
if( (xmppClient->state() != QXmppClient::DisconnectedState) )
xmppClient->disconnectFromServer();
myPresence.setType( QXmppPresence::Unavailable );
}
switch (__status) {
case Online:
myPresence.setAvailableStatusType( QXmppPresence::Online );
break;
case Chat:
myPresence.setAvailableStatusType( QXmppPresence::Chat );
break;
case Away:
myPresence.setAvailableStatusType( QXmppPresence::Away );
break;
case XA:
myPresence.setAvailableStatusType( QXmppPresence::XA );
break;
case DND:
myPresence.setAvailableStatusType( QXmppPresence::DND );
break;
case Offline:
m_status = __status;
this->clearPresence();
break;
default: break;
}
xmppClient->setClientPresence( myPresence );
this->presenceReceived( myPresence );
}
}
示例6: getPresence
QXmppPresence QXmppRosterManager::getPresence(const QString& bareJid,
const QString& resource) const
{
if(d->presences.contains(bareJid) && d->presences[bareJid].contains(resource))
return d->presences[bareJid][resource];
else
{
QXmppPresence presence;
presence.setType(QXmppPresence::Unavailable);
return presence;
}
}
示例7: 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;
}
}
示例8: setClientPresence
void QXmppClient::setClientPresence(QXmppPresence::Type presenceType)
{
QXmppPresence newPresence = d->clientPresence;
newPresence.setType(presenceType);
setClientPresence(newPresence);
}
示例9: executeCommand
bool XMPPPresenceCommand::executeCommand(QStringList * const arguments)
{
bool ret = false;
if (arguments->length() < 4)
{
this->client->write(tr("ERROR: xmppPresence <resource> <priority> <status> <message>")
+ "\r\n");
}
else
{
QXmppClient * const client =
XMPPResourceStore::instance()->getFromStore(arguments->first());
arguments->removeFirst();
if (client)
{
bool intOk = false;
const int priority = arguments->first().toInt(&intOk);
arguments->removeFirst();
if (not intOk)
{
this->client->write(tr("ERROR: Priority must be an integer") + "\r\n");
}
else
{
QXmppPresence presence;
presence.setPriority(priority);
const QString type = arguments->first();
arguments->removeFirst();
bool sOk = true;
presence.setType(QXmppPresence::Available);
if (type == "online")
{
presence.setAvailableStatusType(QXmppPresence::Online);
}
else if (type == "away")
{
presence.setAvailableStatusType(QXmppPresence::Away);
}
else if (type == "xa")
{
presence.setAvailableStatusType(QXmppPresence::XA);
}
else if (type == "dnd")
{
presence.setAvailableStatusType(QXmppPresence::DND);
}
else if (type == "chat")
{
presence.setAvailableStatusType(QXmppPresence::Chat);
}
else if (type == "invisible")
{
presence.setAvailableStatusType(QXmppPresence::Invisible);
}
else
{
sOk = false;
this->client->write(tr("ERROR: Unknown presence status type") + "\r\n");
}
if (sOk)
{
const QString message = arguments->join(" ");
presence.setStatusText(message);
if (XMPPDebugCommand::isDebugEnabled())
{
XMPPPrintCommand::printMessage(
true,
&presence);
}
ret = client->sendPacket(presence);
if (not ret)
{
this->client->write(tr("ERROR: Failed to send packet") + "\r\n");
}
else
{
XMPPResourceStore::instance()->setLastMessageSent(
client,
presence);
}
}
}
}
else
{
this->client->write(tr("ERROR: Unknown resource") + "\r\n");
}
}
return ret;
}