Ejemplo n.º 1
0
	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;
	}
Ejemplo n.º 2
0
	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;
	}
Ejemplo n.º 3
0
	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);
	}
Ejemplo n.º 4
0
	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;
	}
Ejemplo n.º 5
0
	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);
	}
Ejemplo n.º 6
0
	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;
	}
Ejemplo n.º 7
0
	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);
				});
	}
Ejemplo n.º 8
0
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;
    }
}