QXmppIq LastActivityManager::CreateIq (const QString& to, int secs) { QXmppIq iq; iq.setTo (to); QXmppElement queryElem; queryElem.setAttribute ("xmlns", NsLastActivity); if (secs != -1) queryElem.setAttribute ("seconds", QString::number (secs)); iq.setExtensions (queryElem); return iq; }
void AdHocCommandServer::SendCompleted (const QDomElement& sourceElem, const QString& node, const QString& sessionId) { QXmppElement elem; elem.setTagName ("command"); elem.setAttribute ("xmlns", NsCommands); elem.setAttribute ("node", node); elem.setAttribute ("status", "completed"); elem.setAttribute ("sessionid", sessionId); QXmppIq iq; iq.setTo (sourceElem.attribute ("from")); iq.setId (sourceElem.attribute ("id")); iq.setType (QXmppIq::Result); iq.setExtensions (QXmppElementList () << elem); Conn_->GetClient ()->sendPacket (iq); }
bool LegacyEntityTimeExt::handleStanza (const QDomElement& elem) { if (elem.tagName () != "iq" || elem.attribute ("type") != "get") return false; if (elem.firstChildElement ("query").namespaceURI () != NsLegacyEntityTime) return false; const QString& from = elem.attribute ("from"); if (from.isEmpty ()) return false; const QDateTime& date = QDateTime::currentDateTime ().toUTC (); QXmppElement utcElem; utcElem.setTagName ("utc"); utcElem.setValue (date.toString ("yyyyMMddThh:mm:ss")); const QString& displayStr = "Your client/bot sucks since it " "uses the long-deprecated XEP-0090. Upgrade your code. " "Ah, and, regarding your question, it's " + QDateTime::currentDateTime ().toString () + " here"; QXmppElement displayElem; displayElem.setTagName ("display"); displayElem.setValue (displayStr); QXmppElement queryElem; queryElem.setTagName ("query"); queryElem.setAttribute ("xmlns", NsLegacyEntityTime); queryElem.appendChild (utcElem); queryElem.appendChild (displayElem); QXmppIq iq (QXmppIq::Result); iq.setTo (from); iq.setId (elem.attribute ("id")); iq.setExtensions (QXmppElementList () << queryElem); client ()->sendPacket (iq); return true; }
void GlooxAccount::UpdateServerPassword (const QString& newPass) { if (newPass.isEmpty ()) return; const QString nsRegister = "jabber:iq:register"; const auto& jid = SettingsHolder_->GetJID (); const auto aPos = jid.indexOf ('@'); QXmppElement userElem; userElem.setTagName ("username"); userElem.setValue (aPos > 0 ? jid.left (aPos) : jid); QXmppElement passElem; passElem.setTagName ("password"); passElem.setValue (newPass); QXmppElement queryElem; queryElem.setTagName ("query"); queryElem.setAttribute ("xmlns", nsRegister); queryElem.appendChild (userElem); queryElem.appendChild (passElem); QXmppIq iq (QXmppIq::Set); iq.setTo (GetDefaultReqHost ()); iq.setExtensions ({ queryElem }); ClientConnection_->SendPacketWCallback (iq, [this, newPass] (const QXmppIq& reply) -> void { if (reply.type () != QXmppIq::Result) return; emit serverPasswordUpdated (newPass); Core::Instance ().GetPluginProxy ()->SetPassword (newPass, this); ClientConnection_->SetPassword (newPass); }); }