14 #include "siprofileft.h"
16 #include "clientbase.h"
17 #include "siprofilefthandler.h"
18 #include "simanager.h"
20 #include "inbandbytestream.h"
22 #include "socks5bytestream.h"
23 #include "socks5bytestreammanager.h"
33 : m_parent( parent ), m_manager( manager ), m_handler( sipfth ),
34 m_socks5Manager( s5Manager ), m_delManager( false ),
35 m_delS5Manager( false )
45 if( !m_socks5Manager )
48 m_delS5Manager =
true;
59 if( m_socks5Manager && m_delS5Manager )
60 delete m_socks5Manager;
64 const std::string& hash,
const std::string& desc,
65 const std::string& date,
const std::string& mimetype,
66 int streamTypes,
const JID& from,
67 const std::string& sid )
69 if( name.empty() || size <= 0 || !m_manager )
80 new Tag( file,
"desc", desc );
89 sm.insert( std::make_pair( std::string(
"ibb" ),
XMLNS_IBB ) );
91 sm.insert( std::make_pair( std::string(
"oob" ),
XMLNS_IQ_OOB ) );
103 if( m_id2sid.find( sid ) == m_id2sid.end() )
106 const std::string&
id = m_id2sid[sid];
121 from ? from : m_parent->
jid(), sid );
133 m_manager->
acceptSI( to,
id, 0, feature, from );
137 const std::string& text )
139 if( m_id2sid.find( sid ) == m_id2sid.end() || !m_manager )
142 m_manager->
declineSI( to, m_id2sid[sid], reason, text );
161 if( m_id2sid.find( bs->
sid() ) == m_id2sid.end() || !m_manager )
172 if( m_socks5Manager )
178 if( m_socks5Manager )
183 const SIManager::SI& si )
193 const std::string& mt = si.mimetype();
204 StringMultiMap::const_iterator it = options.begin();
205 for( ; it != options.end(); ++it )
217 const std::string& sid = si.id();
219 m_handler->
handleFTRequest( from, to, sid, si.tag1()->findAttribute(
"name" ),
220 atol( si.tag1()->findAttribute(
"size" ).c_str() ),
221 si.tag1()->findAttribute(
"hash" ),
222 si.tag1()->findAttribute(
"date" ),
223 mt.empty() ?
"binary/octet-stream" : mt,
229 const SIManager::SI& si )
248 to ? to : m_parent->
jid(), from, sid );
257 const std::string&
id = m_parent->
getID();
263 m_parent->
send( iq,
this, OOBSent );
An abstraction of a single bytestream.
const std::string & sid() const
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
const std::string getID()
An abstraction of an IQ stanza.
An implementation of a single In-Band Bytestream (XEP-0047).
This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element as sp...
This class manages streams initiated using XEP-0095.
void acceptSI(const JID &to, const std::string &id, Tag *child1, Tag *child2=0, const JID &from=JID())
void registerProfile(const std::string &profile, SIProfileHandler *sih)
void declineSI(const JID &to, const std::string &id, SIError reason, const std::string &text=EmptyString)
void removeProfile(const std::string &profile)
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)
An abstract base class to handle file transfer (FT) requests.
virtual void handleFTRequestError(const IQ &iq, const std::string &sid)=0
virtual void handleFTBytestream(Bytestream *bs)=0
virtual void handleFTRequest(const JID &from, const JID &to, const std::string &sid, const std::string &name, long size, const std::string &hash, const std::string &date, const std::string &mimetype, const std::string &desc, int stypes)=0
virtual const std::string handleOOBRequestResult(const JID &from, const JID &to, const std::string &sid)=0
void setStreamHosts(StreamHostList hosts)
virtual void handleIncomingBytestream(Bytestream *bs)
virtual void handleIqID(const IQ &iq, int context)
void addStreamHost(const JID &jid, const std::string &host, int port)
virtual void handleSIRequest(const JID &from, const JID &to, const std::string &id, const SIManager::SI &si)
void cancel(Bytestream *bs)
virtual void handleSIRequestError(const IQ &iq, const std::string &sid)
virtual void handleIncomingBytestreamRequest(const std::string &sid, const JID &from)
virtual void handleOutgoingBytestream(Bytestream *bs)
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 dispose(Bytestream *bs)
void acceptFT(const JID &to, const std::string &sid, StreamType type=FTTypeS5B, const JID &from=JID())
virtual void handleBytestreamError(const IQ &iq, const std::string &sid)
virtual void handleSIRequestResult(const JID &from, const JID &to, const std::string &sid, const SIManager::SI &si)
SIProfileFT(ClientBase *parent, SIProfileFTHandler *sipfth, SIManager *manager=0, SOCKS5BytestreamManager *s5Manager=0)
void declineFT(const JID &to, const std::string &sid, SIManager::SIError reason, const std::string &text=EmptyString)
An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams.
void setStreamHosts(StreamHostList hosts)
void addStreamHost(const JID &jid, const std::string &host, int port)
void rejectSOCKS5Bytestream(const std::string &sid, StanzaError reason=StanzaErrorNotAcceptable)
bool requestSOCKS5Bytestream(const JID &to, S5BMode mode, const std::string &sid=EmptyString, const JID &from=JID())
bool dispose(SOCKS5Bytestream *s5b)
void acceptSOCKS5Bytestream(const std::string &sid)
An implementation of a single SOCKS5 Bytestream (XEP-0065).
void addExtension(const StanzaExtension *se)
void setFrom(const JID &from)
This is an abstraction of an XML element.
Tag * findChild(const std::string &name) const
bool addAttribute(Attribute *attr)
void addChild(Tag *child)
const std::string cdata() const
The namespace for the gloox library.
const std::string XMLNS_IQ_OOB
std::multimap< std::string, std::string > StringMultiMap
const std::string XMLNS_IBB
const std::string XMLNS_FEATURE_NEG
const std::string XMLNS_X_DATA
const std::string EmptyString
const std::string XMLNS_SI_FT
@ StanzaErrorServiceUnavailable
std::list< StreamHost > StreamHostList
const std::string XMLNS_BYTESTREAMS