siprofileft.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 SIPROFILEFT_H__
#define SIPROFILEFT_H__
#include "iqhandler.h"
#include "socks5bytestreammanager.h"
#include "siprofilehandler.h"
#include "sihandler.h"
#include "simanager.h"
#include "bytestreamhandler.h"
#include <string>
#include <map>
namespace gloox
{
class ClientBase;
class InBandBytestream;
class IQ;
class JID;
class SIProfileFTHandler;
class SOCKS5Bytestream;
class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler,
public BytestreamHandler, public IqHandler
{
public:
enum StreamType
{
FTTypeS5B = 1,
FTTypeIBB = 2,
FTTypeOOB = 4,
FTTypeAll = 0xFF
};
SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0,
SOCKS5BytestreamManager* s5Manager = 0 );
virtual ~SIProfileFT();
const std::string requestFT( const JID& to, const std::string& name, long size,
const std::string& hash = EmptyString,
const std::string& desc = EmptyString,
const std::string& date = EmptyString,
const std::string& mimetype = EmptyString,
int streamTypes = FTTypeAll,
const JID& from = JID(),
const std::string& sid = EmptyString );
void acceptFT( const JID& to, const std::string& sid,
StreamType type = FTTypeS5B, const JID& from = JID() );
void declineFT( const JID& to, const std::string& sid, SIManager::SIError reason,
const std::string& text = EmptyString );
void cancel( Bytestream* bs );
void dispose( Bytestream* bs );
void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; }
void removeSIProfileFTHandler() { m_handler = 0; }
void setStreamHosts( StreamHostList hosts );
void addStreamHost( const JID& jid, const std::string& host, int port );
void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server )
{ if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); }
void removeSOCKS5BytestreamServer()
{ if( m_socks5Manager ) m_socks5Manager->removeSOCKS5BytestreamServer(); }
// reimplemented from SIProfileHandler
virtual void handleSIRequest( const JID& from, const JID& to, const std::string& id,
const SIManager::SI& si );
// reimplemented from SIHandler
virtual void handleSIRequestResult( const JID& from, const JID& to, const std::string& sid,
const SIManager::SI& si );
// reimplemented from SIHandler
virtual void handleSIRequestError( const IQ& iq, const std::string& sid );
// reimplemented from BytestreamHandler
virtual void handleIncomingBytestreamRequest( const std::string& sid, const JID& from );
// reimplemented from BytestreamHandler
virtual void handleIncomingBytestream( Bytestream* bs );
// reimplemented from BytestreamHandler
virtual void handleOutgoingBytestream( Bytestream* bs );
// reimplemented from BytestreamHandler
virtual void handleBytestreamError( const IQ& iq, const std::string& sid );
// reimplemented from IqHandler.
virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
// reimplemented from IqHandler.
virtual void handleIqID( const IQ& iq, int context );
private:
enum TrackEnum
{
OOBSent
};
ClientBase* m_parent;
SIManager* m_manager;
SIProfileFTHandler* m_handler;
SOCKS5BytestreamManager* m_socks5Manager;
StreamHostList m_hosts;
StringMap m_id2sid;
bool m_delManager;
bool m_delS5Manager;
};
}
#endif // SIPROFILEFT_H__
gloox::BytestreamHandler
A virtual interface that allows to receive new incoming Bytestream requests from remote entities.
Definition bytestreamhandler.h:37
gloox::Bytestream
An abstraction of a single bytestream.
Definition bytestream.h:37
gloox::ClientBase
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
Definition clientbase.h:79
gloox::IQ
An abstraction of an IQ stanza.
Definition iq.h:34
gloox::InBandBytestream
An implementation of a single In-Band Bytestream (XEP-0047).
Definition inbandbytestream.h:44
gloox::IqHandler
A virtual interface which can be reimplemented to receive IQ stanzas.
Definition iqhandler.h:32
gloox::JID
An abstraction of a JID.
Definition jid.h:31
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
This class manages streams initiated using XEP-0095.
Definition simanager.h:35
gloox::SIManager::SIError
SIError
Definition simanager.h:42
gloox::SIProfileFTHandler
An abstract base class to handle file transfer (FT) requests.
Definition siprofilefthandler.h:37
gloox::SIProfileFT
An implementation of the file transfer SI profile (XEP-0096).
Definition siprofileft.h:152
gloox::SIProfileFT::handleIq
virtual bool handleIq(const IQ &iq)
Definition siprofileft.h:316
gloox::SIProfileFT::registerSIProfileFTHandler
void registerSIProfileFTHandler(SIProfileFTHandler *sipfth)
Definition siprofileft.h:256
gloox::SIProfileFT::registerSOCKS5BytestreamServer
void registerSOCKS5BytestreamServer(SOCKS5BytestreamServer *server)
Definition siprofileft.h:283
gloox::SIProfileFT::StreamType
StreamType
Definition siprofileft.h:158
gloox::SIProfileFT::FTTypeOOB
@ FTTypeOOB
Definition siprofileft.h:161
gloox::SIProfileFT::FTTypeAll
@ FTTypeAll
Definition siprofileft.h:162
gloox::SIProfileFT::FTTypeS5B
@ FTTypeS5B
Definition siprofileft.h:159
gloox::SIProfileFT::FTTypeIBB
@ FTTypeIBB
Definition siprofileft.h:160
gloox::SIProfileFT::removeSOCKS5BytestreamServer
void removeSOCKS5BytestreamServer()
Definition siprofileft.h:289
gloox::SIProfileFT::SIProfileFT
SIProfileFT(ClientBase *parent, SIProfileFTHandler *sipfth, SIManager *manager=0, SOCKS5BytestreamManager *s5Manager=0)
Definition siprofileft.cpp:31
gloox::SIProfileFT::removeSIProfileFTHandler
void removeSIProfileFTHandler()
Definition siprofileft.h:261
gloox::SIProfileHandler
An abstract base class to handle SI requests for a specific profile, e.g. file transfer.
Definition siprofilehandler.h:38
gloox::SOCKS5BytestreamManager
An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams.
Definition socks5bytestreammanager.h:52
gloox::SOCKS5BytestreamServer
A server listening for SOCKS5 bytestreams.
Definition socks5bytestreamserver.h:37
gloox::SOCKS5Bytestream
An implementation of a single SOCKS5 Bytestream (XEP-0065).
Definition socks5bytestream.h:43
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::StreamHostList
std::list< StreamHost > StreamHostList
Definition socks5bytestreammanager.h:43