gloox  0.9.9.12
simanager.h
1 /*
2  Copyright (c) 2007-2008 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 SIMANAGER_H__
15 #define SIMANAGER_H__
16 
17 #include "iqhandler.h"
18 
19 namespace gloox
20 {
21 
22  class ClientBase;
23  class SIProfileHandler;
24  class SIHandler;
25 
34  class GLOOX_API SIManager : public IqHandler
35  {
36 
37  public:
41  enum SIError
42  {
45  RequestRejected
46  };
47 
53  SIManager( ClientBase* parent, bool advertise = true );
54 
58  virtual ~SIManager();
59 
74  const std::string requestSI( SIHandler* sih, const JID& to, const std::string& profile, Tag* child1,
75  Tag* child2 = 0, const std::string& mimetype = "binary/octet-stream" );
76 
88  void acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2 = 0 );
89 
98  void declineSI( const JID& to, const std::string& id, SIError reason, const std::string& text = "" );
99 
108  void registerProfile( const std::string& profile, SIProfileHandler* sih );
109 
114  void removeProfile( const std::string& profile );
115 
116  // re-implemented from IqHandler
117  virtual bool handleIq( Stanza *stanza );
118 
119  // re-implemented from IqHandler
120  virtual bool handleIqID( Stanza *stanza, int context );
121 
122  private:
123  enum TrackContext
124  {
125  OfferSI
126  };
127 
128  struct TrackStruct
129  {
130  std::string sid;
131  std::string profile;
132  SIHandler* sih;
133  };
134  typedef std::map<std::string, TrackStruct> TrackMap;
135  TrackMap m_track;
136 
137  ClientBase* m_parent;
138 
139  typedef std::map<std::string, SIProfileHandler*> HandlerMap;
140  HandlerMap m_handlers;
141 
142  bool m_advertise;
143 
144  };
145 
146 }
147 
148 #endif // SIMANAGER_H__