flexoff.h

00001 /*
00002   Copyright (c) 2005-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #ifndef FLEXOFF_H__
00015 #define FLEXOFF_H__
00016 
00017 #include "clientbase.h"
00018 #include "discohandler.h"
00019 #include "flexoffhandler.h"
00020 #include "iqhandler.h"
00021 #include "stanzaextension.h"
00022 
00023 namespace gloox
00024 {
00025 
00034   class GLOOX_API FlexibleOffline : public DiscoHandler, public IqHandler
00035   {
00036     public:
00041       FlexibleOffline( ClientBase* parent );
00042 
00046       virtual ~FlexibleOffline();
00047 
00053       void checkSupport();
00054 
00059       void getMsgCount();
00060 
00065       void fetchHeaders();
00066 
00074       void fetchMessages( const StringList& msgs )
00075         { messageOperation( FORequestMsgs, msgs ); }
00076 
00083       void removeMessages( const StringList& msgs )
00084         { messageOperation( FORemoveMsgs, msgs ); }
00085 
00091       void registerFlexibleOfflineHandler( FlexibleOfflineHandler* foh );
00092 
00096       void removeFlexibleOfflineHandler();
00097 
00098       // reimplemented from DiscoHandler
00099       virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context );
00100 
00101       // reimplemented from DiscoHandler
00102       virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context );
00103 
00104       // reimplemented from DiscoHandler
00105       virtual void handleDiscoError( const JID& from, const Error* error, int context );
00106 
00107       // reimplemented from IqHandler.
00108       virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
00109 
00110       // reimplemented from IqHandler.
00111       virtual void handleIqID( const IQ& iq, int context );
00112 
00113     private:
00114 #ifdef FLEXOFF_TEST
00115     public:
00116 #endif
00117       class Offline : public StanzaExtension
00118       {
00119         public:
00124           Offline( const Tag* tag = 0 );
00125 
00131           Offline( int context, const StringList& msgs );
00132 
00136           virtual ~Offline();
00137 
00138           // reimplemented from StanzaExtension
00139           virtual const std::string& filterString() const;
00140 
00141           // reimplemented from StanzaExtension
00142           virtual StanzaExtension* newInstance( const Tag* tag ) const
00143           {
00144             return new Offline( tag );
00145           }
00146 
00147           // reimplemented from StanzaExtension
00148           virtual Tag* tag() const;
00149 
00150           // reimplemented from StanzaExtension
00151           virtual StanzaExtension* clone() const
00152           {
00153             return new Offline( *this );
00154           }
00155 
00156         private:
00157           int m_context;
00158           StringList m_msgs;
00159       };
00160 
00161       void messageOperation( int context, const StringList& msgs );
00162 
00163       enum FOContext
00164       {
00165         FOCheckSupport,
00166         FORequestNum,
00167         FORequestHeaders,
00168         FORequestMsgs,
00169         FORemoveMsgs
00170       };
00171 
00172       ClientBase* m_parent;
00173       FlexibleOfflineHandler* m_flexibleOfflineHandler;
00174   };
00175 
00176 }
00177 
00178 #endif // FLEXOFF_H__

Generated by  doxygen 1.6.2