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); }
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); }
void MyXmppClient::setStatusText( const QString &__statusText ) { if( __statusText != m_statusText ) { m_statusText=__statusText; QXmppPresence myPresence = xmppClient->clientPresence(); myPresence.setStatusText( __statusText ); xmppClient->setClientPresence( myPresence ); emit statusTextChanged(); } }
QXmppPresence StatusToPresence (State state, const QString& text, int prio) { QXmppPresence::Type presType = state == SOffline ? QXmppPresence::Unavailable : QXmppPresence::Available; QXmppPresence pres (presType); if (state != SOffline) pres.setAvailableStatusType (static_cast<QXmppPresence::AvailableStatusType> (state - 1)); pres.setStatusText (text); pres.setPriority (prio); return pres; }
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; }