QXmppElement UserTune::ToXML () const { QXmppElement result; result.setTagName ("item"); QXmppElement tune; tune.setTagName ("tune"); tune.setAttribute ("xmlns", NsTuneNode); auto appendTxt = [&tune] (const QString& tag, const QString& str) { if (str.isEmpty ()) return; QXmppElement elem; elem.setTagName (tag); elem.setValue (str); tune.appendChild (elem); }; appendTxt ("artist", Artist_); appendTxt ("source", Source_); appendTxt ("title", Title_); appendTxt ("track", Track_); appendTxt ("uri", URI_.toEncoded ()); if (Length_) appendTxt ("length", QString::number (Length_)); if (Rating_) appendTxt ("rating", QString::number (Rating_)); result.appendChild (tune); return result; }
QXmppElement UserMood::ToXML () const { QXmppElement mood; mood.setTagName ("mood"); mood.setAttribute ("xmlns", NsMoodNode); if (Mood_ != MoodEmpty) { QXmppElement elem; elem.setTagName (MoodStr [Mood_]); mood.appendChild (elem); if (!Text_.isEmpty ()) { QXmppElement text; text.setTagName ("text"); text.setValue (Text_); mood.appendChild (text); } } QXmppElement result; result.setTagName ("item"); result.appendChild (mood); return result; }
void JabberSearchManager::SubmitSearchRequest (const QString& server, const QXmppDataForm& form) { QXmppElement query; query.setTagName ("query"); query.setAttribute ("xmlns", NsJabberSearch); query.appendChild (XooxUtil::Form2XmppElem (form)); SubmitSearchRequest (server, query); }
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 JabberSearchManager::SubmitSearchRequest (const QString& server, const QList<QXmppElement>& fields) { QXmppElement query; query.setTagName ("query"); query.setAttribute ("xmlns", NsJabberSearch); Q_FOREACH (const QXmppElement& field, fields) query.appendChild (field); SubmitSearchRequest (server, query); }
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); }); }
void QXmppDeliveryReceiptsManager::sendReceipt(const QString &jid, const QString &id) { QXmppMessage msg; msg.setTo(jid); QXmppElement elem; elem.setTagName("received"); elem.setAttribute("xmlns", ns_message_receipts); elem.setAttribute("id", id); msg.setExtensions(QXmppElementList(elem)); client()->sendPacket(msg); }
QXmppElement UserActivity::ToXML () const { QXmppElement activityElem; activityElem.setTagName ("activity"); activityElem.setAttribute ("xmlns", NsActivityNode); QXmppElement result; result.setTagName ("item"); if (General_ == GeneralEmpty) { result.appendChild (activityElem); return result; } QXmppElement generalElem; generalElem.setTagName (activity_general [General_]); if (Specific_ != SpecificEmpty) { QXmppElement specific; specific.setTagName (activity_specific [Specific_]); generalElem.appendChild (specific); } if (!Text_.isEmpty ()) { QXmppElement textElem; textElem.setTagName ("text"); textElem.setValue (Text_); generalElem.appendChild (textElem); } activityElem.appendChild (generalElem); result.appendChild (activityElem); return result; }
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; } }
void QXmppCarbonManager::setCarbonsEnabled(bool enabled) { if(m_carbonsEnabled == enabled) return; m_carbonsEnabled = enabled; if(client()) { QXmppIq iq(QXmppIq::Set); QXmppElement carbonselement; carbonselement.setTagName(m_carbonsEnabled ? "enable" : "disable"); carbonselement.setAttribute("xmlns", ns_carbons); iq.setExtensions(QXmppElementList() << carbonselement); client()->sendPacket(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); }