gloox  1.0.16
flexoff.h
1 /*
2  Copyright (c) 2005-2015 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef FLEXOFF_H__
15 #define FLEXOFF_H__
16 
17 #include "clientbase.h"
18 #include "discohandler.h"
19 #include "flexoffhandler.h"
20 #include "iqhandler.h"
21 #include "stanzaextension.h"
22 
23 namespace gloox
24 {
25 
34  class GLOOX_API FlexibleOffline : public DiscoHandler, public IqHandler
35  {
36  public:
41  FlexibleOffline( ClientBase* parent );
42 
46  virtual ~FlexibleOffline();
47 
53  void checkSupport();
54 
59  void getMsgCount();
60 
65  void fetchHeaders();
66 
74  void fetchMessages( const StringList& msgs )
75  { messageOperation( FORequestMsgs, msgs ); }
76 
83  void removeMessages( const StringList& msgs )
84  { messageOperation( FORemoveMsgs, msgs ); }
85 
91  void registerFlexibleOfflineHandler( FlexibleOfflineHandler* foh );
92 
96  void removeFlexibleOfflineHandler();
97 
98  // reimplemented from DiscoHandler
99  virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context );
100 
101  // reimplemented from DiscoHandler
102  virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context );
103 
104  // reimplemented from DiscoHandler
105  virtual void handleDiscoError( const JID& from, const Error* error, int context );
106 
107  // reimplemented from IqHandler.
108  virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
109 
110  // reimplemented from IqHandler.
111  virtual void handleIqID( const IQ& iq, int context );
112 
113  private:
114 #ifdef FLEXOFF_TEST
115  public:
116 #endif
117  class Offline : public StanzaExtension
118  {
119  public:
124  Offline( const Tag* tag = 0 );
125 
131  Offline( int context, const StringList& msgs );
132 
136  virtual ~Offline();
137 
138  // reimplemented from StanzaExtension
139  virtual const std::string& filterString() const;
140 
141  // reimplemented from StanzaExtension
142  virtual StanzaExtension* newInstance( const Tag* tag ) const
143  {
144  return new Offline( tag );
145  }
146 
147  // reimplemented from StanzaExtension
148  virtual Tag* tag() const;
149 
150  // reimplemented from StanzaExtension
151  virtual StanzaExtension* clone() const
152  {
153  return new Offline( *this );
154  }
155 
156  private:
157  int m_context;
158  StringList m_msgs;
159  };
160 
161  void messageOperation( int context, const StringList& msgs );
162 
163  enum FOContext
164  {
165  FOCheckSupport,
166  FORequestNum,
167  FORequestHeaders,
168  FORequestMsgs,
169  FORemoveMsgs
170  };
171 
172  ClientBase* m_parent;
173  FlexibleOfflineHandler* m_flexibleOfflineHandler;
174  };
175 
176 }
177 
178 #endif // FLEXOFF_H__
An abstraction of a Disco query element (from Service Discovery, XEP-0030) in the disco::items namesp...
Definition: disco.h:275
std::list< std::string > StringList
Definition: gloox.h:1244
An abstraction of an IQ stanza.
Definition: iq.h:33
void removeMessages(const StringList &msgs)
Definition: flexoff.h:83
A stanza error abstraction implemented as a StanzaExtension.
Definition: error.h:34
An implementation of XEP-0013 (Flexible Offline Message Retrieval).
Definition: flexoff.h:34
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class abstracts a stanza extension, which is usually an element in a specific namespace...
virtual bool handleIq(const IQ &iq)
Definition: flexoff.h:108
Implementation of this virtual interface allows for retrieval of offline messages following XEP-0030...
An abstraction of a JID.
Definition: jid.h:30
An abstraction of a Disco Info element (from Service Discovery, XEP-0030) as a StanzaExtension.
Definition: disco.h:65
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition: iqhandler.h:31
A virtual interface that enables objects to receive Service Discovery (XEP-0030) events.
Definition: discohandler.h:34
void fetchMessages(const StringList &msgs)
Definition: flexoff.h:74
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition: clientbase.h:76
This is an abstraction of an XML element.
Definition: tag.h:46