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 SIPROFILEFTHANDLER_H__ 15 #define SIPROFILEFTHANDLER_H__ 16 17 #include "jid.h" 18 19 #include <string> 20 21 namespace gloox 22 { 23 24 class JID; 25 class IQ; 26 class Bytestream; 27 28 /** 29 * @brief An abstract base class to handle file transfer (FT) requests. 30 * 31 * See SIProfileFT for more information regarding file transfer. 32 * 33 * @author Jakob Schröter <js@camaya.net> 34 * @since 0.9 35 */ 36 class GLOOX_API SIProfileFTHandler 37 { 38 39 public: 40 /** 41 * Virtual destructor. 42 */ ~SIProfileFTHandler()43 virtual ~SIProfileFTHandler() {} 44 45 /** 46 * This function is called to handle incoming file transfer requests, i.e. a remote entity requested 47 * to send a file to you. You should use either SIProfileFT::acceptFT() or 48 * SIProfileFT::declineFT() to accept or reject the request, respectively. 49 * @param from The file transfer requestor. 50 * @param to The file transfer recipient. Usuall oneself. Used in component scenario. 51 * @param sid The requested stream's ID. This sid MUST be supplied to SIProfileFT::acceptFT() 52 * and SIProfileFT::declineFT(), respectively. 53 * @param name The file name. 54 * @param size The file size. 55 * @param hash The file content's MD5 sum. 56 * @param date The file's last modification time. 57 * @param mimetype The file's mime-type. 58 * @param desc The file's description. 59 * @param stypes An ORed list of @link gloox::SIProfileFT::StreamType SIProfileFT::StreamType @endlink 60 * indicating the StreamTypes the initiator supports. 61 */ 62 virtual void handleFTRequest( const JID& from, const JID& to, const std::string& sid, 63 const std::string& name, long size, const std::string& hash, 64 const std::string& date, const std::string& mimetype, 65 const std::string& desc, int stypes ) = 0; 66 67 /** 68 * This function is called to handle a request error or decline. 69 * @param iq The complete error stanza. 70 * @param sid The request's SID. 71 */ 72 virtual void handleFTRequestError( const IQ& iq, const std::string& sid ) = 0; 73 74 /** 75 * This function is called to pass a negotiated bytestream (SOCKS5 or IBB). 76 * The bytestream is not yet open and not ready to send/receive data. 77 * @note To initialize the bytestream and to prepare it for data transfer 78 * do the following, preferable in that order: 79 * @li register a BytestreamDataHandler with the Bytestream, 80 * @li set up a separate thread for the bytestream or integrate it into 81 * your main loop, 82 * @li call its connect() method and check the return value. 83 * To not block your application while the data transfer and/or the connection 84 * attempts last, you most likely want to put the bytestream into its own 85 * thread or process (before calling connect() on it). It is safe to do so 86 * without additional synchronization. 87 * @param bs The bytestream. 88 */ 89 virtual void handleFTBytestream( Bytestream* bs ) = 0; 90 91 /** 92 * This function is called if the contact chose OOB as the mechanism. 93 * @param from The remote contact's JID. 94 * @param to The local recipient's JID. Usually oneself. Used in component scenario. 95 * @param sid The stream's ID. 96 * @return The file's URL. 97 */ 98 virtual const std::string handleOOBRequestResult( const JID& from, const JID& to, const std::string& sid ) = 0; 99 100 }; 101 102 } 103 104 #endif // SIPROFILEFTHANDLER_H__ 105