3 * Copyright 2011, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef TALK_XMPP_PUBSUBTASKS_H_
29 #define TALK_XMPP_PUBSUBTASKS_H_
33 #include "talk/xmpp/iqtask.h"
34 #include "talk/xmpp/receivetask.h"
35 #include "webrtc/base/sigslot.h"
39 // A PubSub itemid + payload. Useful for signaling items.
42 // The entire <item>, owned by the stanza handler. To keep a
43 // reference after handling, make a copy.
44 const XmlElement* elem;
47 // An IqTask which gets a <pubsub><items> for a particular jid and
48 // node, parses the items in the response and signals the items.
49 class PubSubRequestTask : public IqTask {
51 PubSubRequestTask(XmppTaskParentInterface* parent,
53 const std::string& node);
55 sigslot::signal2<PubSubRequestTask*,
56 const std::vector<PubSubItem>&> SignalResult;
57 // SignalError inherited by IqTask.
59 virtual void HandleResult(const XmlElement* stanza);
62 // A ReceiveTask which listens for <event><items> of a particular
63 // pubsub JID and node and then signals them items.
64 class PubSubReceiveTask : public ReceiveTask {
66 PubSubReceiveTask(XmppTaskParentInterface* parent,
68 const std::string& node)
69 : ReceiveTask(parent),
70 pubsubjid_(pubsubjid),
74 virtual int ProcessStart();
75 sigslot::signal2<PubSubReceiveTask*,
76 const std::vector<PubSubItem>&> SignalUpdate;
79 virtual bool WantsStanza(const XmlElement* stanza);
80 virtual void ReceiveStanza(const XmlElement* stanza);
87 // An IqTask which publishes a <pubsub><publish><item> to a particular
88 // pubsub jid and node.
89 class PubSubPublishTask : public IqTask {
91 // Takes ownership of children
92 PubSubPublishTask(XmppTaskParentInterface* parent,
94 const std::string& node,
95 const std::string& itemid,
96 const std::vector<XmlElement*>& children);
98 const std::string& itemid() const { return itemid_; }
100 sigslot::signal1<PubSubPublishTask*> SignalResult;
103 // SignalError inherited by IqTask.
104 virtual void HandleResult(const XmlElement* stanza);
109 // An IqTask which publishes a <pubsub><publish><retract> to a particular
110 // pubsub jid and node.
111 class PubSubRetractTask : public IqTask {
113 PubSubRetractTask(XmppTaskParentInterface* parent,
114 const Jid& pubsubjid,
115 const std::string& node,
116 const std::string& itemid);
118 const std::string& itemid() const { return itemid_; }
120 sigslot::signal1<PubSubRetractTask*> SignalResult;
123 // SignalError inherited by IqTask.
124 virtual void HandleResult(const XmlElement* stanza);
131 #endif // TALK_XMPP_PUBSUBTASKS_H_