bool XMPPReachabilityCommand::executeCommand(QStringList * const arguments) { bool ret = false; if (arguments->length() < 2) { this->client->write(tr("ERROR: xmppReachability <resource> <address>") + "\r\n"); } else { QXmppClient * const client = XMPPResourceStore::instance()->getFromStore(arguments->first()); arguments->removeFirst(); if (client) { QXmppAddress addr; addr.setAddress(arguments->first()); arguments->removeFirst(); QXmppReachAddress reachAddr; reachAddr.addAddress(addr); QXmppPubSubIq publish; QXmppPubSubItem item; QList <QXmppPubSubItem> listItems; publish.setType(QXmppIq::Set); publish.setQueryType(QXmppPubSubIq::PublishQuery); publish.setId(QUuid::createUuid().toString()); publish.setQueryNode("urn:xmpp:reach:0"); item.setId(QUuid::createUuid().toString()); item.setContents(reachAddr.toQXmppElement()); listItems.append(item); publish.setItems(listItems); if (XMPPDebugCommand::isDebugEnabled()) { XMPPPrintCommand::printMessage( true, &publish); } ret = client->sendPacket(publish); if (not ret) { this->client->write(tr("ERROR: Failed to send packet") + "\r\n"); } else { XMPPResourceStore::instance()->setLastMessageSent( client, publish); } } else { this->client->write(tr("ERROR: Unknown resource") + "\r\n"); } } return ret; }
bool QXmppPubSubManager::setItems(const QString &jid, const QString &node, const QList<QXmppPubSubItem> items) { QXmppPubSubIq iq; iq.setTo(jid); iq.setType(QXmppIq::Set); iq.setQueryType(QXmppPubSubIq::PublishQuery); iq.setQueryNode(node); iq.setItems(items); return client()->sendPacket(iq); }