gloox  1.0.1
flexoff.h
1 /*
2  Copyright (c) 2005-2012 by Jakob Schroeter <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__