File indexing completed on 2024-04-14 04:01:47

0001  /*
0002     Copyright (c) 2008 by Igor Janssen  <alaves17@gmail.com>
0003 
0004     Kopete    (c) 2008 by the Kopete developers <kopete-devel@kde.org>
0005 
0006     *************************************************************************
0007     *                                                                       *
0008     * This program is free software; you can redistribute it and/or modify  *
0009     * it under the terms of the GNU General Public License as published by  *
0010     * the Free Software Foundation; either either version 2
0011    of the License, or (at your option) any later version.of the License, or     *
0012     * (at your option) any later version.                                   *
0013     *                                                                       *
0014     *************************************************************************
0015  */
0016 
0017 #include "jt_pubsub.h"
0018 
0019 #include "xmpp_xmlcommon.h"
0020 #include "xmpp_client.h"
0021 
0022 using namespace XMPP;
0023 
0024 #define PUBSUB_NS "http://jabber.org/protocol/pubsub"
0025 
0026 JT_PubSubPublish::JT_PubSubPublish(XMPP::Task *parent, const QString &node, XMPP::PubSubItem &psitem):
0027 Task(parent)
0028 {
0029     mIQ = createIQ(doc(), "set", "", id());
0030     QDomElement pubsub = doc()->createElement("pubsub");
0031     pubsub.setAttribute("xmlns", PUBSUB_NS);
0032     mIQ.appendChild(pubsub);
0033     QDomElement publish = doc()->createElement("publish");
0034     publish.setAttribute("node", node);
0035     pubsub.appendChild(publish);
0036     QDomElement item = doc()->createElement("item");
0037     item.setAttribute("id", psitem.id());
0038     publish.appendChild(item);
0039     item.appendChild(psitem.payload());
0040 }
0041 
0042 JT_PubSubPublish::~JT_PubSubPublish()
0043 {
0044 }
0045 
0046 void JT_PubSubPublish::onGo()
0047 {
0048     send(mIQ);
0049 }
0050 
0051 bool JT_PubSubPublish::take(const QDomElement &x)
0052 {
0053     if(!iqVerify(x, "", id()))
0054         return false;
0055     if(x.attribute("type") == "result")
0056         setSuccess();
0057     else
0058         setError(x);
0059     return true;
0060 }
0061 
0062 #include "moc_jt_pubsub.cpp"