Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

simanager.h

00001 /*
00002   Copyright (c) 2007-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 #ifndef SIMANAGER_H__
00015 #define SIMANAGER_H__
00016 
00017 #include "iqhandler.h"
00018 
00019 namespace gloox
00020 {
00021 
00022   class ClientBase;
00023   class SIProfileHandler;
00024   class SIHandler;
00025 
00034   class GLOOX_API SIManager : public IqHandler
00035   {
00036 
00037     public:
00041       enum SIError
00042       {
00043         NoValidStreams,             
00044         BadProfile,                 
00045         RequestRejected             
00046       };
00047 
00048       class SI : public StanzaExtension
00049       {
00050         public:
00055           SI( const Tag* tag = 0 );
00056 
00062           SI( Tag* tag1, Tag* tag2, const std::string& id = EmptyString,
00063               const std::string& mimetype = EmptyString,
00064               const std::string& profile = EmptyString );
00065 
00069           virtual ~SI();
00070 
00075           const std::string& profile() const { return m_profile; };
00076 
00081           const std::string& mimetype() const { return m_mimetype; };
00082 
00087           const std::string& id() const { return m_id; };
00088 
00094           const Tag* tag1() const { return m_tag1; };
00095 
00101           const Tag* tag2() const { return m_tag2; };
00102 
00103           // reimplemented from StanzaExtension
00104           virtual const std::string& filterString() const;
00105 
00106           // reimplemented from StanzaExtension
00107           virtual StanzaExtension* newInstance( const Tag* tag ) const
00108           {
00109             return new SI( tag );
00110           }
00111 
00112           // reimplemented from StanzaExtension
00113           virtual Tag* tag() const;
00114 
00115         private:
00116           Tag* m_tag1;
00117           Tag* m_tag2;
00118           std::string m_id;
00119           std::string m_mimetype;
00120           std::string m_profile;
00121       };
00122 
00128       SIManager( ClientBase* parent, bool advertise = true );
00129 
00133       virtual ~SIManager();
00134 
00149       const std::string requestSI( SIHandler* sih, const JID& to, const std::string& profile, Tag* child1,
00150                                    Tag* child2 = 0, const std::string& mimetype = "binary/octet-stream" );
00151 
00163       void acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2 = 0 );
00164 
00173       void declineSI( const JID& to, const std::string& id, SIError reason,
00174                       const std::string& text = EmptyString );
00175 
00184       void registerProfile( const std::string& profile, SIProfileHandler* sih );
00185 
00190       void removeProfile( const std::string& profile );
00191 
00192       // reimplemented from IqHandler.
00193       virtual bool handleIq( const IQ& iq );
00194 
00195       // reimplemented from IqHandler.
00196       virtual void handleIqID( const IQ& iq, int context );
00197 
00198     private:
00199 #ifdef SIMANAGER_TEST
00200     public:
00201 #endif
00202       enum TrackContext
00203       {
00204         OfferSI
00205       };
00206 
00207       struct TrackStruct
00208       {
00209         std::string sid;
00210         std::string profile;
00211         SIHandler* sih;
00212       };
00213       typedef std::map<std::string, TrackStruct> TrackMap;
00214       TrackMap m_track;
00215 
00216       ClientBase* m_parent;
00217 
00218       typedef std::map<std::string, SIProfileHandler*> HandlerMap;
00219       HandlerMap m_handlers;
00220 
00221       bool m_advertise;
00222 
00223   };
00224 
00225 }
00226 
00227 #endif // SIMANAGER_H__

Generated on Sun Dec 28 22:10:18 2008 for gloox by  doxygen 1.4.1