Home | History | Annotate | Download | only in xmpp
      1 /*
      2  *  Copyright 2011 The WebRTC Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_LIBJINGLE_XMPP_RECEIVETASK_H_
     12 #define WEBRTC_LIBJINGLE_XMPP_RECEIVETASK_H_
     13 
     14 #include "webrtc/libjingle/xmpp/xmpptask.h"
     15 
     16 namespace buzz {
     17 
     18 // A base class for receiving stanzas.  Override WantsStanza to
     19 // indicate that a stanza should be received and ReceiveStanza to
     20 // process it.  Once started, ReceiveStanza will be called for all
     21 // stanzas that return true when passed to WantsStanza. This saves
     22 // you from having to remember how to setup the queueing and the task
     23 // states, etc.
     24 class ReceiveTask : public XmppTask {
     25  public:
     26   explicit ReceiveTask(XmppTaskParentInterface* parent) :
     27       XmppTask(parent, XmppEngine::HL_TYPE) {}
     28   virtual int ProcessStart();
     29 
     30  protected:
     31   virtual bool HandleStanza(const XmlElement* stanza);
     32 
     33   // Return true if the stanza should be received.
     34   virtual bool WantsStanza(const XmlElement* stanza) = 0;
     35   // Process the received stanza.
     36   virtual void ReceiveStanza(const XmlElement* stanza) = 0;
     37 };
     38 
     39 }  // namespace buzz
     40 
     41 #endif  // WEBRTC_LIBJINGLE_XMPP_RECEIVETASK_H_
     42