simanager.h
/*
Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef SIMANAGER_H__
#define SIMANAGER_H__
#include "iqhandler.h"
namespace gloox
{
class ClientBase;
class SIProfileHandler;
class SIHandler;
class GLOOX_API SIManager : public IqHandler
{
public:
enum SIError
{
NoValidStreams,
BadProfile,
RequestRejected
};
class SI : public StanzaExtension
{
public:
SI( const Tag* tag = 0 );
SI( Tag* tag1, Tag* tag2, const std::string& id = EmptyString,
const std::string& mimetype = EmptyString,
const std::string& profile = EmptyString );
virtual ~SI();
const std::string& profile() const { return m_profile; };
const std::string& mimetype() const { return m_mimetype; };
const std::string& id() const { return m_id; };
const Tag* tag1() const { return m_tag1; };
const Tag* tag2() const { return m_tag2; };
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new SI( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
SI* s = new SI();
s->m_tag1 = m_tag1 ? m_tag1->clone() : 0;
s->m_tag2 = m_tag2 ? m_tag2->clone() : 0;
s->m_id = m_id;
s->m_mimetype = m_mimetype;
s->m_profile = m_profile;
return s;
}
private:
Tag* m_tag1;
Tag* m_tag2;
std::string m_id;
std::string m_mimetype;
std::string m_profile;
};
SIManager( ClientBase* parent, bool advertise = true );
virtual ~SIManager();
const std::string requestSI( SIHandler* sih, const JID& to, const std::string& profile, Tag* child1,
Tag* child2 = 0, const std::string& mimetype = "binary/octet-stream",
const JID& from = JID(), const std::string& sid = EmptyString );
void acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2 = 0, const JID& from = JID() );
void declineSI( const JID& to, const std::string& id, SIError reason,
const std::string& text = EmptyString );
void registerProfile( const std::string& profile, SIProfileHandler* sih );
void removeProfile( const std::string& profile );
// reimplemented from IqHandler.
virtual bool handleIq( const IQ& iq );
// reimplemented from IqHandler.
virtual void handleIqID( const IQ& iq, int context );
private:
#ifdef SIMANAGER_TEST
public:
#endif
enum TrackContext
{
OfferSI
};
struct TrackStruct
{
std::string sid;
std::string profile;
SIHandler* sih;
};
typedef std::map<std::string, TrackStruct> TrackMap;
TrackMap m_track;
ClientBase* m_parent;
typedef std::map<std::string, SIProfileHandler*> HandlerMap;
HandlerMap m_handlers;
bool m_advertise;
};
}
#endif // SIMANAGER_H__
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::SIHandler
An abstract base class to handle results of outgoing SI requests, i.e. you requested a stream (using ...
Definition sihandler.h:40
gloox::SIManager::SIManager
SIManager(ClientBase *parent, bool advertise=true)
Definition simanager.cpp:89
gloox::SIManager::SIError
SIError
Definition simanager.h:42
gloox::SIManager::NoValidStreams
@ NoValidStreams
Definition simanager.h:43
gloox::SIManager::RequestRejected
@ RequestRejected
Definition simanager.h:45
gloox::SIManager::BadProfile
@ BadProfile
Definition simanager.h:44
gloox::SIProfileHandler
An abstract base class to handle SI requests for a specific profile, e.g. file transfer.
Definition siprofilehandler.h:38
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124