gloox 1.0.24
simanager.h
1/*
2 Copyright (c) 2007-2019 by Jakob Schröter <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
19namespace gloox
20{
21
22 class ClientBase;
23 class SIProfileHandler;
24 class SIHandler;
25
34 class GLOOX_API SIManager : public IqHandler
35 {
36
37 public:
42 {
45 RequestRejected
46 };
47
48 class SI : public StanzaExtension
49 {
50 public:
55 SI( const Tag* tag = 0 );
56
62 SI( Tag* tag1, Tag* tag2, const std::string& id = EmptyString,
63 const std::string& mimetype = EmptyString,
64 const std::string& profile = EmptyString );
65
69 virtual ~SI();
70
75 const std::string& profile() const { return m_profile; };
76
81 const std::string& mimetype() const { return m_mimetype; };
82
87 const std::string& id() const { return m_id; };
88
94 const Tag* tag1() const { return m_tag1; };
95
101 const Tag* tag2() const { return m_tag2; };
102
103 // reimplemented from StanzaExtension
104 virtual const std::string& filterString() const;
105
106 // reimplemented from StanzaExtension
107 virtual StanzaExtension* newInstance( const Tag* tag ) const
108 {
109 return new SI( tag );
110 }
111
112 // reimplemented from StanzaExtension
113 virtual Tag* tag() const;
114
115 // reimplemented from StanzaExtension
116 virtual StanzaExtension* clone() const
117 {
118 SI* s = new SI();
119 s->m_tag1 = m_tag1 ? m_tag1->clone() : 0;
120 s->m_tag2 = m_tag2 ? m_tag2->clone() : 0;
121 s->m_id = m_id;
122 s->m_mimetype = m_mimetype;
123 s->m_profile = m_profile;
124 return s;
125 }
126
127 private:
128 Tag* m_tag1;
129 Tag* m_tag2;
130 std::string m_id;
131 std::string m_mimetype;
132 std::string m_profile;
133 };
134
140 SIManager( ClientBase* parent, bool advertise = true );
141
145 virtual ~SIManager();
146
164 const std::string requestSI( SIHandler* sih, const JID& to, const std::string& profile, Tag* child1,
165 Tag* child2 = 0, const std::string& mimetype = "binary/octet-stream",
166 const JID& from = JID(), const std::string& sid = EmptyString );
167
181 void acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2 = 0, const JID& from = JID() );
182
191 void declineSI( const JID& to, const std::string& id, SIError reason,
192 const std::string& text = EmptyString );
193
202 void registerProfile( const std::string& profile, SIProfileHandler* sih );
203
208 void removeProfile( const std::string& profile );
209
210 // reimplemented from IqHandler.
211 virtual bool handleIq( const IQ& iq );
212
213 // reimplemented from IqHandler.
214 virtual void handleIqID( const IQ& iq, int context );
215
216 private:
217#ifdef SIMANAGER_TEST
218 public:
219#endif
220 enum TrackContext
221 {
222 OfferSI
223 };
224
225 struct TrackStruct
226 {
227 std::string sid;
228 std::string profile;
229 SIHandler* sih;
230 };
231 typedef std::map<std::string, TrackStruct> TrackMap;
232 TrackMap m_track;
233
234 ClientBase* m_parent;
235
236 typedef std::map<std::string, SIProfileHandler*> HandlerMap;
237 HandlerMap m_handlers;
238
239 bool m_advertise;
240
241 };
242
243}
244
245#endif // SIMANAGER_H__
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition: iqhandler.h:32
This class manages streams initiated using XEP-0095.
Definition: simanager.h:35
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
Definition: tag.h:47
The namespace for the gloox library.
Definition: adhoc.cpp:28
const std::string EmptyString
Definition: gloox.cpp:124