adhoc.h

00001 /*
00002   Copyright (c) 2004-2008 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 
00015 #ifndef ADHOC_H__
00016 #define ADHOC_H__
00017 
00018 #include "disconodehandler.h"
00019 #include "discohandler.h"
00020 #include "iqhandler.h"
00021 
00022 #include <string>
00023 #include <list>
00024 #include <map>
00025 
00026 namespace gloox
00027 {
00028 
00029   class DataForm;
00030   class ClientBase;
00031   class Stanza;
00032   class AdhocHandler;
00033   class AdhocCommandProvider;
00034 
00078   class GLOOX_API Adhoc : public DiscoNodeHandler, public DiscoHandler, public IqHandler
00079   {
00080     public:
00084       enum AdhocCommandStatus
00085       {
00086         AdhocCommandExecuting,      
00087         AdhocCommandCompleted,      
00088         AdhocCommandCanceled,       
00089         AdhocCommandStatusUnknown   
00090       };
00091 
00095       enum AdhocExecuteActions
00096       {
00097         ActionDefault    =  0,      
00098         ActionPrevious   =  1,      
00099         ActionNext       =  2,      
00100         ActionComplete   =  4,      
00101         ActionCancel     =  8       
00102       };
00103 
00107       enum AdhocNoteType
00108       {
00109         AdhocNoteInfo,              
00111         AdhocNoteWarn,              
00113         AdhocNoteError              
00115       };
00116 
00122       Adhoc( ClientBase *parent );
00123 
00127       virtual ~Adhoc();
00128 
00129       // reimplemented from DiscoNodeHandler
00130       virtual StringList handleDiscoNodeFeatures( const std::string& node );
00131 
00132       // reimplemented from DiscoNodeHandler
00133       virtual StringMap handleDiscoNodeIdentities( const std::string& node, std::string& name );
00134 
00135       // reimplemented from DiscoNodeHandler
00136       virtual DiscoNodeItemList handleDiscoNodeItems( const std::string& node );
00137 
00138       // reimplemented from IqHandler
00139       virtual bool handleIq( Stanza *stanza );
00140 
00141       // reimplemented from IqHandler
00142       virtual bool handleIqID( Stanza *stanza, int context );
00143 
00144       // reimplemented from DiscoHandler
00145       virtual void handleDiscoInfoResult( Stanza *stanza, int context );
00146 
00147       // reimplemented from DiscoHandler
00148       virtual void handleDiscoItemsResult( Stanza *stanza, int context );
00149 
00150       // reimplemented from DiscoHandler
00151       virtual void handleDiscoError( Stanza *stanza, int context );
00152 
00160       void registerAdhocCommandProvider( AdhocCommandProvider *acp, const std::string& command,
00161                                          const std::string& name );
00162 
00168       void checkSupport( const JID& remote, AdhocHandler *ah );
00169 
00176       void getCommands( const JID& remote, AdhocHandler *ah );
00177 
00192       void execute( const JID& remote, const std::string& command, AdhocHandler *ah,
00193                     const std::string& sessionid = "", DataForm *form = 0,
00194                     AdhocExecuteActions action = ActionDefault );
00195 
00201       void removeAdhocCommandProvider( const std::string& command );
00202 
00203     private:
00204       typedef std::map<const std::string, AdhocCommandProvider*> AdhocCommandProviderMap;
00205       AdhocCommandProviderMap m_adhocCommandProviders;
00206 
00207       enum AdhocContext
00208       {
00209         CheckAdhocSupport,
00210         FetchAdhocCommands,
00211         ExecuteAdhocCommand
00212       };
00213 
00214       struct TrackStruct
00215       {
00216         JID remote;
00217         AdhocContext context;
00218         AdhocHandler *ah;
00219       };
00220       typedef std::map<std::string, TrackStruct> AdhocTrackMap;
00221       AdhocTrackMap m_adhocTrackMap;
00222 
00223       ClientBase *m_parent;
00224 
00225       StringMap m_items;
00226 
00227   };
00228 
00229 }
00230 
00231 #endif // ADHOC_H__

Generated on Mon Dec 7 13:28:18 2009 for gloox by  doxygen 1.6.1