Index: ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpbase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpbase.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpbase.h (revision 27490) @@ -1,138 +1,142 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 CONNECTIONTCPBASE_H__ #define CONNECTIONTCPBASE_H__ #include "gloox.h" #include "connectionbase.h" #include "logsink.h" #include "mutex.h" #ifdef __MINGW32__ #include #endif #include namespace gloox { namespace util { class Mutex; } /** * @brief This is a base class for a simple TCP connection. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionTCPBase : public ConnectionBase { public: /** * Constructs a new ConnectionTCPBase object. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. * @param port The port to connect to. The default of -1 means that XMPP SRV records * will be used to find out about the actual host:port. * @note To properly use this object, you have to set a ConnectionDataHandler using * registerConnectionDataHandler(). This is not necessary if this object is * part of a 'connection chain', e.g. with ConnectionHTTPProxy. */ ConnectionTCPBase( const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Constructs a new ConnectionTCPBase object. * @param cdh An ConnectionDataHandler-derived object that will handle incoming data. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. * @param port The port to connect to. The default of -1 means that SRV records will be used * to find out about the actual host:port. */ ConnectionTCPBase( ConnectionDataHandler* cdh, const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Virtual destructor */ virtual ~ConnectionTCPBase(); // reimplemented from ConnectionBase virtual bool send( const std::string& data ); // reimplemented from ConnectionBase + virtual bool send( const char* data, const size_t len ); + + // reimplemented from ConnectionBase virtual ConnectionError receive(); // reimplemented from ConnectionBase virtual void disconnect(); // reimplemented from ConnectionBase virtual void cleanup(); // reimplemented from ConnectionBase virtual void getStatistics( long int &totalIn, long int &totalOut ); /** * Gives access to the raw socket of this connection. Use it wisely. You can * select()/poll() it and use ConnectionTCPBase::recv( -1 ) to fetch the data. * @return The socket of the active connection, or -1 if no connection is established. */ int socket() const { return m_socket; } /** * This function allows to set an existing socket with an established * connection to use in this connection. You will still need to call connect() in order to * negotiate the XMPP stream. You should not set a new socket after having called connect(). * @param socket The existing socket. */ void setSocket( int socket ) { m_cancel = false; m_state = StateConnected; m_socket = socket; } /** * Returns the local port. * @return The local port. */ virtual int localPort() const; /** * Returns the locally bound IP address. * @return The locally bound IP address. */ virtual const std::string localInterface() const; protected: ConnectionTCPBase& operator=( const ConnectionTCPBase& ); void init( const std::string& server, int port ); bool dataAvailable( int timeout = -1 ); void cancel(); + int waitForSocketReady( bool readop = true ); const LogSink& m_logInstance; util::Mutex m_sendMutex; util::Mutex m_recvMutex; char* m_buf; int m_socket; long int m_totalBytesIn; long int m_totalBytesOut; const int m_bufsize; bool m_cancel; }; } #endif // CONNECTIONTCPBASE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/client.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/client.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/client.h (revision 27490) @@ -1,530 +1,542 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 CLIENT_H__ #define CLIENT_H__ #include "clientbase.h" #include "presence.h" #include namespace gloox { +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CAPABILITIES ) class Capabilities; +#endif // GLOOX_MINIMAL class RosterManager; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUH ) class NonSaslAuth; +#endif // GLOOX_MINIMAL class IQ; /** * @brief This class implements a basic Jabber/XMPP Client. * * It supports @ref sasl_auth as well as TLS (Encryption), which can be * switched on/off separately. They are used automatically if the server supports them. * * To use, create a new Client instance and feed it connection credentials, either in the Constructor or * afterwards using the setters. You should then register packet handlers implementing the corresponding * Interfaces (ConnectionListener, PresenceHandler, MessageHandler, IqHandler, SubscriptionHandler), * and call @ref connect() to establish the connection to the server. * * @note While the MessageHandler interface is still available (and will be in future versions) * it is now recommended to use the new @link gloox::MessageSession MessageSession @endlink for any * serious messaging. * * Simple usage example: * @code * using namespace gloox; * * void TestProg::doIt() * { * Client* j = new Client( "user@server/resource", "password" ); * j->registerPresenceHandler( this ); * j->disco()->setVersion( "TestProg", "1.0" ); * j->disco()->setIdentity( "client", "bot" ); * j->connect(); * } * * virtual void TestProg::presenceHandler( Presence* presence ) * { * // handle incoming presence packets here * } * @endcode * * However, you can skip the presence handling stuff if you make use of the RosterManager. * * By default, the library handles a few (incoming) IQ namespaces on the application's behalf. These * include: * @li jabber:iq:roster: by default the server-side roster is fetched and handled. Use * @ref rosterManager() and @ref RosterManager to interact with the Roster. * @li @xep{0092} (Software Version): If no version is specified, a name of "based on gloox" with * gloox's current version is announced. * @li @xep{0030} (Service Discovery): All supported/available services are announced. No items are * returned. * @note As of gloox 0.9, by default a priority of 0 is sent along with the initial presence. * @note As of gloox 0.9, initial presence is automatically sent. Presence: available, Priority: 0. * To disable sending of initial Presence use setPresence() with a value of Unavailable * prior to connecting. * * @section sasl_auth SASL Authentication * * Besides the simple, IQ-based authentication (@xep{0078}), gloox supports several SASL (Simple * Authentication and Security Layer, RFC 2222) authentication mechanisms. * @li DIGEST-MD5: This mechanism is preferred over all other mechanisms if username and password are * provided to the Client instance. It is secure even without TLS encryption. * @li PLAIN: This mechanism is used if DIGEST-MD5 is not available. It is @b not secure without * encryption. * @li ANONYMOUS This mechanism is used if neither username nor password are set. The server generates * random, temporary username and resource and may restrict available services. * @li EXTERNAL This mechanism is currently only available if client certificate and private key * are provided. The server tries to figure out who the client is by external means -- for instance, * using the provided certificate or even the IP address. (The restriction to certificate/key * availability is likely to be lifted in the future.) * * Of course, all these mechanisms are not tried unless the server offers them. * * @section stream_management Stream Management * * To enable Stream Management (@xep{0198}), call @ref setStreamManagement() with the first parameter set to @b true * at any time. This will tell the server to enable Stream Management, if the feature is available. Once switched on, * Stream Management can not be disabled for a given active stream. However, setting the first * parameter to @b false, it can be disabled inside gloox so that Stream Management will not be used * for subsequent connections. * * To enable the stream resumption feature, pass @b true as the second parameter to @ref setStreamManagement(). * Upon re-connect after an unexpected (i.e. neither user-triggered nor server-triggered) disconnect, gloox will try * to resume the stream and re-send any non-acknowledged stanzas automatically. * For stream resumption to work you have to re-connect using the very same Client instance. * * After an unexpected disconnect you may check the send queue using @link ClientBase::sendQueue() sendQueue() @endlink. * Stanzas in the queue have been sent but not yet acknowledged by the server. Depending on the circumstances of the * disconnect, this does not mean that those stanzas have not been received by the recipient. * * * @author Jakob Schröter */ class GLOOX_API Client : public ClientBase { public: +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUTH ) friend class NonSaslAuth; +#endif // GLOOX_MINIMAL friend class Parser; /** * Constructs a new Client which can be used for account registration only. * SASL and TLS are on by default. The port will be determined by looking up SRV records. * Alternatively, you can set the port explicitly by calling @ref setPort(). * @param server The server to connect to. */ Client( const std::string& server ); /** * Constructs a new Client. * SASL and TLS are on by default. This should be the default constructor for most use cases. * The server address will be taken from the JID. The actual host will be resolved using SRV * records. The domain part of the JID is used as a fallback in case no SRV record is found, or * you can set the server address separately by calling @ref setServer(). * @param jid A full Jabber ID used for connecting to the server. * @param password The password used for authentication. * @param port The port to connect to. The default of -1 means to look up the port via DNS SRV. */ Client( const JID& jid, const std::string& password, int port = -1 ); /** * Virtual destructor. */ virtual ~Client(); /** * Use this function to bind an additional resource or to @b re-try to bind a * resource in case previous binding failed and you were notified by means of * ConnectionListener::onResourceBindError(). Use hasResourceBind() to find out if the * server supports binding of multiple resources. bindResource() is a NOOP if it doesn't. * @note ConnectionListener::onResourceBound() and ConnectionListener::onResourceBindError() * will be called in case of success and failure, respectively. * @param resource The resource identifier to bind. May be empty. In that case * the server will assign a unique resource identifier. * @return Returns @b true if binding of multiple resources is supported, @b false * otherwise. A return value of @b true does not indicate that the resource was * successfully bound. * @note It is not necessary to call this function to bind the initial, main, resource. * @since 1.0 */ bool bindResource( const std::string& resource ) { return bindOperation( resource, true ); } /** * Use this function to select a resource identifier that has been bound * previously by means of bindResource(). It is not necessary to call this function * if only one resource is bound. Use hasResourceBind() to find out if the * server supports binding of multiple resources. * @param resource A resource string that has been bound previously. * @note If the resource string has not been bound previously, future sending of * stanzas will fail. */ bool selectResource( const std::string& resource ); /** * This function can be used to find out whether the server supports binding of multiple * resources. * @return @b True if binding of multiple resources is supported by the server, * @b false otherwise. */ bool hasResourceBind() const { return ((m_streamFeatures & StreamFeatureUnbind) == StreamFeatureUnbind); } /** * Use this function to unbind a resource identifier that has been bound * previously by means of bindResource(). Use hasResourceBind() to find out if the * server supports binding of multiple resources. unbindResource() is a NOOP if it doesn't. * @param resource A resource string that has been bound previously. * @note Servers are encouraged to terminate the connection should the only bound * resource be unbound. */ bool unbindResource( const std::string& resource ) { return bindOperation( resource, false ); } /** * Returns the current prepped main resource. * @return The resource used to connect. */ const std::string& resource() const { return m_jid.resource(); } /** * This function enables Stream Management (@xep{0198}) if the server supports it. * Optionally, stream resumption can be disabled. * @note You can use this function at any time. However, gloox will make sure Stream Management * requests are sent only when allowed by the specification. * @param enable Enable or disable Stream Management. Note: once enabled on a connection, Stream * Management can not be disabled for that connection. * @param resume Tells the server whether to enable stream resumption. Defaults to @b true. * @note This function is part of @xep{0198}. * @since 1.0.4 */ void setStreamManagement( bool enable = true, bool resume = true ); /** * Use this function to send an unrequested 'ack' to the server to let it know the number of handled stanzas. * You may use this function at any time. However, gloox will also reply to incoming 'ack requests' automatically. * These automatic 'acks' are not announced anywhere in gloox. * This function is a no-op if called in situations where sending an ack is not * allowed by the protocol. * @note This function is part of @xep{0198}. * @since 1.0.4 */ void ackStreamManagement(); /** * Use this function to request the number of handled stanzas from the server. * You may use this function at any time. gloox does not send any such requests * automatically. * @note This function is part of @xep{0198}. * @since 1.0.4 */ void reqStreamManagement(); /** * Returns the current priority. * @return The priority of the current resource. */ int priority() const { return m_presence.priority(); } /** * Sets the username to use to connect to the XMPP server. * @param username The username to authenticate with. */ void setUsername( const std::string &username ); /** * Sets the main resource to use to connect to the XMPP server. * @param resource The resource to use to log into the server. */ void setResource( const std::string &resource ) { m_jid.setResource( resource ); } /** * Sends directed presence to the given JID. This is a NOOP if there's no active connection. * To broadcast presence use setPresence( Presence::PresenceType, int, const std::string& ). * @param to The JID to send directed Presence to. * @param pres The presence to send. * @param priority The priority to include. Legal values: -128 <= priority <= 127 * @param status The optional status message to include. * @note This function does not include any presence extensions (as added by * means of addPresenceExtension()) to the stanza. */ void setPresence( const JID& to, Presence::PresenceType pres, int priority, const std::string& status = EmptyString ); /** * Use this function to set the entity's presence, that is, to broadcast presence to all * subscribed entities. To send directed presence, use * setPresence( const JID&, Presence::PresenceType, int, const std::string& ). * If used prior to establishing a connection, the set values will be sent with * the initial presence stanza. * If used while a connection already is established, a presence stanza will be * sent out immediately. * @param pres The Presence value to set. * @param priority An optional priority value. Legal values: -128 <= priority <= 127 * @param status An optional message describing the presence state. * @since 0.9 */ void setPresence( Presence::PresenceType pres, int priority, const std::string& status = EmptyString ); /** * Use this function to broadcast the entity's presence to all * subscribed entities. This is a NOOP if there's no active connection. * To send directed presence, use * setPresence( const JID&, Presence::PresenceType, int, const std::string& ). * If used while a connection already is established a repective presence stanza will be * sent out immediately. Use presence() to modify the Presence object. * @note When login is finished, initial presence will be sent automatically. * So you do not need to call this function after login. * @since 1.0 */ void setPresence() { sendPresence( m_presence ); } /** * Use this function to indicate a client state of 'active' to the Server. * See @xep{0352} for more information. * This function is a no-op if the server does not support Client State Indication (i.e. nothing is sent). * Use hasClientStateIndication() to find out. * @since 1.0.19 */ void setActive() { if( hasClientStateIndication() ) send( new Tag( "active", XMLNS, XMLNS_CLIENT_STATE_INDICATION ) ); } /** * Use this function to indicate a client state of 'inactive' to the Server. * See @xep{0352} for more information. * This function is a no-op if the server does not support Client State Indication (i.e. nothing is sent). * Use hasClientStateIndication() to find out. * @since 1.0.19 */ void setInactive() { if( hasClientStateIndication() ) send( new Tag( "inactive", XMLNS, XMLNS_CLIENT_STATE_INDICATION ) ); } /** * Use this function to find out whether the server supports Client State Indication (@xep{0352}). * @return @b True if the server supports @xep{0352}, @b false if not. * XEP Version: 0.2 * @since 1.0.19 */ bool hasClientStateIndication() const { return ((m_streamFeatures & StreamFeatureClientStateIndication) == StreamFeatureClientStateIndication); } /** * Returns the current presence. * @return The current presence. */ Presence& presence() { return m_presence; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUH ) /** * This is a temporary hack to enforce Non-SASL login. You should not need to use it. * @param force Whether to force non-SASL auth. Default @b true. * @deprecated Please update the server to properly support SASL instead. */ GLOOX_DEPRECATED void setForceNonSasl( bool force = true ) { m_forceNonSasl = force; } +#endif // GLOOX_MINIMAL /** * Disables the automatic roster management. * You have to keep track of incoming presence yourself if * you want to have a roster. */ void disableRoster(); /** * This function gives access to the @c RosterManager object. * @return A pointer to the RosterManager. */ RosterManager* rosterManager() { return m_rosterManager; } /** * Disconnects from the server. */ void disconnect(); /** * Initiates a login attempt (currently SASL External not supported). * This is useful after registering a new account. Simply use setUsername() and setPassword(), * and call login(). * @return @b True if a login attempt could be started, @b false otherwise. A return * value of @b true does not indicate that login was successful. */ bool login(); protected: +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUH ) /** * Initiates non-SASL login. */ void nonSaslLogin(); +#endif // GLOOX_MINIMAL private: #ifdef CLIENT_TEST public: #endif /** * @brief This is an implementation of a resource binding StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class ResourceBind : public StanzaExtension { public: /** * Constructs a new object with the given resource string. * @param resource The resource to set. * @param bind Indicates whether this is an bind or unbind request. * Defaults to @b true (bind). */ ResourceBind( const std::string& resource, bool bind = true ); /** * Constructs a new object from the given Tag. * @param tag The Tag to parse. */ ResourceBind( const Tag* tag ); /** * Destructor. */ ~ResourceBind(); /** * Returns the requested resource. * @return The requested resource. */ const std::string& resource() const { return m_resource; } /** * Returns the assigned JID. * @return The assigned JID. */ const JID& jid() const { return m_jid; } /** * Use this function to find out whether the extension contains a * bind or unbind request. * @return @b True if the extension contains an unbind request, @b false otherwise. */ bool unbind() const { return !m_bind; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new ResourceBind( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new ResourceBind( *this ); } private: std::string m_resource; JID m_jid; bool m_bind; }; /** * @brief This is an implementation of a session creating StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class SessionCreation : public StanzaExtension { public: /** * Constructs a new object. */ SessionCreation() : StanzaExtension( ExtSessionCreation ) {} /** * Destructor. */ ~SessionCreation() {} // reimplemented from StanzaExtension virtual const std::string& filterString() const { return EmptyString; } // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { (void)tag; return 0; } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return 0; } }; virtual void handleStartNode( const Tag* /*start*/ ) {} virtual bool handleNormalNode( Tag* tag ); virtual void disconnect( ConnectionError reason ); virtual void handleIqIDForward( const IQ& iq, int context ); int getStreamFeatures( Tag* tag ); int getSaslMechs( Tag* tag ); int getCompressionMethods( Tag* tag ); void processResourceBind( const IQ& iq ); void processCreateSession( const IQ& iq ); void sendPresence( Presence& pres ); void createSession(); void negotiateCompression( StreamFeature method ); void connected(); virtual void rosterFilled(); virtual void cleanup(); bool bindOperation( const std::string& resource, bool bind ); void sendStreamManagement(); void init(); enum TrackContext { CtxResourceBind = 1000, // must be higher than the last element in ClientBase's TrackContext CtxResourceUnbind, CtxSessionEstablishment }; RosterManager* m_rosterManager; + + #if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUTH ) NonSaslAuth* m_auth; + bool m_forceNonSasl; +#endif // GLOOX_MINIMAL Presence m_presence; - - bool m_forceNonSasl; bool m_manageRoster; std::string m_smId; std::string m_smLocation; bool m_smResume; bool m_smWanted; int m_smMax; int m_streamFeatures; }; } #endif // CLIENT_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/component.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/component.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/component.h (revision 27490) @@ -1,77 +1,81 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_COMPONENT ) + #ifndef COMPONENT_H__ #define COMPONENT_H__ #include "clientbase.h" #include namespace gloox { /** * @brief This is an implementation of a basic jabber Component. * * It's using @xep{0114} (Jabber Component Protocol) to authenticate with a server. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API Component : public ClientBase { public: /** * Constructs a new Component. * @param ns The namespace that qualifies the stream. Either @b jabber:component:accept or * @b jabber:component:connect. See @xep{0114} for details. * @param server The server to connect to. * @param component The component's hostname. FQDN. * @param password The component's password. * @param port The port to connect to. The default of 5347 is the default port of the router * in jabberd2. */ Component( const std::string& ns, const std::string& server, const std::string& component, const std::string& password, int port = 5347 ); /** * Virtual Destructor. */ virtual ~Component() {} /** * Disconnects from the server. */ virtual void disconnect() { ClientBase::disconnect( ConnUserDisconnected ); } protected: // reimplemented from ClientBase virtual void handleStartNode( const Tag* start ); // reimplemented from ClientBase virtual bool handleNormalNode( Tag* tag ); // reimplemented from ClientBase virtual bool checkStreamVersion( const std::string& /*version*/ ) { return true; } private: // reimplemented from ClientBase virtual void rosterFilled() {} }; } #endif // COMPONENT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/config.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/config.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/config.h (revision 27490) @@ -1,27 +1,25 @@ /* Copyright (c) 2009-2019 by Jakob Schröter 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 CONFIG_H__ #define CONFIG_H__ -#if ( defined _WIN32 ) && !defined( __SYMBIAN32__ ) +#if ( defined _WIN32 ) # include "../config.h.win" #elif defined( _WIN32_WCE ) # include "../config.h.win" -#elif defined( __SYMBIAN32__ ) -# include "../config.h.symbian" #else # include "config.h.unix" // run ./configure to create config.h.unix #endif #endif // CONFIG_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/connectionbosh.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectionbosh.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectionbosh.h (revision 27490) @@ -1,225 +1,237 @@ /* * Copyright (c) 2007-2019 by Jakob Schröter * 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CONNECTIONBOSH ) + #ifndef CONNECTIONBOSH_H__ #define CONNECTIONBOSH_H__ #include "gloox.h" #include "connectionbase.h" #include "logsink.h" #include "taghandler.h" #include "parser.h" #include #include #include namespace gloox { /** * @brief This is an implementation of a BOSH (HTTP binding) connection. * * Usage: * * @code * Client *c = new Client( ... ); * c->setConnectionImpl( new ConnectionBOSH( c, * new ConnectionTCPClient( c->logInstance(), httpServer, httpPort ), * c->logInstance(), boshHost, xmpphost, xmppPort ) ); * @endcode * * Make sure to pass the BOSH connection manager's host/port to the transport connection * (ConnectionTCPClient in this case), and the XMPP server's host and port to the BOSH connection. * You must also pass to BOSH the address of the BOSH server you are dealing with, this is used * in the HTTP Host header. * * In the case of using ConnectionBOSH through a HTTP proxy, supply httpServer and httpPort as * those of the proxy. In all cases, boshHost should be set to the hostname (not IP address) of * the server running the BOSH connection manager. * * The reason why ConnectionBOSH doesn't manage its own ConnectionTCPClient is that it allows it * to be used with other transports (like chained SOCKS5/HTTP proxies, or ConnectionTLS * for HTTPS). * * @note To avoid problems, you should disable TLS in gloox by calling * ClientBase::setTls( TLSDisabled ). * * Sample configurations for different servers can be found in the bosh_example.cpp file included * with gloox in the @b src/examples/ directory. * * @author Matthew Wild * @author Jakob Schröter * @since 1.0 */ class GLOOX_API ConnectionBOSH : public ConnectionBase, ConnectionDataHandler, TagHandler { public: /** * Constructs a new ConnectionBOSH object. * @param connection A transport connection. It should be configured to connect to * the BOSH connection manager's (or a HTTP proxy's) host and port, @b not to the XMPP host. * ConnectionBOSH will own the transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param boshHost The hostname of the BOSH connection manager * @param xmppServer A server to connect to. This is the XMPP server's address, @b not the * connection manager's. * @param xmppPort The port to connect to. This is the XMPP server's port, @b not the connection * manager's. * @note To properly use this object, you have to set a ConnectionDataHandler using * registerConnectionDataHandler(). This is not necessary if this object is * part of a 'connection chain', e.g. with ConnectionSOCKS5Proxy. */ ConnectionBOSH( ConnectionBase* connection, const LogSink& logInstance, const std::string& boshHost, const std::string& xmppServer, int xmppPort = 5222 ); /** * Constructs a new ConnectionBOSH object. * @param cdh An ConnectionDataHandler-derived object that will handle incoming data. * @param connection A transport connection. It should be configured to connect to * the connection manager's (or proxy's) host and port, @b not to the XMPP host. ConnectionBOSH * will own the transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param boshHost The hostname of the BOSH connection manager (not any intermediate proxy) * @param xmppServer A server to connect to. This is the XMPP server's address, @b not the connection * manager's. * @param xmppPort The port to connect to. This is the XMPP server's port, @b not the connection * manager's. */ ConnectionBOSH( ConnectionDataHandler* cdh, ConnectionBase* connection, const LogSink& logInstance, const std::string& boshHost, const std::string& xmppServer, int xmppPort = 5222 ); /** * Virtual destructor */ virtual ~ConnectionBOSH(); /** * The supported connection modes. Usually auto-detected. */ enum ConnMode { ModeLegacyHTTP, /**< HTTP 1.0 connections, closed after receiving a response */ ModePersistentHTTP, /**< HTTP 1.1 connections, re-used after receiving a response */ ModePipelining /**< HTTP Pipelining (implies HTTP 1.1) a single connection is used */ }; /** * Sets the XMPP server to proxy to. * @param xmppHost The XMPP server hostname (IP address). * @param xmppPort The XMPP server port. */ void setServer( const std::string& xmppHost, unsigned short xmppPort = 5222 ) { m_server = xmppHost; m_port = xmppPort; } /** * Sets the path on the connection manager to request * @param path The path, the default is "/http-bind/", which is the default for * many connection managers. */ void setPath( const std::string& path ) { m_path = path; } /** * Sets the connection mode * @param mode The connection mode, @sa ConnMode * @note In the case that a mode is selected that the connection manager * or proxy does not support, gloox will fall back to using HTTP/1.0 connections, * which should work with any server. */ void setMode( ConnMode mode ) { m_connMode = mode; } // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionBase virtual bool send( const std::string& data ); // reimplemented from ConnectionBase + virtual bool send( const char* /*data*/, const size_t /*len*/ ) + { + m_logInstance.err( LogAreaClassConnectionBOSH, "Sending binary not implemented" ); + return false; + } + + // reimplemented from ConnectionBase virtual ConnectionError receive(); // reimplemented from ConnectionBase virtual void disconnect(); // reimplemented from ConnectionBase virtual void cleanup(); // reimplemented from ConnectionBase virtual void getStatistics( long int& totalIn, long int& totalOut ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); // reimplemented from ConnectionDataHandler virtual ConnectionBase* newInstance() const; // reimplemented from TagHandler virtual void handleTag( Tag* tag ); private: ConnectionBOSH& operator=( const ConnectionBOSH& ); void initInstance( ConnectionBase* connection, const std::string& xmppServer, const int xmppPort ); bool sendRequest( const std::string& xml ); bool sendXML(); const std::string getHTTPField( const std::string& field ); - ConnectionBase* getConnection(); - ConnectionBase* activateConnection(); + ConnectionBase* getConnection( int timeout = -1 ); + ConnectionBase* activateConnection( int timeout = -1 ); void putConnection(); //ConnectionBase *m_connection; const LogSink& m_logInstance; Parser m_parser; // Used for parsing XML section of responses std::string m_boshHost; // The hostname of the BOSH connection manager std::string m_boshedHost; // The hostname of the BOSH connection manager + : + port std::string m_path; // The path part of the URL that we need to request // BOSH parameters unsigned long m_rid; std::string m_sid; bool m_initialStreamSent; int m_openRequests; int m_maxOpenRequests; int m_wait; int m_hold; bool m_streamRestart; // Set to true if we are waiting for an acknowledgement of a stream restart time_t m_lastRequestTime; unsigned long m_minTimePerRequest; std::string m_buffer; // Buffer of received data std::string m_bufferHeader; // HTTP header of data currently in buffer // FIXME doens't need to be member std::string::size_type m_bufferContentLength; // Length of the data in the current response std::string m_sendBuffer; // Data waiting to be sent typedef std::list ConnectionList; ConnectionList m_activeConnections; ConnectionList m_connectionPool; ConnMode m_connMode; }; } #endif // CONNECTIONBOSH_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/connectionsocks5proxy.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectionsocks5proxy.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectionsocks5proxy.h (revision 27490) @@ -1,178 +1,190 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CONNECTIONSOCKS5PROXY ) + #ifndef CONNECTIONSOCKS5PROXY_H__ #define CONNECTIONSOCKS5PROXY_H__ #include "gloox.h" #include "connectionbase.h" #include "logsink.h" #include namespace gloox { /** * @brief This is an implementation of a simple SOCKS5 Proxying connection (RFC 1928 + RFC 1929). * * To use with a SOCKS5 proxy: * * @code * Client* c = new Client( ... ); * c->setConnectionImpl( new ConnectionSOCKS5Proxy( c, * new ConnectionTCPClient( c->logInstance(), proxyHost, proxyPort ), * c->logInstance(), xmppHost, xmppPort ) ); * @endcode * * Make sure to pass the proxy host/port to the transport connection (ConnectionTCPClient in this case), * and the XMPP host/port to the proxy connection. * * The reason why ConnectionSOCKS5Proxy doesn't manage its own ConnectionTCPClient is that it allows it * to be used with other transports (like IPv6 or chained HTTP/SOCKS5 proxies). * * @note This class is also used by the SOCKS5 bytestreams implementation (with slightly different * semantics). * * @note Simple @b plain-text username/password authentication is supported. GSSAPI authentication * is not supported. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionSOCKS5Proxy : public ConnectionBase, public ConnectionDataHandler { public: /** * Constructs a new ConnectionSOCKS5Proxy object. * @param connection A transport connection. It should be configured to connect to * the proxy host and port, @b not to the (XMPP) host. ConnectionSOCKS5Proxy will own the * transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. This is the XMPP server's address, @b not the proxy. * @param port The proxy's port to connect to. This is the (XMPP) server's port, @b not the proxy's. * The default of -1 means that SRV records will be used to find out about the actual host:port. * @param ip Indicates whether @c server is an IP address (true) or a host name (false). * @note To properly use this object, you have to set a ConnectionDataHandler using * registerConnectionDataHandler(). This is not necessary if this object is * part of a 'connection chain', e.g. with ConnectionHTTPProxy. */ ConnectionSOCKS5Proxy( ConnectionBase* connection, const LogSink& logInstance, const std::string& server, int port = -1, bool ip = false ); /** * Constructs a new ConnectionSOCKS5Proxy object. * @param cdh A ConnectionDataHandler-derived object that will handle incoming data. * @param connection A transport connection. It should be configured to connect to * the proxy host and port, @b not to the (XMPP) host. ConnectionSOCKS5Proxy will own the * transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. This is the XMPP server's address, @b not the proxy. * @param port The proxy's port to connect to. This is the (XMPP) server's port, @b not the proxy's. * The default of -1 means that SRV records will be used to find out about the actual host:port. * @param ip Indicates whether @c server is an IP address (true) or a host name (false). */ ConnectionSOCKS5Proxy( ConnectionDataHandler* cdh, ConnectionBase* connection, const LogSink& logInstance, const std::string& server, int port = -1, bool ip = false ); /** * Virtual destructor */ virtual ~ConnectionSOCKS5Proxy(); // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionBase virtual bool send( const std::string& data ); // reimplemented from ConnectionBase + virtual bool send( const char* /*data*/, const size_t /*len*/ ) + { + m_logInstance.err( LogAreaClassConnectionSOCKS5Proxy, "Sending binary not implemented" ); + return false; + } + + // reimplemented from ConnectionBase virtual ConnectionError receive(); // reimplemented from ConnectionBase virtual void disconnect(); // reimplemented from ConnectionBase virtual void cleanup(); // reimplemented from ConnectionBase virtual void getStatistics( long int &totalIn, long int &totalOut ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); // reimplemented from ConnectionDataHandler virtual ConnectionBase* newInstance() const; /** * Sets the server to proxy to. * @param host The server hostname (IP address). * @param port The server port. The default of -1 means that SRV records will be used * to find out about the actual host:port. * @param ip Indicates whether @c host is an IP address (true) or a host name (false). */ void setServer( const std::string& host, int port = -1, bool ip = false ) { m_server = host; m_port = port; m_ip = ip; } /** * Sets proxy authorization credentials. * @param user The user name to use for proxy authorization. * @param password The password to use for proxy authorization. */ void setProxyAuth( const std::string& user, const std::string& password ) { m_proxyUser = user; m_proxyPwd = password; } /** * Sets the underlying transport connection. A possibly existing connection will be deleted. * @param connection The ConnectionBase to replace the current connection, if any. */ void setConnectionImpl( ConnectionBase* connection ); private: enum Socks5State { S5StateDisconnected, S5StateConnecting, S5StateNegotiating, S5StateAuthenticating, S5StateConnected }; ConnectionSOCKS5Proxy &operator=( const ConnectionSOCKS5Proxy& ); void negotiate(); ConnectionBase* m_connection; const LogSink& m_logInstance; Socks5State m_s5state; std::string m_proxyUser; std::string m_proxyPwd; std::string m_proxyHandshakeBuffer; bool m_ip; }; } #endif // CONNECTIONSOCKS5PROXY_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpserver.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpserver.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpserver.h (revision 27490) @@ -1,77 +1,82 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CONNECTIONTCPSERVER ) + #ifndef CONNECTIONTCPSERVER_H__ #define CONNECTIONTCPSERVER_H__ #include "gloox.h" #include "connectiontcpbase.h" #include "logsink.h" #include namespace gloox { class ConnectionHandler; /** * @brief This is an implementation of a simple listening TCP connection. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionTCPServer : public ConnectionTCPBase { public: /** * Constructs a new ConnectionTCPServer object. * @param ch A ConnectionHandler-derived object that will handle incoming connections. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param ip The local IP address to listen on. This must @b not be a hostname. * Leave this empty to listen on all local interfaces. * @param port The port to listen on. */ ConnectionTCPServer( ConnectionHandler* ch, const LogSink& logInstance, const std::string& ip, int port ); /** * Virtual destructor */ virtual ~ConnectionTCPServer(); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); /** * This function actually starts @c listening on the port given in the * constructor. */ // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionBase* newInstance() const; private: ConnectionTCPServer &operator=( const ConnectionTCPServer & ); ConnectionHandler* m_connectionHandler; }; } #endif // CONNECTIONTCPSERVER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/connectionwebsocket.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectionwebsocket.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectionwebsocket.h (revision 27490) @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2017-2019 by Jakob Schröter + * 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. + */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_WEBSOCKET ) + +#ifndef CONNECTIONWEBSOCKET_H__ +#define CONNECTIONWEBSOCKET_H__ + +#include +#include +#include + +#if defined(_WIN32) || defined (_WIN32_WCE) +#include +#endif + +#include "gloox.h" +#include "connectionbase.h" +#include "logsink.h" +#include "taghandler.h" +#include "pinghandler.h" +#include "parser.h" +#include "base64.h" +#include "sha.h" + + +#ifndef SYSTEM_RANDOM_FILEPATH +#define SYSTEM_RANDOM_FILEPATH "/dev/urandom" +#endif + +namespace gloox +{ + + /** + * @brief This class implements XMPP over Websocket (RFC7395). + * + * @author Didier Perrotey + * @author Olivier Tchilinguirian + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API ConnectionWebSocket : public ConnectionBase, public ConnectionDataHandler, public TagHandler + { + public: + /** + * Creates a new WebSocket connection. Usually, you would feed it a ConnectionTLS + * and/or ConnectionTCPClient as transport connection (1st parameter). + * The default path part of the URI is @c /xmpp. Use setPath() to change it. + * @param connection The transport connection. + * @param logInstance The LogSink to use for logging. + * @param wsHost The WebSocket host. This will be put in the HTTP request's Host: header. It + * is not used to resolve hostnames or make an actual connection. + * @param ph The PingHandler to receive notifications about WebSocket Pings. Not required + * for full functionality. + */ + ConnectionWebSocket( ConnectionBase* connection, const LogSink& logInstance, const std::string& wsHost, + PingHandler *ph = 0 ); + + /** + * Creates a new WebSocket connection. Usually, you would feed it a ConnectionTLS + * and/or ConnectionTCPClient as transport connection (2nd parameter). + * The default path part of the URI is @c /xmpp. Use setPath() to change it. + * @param cdh The data handler for incoming data. + * @param connection The transport connection. + * @param logInstance The LogSink to use for logging. + * @param wsHost The WebSocket host. This will be put in the HTTP request's Host: header. It + * is not used to resolve hostnames or make an actual connection. + * @param ph The PingHandler to receive notifications about WebSocket Pings. Not required + * for full functionality. + */ + ConnectionWebSocket( ConnectionDataHandler* cdh, ConnectionBase* connection, + const LogSink& logInstance, const std::string& wsHost, + PingHandler *ph = 0 ); + + /** + * Virtual destructor. + */ + virtual ~ConnectionWebSocket(); + + /** + * Sets the WebSocket host. + * @param wsHost The WebSocket host. This will be put in the HTTP request's Host: header. It + * is not used to resolve hostnames or make an actual connection. + */ + void setServer( const std::string& wsHost ) { m_server = wsHost; } + + /** + * Sets the path part of the URI that is the WebSocket endpoint. + * @param path The path. + */ + void setPath( const std::string& path ) { m_path = path; } + + void setMasked( bool bMasked ) { m_bMasked = bMasked; } + + void setFlags( int flags ) { m_flags = flags; } + + // reimplemented from ConnectionBase + virtual ConnectionError connect( int timeout = -1 ); + + // reimplemented from ConnectionBase + virtual ConnectionError recv( int timeout = -1 ); + + // reimplemented from ConnectionBase + virtual bool send( const std::string& data ); + + // reimplemented from ConnectionBase + virtual bool send( const char* data, const size_t len ) ; + + // reimplemented from ConnectionBase + virtual ConnectionError receive(); + + // reimplemented from ConnectionBase + virtual void disconnect(); + + // reimplemented from ConnectionBase + virtual void cleanup(); + + // reimplemented from ConnectionBase + virtual void getStatistics( long int& totalIn, long int& totalOut ); + + // reimplemented from ConnectionBase + virtual std::string header( std::string to, std::string xmlns, std::string xmllang ); + + // reimplemented from ConnectionDataHandler + virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); + + // reimplemented from ConnectionDataHandler + virtual void handleConnect( const ConnectionBase* connection ); + + // reimplemented from ConnectionDataHandler + virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); + + // reimplemented from ConnectionDataHandler + virtual ConnectionBase* newInstance() const; + + // reimplemented from TagHandler + virtual void handleTag( Tag* tag ); + +// virtual ConnectionBase* connectionImpl() const { return m_connection ; }; + + /** + * Sends a WebSocket Ping. + * @param body An optional ping body. + */ + virtual bool sendPingWebSocketFrame( std::string body = EmptyString ); + + private: + + class FrameWebSocket + { + public: + enum wsFrameType + { + wsFrameContinuation, + wsFrameText, + wsFrameBinary, + wsFrameClose = 8, + wsFramePing, + wsFramePong + }; + + /** + * Constructs a new FrameWebSocket object + */ + FrameWebSocket( const LogSink& logInstance, int flags ); + + FrameWebSocket( const LogSink& logInstance, const std::string& payload, wsFrameType frameType, + bool bMasked, int flags ); + + /** + * Virtual destructor. + */ + virtual ~FrameWebSocket() + { + if( m_encodedFrame ) + { + delete[] m_encodedFrame; + m_encodedFrame = 0; + } + }; + + void encode( bool addCRLF = false, int reason = 0 ); + + void decode( std::string& frameContent ); + + unsigned char* getEncodedBuffer() { return m_encodedFrame; }; + + bool isMasked() { return m_MASK; }; + + unsigned long long getFrameLen(); + + unsigned long long getEffectiveLen(); + + unsigned long long getOffsetLen(); + + /** + * Check if frame content is full or partial. + * @return @b True if this frame content is full (no data missing), @b false otherwise. + */ + bool isFull(); + + std::string getPayload() { return m_payload; }; + + void getMask( std::string& mask ); + + wsFrameType getType() { return m_opcode; } + + bool isUnfragmented() { return m_FIN; } + + void dump(); + + private: + + bool m_FIN; + bool m_RSV1; + bool m_RSV2; + bool m_RSV3; + wsFrameType m_opcode; + bool m_MASK; + unsigned long long m_lenPayload; + unsigned long long m_len; + unsigned int m_payloadOffset; + std::string m_payload; + std::string m_maskingKey; + unsigned char* m_encodedFrame; + const LogSink& m_logInstance; + int m_flags; + + }; // ~FrameWebSocket + + enum WebSocketState + { + wsStateDisconnected, + wsStateDisconnecting, + wsStateConnecting, + wsStateClientOpeningHandshake, + wsStateServerOpeningHandshake, + wsStateClientOpeningXmpp, + wsStateClientClosingXmpp, + wsStateServerOpeningXmpp, + wsStateClientOpeningXmppFragmented, + wsStateConnected, + wsStateConnectedFragmented + + }; + + enum WebSocketStatusCode + { + wsStatusNormal = 1000, + wsStatusAway, + wsStatusProtocolError, + wsStatusUnsupportedData, + wsStatusNotReceived = 1005, + wsStatusAbnormalClosure, + wsStatusInvalidData, + wsStatusPolicyViolation, + wsStatusMessageTooBig, + wsStatusMandatoryExtension, + wsStatusInternalServerError, + wsStatusTLSHandshakeError = 1015 + }; + + //ConnectionWebSocket& operator=( const ConnectionWebSocket& ); + int getRandom( unsigned char* buf, int len ); + void initInstance( ConnectionBase* connection ); + const std::string getHTTPField( const std::string& field ); + + bool sendFrame( FrameWebSocket& frame ); + + bool sendOpeningHandshake(); + + bool sendCloseWebSocketFrame( const WebSocketStatusCode status, std::string reason = EmptyString ); + bool sendPongWebSocketFrame( std::string body = EmptyString ); + + bool sendOpenXmppStream(); + bool sendCloseXmppStream( ConnectionError err=ConnUserDisconnected ); + bool sendStartXmppStream(); + bool parse( const std::string &data ); + + bool checkStreamVersion( const std::string& version ); + + ConnectionBase *m_connection; + const LogSink& m_logInstance; + + WebSocketState m_wsstate; + + PingHandler* m_pinghandler; + + std::string m_path; // The path part of the URL that we need to request + std::string m_buffer; // Buffer of received data + std::string m_fragmentBuffer; // Buffer of fragmented received data + std::string m_bufferHeader; // HTTP header of data currently in buffer // FIXME doens't need to be member + std::string::size_type m_bufferContentLength; // Length of the data in the current response + std::string m_sendBuffer; // Data waiting to be sent + std::string m_clientOpeningHandshake; + + Parser m_parser; // Used for parsing XML section of responses + bool m_streamInitiationValidated; + bool m_streamClosureValidated; + bool m_bMasked; + int m_flags; + +#if defined( _WIN32 ) || defined ( _WIN32_WCE ) + HCRYPTPROV m_hCryptProv; +#else + int m_fd_random; +#endif + + }; + +} + +#endif // CONNECTIONWEBSOCKET_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/connectionwebsocket.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/dataformfieldcontainer.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataformfieldcontainer.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataformfieldcontainer.h (revision 27490) @@ -1,125 +1,129 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + #ifndef DATAFORMFIELDCONTAINER_H__ #define DATAFORMFIELDCONTAINER_H__ #include "dataformfield.h" #include #include namespace gloox { class DataFormField; /** * @brief An abstract base class for a @xep{0004} Data Form. * * You shouldn't need to use this class directly. Use DataForm instead. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API DataFormFieldContainer { public: /** * Creates a new FieldContainer. */ DataFormFieldContainer(); /** * Creates a new FieldContainer, copying all fields from the given FieldContainer. * @param dffc The FieldContainer to copy. */ DataFormFieldContainer( const DataFormFieldContainer& dffc ); /** * Virtual destructor. */ virtual ~DataFormFieldContainer(); /** * A list of @xep{0004} Data Form Fields. */ typedef std::list FieldList; /** * Use this function to check whether this form contains a field with the given name. * @param field The name of the field (the content of the 'var' attribute). * @return Whether or not the form contains the named field. */ bool hasField( const std::string& field ) const { return DataFormFieldContainer::field( field ) != 0; } /** * Use this function to fetch a pointer to a field of the form. If no such field exists, * 0 is returned. * @param field The name of the field (the content of the 'var' attribute). * @return A copy of the field with the given name if it exists, 0 otherwise. */ DataFormField* field( const std::string& field ) const; /** * Use this function to retrieve the list of fields of a form. * @return The list of fields the form contains. */ FieldList& fields() { return m_fields; } /** * Use this function to retrieve the const list of fields of a form. * @return The const list of fields the form contains. */ const FieldList& fields() const { return m_fields; } /** * Use this function to set the fields the form contains. * @param fields The list of fields. * @note Any previously set fields will be deleted. Always set all fields, not a delta. */ virtual void setFields( FieldList& fields ) { m_fields = fields; } /** * Use this function to add a single field to the list of existing fields. * @param field The field to add. * @since 0.9 */ virtual void addField( DataFormField* field ) { m_fields.push_back( field ); } /** * Adds a single new Field and returns a pointer to that field. * @param type The field's type. * @param name The field's name (the value of the 'var' attribute). * @param value The field's value. * @param label The field's label. * @since 0.9.4 */ DataFormField* addField( DataFormField::FieldType type, const std::string& name, const std::string& value = EmptyString, const std::string& label = EmptyString ) { DataFormField* field = new DataFormField( name, value, label, type ); m_fields.push_back( field ); return field; } protected: FieldList m_fields; }; } #endif // DATAFORMFIELDCONTAINER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/connectiontls.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectiontls.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectiontls.h (revision 27490) @@ -1,200 +1,211 @@ /* * Copyright (c) 2007-2019 by Jakob Schröter * 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 CONNECTIONTLS_H__ #define CONNECTIONTLS_H__ #include "gloox.h" #include "logsink.h" #include "connectionbase.h" #include "tlsdefault.h" #include "connectiondatahandler.h" #include namespace gloox { /** * @brief This is an implementation of a TLS/SSL connection. * * You should not need to use this function directly. However, * you can use it to connect to the legacy Jabber SSL port, * 5223. * * Usage: * @code * Client *c = new Client( ... ); * c->setConnectionImpl( new ConnectionTLS( c, * new ConnectionTCPClient( c->logInstance(), server, 5223 ), * c->logInstance()) ); * @endcode * * Due to the need for handshaking data to be sent/received before the connection is fully * established, be sure not to use the connection until ConnectionDataHandler::handleConnect() * of the specified ConnectionDataHandler is called. * * @author Jakob Schröter * @author Matthew Wild * @since 1.0 */ class GLOOX_API ConnectionTLS : public TLSHandler, public ConnectionBase, public ConnectionDataHandler { public: /** * Constructs a new ConnectionTLS object. * @param cdh The ConnectionDataHandler that will be notified of events from this connection * @param conn A transport connection. It should be configured to connect to * the server and port you wish to make the encrypted connection to. * ConnectionTLS will own the transport connection and delete it in its destructor. * @param log The log target. Obtain it from ClientBase::logInstance(). */ ConnectionTLS( ConnectionDataHandler* cdh, ConnectionBase* conn, const LogSink& log ); /** * Constructs a new ConnectionTLS object. * @param conn A transport connection. It should be configured to connect to * the server and port you wish to make the encrypted connection to. * ConnectionTLS will own the transport connection and delete it in its destructor. * @param log The log target. Obtain it from ClientBase::logInstance(). */ ConnectionTLS( ConnectionBase* conn, const LogSink& log ); /** * Virtual Destructor. */ virtual ~ConnectionTLS(); /** * Use this function to set a number of trusted root CA certificates which shall be * used to verify a servers certificate. * @param cacerts A list of absolute paths to CA root certificate files in PEM format. * @note This function is a wrapper for TLSBase::setCACerts(). */ void setCACerts( const StringList& cacerts ) { m_cacerts = cacerts; } /** * This function is used to retrieve certificate and connection info of a encrypted connection. * @return Certificate information. * @note This funcztion is a wrapper around TLSBase::fetchTLSInfo(). */ const CertInfo& fetchTLSInfo() const { return m_certInfo; } /** * Use this function to set the user's certificate and private key. The certificate will * be presented to the server upon request and can be used for SASL EXTERNAL authentication. * The user's certificate file should be a bundle of more than one certificate in PEM format. * The first one in the file should be the user's certificate, each cert following that one * should have signed the previous one. * @note These certificates are not necessarily the same as those used to verify the server's * certificate. * @param clientKey The absolute path to the user's private key in PEM format. * @param clientCerts A path to a certificate bundle in PEM format. * @note This function is a wrapper around TLSBase::setClientCert(). */ void setClientCert( const std::string& clientKey, const std::string& clientCerts ) { m_clientKey = clientKey; m_clientCerts = clientCerts; } /** * Sets the transport connection. * @param connection The transport connection to use. A potentially previously set connection * will be deleted. */ void setConnectionImpl( ConnectionBase* connection ); /** * Registers an TLSHandler derived object. Only the handleHandshakeResult() * function will be used after a handshake took place. * You can review certificate info there. * @param th The TLSHandler to register. * @note If no handler is set, ConnectionTLS will accept * any certificate and continue with the connection. */ void registerTLSHandler( TLSHandler* th ) { m_tlsHandler = th; } + /** + * This function is used to set the minimum required/requested TLS version. Default is to use + * at least TLS v1. + * @param tlsVersion The TLS version. + */ + void setTLSVersion( TLSVersion tlsVersion) { m_tlsVersion = tlsVersion; } + // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionBase virtual bool send( const std::string& data ); // reimplemented from ConnectionBase + virtual bool send( const char* data, const size_t len ); + + // reimplemented from ConnectionBase virtual ConnectionError receive(); // reimplemented from ConnectionBase virtual void disconnect(); // reimplemented from ConnectionBase virtual void cleanup(); // reimplemented from ConnectionBase virtual void getStatistics( long int& totalIn, long int& totalOut ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); // reimplemented from ConnectionDataHandler virtual ConnectionBase* newInstance() const; // reimplemented from TLSHandler virtual void handleEncryptedData( const TLSBase*, const std::string& data ); // reimplemented from TLSHandler virtual void handleDecryptedData( const TLSBase*, const std::string& data ); // reimplemented from TLSHandler virtual void handleHandshakeResult( const TLSBase* base, bool success, CertInfo& certinfo ); protected: /** * Returns a TLS object (client). Reimplement to change the * type of the object. * @return A TLS object. */ virtual TLSBase* getTLSBase( TLSHandler* th, const std::string server ) { return new TLSDefault( th, server, TLSDefault::VerifyingClient ); } ConnectionBase* m_connection; TLSBase* m_tls; TLSHandler* m_tlsHandler; CertInfo m_certInfo; const LogSink& m_log; StringList m_cacerts; std::string m_clientCerts; std::string m_clientKey; + TLSVersion m_tlsVersion; private: ConnectionTLS& operator=( const ConnectionTLS& ); }; } #endif // CONNECTIONTLS_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/dataform.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataform.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataform.h (revision 27490) @@ -1,197 +1,201 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + #ifndef DATAFORM_H__ #define DATAFORM_H__ #include "dataformfieldcontainer.h" #include "adhocplugin.h" #include #include namespace gloox { class Tag; class DataFormItem; class DataFormReported; /** * Describes the possible Form Types. */ enum FormType { TypeForm, /**< The forms-processing entity is asking the forms-submitting * entity to complete a form. */ TypeSubmit, /**< The forms-submitting entity is submitting data to the * forms-processing entity. */ TypeCancel, /**< The forms-submitting entity has cancelled submission of data * to the forms-processing entity. */ TypeResult, /**< The forms-processing entity is returning data (e.g., search * results) to the forms-submitting entity, or the data is a * generic data set. */ TypeInvalid /**< The form is invalid. Only possible if the form was created * from an Tag which doesn't correctly describe a Data Form. */ }; /** * @brief An abstraction of a @xep{0004} Data Form. * - * + * XEP Version: 2.9 * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API DataForm : public AdhocPlugin, public DataFormFieldContainer { public: /** * A list of DataFormItems. */ typedef std::list ItemList; /** * Constructs a new, empty form. * @param type The form type. * @param instructions Natural-language instructions for filling out the form. Should not contain * newlines (\\n, \\r). * @param title The natural-language title of the form. Should not contain newlines (\\n, \\r). */ DataForm( FormType type, const StringList& instructions, const std::string& title = EmptyString ); /** * Constructs a new, empty form without any instructions or title set. Probably best suited for * result forms. * @param type The form type. * @param title The natural-language title of the form. Should not contain newlines (\\n, \\r). * @since 0.9 */ DataForm( FormType type, const std::string& title = EmptyString ); /** * Constructs a new DataForm from an existing Tag/XML representation. * @param tag The existing form to parse. */ DataForm( const Tag* tag ); /** * Creates a new DataForm, copying the given one. * @param form The form to copy. */ DataForm( const DataForm& form ); /** * Virtual destructor. */ virtual ~DataForm(); /** * Use this function to retrieve the title of the form. * @return The title of the form. */ const std::string& title() const { return m_title; } /** * Use this function to set the title of the form. * @param title The new title of the form. * @note The title should not contain newlines (\\n, \\r). */ void setTitle( const std::string& title ) { m_title = title; } /** * Retrieves the natural-language instructions for the form. * @return The fill-in instructions for the form. */ const StringList& instructions() const { return m_instructions; } /** * Use this function to set natural-language instructions for the form. * @param instructions The instructions for the form. * @note The instructions should not contain newlines (\\n, \\r). Instead, every line should be an * element of the StringMap. This allows for platform dependent newline handling on the target * platform. */ void setInstructions( const StringList& instructions ) { m_instructions = instructions; } /** * Returns the reported field list in a DataForm. * @return The reported section, containing 0..n fields. */ const DataFormReported* reported() const { return m_reported; } /** * Returns a list of items in a DataForm. * @return A list of items. */ const ItemList& items() const { return m_items; } /** * Returns the form's type. * @return The form's type. * @since 0.9 */ FormType type() const { return m_type; } /** * Sets the form's type. * @param type The form's new type. */ void setType( FormType type ) { m_type = type; } /** * Parses the given Tag and creates an appropriate DataForm representation. * @param tag The Tag to parse. * @return @b True on success, @b false otherwise. * @since 0.9 */ bool parse( const Tag* tag ); /** * Converts to @b true if the DataForm is valid, @b false otherwise. */ operator bool() const { return m_type != TypeInvalid; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new DataForm( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new DataForm( *this ); } protected: FormType m_type; private: StringList m_instructions; std::string m_title; DataFormReported* m_reported; ItemList m_items; }; } #endif // DATAFORM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/dataformitem.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataformitem.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataformitem.h (revision 27490) @@ -1,62 +1,66 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + #ifndef DATAFORMITEM_H__ #define DATAFORMITEM_H__ #include "dataformfieldcontainer.h" namespace gloox { /** * @brief An abstraction of an <item> element in a @xep{0004} Data Form of type result. * * There are some constraints regarding usage of this element you should be aware of. Check @xep{0004} * section 3.4. This class does not enforce correct usage at this point. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API DataFormItem : public DataFormFieldContainer { public: /** * Creates an empty 'item' element you can add fields to. */ DataFormItem(); /** * Creates a 'item' element and fills it with the 'field' elements contained in the given Tag. * The Tag's root element must be a 'item' element. Its child element should be 'field' elements. * @param tag The tag to read the 'field' elements from. * @since 0.8.5 */ DataFormItem( const Tag* tag ); /** * Virtual destructor. */ virtual ~DataFormItem(); /** * Creates and returns a Tag representation of the current object. * @return A Tag representation of the current object. */ virtual Tag* tag() const; }; } #endif // DATAFORMITEM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/delayeddelivery.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/delayeddelivery.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/delayeddelivery.h (revision 27490) @@ -1,130 +1,134 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DELAYEDDELIVERY ) + #ifndef DELAYEDDELIVERY_H__ #define DELAYEDDELIVERY_H__ #include "gloox.h" #include "jid.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0203} (Delayed Delivery). * * The class also implements the deprecated @xep{0091} (Delayed Delivery) in a read-only fashion. * It understands both XEP formats for input, but any output will conform to @xep{0203}. * * XEP Version: 0.1 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API DelayedDelivery : public StanzaExtension { public: /** * Constructs a new object and fills it according to the parameters. * @param from The JID of the original sender or the entity that delayed the sending. * @param stamp The datetime stamp of the original send. * @param reason An optional natural language reason for the delay. */ DelayedDelivery( const JID& from, const std::string stamp, const std::string& reason = "" ); /** * Constructs a new object from the given Tag. * @param tag The Tag to parse. */ DelayedDelivery( const Tag* tag = 0 ); /** * Virtual Destructor. */ virtual ~DelayedDelivery(); /** * Returns the datetime when the stanza was originally sent. * The format MUST adhere to the dateTime format specified in @xep{0082} and MUST * be expressed in UTC. * @return The original datetime. */ const std::string& stamp() const { return m_stamp; } /** * Sets the original datetime. * @param stamp The original datetime. */ void setStamp( const std::string& stamp ) { m_stamp = stamp; } /** * Returns the JID of the original sender of the stanza or the entity that * delayed the sending. * The format MUST adhere to the dateTime format specified in @xep{0082} and MUST * be expressed in UTC. * @return The JID. */ const JID& from() const { return m_from; } /** * Sets the JID of the origianl sender or the entity that delayed the sending. * @param from The JID. */ void setFrom( const JID& from ) { m_from = from; } /** * Returns a natural language reason for the delay. * @return A natural language reason for the delay. */ const std::string& reason() const { return m_reason; } /** * Sets the reason for the delay. * @param reason The reason for the delay. */ void setReason( const std::string& reason ) { m_reason = reason; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new DelayedDelivery( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new DelayedDelivery( *this ); } private: JID m_from; std::string m_stamp; std::string m_reason; }; } #endif // DELAYEDDELIVERY_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/dataformreported.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataformreported.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataformreported.h (revision 27490) @@ -1,64 +1,68 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + #ifndef DATAFORMREPORTED_H__ #define DATAFORMREPORTED_H__ #include "dataformfieldcontainer.h" namespace gloox { class Tag; /** * @brief An abstraction of a <reported> element in a @xep{0004} Data Form of type result. * * There are some constraints regarding usage of this element you should be aware of. Check @xep{0004} * section 3.4. This class does not enforce correct usage at this point. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API DataFormReported : public DataFormFieldContainer { public: /** * Creates an empty 'reported' element you can add fields to. */ DataFormReported(); /** * Creates a 'reported' element and fills it with the 'field' elements contained in the given Tag. * The Tag's root element must be a 'reported' element. Its child element should be 'field' elements. * @param tag The tag to read the 'field' elements from. * @since 0.8.5 */ DataFormReported( Tag* tag ); /** * Virtual destructor. */ virtual ~DataFormReported(); /** * Creates and returns a Tag representation of the current object. * @return A Tag representation of the current object. */ virtual Tag* tag() const; }; } #endif // DATAFORMREPORTED_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/disconodehandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/disconodehandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/disconodehandler.h (revision 27490) @@ -1,81 +1,84 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) #ifndef DISCONODEHANDLER_H__ #define DISCONODEHANDLER_H__ #include "gloox.h" #include "disco.h" #include #include #include namespace gloox { /** * @brief Derived classes can be registered as NodeHandlers for certain nodes with the Disco object. * * Incoming disco#info and disco#items queries are delegated to their respective handlers. * * @author Jakob Schröter */ class GLOOX_API DiscoNodeHandler { public: /** * Virtual Destructor. */ virtual ~DiscoNodeHandler() {} /** * In addition to @c handleDiscoNodeIdentities, this function is used to gather * more information on a specific node. It is called when a disco#info query * arrives with a node attribute that matches the one registered for this handler. * @param from The sender of the request. * @param node The node this handler is supposed to handle. * @return A list of features supported by this node. */ virtual StringList handleDiscoNodeFeatures( const JID& from, const std::string& node ) = 0; /** * In addition to @c handleDiscoNodeFeatures, this function is used to gather * more information on a specific node. It is called when a disco#info query * arrives with a node attribute that matches the one registered for this handler. * @param from The sender of the request. * @param node The node this handler is supposed to handle. * @return A list of identities for the given node. The caller will own the identities. */ virtual Disco::IdentityList handleDiscoNodeIdentities( const JID& from, const std::string& node ) = 0; /** * This function is used to gather more information on a specific node. * It is called when a disco#items query arrives with a node attribute that * matches the one registered for this handler. If node is empty, items for the * root node (no node) shall be returned. * @param from The sender of the request. * @param to The receiving JID (useful for transports). * @param node The node this handler is supposed to handle. * @return A list of items supported by this node. */ virtual Disco::ItemList handleDiscoNodeItems( const JID& from, const JID& to, const std::string& node = EmptyString ) = 0; }; } #endif // DISCONODEHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/binaries/system/gloox-1.0.dll =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ps/trunk/libraries/win32/gloox/include/gloox/disco.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/disco.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/disco.h (revision 27490) @@ -1,636 +1,650 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) #ifndef DISCO_H__ #define DISCO_H__ #include "gloox.h" #include "iqhandler.h" #include "jid.h" #include #include #include namespace gloox { class ClientBase; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) class DataForm; +#endif // GLOOX_MINIMAL class DiscoHandler; class DiscoNodeHandler; class IQ; /** * @brief This class implements @xep{0030} (Service Discovery) and @xep{0092} (Software Version). * * ClientBase will automatically instantiate a Disco object. It can be used to * announce special features of your client, or its version, or... * * XEP version: 2.2 * @author Jakob Schröter */ class GLOOX_API Disco : public IqHandler { friend class ClientBase; public: class Identity; // declared below class Info /** * A list of pointers to Identity objects. Used with Disco::Info. */ typedef std::list IdentityList; /** * @brief An abstraction of a Disco Info element (from Service Discovery, @xep{0030}) * as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Info : public StanzaExtension { friend class Disco; public: /** * Returns the queried node identifier, if any. * @return The node identifier. May be empty. */ const std::string& node() const { return m_node; } /** * Returns the entity's supported features. * @return A list of supported features/namespaces. */ const StringList& features() const { return m_features; } /** * Use this function to check if the entity the Info came from supports agiven feature. * @param feature The feature to check for. * @return @b True if the entity announces support for the feature, @b false otherwise. */ bool hasFeature( const std::string& feature ) const; /** * Returns the entity's identities. * @return A list of pointers to Identity objects. */ const IdentityList& identities() const { return m_identities; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) /** * Returns an optionally included data form. This is used by e.g. MUC (@xep{0045}). * @return An optional data form included in the disco#info. May be 0. */ const DataForm* form() const { return m_form; } /** * Adds an optional DataForm, e.g. for @xep{0232}. Only one form can be added * at this point. * @param form An optional DataForm to include in the Info reply. * The form will be owned by and deleted on destruction of the Info object. * @note If called more than once the previously set form will be deleted. */ void setForm( DataForm* form ); +#endif // GLOOX_MINIMAL // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Info( tag ); } // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Info( *this ); } // reimplemented from StanzaExtension virtual Tag* tag() const; private: #ifdef DISCO_INFO_TEST public: #endif /** * Creates a empty Info object, suitable for making disco#info requests. * @param node The node identifier to query (optional). * @param defaultFeatures Indicates whether or not the default features should be * included in the Info. Should be @b false for requests, @b true for replies. * Defaults to @b false. */ Info( const std::string& node = EmptyString, bool defaultFeatures = false ); /** * Creates an Info object from the given Tag. * @param tag A <query> tag in the disco#info namespace, (possibly) containing * a disco#info reply. */ Info( const Tag* tag ); /** * Copy constructor. * @param info An Info object to copy. */ Info( const Info& info ); /** * Virtual destructor. */ virtual ~Info(); /** * Sets the current info node. * @param node The info node. */ void setNode( const std::string& node ) { m_node = node; } /** * This function can be used to set the entity's features. * @param features A list of supported features/namespaces. */ void setFeatures( const StringList& features ) { StringList fl( features ); fl.sort(); // needed on win32 m_features.merge( fl ); } /** * This function can be used to set the entity's identities. * @param identities A list of pointers to the entity's identities. * @note The Identity objects pointed to will be owned by the Info object. The * list should neither be used again nor should the Identity objects be deleted. */ void setIdentities( const IdentityList& identities ) { m_identities = identities; } std::string m_node; StringList m_features; IdentityList m_identities; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) DataForm* m_form; +#endif // GLOOX_MINIMAL + }; /** * @brief An abstraction of a Disco identity (Service Discovery, @xep{0030}). * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Identity { friend class Info; friend class Disco; public: /** * Constructs a Disco Identity from a category, type and name. * See http://www.xmpp.org/registrar/disco-categories.html for more info. * @param category The identity's category. * @param type The identity's type. * @param name The identity's name. */ Identity( const std::string& category, const std::string& type, const std::string& name ); /** * Copy Contructor. * @param id An Identity to create a new Identity object from. */ Identity( const Identity& id ); /** * Destructor. */ ~Identity(); /** * Returns the identity's category. * @return The identity's category. */ const std::string& category() const { return m_category; } /** * Returns the identity's type. * @return The identity's type. */ const std::string& type() const { return m_type; } /** * Returns the identity's name. * @return The identity's name. */ const std::string& name() const { return m_name; } /** * Creates and returns a Tag representation of this identity. * @return A Tag, or 0. */ Tag* tag() const; private: /** * Creates a Disco Identity from the given Tag. * @param tag A Tag representation of a disco identity. */ Identity( const Tag* tag ); std::string m_category; /**< The identity's category. */ std::string m_type; /**< The identity's type. */ std::string m_name; /**< The identity's name. */ }; class Item; // declared below class Items /** * A list of pointers to Item objects. Used with Disco::Items. */ typedef std::list ItemList; /** * @brief An abstraction of a Disco query element (from Service Discovery, @xep{0030}) * in the disco#items namespace, implemented as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Items : public StanzaExtension { friend class Disco; public: // This needs to be public so one can proactively send a list of adhoc commands // see @xep{0050} /** * Creates an empty Items object, suitable for making disco#items requests. * @param node The node identifier to query (optional). */ Items( const std::string& node = EmptyString ); /** * Virtual destructor. */ virtual ~Items(); /** * This function can be used to set the entity's/node's items. * @param items A list of pointers to the entity's/node's items. * @note The Item objects pointed to will be owned by the Items object. The * list should neither be used again nor should the Item objects be deleted. */ void setItems( const ItemList& items ); /** * Returns the queried node identifier, if any. * @return The node identifier. May be empty. */ const std::string& node() const { return m_node; } /** * Returns the entity's/node's items. * @return A list of pointers to Item objects. */ const ItemList& items() const { return m_items; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Items( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Items( *this ); } private: #ifdef DISCO_ITEMS_TEST public: #endif /** * Creates an Items object from the given Tag. * @param tag A <query> tag in the disco#items namespace, (possibly) containing * a disco#items reply. */ Items( const Tag* tag ); std::string m_node; ItemList m_items; }; /** * @brief An abstraction of a Disco item (Service Discovery, @xep{0030}). * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Item { friend class Items; public: /** * Constructs a Disco Item from a JID, node and name. * @param jid The item's JID. * @param node The item's type. * @param name The item's name. */ Item( const JID& jid, const std::string& node, const std::string& name ) : m_jid( jid ), m_node( node ), m_name( name ) {} /** * Destructor. */ ~Item() {} /** * Returns the item's JID. * @return The item's JID. */ const JID& jid() const { return m_jid; } /** * Returns the item's node. * @return The item's node. */ const std::string& node() const { return m_node; } /** * Returns the item's name. * @return The item's name. */ const std::string& name() const { return m_name; } /** * Creates and returns a Tag representation of this item. * @return A Tag, or 0. */ Tag* tag() const; private: /** * Creates a Disco Item from the given Tag. * @param tag A Tag representation of a Disco item. */ Item( const Tag* tag ); JID m_jid; /**< The item's jid. */ std::string m_node; /**< The item's type. */ std::string m_name; /**< The item's name. */ }; /** * Adds a feature to the list of supported Jabber features. * The list will be posted as an answer to IQ queries in the * "http://jabber.org/protocol/disco#info" namespace. * These IQ packets will also be forwarded to the * application's IqHandler, if it listens to the @c disco\#info namespace. * By default, disco(very) queries are handled by the library. * By default, all supported, not disabled features are announced. * @param feature A feature (namespace) the host app supports. * @note Use this function for non-queryable features. For nodes that shall * answer to @c disco\#info queries, use registerNodeHandler(). */ void addFeature( const std::string& feature ) { m_features.push_back( feature ); } /** * Removes the given feature from the list of advertised client features. * @param feature The feature to remove. * @since 0.9 */ void removeFeature( const std::string& feature ) { m_features.remove( feature ); } /** * Lets you retrieve the features this Disco instance supports. * @param defaultFeatures Include default features. Defaults to @b false. * @return A list of supported features/namespaces. */ const StringList features( bool defaultFeatures = false ) const; /** * Queries the given JID for general infomation according to * @xep{0030} (Service Discovery). * To receive the results inherit from DiscoHandler and register with the Disco object. * @param to The destination-JID of the query. * @param node An optional node to query. Not inserted if empty. * @param dh The DiscoHandler to notify about results. * @param context A context identifier. * @param tid An optional id that is going to be used as the IQ request's id. Only * necessary if you need to know the request's id. */ void getDiscoInfo( const JID& to, const std::string& node, DiscoHandler* dh, int context, const std::string& tid = EmptyString ) { getDisco( to, node, dh, context, GetDiscoInfo, tid ); } /** * Queries the given JID for its items according to * @xep{0030} (Service Discovery). * To receive the results inherit from DiscoHandler and register with the Disco object. * @param to The destination-JID of the query. * @param node An optional node to query. Not inserted if empty. * @param dh The DiscoHandler to notify about results. * @param context A context identifier. * @param tid An optional id that is going to be used as the IQ request's id. Only * necessary if you need to know the request's id. */ void getDiscoItems( const JID& to, const std::string& node, DiscoHandler* dh, int context, const std::string& tid = EmptyString ) { getDisco( to, node, dh, context, GetDiscoItems, tid ); } /** * Sets the version of the host application using this library. * The library takes care of jabber:iq:version requests. These * IQ packets will not be forwarded to the IqHandlers. * @param name The name to be returned to inquiring clients. * @param version The version to be returned to inquiring clients. * @param os The operating system to announce. Default: don't include. */ void setVersion( const std::string& name, const std::string& version, const std::string& os = EmptyString ); /** * Returns the application's advertised name. * @return The application's advertised name. */ const std::string& name() const { return m_versionName; } /** * Returns the application's advertised version. * @return The application's advertised version. */ const std::string& version() const { return m_versionVersion; } /** * Returns the application's advertised operating system. * @return The application's advertised operating system. */ const std::string& os() const { return m_versionOs; } /** * Sets the identity of this entity. * The library uses this information to answer disco#info requests * with a correct identity. * @xep{0030} requires an entity to have at least one identity. See @xep{0030} * for more information on categories and types. * @param category The entity category of this client. Default: client. May not be empty. * @param type The type of this entity. Default: bot. May not be empty. * @param name The name of the entity. Default: empty. * @note An entity can have more than one identity. You cann add more identities * using addIdentity(). A call to setIdentity() will clear the list of identities * and, after that, add the new identity given by the arguments to setIdentity(). */ void setIdentity( const std::string& category, const std::string& type, const std::string& name = EmptyString ); /** * Adds another identity to the list of identities. * @param category The entity category of this client. Default: client. May not be empty. * @param type The type of this entity. Default: bot. May not be empty. * @param name The name of the entity. Default: empty. */ void addIdentity( const std::string& category, const std::string& type, const std::string& name = EmptyString ) { m_identities.push_back( new Identity( category, type, name ) ); } /** * Returns the entity's identities. * @return The entity's identities. */ const IdentityList& identities() const { return m_identities; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) /** * Adds an optional DataForm to Disco:Info replies, e.g. for @xep{0232}. * Only one form can be added at this point. * @param form An optional DataForm to include in the Info reply. * The form will be owned by and deleted on destruction of the Disco object. * @note If called more than once the previously set form will be deleted. */ void setForm( DataForm* form ); /** * Returns the DataForm set by setForm(). Used by Capabilities. * @return The DataForm, or 0. */ const DataForm* form() const { return m_form; } +#endif // GLOOX_MINIMAL /** * Use this function to register an @ref DiscoHandler with the Disco * object. This is only necessary if you want to receive Disco-set requests. Else * a one-time registration happens when calling getDiscoInfo() and getDiscoItems(), respectively. * @param dh The DiscoHandler-derived object to register. */ void registerDiscoHandler( DiscoHandler* dh ) { m_discoHandlers.push_back( dh ); } /** * Unregisters the given DiscoHandler. * @param dh The DiscoHandler to unregister. */ void removeDiscoHandler( DiscoHandler* dh ); /** * Use this function to register a @ref DiscoNodeHandler with the Disco * object. The DiscoNodeHandler will receive disco#items queries which are * directed to the corresponding node registered for the handler. * @param nh The NodeHandler-derived object to register. * @param node The node name to associate with this handler. Use an empty string to * register for the root node. */ void registerNodeHandler( DiscoNodeHandler* nh, const std::string& node ); /** * Removes the node handler for the given node. * @param nh The NodeHandler to unregister. * @param node The node for which the handler shall be removed. Use an empty string to * remove the root node's handler. */ void removeNodeHandler( DiscoNodeHandler* nh, const std::string& node ); /** * Removes all registered nodes of the given node handler. * @param nh The NodeHandler to unregister. */ void removeNodeHandlers( DiscoNodeHandler* nh ); // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); private: #ifdef DISCO_TEST public: #endif Disco( ClientBase* parent ); virtual ~Disco(); enum IdType { GetDiscoInfo, GetDiscoItems }; void getDisco( const JID& to, const std::string& node, DiscoHandler* dh, int context, IdType idType, const std::string& tid ); struct DiscoHandlerContext { DiscoHandler* dh; int context; }; ClientBase* m_parent; typedef std::list DiscoHandlerList; typedef std::list DiscoNodeHandlerList; typedef std::map DiscoNodeHandlerMap; typedef std::map DiscoHandlerMap; DiscoHandlerList m_discoHandlers; DiscoNodeHandlerMap m_nodeHandlers; DiscoHandlerMap m_track; IdentityList m_identities; StringList m_features; StringMap m_queryIDs; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) DataForm* m_form; +#endif // GLOOX_MINIMAL std::string m_versionName; std::string m_versionVersion; std::string m_versionOs; }; } #endif // DISCO_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/dns.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dns.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dns.h (revision 27490) @@ -1,179 +1,181 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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 DNS_H__ #define DNS_H__ #include "macros.h" #include "logsink.h" #ifdef __MINGW32__ # include # include #endif #ifdef HAVE_ARPA_NAMESER_H # include #endif #ifdef __APPLE__ # include #endif #ifndef NS_MAXDNAME # define NS_MAXDNAME 1025 #endif #ifndef NS_PACKETSZ # define NS_PACKETSZ 512 #endif #ifdef HAVE_GETADDRINFO # include # include # include #endif #include #include namespace gloox { /** * @brief This class holds a number of static functions used for DNS related stuff. * * You should not need to use these functions directly. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API DNS { public: /** * A list of strings (used for server addresses) and ints (used for port numbers). */ typedef std::map HostMap; /** * This function resolves a service/protocol/domain tuple. * @param service The SRV service type. * @param proto The SRV protocol. * @param domain The domain to search for SRV records. * @param logInstance A LogSink to use for logging. * @return A list of weighted hostname/port pairs from SRV records, or A records if no SRV * records where found. */ static HostMap resolve( const std::string& service, const std::string& proto, const std::string& domain, const LogSink& logInstance ); /** * This is a convenience funtion which uses @ref resolve() to resolve SRV records * for a given domain, using a service of @b xmpp-client and a proto of @b tcp. * @param domain The domain to resolve SRV records for. * @param logInstance A LogSink to use for logging. * @return A list of weighted hostname/port pairs from SRV records, or A records if no SRV * records where found. */ static HostMap resolve( const std::string& domain, const LogSink& logInstance ) { return resolve( "xmpp-client", "tcp", domain, logInstance ); } /** * This is a convenience function which uses @ref resolve() to get a list of hosts * and connects to one of them. * @param host The host to resolve SRV records for. * @param logInstance A LogSink to use for logging. + * @param timeout The timeout to use for select() in milliseconds. Default of -1 means blocking. * @return A file descriptor for the established connection. */ - static int connect( const std::string& host, const LogSink& logInstance ); + static int connect( const std::string& host, const LogSink& logInstance, const int timeout = -1 ); /** * This is a convenience function which connects to the given host and port. No SRV * records are resolved. Use this function for special setups. * @param host The host/IP address to connect to. * @param port A custom port to connect to. * @param logInstance A LogSink to use for logging. + * @param timeout The timeout to use for select() in milliseconds. Default of -1 means blocking. * @return A file descriptor for the established connection. */ - static int connect( const std::string& host, int port, const LogSink& logInstance ); + static int connect( const std::string& host, int port, const LogSink& logInstance, const int timeout = -1 ); /** * A convenience function that prepares and returnes a simple, unconnected TCP socket. * @param logInstance A LogSink to use for logging. * @return A TCP socket. */ static int getSocket( const LogSink& logInstance ); /** * Closes the given socket. * @param fd The socket to close. * @param logInstance A LogSink to use for logging. */ static void closeSocket( int fd, const LogSink& logInstance ); private: #ifdef HAVE_GETADDRINFO /** * Resolves the given service for the given domain and protocol, using the IPv6-ready * getaddrinfo(). The result is put into the first parameter. * @param res A pointer to a pointer holding the query results. * @param service A service string to query for, e.g. xmpp-client. * @param proto A protocol name. * @param domain The domain to query for. * @param logInstance A LogSink to use for logging. */ static void resolve( struct addrinfo** res, const std::string& service, const std::string& proto, const std::string& domain, const LogSink& logInstance ); /** * This is a convenience funtion which uses @ref resolve() to resolve SRV records * for a given domain, using a service of @b xmpp-client and a proto of @b tcp. * @param res A pointer to a pointer holding the query results. * @param domain The domain to resolve SRV records for. * @param logInstance A LogSink to use for logging. */ static void resolve( struct addrinfo** res, const std::string& domain, const LogSink& logInstance ) { resolve( res, "xmpp-client", "tcp", domain, logInstance ); } /** * Tries to connect to the host/address contained in the addrinfo structure. * @param res The connection parameters. * @param logInstance A LogSink to use for logging. * @return A file descriptor for the established connection. */ static int connect( struct addrinfo* res, const LogSink& logInstance ); #endif /** * This function prepares and returns a socket with the given parameters. * @param af The address family. E.g. PF_INET. * @param socktype The socket type. E.g. SOCK_STREAM. * @param proto The protocol number. E.g. 6 (TCP). */ static int getSocket( int af, int socktype, int proto, const LogSink& logInstance ); static HostMap defaultHostMap( const std::string& domain, const LogSink& logInstance ); static void cleanup( const LogSink& logInstance ); struct buffer { unsigned char buf[NS_PACKETSZ]; int len; }; }; } #endif // DNS_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/flexoffhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/flexoffhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/flexoffhandler.h (revision 27490) @@ -1,82 +1,86 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_FLEXOFF ) + #ifndef FLEXOFFHANDLER_H__ #define FLEXOFFHANDLER_H__ #include "disco.h" #include "gloox.h" namespace gloox { /** * Describes the possible results of a message retrieval or deletion request. */ enum FlexibleOfflineResult { FomrRemoveSuccess, /**< Message(s) were removed successfully. */ FomrRequestSuccess, /**< Message(s) were fetched successfully. */ FomrForbidden, /**< The requester is a JID other than an authorized resource of the * user. Something wnet serieously wrong */ FomrItemNotFound, /**< The requested node (message ID) does not exist. */ FomrUnknownError /**< An error occurred which is not specified in @xep{0013}. */ }; /** * @brief Implementation of this virtual interface allows for retrieval of offline messages following * @xep{0030}. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API FlexibleOfflineHandler { public: /** * Virtual Destructor. */ virtual ~FlexibleOfflineHandler() {} /** * This function is called to indicate whether the server supports @xep{0013} or not. * Call @ref FlexibleOffline::checkSupport() to trigger the check. * @param support Whether the server support @xep{0013} or not. */ virtual void handleFlexibleOfflineSupport( bool support ) = 0; /** * This function is called to announce the number of available offline messages. * Call @ref FlexibleOffline::getMsgCount() to trigger the check. * @param num The number of stored offline messages. */ virtual void handleFlexibleOfflineMsgNum( int num ) = 0; /** * This function is called when the offline message headers arrive. * Call @ref FlexibleOffline::fetchHeaders() to trigger the check. * @param headers A map of ID/sender pairs describing the offline messages. */ virtual void handleFlexibleOfflineMessageHeaders( const Disco::ItemList& headers ) = 0; /** * This function is called to indicate the result of a fetch or delete instruction. * @param foResult The result of the operation. */ virtual void handleFlexibleOfflineResult( FlexibleOfflineResult foResult ) = 0; }; } #endif // FLEXOFFHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/flexoff.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/flexoff.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/flexoff.h (revision 27490) @@ -1,178 +1,182 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_FLEXOFF ) + #ifndef FLEXOFF_H__ #define FLEXOFF_H__ #include "clientbase.h" #include "discohandler.h" #include "flexoffhandler.h" #include "iqhandler.h" #include "stanzaextension.h" namespace gloox { /** * @brief An implementation of @xep{0013} (Flexible Offline Message Retrieval). * * Use the FlexibleOfflineHandler to receive results. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API FlexibleOffline : public DiscoHandler, public IqHandler { public: /** * Creates a new FlexibleOffline object that manages retrieval of offline messages. * @param parent The ClientBase to use for communication. */ FlexibleOffline( ClientBase* parent ); /** * Virtual Destructor. */ virtual ~FlexibleOffline(); /** * Initiates querying the server for Flexible Offline Message Retrieval-support. * The result is announced through the FlexibleOfflineHandler. * An application could cache the result on a per-server basis to eliminate the associated delay. */ void checkSupport(); /** * Asks the server for the number of stored offline messages. * The result is announced through the FlexibleOfflineHandler. */ void getMsgCount(); /** * Initiates fetching the offline message headers. * The result is announced through the FlexibleOfflineHandler. */ void fetchHeaders(); /** * Initiates fetching of one or more specific messages, or all messages. * The result is announced through the FlexibleOfflineHandler. * If the list of message nodes contains one or more nodes, the corresponding messages are * fetched. If the list is empty all messages are fetched (<fetch>). * @param msgs A list of message nodes to fetch. */ void fetchMessages( const StringList& msgs ) { messageOperation( FORequestMsgs, msgs ); } /** * Initiates removing of one or more specific messages, or all messages. * The result is announced through the FlexibleOfflineHandler. * If the list of message nodes contains one or more nodes, the corresponding messages are * removed. If the list is empty all messages are removed (<purge>). */ void removeMessages( const StringList& msgs ) { messageOperation( FORemoveMsgs, msgs ); } /** * Registers a FlexibleOfflineHandler as object that receives results of @xep{0013} queries. * Only one Handler at a time is possible. * @param foh The Handler object to register. */ void registerFlexibleOfflineHandler( FlexibleOfflineHandler* foh ); /** * Removes the registered handler. */ void removeFlexibleOfflineHandler(); // reimplemented from DiscoHandler virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context ); // reimplemented from DiscoHandler virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context ); // reimplemented from DiscoHandler virtual void handleDiscoError( const JID& from, const Error* error, int context ); // 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: #ifdef FLEXOFF_TEST public: #endif class Offline : public StanzaExtension { public: /** * Constructs a new Offline object from the given Tag. * @param tag The Tag to parse. */ Offline( const Tag* tag = 0 ); /** * Constructs a new Offline object for the given context and messages. * @param context The context. * @param msgs The messages. */ Offline( int context, const StringList& msgs ); /** * Virtual destructor. */ virtual ~Offline(); // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Offline( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Offline( *this ); } private: int m_context; StringList m_msgs; }; void messageOperation( int context, const StringList& msgs ); enum FOContext { FOCheckSupport, FORequestNum, FORequestHeaders, FORequestMsgs, FORemoveMsgs }; ClientBase* m_parent; FlexibleOfflineHandler* m_flexibleOfflineHandler; }; } #endif // FLEXOFF_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/error.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/error.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/error.h (revision 27490) @@ -1,145 +1,146 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 ERROR_H__ #define ERROR_H__ #include "gloox.h" #include "stanzaextension.h" #include #include namespace gloox { class Tag; /** * @brief A stanza error abstraction implemented as a StanzaExtension. * * @author Vincent Thomasset * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Error : public StanzaExtension { public: // Error() // : StanzaExtension( ExtError ), m_type( StanzaErrorTypeUndefined ), // m_error( StanzaErrorUndefined ), m_appError( 0 ) // {} /** * Creates a new Error object from the given Tag. * @param tag The Tag to parse. */ Error( const Tag* tag = 0 ); /** * Creates a new Error object. * @param type The error type. * @param error The actual stanza error. * @param appError An optional application-specific error. */ Error( StanzaErrorType type, StanzaError error, Tag* appError = 0 ) : StanzaExtension( ExtError ), m_type( type ), m_error( error ), m_appError( appError ) {} /** * Virtual destructor. */ virtual ~Error(); /** * Returns the error type. * @return The error type. */ StanzaErrorType type() const { return m_type; } /** * Return the stanza error. * @return The actual error. */ StanzaError error() const { return m_error; } /** * This function can be used to retrieve the application-specific error * condition of a stanza error. * @return The application-specific error element of a stanza error. * 0 if no respective element was found or no error occured. */ const Tag* appError() const { return m_appError; } /** * Sets the application-specific error condition of a stanza error. * @param appError The application-specific error element of a stanza error. The Error object will own and delete the Tag. */ void setAppError( Tag* appError ); /** * Returns the text of a error stanza for the given language if available. * If the requested language is not available, the default text (without * a xml:lang attribute) will be returned. * @param lang The language identifier for the desired language. It must * conform to section 2.12 of the XML specification and RFC 3066. If * empty, the default text will be returned, if any. * @return The text of an error stanza. */ const std::string& text( const std::string& lang = EmptyString ) const; /** * Sets the text of a error stanza for the given language. * @param text The error text to set. * @param lang The language identifier for the desired language. It must * conform to section 2.12 of the XML specification and RFC 3066. If * empty, the default text will be set. */ void setText( const std::string& text, const std::string& lang = EmptyString ) { m_text[lang] = text; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Error( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Error( *this ); } private: Error( const Error& error ); void setValues( const Tag* tag ); StanzaErrorType m_type; StanzaError m_error; Tag* m_appError; StringMap m_text; }; } -#endif // ERROR_H__ +#endif /* ERROR_H__ */ Index: ps/trunk/libraries/win32/gloox/include/gloox/forward.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/forward.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/forward.h (revision 27490) @@ -1,104 +1,108 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_FORWARD ) + #ifndef FORWARD_H__ #define FORWARD_H__ #include "stanzaextension.h" #include namespace gloox { class DelayedDelivery; class Stanza; /** * @brief This is an implementation of Stanza Forwarding (@xep{0297}) as a StanzaExtension. * * @note At this point, Forward can only hold forwarded Messages, not IQ or Presence. * However, Forward can be used inside any type of stanza (<message>, <iq>, * or <presence>). * * XEP-Version: 0.5 * * @author Jakob Schröter * @author Fernando Sanchez * @since 1.0.5 */ class GLOOX_API Forward : public StanzaExtension { public: /** * Creates a forwarding StanzaExtension, embedding the given Stanza and DelayedDelivery objects. * @param stanza The forwarded Stanza. This Forward instance will own the Stanza object. * @param delay The date/time the forwarded stanza was received at by the forwarder. This * Forward instance will own the DelayedDelivery object. */ Forward( Stanza* stanza, DelayedDelivery* delay ); /** * Creates a forwarding Stanza from the given Tag. The original Tag will be ripped off. * If a valid Stanza is conatined (as a child) in the Tag it will be parsed, too. * It can then be accessed through embeddedStanza(). The Tag that the Stanza was built from * is available through embeddedTag(). * @param tag The Tag to parse. */ Forward( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~Forward(); /** * This function returns a pointer to a DelayedDelivery StanzaExtension which indicates * when the forwarder originally received the forwarded stanza. * * @return A pointer to a DelayedDelivery object. May be 0. */ const DelayedDelivery* when() const { return m_delay; } // reimplemented from StanzaExtension virtual Stanza* embeddedStanza() const { return m_stanza; } // reimplemented from StanzaExtension virtual Tag* embeddedTag() const { return m_tag; } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension const std::string& filterString() const; // reimplemented from StanzaExtension StanzaExtension* newInstance( const Tag* tag ) const { return new Forward( tag ); } // reimplemented from StanzaExtension StanzaExtension* clone() const; private: Stanza* m_stanza; Tag* m_tag; DelayedDelivery* m_delay; }; } #endif // FORWARD_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/gpgencrypted.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/gpgencrypted.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/gpgencrypted.h (revision 27490) @@ -1,91 +1,95 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_GPGENCRYPTED ) + #ifndef GPGENCRYPTED_H__ #define GPGENCRYPTED_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an abstraction of a jabber:x:encrypted namespace element, as used in @xep{0027} * (Current Jabber OpenPGP Usage). * * This class does not encrypt or decrypt any stanza content. It's meant to be an abstraction * of the XML representation only. * * XEP version: 1.3 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API GPGEncrypted : public StanzaExtension { public: /** * Constructs a new object with the given encrypted message. * @param encrypted The encrypted message. */ GPGEncrypted( const std::string& encrypted ); /** * Constructs an GPGEncrypted object from the given Tag. To be recognized properly, the Tag should * have a name of 'x' in the @c jabber:x:encrypted namespace. * @param tag The Tag to parse. */ GPGEncrypted( const Tag* tag ); /** * Virtual destructor. */ virtual ~GPGEncrypted(); /** * Returns the encrypted message. * @return The encrypted message. */ const std::string& encrypted() const { return m_encrypted; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new GPGEncrypted( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new GPGEncrypted( *this ); } private: std::string m_encrypted; bool m_valid; }; } #endif // GPGENCRYPTED_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/instantmucroom.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/instantmucroom.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/instantmucroom.h (revision 27490) @@ -1,60 +1,63 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) #ifndef INSTANTMUCROOM_H__ #define INSTANTMUCROOM_H__ #include "mucroom.h" namespace gloox { /** * @brief This class implements an instant MUC room. * * XEP version: 1.21 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API InstantMUCRoom : public MUCRoom { public: /** * Creates a new abstraction of a @b unique Multi-User Chat room. The room is not joined * automatically. Use join() to join the room, use leave() to leave it. See MUCRoom for * detailed info. * @param parent The ClientBase object to use for the communication. * @param nick The room's name and service plus the desired nickname in the form * room\@service/nick. * @param mrh The MUCRoomHandler that will listen to room events. May be 0 and may be specified * later using registerMUCRoomHandler(). However, without one, MUC is no joy. * @note To subsequently configure the room, use MUCRoom::registerMUCRoomConfigHandler(). */ InstantMUCRoom( ClientBase* parent, const JID& nick, MUCRoomHandler* mrh ); /** * Virtual Destructor. */ virtual ~InstantMUCRoom(); protected: // reimplemented from MUCRoom (acknowledges instant room creation w/o a // call to the MUCRoomConfigHandler) virtual bool instantRoomHook() const { return true; } }; } #endif // INSTANTMUCROOM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/glooxversion.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/glooxversion.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/glooxversion.h (revision 27490) @@ -1,13 +1,14 @@ /* Copyright (c) 2009-2019 by Jakob Schröter 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. */ -#define GLOOXVERSION 0x010020 +#define GLOOXVERSION 0x010100 + Index: ps/trunk/libraries/win32/gloox/include/gloox/inbandbytestream.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/inbandbytestream.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/inbandbytestream.h (revision 27490) @@ -1,215 +1,221 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef INBANDBYTESTREAM_H__ #define INBANDBYTESTREAM_H__ #include "bytestream.h" #include "iqhandler.h" #include "messagehandler.h" #include "gloox.h" namespace gloox { class BytestreamDataHandler; class ClientBase; class Message; /** * @brief An implementation of a single In-Band Bytestream (@xep{0047}). * * One instance of this class handles a single byte stream. * * See SIProfileFT for a detailed description on how to implement file transfer. * * @note This class can @b receive data wrapped in Message stanzas. This will only work if you * are not using MessageSessions. However, it will always send * data using IQ stanzas (which will always work). * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API InBandBytestream : public Bytestream, public IqHandler, public MessageHandler { friend class SIProfileFT; public: /** * Virtual destructor. */ virtual ~InBandBytestream(); /** * Lets you retrieve this bytestream's block-size. The default is 4096 bytes. * @return The bytestream's block-size. */ int blockSize() const { return m_blockSize; } /** * Sets the stream's block-size. Default: 4096 bytes. Maximum allowed block-size: 65535 bytes * @param blockSize The new block size. * @note You should not change the block size once connect() has been called. Though neither * the block-size limit nor changing it mid-stream are enforced by this function. */ void setBlockSize( int blockSize ) { m_blockSize = blockSize; } // reimplemented from Bytestream virtual ConnectionError recv( int timeout = -1 ) { (void)timeout; return ConnNoError; } // reimplemented from Bytestream bool send( const std::string& data ); // reimplemented from Bytestream - virtual bool connect(); + virtual bool connect( int timeout = -1 ); // reimplemented from Bytestream virtual void close(); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); // reimplemented from MessageHandler virtual void handleMessage( const Message& msg, MessageSession* session = 0 ); private: #ifdef INBANDBYTESTREAM_TEST public: #endif enum IBBType { IBBOpen, IBBData, IBBClose, IBBInvalid }; /** * @brief An abstraction of IBB elements, implemented as as StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class IBB : public StanzaExtension { public: /** * Constructs a new IBB object that opens an IBB, using the given SID and block size. * @param sid The SID of the IBB to open. * @param blocksize The streams block size. */ IBB( const std::string& sid, int blocksize ); /** * Constructs a new IBB object that can be used to send a single block of data, * using the given SID and sequence number. * @param sid The SID of the IBB. * @param seq The block's sequence number. * @param data The block data, not base64 encoded. */ IBB( const std::string& sid, int seq, const std::string& data ); /** * Constructs a new IBB object that closes an IBB, using the given SID. * @param sid The SID of the IBB to close. */ IBB( const std::string& sid ); /** * Constructs a new IBB object from the given Tag. * @param tag The Tag to parse. */ IBB( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~IBB(); /** * Returns the IBB's type. * @return The IBB's type. */ IBBType type() const { return m_type; } /** * Returns the IBB's block size. Only meaningful if the IBB is of type() IBBOpen. * @return The IBB's block size. */ int blocksize() const { return m_blockSize; } /** * Returns the current block's sequence number. * @return The current block's sequence number. */ int seq() const { return m_seq; } /** * Returns the current block's SID. * @return The current block's SID. */ const std::string sid() const { return m_sid; } /** * Returns the current block's data (not base64 encoded). * @return The current block's data. */ const std::string& data() const { return m_data; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new IBB( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new IBB( *this ); } private: std::string m_sid; int m_seq; int m_blockSize; std::string m_data; IBBType m_type; }; InBandBytestream( ClientBase* clientbase, LogSink& logInstance, const JID& initiator, const JID& target, const std::string& sid ); InBandBytestream& operator=( const InBandBytestream& ); void closed(); // by remote entity + void error( const IQ& iq ); // by remote entity void returnResult( const JID& to, const std::string& id ); void returnError( const JID& to, const std::string& id, StanzaErrorType type, StanzaError error ); ClientBase* m_clientbase; int m_blockSize; int m_sequence; int m_lastChunkReceived; + const LogSink& m_logInstance; }; } #endif // INBANDBYTESTREAM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/gpgsigned.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/gpgsigned.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/gpgsigned.h (revision 27490) @@ -1,91 +1,95 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_GPGSIGNED ) + #ifndef GPGSIGNED_H__ #define GPGSIGNED_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an abstraction of a jabber:x:signed namespace element, as used in @xep{0027} * (Current Jabber OpenPGP Usage). * * This class does not sign or verify any stanza content. It's meant to be an abstraction * of the XML representation only. * * XEP version: 1.3 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API GPGSigned : public StanzaExtension { public: /** * Constructs a new object with the given signature. * @param signature The signature. */ GPGSigned( const std::string& signature ); /** * Constructs an GPGSigned object from the given Tag. To be recognized properly, the Tag should * have a name of 'x' in the @c jabber:x:signed namespace. * @param tag The Tag to parse. */ GPGSigned( const Tag* tag ); /** * Virtual destructor. */ virtual ~GPGSigned(); /** * Returns the signature. * @return The signature. */ const std::string& signature() const { return m_signature; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new GPGSigned( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new GPGSigned( *this ); } private: std::string m_signature; bool m_valid; }; } #endif // GPGSIGNED_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/iodata.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/iodata.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/iodata.h (revision 27490) @@ -1,192 +1,196 @@ /* Copyright (c) 2015-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_IODATA ) || defined( WANT_ADHOC ) + #ifndef IODATA_H__ #define IODATA_H__ #include "adhocplugin.h" #include "gloox.h" #include "tag.h" #include namespace gloox { /** * @brief This is an abstraction of the IO Data specification @xep{0244}. * * This abstraction can be used to implement IO Data on top of Data Forms. * * XEP version: 0.1 * @author Jakob Schröter * @since 1.0.13 */ class GLOOX_API IOData : public AdhocPlugin { public: /** * The IO Data transaction types. */ enum Type { TypeIoSchemataGet, /** To request the schemata of input and output. */ TypeInput, /** To submit the input. */ TypeGetStatus, /** To request the status of the procedure. */ TypeGetOutput, /** To request the output. */ TypeIoSchemataResult, /** To return the schemata of input and output. */ TypeOutput, /** To submit the output. */ TypeError, /** To submit additional error information. */ TypeStatus, /** To indicate the current status of the procedure. */ TypeInvalid /** Invalid type. */ }; struct Status { int elapsed; /** Aan integer value of the time in milliseconds that * elapsed since the procedure was invoked. */ int remaining; /** An integer value of the (estimated) time in milliseconds * till the procedure will finish. */ int percentage; /** The percentage of the procedure that is finished. */ std::string info; /** Describes the current status of the procedure. */ }; /** * Constructs a new IO Data object of the given type. * @param type The transaction type. */ IOData( Type type ); /** * Constructs a new IO Data object by parsing the given Tag. * @param tag The Tag to parse. This should be a <iodata> tag with the correct namespace and child elements. */ IOData( const Tag* tag ); /** * Virtual destructor. */ virtual ~IOData(); /** * Returns the IO Data object's type. * @return The IO Data object's type. */ Type type() const { return m_type; } /** * Returns the 'input' tag, if the transaction type is either @c input or @c io-schemata-result. * @return The 'input' tag, including the encapsulating <in>. * @note The IOData instance will still own the tag and delete it. Clone it if you need it later. */ const Tag* in() const { return m_in; } /** * Sets the 'input' tag. If an 'input' tag was previosuly set, it is deleted before the new one is set. * Alternatively, if your input consists of more than one element, you can embed these into an * <in> tag with no namespace. * @param in The new 'input' tag. * @note The @c in tag will be owned by this IOData instance. Clone it if you need it somewhere else. */ void setIn( Tag* in ); /** * Returns the 'output' tag, if the transaction type is either @c output or @c io-schemata-result. * @return The 'output' tag, including the encapsulating <out>. * @note The IOData instance will still own the tag and delete it. Clone it if you need it later. */ const Tag* out() const { return m_out; } /** * Sets the 'output' tag. If an 'output' tag was previosuly set, it is deleted before the new one is set. * Alternatively, if your output consists of more than one element, you can embed these into an * <out> tag with no namespace. * @param out The new 'output' tag. * @note The @c out tag will be owned by this IOData instance. Clone it if you need it somewhere else. */ void setOut( Tag* out ); /** * Returns the 'error' tag, if the transaction type is either @c error or @c io-schemata-result. * @return The 'error' tag, including the encapsulating <error>. * @note The IOData instance will still own the tag and delete it. Clone it if you need it later. */ const Tag* error() const { return m_error; } /** * Sets the 'error' tag. If an 'error' tag was previosuly set, it is deleted before the new one is set. * Alternatively, if your error consists of more than one element, you can embed these into an * <error> tag with no namespace. * @param error The new 'error' tag. * @note The @c error tag will be owned by this IOData instance. Clone it if you need it somewhere else. */ void setError( Tag* error ); /** * Sets the Schema description. Only used/valid if type is @c io-schemata-result. * @param desc The schema description. */ void setDesc( const std::string& desc ) { m_desc = desc; } /** * Returns the schema description, if any. Usually only valid if transaction type is @c io-schema-result. * @return The schema description. */ const std::string& desc() const { return m_desc; } /** * Sets the status of the procedure. Only used/valid if transaction type is @c status. * @param status The status of the procedure. */ void setStatus( Status status ) { m_status = status; } /** * Returns the status of the procedure. Only used/valid if transaction type is @c status. * @return The status of the procedure. */ Status status() const { return m_status; } // reimplemented from AdhocPlugin/StanzaExtension virtual Tag* tag() const; // reimplemented from AdhocPlugin/StanzaExtension virtual IOData* clone() const; // reimplemented from AdhocPlugin/StanzaExtension virtual const std::string& filterString() const { return EmptyString; } // reimplemented from AdhocPlugin/StanzaExtension virtual StanzaExtension* newInstance( const Tag* /*tag*/ ) const { return 0; } /** * Converts to @b true if the IOData is valid, @b false otherwise. */ operator bool() const { return m_type != TypeInvalid; } private: Tag* m_in; Tag* m_out; Tag* m_error; std::string m_desc; Status m_status; Type m_type; }; } #endif // IODATA_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jingleiceudp.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jingleiceudp.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jingleiceudp.h (revision 27490) @@ -1,141 +1,145 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLEICEUDP_H__ #define JINGLEICEUDP_H__ #include "jingleplugin.h" #include #include namespace gloox { class Tag; namespace Jingle { /** * @brief An abstraction of the signaling part of Jingle ICE-UDP Transport Method (@xep{0176}). * * XEP Version: 1.0 * * @author Jakob Schröter * @since 1.0.7 */ class GLOOX_API ICEUDP : public Plugin { public: /** * Describes the candidate type. */ enum Type { Host, /**< A host candidate. */ PeerReflexive, /**< A peer reflexive candidate. */ Relayed, /**< A relayed candidate. */ ServerReflexive /**< A server reflexive candidate. */ }; /** * Describes a single transport candidate. */ struct Candidate { std::string component; /**< A Component ID as defined in ICE-CORE. */ std::string foundation; /**< A Foundation as defined in ICE-CORE.*/ std::string generation; /**< An index, starting at 0, that enables the parties to keep track of updates to the candidate throughout the life of the session. */ std::string id; /**< A unique identifier for the candidate. */ std::string ip; /**< The IP address for the candidate transport mechanism. */ std::string network; /**< An index, starting at 0, referencing which network this candidate is on for a given peer. */ int port; /**< The port at the candidate IP address. */ int priority; /**< A Priority as defined in ICE-CORE. */ std::string protocol; /**< The protocol to be used. Should be @b udp. */ std::string rel_addr; /**< A related address as defined in ICE-CORE. */ int rel_port; /**< A related port as defined in ICE-CORE. */ Type type; /**< A Candidate Type as defined in ICE-CORE. */ }; /** A list of transport candidates. */ typedef std::list CandidateList; /** * Constructs a new instance. * @param pwd The @c pwd value. * @param ufrag The @c ufrag value. * @param candidates A list of connection candidates. */ ICEUDP( const std::string& pwd, const std::string& ufrag, CandidateList& candidates ); /** * Constructs a new instance from the given tag. * @param tag The Tag to parse. */ ICEUDP( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~ICEUDP() {} /** * Returns the @c pwd value. * @return The @c pwd value. */ const std::string& pwd() const { return m_pwd; } /** * Returns the @c ufrag value. * @return The @c ufrag value. */ const std::string& ufrag() const { return m_ufrag; } /** * Returns the list of connection candidates. * @return The list of connection candidates. */ const CandidateList& candidates() const { return m_candidates; } // reimplemented from Plugin virtual const StringList features() const; // reimplemented from Plugin virtual const std::string& filterString() const; // reimplemented from Plugin virtual Tag* tag() const; // reimplemented from Plugin virtual Plugin* newInstance( const Tag* tag ) const; // reimplemented from Plugin virtual Plugin* clone() const { return new ICEUDP( *this ); } private: std::string m_pwd; std::string m_ufrag; CandidateList m_candidates; }; } } #endif // JINGLEICEUDP_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglefiletransfer.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglefiletransfer.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglefiletransfer.h (revision 27490) @@ -1,134 +1,138 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLEFILETRANSFER_H__ #define JINGLEFILETRANSFER_H__ #include "jingleplugin.h" #include "tag.h" #include #include namespace gloox { namespace Jingle { /** * @brief An abstraction of the signaling part of Jingle File Transfer (@xep{0234}), implemented as a Jingle::Plugin. * * XEP Version: 0.15 * * @author Jakob Schröter * @since 1.0.7 */ class GLOOX_API FileTransfer : public Plugin { public: /** * The type of a FileTransfer instance. */ enum Type { Offer, /**< Signifies a file transfer offer (send). */ Request, /**< Signifies a file request (pull). */ Checksum, /**< Used to send a file's checksum. */ Abort, /**< used to abort a running transfer. */ Received, /**< Signifies a successful file transfer. */ Invalid /**< Invalid type. */ }; /** * A struct holding information about a file. */ struct File { std::string name; /**< The file's name. */ std::string date; /**< The file's (creation?) date */ std::string desc; /**< A description. */ std::string hash; /**< The file's cehcksum. */ std::string hash_algo; /**< The algorithm used to calculate the checksum */ long int size; /**< The filesize in Bytes. */ bool range; /**< Signifies that an offset transfer is possible. */ long int offset; /**< An (optional) offset. */ }; /** A list of file information structs. */ typedef std::list FileList; /** * Creates a new instance. * @param type The type of the object. * @param files A list of files to offer, request, acknowledge, ... Most of * the time this list will contain only one file. */ FileTransfer( Type type, const FileList& files ); /** * Creates a new instance from the given Tag * @param tag The Tag to parse. */ FileTransfer( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~FileTransfer() {} /** * Returns the type. * @return The type. */ Type type() const { return m_type; } /** * Returns a list of embedded file infos. * @return A list of embedded file infos. */ const FileList& files() const { return m_files; } // reimplemented from Plugin virtual const StringList features() const; // reimplemented from Plugin virtual const std::string& filterString() const; // reimplemented from Plugin virtual Tag* tag() const; // reimplemented from Plugin virtual Plugin* newInstance( const Tag* tag ) const; // reimplemented from Plugin virtual Plugin* clone() const { return new FileTransfer( *this ); } private: void parseFileList( const TagList& files ); Type m_type; FileList m_files; }; } } #endif // JINGLEFILETRANSFER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglesession.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglesession.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglesession.h (revision 27490) @@ -1,575 +1,579 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLESESSION_H__ #define JINGLESESSION_H__ #include "stanzaextension.h" #include "tag.h" #include "iqhandler.h" #include "jingleplugin.h" #include namespace gloox { class ClientBase; /** * @brief The namespace containing Jingle-related (@xep{0166} et. al.) classes. * * See @link gloox::Jingle::SessionManager SessionManager @endlink for more information * about Jingle in gloox. * * @author Jakob Schröter * @since 1.0.5 */ namespace Jingle { class Description; class Transport; class SessionHandler; class Content; /** * Jingle Session actions. */ enum Action { ContentAccept, /**< Accept a content-add action received from another party. */ ContentAdd, /**< Add one or more new content definitions to the session. */ ContentModify, /**< Change the directionality of media sending. */ ContentReject, /**< Reject a content-add action received from another party. */ ContentRemove, /**< Remove one or more content definitions from the session. */ DescriptionInfo, /**< Exchange information about parameters for an application type. */ SecurityInfo, /**< Send information related to establishment or maintenance of security preconditions. */ SessionAccept, /**< Definitively accept a session negotiation. */ SessionInfo, /**< Send session-level information, such as a ping or a ringing message. */ SessionInitiate, /**< Request negotiation of a new Jingle session. */ SessionTerminate, /**< End an existing session. */ TransportAccept, /**< Accept a transport-replace action received from another party. */ TransportInfo, /**< Exchange transport candidates. */ TransportReject, /**< Reject a transport-replace action received from another party. */ TransportReplace, /**< Redefine a transport method or replace it with a different method. */ InvalidAction /**< Invalid action. */ }; /** * @brief This is an implementation of a Jingle Session (@xep{0166}). * * See @link gloox::Jingle::SessionManager Jingle::SessionManager @endlink for info on how to use * Jingle in gloox. * * XEP Version: 1.1 * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API Session : public IqHandler { friend class SessionManager; public: /** * Session state. */ enum State { Ended, /**< The session has ended or was not active yet. */ Pending, /**< The session has been initiated but has not yet been accepted by the remote party. */ Active /**< The session is active. */ }; /** * @brief An abstraction of a Jingle (@xep{0166}) session terminate reason. * * XEP Version: 1.1 * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API Reason : public Plugin { public: /** * Defined reasons for terminating a Jingle Session. */ enum Reasons { AlternativeSession, /**< An alternative session exists that should be used. */ Busy, /**< The terminating party is busy. */ Cancel, /**< The session has been canceled. */ ConnectivityError, /**< Connectivity error. */ Decline, /**< The terminating party formally declines the request. */ Expired, /**< The session has expired. */ FailedApplication, /**< Application type setup failed. */ FailedTransport, /**< Transport setup has failed. */ GeneralError, /**< General error. */ Gone, /**< Participant went away. */ IncompatibleParameters, /**< Offered or negotiated application type parameters not supported. */ MediaError, /**< Media error. */ SecurityError, /**< Security error. */ Success, /**< Session terminated after successful call. */ Timeout, /**< A timeout occured. */ UnsupportedApplications, /**< The terminating party does not support any of the offered application formats. */ UnsupportedTransports, /**< The terminating party does not support any of the offered transport methods. */ InvalidReason /**< Invalid reason. */ }; /** * Constructor. * @param reason The reason for the termination of the session. * @param sid An optional session ID (only used if reason is AlternativeSession). * @param text An optional human-readable text explaining the reason for the session termination. */ Reason( Reasons reason, const std::string& sid = EmptyString, const std::string& text = EmptyString ); /** * Constructs a new element by parsing the given Tag. * @param tag A tag to parse. */ Reason( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~Reason(); /** * Returns the reason for the session termination. * @return The reason for the session termination. */ Reasons reason() const { return m_reason; } /** * Returns the session ID of the alternate session, if given (only applicable * if reason() returns AlternativeSession). * @return The session ID of the alternative session, or an empty string. */ const std::string& sid() const { return m_sid; } /** * Returns the content of an optional, human-readable * <text> element. * @return An optional text describing the reason for the terminate action. */ const std::string& text() const { return m_text; } // reimplemented from Plugin virtual const std::string& filterString() const; // reimplemented from Plugin virtual Tag* tag() const; // reimplemented from Plugin virtual Plugin* newInstance( const Tag* tag ) const { return new Reason( tag ); } // reimplemented from Plugin virtual Plugin* clone() const; private: Reasons m_reason; std::string m_sid; std::string m_text; }; /** * @brief This is an abstraction of Jingle's (@xep{0166}) <jingle> element as a StanzaExtension. * * XEP Version: 1.1 * @author Jakob Schröter * @since 1.0.5 */ class Jingle : public StanzaExtension { friend class Session; public: /** * Constructs a new object from the given Tag. * @param tag The Tag to parse. */ Jingle( const Tag* tag = 0 ); /** * Virtual Destructor. */ virtual ~Jingle(); /** * Returns the session ID. * @return The session ID. */ const std::string& sid() const { return m_sid; } /** * Returns the 'session initiator'. This will usually be empty for any action other than 'session-initiate'. * @return The 'session initiator'. */ const JID& initiator() const { return m_initiator; } /** * Returns the 'session responder'. This will usually be empty for any action other than 'session-accept'. * @return The 'session responder'. */ const JID& responder() const { return m_responder; } /** * Returns this Jingle's action. * @return The action. */ Action action() const { return m_action; } /** * Adds a Plugin as child. * @param plugin A plugin to be embedded. Will be owned by this instance and deleted in the destructor. */ void addPlugin( const Plugin* plugin ) { if( plugin ) m_plugins.push_back( plugin ); } /** * Returns a reference to a list of embedded plugins. * @return A reference to a list of embedded plugins. */ const PluginList& plugins() const { return m_plugins; } /** * Returns the tag to build plugins from. * @return The tag to build plugins from. */ Tag* embeddedTag() const { return m_tag; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Jingle( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; #ifdef JINGLE_TEST public: #else private: #endif /** * Constructs a new object and fills it according to the parameters. * @param action The Action to carry out. * @param initiator The full JID of the initiator of the session flow. Will only be used for the SessionInitiate action. * @param responder The full JID of the responder. Will only be used for the SessionAccept action. * @param plugins A list of contents (plugins) for the <jingle> * element. Usually, these will be Content objects, but can be any Plugin-derived objects. * These objects will be owned and deleted by this Jingle instance. * @param sid The session ID: */ Jingle( Action action, const JID& initiator, const JID& responder, const PluginList& plugins, const std::string& sid ); #ifdef JINGLE_TEST /** * Constructs a new object and fills it according to the parameters. * @param action The Action to carry out. * @param initiator The full JID of the initiator of the session flow. Will only be used for the SessionInitiate action. * @param responder The full JID of the responder. Will only be used for the SessionAccept action. * @param plugin A single content (plugin) for the <jingle> * element. Usually, this will be a Content object, but can be any Plugin-derived object. * This object will be owned and deleted by this Jingle instance. * @param sid The session ID: */ Jingle( Action action, const JID& initiator, const JID& responder, const Plugin* plugin, const std::string& sid ); #endif // /** // * Copy constructor. // * @param right The instance to copy. // */ // Jingle( const Jingle& right ); Action m_action; std::string m_sid; JID m_initiator; JID m_responder; PluginList m_plugins; Tag* m_tag; }; /** * Virtual Destructor. */ virtual ~Session(); /** * Explicitely sets a new session initiator. The initiator defaults to the initiating entity's JID. * Normally, you should not need to use this function. * @param initiator The new initiator. */ void setInitiator( const JID& initiator ) { m_initiator = initiator; } /** * Returns the session's initiator. * @return The session's initiator. */ const JID& initiator() const { return m_initiator; } /** * Returns the session's responder. This will only return something useful after the 'session-accept' action has been * sent/received. * @return The session's responder. */ const JID& responder() const { return m_responder; } /** * Explicitely sets the 'session responder'. By default, the associated ClientBase's jid() will be used. * You can change this here. * @note Changing the session responder only affects the 'session-accept' action; it will have no effect after * that action has been executed or if the local entity is the session initiator. * @param jid The session responder's full JID. */ void setResponder( const JID& jid ) { m_responder = jid; } /** * Explicitely sets a new handler for the session. * @param handler The new handler. */ void setHandler( SessionHandler* handler ) { m_handler = handler; } /** * Sends a 'content-accept' notification. * @param content The accepted content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentAccept( const Content* content ); /** * Sends a 'content-add' request. * @param content The proposed content to be added. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentAdd( const Content* content ); /** * Sends a 'content-add' request. * @param contents A list of proposed content to be added. * These objects will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentAdd( const PluginList& contents ); /** * Sends a 'content-modify' request. * @param content The proposed content type to be modified. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentModify( const Content* content ); /** * Sends a 'content-reject' reply. * @param content The rejected content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentReject( const Content* content ); /** * Sends a 'content-remove' request. * @param content The content type to be removed. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool contentRemove( const Content* content ); /** * Sends a 'description-info' notice. * @param info The payload. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool descriptionInfo( const Plugin* info ); /** * Sends a 'security-info' notice. * @param info A security pre-condition. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool securityInfo( const Plugin* info ); /** * Accepts an incoming session with the given content. * @param content A pair of application description and transport method wrapped in a Content that describes * the accepted session parameters. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionAccept( const Content* content ); /** * Accepts an incoming session with the given list of contents. * @param plugins A list of Content objects that describe the accepted session parameters. * These objects will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionAccept( const PluginList& plugins ); /** * Sends a 'session-info' notice. * @param info The payload. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionInfo( const Plugin* info ); /** * Initiates a session with a remote entity. * @param content A Content object. You may use initiate( const PluginList& contents ) for more than one Content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionInitiate( const Content* content ); /** * Initiates a session with a remote entity. * @param plugins A list of Content objects. It is important to pass a (list of) Content objects here. * Even though e.g. Jingle::ICEUDP are Plugin-derived, too, using anything other than Content here will result * in erroneous behaviour at best. You may use sessionInitiate( const Content* content ) for just one Content. * These objects will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionInitiate( const PluginList& plugins ); /** * Terminates the current session, if it is at least in Pending state, with the given reason. The sid parameter * is ignored unless the reason is AlternativeSession. * @param reason The reason for terminating the session. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool sessionTerminate( Session::Reason* reason ); /** * Sends a 'transport-accept' reply. * @param content The accepted transport wrapped in a Content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool transportAccept( const Content* content ); /** * Sends a 'transport-info' notice. * @param info The payload. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool transportInfo( const Plugin* info ); /** * Sends a 'transport-reject' reply. * @param content The rejected transport wrapped in a Content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool transportReject( const Content* content ); /** * Sends a 'transport-replace' request. * @param content The proposed transport to be replaced wrapped in a Content. * This object will be owned and deleted by this Session instance. * @return @b False if a prerequisite is not met, @b true otherwise. */ bool transportReplace( const Content* content ); /** * Returns the session's state. * @return The session's state. */ State state() const { return m_state; } /** * Sets the session's ID. This will be initialized to a random value (or taken from an incoming session request) * by default. You should not need to set the session ID manually. * @param sid The session's id. */ void setSID( const std::string& sid ) { m_sid = sid; } /** * Returns the session's ID. * @return The session's ID. */ const std::string& sid() const { return m_sid; } // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); #ifdef JINGLE_TEST public: #else private: #endif /** * Creates a new Jingle Session. * @param parent The ClientBase to use for communication. * @param callee The remote end of the session. * @param jsh The handler to receive events and results. */ Session( ClientBase* parent, const JID& callee, SessionHandler* jsh ); /** * Creates a new Session from the incoming Jingle object. * This is a NOOP for Jingles that have an action() different from SessionInitiate. * @param parent The ClientBase to use for communication. * @param callee The remote entity. * @param jingle The Jingle object to init the Session from. * @param jsh The handler to receive events and results. */ Session( ClientBase* parent, const JID& callee, const Session::Jingle* jingle, SessionHandler* jsh ); bool doAction( Action action, const Plugin* plugin ); bool doAction( Action action, const PluginList& plugin ); ClientBase* m_parent; State m_state; JID m_remote; JID m_initiator; JID m_responder; SessionHandler* m_handler; std::string m_sid; bool m_valid; }; } } #endif // JINGLESESSION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jingleplugin.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jingleplugin.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jingleplugin.h (revision 27490) @@ -1,179 +1,183 @@ /* Copyright (c) 2008-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLEPLUGIN_H__ #define JINGLEPLUGIN_H__ #include "macros.h" #include "util.h" #include #include namespace gloox { class Tag; namespace Jingle { class Plugin; class PluginFactory; /** * The type of Jingle plugin. */ enum JinglePluginType { PluginNone, /**< Invalid plugin type. */ PluginContent, /**< A plugin abstracting a <content> element. May contain further plugins. */ PluginFileTransfer, /**< A plugin for File Transfer. */ PluginICEUDP, /**< A plugin for ICE UDP transport negotiation. */ PluginReason, /**< An abstraction of a Jingle (@xep{0166}) session terminate reason. */ PluginUser /**< User-supplied plugins must use IDs above this. Do * not hard-code PluginUser's value anywhere, it is subject * to change. */ }; /** * A list of Jingle plugins. */ typedef std::list PluginList; /** * @brief An abstraction of a Jingle plugin. This is part of Jingle (@xep{0166} et al.) * * This is the base class for Content and all other pluggable Jingle-related containers, e.g. * session information, such as the 'ringing' info in Jingle Audio, or Jingle DTMF, etc. * * A Plugin abstracts the XML that gets sent and received as part of a Jingle session negotiation. * * XEP Version: 1.1 * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API Plugin { friend class PluginFactory; public: /** * Simple initializer. */ Plugin( JinglePluginType type ) : m_factory( 0 ), m_pluginType( type ) {} /** * Virtual destructor. */ virtual ~Plugin() { util::clearList( m_plugins ) ; } /** * Adds another Plugin as child. * @param plugin A plugin to be embedded. Will be owned by this instance and deleted in the destructor. */ void addPlugin( const Plugin* plugin ) { if( plugin ) m_plugins.push_back( plugin ); } /** * Finds a Jingle::Plugin of a particular type. * @param type JinglePluginType to search for. * @return A pointer to the first Jingle::Plugin of the given type, or 0 if none was found. */ const Plugin* findPlugin( int type ) const { PluginList::const_iterator it = m_plugins.begin(); for( ; it != m_plugins.end() && (*it)->pluginType() != type; ++it ) ; return it != m_plugins.end() ? (*it) : 0; } /** * Finds a Jingle::Plugin of a particular type. * Example: * @code * const MyPlugin* c = plugin.findPlugin( PluginMyPlugin ); * @endcode * @param type The plugin type to look for. * @return The static_cast' type, or 0 if none was found. */ template< class T > inline const T* findPlugin( int type ) const { return static_cast( findPlugin( type ) ); } /** * Returns a reference to a list of embedded plugins. * @return A reference to a list of embedded plugins. */ const PluginList& plugins() const { return m_plugins; } /** * Reimplement this function if your plugin wants to add anything to the list of * features announced via Disco. * @return A list of additional feature strings. */ virtual const StringList features() const { return StringList(); } /** * Returns an XPath expression that describes a path to child elements of a * jingle element that the plugin handles. * The result should be a single Tag. * * @return The plugin's filter string. */ virtual const std::string& filterString() const = 0; /** * Returns a Tag representation of the plugin. * @return A Tag representation of the plugin. */ virtual Tag* tag() const = 0; /** * Returns a new instance of the same plugin type, * based on the Tag provided. * @param tag The Tag to parse and create a new instance from. * @return The new plugin instance. */ virtual Plugin* newInstance( const Tag* tag ) const = 0; /** * Creates an identical deep copy of the current instance. * @return An identical deep copy of the current instance. */ virtual Plugin* clone() const = 0; /** * Returns the plugin type. * @return The plugin type. */ JinglePluginType pluginType() const { return m_pluginType; } protected: PluginList m_plugins; PluginFactory* m_factory; private: void setFactory( PluginFactory* factory ) { m_factory = factory; } JinglePluginType m_pluginType; }; } } #endif // JINGLEPLUGIN_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionhandler.h (revision 27490) @@ -1,74 +1,78 @@ /* Copyright (c) 2008-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLESESSIONHANDLER_H__ #define JINGLESESSIONHANDLER_H__ #include "macros.h" #include "jinglesession.h" namespace gloox { namespace Jingle { /** * @brief A Jingle session handler. * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API SessionHandler { public: /** * Virtual destructor. */ virtual ~SessionHandler() {} /** * This function is called when the remote party requests an action to be taken. * @param action The requested action. A convenience parameter, identical to jingle->action(). * @param session The affected session. * @param jingle The complete Jingle. * @note Note that an action can cause a session state change. You may check using session->state(). * @note Also note that you have to reply to most actions, usually with the *Accept or *Reject counterpart, * using the similarly-named functions that Session offers. */ virtual void handleSessionAction( Action action, Session* session, const Session::Jingle* jingle ) = 0; /** * This function is called when a request to a remote entity returns an error. * @param action The Action that failed. * @param session The affected session. * @param error The error. May be 0 in special cases. * @note Note that an action can cause a session state change. You may check using session->state(). */ virtual void handleSessionActionError( Action action, Session* session, const Error* error ) = 0; /** * This function is called if a remote entity wants to establish a Jingle session. * @param session The new Jingle session. * @note Note that you have to explicitely accept or reject the session by calling either of session->sessionAccept() and * session->sessionTerminate(), respectively. */ virtual void handleIncomingSession( Session* session ) = 0; }; } } #endif // JINGLESESSIONHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/lastactivityhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/lastactivityhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/lastactivityhandler.h (revision 27490) @@ -1,58 +1,62 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LASTACTIVITY ) + #ifndef LASTACTIVITYHANDLER_H__ #define LASTACTIVITYHANDLER_H__ #include "gloox.h" #include "jid.h" namespace gloox { /** * @brief This is an virtual interface that, once reimplemented, allows to receive the * results of Last-Activity-queries to other entities. * * @author Jakob Schröter * @since 0.6 */ class GLOOX_API LastActivityHandler { public: /** * Virtual Destructor. */ virtual ~LastActivityHandler() {} /** * This function is called when a positive result of a query arrives. * @param jid The JID of the queried contact. * @param seconds The idle time or time of last presence of the contact. (Depends * on the JID, check the spec.) * @param status If the contact is offline, this is the last presence status message. May be empty. */ virtual void handleLastActivityResult( const JID& jid, long seconds, const std::string& status ) = 0; /** * This function is called when an error is returned by the queried antity. * @param jid The queried entity's address. * @param error The reported error. */ virtual void handleLastActivityError( const JID& jid, StanzaError error ) = 0; }; } #endif // LASTACTIVITYHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/lastactivity.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/lastactivity.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/lastactivity.h (revision 27490) @@ -1,166 +1,170 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LASTACTIVITY ) + #ifndef LASTACTIVITY_H__ #define LASTACTIVITY_H__ #include "iqhandler.h" #include namespace gloox { class JID; class ClientBase; class LastActivityHandler; /** * @brief This is an implementation of @xep{0012} (Last Activity) for both clients and components. * * LastActivity can be used to query remote entities about their last activity time as well * as answer incoming last-activity-queries. * * XEP Version: 2.0 * * @author Jakob Schröter * @since 0.6 */ class GLOOX_API LastActivity : public IqHandler { public: /** * @brief This is an abstraction of a LastActivity Query that * can be used in @xep{0012} as well as @xep{0256}. * * XEP-Version: 2.0 (@xep{0012}) * XEP-Version: 0.1 (@xep{0256}) * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Query : public StanzaExtension { public: /** * Constructs a new Query object from the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag = 0 ); /** * Constructs a new Query object from the given long. * @param status A status message. * @param seconds The number of seconds since last activity. */ Query( const std::string& status, long seconds ); /** * Virtual destructor. */ virtual ~Query(); /** * Returns the number of seconds since last activity. * @return The number of seconds since last activity. * -1 if last activity is unknown. */ long seconds() const { return m_seconds; } /** * Returns the last status message if the user is offline * and specified a status message when logging off. * @return The last status message, if any. */ const std::string& status() const { return m_status; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Query( *this ); } private: long m_seconds; std::string m_status; }; /** * Constructs a new LastActivity object. * @param parent The ClientBase object to use for communication. */ LastActivity( ClientBase* parent ); /** * Virtual destructor. */ virtual ~LastActivity(); /** * Queries the given JID for their last activity. The result can be received by reimplementing * @ref LastActivityHandler::handleLastActivityResult() and * @ref LastActivityHandler::handleLastActivityError(). */ void query( const JID& jid ); /** * Use this function to register an object as handler for incoming results of Last-Activity queries. * Only one handler is possible at a time. * @param lah The object to register as handler. */ void registerLastActivityHandler( LastActivityHandler* lah ) { m_lastActivityHandler = lah; } /** * Use this function to un-register the LastActivityHandler set earlier. */ void removeLastActivityHandler() { m_lastActivityHandler = 0; } /** * Use this function to reset the idle timer. By default the number of seconds since the * instantiation will be used. */ void resetIdleTimer(); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); private: #ifdef LASTACTIVITY_TEST public: #endif LastActivityHandler* m_lastActivityHandler; ClientBase* m_parent; time_t m_active; }; } #endif // LASTACTIVITY_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionmanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionmanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglesessionmanager.h (revision 27490) @@ -1,117 +1,121 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLESESSIONMANAGER_H__ #define JINGLESESSIONMANAGER_H__ #include "macros.h" #include "iqhandler.h" #include "jinglepluginfactory.h" #include namespace gloox { class ClientBase; namespace Jingle { class Session; class SessionHandler; /** * @brief The SessionManager is responsible for creating and destroying Jingle sessions, as well as for delegating incoming * IQs to their respective sessions. This is part of Jingle (@xep{0166}). * * @note The classes in the Jingle namespace implement the signaling part of Jingle only. * Establishing connections to a remote entity or transfering data outside the XMPP channel * is out of scope of gloox. * * To use Jingle with gloox you should first instantiate a Jingle::SessionManager. The SessionManager will * let you create new Jingle sessions and notify the respective handler about incoming Jingle session requests. * It will also announce generic Jingle support via Disco. You have to register any * @link gloox::Jingle::Plugin Jingle plugins @endlink you want to use using registerPlugin(). * These will automatically announce any additional features via Disco. * * Use createSession() to create a new Session. * * Implement SessionHandler::handleIncomingSession() to receive incoming session requests. * * Use discardSession() to get rid of a session. Do not delete a session manually. * * There is no limit to the number of concurrent sessions. * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API SessionManager : public IqHandler { public: /** * Creates new instance. There should be only one SessionManager per ClientBase. * @param parent A ClientBase instance used for sending and receiving. * @param sh A session handler that will be notified about incoming session requests. * Only handleIncomingSession() will be called in that handler. */ SessionManager( ClientBase* parent, SessionHandler* sh ); /** * Virtual destructor. */ virtual ~SessionManager(); /** * Registers an empty Plugin as a template with the manager. * @param plugin The plugin to register. */ void registerPlugin( Plugin* plugin ); /** * Lets you create a new Jingle session. * @param callee The remote entity's JID. * @param handler The handler responsible for handling events assicoated with the new session. * @return The new session. * @note You should not delete a session yourself. Instead, pass it to discardSession(). */ Session* createSession( const JID& callee, SessionHandler* handler ); /** * Removes a given session from the nternal queue and deletes it. * @param session The session to delete. */ void discardSession( Session* session ); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& /*iq*/, int /*context*/ ) {} private: typedef std::list SessionList; SessionList m_sessions; ClientBase* m_parent; SessionHandler* m_handler; PluginFactory m_factory; }; } } #endif // JINGLESESSIONMANAGER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/linklocal.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/linklocal.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/linklocal.h (revision 27490) @@ -1,79 +1,84 @@ /* Copyright (c) 2012-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LINKLOCAL ) + #ifndef LINKLOCAL_H__ #define LINKLOCAL_H__ #include "config.h" #ifdef HAVE_MDNS #include #include namespace gloox { /** * @brief Namespace holding all the Link-local-related structures and definitions. * * See @ref gloox::LinkLocal::Manager for more information on how to implement * link-local messaging. */ namespace LinkLocal { class Client; /** * Used in conjunction with Service to indicate whether a service has been added (newly advertised) or removed. */ enum Flag { AddService, /**< A service has been added. */ RemoveService /**< A service has been removed. */ }; /** * @brief An abstraction of the parameters of a single link-local service. * * @author Jakob Schröter * @since 1.0.x */ struct Service { friend class Manager; private: Service( Flag _flag, const std::string& _service, const std::string& _regtype, const std::string& _domain, int _interface ) : flag( _flag ), service( _service ), regtype( _regtype ), domain( _domain ), iface( _interface ) {} public: Flag flag; std::string service; std::string regtype; std::string domain; int iface; }; /** * A list of services. */ typedef std::list ServiceList; } } #endif // HAVE_MDNS #endif // LINKLOCAL_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/binaries/system/gloox-1.0.pdb =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ps/trunk/libraries/win32/gloox/include/gloox/linklocalmanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/linklocalmanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/linklocalmanager.h (revision 27490) @@ -1,356 +1,361 @@ /* Copyright (c) 2012-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LINKLOCAL ) + #ifndef LINKLOCALMANAGER_H___ #define LINKLOCALMANAGER_H___ #include "config.h" #ifdef HAVE_MDNS #include "linklocal.h" #include "macros.h" #include "gloox.h" #include "util.h" #include "logsink.h" #include "connectiontcpserver.h" #include "mutex.h" #include "jid.h" #include #include namespace gloox { class ConnectionHandler; class ConnectionTCPClient; namespace LinkLocal { class Handler; /** * @brief This is a manager for server-less messaging (@xep{0174}). * * Enable compilation of this code with the @c \-\-enable-mdns switch to @c configure, or add * @c \#define @c HAVE_MDNS to your platform's @c config.h. @c dns_sd.h, @c libdns_sd.so, as well * as the @c mdnsd daemon from Apple's bonjour distribution are required. The @c mdnsd daemon has * to be running on the local host. * * ### Browsing the local network for XMPP services * * You can use the Manager to browse the local network for XMPP services. * First, create a new instance, register a LinkLocal::Handler, and call startBrowsing(). * @code * m_mdns = new LinkLocal::Manager( ... ); * m_mdns->registerLinkLocalHandler( yourHandler ); * m_mdns->startBrowsing(); * @endcode * * Then you will need to call @c recv() periodcally. The handler will then receive lists of available * or removed services. Check the @c flag member of the Service struct. * * @code * void MyClass::handleBrowseReply( const Service& service ) * { * LinkLocal::ServiceList::const_iterator it = services.begin(); * for( ; it != services.end(); ++it ) * { * if( (*it).flag == LinkLocal::AddService ) * { * // new service * } * else * { * // service removed * } * } * } * @endcode * * @note Note that your own service may show up in the list, too. * * ### Connecting to an XMPP service * * Using the info from the Service struct you can initiate a connection to the remote entity. * First, create a new instance of LinkLocal::Client and register some basic handlers like you * would with a normal gloox::Client: * * @code * LinkLocal::Client c( JID( "romeo@montague.net" ) ); * c.logInstance().registerLogHandler( LogLevelDebug, LogAreaAll, this ); // optional * c.registerConnectionListener( yourConnectionListener ); * @endcode * * Then call @link gloox::LinkLocal::Client::connect( const std::string&, const std::string&, const std::string&, int ) connect() @endlink * and pass the paramters from the Service struct that you received in handleBrowseReply(). * * @code * c.connect( "juliet@laptop", "_presence._tcp", ".local", 4 ); // don't use literal values * @endcode * * Put your LinkLocal::Client instance in your event loop (or in a separate thread) and call * @link gloox::LinkLocal::Client::recv() recv() @endlink periodically. * * ### Advertising an XMPP service on the local network * * To advertise your own XMPP service you can (re-)use the same Manager instance from 'browsing the local network' * above. * * You can publish some basic info about your service in a DNS TXT record. The Manager offers the addTXTData() function * for that. See http://xmpp.org/registrar/linklocal.html for a list of official parameters. * * @code * m_mdns->addTXTData("nick","July"); * m_mdns->addTXTData("1st","Juliet"); * m_mdns->addTXTData("last","Capulet"); * m_mdns->addTXTData("msg","Hanging out"); * m_mdns->addTXTData("jid","julia@capulet.com"); * m_mdns->addTXTData("status","avail"); * @endcode * * Then, to start publishing the availability of your service as well as the TXT record with the additional info * you just call @c registerService(). * * @code * m_mdns->registerService(); * @endcode * * Other entities on the network will now be informed about the availability of your service. * * ### Listening for incoming connections * * The second argument to Manager's constructor is a ConnectionHandler-derived class that * will receive incoming connections. * * When registerService() gets called, the Manager will also start a local server that will * accept incoming connections. By default, it will listen on port 5562. * * In @link gloox::ConnectionHandler::handleIncomingConnection() handleIncomingConnection() @endlink * you should create a new LinkLocal::Client and register some basic handlers: * * @code * LinkLocal::Client c( JID( "romeo@desktop" ) ); * c.logInstance().registerLogHandler( LogLevelDebug, LogAreaAll, this ); * c.registerMessageHandler( this ); * c.registerConnectionListener( this ); * @endcode * * Finally you have to attach the incoming connection to the Client instance, and call connect(). * * @code * connection->registerConnectionDataHandler( &c ); * c.setConnectionImpl( connection ); * c.connect(); * @endcode * * Add the Client to your event loop to call recv() periodically. * * @see @c linklocal_example.cpp in @c src/examples/ for a (very) simple implementation of a bot * handling both incoming and outgoing connections. * * @author Jakob Schröter * @since 1.0.1 */ class GLOOX_API Manager { public: /** * Creates a new Link-local Manager instance. You can call @c registerService() and/or @c startBrowsing() * immediately on a new Manager object, it will use sane defaults. * @param user The username to advertise, preferably (as per @xep{0174}) the locally * logged-in user. This is just the local part of the local JID. * @param connHandler A pointer to a ConnectionHandler that will receive incoming connections. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). */ Manager( const std::string& user, ConnectionHandler* connHandler, const LogSink &logInstance ); /** * Virtual destructor. * @note @c deregisterService() and @c stopBrowsing() will be called automatically if necessary. */ virtual ~Manager(); /** * Lets you add additional data to the published TXT record. * @note The @c txtvers=1 parameter is included by default and cannot be changed. * @param key The key of a key=value parameter pair. Must be non-empty. If the given key * has been set before, its value will be overwritten by the new value. * @param value The value of a @c key=value parameter pair. Must be non-empty. * @note If either parameter is empty, this function is a NOOP. * @note The additional data will not be automatically published if you have already called * @c registerService(). You will have to call @c registerService() again to update the * TXT record. */ void addTXTData( const std::string& key, const std::string& value ); /** * Lets you remove TXT record data by key. * @note The @c txtvers=1 parameter is included by default and cannot be removed. * @param key The key of the @c key=value parameter pair that should be removed. Must be non-empty. * @note A published TXT record will not be automatically updated if you have already called * @c registerService(). You will have to call @c registerService() again to update the TXT record. */ void removeTXTData( const std::string& key ); /** * Starts advertising link-local messaging capabilities by publishing a number of DNS records, * as per @xep{0174}. * You can call this function again to publish any values you updated after the first call. */ void registerService(); /** * Removes the published DNS records and thereby stops advertising link-local messaging * capabilities. */ void deregisterService(); /** * Lets you specify a new username. * @param user The new username. * @note The new username will not be automatically advertised if you have already called * @c registerService(). You will have to call @c registerService() again to update the username. */ void setUser( const std::string& user ) { m_user = user; } /** * Lets you specify an alternate host name to advertise. By default the local machine's hostname * as returned by @c gethostname() will be used. * @param host The hostname to use. * @note The new hostname will not be automatically advertised if you have already called * @c registerService(). You will have to call @c registerService() again to update the hostname. */ void setHost( const std::string& host ) { m_host = host; } /** * This function lets you set an alternate browse domain. The default domain should work in most cases. * @param domain The browse domain to set. * @note The new domain will not be automatically used if you have already called * @c registerService(). You will have to call @c registerService() again to update the domain. * The same applies to @c startBrowsing(). */ void setDomain( const std::string& domain ) { m_domain = domain; } /** * Lets you specifiy a port to listen on for incoming server-less XMPP connections. Default * for this implementation is port 5562, but any unused port can be used. * @note In addition to the SRV record, the port will also be published in the TXT record * automaticlly, you do not have to add it manually. That is, you should not call * @c addTXTData() with a key of @c "port.p2pj". * @param port The port to use. * @note The new port will not be automatically advertised if you have already called * @c registerService(). You will have to call @c registerService() again to update the port. */ void setPort( const int port ) { m_port = port; addTXTData( "port.p2pj", util::int2string( m_port ) ); } /** * This function can be used to set a non-default interface. Use @c if_nametoindex() to * find the index for a specific named device. * By default DNS records will be broadcast on all available interfaces, and all available * interfaces will be used or browsing services. * @param iface The interface to use. If you set an interface here, and want to change it * back to 'any', use @b 0. Use @b -1 to broadcast only on the local machine. * @note The new interface will not be automatically used if you have already called * @c registerService(). You will have to call @c registerService() again to use the new * interface. The same applies to @c startBrowsing(). */ void setInterface( unsigned iface ) { m_interface = iface; } /** * Starts looking for other entities of type @c _presence. You have to set a handler for * results using @c registerLinkLocalHandler() before calling this function. * You can call this function again to re-start browsing with updated parameters. * @return Returns @b true if browsing could be started successfully, @b false otherwise. */ bool startBrowsing(); /** * Stops the browsing. */ void stopBrowsing(); /** * Exposes the socket used for browsing so you can have it checked in your own event loop, * if desired. If your event loop signals new data on the socket, you should NOT * try to read from it directly. Instead you should call @c recv(). * As an alternative to using the raw socket you could also put the Manager in a * separate thread and call @c recv() repeatedly, or achieve this in any other way. */ int socket() const { return m_browseFd; } /** * Checks once for new data on the socket used for browsing. * @param timeout The timeout for @c select() in microseconds. Use @b -1 if blocking behavior * is acceptable. */ void recv( int timeout ); /** * Registers a handler that will be notfied about entities found on the network that match * the given browse criteria. * @param handler The handler to register. */ void registerLinkLocalHandler( Handler* handler ) { m_linkLocalHandler = handler; } // /** // * // */ // static const StringMap decodeTXT( const std::string& txt ); private: static void handleBrowseReply( DNSServiceRef sdRef, DNSServiceFlags flags, unsigned interfaceIndex, DNSServiceErrorType errorCode, const char* serviceName, const char* regtype, const char* replyDomain, void* context ); void handleBrowse( Flag flag, const std::string& service, const std::string& regtype, const std::string& domain, int iface, bool moreComing ); typedef std::list ConnectionList; typedef std::map ConnectionMap; DNSServiceRef m_publishRef; DNSServiceRef m_browseRef; ServiceList m_tmpServices; // ServiceList m_services; std::string m_user; std::string m_host; std::string m_domain; unsigned m_interface; int m_port; const LogSink& m_logInstance; int m_browseFd; StringMap m_txtData; ConnectionTCPServer m_server; Handler* m_linkLocalHandler; ConnectionHandler* m_connectionHandler; }; } } #endif // HAVE_MDNS #endif // LINKLOCALMANAGER_H___ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/messageevent.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messageevent.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/messageevent.h (revision 27490) @@ -1,94 +1,99 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGEEVENT ) + #ifndef MESSAGEEVENT_H__ #define MESSAGEEVENT_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief An implementation of Message Events (@xep{0022}) as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API MessageEvent : public StanzaExtension { public: /** * Constructs a new object from the given Tag. * @param tag A Tag to parse. */ MessageEvent( const Tag* tag ); /** * Constructs a new object of the given type, with an optional message ID. * @param type One or more @link gloox::MessageEventType MessageEventType @endlink. * @param id An optional message ID. Links this Event to the message it is generated for. */ MessageEvent( int type, const std::string& id = EmptyString ) : StanzaExtension( ExtMessageEvent ), m_id( id ), m_event( type ) {} /** * Virtual destructor. */ virtual ~MessageEvent() {} /** * Returns the object's event or events. * @return The object's event or events. */ int event() const { return m_event; } /** * Returns the event's ID. * @return The event's ID. */ std::string id() const { return m_id; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new MessageEvent( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new MessageEvent( *this ); } private: std::string m_id; int m_event; }; } #endif // MESSAGEEVENT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/linklocalhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/linklocalhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/linklocalhandler.h (revision 27490) @@ -1,66 +1,70 @@ /* Copyright (c) 2012-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LINKLOCAL ) + #ifndef LINKLOCALHANDLER_H__ #define LINKLOCALHANDLER_H__ #ifdef HAVE_MDNS #include "linklocal.h" #include "macros.h" #include "gloox.h" #include namespace gloox { namespace LinkLocal { // class Client; /** * @brief A base class that gets informed about advertised or removed XMPP services on the local network. * * See @ref gloox::LinkLocal::Manager for more information on how to implement * link-local messaging. * * @author Jakob Schröter * @since 1.0.x */ class GLOOX_API Handler { public: /** * Reimplement this function to be notified about services available on (or removed from) * the local network. * @param services A list of services. * @note Make a copy of the service list as the list will not be valid after the function * returned. */ virtual void handleBrowseReply( const ServiceList& services ) = 0; // /** // * // */ // virtual void handleClient( Client* client ) = 0; }; } } #endif // HAVE_MDNS #endif // LINKLOCALHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/message.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/message.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/message.h (revision 27490) @@ -1,159 +1,161 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 MESSAGE_H__ #define MESSAGE_H__ #include "delayeddelivery.h" #include "stanza.h" #include namespace gloox { class JID; /** * @brief An abstraction of a message stanza. * * @author Vincent Thomasset * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Message : public Stanza { friend class ClientBase; friend class Forward; public: /** * Describes the different valid message types. */ enum MessageType { Chat = 1, /**< A chat message. */ Error = 2, /**< An error message. */ Groupchat = 4, /**< A groupchat message. */ Headline = 8, /**< A headline message. */ Normal = 16, /**< A normal message. */ Invalid = 32 /**< The message stanza is invalid. */ }; /** * Creates a Message. * @param type The message type. * @param to The intended receiver. * @param body The message's body text. * @param subject The message's optional subject. * @param thread The message's optional thread ID. * @param xmllang An optional xml:lang for the message body. */ Message( MessageType type, const JID& to, const std::string& body = EmptyString, const std::string& subject = EmptyString, const std::string& thread = EmptyString, const std::string& xmllang = EmptyString ); /** * Destructor. */ virtual ~Message(); /** * Returns the message's type. * @return The message's type. */ MessageType subtype() const { return m_subtype; } /** * Returns the message body for the given language if available. * If the requested language is not available, the default body (without a xml:lang * attribute) will be returned. * @param lang The language identifier for the desired language. It must conform to * section 2.12 of the XML specification and RFC 3066. If empty, the default body * will be returned, if any. * @return The message body. */ const std::string body( const std::string& lang = "default" ) const { return findLang( m_bodies, m_body, lang ); } /** * Returns the message subject for the given language if available. * If the requested language is not available, the default subject (without a xml:lang * attribute) will be returned. * @param lang The language identifier for the desired language. It must conform to * section 2.12 of the XML specification and RFC 3066. If empty, the default subject * will be returned, if any. * @return The message subject. */ const std::string subject( const std::string& lang = "default" ) const { return findLang( m_subjects, m_subject, lang ); } /** * Returns the thread ID of a message stanza. * @return The thread ID of a message stanza. Empty for non-message stanzas. */ const std::string& thread() const { return m_thread; } /** * Sets the thread ID. * @param thread The thread ID. */ void setThread( const std::string& thread ) { m_thread = thread; } /** * Sets the message's ID. Optional. * @param id The ID. */ void setID( const std::string& id ) { m_id = id; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DELAYEDDELIVERY ) /** * Convenience function that returns a pointer to a DelayedDelivery StanzaExtension, if the * message contains one. * Make sure you have registered a DelayedDelivery instance with your ClientBase (this is not done automatically), * otherwise this method will always return 0. * @return A pointer to a DelayedDelivery object, or 0. */ const DelayedDelivery* when() const { return static_cast( findExtension( ExtDelay ) ); } +#endif // GLOOX_MINIMAL // reimplemented from Stanza virtual Tag* tag() const; private: #ifdef MESSAGE_TEST public: #endif /** * Creates a message Stanza from the given Tag. The original Tag will be ripped off. * @param tag The Tag to parse. */ Message( Tag* tag ); MessageType m_subtype; std::string m_body; std::string m_subject; StringMap* m_bodies; StringMap* m_subjects; std::string m_thread; }; } #endif // MESSAGE_H__ Index: ps/trunk/binaries/system/gloox-1.0d.dll =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ps/trunk/libraries/win32/gloox/include/gloox/macros.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/macros.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/macros.h (revision 27490) @@ -1,49 +1,49 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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 GLOOX_MACROS_H__ #define GLOOX_MACROS_H__ #if defined( _MSC_VER ) || defined( _WIN32_WCE ) # pragma warning( disable:4251 ) # pragma warning( disable:4786 ) #endif -#if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) +#if defined( _WIN32 ) # if defined( GLOOX_EXPORTS ) || defined( DLL_EXPORT ) # define GLOOX_API __declspec( dllexport ) # else # if defined( GLOOX_IMPORTS ) || defined( DLL_IMPORT ) # define GLOOX_API __declspec( dllimport ) # endif # endif #endif #ifndef GLOOX_API # define GLOOX_API #endif #if defined( __GNUC__ ) && ( __GNUC__ - 0 > 3 || ( __GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2 ) ) # define GLOOX_DEPRECATED __attribute__ ( (__deprecated__) ) # define GLOOX_DEPRECATED_CTOR explicit GLOOX_DEPRECATED #elif defined( _MSC_VER ) && ( _MSC_VER >= 1300 ) # define GLOOX_DEPRECATED __declspec( deprecated ) # define GLOOX_DEPRECATED_CTOR explicit GLOOX_DEPRECATED #else # define GLOOX_DEPRECATED # define GLOOX_DEPRECATED_CTOR #endif #endif // GLOOX_MACROS_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/messageeventhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messageeventhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/messageeventhandler.h (revision 27490) @@ -1,51 +1,56 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGEEVENT ) + #ifndef MESSAGEEVENTHANDLER_H__ #define MESSAGEEVENTHANDLER_H__ #include "gloox.h" namespace gloox { class JID; + class MessageEvent; /** * @brief A virtual interface that enables an object to be notified about * Message Events (@xep{0022}). * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API MessageEventHandler { public: /** * Virtual Destructor. */ virtual ~MessageEventHandler() {} /** * Notifies the MessageEventHandler that an event has been raised by the remote * contact. * @param from The originator of the Event. * @param event The Event which has been raised. */ - virtual void handleMessageEvent( const JID& from, MessageEventType event ) = 0; + virtual void handleMessageEvent( const JID& from, const MessageEvent* event ) = 0; }; } #endif // MESSAGEEVENTHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/messagesessionhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messagesessionhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/messagesessionhandler.h (revision 27490) @@ -1,67 +1,71 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) + #ifndef MESSAGESESSIONHANDLER_H__ #define MESSAGESESSIONHANDLER_H__ #include "stanza.h" #include "messagesession.h" namespace gloox { /** * @brief A virtual interface which can be reimplemented to receive incoming message sessions. * * Derived classes can be registered as MessageSessionHandlers with the Client. * If you have registered as a MessageSessionHandler by calling ClientBase::registerMessageSessionHandler(), * handleMessageSession() will be called if a message stanza arrives for which there is no * MessageSession yet. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API MessageSessionHandler { public: /** * Virtual Destructor. */ virtual ~MessageSessionHandler() {} /** * Reimplement this function if you want to be notified about * incoming messages by means of automatically created MessageSessions. * You receive ownership of the supplied session (@b not the stanza) and * are responsible for deleting it at the end of its life. * * @note Make sure to read the note in ClientBase::registerMessageSessionHandler() * regarding the feeding of decorators. * * @note You should never delete the MessageSession manually. Instead call * ClientBase::disposeMessageSession() when you no longer need the session. * * @note If you don't need the MessageSession, you should not dispose it here. You will * get an endless loop if you do. * * @note You should register your MessageHandler here, or else the first message * (that caused the MessageSession to be created) may get lost. * * @param session The new MessageSession. */ virtual void handleMessageSession( MessageSession* session ) = 0; }; } #endif // MESSAGESESSIONHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/messagesession.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messagesession.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/messagesession.h (revision 27490) @@ -1,318 +1,322 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) + #ifndef MESSAGESESSION_H__ #define MESSAGESESSION_H__ #include "jid.h" #include "gloox.h" #include #include namespace gloox { class ClientBase; class MessageFilter; class MessageHandler; class Message; /** * @brief An abstraction of a message session between any two entities. * * This is an alternative interface to unmanaged messaging. The original interface, using the simple * MessageHandler-derived interface, is based on an all-or-nothing approach. Once registered with * ClientBase, a handler receives all message stanzas sent to this client and has to do any filtering * on its own. * * MessageSession adds an abstraction to a chat conversation. A MessageSession is responsible for * communicating with exactly one (full) JID. It is extensible with so-called MessageFilters, which can * provide additional features such as Message Events, or Chat State Notifications. * * You can still use the old MessageHandler in parallel, but messages will not be relayed to both * the generic MessageHandler and a MessageSession established for the sender's JID. The MessageSession * takes precedence. * * Using MessageSessions has the following advantages over the plain old MessageHandler: * @li automatic creation of MessageSessions * @li filtering by JID * @li automatic handling of threading (i.e., XMPP message threads) * @li simpler sending of messages * @li support for MessageFilters. * * @b Usage:
* Derive an object from MessageSessionHandler and reimplement handleMessageSession() to store your * shiny new sessions somewhere, or to create a new chat window, or whatever. Register your * object with a ClientBase instance using registerMessageSessionHandler(). In code: * @code * void MyClass::myFunc() * { * JID jid( "abc@example.org/gloox" ); * j = new Client( jid, "password" ); * [...] * j->registerMessageSessionHandler( this, 0 ); * } * @endcode * MyClass is a MessageSessionHandler here. * * In this example, MyClass needs to be MessageHandler, MessageEventHandler and * ChatStateHandler, too. The handlers are registered with the session to receive the * respective events. * @code * virtual void MyClass::handleMessageSession( MessageSession* session ) * { * // for this example only, we delete any earlier session * if( m_session ) * j->disposeMessageSession( m_session ); * m_session = session; * m_session->registerMessageHandler( this ); * * // the following is optional * m_messageEventFilter = new MessageEventFilter( m_session ); * m_messageEventFilter->registerMessageEventHandler( this ); * m_chatStateFilter = new ChatStateFilter( m_session ); * m_chatStateFilter->registerChatStateHandler( this ); * } * @endcode * * MessageEventHandler::handleMessageEvent() and ChatStateHandler::handleChatState() are called * for incoming Message Events and Chat States, respectively. * @code * virtual void MyClass::handleMessageEvent( const JID& from, MessageEventType event ) * { * // display contact's Message Event * } * * virtual void MyClass::handleChatState( const JID& from, ChatStateType state ) * { * // display contact's Chat State * } * @endcode * * To let the chat partner now that the user is typing a message or has closed the chat window, use * raiseMessageEvent() and setChatState(), respectively. For example: * @code * // user is typing a message * m_messageEventFilter->raiseMessageEvent( MessageEventComposing ); * * // acknowledge receiving of a message * m_messageEventFilter->raiseMessageEvent( MessageEventDelivered ); * * // user is not actively paying attention to the chat * m_chatStateFilter->setChatState( ChatStateInactive ); * * // user has closed the chat window * m_chatStateFilter->setChatState( ChatStateGone ); * @endcode * * To send a message to the chat partner of the session, use * @ref send( const std::string& message, const std::string& subject, const StanzaExtensionList& ). * You don't have to care about * receipient, thread id, etc., they are added automatically. * * @code * m_session->send( "Hello World!", "No Subject" ); * @endcode * * To initiate a new chat session, all you have to do is create a new MessageSession and register * a MessageHandler with it: * @code * MessageSession* MyClass::newSession( const JID& to ) * { * MessageSession* session = new MessageSession( m_client, to ); * session->registerMessageHandler( this ); * return session; * } * @endcode * * @note You should never delete a MessageSession manually. Use ClientBase::disposeMessageSession() * instead. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API MessageSession { friend class MessageFilter; public: /** * Constructs a new MessageSession for the given JID. * It is recommended to supply a full JID, in other words, it should have a resource set. * No resource can lead to unexpected behavior. A thread ID is generated and sent along * with every message sent through this session. * @param parent The ClientBase to use for communication. * @param jid The remote contact's full JID. If you don't know the full JID (this is probably the * most common case) but still want replies from the full JID to be handled by this MessageSession, * set the @b wantUpgrade parameter to true (or leave it untouched). * @param wantUpgrade This flag indicates whether gloox should try to match an incoming message * from a full JID to this MessageSession. If unsure, use the default. You probably only want to use * a non-default value if this MessageSession is supposed to talk directly to a server or component * JID that has no resource. This 'upgrade' will only happen once. * @param types ORed list of Message::MessageType values this MessageSession shall receive. * Defaults to 0 which means any type is received. * @param honorTID Indicates whether thread IDs should be honored when matching incoming messages to MessageSessions. * The default (@b true) is usually fine. */ MessageSession( ClientBase* parent, const JID& jid, bool wantUpgrade = true, int types = 0, bool honorTID = true ); /** * Virtual destructor. * * @note You should never delete a MessageSession manually. Use ClientBase::disposeMessageSession() * instead. */ virtual ~MessageSession(); /** * Use this function to find out where this session points at. * @return The receipient's JID. */ const JID& target() const { return m_target; } /** * By default, a thread ID is sent with every message to identify * messages belonging together. * @returns The thread ID for this session. */ const std::string& threadID() const { return m_thread; } /** * Use this function to set the session's thread ID if e.g. a specific thread is * continued. It should not normally be needed to set the thread ID manually. * @param thread The new thread ID. */ void setThreadID( const std::string& thread ) { m_thread = thread; } /** * Indicates whether thread IDs are honored when matching incoming * messages to MessageSessions. * @return Whether thread IDs are honored. */ bool honorThreadID() const { return m_honorThreadID; } /** * Use this function to associate a MessageHandler with this MessageSession. * The MessageHandler will receive all messages sent from this MessageSession's * remote contact. * @param mh The MessageHandler to register. */ void registerMessageHandler( MessageHandler* mh ) { m_messageHandler = mh; } /** * This function clears the internal pointer to the MessageHandler and therefore * disables message delivery. */ void removeMessageHandler() { m_messageHandler = 0; } /** * A convenience function to quickly send a message. * @param message The message to send. */ virtual void send( const std::string& message ); /** * A convenience function to quickly send a message (optionally with subject). This is * the preferred way to send a message from a MessageSession. * @param message The message to send. * @param subject The optional subject to send. * @param sel An optional list of StanzaExtensions. The extensions will be owned by the message-to-be-sent; * do not attempt to re-use or delete them. */ virtual void send( const std::string& message, const std::string& subject, const StanzaExtensionList& sel = StanzaExtensionList() ); /** * Use this function to hook a new MessageFilter into a MessageSession. * The filter will be able to read and/or modify a message stanza's content. * @note The MessageSession will become the owner of the filter, it will be * deleted by MessageSession's destructor. To get rid of the filter before that, * use disposeMessageFilter(). * @param mf The MessageFilter to add. */ void registerMessageFilter( MessageFilter* mf ) { m_messageFilterList.push_back( mf ); } /** * Use this function to remove a MessageFilter from the MessageSession. * @param mf The MessageFilter to remove. * @note To remove and delete the MessageFilter in one step use disposeMessageFilter(). */ void removeMessageFilter( MessageFilter* mf ) { m_messageFilterList.remove( mf ); } /** * Use this function to remove and delete a MessageFilter from the MessageSession. * @param mf The MessageFilter to remove and delete. * @note To just remove (and not delete) the MessageFilter use removeMessageFilter(). */ void disposeMessageFilter( MessageFilter* mf ); /** * Returns the message type this MessageSession wants to receive. * @return ORed list of Message::MessageType values this MessageSession wants to receive. */ int types() const { return m_types; } /** * This function resets the session's target JID to its bare form such that * subsequently sent messages will be sent to that bare JID. The server will * determine the best resource to deliver to. Useful if the target * resource changed presence to e.g. away or offline. This does not automatically * set the wantResourceTracking option. If you need escalation, be sure to set * this option in the constructor. */ void resetResource(); /** * This function can be used to feed a message into the session. Ususally, only * ClientBase should call this function. * @param msg A Message to feed into the session. */ virtual void handleMessage( Message& msg ); protected: /** * A wrapper around ClientBase::send(). You should @b not use this function to send a * chat message because the Tag is not prepared accordingly (neither a thread ID is added nor is * the message ran through the message filters). * @param msg A Message to send. */ virtual void send( const Message& msg ); void decorate( Message& msg ); ClientBase* m_parent; JID m_target; MessageHandler* m_messageHandler; private: void setResource( const std::string& resource ); typedef std::list MessageFilterList; MessageFilterList m_messageFilterList; std::string m_thread; int m_types; bool m_wantResourceTracking; bool m_hadMessages; bool m_honorThreadID; }; } #endif // MESSAGESESSION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/messagemarkup.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messagemarkup.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/messagemarkup.h (revision 27490) @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2018-2019 by Jakob Schröter + * 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. + */ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGEMARKUP ) + +#ifndef MESSAGEMARKUP_H__ +#define MESSAGEMARKUP_H__ + +#include "gloox.h" +#include "stanzaextension.h" + +#include +#include + +namespace gloox +{ + /** + * This is an abstraction of Message Markup (@xep{0394}). + * + * XEP Version: 0.1.0 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API MessageMarkup : public StanzaExtension + { + public: + + /** + * A list of ints. + */ + typedef std::list IntList; + + /** + * The supported Message Markup types according to @xep{0394}. + */ + enum MarkupType + { + Span, /**< A span, possibly containing emphasis, code and/or deleted tags. */ + BCode, /**< A code block. Suggested rendering: as block-level element with + * monospaced font. */ + List, /**< An itemized list. */ + BQuote, /**< A block quote. */ + InvalidType /**< Invalid/unknown type. Ignored. */ + }; + + /** + * The supported Span types according to @xep{0394}. + */ + enum SpanType + { + Emphasis = 1, /**< An emphasised section of text. */ + Code = 2, /**< Suggested rendering: with monospaced font. */ + Deleted = 4, /**< Deleted text. Suggested rendering strike-through. */ + InvalidSpan = 8 /**< Invalid/unknown type. Ignored. */ + }; + + /** + * A struct describing a single child element of a <markup> element. + */ + struct Markup + { + MarkupType type; /**< The type. */ + int start; /**< The start of the range, in units of unicode code points in the character + * data of the body element. */ + int end; /**< The end of the range, in units of unicode code points in the character + * data of the body element. */ + int spans; /**< The applicable span types (SpanType) for the current span. Only set if + * @c type is @c Span, 0 otherwise. */ + IntList lis; /**< A list of positions inside the text that are start positions for list + * items. Only used if @c type is List, empty otherwise. */ + + /** + * Constructor for a Markup struct for convenience. + * @param _type The type. + * @param _start The start of the range. + * @param _end The end of the range. + * @param _spans The applicable span types (SpanType) for the current span. + * @param _lis A list of positions inside the text that are start positions for list + * items. + */ + Markup( MarkupType _type, int _start, int _end, int _spans, IntList _lis ) + : type( _type ), start( _start ), end( _end ), spans( _spans ), lis( _lis ) + {} + + }; + + /** + * A list of Markup structs. + */ + typedef std::list MarkupList; + + /** + * Constructs a new object from the given Tag. + * @param tag A Tag to parse. + */ + MessageMarkup( const Tag* tag ); + + /** + * Constructs a new MessageMarkup object with the given markups. + * @param ml The markups to include. + */ + MessageMarkup( const MarkupList& ml ) + : StanzaExtension( ExtMessageMarkup ), m_markups( ml ) + {} + + /** + * Virtual destructor. + */ + virtual ~MessageMarkup() {} + + /** + * Lets you set the @c lang attribute (@c xml:lang) to that of the corresponding body element. + * @param lang The language. + */ + void setLang( const std::string& lang ) { m_lang = lang; } + + /** + * Lets you retrieve the @c lang attribute's value (@c xml:lang). + * @return The @c lang attribute's value. + */ + const std::string& lang() const { return m_lang; } + + /** + * Returns the list of markups. + * @return The list of markups. + */ + const MarkupList& markup() const { return m_markups; } + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new MessageMarkup( tag ); + } + + // reimplemented from StanzaExtension + Tag* tag() const; + + // reimplemented from StanzaExtension + virtual MessageMarkup* clone() const + { + return new MessageMarkup( *this ); + } + + private: + MarkupList m_markups; + std::string m_lang; + + }; + +} + +#endif // MESSAGEMARKUP_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/messagemarkup.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/mucmessagesession.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/mucmessagesession.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/mucmessagesession.h (revision 27490) @@ -1,66 +1,70 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) + #ifndef MUCMESSAGESESSION_H__ #define MUCMESSAGESESSION_H__ #include "messagesession.h" namespace gloox { class ClientBase; /** * @brief This is a MessageSession, adapted to be used in a MUC context. * * This class is used internally by MUCRoom. You should not need to use it directly. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MUCMessageSession : public MessageSession { public: /** * Creates a new MUCMessageSession. * @param parent The ClientBase to use for communication. * @param jid The @b bare JID of the MUC room. */ MUCMessageSession( ClientBase* parent, const JID& jid ); /** * Virtual Destructor. */ virtual ~MUCMessageSession(); /** * Use this function to send a message to all room occupants. * @param message The message to send. */ virtual void send( const std::string& message ); /** * Use this function to set a new room subject. * @param subject The new room subject. */ virtual void setSubject( const std::string& subject ); // reimplemented from MessageSession virtual void handleMessage( Message& msg ); }; } #endif // MUCMESSAGESESSION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/binaries/system/gloox-1.0d.pdb =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ps/trunk/libraries/win32/gloox/include/gloox/adhoc.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/adhoc.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/adhoc.h (revision 27490) @@ -1,500 +1,496 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ADHOC ) #ifndef ADHOC_H__ #define ADHOC_H__ #include "adhocplugin.h" #include "disco.h" #include "disconodehandler.h" #include "discohandler.h" #include "iqhandler.h" #include "stanzaextension.h" #include "mutex.h" #include #include #include namespace gloox { class ClientBase; class Stanza; class AdhocHandler; class AdhocCommandProvider; /** * @brief This class implements a provider for @xep{0050} (Ad-hoc Commands). * * The current, not complete, implementation is probably best suited for fire-and-forget * type of commands. Any additional feature, like multiple stages, etc., would have to be * added separately. * * To offer commands to remote entities, use this class as follows:
* Create a class that will handle command execution requests and derive it from * AdhocCommandProvider. Instantiate an Adhoc object and register your * AdhocCommandProvider-derived object with the Adhoc object using * registerAdhocCommandProvider(). The additional parameters to that method are the internal * name of the command as used in the code, and the public name of the command as it * will be shown to an end user: * @code * MyClass::someFunc() * { * Adhoc* m_adhoc = new Adhoc( m_client ); * * // this might be a bot monitoring a weather station, for example * m_adhoc->registerAdhocCommandProvider( this, "getTemp", "Retrieve current temperature" ); * m_adhoc->registerAdhocCommandProvider( this, "getPressure", "Retrieve current air pressure" ); * [...] * } * @endcode * In this example, MyClass is AdhocCommandProvider-derived so it is obviously the command handler, too. * * And that's about it you can do with the Adhoc class. Of course you can have a AdhocCommandProvider * handle more than one command, just register it with the Adhoc object for every desired command, * like shown above. * * What the Adhoc object does when you install a new command is tell the supplied Disco object * to advertise these commands to clients using the 'Service Discovery' protocol to learn about * this implementation's features. These clients can then call and execute the command. Of course you * are free to implement access restrictions to not let anyone mess with your bot, for example. * However, the commands offered using Service Discovery are publically visible in any case. * * To execute commands offered by a remote entity:
* ...TBC... * * XEP version: 1.2 * @author Jakob Schröter */ class GLOOX_API Adhoc : public DiscoNodeHandler, public DiscoHandler, public IqHandler { public: /** * @brief An abstraction of an Adhoc Command element (from Adhoc Commands, @xep{0050}) * as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Command : public StanzaExtension { friend class Adhoc; public: /** * Specifies the action to undertake with the given command. */ enum Action { Execute = 1, /**< The command should be executed or continue to be executed. * This is the default value. */ Cancel = 2, /**< The command should be canceled. */ Previous = 4, /**< The command should be digress to the previous stage of * execution. */ Next = 8, /**< The command should progress to the next stage of * execution. */ Complete = 16, /**< The command should be completed (if possible). */ InvalidAction = 32 /**< The action is unknown or invalid. */ }; /** * Describes the current status of a command. */ enum Status { Executing, /**< The command is being executed. */ Completed, /**< The command has completed. The command session has ended. */ Canceled, /**< The command has been canceled. The command session has ended. */ InvalidStatus /**< The status is unknown or invalid. */ }; /** * An abstraction of a command note. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Note { friend class Command; public: /** * Specifies the severity of a note. */ enum Severity { Info, /**< The note is informational only. This is not really an * exceptional condition. */ Warning, /**< The note indicates a warning. Possibly due to illogical * (yet valid) data. */ Error, /**< The note indicates an error. The text should indicate the * reason for the error. */ InvalidSeverity /**< The note type is unknown or invalid. */ }; /** * A convenience constructor. * @param sev The note's severity. * @param note The note's content. */ Note( Severity sev, const std::string& note ) : m_severity( sev ), m_note( note ) {} /** * Destructor. */ ~Note() {} /** * Returns the note's severity. * @return The note's severity. */ Severity severity() const { return m_severity; } /** * Returns the note's content. * @return The note's content. */ const std::string& content() const { return m_note; } /** * Returns a Tag representation of the Note. * @return A Tag representation. */ Tag* tag() const; private: #ifdef ADHOC_COMMANDS_TEST public: #endif /** * Constructs a new Note from the given Tag. * @param tag The Tag to parse. */ Note( const Tag* tag ); Severity m_severity; /**< The note's severity. */ std::string m_note; /**< The note's content. */ }; /** * A list of command notes. */ typedef std::list NoteList; /** * Creates a Command object that can be used to perform the provided Action. * This constructor is used best to continue execution of a multi stage command * (for which the session ID must be known). * @param node The node (command) to perform the action on. * @param sessionid The session ID of an already running adhoc command session. * @param action The action to perform. * @param plugin An optional AdhocPlugin (e.g. DataForm) to include in the request. Will be deleted in Command's * destructor. */ Command( const std::string& node, const std::string& sessionid, Action action, AdhocPlugin* plugin = 0 ); /** * Creates a Command object that can be used to perform the provided Action. * This constructor is used best to reply to an execute request. * @param node The node (command) to perform the action on. * @param sessionid The (possibly newly created) session ID of the adhoc command session. * @param status The execution status. * @param plugin An optional AdhocPlugin (e.g. DataForm) to include in the reply. Will be deleted in Command's * destructor. */ Command( const std::string& node, const std::string& sessionid, Status status, AdhocPlugin* plugin = 0 ); /** * Creates a Command object that can be used to perform the provided Action. * This constructor is used best to reply to a multi stage command that is not yet completed * (for which the session ID must be known). * @param node The node (command) to perform the action on. * @param sessionid The (possibly newly created) session ID of the adhoc command session. * @param status The execution status. * @param executeAction The action to execute. * @param allowedActions Allowed reply actions. * @param plugin An optional AdhocPlugin (e.g. DataForm) to include in the reply. Will be deleted in Command's * destructor. */ Command( const std::string& node, const std::string& sessionid, Status status, Action executeAction, int allowedActions = Complete, AdhocPlugin* plugin = 0 ); /** * Creates a Command object that can be used to perform the provided Action. * This constructor is used best to execute the initial step of a command * (single or multi stage). * @param node The node (command) to perform the action on. * @param action The action to perform. * @param plugin An optional AdhocPlugin (e.g. DataForm) to include in the request. Will be deleted in Command's * destructor. */ Command( const std::string& node, Action action, AdhocPlugin* plugin = 0 ); /** * Creates a Command object from the given Tag. * @param tag A <command> tag in the adhoc commands' namespace. */ Command( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~Command(); /** * Returns the node identifier (the command). * @return The node identifier. */ const std::string& node() const { return m_node; } /** * Returns the command's session ID, if any. * @return The command's session ID. */ const std::string& sessionID() const { return m_sessionid; } /** * Returns the execution status for a command. Only valid for execution * results. * @return The execution status for a command. */ Status status() const { return m_status; } /** * Returns the command's action. * @return The command's action. */ Action action() const { return m_action; } /** * Returns the ORed actions that are allowed to be executed on the * current stage. * @return An int containing the ORed actions. */ int actions() const { return m_actions; } /** * Returns the list of notes associated with the command. * @return The list of notes. */ const NoteList& notes() const { return m_notes; } /** * Use this function to add a note to the command. * @param note A pointer to a Note object. The Command will own * the Note. */ void addNote( const Note* note ) { m_notes.push_back( note ); } /** * Returns the command's embedded AdhocPlugin (e.g. DataForm). * @return The command's embedded AdhocPlugin (e.g. DataForm). May be 0. - * @note This will be removed in 1.1. Use plugin() instead. - */ - GLOOX_DEPRECATED const AdhocPlugin* form() const { return m_plugin; } - - /** - * Returns the command's embedded AdhocPlugin (e.g. DataForm). - * @return The command's embedded AdhocPlugin (e.g. DataForm). May be 0. */ const AdhocPlugin* plugin() const { return m_plugin; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Command( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { Command* c = new Command(); NoteList::const_iterator it = m_notes.begin(); for( ; it != m_notes.end(); ++it ) c->m_notes.push_back( new Note( *(*it) ) ); c->m_node = m_node; c->m_sessionid = m_sessionid; c->m_plugin = m_plugin ? static_cast( m_plugin->clone() ) : 0; c->m_action = m_action; c->m_status = m_status; c->m_actions = m_actions; return c; } private: #ifdef ADHOC_COMMANDS_TEST public: #endif NoteList m_notes; std::string m_node; std::string m_sessionid; AdhocPlugin* m_plugin; Action m_action; Status m_status; int m_actions; }; /** * Constructor. * Creates a new Adhoc client that registers as IqHandler with a ClientBase. * @param parent The ClientBase used for XMPP communication. */ Adhoc( ClientBase* parent ); /** * Virtual destructor. */ virtual ~Adhoc(); /** * This function queries the given remote entity for Adhoc Commands support. * @param remote The remote entity's JID. * @param ah The object handling the result of this request. * @param context A user defined context. */ void checkSupport( const JID& remote, AdhocHandler* ah, int context = 0 ); /** * Retrieves a list of commands from the remote entity. You should check whether the remote * entity actually supports Adhoc Commands by means of checkSupport(). * @param remote The remote entity's JID. * @param ah The object handling the result of this request. * @param context A user defined context. */ void getCommands( const JID& remote, AdhocHandler* ah, int context = 0 ); /** * Executes or continues the given command on the given remote entity. * To construct the @c command object, it is recommended to use either * Command( const std::string&, Action ) to begin execution of a command, or * Command( const std::string&, const std::string&, Action ) to continue execution * of a command. * @param remote The remote entity's JID. * @param command The command to execute. * @param ah The object handling the result of this request. * @param context A user defined context. */ void execute( const JID& remote, const Adhoc::Command* command, AdhocHandler* ah, int context = 0 ); /** * Use this function to respond to an execution request submitted by means * of AdhocCommandProvider::handleAdhocCommand(). * It is recommended to use * Command( const std::string&, const std::string&, Status, AdhocPlugin* ) * to construct the @c command object. * Optionally, an Error object can be included. In that case the IQ sent is of type @c error. * @param remote The requester's JID. * @param command The response. The Adhoc object will own and delete the * command object pointed to. * @param error An optional Error object to include. */ void respond( const JID& remote, const Adhoc::Command* command, const Error* error = 0 ); /** * Using this function, you can register a AdhocCommandProvider -derived object as * handler for a specific Ad-hoc Command as defined in @xep{0050}. * @param acp The object to register as handler for the specified command. * @param command The node name of the command. Will be announced in disco#items. * @param name The natural-language name of the command. Will be announced in disco#items. */ void registerAdhocCommandProvider( AdhocCommandProvider* acp, const std::string& command, const std::string& name ); /** * Use this function to unregister an adhoc command previously registered using * registerAdhocCommandProvider(). * @param command The command to unregister. */ void removeAdhocCommandProvider( const std::string& command ); // reimplemented from DiscoNodeHandler virtual StringList handleDiscoNodeFeatures( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::IdentityList handleDiscoNodeIdentities( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::ItemList handleDiscoNodeItems( const JID& from, const JID& to, const std::string& node ); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); // reimplemented from DiscoHandler virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context ); // reimplemented from DiscoHandler virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context ); // reimplemented from DiscoHandler virtual void handleDiscoError( const JID& from, const Error* error, int context ); private: #ifdef ADHOC_TEST public: #endif typedef std::map AdhocCommandProviderMap; AdhocCommandProviderMap m_adhocCommandProviders; enum AdhocContext { CheckAdhocSupport, FetchAdhocCommands, ExecuteAdhocCommand }; struct TrackStruct { JID remote; AdhocContext context; std::string session; AdhocHandler* ah; int handlerContext; }; typedef std::map AdhocTrackMap; AdhocTrackMap m_adhocTrackMap; util::Mutex m_adhocTrackMapMutex; ClientBase* m_parent; StringMap m_items; StringMap m_activeSessions; }; } #endif // ADHOC_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/adhoccommandprovider.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/adhoccommandprovider.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/adhoccommandprovider.h (revision 27490) @@ -1,79 +1,82 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ADHOC ) #ifndef ADHOCCOMMANDPROVIDER_H__ #define ADHOCCOMMANDPROVIDER_H__ #include "tag.h" #include "jid.h" #include "adhoc.h" #include #include #include namespace gloox { /** * @brief A virtual interface for an Ad-hoc Command Provider according to @xep{0050}. * * Derived classes can be registered as Command Providers with the Adhoc object. * * @author Jakob Schröter */ class GLOOX_API AdhocCommandProvider { public: /** * Virtual destructor. */ virtual ~AdhocCommandProvider() {} /** * This function is called when an Ad-hoc Command needs to be handled. * The callee is responsible for the whole command execution, i.e. session * handling etc. * To reply, use Adhoc::respond(). * @param from The sender of the command request. * @param command The name of the command to be executed. * @param sessionID The session ID. Either newly generated or taken from the command. * When responding, its value must be passed to Adhoc::Command's constructor. */ virtual void handleAdhocCommand( const JID& from, const Adhoc::Command& command, const std::string& sessionID ) = 0; /** * This function gets called for each registered command when a remote * entity requests the list of available commands. * @param from The requesting entity. * @param command The command's name. * @return @b True if the remote entity is allowed to see the command, @b false if not. * @note The return value of this function does not influence * the execution of a command. That is, you have to * implement additional access control at execution stage. * @note This function should not block. */ virtual bool handleAdhocAccessRequest( const JID& from, const std::string& command ) { (void)from; (void)command; return true; } }; } #endif // ADHOCCOMMANDPROVIDER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/adhochandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/adhochandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/adhochandler.h (revision 27490) @@ -1,79 +1,82 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ADHOC ) #ifndef ADHOCHANDLER_H__ #define ADHOCHANDLER_H__ #include "adhoc.h" namespace gloox { /** * @brief A virtual interface for an Ad-hoc Command users according to @xep{0050}. * * Derived classes can be registered with the Adhoc object to receive notifications * about Adhoc Commands remote entities support. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API AdhocHandler { public: /** * Virtual destructor. */ virtual ~AdhocHandler() {} /** * This function is called in response to a call to Adhoc::checkSupport(). * @param remote The queried remote entity's JID. * @param support Whether the remote entity supports Adhoc Commands. * @param context A user defined context. */ virtual void handleAdhocSupport( const JID& remote, bool support, int context ) = 0; /** * This function is called in response to a call to Adhoc::getCommands() * and delivers a list of supported commands. * @param remote The queried remote entity's JID. * @param commands A map of supported commands and their human-readable name. * @param context A user defined context. * The map may be empty. */ virtual void handleAdhocCommands( const JID& remote, const StringMap& commands, int context ) = 0; /** * This function is called in response to a call to Adhoc::getCommands() or * Adhoc::checkSupport() or Adhoc::execute() in case the respective request returned * an error. * @param remote The queried remote entity's JID. * @param error The error condition. May be 0. * @param context A user defined context. */ virtual void handleAdhocError( const JID& remote, const Error* error, int context ) = 0; /** * This function is called in response to a remote command execution. * @param remote The remote entity's JID. * @param command The command being executed. * @param context A user defined context. */ virtual void handleAdhocExecutionResult( const JID& remote, const Adhoc::Command& command, int context ) = 0; }; } #endif // ADHOCHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/amp.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/amp.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/amp.h (revision 27490) @@ -1,243 +1,247 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_AMP ) + #ifndef AMP_H__ #define AMP_H__ #include "stanzaextension.h" #include "jid.h" #include #include #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0079} (Advanced Message Processing) * as a StanzaExtension. * * XEP Version: 1.2 * @author Jakob Schröter * @author Vincent Thomasset * @since 1.0 */ class GLOOX_API AMP : public StanzaExtension { public: /** * Possible types for a rule's condition. */ enum ConditionType { ConditionDeliver, /**< Ensures (non-)delivery of the message */ ConditionExpireAt, /**< Ensures delivery only before a certain time (UTC) */ ConditionMatchResource, /**< Ensures delivery only to a specific resource type */ ConditionInvalid /**< Invalid condition */ }; /** * Possible actions to take when the corresponding condition is met. */ enum ActionType { ActionAlert, /**< Sends back a message stanza with an 'alert' status */ ActionError, /**< Sends back a message stanza with an error type */ ActionDrop, /**< Silently ignore the message */ ActionNotify, /**< Sends back a message stanza with a 'notify' status */ ActionInvalid /**< Invalid action */ }; /** * Possible delivery rules. */ enum DeliverType { DeliverDirect, /**< The message would be immediately delivered to the intended * recipient or routed to the next hop. */ DeliverForward, /**< The message would be forwarded to another XMPP address or * account. */ DeliverGateway, /**< The message would be sent through a gateway to an address * or account on a non-XMPP system. */ DeliverNone, /**< The message would not be delivered at all (e.g., because * the intended recipient is offline and message storage is * not enabled). */ DeliverStored, /**< The message would be stored offline for later delivery * to the intended recipient. */ DeliverInvalid /**< Invalid deliver value */ }; /** * Possible resource matching rules. */ enum MatchResourceType { MatchResourceAny, /**< Destination resource matches any value, effectively * ignoring the intended resource. */ MatchResourceExact, /**< Destination resource exactly matches the intended * resource. */ MatchResourceOther, /**< Destination resource matches any value except for * the intended resource. */ MatchResourceInvalid /**< Invalid match-resource value */ }; /** * Available Stati. */ enum Status { StatusAlert, /**< The message is a reply to a @c Alert rule. */ StatusNotify, /**< The message is a reply to a @c Notify rule. */ StatusInvalid /**< Invalid status. */ }; /** * Describes an AMP rule. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Rule { public: /** * Creates a new AMP rule object with a condition of 'deliver'. * @param deliver The delivery type. * @param action The rule's action. */ Rule( DeliverType deliver, ActionType action ); /** * Creates a new AMP rule object with a condition of 'expire-at'. * @param date The expiry date/time in the format defined in @xep{0082}. * @param action The rule's action. */ Rule( const std::string& date, ActionType action ); /** * Creates a new AMP rule object with a condition of 'match-resource'. * @param match The match type. * @param action The rule's action. */ Rule( MatchResourceType match, ActionType action ); /** * Creates a new AMP rule object from the given strings. * @param condition The rule's condition. * @param action The rule's action. * @param value The rule's value. */ Rule( const std::string& condition, const std::string& action, const std::string& value ); /** * Destructor. */ ~Rule(); /** * Creates a Tag representation from the current rule. * @return A Tag representation of the rule. */ Tag* tag() const; private: ConditionType m_condition; union { DeliverType m_deliver; MatchResourceType m_matchresource; std::string* m_expireat; }; ActionType m_action; }; /** * A list of AMP rules. */ typedef std::list RuleList; /** * Constructs a new object. * @param perhop Indicates whether the ruleset should be applied to all hops, * or at the edge servers only. Default: @c false (edge servers only) */ AMP( bool perhop = false ); /** * Constructs a new object from the given Tag. * @param tag The AMP Tag to parse. */ AMP( const Tag* tag ); /** * Adds the given rule to the list of rules. * @param rule The rule to add. */ void addRule( const Rule* rule ); /** * Returns the current list of rules for inspection. * @return The current list of rules. */ const RuleList& rules() const { return m_rules; } /** * @brief Virtual Destructor. */ virtual ~AMP(); // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new AMP( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { AMP* a = new AMP(); a->m_perhop = m_perhop; RuleList::const_iterator it = m_rules.begin(); for( ; it != m_rules.end(); ++it ) a->m_rules.push_back( new Rule( *(*it) ) ); a->m_status = m_status; a->m_from = m_from; a->m_to = m_to; return a; } private: bool m_perhop; RuleList m_rules; Status m_status; JID m_from; JID m_to; }; } #endif // AMP_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/annotations.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/annotations.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/annotations.h (revision 27490) @@ -1,147 +1,150 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ANNOTATIONS ) #ifndef ANNOTATIONS_H__ #define ANNOTATIONS_H__ #include "macros.h" #include "annotationshandler.h" #include "privatexml.h" #include "privatexmlhandler.h" #include #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0145} (Annotations). * * You can use this class to store arbitrary notes about a roster item on the server * (and to retrieve them later on). * To retrieve all stored annotations for the current user's roster you have to create * a class which inherits from AnnotationsHandler. This handler receives retrieved notes. * * @code * class MyClass : public AnnotationsHandler * { * public: * // ... * void myFuncRetrieve(); * void myFuncStore(); * void handleAnnotations( const AnnotationsList &aList ); * * private: * Annotations* m_notes; * AnnotationsList m_list; * }; * * void MyClass::myFuncRetrieve() * { * [...] * m_notes = new Annotations( m_client ); * m_notes->requestAnnotations(); * } * * void MyClass::handleAnnotations( const AnnotationsList &aList ) * { * m_list = aList; * } * @endcode * * To store an additional note you have to fetch the currently stored notes first, * add your new note to the list of notes, and transfer them all together back to the * server. This protocol does not support storage of 'deltas', that is, when saving * notes all previously saved notes are overwritten. * * @code * void MyClass::myFuncStore() * { * annotationsListItem item; * item.jid = "me@example.com"; * item.cdate = "2006-02-04T15:23:21Z"; * item.note = "some guy at example.com"; * m_list.push_back( item ); * * item.jid = "abc@def.com"; * item.cdate = "2006-01-24T15:23:21Z"; * item.mdate = "2006-02-04T05:11:46Z"; * item.note = "some other guy"; * m_list.push_back( item ); * * m_notes->storeAnnotations( m_list ); * } * @endcode * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API Annotations : public PrivateXML, public PrivateXMLHandler { public: /** * Constructs a new Annotations object. * @param parent The ClientBase to use for communication. */ Annotations( ClientBase* parent ); /** * Virtual destructor. */ virtual ~Annotations(); /** * Use this function to store notes (annotations to contacts in a roster) on the server. * Make sure you store the whole set of annotations, not a 'delta'. * @param aList A list of notes to store. */ void storeAnnotations( const AnnotationsList& aList ); /** * Use this function to initiate retrieval of annotations. Use registerAnnotationsHandler() * to register an object which will receive the lists of notes. */ void requestAnnotations(); /** * Use this function to register a AnnotationsHandler. * @param ah The AnnotationsHandler which shall receive retrieved notes. */ void registerAnnotationsHandler( AnnotationsHandler* ah ) { m_annotationsHandler = ah; } /** * Use this function to un-register the AnnotationsHandler. */ void removeAnnotationsHandler() { m_annotationsHandler = 0; } // reimplemented from PrivateXMLHandler virtual void handlePrivateXML( const Tag* xml ); // reimplemented from PrivateXMLHandler virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult ); private: AnnotationsHandler* m_annotationsHandler; }; } #endif // ANNOTATIONS_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/annotationshandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/annotationshandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/annotationshandler.h (revision 27490) @@ -1,66 +1,69 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ANNOTATIONS ) #ifndef ANNOTATIONSHANDLER_H__ #define ANNOTATIONSHANDLER_H__ #include "macros.h" #include #include namespace gloox { /** * This describes a single note item. */ struct AnnotationsListItem { std::string jid; /**< The JID of the roster item this note is about */ std::string cdate; /**< Creation date of this note. */ std::string mdate; /**< Date of last modification of this note. */ std::string note; /**< The note. */ }; /** * A list of note items. */ typedef std::list AnnotationsList; /** * @brief A virtual interface which can be reimplemented to receive notes with help of * the Annotations object. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API AnnotationsHandler { public: /** * Virtual destructor. */ virtual ~AnnotationsHandler() {} /** * This function is called when notes arrive from the server. * @param aList A list of notes. */ virtual void handleAnnotations( const AnnotationsList &aList ) = 0; }; } #endif // ANNOTATIONSHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/attention.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/attention.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/attention.h (revision 27490) @@ -1,70 +1,73 @@ /* Copyright (c) 2009-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ATTENTION ) #ifndef ATTENTION_H__ #define ATTENTION_H__ #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0224} as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Attention : public StanzaExtension { public: /** * Constructs a new object from the given Tag. */ Attention(); /** * Virtual Destructor. */ virtual ~Attention(); // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* /*tag*/ ) const { return new Attention(); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Attention(); } }; } #endif// ATTENTION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/bob.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bob.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/bob.h (revision 27490) @@ -0,0 +1,131 @@ +/* + Copyright (c) 2019 by Jakob Schroeter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BOB ) + +#ifndef BOB_H__ +#define BOB_H__ + +#include "macros.h" + +#include "stanzaextension.h" + +// #include "bobhandler.h" + +#include + +namespace gloox +{ + + class Tag; + + /** + * @brief This is an implementation of Bits of Binary (@xep{0231}) as a StanzaExtension. + * + * XEP Version: 1.0 + * @author Adrien Destugues + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API BOB : public StanzaExtension + { + + public: + /** + * Constructs a new object from the given Tag. + * @param tag The Tag to parse. + */ + BOB( const Tag* tag = 0 ); + + /** + * Constructs a new object with the given namespace and priority. + * @param cid A Content-ID that matches the data below and can be mapped to a cid: URL as specified + * in RFC 2111 [10]. The 'cid' value SHOULD be of the form algo+hash@bob.xmpp.org, + * where the "algo" is the hashing algorithm used (e.g., "sha1" for the SHA-1 + * algorithm as specified in RFC 3174) and the "hash" is the hex + * output of the algorithm applied to the binary data itself. + * This will be calculated for you using SHA1 if left empty. + * @param type The value of the 'type' attribute MUST match the syntax specified in RFC 2045. + * That is, the value MUST include a top-level media type, the "/" character, + * and a subtype; in addition, it MAY include one or more optional parameters + * (e.g., the "audio/ogg" MIME type in the example shown below includes a + * "codecs" parameter as specified in RFC 4281 [14]). The "type/subtype" + * string SHOULD be registered in the IANA MIME Media Types Registry, + * but MAY be an unregistered or yet-to-be-registered value. + * @param data The binary data. It will be Base64-encoded for you. + * @param maxage A suggestion regarding how long (in seconds) to cache the data; + * the meaning matches the Max-Age attribute from RFC 2965. + */ + BOB( const std::string& cid, const std::string& type, + const std::string& data, int maxage ); + + /** + * Virtual Destructor. + */ + virtual ~BOB() {} + + /** + * Returns the binary data. + * @return The binary data. + */ + const std::string data() const; + + /** + * Returns the content ID. + * @return The content ID. + */ + const std::string cid() const { return m_cid; } + + /** + * Returns the content type. + * @return The content type. + */ + const std::string& type() const { return m_type; } + + /** + * Returns the maximum cache time in seconds. + * @return The maximum cache time in seconds. + */ + int maxage() const { return m_maxage; } + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new BOB( tag ); + } + + // reimplemented from StanzaExtension + virtual Tag* tag() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* clone() const + { + return new BOB( *this ); + } + + private: + std::string m_cid; + std::string m_type; + std::string m_data; + int m_maxage; + + }; + +} + +#endif // BOB_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/bob.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/bookmarkhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bookmarkhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/bookmarkhandler.h (revision 27490) @@ -1,82 +1,85 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BOOKMARKSTORAGE ) #ifndef BOOKMARKHANDLER_H__ #define BOOKMARKHANDLER_H__ #include "macros.h" #include #include namespace gloox { /** * This describes a single bookmarked URL item. */ struct BookmarkListItem { std::string name; /**< A human readable name of the bookmark. */ std::string url; /**< The URL of the bookmark. */ }; /** * This describes a single bookmarked conference item. */ struct ConferenceListItem { std::string name; /**< A human readable name of the conference room. */ std::string jid; /**< The address of the room. */ std::string nick; /**< The nick name to use in this room. */ std::string password; /**< The password to use for a protected room. */ bool autojoin; /**< The conference shall be joined automatically on login. */ }; /** * A list of URL items. */ typedef std::list BookmarkList; /** * A list of conference items. */ typedef std::list ConferenceList; /** * @brief A virtual interface which can be reimplemented to receive bookmarks with help of a * BookmarkStorage object. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API BookmarkHandler { public: /** * Virtual Destructor. */ virtual ~BookmarkHandler() {} /** * This function is called when bookmarks arrive from the server. * @param bList A list of URL bookmarks. * @param cList A list of conference bookmarks. */ virtual void handleBookmarks( const BookmarkList &bList, const ConferenceList &cList ) = 0; }; } #endif // BOOKMARKHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/bookmarkstorage.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bookmarkstorage.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/bookmarkstorage.h (revision 27490) @@ -1,150 +1,153 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BOOKMARKSTORAGE ) #ifndef BOOKMARKSTORAGE_H__ #define BOOKMARKSTORAGE_H__ #include "macros.h" #include "bookmarkhandler.h" #include "privatexml.h" #include "privatexmlhandler.h" #include #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0048} (Bookmark Storage). * * You can use this class to store bookmarks to multi-user chat rooms or ordinary URLs * on the server (and to retrieve them later on). * To retrieve all stored bookmarks for the current user you have to create a class which * inherits from BookmarkHandler. This handler receives retrieved bookmarks. * * @code * class MyClass : public BookmarkHandler * { * public: * // ... * void myFuncRetrieve(); * void myFuncStore(); * void handleBookmarks( const BookmarkList &bList, const ConferenceList &cList ); * * private: * BookmarkStorage* m_bs; * BookmarkList m_bList; * ConferenceList m_cList; * }; * * void MyClass::myFuncRetrieve() * { * m_bs = new BookmarkStorage( m_client ); * m_bs->requestBookmarks(); * } * * void MyClass::handleBookmarks( const BookmarkList &bList, const ConferenceList &cList ) * { * m_bList = bList; * m_cList = cList; * } * @endcode * * * To store additional bookmarks you have to fetch the currently stored ones first, * add your new bookmark to the list, and transfer them all together back to the * server. This protocol does not support storage of 'deltas', that is, when saving * bookmarks all previously saved bookmarks are overwritten. * * @code * void MyClass::myFuncStore() * { * BookmarkListItem bi; * bi.url = "http://www.jabber.org"; * bi.name = "my favourite IM protocol"; * m_bList.push_back( bi ); * * conferenceListItem ci * ci.name = "jabber/xmpp development room"; * ci.jid = "jdev@conference.jabber.org"; * ci.nick = "myNick"; * ci.password = EmptyString; * ci.autojoin = true; * m_cList.push_back( ci ); * * m_bs->storeBookmarks( m_bList, m_cList ); * } * @endcode * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API BookmarkStorage : public PrivateXML, public PrivateXMLHandler { public: /** * Constructs a new BookmarkStorage object. * @param parent The ClientBase to use for communication. */ BookmarkStorage( ClientBase* parent ); /** * Virtual destructor. */ virtual ~BookmarkStorage(); /** * Use this function to store a number of URL and conference bookmarks on the server. * Make sure you store the whole set of bookmarks, not a 'delta'. * @param bList A list of URLs to store. * @param cList A list of conferences to store. */ void storeBookmarks( const BookmarkList& bList, const ConferenceList& cList ); /** * Use this function to initiate retrieval of bookmarks. Use registerBookmarkHandler() * to register an object which will receive the lists of bookmarks. */ void requestBookmarks(); /** * Use this function to register a BookmarkHandler. * @param bmh The BookmarkHandler which shall receive retrieved bookmarks. */ void registerBookmarkHandler( BookmarkHandler* bmh ) { m_bookmarkHandler = bmh; } /** * Use this function to un-register the BookmarkHandler. */ void removeBookmarkHandler() { m_bookmarkHandler = 0; } // reimplemented from PrivateXMLHandler virtual void handlePrivateXML( const Tag* xml ); // reimplemented from PrivateXMLHandler virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult ); private: BookmarkHandler* m_bookmarkHandler; }; } #endif // BOOKMARKSTORAGE_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/bytestream.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bytestream.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/bytestream.h (revision 27490) @@ -1,180 +1,186 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef BYTESTREAM_H__ #define BYTESTREAM_H__ #include "jid.h" #include "logsink.h" #include namespace gloox { class BytestreamDataHandler; /** * @brief An abstraction of a single bytestream. * * Used as a base class for InBand Bytestreams as well as SOCKS5 Bytestreams. * You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Bytestream { public: /** * Available stream types. */ enum StreamType { S5B, /**< SOCKS5 Bytestream */ IBB /**< In-Band Bytestream */ }; /** * Creates a new Bytestream. * @param type The stream type. * @param logInstance A Logsink to use for logging. Obtain it from ClientBase::logInstance(). * @param initiator The initiator of the stream (usually the sender). * @param target The target of the stream (usually the receiver). * @param sid The stream's ID. */ Bytestream( StreamType type, LogSink& logInstance, const JID& initiator, const JID& target, const std::string& sid ) : m_handler( 0 ), m_logInstance( logInstance ), m_initiator( initiator ), m_target( target ), m_type( type ), m_sid( sid ), m_open( false ) {} /** * Virtual destructor. */ virtual ~Bytestream() {} /** * Returns whether the bytestream is open, that is, accepted by both parties and ready * to send/receive data. * @return Whether or not the bytestream is open. */ bool isOpen() const { return m_open; } /** * This function starts the connection process. + * @param timeout The timeout to use for select() in microseconds. Default of -1 means blocking. + * This parameter has no effect in IBB modes. * @return @b True if a connection to a remote entity could be established, @b false * otherwise. * @note If @b false is returned you should pass this Bytestream object * to SIProfileFT::dispose() for deletion. * @note Make sure you have a BytestreamDataHandler registered (using * registerBytestreamDataHandler()) before calling this function. */ - virtual bool connect() = 0; + virtual bool connect( int timeout = -1 ) = 0; /** * Closes the bytestream. */ virtual void close() = 0; /** * Use this function to send a chunk of data over an open bytestream. * If the stream is not open or has been closed again * (by the remote entity or locally), nothing is sent and @b false is returned. * This function does any base64 encoding for you, if necessary. * @param data The block of data to send. * @return @b True if the data has been sent (no guarantee of receipt), @b false * in case of an error. */ virtual bool send( const std::string& data ) = 0; /** * Call this function repeatedly to receive data. You should even do this * if you use the bytestream to merely @b send data. May be a NOOP, depending on the actual * stream type. * @param timeout The timeout to use for select in microseconds. Default of -1 means blocking. * @return The state of the connection. */ virtual ConnectionError recv( int timeout = -1 ) = 0; /** * Lets you retrieve the stream's ID. * @return The stream's ID. */ const std::string& sid() const { return m_sid; } /** * Returns the stream's type. * @return The stream's type. */ StreamType type() const { return m_type; } /** * Returns the target entity's JID. If this bytestream is remote-initiated, this is * the local JID. If it is local-initiated, this is the remote entity's JID. * @return The target's JID. */ const JID& target() const { return m_target; } /** * Returns the initiating entity's JID. If this bytestream is remote-initiated, this is * the remote entity's JID. If it is local-initiated, this is the local JID. * @return The initiator's JID. */ const JID& initiator() const { return m_initiator; } /** * Use this function to register an object that will receive any notifications from * the Bytestream instance. Only one BytestreamDataHandler can be registered * at any one time. * @param bdh The BytestreamDataHandler-derived object to receive notifications. */ void registerBytestreamDataHandler( BytestreamDataHandler* bdh ) { m_handler = bdh; } /** * Removes the registered BytestreamDataHandler. */ void removeBytestreamDataHandler() { m_handler = 0; } protected: /** A handler for incoming data and open/close events. */ BytestreamDataHandler* m_handler; /** A LogSink instance to use for logging. */ const LogSink& m_logInstance; /** The initiator's JID. */ const JID m_initiator; /** The target's JID. */ const JID m_target; /** The stream type. */ StreamType m_type; /** The stream ID. */ std::string m_sid; /** Indicates whether or not the stream is open. */ bool m_open; private: Bytestream& operator=( const Bytestream& ); }; } #endif // BYTESTREAM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/bytestreamdatahandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bytestreamdatahandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/bytestreamdatahandler.h (revision 27490) @@ -1,92 +1,96 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef BYTESTREAMDATAHANDLER_H__ #define BYTESTREAMDATAHANDLER_H__ #include "macros.h" #include namespace gloox { class Bytestream; class IQ; /** * @brief A virtual interface that allows implementors to receive data * sent over a SOCKS5 Bytestream as defined in @xep{0066}, or an In-Band Bytestream * as defined in @xep{0047}. You'll also need it for sending of data. * * An BytestreamDataHandler is registered with a Bytestream. * * See SIProfileFT for more information regarding file transfer. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API BytestreamDataHandler { public: /** * Virtual destructor. */ virtual ~BytestreamDataHandler() {} /** * Reimplement this function to receive data which is sent over the bytestream. * The data received here is (probably) only a single chunk of the complete data (depending * on the amount of data you want to send). * @param bs The bytestream. * @param data The actual stream payload. */ virtual void handleBytestreamData( Bytestream* bs, const std::string& data ) = 0; /** * Reimplement this function to be notified when the remote end has * received and acknowledged a single data packet. This packet may be * smaller than the chunk that was fed into Bytream::send() due to internal * chunk size limits. so this callback may be called multiple times for * each call to Bytestream::send(). it can be used to implement burst limits. * @param bs The bytestream. * @since 1.0.20 */ - virtual void handleBytestreamDataAck( Bytestream* bs ) {} + virtual void handleBytestreamDataAck( Bytestream* bs ) = 0; /** * Notifies about an error occuring while using a bytestream. * When this handler is called the stream has already been closed. * @param bs The bytestream. * @param iq The error stanza. */ virtual void handleBytestreamError( Bytestream* bs, const IQ& iq ) = 0; /** * Notifies the handler that the given bytestream has been acknowledged * and is ready to send/receive data. * @param bs The opened bytestream. */ virtual void handleBytestreamOpen( Bytestream* bs ) = 0; /** * Notifies the handler that the given bytestream has been closed. * @param bs The closed bytestream. */ virtual void handleBytestreamClose( Bytestream* bs ) = 0; }; } #endif // BYTESTREAMDATAHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/bytestreamhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/bytestreamhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/bytestreamhandler.h (revision 27490) @@ -1,90 +1,94 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef BYTESTREAMHANDLER_H__ #define BYTESTREAMHANDLER_H__ #include "macros.h" #include "jid.h" #include "bytestream.h" #include "iq.h" namespace gloox { /** * @brief A virtual interface that allows to receive new incoming Bytestream requests * from remote entities. * * You should not need to use this interface directly. * * See SIProfileFT on how to implement file transfer in general. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API BytestreamHandler { public: /** * Virtual destructor. */ virtual ~BytestreamHandler() {} /** * Notifies the implementor of a new incoming bytestream request. * You have to call either * BytestreamManager::acceptBytestream() or * BytestreamManager::rejectBytestream(), to accept or reject the bytestream * request, respectively. * @param sid The bytestream's id, to be passed to BytestreamManager::acceptBytestream() * and BytestreamManager::rejectBytestream(), respectively. * @param from The remote initiator of the bytestream request. */ virtual void handleIncomingBytestreamRequest( const std::string& sid, const JID& from ) = 0; /** * Notifies the implementor of a new incoming bytestream. The bytestream is not yet ready to * send data. * To initialize the bytestream and to prepare it for data transfer, register a * BytestreamDataHandler with it and call its connect() method. * To not block your application while the data transfer lasts, you most * likely want to put the bytestream into its own thread or process (before calling connect() on it). * It is safe to do so without additional synchronization. * When you are finished using the bytestream, use SIProfileFT::dispose() to get rid of it. * @param bs The bytestream. */ virtual void handleIncomingBytestream( Bytestream* bs ) = 0; /** * Notifies the implementor of successful establishing of an outgoing bytestream request. * The stream has been accepted by the remote entity and is ready to send data. * The BytestreamHandler does @b not become the owner of the Bytestream object. * Use SIProfileFT::dispose() to get rid of the bytestream object after it has been closed. * @param bs The new bytestream. */ virtual void handleOutgoingBytestream( Bytestream* bs ) = 0; /** * Notifies the handler of errors occuring when a bytestream was requested. * For example, if the remote entity does not implement SOCKS5 bytestreams. * @param iq The error stanza. * @param sid The request's SID. */ virtual void handleBytestreamError( const IQ& iq, const std::string& sid ) = 0; }; } #endif // BYTESTREAMHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/capabilities.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/capabilities.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/capabilities.h (revision 27490) @@ -1,132 +1,137 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CAPABILITIES ) + #ifndef CAPABILITIES_H__ #define CAPABILITIES_H__ #include "disconodehandler.h" #include "stanzaextension.h" #include "tag.h" #include namespace gloox { class Disco; class Tag; /** * @brief This is an implementation of @xep{0115} (Entity Capabilities). * - * XEP Version: 1.5-15 + * XEP Version: 1.5 + * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Capabilities : public StanzaExtension, public DiscoNodeHandler { public: /** * Constructs a new object and fills it according to the parameters. * @param disco The current Client's Disco object. */ Capabilities( Disco* disco ); /** * Constructs a new object from the given Tag. * @param tag The Tag to parse. */ Capabilities( const Tag* tag = 0 ); /** * Virtual Destructor. */ virtual ~Capabilities(); /** * Returns the client's identifying node. * @return The node. */ const std::string& node() const { return m_node; } /** * Sets the client's identifying node. * @param node The node. */ void setNode( const std::string& node ) { m_node = node; } /** * Returns the client's identifying ver string. * @return The ver string. */ const std::string ver() const; // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Capabilities( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Capabilities( *this ); } // reimplemented from DiscoNodeHandler virtual StringList handleDiscoNodeFeatures( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::IdentityList handleDiscoNodeIdentities( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::ItemList handleDiscoNodeItems( const JID& from, const JID& to, const std::string& node = EmptyString ); private: /** * Returns the hash function used for creating the caps info. * @return The current hash function's name. */ const std::string& hash() const { return m_hash; } /** * Use this function to set the hash function to use. * @param hash The hash function. * @todo Convert to using an enum and make public. */ void setHash( const std::string& hash ) { m_hash = hash; } static std::string generate( const Disco::IdentityList& identities, const StringList& features, const DataForm* form = 0 ); static std::string generate( const Disco::Info* info ); static std::string generate( const Disco* disco ); Disco* m_disco; std::string m_node; std::string m_hash; std::string m_ver; bool m_valid; }; } #endif // CAPABILITIES_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/carbons.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/carbons.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/carbons.h (revision 27490) @@ -1,185 +1,189 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CARBONS ) + #ifndef CARBONS_H__ #define CARBONS_H__ #include "macros.h" #include "stanzaextension.h" #include "tag.h" namespace gloox { class Forward; /** * @brief An implementation of Message Carbons (@xep{0280}) as a StanzaExtension. * * @section enable Enable Mesage Carbons * * Before using Message Carbons you have to check your server for support of the extension. * You can do so using Disco::getDiscoInfo(). You can check the result (in DiscoHandler::handleDiscoInfo()) * for a feature of @c XMLNS_MESSAGE_CARBONS (use Disco::Info::hasFeature()). * * If the feature exists, you can enable Message Carbons with the server. * * @code * Client cb( ... ); * // ... * * // setup * cb.registerStanzaExtension( new Forward() ); // required for Message Carbons support * cb.registerStanzaExtension( new Carbons() ); * // ... * * // enable Message Carbons * IQ iq( IQ::Set, JID() ); // empty JID * iq.addExtension( new Carbons( Carbons::Enable ) ); * cb.send( iq, MyIqHandler, 1 ); // myIqHandler will be notified of the result with the given context ('1' in this case). * @endcode * * @note Once enabled, the server will automatically send all received and sent messages @b of @b type @c Chat to all other Carbons-enabled resources of * the current account. You have to make sure that you actually send messages of type @c Chat. The default is currently @c Normal. * * @section disable Disable Message Carbons * * Once enabled, you can easily disable Message carbons. The code is almost identical to the code used to enable the feature, * except that you use a Carbons::Type of Carbons::Disable when you add the Carbons extension to the IQ: * @code * iq.addExtension( new Carbons( Carbons::Disable ) ); * @endcode * * @section private Prevent carbon copies for a single message * * To disable carbon copies for a single message, add a Carbons extension of type Private: * * @code * Message msg( Message::Chat, ... ); * // ... * msg.addExtension( new Carbons( Carbons::Private ) ); * @endcode * * The server will not copy this message to your other connected resources. * * @section access Access received carbon copies * * When receiving a message (sent by either another connected client of the current user, or by a 3rd party), a carbon copy will * have the following characteristics: * @li The message's @c from attribute will be the @b bare JID of the @b receiving entity. * @li The message's @c from attribute will be the @b full JID of the @b receiving entity. * @li The message contains a Carbons StanzaExtension. This extension contains the original message with the @b original * @c from/to attributes. * * Some sample code: * @code * bool Myclass::handleMessage( const Message& msg, MessageSession* ) * { * if( msg.hasEmbeddedStanza() ) // optional, saves some processing time when there is no Carbons extension * { * const Carbons* carbon = msg.findExtension( ExtCarbons ); * if( carbon && carbon->embeddedStanza() ) * { * Message* embeddedMessage = static_cast( carbon->embeddedStanza() ); * } * } * } * @endcode * * You can also determine whether a carbon was sent by a 3rd party or a different client of the current user by checking the return value of Carbons::type(). * @code * Carbons* c = msg.findExtension<...>( ... ); * // check that c is valid * * if( c->type() == Carbons::Received ) * // Message was sent by a 3rd party * else if( c->type() == Carbons::Sent ) * // Message was sent by a different client of the current user * @endcode * * XEP Version: 0.8 * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API Carbons : public StanzaExtension { public: /** * The types of Message Carbons stanza extensions. */ enum Type { Received, /**< Indicates that the message received has been sent by a third party. */ Sent, /**< Indicates that the message received has been sent by one of the user's own resources. */ Enable, /**< Indicates that the sender wishes to enable carbon copies. */ Disable, /**< Indicates that the sender wishes to disable carbon copies. */ Private, /**< Indicates that the sender does not want carbon copies to be sent for this message. */ Invalid /**< Invalid type. */ }; /** * Constructs a new Carbons instance of the given type. * You should only use the @c Enable, @c Disable and @c Private types. * @param type The Carbons type to create. */ Carbons( Type type ); /** * Constructs a new Carbons instance from the given tag. * @param tag The Tag to create the Carbons instance from. */ Carbons( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~Carbons(); /** * Returns the current instance's type. * @return The intance's type. */ Type type() const { return m_type; } // reimplemented from StanzaExtension virtual Stanza* embeddedStanza() const; // reimplemented from StanzaExtension virtual Tag* embeddedTag() const; // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Carbons( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; private: Forward* m_forward; Type m_type; }; } #endif // CARBONS_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/chatmarker.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatmarker.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatmarker.h (revision 27490) @@ -0,0 +1,93 @@ +/* + Copyright (c) 2018-2019 by Jakob Schröter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATMARKER ) + +#ifndef CHATMARKER_H__ +#define CHATMARKER_H__ + +#include "gloox.h" +#include "stanzaextension.h" + +#include + +namespace gloox +{ + + class Tag; + + /** + * @brief An implementation of Chat Markers (@xep{0333}) as a StanzaExtension. + * + * XEP Version: 0.3 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API ChatMarker : public StanzaExtension + { + public: + + /** + * Constructs a new object from the given Tag. + * @param tag A Tag to parse. + */ + ChatMarker( const Tag* tag ); + + /** + * Constructs a new object of the given type. + * @param type The chat type. + */ + ChatMarker( ChatMarkerType type ) + : StanzaExtension( ExtChatMarkers ), m_marker( type ) + {} + + /** + * Virtual destructor. + */ + virtual ~ChatMarker() {} + + /** + * Returns the object's type. + * @return The object's type. + */ + ChatMarkerType marker() const { return m_marker; } + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new ChatMarker( tag ); + } + + // reimplemented from StanzaExtension + Tag* tag() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* clone() const + { + return new ChatMarker( *this ); + } + + private: + ChatMarkerType m_marker; + + }; + +} + +#endif // CHATMARKER_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/chatmarker.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerfilter.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerfilter.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerfilter.h (revision 27490) @@ -0,0 +1,109 @@ +/* + Copyright (c) 2005-2019 by Jakob Schröter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATMARKER ) + +#ifndef CHATMARKERFILTER_H__ +#define CHATMARKERFILTER_H__ + +#include "messagefilter.h" +#include "gloox.h" + +namespace gloox +{ + + class Tag; + class ChatMarkerHandler; + class MessageSession; + class Message; + + /** + * @brief This class adds Chat Markers (@xep{0333}) support to a MessageSession. + * + * This implementation of Chat States is fully transparent to the user of the class. + * If the remote entity does not request chat markers, ChatMarkerFilter will not send + * any, even if the user requests it. (This is required by the protocol specification.) + * You MUST annouce this capability by use of Disco (associated namespace is XMLNS_CHAT_STATES). + * (This is also required by the protocol specification.) + * + * @note You must register ChatMarker as a StanzaExtension by calling + * ClientBase::registerStanzaExtension() for notifications to work. + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API ChatMarkerFilter : public MessageFilter + { + public: + /** + * Constructs a new Chat State filter for a MessageSession. + * @param parent The MessageSession to decorate. + */ + ChatMarkerFilter( MessageSession* parent ); + + /** + * Virtual destructor. + */ + virtual ~ChatMarkerFilter(); + + /** + * Use this function to set a chat marker as defined in @xep{0085}. + * @note The Spec states that Chat States shall not be sent to an entity + * which did not request them. Reasonable effort is taken in this function to + * avoid spurious marker sending. You should be safe to call this even if Message + * Events were not requested by the remote entity. However, + * calling setChatState( CHAT_STATE_COMPOSING ) for every keystroke still is + * discouraged. ;) + * @param marker The marker to set. + */ + void setMessageMarkable(); + + /** + * The ChatMarkerHandler registered here will receive Chat States according + * to @xep{0085}. + * @param csh The ChatMarkerHandler to register. + */ + void registerChatMarkerHandler( ChatMarkerHandler* csh ) + { m_chatMarkerHandler = csh; } + + /** + * This function clears the internal pointer to the ChatMarkerHandler. + * Chat States will not be delivered anymore after calling this function until another + * ChatMarkerHandler is registered. + */ + void removeChatMarkerHandler() + { m_chatMarkerHandler = 0; } + + // reimplemented from MessageFilter + virtual void decorate( Message& msg ); + + // reimplemented from MessageFilter + virtual void filter( Message& msg ); + + protected: + /** A handler for incoming chat marker changes. */ + ChatMarkerHandler* m_chatMarkerHandler; + + /** Holds the marker sent last. */ + ChatMarkerType m_lastSent; + + /** Indicates whether or not chat markers are currently enabled. */ + bool m_enableChatMarkers; + + }; + +} + +#endif // CHATMARKERFILTER_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerfilter.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerhandler.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerhandler.h (revision 27490) @@ -0,0 +1,56 @@ +/* + Copyright (c) 2005-2019 by Jakob Schröter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATMARKER ) + +#ifndef CHATMARKERHANDLER_H__ +#define CHATMARKERHANDLER_H__ + +#include "gloox.h" + +namespace gloox +{ + + class JID; + + /** + * @brief A virtual interface that enables an object to be notified about incoming + * Chat Markers (@xep{0333}). + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API ChatMarkerHandler + { + public: + /** + * Virtual Destructor. + */ + virtual ~ChatMarkerHandler() {} + + /** + * Notifies the ChatMarkerHandler that a message has been marked by the remote + * contact. The occurrence of the 'markable' tag does not cause this handler to be called. + * @param from The originator of the Event. + * @param marker The marker type. + * @param id The marked message's ID. + */ + virtual void handleChatMarker( const JID& from, ChatMarkerType type, const std::string& id ) = 0; + + }; + +} + +#endif // CHATMARKERHANDLER_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/chatmarkerhandler.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/chatstate.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatstate.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatstate.h (revision 27490) @@ -1,87 +1,91 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATSTATE ) + #ifndef CHATSTATE_H__ #define CHATSTATE_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief An implementation of Chat State Notifications (@xep{0085}) as a StanzaExtension. * * @author Vincent Thomasset * @author Jakob Schröter * @since 1.0 */ class GLOOX_API ChatState : public StanzaExtension { public: /** * Constructs a new object from the given Tag. * @param tag A Tag to parse. */ ChatState( const Tag* tag ); /** * Constructs a new object of the given type. * @param state The chat state. */ ChatState( ChatStateType state ) : StanzaExtension( ExtChatState ), m_state( state ) {} /** * Virtual destructor. */ virtual ~ChatState() {} /** * Returns the object's state. * @return The object's state. */ ChatStateType state() const { return m_state; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new ChatState( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new ChatState( *this ); } private: ChatStateType m_state; }; } #endif // CHATSTATE_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/chatstatefilter.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatstatefilter.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatstatefilter.h (revision 27490) @@ -1,105 +1,109 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATSTATE ) + #ifndef CHATSTATEFILTER_H__ #define CHATSTATEFILTER_H__ #include "messagefilter.h" #include "gloox.h" namespace gloox { class Tag; class ChatStateHandler; class MessageSession; class Message; /** * @brief This class adds Chat State Notifications (@xep{0085}) support to a MessageSession. * * This implementation of Chat States is fully transparent to the user of the class. * If the remote entity does not request chat states, ChatStateFilter will not send * any, even if the user requests it. (This is required by the protocol specification.) * You MUST annouce this capability by use of Disco (associated namespace is XMLNS_CHAT_STATES). * (This is also required by the protocol specification.) * * @note You must register ChatState as a StanzaExtension by calling * ClientBase::registerStanzaExtension() for notifications to work. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API ChatStateFilter : public MessageFilter { public: /** * Constructs a new Chat State filter for a MessageSession. * @param parent The MessageSession to decorate. */ ChatStateFilter( MessageSession* parent ); /** * Virtual destructor. */ virtual ~ChatStateFilter(); /** * Use this function to set a chat state as defined in @xep{0085}. * @note The Spec states that Chat States shall not be sent to an entity * which did not request them. Reasonable effort is taken in this function to * avoid spurious state sending. You should be safe to call this even if Message * Events were not requested by the remote entity. However, * calling setChatState( CHAT_STATE_COMPOSING ) for every keystroke still is * discouraged. ;) * @param state The state to set. */ void setChatState( ChatStateType state ); /** * The ChatStateHandler registered here will receive Chat States according * to @xep{0085}. * @param csh The ChatStateHandler to register. */ void registerChatStateHandler( ChatStateHandler* csh ) { m_chatStateHandler = csh; } /** * This function clears the internal pointer to the ChatStateHandler. * Chat States will not be delivered anymore after calling this function until another * ChatStateHandler is registered. */ void removeChatStateHandler() { m_chatStateHandler = 0; } // reimplemented from MessageFilter virtual void decorate( Message& msg ); // reimplemented from MessageFilter virtual void filter( Message& msg ); protected: /** A handler for incoming chat state changes. */ ChatStateHandler* m_chatStateHandler; /** Holds the state sent last. */ ChatStateType m_lastSent; /** Indicates whether or not chat states are currently enabled. */ bool m_enableChatStates; }; } #endif // CHATSTATEFILTER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/chatstatehandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/chatstatehandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/chatstatehandler.h (revision 27490) @@ -1,51 +1,55 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CHATSTATE ) + #ifndef CHATSTATEHANDLER_H__ #define CHATSTATEHANDLER_H__ #include "gloox.h" namespace gloox { class JID; /** * @brief A virtual interface that enables an object to be notified about * a remote entity's Chat States (@xep{0085}). * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API ChatStateHandler { public: /** * Virtual Destructor. */ virtual ~ChatStateHandler() {} /** * Notifies the ChatStateHandler that a different chat state has been set by the remote * contact. * @param from The originator of the Event. * @param state The chat state set by the remote entity. */ virtual void handleChatState( const JID& from, ChatStateType state ) = 0; }; } #endif // CHATSTATEHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/clientbase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/clientbase.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/clientbase.h (revision 27490) @@ -1,1113 +1,1180 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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 CLIENTBASE_H__ #define CLIENTBASE_H__ #include "macros.h" #include "gloox.h" +// #include "connectionbase.h" #include "eventdispatcher.h" #include "iqhandler.h" #include "jid.h" #include "logsink.h" #include "mutex.h" +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) +#include "pinghandler.h" +#endif // GLOOX_MINIMAL #include "taghandler.h" #include "statisticshandler.h" #include "tlshandler.h" #include "compressiondatahandler.h" #include "connectiondatahandler.h" #include "parser.h" #include "atomicrefcount.h" #include #include #include -#if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) +#if defined( _WIN32 ) #include #define SECURITY_WIN32 #include #endif namespace gloox { class Disco; class EventHandler; class Event; class Tag; class IQ; class Message; class Presence; class Subscription; - class MessageSessionHandler; class ConnectionListener; class MessageHandler; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) class MessageSession; + class MessageSessionHandler; +#endif // GLOOX_MINIMAL class PresenceHandler; class SubscriptionHandler; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) class MUCInvitationHandler; +#endif // GLOOX_MINIMAL class TagHandler; class TLSBase; class ConnectionBase; class CompressionBase; class StanzaExtensionFactory; /** * @brief This is the common base class for a Jabber/XMPP Client and a Jabber Component. * * It manages connection establishing, authentication, filter registration and invocation. * You should normally use Client for client connections and Component for component connections. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API ClientBase : public TagHandler, public ConnectionDataHandler, public CompressionDataHandler, public TLSHandler, +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) + public PingHandler, +#endif // GLOOX_MINIMAL public IqHandler - { + { friend class RosterManager; public: /** * Constructs a new ClientBase. * You should not need to use this class directly. Use Client or Component instead. * @param ns The namespace which qualifies the stream. Either jabber:client or jabber:component:* * @param server The server to connect to. * @param port The port to connect to. The default of -1 means to look up the port via DNS SRV * or to use a default port of 5222 as defined in XMPP Core. */ ClientBase( const std::string& ns, const std::string& server, int port = -1 ); /** * Constructs a new ClientBase. * You should not need to use this class directly. Use Client or Component instead. * @param ns The namespace which qualifies the stream. Either jabber:client or jabber:component:* * @param password The password to use for further authentication. * @param server The server to connect to. * @param port The port to connect to. The default of -1 means to look up the port via DNS SRV * or to use a default port of 5222 as defined in XMPP: Core. */ ClientBase( const std::string& ns, const std::string& password, const std::string& server, int port = -1 ); /** * Virtual destrcuctor. */ virtual ~ClientBase(); /** * Initiates the connection to a server. This function blocks as long as a connection is * established. * You can have the connection block 'til the end of the connection, or you can have it return * immediately. If you choose the latter, its your responsibility to call @ref recv() every now * and then to actually receive data from the socket and to feed the parser. * @param block @b True for blocking, @b false for non-blocking connect. Defaults to @b true. + * @param timeout The timeout in microseconds to use for select(). Default of -1 means blocking. * @return @b False if prerequisits are not met (server not set) or if the connection was refused, * @b true otherwise. * @note Since 0.9 @link ConnectionListener::onDisconnect() onDisconnect() @endlink is called * in addition to a return value of @b false. */ - bool connect( bool block = true ); + bool connect( bool block = true, int timeout = -1 ); /** * Use this periodically to receive data from the socket and to feed the parser. You need to use * this only if you chose to connect in non-blocking mode. - * @param timeout The timeout in microseconds to use for select. Default of -1 means blocking + * @param timeout The timeout in microseconds to use for select. Default of -1 means blocking. * until data was available. * @return The state of the connection. */ virtual ConnectionError recv( int timeout = -1 ); /** * Reimplement this function to provide a username for connection purposes. * @return The username. */ virtual const std::string& username() const { return m_jid.username(); } /** * Returns the current Jabber ID. If an authorization ID has been set (using setAuthzid()) * this authzid is returned. * @return A reference to the Jabber ID. * @note If you change the server part of the JID, the server of the connection is not synced. * You have to do that manually using @ref setServer(). */ const JID& jid() { return m_authzid ? m_authzid : m_jid; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_WEBSOCKET ) + /** + * Switches usage of websocket transport on/off. Default: off. + * @param ws Whether to switch websocket transport usage on or off. + */ + void setWebsocket( bool ws ) { m_websocket = ws; } +#endif // GLOOX_MINIMAL + /** * Switches usage of SASL on/off. Default: on. SASL should only be disabled if there are * problems with using it, and if an alternative authentication method exists. * @param sasl Whether to switch SASL usage on or off. */ void setSasl( bool sasl ) { m_sasl = sasl; } /** * Sets the TLS policy. Default: TLS will be used if available. TLS should only be - * disabled if there are problems with using it. + * disabled if there are problems with using it. Also sets the minimum required/requested + * TLS version for the connection. * @param tls The TLS policy. + * @param tlsVersion The TLS version to require/request. Default: TLS v1. */ - void setTls( TLSPolicy tls ) { m_tls = tls; } + void setTls( TLSPolicy tls, TLSVersion tlsVersion = TLSv1 ) { m_tls = tls; m_tlsVersion = tlsVersion; } /** * Switches usage of Stream Compression on/off (if available). Default: on if available. Stream * Compression should only be disabled if there are problems with using it. * @param compression Whether to switch Stream Compression usage on or off. */ void setCompression( bool compression ) { m_compress = compression; } /** * Sets the port to connect to. This is not necessary if either the default port (5222) is used * or SRV records exist which will be resolved. * @param port The port to connect to. */ void setPort( int port ) { m_port = port; } /** * Sets the XMPP server to connect to. * @param server The server to connect to. Either IP or fully qualified domain name. * @note If you change the server, the server part of the JID is not synced. You have to do that * manually using @ref jid() and @ref JID::setServer(). * @note This function also sets the server of the Connection(Base) in use. */ void setServer( const std::string &server ); /** * Sets the password to use to connect to the XMPP server. * @param password The password to use for authentication. */ void setPassword( const std::string &password ) { m_password = password; } /** * Returns the current prepped server. * @return The server used to connect. */ const std::string& server() const { return m_server; } /** * Returns whether SASL is currently enabled (not necessarily used). * @return The current SASL status. */ bool sasl() const { return m_sasl; } /** * Returns whether TLS is currently enabled (not necessarily used). * @return The current TLS status. */ TLSPolicy tls() const { return m_tls; } /** + * Returns the minimum required TLS version (not necessarily the one in use). + * @return The TLS version. + */ + TLSVersion tlsVersion() const { return m_tlsVersion; } + + /** * Returns whether Stream Compression is currently enabled (not necessarily used). * @return The current Stream Compression status. */ bool compression() const { return m_compress; } /** * Returns the port. The default of -1 means that the actual port will be looked up using * SRV records, or the XMPP default port of 5222 will be used. * @return The port used to connect. */ int port() const { return m_port; } /** * Returns the current password. * @return The password used to connect. */ virtual const std::string& password() const { return m_password; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) /** * This function gives access to the @c Disco object. * @return A pointer to the Disco object. */ virtual Disco* disco() const { return m_disco; } +#endif // GLOOX_MINIMAL /** * Creates a string which is unique in the current instance and * can be used as an ID for queries. * @return A unique string suitable for query IDs. */ const std::string getID(); /** * Sends the given Tag over an established connection. * The ClientBase object becomes the owner of this Tag and will delete it after sending it. * You should not rely on the existance of the Tag after it's been sent. If you still need * it after sending it, use Tag::clone() to create a deep copy. * @param tag The Tag to send. */ void send( Tag* tag ); /** * Sends the given IQ stanza. The given IqHandler is registered to be notified of replies. This, * of course, only works for IQs of type get or set. An ID is added if necessary. * @param iq The IQ stanza to send. * @param ih The handler to register for replies. * @param context A value that allows for restoring context. * @param del Whether or not delete the IqHandler object after its being called. * Default: @b false. */ void send( IQ& iq, IqHandler* ih, int context, bool del = false ); /** * A convenience function that sends the given IQ stanza. * @param iq The IQ stanza to send. */ void send( const IQ& iq ); /** * A convenience function that sends the given Message stanza. * @param msg The Message stanza to send. */ void send( const Message& msg ); /** * A convenience function that sends the given Subscription stanza. * @param sub The Subscription stanza to send. */ void send( const Subscription& sub ); /** * A convenience function that sends the given Presence stanza. * @param pres The Presence stanza to send. */ void send( const Presence& pres ); /** * Returns whether authentication has taken place and was successful. * @return @b True if authentication has been carried out @b and was successful, @b false otherwise. */ bool authed() const { return m_authed; } /** * Returns the current connection status. * @return The status of the connection. */ ConnectionState state() const; /** * Retrieves the value of the xml:lang attribute of the initial stream. * Default is 'en', i.e. if not changed by a call to @ref setXmlLang(). */ const std::string& xmlLang() const { return m_xmllang; } /** * Sets the value for the xml:lang attribute of the initial stream. * @param xmllang The language identifier for the stream. It must conform to * section 2.12 of the XML specification and RFC 3066. * Default is 'en'. */ void setXmlLang( const std::string& xmllang ) { m_xmllang = xmllang; } /** * This function returns the concrete connection implementation currently in use. * @return The concrete connection implementation. * @since 0.9 */ ConnectionBase* connectionImpl() const { return m_connection; } /** * Use this function if you have a class implementing a UDP, SCTP (or whatever) * connection. This should be called before calling connect(). If there already is a * connection implementation set (either manually or automatically), it gets deleted. * @param cb The connection to use. * @since 0.9 */ void setConnectionImpl( ConnectionBase* cb ); /** * This function returns the concrete encryption implementation currently in use. * @return The concrete encryption implementation. * @since 0.9 */ TLSBase* encryptionImpl() const { return m_encryption; } /** * Use this function if you have a class supporting hardware encryption (or whatever). * This should be called before calling connect(). If there already is a * encryption implementation set (either manually or automatically), it gets deleted. * @param tb The encryption implementation to use. * @since 0.9 */ void setEncryptionImpl( TLSBase* tb ); /** * This function returns the concrete compression implementation currently in use. * @return The concrete compression implementation. * @since 0.9 */ CompressionBase* compressionImpl() const { return m_compression; } /** * Use this function if you have a class supporting some fancy compression algorithm. * This should be called before calling connect(). If there already is a * compression implementation set (either manually or automatically), it gets deleted. * @param cb The compression implementation to use. * @since 0.9 */ void setCompressionImpl( CompressionBase* cb ); +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) /** * Sends a whitespace ping to the server. * @since 0.9 */ void whitespacePing(); /** * Sends a XMPP Ping (@xep{0199}) to the given JID. * @param to Then entity to ping. * @param eh An EventHandler to inform about the reply. * @since 0.9 */ void xmppPing( const JID& to, EventHandler* eh ); +#endif // GLOOX_MINIMAL /** * Use this function to set an authorization ID (authzid). Provided the server supports it * and the user has sufficient rights, they could then authenticate as bob@example.net but * act as alice@example.net. * @param authzid The JID to authorize as. Only the bare JID is used. * @since 0.9 */ void setAuthzid( const JID& authzid ) { m_authzid = authzid; } /** * Use this function to set an authentication ID (authcid) for SASL PLAIN. * The default authcid is the username, i.e. the JID's node part. This should work in most cases. * If this is not what you want to use for authentication, use this function. * @param authcid The authentication ID. * @since 1.0 * @note Right now this is used for SASL PLAIN authentication only. */ void setAuthcid( const std::string& authcid ) { m_authcid = authcid; } /** * Use this function to limit SASL mechanisms gloox can use. By default, all * supported mechanisms are allowed. To exclude one (or more) mechanisms, remove * it from SaslMechAll like so: * @code * int mymechs = SaslMechAll ^ SaslMechDigestMd5; * @endcode * @param mechanisms Bitwise ORed @ref SaslMechanism. * @since 0.9 */ void setSASLMechanisms( int mechanisms ) { m_availableSaslMechs = mechanisms; } /** * Registers a new StanzaExtension with the StanzaExtensionFactory. * @param ext The extension to register. */ void registerStanzaExtension( StanzaExtension* ext ); /** * Removes the given StanzaExtension type from the StanzaExtensionFactory. * @param ext The extension type. * @return @b True if the given type was found (and removed), @b false otherwise. */ bool removeStanzaExtension( int ext ); /** * Registers @c cl as object that receives connection notifications. * @param cl The object to receive connection notifications. */ void registerConnectionListener( ConnectionListener* cl ); /** * Registers @c ih as object that receives notifications for IQ stanzas * that contain StanzaExtensions of the given type. The number of handlers * per extension type is not limited. * @param ih The object to receive IQ stanza notifications. * @param exttype The extension type. See StanzaExtension and * @link gloox::StanzaExtensionType StanzaExtensionType @endlink. * @since 1.0 */ void registerIqHandler( IqHandler* ih, int exttype ); /** * Removes the given IqHandler from the list of handlers of pending operations, added * using send( IQ&, IqHandler*, int, bool ). Necessary, for example, when closing a GUI element that has an * operation pending. * @param ih The IqHandler to remove. * @since 0.8.7 */ void removeIDHandler( IqHandler* ih ); /** * Registers @c mh as object that receives Message stanza notifications. * @param mh The object to receive Message stanza notifications. */ void registerMessageHandler( MessageHandler* mh ); /** * Removes the given object from the list of message handlers. * @param mh The object to remove from the list. */ void removeMessageHandler( MessageHandler* mh ); +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) + /** + * Registers @c ph as object that receives Ping stanza notifications. + * @param ph The object to receive Ping stanza notifications. + */ + void registerPingHandler( PingHandler* ph ); + + /** + * Clears the current ping handler. The ping handler does not get deleted. + */ + void removePingHandler(); +#endif // GLOOX_MINIMAL + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) /** * Registers the given MessageSession to receive Messages incoming from the session's * target JID. * @note The ClientBase instance becomes the owner of the MessageSession, it will be deleted * in ClientBase's destructor. To get rid of the session before that, use disposeMessageSession(). * @param session The MessageSession to register. * @note Since a MessageSession automatically registers itself with the ClientBase, there is no * need to call this function directly. */ void registerMessageSession( MessageSession* session ); /** * Removes the given MessageSession from the list of MessageSessions and deletes it. * @param session The MessageSession to be deleted. */ void disposeMessageSession( MessageSession* session ); /** + * Use this function to register a MessageSessionHandler with the Client. + * Optionally the MessageSessionHandler can receive only MessageSessions with a given + * message type. There can be only one handler per message type.
+ * A MessageSession will be created for every incoming + * message stanza if there is no MessageHandler registered for the originating JID. + * @param msh The MessageSessionHandler that will receive the newly created MessageSession. + * @param types ORed StanzaSubType's that describe the desired message types the handler + * shall receive. Only StanzaMessage* types are valid. A value of 0 means any type (default). + */ + void registerMessageSessionHandler( MessageSessionHandler* msh, int types = 0 ); +#endif // GLOOX_MINIMAL + + /** * Registers @c ph as object that receives Presence stanza notifications. * @param ph The object to receive Presence stanza notifications. */ void registerPresenceHandler( PresenceHandler* ph ); /** * Registers a new PresenceHandler for the given JID. Presences received for this * particular JID will not be forwarded to the generic PresenceHandler (and therefore * the Roster). * This functionality is primarily intended for the MUC implementation. * @param jid The JID to 'watch'. * @param ph The PresenceHandler to inform about presence changes from @c jid. * @since 0.9 */ void registerPresenceHandler( const JID& jid, PresenceHandler* ph ); /** * Registers @c sh as object that receives Subscription stanza notifications. * @param sh The object to receive Subscription stanza notifications. */ void registerSubscriptionHandler( SubscriptionHandler* sh ); /** * Registers @c th as object that receives incoming packts with a given root tag * qualified by the given namespace. * @param th The object to receive Subscription packet notifications. * @param tag The element's name. * @param xmlns The element's namespace. */ void registerTagHandler( TagHandler* th, const std::string& tag, const std::string& xmlns ); /** * Registers @c sh as object that receives up-to-date connection statistics each time * a Stanza is received or sent. Alternatively, you can use getStatistics() manually. * Only one StatisticsHandler per ClientBase at a time is possible. * @param sh The StatisticsHandler to register. */ void registerStatisticsHandler( StatisticsHandler* sh ); /** * Removes the given object from the list of connection listeners. * @param cl The object to remove from the list. */ void removeConnectionListener( ConnectionListener* cl ); /** * Removes the given IQ handler for the given extension type. * @param ih The IqHandler. * @param exttype The extension type. See * @link gloox::StanzaExtensionType StanzaExtensionType @endlink. * @since 1.0 */ void removeIqHandler( IqHandler* ih, int exttype ); /** * Removes the given object from the list of presence handlers. * @param ph The object to remove from the list. */ void removePresenceHandler( PresenceHandler* ph ); /** * Removes the given object from the list of presence handlers for the given JID. * @param jid The JID to remove the PresenceHandler(s) for. * @param ph The PresenceHandler to remove from the list. If @c ph is 0, * all handlers for the given JID will be removed. */ void removePresenceHandler( const JID& jid, PresenceHandler* ph ); /** * Removes the given object from the list of subscription handlers. * @param sh The object to remove from the list. */ void removeSubscriptionHandler( SubscriptionHandler* sh ); /** * Removes the given object from the list of tag handlers for the given element and namespace. * @param th The object to remove from the list. * @param tag The element to remove the handler for. * @param xmlns The namespace qualifying the element. */ void removeTagHandler( TagHandler* th, const std::string& tag, const std::string& xmlns ); /** * Removes the current StatisticsHandler. */ void removeStatisticsHandler(); /** * Use this function to set a number of trusted root CA certificates which shall be * used to verify a servers certificate. * @param cacerts A list of absolute paths to CA root certificate files in PEM format. */ void setCACerts( const StringList& cacerts ) { m_cacerts = cacerts; } /** * Use this function to set the user's certificate and private key. The certificate will * be presented to the server upon request and can be used for SASL EXTERNAL authentication. * The user's certificate file should be a bundle of more than one certificate in PEM format. * The first one in the file should be the user's certificate, each cert following that one * should have signed the previous one. * @note These certificates are not necessarily the same as those used to verify the server's * certificate. * @param clientKey The absolute path to the user's private key in PEM format. * @param clientCerts A path to a certificate bundle in PEM format. */ void setClientCert( const std::string& clientKey, const std::string& clientCerts ); /** - * Use this function to register a MessageSessionHandler with the Client. - * Optionally the MessageSessionHandler can receive only MessageSessions with a given - * message type. There can be only one handler per message type.
- * A MessageSession will be created for every incoming - * message stanza if there is no MessageHandler registered for the originating JID. - * @param msh The MessageSessionHandler that will receive the newly created MessageSession. - * @param types ORed StanzaSubType's that describe the desired message types the handler - * shall receive. Only StanzaMessage* types are valid. A value of 0 means any type (default). - */ - void registerMessageSessionHandler( MessageSessionHandler* msh, int types = 0 ); - - /** * Returns the LogSink instance for this ClientBase and all related objects. * @return The LogSink instance used in the current ClientBase. */ LogSink& logInstance() { return m_logInstance; } /** * Use this function to retrieve the type of the stream error after it occurs and you received a * ConnectionError of type @b ConnStreamError from the ConnectionListener. * @return The StreamError. * @note The return value is only meaningful when called from ConnectionListener::onDisconnect(). */ StreamError streamError() const { return m_streamError; } /** * Returns the text of a stream error for the given language if available. * If the requested language is not available, the default text (without a xml:lang * attribute) will be returned. * @param lang The language identifier for the desired language. It must conform to * section 2.12 of the XML specification and RFC 3066. If empty, the default body * will be returned, if any. * @return The describing text of a stream error. Empty if no stream error occured. */ const std::string& streamErrorText( const std::string& lang = "default" ) const; /** * In case the defined-condition element of an stream error contains XML character data you can * use this function to retrieve it. RFC 3920 only defines one condition (see-other-host)where * this is possible. * @return The cdata of the stream error's text element (only for see-other-host). */ const std::string& streamErrorCData() const { return m_streamErrorCData; } /** * This function can be used to retrieve the application-specific error condition of a stream error. * @return The application-specific error element of a stream error. 0 if no respective element was * found or no error occured. */ const Tag* streamErrorAppCondition() const { return m_streamErrorAppCondition; } /** * Use this function to retrieve the type of the authentication error after it occurs and you * received a ConnectionError of type @b ConnAuthenticationFailed from the ConnectionListener. * @return The type of the authentication, if any, @b AuthErrorUndefined otherwise. */ AuthenticationError authError() const { return m_authError; } /** * Returns a StatisticsStruct containing byte and stanza counts for the current * active connection. * @return A struct containing the current connection's statistics. */ StatisticsStruct getStatistics(); +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) /** * Registers a MUCInvitationHandler with the ClientBase. * @param mih The MUCInvitationHandler to register. */ void registerMUCInvitationHandler( MUCInvitationHandler* mih ); /** * Removes the currently registered MUCInvitationHandler. */ void removeMUCInvitationHandler(); +#endif // GLOOX_MINIMAL /** * Adds a StanzaExtension that will be sent with every Presence stanza * sent. Capabilities are included by default if you are using a Client. * @param se A StanzaExtension to add. If an extension of the same type * has been added previously it will be replaced by the new one. * Use removePresenceExtension() to remove an extension. */ void addPresenceExtension( StanzaExtension* se ); /** * Removes the StanzaExtension of the given type from the list of Presence * StanzaExtensions. * Use addPresenceExtension() to replace an already added type. */ bool removePresenceExtension( int type ); /** * Returns the current list of Presence StanzaExtensions. * @return The current list of Presence StanzaExtensions. */ const StanzaExtensionList& presenceExtensions() const { return m_presenceExtensions; } /** * Returns a list of Tags that are currently in the send queue. * You should not rely on the currentness of this data when there is an established connection. * @return A 'decoupled' list of Tags (deep copies) in the send queue. The caller is responsible * for deleting the tags. * @since 1.0.6 */ const TagList sendQueue(); // reimplemented from ParserHandler virtual void handleTag( Tag* tag ); // reimplemented from CompressionDataHandler virtual void handleCompressedData( const std::string& data ); // reimplemented from CompressionDataHandler virtual void handleDecompressedData( const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); // reimplemented from TLSHandler virtual void handleEncryptedData( const TLSBase* base, const std::string& data ); // reimplemented from TLSHandler virtual void handleDecryptedData( const TLSBase* base, const std::string& data ); // reimplemented from TLSHandler virtual void handleHandshakeResult( const TLSBase* base, bool success, CertInfo &certinfo ); - protected: -#ifdef CLIENTBASE_TEST +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) + // reimplemented from PingHandler + virtual void handlePing( const PingType type, const std::string& body ); +#endif // GLOOX_MINIMAL + + protected: +#if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) public: #endif /** * This function is called when resource binding yieled an error. * @param error A pointer to an Error object that contains more * information. May be 0. */ void notifyOnResourceBindError( const Error* error ); /** * This function is called when binding a resource succeeded. * @param resource The bound resource. */ void notifyOnResourceBind( const std::string& resource ); /** * This function is called when session creation yieled an error. * @param error A pointer to an Error object that contains more * information. May be 0. */ void notifyOnSessionCreateError( const Error* error ); /** * This function is called when the TLS handshake completed correctly. The return * value is used to determine whether or not the client accepted the server's * certificate. If @b false is returned the connection is closed. * @param info Information on the server's certificate. * @return @b True if the certificate seems trustworthy, @b false otherwise. */ bool notifyOnTLSConnect( const CertInfo& info ); /** * This function is called to notify about successful connection. */ void notifyOnConnect(); /** * This function is used to notify subscribers of stream events. * @param event The event to publish. */ void notifyStreamEvent( StreamEvent event ); /** * Disconnects the underlying stream and broadcasts the given reason. * @param reason The reason for the disconnect. */ virtual void disconnect( ConnectionError reason ); - /** - * Sends the stream header. - */ - void header(); /** * Tells ClientBase that authentication was successful (or not). * @param authed Whether or not authentication was successful. */ void setAuthed( bool authed ) { m_authed = authed; } /** * If authentication failed, this function tells ClientBase * the reason. * @param e The reason for the authentication failure. */ void setAuthFailure( AuthenticationError e ) { m_authError = e; } /** * Implementors of this function can check if they support the advertized stream version. * The return value indicates whether or not the stream can be handled. A default * implementation is provided. * @param version The advertized stream version. * @return @b True if the stream can be handled, @b false otherwise. */ virtual bool checkStreamVersion( const std::string& version ); /** * Starts authentication using the given SASL mechanism. * @param type A SASL mechanism to use for authentication. */ void startSASL( SaslMechanism type ); /** * Verifies the server response after successful authentication (if applicable) and * releases SASL related resources (if applicable). * @param payload The server's verification string. - * @return @b True if verification is not supported by the chosen SASL mechanism or could be completed successfully, - * @b false if verification failed. + * @return @b True if verification is not supported by the chosen SASL mechanism or could be + * completed successfully, @b false if verification failed. */ bool processSASLSuccess( const std::string& payload ); /** * Processes the given SASL challenge and sends a response. * @param challenge The SASL challenge to process. */ void processSASLChallenge( const std::string& challenge ); /** * Examines the given Tag for SASL errors. * @param tag The Tag to parse. */ void processSASLError( Tag* tag ); /** * Sets the domain to use in SASL NTLM authentication. * @param domain The domain. */ void setNTLMDomain( const std::string& domain ) { m_ntlmDomain = domain; } /** * Starts the TLS handshake. */ void startTls(); /** * Indicates whether or not TLS is supported. * @return @b True if TLS is supported, @b false otherwise. */ bool hasTls(); /** * Sends the given data unchecked over the underlying transport connection. Use at your own risk. * The server will check any data received anyway and disconnect if something is wrong. * @param xml The data to send. */ void send( const std::string& xml ); /** * This function checks if there are any unacknowledged Tags in the send queue and resends * as necessary. * @param handled The sequence number of the last handled stanza. * @param resend Whether to resend unhandled stanzas. * @note This function is part of @xep{0198}. You should not need to use it directly. * @since 1.0.4 */ void checkQueue( int handled, bool resend ); /** * Returns the number of sent stanzas, if Stream Management is enabled. * @return The number of sent stanzas. */ int stanzasSent() const { return m_smSent; } /** * Returns 32 octets of random characters. * @return Random characters. */ std::string getRandom(); JID m_jid; /**< The 'self' JID. */ JID m_authzid; /**< An optional authorization ID. See setAuthzid(). */ std::string m_authcid; /**< An alternative authentication ID. See setAuthcid(). */ ConnectionBase* m_connection; /**< The transport connection. */ TLSBase* m_encryption; /**< Used for connection encryption. */ CompressionBase* m_compression; /**< Used for connection compression. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) Disco* m_disco; /**< The local Service Discovery client. */ +#endif // GLOOX_MINIMAL /** A list of permanent presence extensions. */ StanzaExtensionList m_presenceExtensions; - GLOOX_DEPRECATED std::string m_selectedResource; /**< The currently selected resource. - * See Client::selectResource() and Client::bindRessource(). - * @deprecated Not used anymore. Will be removed for 1.1. - * @todo Remove for 1.1 */ std::string m_clientCerts; /**< TLS client certificates. */ std::string m_clientKey; /**< TLS client private key. */ std::string m_namespace; /**< Default namespace. */ std::string m_password; /**< Client's password. */ std::string m_xmllang; /**< Default value of the xml:lang attribute. */ std::string m_server; /**< The server to connect to, if different from the * JID's server. */ std::string m_sid; /**< The stream ID. */ bool m_compressionActive; /**< Indicates whether or not stream compression * is currently activated. */ bool m_encryptionActive; /**< Indicates whether or not stream encryption * is currently activated. */ bool m_compress; /**< Whether stream compression * is desired at all. */ bool m_authed; /**< Whether authentication has been completed successfully. */ bool m_resourceBound; /**< Whether resource binding has been completed successfully. */ bool m_block; /**< Whether blocking connection is wanted. */ bool m_sasl; /**< Whether SASL authentication is wanted. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_WEBSOCKET ) + bool m_websocket; /**< Whether connection is done over websocket. */ +#endif // GLOOX_MINIMAL TLSPolicy m_tls; /**< The current TLS policy. */ + TLSVersion m_tlsVersion; /**< The minimum TLS version to require/request. */ int m_port; /**< The port to connect to, if not to be determined * by querying the server's SRV records. */ int m_availableSaslMechs; /**< The SASL mechanisms the server offered. */ /** * An enum for the Stream Management state machine. */ enum SMContext { CtxSMInvalid, /**< Initial value. */ CtxSMFailed, /**< Either of the below failed. */ CtxSMEnable, /**< 'enable' request sent */ CtxSMResume, /**< 'resume' request sent */ CtxSMEnabled, /**< Stream Management successfully enabled. */ CtxSMResumed /**< Stream successfully resumed. */ }; SMContext m_smContext; /**< The Stream Management state. Used in @xep{0198}. */ int m_smHandled; /**< The number of handled stanzas. Used in @xep{0198}. * You should NOT mess with this. */ private: -#ifdef CLIENTBASE_TEST +#if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) public: #endif +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) /** * @brief This is an implementation of an XMPP Ping (@xep{0199}). * * @author Jakob Schröter * @since 1.0 */ class Ping : public StanzaExtension { public: /** * Constructs a new object. */ Ping(); /** * Destructor. */ virtual ~Ping(); // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { (void)tag; return new Ping(); } // reimplemented from StanzaExtension virtual Tag* tag() const { return new Tag( "ping", "xmlns", XMLNS_XMPP_PING ); } // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Ping(); } }; +#endif // GLOOX_MINIMAL + private: ClientBase( const ClientBase& ); ClientBase& operator=( const ClientBase& ); +#if defined( CLIENTBASE_TEST ) || defined( ENABLE_SEND_RAW_XML ) + public: +#endif /** * This function is called right after the opening <stream:stream> was received. * @param start The complete stream opening tag. Note that the XML representation (Tag::xml()) * will contain a closed stream tag. The original is open. */ virtual void handleStartNode( const Tag* start ) = 0; /** * This function is called for each Tag. Only stream initiation/negotiation should * be done here. * @param tag A Tag to handle. * @return Returns @b true if the tag has been handled inside the function, @b false otherwise. */ virtual bool handleNormalNode( Tag* tag ) = 0; virtual void rosterFilled() = 0; virtual void cleanup() {} virtual void handleIqIDForward( const IQ& iq, int context ) { (void) iq; (void) context; } void send( Tag* tag, bool queue, bool del ); std::string hmac( const std::string& str, const std::string& key ); std::string hi( const std::string& str, const std::string& key, int iter ); void parse( const std::string& data ); void init(); void handleStreamError( Tag* tag ); TLSBase* getDefaultEncryption(); CompressionBase* getDefaultCompression(); void notifyIqHandlers( IQ& iq ); void notifyMessageHandlers( Message& msg ); void notifyPresenceHandlers( Presence& presence ); void notifySubscriptionHandlers( Subscription& s10n ); void notifyTagHandlers( Tag* tag ); void notifyOnDisconnect( ConnectionError e ); void addFrom( Tag* tag ); void addNamespace( Tag* tag ); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); struct TrackStruct { IqHandler* ih; int context; bool del; }; struct TagHandlerStruct { TagHandler* th; std::string xmlns; std::string tag; }; struct JidPresHandlerStruct { JID* jid; PresenceHandler* ph; }; enum TrackContext { XMPPPing }; typedef std::list ConnectionListenerList; typedef std::multimap IqHandlerMapXmlns; typedef std::multimap IqHandlerMap; typedef std::map IqTrackMap; typedef std::map MessageHandlerMap; typedef std::map SMQueueMap; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) typedef std::list MessageSessionList; +#endif // GLOOX_MINIMAL typedef std::list MessageHandlerList; typedef std::list PresenceHandlerList; typedef std::list PresenceJidHandlerList; typedef std::list SubscriptionHandlerList; typedef std::list TagHandlerList; ConnectionListenerList m_connectionListeners; IqHandlerMapXmlns m_iqNSHandlers; IqHandlerMap m_iqExtHandlers; IqTrackMap m_iqIDHandlers; SMQueueMap m_smQueue; - MessageSessionList m_messageSessions; MessageHandlerList m_messageHandlers; PresenceHandlerList m_presenceHandlers; PresenceJidHandlerList m_presenceJidHandlers; SubscriptionHandlerList m_subscriptionHandlers; TagHandlerList m_tagHandlers; StringList m_cacerts; StatisticsHandler * m_statisticsHandler; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) MUCInvitationHandler * m_mucInvitationHandler; +#endif // GLOOX_MINIMAL +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) + MessageSessionList m_messageSessions; MessageSessionHandler * m_messageSessionHandlerChat; MessageSessionHandler * m_messageSessionHandlerGroupchat; MessageSessionHandler * m_messageSessionHandlerHeadline; MessageSessionHandler * m_messageSessionHandlerNormal; +#endif // GLOOX_MINIMAL +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) + PingHandler * m_pingHandler; +#endif // GLOOX_MINIMAL util::Mutex m_iqHandlerMapMutex; util::Mutex m_iqExtHandlerMapMutex; util::Mutex m_queueMutex; Parser m_parser; LogSink m_logInstance; StanzaExtensionFactory* m_seFactory; EventDispatcher m_dispatcher; AuthenticationError m_authError; StreamError m_streamError; StringMap m_streamErrorText; std::string m_streamErrorCData; Tag* m_streamErrorAppCondition; StatisticsStruct m_stats; SaslMechanism m_selectedSaslMech; std::string m_clientFirstMessageBare; std::string m_serverSignature; std::string m_gs2Header; std::string m_ntlmDomain; bool m_customConnection; std::string m_uniqueBaseId; util::AtomicRefCount m_nextId; int m_smSent; -#if defined( _WIN32 ) && !defined( __SYMBIAN32__ ) +#if defined( _WIN32 ) CredHandle m_credHandle; CtxtHandle m_ctxtHandle; #endif }; } #endif // CLIENTBASE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/compressiondatahandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/compressiondatahandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/compressiondatahandler.h (revision 27490) @@ -1,58 +1,57 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 COMPRESSIONDATAHANDLER_H__ #define COMPRESSIONDATAHANDLER_H__ #include "macros.h" #include namespace gloox { /** * @brief An abstract base class used to receive de/compressed data from a * CompressionBase-derived object. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API CompressionDataHandler { public: /** * Virtual Destructor. */ virtual ~CompressionDataHandler() {} /** * This function is called when compression is finished. * @param data The compressed data. */ virtual void handleCompressedData( const std::string& data ) = 0; /** * This function is called when decompression is finished. * @param data The decompressed data. */ virtual void handleDecompressedData( const std::string& data ) = 0; }; } #endif // COMPRESSIONDATAHANDLER_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/connectionbase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectionbase.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectionbase.h (revision 27490) @@ -1,167 +1,200 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 CONNECTIONBASE_H__ #define CONNECTIONBASE_H__ #include "gloox.h" #include "connectiondatahandler.h" #include namespace gloox { /** * @brief An abstract base class for a connection. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionBase { public: /** * Constructor. * @param cdh An object derived from @ref ConnectionDataHandler that will receive * received data. */ ConnectionBase( ConnectionDataHandler* cdh ) - : m_handler( cdh ), m_state( StateDisconnected ), m_port( -1 ) + : m_handler( cdh ), m_state( StateDisconnected ), m_port( -1 ), m_timeout( -1 ) {} /** * Virtual destructor. */ virtual ~ConnectionBase() { cleanup(); } /** * Used to initiate the connection. + * @param timeout The timeout to use for select() in milliseconds. Default of -1 means blocking. * @return Returns the connection state. */ - virtual ConnectionError connect() = 0; + virtual ConnectionError connect( int timeout = -1 ) = 0; /** * Use this periodically to receive data from the socket. * @param timeout The timeout to use for select in microseconds. Default of -1 means blocking. * @return The state of the connection. */ virtual ConnectionError recv( int timeout = -1 ) = 0; /** * Use this function to send a string of data over the wire. The function returns only after * all data has been sent. * @param data The data to send. * @return @b True if the data has been sent (no guarantee of receipt), @b false * in case of an error. */ virtual bool send( const std::string& data ) = 0; /** + * Use this function to send an arbitrary chunk of data over the wire. The function returns only after + * all data has been sent. + * @param data The data to send. + * @param len The length of data to send. + * @return @b True if the data has been sent (no guarantee of receipt), @b false + * in case of an error. + */ + virtual bool send( const char* data, const size_t len ) = 0; + + /** * Use this function to put the connection into 'receive mode', i.e. this function returns only * when the connection is terminated. * @return Returns a value indicating the disconnection reason. */ virtual ConnectionError receive() = 0; /** * Disconnects an established connection. NOOP if no active connection exists. */ virtual void disconnect() = 0; /** * This function is called after a disconnect to clean up internal state. It is also called by * ConnectionBase's destructor. */ virtual void cleanup() {} /** * Returns the current connection state. * @return The state of the connection. */ ConnectionState state() const { return m_state; } /** * Use this function to register a new ConnectionDataHandler. There can be only one * ConnectionDataHandler at any one time. * @param cdh The new ConnectionDataHandler. */ void registerConnectionDataHandler( ConnectionDataHandler* cdh ) { m_handler = cdh; } /** * Sets the server to connect to. * @param server The server to connect to. Either IP or fully qualified domain name. * @param port The port to connect to. */ void setServer( const std::string &server, int port = -1 ) { m_server = server; m_port = port; } /** * Returns the currently set server/IP. * @return The server host/IP. */ const std::string& server() const { return m_server; } /** * Returns the currently set port. * @return The server port. */ int port() const { return m_port; } /** * Returns the local port. * @return The local port. */ virtual int localPort() const { return -1; } /** + * Returns the open timeout value. + * If return value is >= 0 this is a non-blocking connection. + * @return The timeout value. + */ + int timeout() const { return m_timeout; } + + /** * Returns the locally bound IP address. * @return The locally bound IP address. */ virtual const std::string localInterface() const { return EmptyString; } /** * Returns current connection statistics. * @param totalIn The total number of bytes received. * @param totalOut The total number of bytes sent. */ virtual void getStatistics( long int &totalIn, long int &totalOut ) = 0; /** * This function returns a new instance of the current ConnectionBase-derived object. * The idea is to be able to 'clone' ConnectionBase-derived objects without knowing of * what type they are exactly. * @return A new Connection* instance. */ virtual ConnectionBase* newInstance() const = 0; + /** + * Sends the stream header. + */ + virtual std::string header( std::string to, std::string xmlns, std::string xmllang ) + { + std::string head = ""; + head += ""; + + return head; + } + protected: /** A handler for incoming data and connect/disconnect events. */ ConnectionDataHandler* m_handler; /** Holds the current connection state. */ ConnectionState m_state; /** Holds the server's name/address. */ std::string m_server; /** Holds the port to connect to. */ int m_port; + /** If timeout is >= 0 this is a non-blocking connection. */ + int m_timeout; }; } #endif // CONNECTIONBASE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/connectionhttpproxy.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectionhttpproxy.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectionhttpproxy.h (revision 27490) @@ -1,171 +1,179 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CONNECTIONHTTPPROXY ) + #ifndef CONNECTIONHTTPPROXY_H__ #define CONNECTIONHTTPPROXY_H__ #include "gloox.h" #include "connectionbase.h" #include "logsink.h" #include namespace gloox { /** * @brief This is an implementation of a simple HTTP Proxying connection. * * Usage: * * @code * Client* c = new Client( ... ); * ConnectionTCPClient* conn0 = new ConnectionTCPClient( c->logInstance(), * proxyHost, proxyPort ); * ConnectionHTTPProxy* conn1 = new ConnectionHTTPProxy( c, conn0, c->logInstance(), * xmppHost, xmppPort ); * c->setConnectionImpl( conn1 ); * @endcode * * Make sure to pass the proxy host/port to the transport connection (ConnectionTCPClient in this case), * and the XMPP host/port to the proxy connection. * * ConnectionHTTPProxy uses the CONNECT method to pass through the proxy. If your proxy does not * allow this kind of connections, or if it kills connections after some time, you may want to use * ConnectionBOSH instead or in addition. * * The reason why ConnectionHTTPProxy doesn't manage its own ConnectionTCPClient is that it allows it * to be used with other transports (like IPv6 or chained SOCKS5/HTTP proxies). * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionHTTPProxy : public ConnectionBase, public ConnectionDataHandler { public: /** * Constructs a new ConnectionHTTPProxy object. * @param connection A transport connection. It should be configured to connect to * the proxy host and port, @b not to the XMPP host. ConnectionHTTPProxy will own the * transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. This is the XMPP server's address, @b not the proxy. * @param port The port to connect to. This is the XMPP server's port, @b not the proxy's. * The default of -1 means that SRV records will be used to find out about the actual host:port. * @note To properly use this object, you have to set a ConnectionDataHandler using * registerConnectionDataHandler(). This is not necessary if this object is * part of a 'connection chain', e.g. with ConnectionSOCKS5Proxy. */ ConnectionHTTPProxy( ConnectionBase* connection, const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Constructs a new ConnectionHTTPProxy object. * @param cdh An ConnectionDataHandler-derived object that will handle incoming data. * @param connection A transport connection. It should be configured to connect to * the proxy host and port, @b not to the XMPP host. ConnectionHTTPProxy will own the * transport connection and delete it in its destructor. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. This is the XMPP server's address, @b not the proxy. * @param port The port to connect to. This is the XMPP server's port, @b not the proxy's. * The default of -1 means that SRV records will be used to find out about the actual host:port. */ ConnectionHTTPProxy( ConnectionDataHandler* cdh, ConnectionBase* connection, const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Virtual destructor */ virtual ~ConnectionHTTPProxy(); // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionBase virtual bool send( const std::string& data ); // reimplemented from ConnectionBase + virtual bool send( const char* data, const size_t len ) ; + + // reimplemented from ConnectionBase virtual ConnectionError receive(); // reimplemented from ConnectionBase virtual void disconnect(); // reimplemented from ConnectionBase virtual void cleanup(); // reimplemented from ConnectionBase virtual void getStatistics( long int &totalIn, long int &totalOut ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); // reimplemented from ConnectionDataHandler virtual ConnectionBase* newInstance() const; /** * Sets the XMPP server to proxy to. * @param host The XMPP server hostname (IP address). * @param port The XMPP server port. The default of -1 means that SRV records will be used * to find out about the actual host:port. */ void setServer( const std::string& host, int port = -1 ) { m_server = host; m_port = port; } /** * Sets proxy authorization credentials. * @param user The user name to use for proxy authorization. * @param password The password to use for proxy authorization. */ void setProxyAuth( const std::string& user, const std::string& password ) { m_proxyUser = user; m_proxyPwd = password; } /** * Sets the underlying transport connection. A possibly existing connection will be deleted. * @param connection The ConnectionBase to replace the current connection, if any. */ void setConnectionImpl( ConnectionBase* connection ); /** * Switches usage of HTTP/1.1 on or off. * @param http11 Set this to @b true to connect through a HTTP/1.1-only proxy, or @b false * to use HTTP/1.0. Defaults to HTTP/1.0 which should work with 99.9% of proxies. */ void setHTTP11( bool http11 ) { m_http11 = http11; } private: ConnectionHTTPProxy &operator=( const ConnectionHTTPProxy& ); ConnectionBase* m_connection; const LogSink& m_logInstance; std::string m_proxyUser; std::string m_proxyPwd; std::string m_proxyHandshakeBuffer; bool m_http11; }; } #endif // CONNECTIONHTTPPROXY_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpclient.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpclient.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectiontcpclient.h (revision 27490) @@ -1,83 +1,83 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 CONNECTIONTCPCLIENT_H__ #define CONNECTIONTCPCLIENT_H__ #include "gloox.h" #include "connectiontcpbase.h" #include "logsink.h" #include namespace gloox { /** * @brief This is an implementation of a simple TCP connection. * * You should only need to use this class directly if you need access to some special feature, like * the raw socket(), or if you need HTTP proxy support (see @ref gloox::ConnectionHTTPProxy for more * information). * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API ConnectionTCPClient : public ConnectionTCPBase { public: /** * Constructs a new ConnectionTCPClient object. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. * @param port The port to connect to. The default of -1 means that XMPP SRV records * will be used to find out about the actual host:port. * @note To properly use this object, you have to set a ConnectionDataHandler using * registerConnectionDataHandler(). This is not necessary if this object is * part of a 'connection chain', e.g. with ConnectionHTTPProxy. */ ConnectionTCPClient( const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Constructs a new ConnectionTCPClient object. * @param cdh An ConnectionDataHandler-derived object that will handle incoming data. * @param logInstance The log target. Obtain it from ClientBase::logInstance(). * @param server A server to connect to. * @param port The port to connect to. The default of -1 means that SRV records will be used * to find out about the actual host:port. */ ConnectionTCPClient( ConnectionDataHandler* cdh, const LogSink& logInstance, const std::string& server, int port = -1 ); /** * Virtual destructor */ virtual ~ConnectionTCPClient(); // reimplemented from ConnectionBase virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionBase - virtual ConnectionError connect(); + virtual ConnectionError connect( int timeout = -1 ); // reimplemented from ConnectionBase virtual ConnectionBase* newInstance() const; private: ConnectionTCPClient &operator=( const ConnectionTCPClient & ); }; } #endif // CONNECTIONTCPCLIENT_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/connectiontlsserver.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/connectiontlsserver.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/connectiontlsserver.h (revision 27490) @@ -1,81 +1,87 @@ /* * Copyright (c) 2009-2019 by Jakob Schröter * 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. */ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CONNECTIONTLSSERVER ) + #ifndef CONNECTIONTLSSERVER_H__ #define CONNECTIONTLSSERVER_H__ #include "macros.h" #include "logsink.h" #include "connectionbase.h" #include "connectiontls.h" #include "tlsdefault.h" #include "tlshandler.h" #include namespace gloox { class ConnectionDataHandler; /** * @brief This is an implementation of the server-side of a TLS/SSL connection. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API ConnectionTLSServer : public ConnectionTLS { public: /** * Constructs a new ConnectionTLSServer object. * @param cdh The ConnectionDataHandler that will be notified of events from this connection * @param conn A transport connection. It should be an established connection from * a client that is about to perform a TLS handshake. * ConnectionTLSServer will own the transport connection and delete it in its destructor. * @param log The log target. Obtain it from ClientBase::logInstance(). */ ConnectionTLSServer( ConnectionDataHandler* cdh, ConnectionBase* conn, const LogSink& log ); /** * Constructs a new ConnectionTLSServer object. * @param conn A transport connection. It should be an established connection from * a client that is about to perform a TLS handshake. * ConnectionTLSServer will own the transport connection and delete it in its destructor. * @param log The log target. Obtain it from ClientBase::logInstance(). */ ConnectionTLSServer( ConnectionBase* conn, const LogSink& log ); /** * Virtual Destructor. */ virtual ~ConnectionTLSServer(); /** * Returns a TLS server. * @return A TLS server. */ virtual TLSBase* getTLSBase( TLSHandler* th, const std::string server ); // reimplemented from ConnectionTLS virtual ConnectionBase* newInstance() const; private: ConnectionTLSServer& operator=( const ConnectionTLSServer& ); }; } #endif // CONNECTIONTLSSERVER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/dataformfield.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataformfield.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataformfield.h (revision 27490) @@ -1,242 +1,248 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + #ifndef DATAFORMFIELD_H__ #define DATAFORMFIELD_H__ #include "gloox.h" #include #include namespace gloox { class Tag; + class DataFormMedia; /** * @brief An abstraction of a single field in a @xep{0004} Data Form. * * @author Jakob Schröter * @since 0.7 */ class GLOOX_API DataFormField { public: /** * Describes the possible types of a Data Form Field. */ enum FieldType { TypeBoolean, /**< The field enables an entity to gather or provide an either-or * choice between two options. The default value is "false". */ TypeFixed, /**< The field is intended for data description (e.g., * human-readable text such as "section" headers) rather than data * gathering or provision. The <value/> child SHOULD NOT contain * newlines (the \\n and \\r characters); instead an application SHOULD * generate multiple fixed fields, each with one <value/> child. */ TypeHidden, /**< The field is not shown to the entity providing information, but * instead is returned with the form. */ TypeJidMulti, /**< The field enables an entity to gather or provide multiple Jabber * IDs.*/ TypeJidSingle, /**< The field enables an entity to gather or provide a single Jabber * ID.*/ TypeListMulti, /**< The field enables an entity to gather or provide one or more options * from among many. */ TypeListSingle, /**< The field enables an entity to gather or provide one option from * among many. */ TypeTextMulti, /**< The field enables an entity to gather or provide multiple lines of * text. */ TypeTextPrivate, /**< The field enables an entity to gather or provide a single line or * word of text, which shall be obscured in an interface * (e.g., *****). */ TypeTextSingle, /**< The field enables an entity to gather or provide a single line or * word of text, which may be shown in an interface. This field type is * the default and MUST be assumed if an entity receives a field type it * does not understand.*/ TypeNone, /**< The field is child of either a <reported> or <item> * element or has no type attribute. */ TypeInvalid /**< The field is invalid. Only possible if the field was created from * a Tag not correctly describing a Data Form Field. */ }; public: /** * Constructs a new DataForm field. * @param type The type of the field. Default: text-single. */ DataFormField( FieldType type = TypeTextSingle ); /** * Constructs a new DataForm field and fills it with the given values. * @param name The field's name (the value of the 'var' attribute). * @param value The field's value. * @param label The field's label. * @param type The field's type. * @since 0.9 */ DataFormField( const std::string& name, const std::string& value = EmptyString, const std::string& label = EmptyString, FieldType type = TypeTextSingle ); /** * Constructs a new Data Form Field from an existing tag that describes a field. * @param tag The tag to parse. */ DataFormField( const Tag* tag ); /** * Virtual destructor. */ virtual ~DataFormField(); /** * Use this function to retrieve the optional values of a field. * @return The options of a field. */ const StringMultiMap& options() const { return m_options; } /** * Use this function to create a Tag representation of the form field. This is usually called by * DataForm. * @return A Tag hierarchically describing the form field, or NULL if the field is invalid (i.e. * created from a Tag not correctly describing a Data Form Field). */ virtual Tag* tag() const; /** * Use this function to retrieve the name of the field (the content of the 'var' attribute). * @return The name of the field. */ const std::string& name() const { return m_name; } /** * Sets the name (the content of the 'var' attribute) of the field. The name identifies the * field uniquely in the form. * @param name The new name of the field. * @note Fields of type other than 'fixed' MUST have a name, if it is 'fixed', it MAY. */ void setName( const std::string& name ) { m_name = name; } /** * Use this function to set the optional values of the field. The key of the map * will be used as the label of the option, while the value will be used as ... the * value. ;) * @param options The optional values of a list* or *multi type of field. */ void setOptions( const StringMultiMap& options ) { m_options = options; } /** * Adds a single option to the list of options. * @param label The label of the option. * @param value The value of the option. * @since 0.9.4 */ void addOption( const std::string& label, const std::string& value ) { m_options.insert( std::make_pair( label, value ) ); } /** * Use this function to determine whether or not this field is required. * @return Whether or not this field is required. */ bool required() const { return m_required; } /** * Use this field to set this field to be required. * @param required Whether or not this field is required. */ void setRequired( bool required ) { m_required = required; } /** * Use this function to retrieve the describing label of this field. * @return The describing label of this field. */ const std::string& label() const { return m_label; } /** * Use this function to set the describing label of this field. * @param label The describing label of this field. */ void setLabel( const std::string& label ) { m_label = label; } /** * Use this function to retrieve the description of this field. * @return The description of this field */ const std::string& description() const { return m_desc; } /** * Use this function to set the description of this field. * @param desc The description of this field. */ void setDescription( const std::string& desc ) { m_desc = desc; } /** * Use this function to retrieve the value of this field. * @return The value of this field. */ const std::string& value() const { return ( m_values.size() > 0 ) ? m_values.front() : EmptyString; } /** * Use this function to set the value of this field. * @param value The new value of this field. */ void setValue( const std::string& value ) { m_values.clear(); addValue( value ); } /** * Use this function to retrieve the values of this field, if its of type 'text-multi'. * @return The value of this field. */ const StringList& values() const { return m_values; } /** * Use this function to set multiple values of this field, if it is of type 'text-multi'. If its not, * use @ref setValue() instead. * @param values The new values of this field. */ void setValues( const StringList& values ) { m_values = values; } /** * Adds a single value to the list of values. * @param value The value to add. */ void addValue( const std::string& value ) { m_values.push_back( value ); } /** * Use this function to retrieve the type of this field. * @return The type of this field. */ FieldType type() const { return m_type; } /** * Converts to @b true if the FormBase is valid, @b false otherwise. */ operator bool() const { return m_type != TypeInvalid; } private: FieldType m_type; StringMultiMap m_options; StringList m_values; + DataFormMedia* m_media; std::string m_name; std::string m_desc; std::string m_label; bool m_required; }; } #endif // DATAFORMFIELD_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/dataformmedia.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/dataformmedia.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/dataformmedia.h (revision 27490) @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019 by Jakob Schröter + * 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. + */ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DATAFORM ) || defined( WANT_ADHOC ) + +#ifndef DATAFORMMEDIA_H__ +#define DATAFORMMEDIA_H__ + +#include "macros.h" + +#include + +namespace gloox +{ + + class Tag; + + /** + * An implementation of Data Forms Media Element (@xep{0221}). + * @note So far only a single URI is supported. + * + * XEP version: 1.0 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API DataFormMedia + { + public: + /** + * Constructs a new object. + * @param uri The mandatory URI to the media. + * @param type The MIME type of the media. + * @param height Optionally, the display height of the media. + * @param width Optionally, the display width of the media. + */ + DataFormMedia( const std::string& uri, const std::string& type, int height = 0, int width = 0 ); + + /** + * Constructs a new object from the given Tag. + * @param tag The Tag to parse. + */ + DataFormMedia( const Tag* tag ); + + /** + * Virtual destructor. + */ + virtual ~DataFormMedia() {} + + /** + * Creates the XML representation of the object. + * @return The XML. + */ + Tag* tag() const; + + /** + * Returns the URI. + * @return The URI. + */ + const std::string& uri() const { return m_uri; } + + /** + * Returns the MIME type. + * @return The MIME type. + */ + const std::string& type() const { return m_type; } + + /** + * Returns the height. + * @return The height. + */ + const int height() const { return m_height; } + + /** + * Returns the width. + * @return The width. + */ + const int width() const { return m_width; } + + private: + std::string m_uri; + std::string m_type; + int m_height; + int m_width; + + }; + +} + +#endif // DATAFORMMEDIA_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/dataformmedia.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/discohandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/discohandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/discohandler.h (revision 27490) @@ -1,83 +1,87 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_DISCO ) + #ifndef DISCOHANDLER_H__ #define DISCOHANDLER_H__ #include "macros.h" #include "disco.h" #include namespace gloox { class IQ; /** * @brief A virtual interface that enables objects to receive Service Discovery (@xep{0030}) events. * * A class implementing this interface can receive the results of sent disco queries. * * @author Jakob Schröter */ class GLOOX_API DiscoHandler { public: /** * Virtual Destructor. */ virtual ~DiscoHandler() {} /** * Reimplement this function if you want to be notified about the result * of an disco#info query. * @param from The sender of the disco#info result. * @param info The Info. * @param context A context identifier. * @since 1.0 */ virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context ) = 0; /** * Reimplement this function if you want to be notified about the result * of a disco#items query. * @param from The sender of the disco#items result. * @param items The Items. * @param context A context identifier. * @since 1.0 */ virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context ) = 0; /** * Reimplement this function to receive disco error notifications. * @param from The sender of the error result. * @param error The Error. May be 0. * @param context A context identifier. * @since 1.0 */ virtual void handleDiscoError( const JID& from, const Error* error, int context ) = 0; /** * Reimplement this function to receive notifications about incoming IQ * stanzas of type 'set' in the disco namespace. * @param iq The full IQ. * @return Returns @b true if the stanza was handled and answered, @b false otherwise. */ virtual bool handleDiscoSet( const IQ& iq ) { (void)iq; return false; } }; } #endif // DISCOHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/featureneg.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/featureneg.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/featureneg.h (revision 27490) @@ -1,86 +1,90 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_FEATURENEG ) + #ifndef FEATURENEG_H__ #define FEATURENEG_H__ #include "stanzaextension.h" #include namespace gloox { class DataForm; class Tag; /** * @brief An abstraction of Feature Negotiation (@xep{0020}), implemented * as a StanzaExtension. * * XEP Version: 1.5 * @author Jakob Schröter * @since 1.0 */ class GLOOX_API FeatureNeg : public StanzaExtension { public: /** * Creates a new wrapper object using the given DataForm. * @param form The DataForm to embed. The FeatureNeg object will own the DataForm. */ FeatureNeg( DataForm* form ); /** * Creates a new wrapper object from the given Tag. * @param tag The Tag to parse. */ FeatureNeg( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~FeatureNeg(); /** * Returns the wrapped DataForm. * @return The wrapped DataForm. May be 0. */ const DataForm* form() const { return m_form; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new FeatureNeg( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new FeatureNeg( m_form ); } private: DataForm* m_form; }; } #endif // FEATURENEG_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/gloox.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/gloox.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/gloox.h (revision 27490) @@ -1,1280 +1,1357 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ /*! @mainpage gloox API Documentation * * @section contents Contents * @ref intro_sec
* @ref handlers_sec
* @ref comp_sec
* @ref client_sec
* @ref block_conn_sec
* @ref roster_sec
* @ref privacy_sec
* @ref auth_sec
* @ref msg_sec
* @ref xeps_sec
* @ref filetransfer_sec
* @ref proxy_sec
* @ref upgrading_sec
*
* * @section intro_sec Introduction * * The design of gloox follows the so-called observer pattern, which basically means that everything is * event-driven. There are two ways you can connect to the Jabber/XMPP network using gloox, either as * client or as component. For a C++ XMPP server library see . * * @note Section 11.5 of the XMPP specification (RFC 3290) requires that only UTF-8 is used as encoding * for any traffic sent over the wire. Since gloox cannot know which encoding is used in any given input, * it is a requirement that any input to gloox is valid UTF-8. * * @section handlers_sec Event Handlers * * The most important tools of gloox are the event handlers. Currently, there exist 4 handlers for * the basic protocol as defined in the RFCs, as well as numerous handlers for events generated by * the included XEP-implementations and for additional functionality. Additionally, a log handler, * a generic tag handler and a handler for connection events are available. * * Basically these handlers are virtual interfaces from which you derive a class and implement a few * virtual functions. Then you register such an object with the respective protocol implementation. A * short example: * @code * class MyClass : public PresenceHandler * { * public: * // reimplemented from PresenceHandler * virtual void handlePresence( const Presence& presence ); * * [...] * }; * * void MyClass::handlePresence( const Presence& presence ) * { * // extract further information from the Presence object * } * @endcode * * Somewhere else you do something like this: * @code * OtherClass::doSomething() * { * Client* client = new Client( ... ); * [...] * MyClass* handler = new MyClass( ... ); * client->registerPresenceHandler( handler ); * } * @endcode * * Now, every time a presence stanza (not subscription stanza) is received, handlePresence() is called * with the current stanza as argument. You can then use the extensive getters of the Stanza class to * extract stanza data. * * This works similar for all the other event handlers. * Another example, this time using the connection event handler (class @link gloox::ConnectionListener * ConnectionListener @endlink): * @code * class MyClass : public ConnectionListener * { * public: * virtual void onConnect(); * * virtual bool onTLSConnect( ... ); * }; * * void MyClass::onConnect() * { * // do something when the connection is established * } * * bool MyClass::onTLSConnect( const CertInfo& info ) * { * // decide whether you trust the certificate, examine the CertInfo structure * return true; // if you trust it, otherwise return false * } * @endcode * * @note The ConnectionListener interface is a peculiarity. You MUST re-implement * @link gloox::ConnectionListener::onTLSConnect() ConnectionListener::onTLSConnect() @endlink if * you want to be able to connect successfully to TLS/SSL enabled servers. Even though gloox tries * to verify the server's certificate it does not automatically trust a server. The client's programmer * and/or user have to decide whether to trust a server or not. This trust is expressed by the return * value of onTLSConnect(). @b False means you don't trust the server/certificate and as a consequence * the connection is dropped immediately. * * @section comp_sec Components * * A component in the Jabber/XMPP network is an add-on to a server which runs externally * to the actual server software, but can have similar privileges. Components use a protocol described in * @xep{0114} to connect and authenticate to a server. * * The @link gloox::Component Component @endlink class supports this protocol and can be used to create * a new Jabber component. It's as simple as: * @code * Component* comp = new Component( ... ); * comp->connect(); * @endcode * * @section client_sec Clients * * A client can be an end-user's chat client, a bot, or a similar entity not tied to a particular * server. The @link gloox::Client Client @endlink class implements the necessary functionality to * connect to an XMPP server. Usage is, again, pretty simple: * @code * class MyClass : public ConnectionListener, PresenceHandler * { * public: * void doSomething(); * * virtual void handlePresence( ... ); * * virtual void onConnect(); * * virtual bool onTLSConnect( const CertInfo& info ); * }; * * void MyClass::doSomething() * { * JID jid( "jid@server/resource" ); * Client* client = new Client( jid, "password" ); * client->registerConnectionListener( this ); * client->registerPresenceHandler( this ); * client->connect(); * } * * void MyClass::onConnect() * { * // connection established, auth done (see API docs for exceptions) * } * * bool MyClass::onTLSConnect( const CertInfo& info ) * { * // examine certificate info * } * * void MyClass::handlePresence( Presence* presence ) * { * // presence info * } * @endcode * * @note gloox does not officially support the style of connection which is usually used on port * 5223, i.e. SSL encryption before any XML is sent, because it's a legacy method and not standard XMPP. * However, gloox includes a ConnectionTLS class that, as a side-effect, allows you to establish such * connections. * * @note @link gloox::Client::connect() Client::connect() @endlink by default blocks until the * connection ends (either @link gloox::Client::disconnect() Client::disconnect() @endlink is called * or the server closes the connection). * * @section block_conn_sec Blocking vs. Non-blocking Connections * * For some kind of bots a blocking connection (the default behaviour) is ideal. All the bot does is * react to events coming from the server. However, for end user clients or anything with a GUI this * is far from perfect. * * In these cases non-blocking connections can be used. If * @link gloox::ClientBase::connect() ClientBase::connect( false ) @endlink is * called, the function returnes immediately after the connection has been established. It is then * the resposibility of the programmer to initiate receiving of data from the socket. * * The easiest way is to call @link gloox::ClientBase::recv() ClientBase::recv() @endlink * periodically with the desired timeout (in microseconds) as parameter. The default value of -1 * means the call blocks until any data was received, which is then parsed automatically. * * As an alternative to periodic polling you can get a hold of the raw file descriptor used for the * connection. You can then use select() on it and use * @link gloox::ClientBase::recv() ClientBase::recv() @endlink when select indicates that data is * available. You should @b not recv() any data from the file descriptor directly as there is no * way to feed that back into the parser. * * To get the file descriptor you'll need to set a connection class (e.g. an instance of * @link gloox::ConnectionTCPClient ConnectionTCPClient @endlink) manually, like so: * * @code * Client* client = new Client( ... ); * ConnectionTCPClient* conn = new ConnectionTCPClient( client, client->logInstance(), server, port ); * client->setConnectionImpl( conn ); * * client->connect( false ); * int sock = conn->socket(); * * [...] * @endcode * * It would also be possible to fetch the fd like this: * * @code * Client* client = new Client( ... ); * client->connect( false ); * int sock = static_cast( client->connectionImpl() )->socket(); * * [...] * @endcode * Obviously this will only work as long as you haven't set a different type of connection using setConnectionImpl(). * * @note This has changed in 0.9. ClientBase::fileDescriptor() is no longer available. * * @section roster_sec Roster Management * * Among others, RFC 3921 defines the protocol to manage one's contact list (roster). In gloox, the * @link gloox::RosterManager RosterManager @endlink class implements this functionality. A few * easy-to-use functions are available to subscribe to or unsubscribe from the presence of remote * entities. It is also possible to add a contact to a roster without actually subscribing to the * contacts presence. Additionally, the interface @link gloox::RosterListener RosterListener @endlink * offers many callbacks for various roster-related events. * * If you create a Client object as shown above, you also get a RosterManager for free. * @link gloox::Client::rosterManager() Client::rosterManager() @endlink returns a pointer to the * object. * * @section privacy_sec Privacy Lists * * Also defined in RFC 3921: Privacy Lists. A Privacy List can be used to explicitely block or allow * sending of stanzas from and to contacts, respectively. You can define rules based on JID, stanza type, * etc. The @link gloox::PrivacyManager PrivacyManager @endlink class and the * @link gloox::PrivacyListHandler PrivacyListHandler @endlink virtual interface allow for full * flexibility in Privacy List handling. * * @code * PrivacyManager* p = new PrivacyManager( ... ); * [...] * PrivacyListHandler::PrivacyList list; * PrivacyItem item( PrivacyItem::TypeJid, PrivacyItem::ActionDeny, * PrivacyItem::PacketMessage, "me@there.com" ); * list.push_back( item ); * * PrivacyItem item2( PrivacyItem::TypeJid, PrivacyItem::ActionAllow, * PrivacyItem::PacketIq, "me@example.org" ); * list.push_back( item2 ); * * p->store( "myList", list ); * @endcode * * @section auth_sec Authentication * * gloox supports old-style IQ-based authentication defined in @xep{0078} as well as several SASL mechanisms. * See the documentation of the @link gloox::Client Client @endlink class for more information. * * @section msg_sec Sending and Receiving of Chat Messages * * For Messaging it is recommended to use the MessageSession interface. It handles sending and receiving * of messages as well as message events and chat states (such as typing notifications, etc.). See * @link gloox::MessageSession MessageSession @endlink for more details. * * @section xeps_sec Protocol Extensions (XEPs) * * The XMPP Standards Foundation has published a number of extensions to the core protocols, called * XMPP Extension Protocols (XEPs). A couple of these XEPs are implemented in gloox: * * @li @xep{0004} @link gloox::DataForm Data Forms @endlink * @li @xep{0012} @link gloox::LastActivity Last Activity @endlink * @li @xep{0013} @link gloox::FlexibleOffline Flexible Offline Message Retrieval @endlink * @li @xep{0022} Message Events (see @link gloox::MessageSession MessageSession @endlink for examples) * @li @xep{0027} Current Jabber OpenPGP Usage (see @link gloox::GPGSigned GPGSigned @endlink * and @link gloox::GPGEncrypted GPGEncrypted @endlink) * @li @xep{0030} @link gloox::Disco Service Discovery @endlink * @li @xep{0045} @link gloox::MUCRoom Multi-User Chat @endlink * @li @xep{0047} In-Band Bytestreams, used with @ref filetransfer_sec * @li @xep{0048} @link gloox::BookmarkStorage Bookmark Storage @endlink * @li @xep{0049} @link gloox::PrivateXML Private XML Storage @endlink * @li @xep{0050} @link gloox::Adhoc Ad-hoc Commands @endlink * @li @xep{0054} @link gloox::VCardManager vcard-temp @endlink * @li @xep{0060} @link gloox::PubSub::Manager Publish-Subscribe @endlink * @li @xep{0065} @link gloox::SOCKS5BytestreamManager SOCKS5 Bytestreams @endlink, used with * @ref filetransfer_sec and @ref proxy_sec * @li @xep{0066} @link gloox::OOB Out of Band Data @endlink, also used with @ref filetransfer_sec * @li @xep{0077} @link gloox::Registration In-Band Registration @endlink * @li @xep{0078} Non-SASL Authentication (automatically used if the server does not support SASL) * @li @xep{0079} @link gloox::AMP Advanced Message Processing @endlink * @li @xep{0083} Nested Roster Groups (automatically used if supported by the server, see * @link gloox::RosterManager::delimiter() RosterManager @endlink) * @li @xep{0085} Chat State Notifications (see @link gloox::MessageSession MessageSession @endlink for * examples) * @li @xep{0091} @link gloox::DelayedDelivery Delayed Delivery @endlink (old spec) * @li @xep{0092} Software Version (integrated into @link gloox::Disco Service Discovery @endlink) * @li @xep{0095} @link gloox::SIManager Stream Initiation @endlink, used with @ref filetransfer_sec * @li @xep{0096} @ref filetransfer_sec * @li @xep{0106} @link gloox::JID::escapeNode() JID Escaping @endlink * @li @xep{0114} @link gloox::Component Jabber Component Protocol @endlink * @li @xep{0115} @link gloox::Capabilities Entity Capabilities @endlink (used automatically internally) * @li @xep{0124} @link gloox::ConnectionBOSH Bidirectional-streams Over Synchronous HTTP (BOSH) @endlink * @li @xep{0131} @link gloox::SHIM Stanza Headers and Internet Metadata @endlink * @li @xep{0138} Stream Compression (used automatically if gloox is compiled with zlib and if the server * supports it) + * @li @xep{0144} @link gloox::RosterX Roster Item Exchange @endlink * @li @xep{0145} @link gloox::Annotations Annotations @endlink * @li @xep{0153} @link gloox::VCardUpdate vCard-based Avatars @endlink * @li @xep{0166} @link gloox::Jingle::SessionManager Jingle @endlink * @li @xep{0172} @link gloox::Nickname User Nickname @endlink * @li @xep{0174} @link gloox::LinkLocal::Manager Link-local Messaging @endlink * @li @xep{0176} @link gloox::Jingle::ICEUDP Jingle ICE-UDP Transport Method @endlink * @li @xep{0184} @link gloox::Receipt Message Receipts @endlink * @li @xep{0198} Stream Management (integrated into @link gloox::Client @endlink) * @li @xep{0199} @link gloox::ClientBase::xmppPing() XMPP Ping @endlink * @li @xep{0203} @link gloox::DelayedDelivery Delayed Delivery @endlink (new spec) * @li @xep{0206} XMPP Over BOSH, see @link gloox::ConnectionBOSH BOSH @endlink * @li @xep{0224} @link gloox::Attention Attention @endlink * @li @xep{0234} @link gloox::Jingle::FileTransfer Jingle File Transfer @endlink * @li @xep{0256} @link gloox::LastActivity::Query Last Activity in Presence @endlink * @li @xep{0280} @link gloox::Carbons Message Carbons @endlink * @li @xep{0297} @link gloox::Forward Stanza Forwarding @endlink + * @li @xep{0333} @link gloox::ChatMarker Chat Markers @endlink + * @li @xep{0334} @link gloox::Hint Message Processing Hints @endlink * @li @xep{0352} @link gloox::Client::hasClientStateIndication() Client State Indication @endlink + * @li @xep{0372} @link gloox::Reference References @endlink + * @li @xep{0394} @link gloox::MessageMarkup Message Markup @endlink + * + * @li RFC 7395: XMPP Over WebSocket, see @link gloox::ConnectionWebSocket WebSocket @endlink * * Further extensions can easily be implemented using * @link gloox::StanzaExtension StanzaExtensions @endlink. * * @section filetransfer_sec File Transfer * * For file transfer, gloox implements @xep{0095} (Stream Initiation) as well @xep{0096} (File Transfer) * for the signalling, and @xep{0065} (SOCKS5 Bytestreams) as well as @xep{0047} (In-Band Bytestreams) * for the transport. See @link gloox::SIProfileFT SIProfileFT @endlink. * * @section proxy_sec HTTP and SOCKS5 Proxy support * * gloox is capable of traversing HTTP as well as SOCKS5 proxies, even chained. See * @link gloox::ConnectionHTTPProxy ConnectionHTTPProxy @endlink and * @link gloox::ConnectionSOCKS5Proxy ConnectionSOCKS5Proxy @endlink. * * @section upgrading_sec Upgrading from earlier versions * * See Upgrading. * */ #ifndef GLOOX_H__ #define GLOOX_H__ #include "macros.h" +#include + #include #include #include /** * @brief The namespace for the gloox library. * * @author Jakob Schröter * @since 0.3 */ namespace gloox { /** Client namespace (RFC 3920)*/ GLOOX_API extern const std::string XMLNS_CLIENT; /** Component Accept namespace (@xep{0114}) */ GLOOX_API extern const std::string XMLNS_COMPONENT_ACCEPT; /** Component Connect namespace (@xep{0114}) */ GLOOX_API extern const std::string XMLNS_COMPONENT_CONNECT; /** Service Discovery Info namespace (@xep{0030}) */ GLOOX_API extern const std::string XMLNS_DISCO_INFO; /** Service Discovery Items namespace (@xep{0030}) */ GLOOX_API extern const std::string XMLNS_DISCO_ITEMS; /** Service Discovery Publish namespace (@xep{0030}) */ GLOOX_API extern const std::string XMLNS_DISCO_PUBLISH; /** Adhoc Commands namespace (@xep{0050}) */ GLOOX_API extern const std::string XMLNS_ADHOC_COMMANDS; /** Stream Compression namespace (@xep{0138}) */ GLOOX_API extern const std::string XMLNS_COMPRESSION; /** Flexible Offline Message Retrieval (@xep{0013}) */ GLOOX_API extern const std::string XMLNS_OFFLINE; /** Chat State Notifications namespace (@xep{0085}) */ GLOOX_API extern const std::string XMLNS_CHAT_STATES; /** Advanced Message Processing (@xep{0079}) */ GLOOX_API extern const std::string XMLNS_AMP; /** In-Band Bytestreams namespace (@xep{0047}) */ GLOOX_API extern const std::string XMLNS_IBB; /** Feature Negotiation namespace (@xep{0020}) */ GLOOX_API extern const std::string XMLNS_FEATURE_NEG; /** Chat Session Negotiation namespace (@xep{0155}) */ GLOOX_API extern const std::string XMLNS_CHATNEG; /** XHTML-IM namespace (@xep{0071}) */ GLOOX_API extern const std::string XMLNS_XHTML_IM; /** Delayed Delivery namespace (@xep{0203}) */ GLOOX_API extern const std::string XMLNS_DELAY; /** Roster namespace (RFC 3921) */ GLOOX_API extern const std::string XMLNS_ROSTER; /** Software Version namespace (@xep{0092}) */ GLOOX_API extern const std::string XMLNS_VERSION; /** In-Band Registration namespace (@xep{0077}) */ GLOOX_API extern const std::string XMLNS_REGISTER; /** Privacy lists namespace (RFC 3921) */ GLOOX_API extern const std::string XMLNS_PRIVACY; /** Non-SASL Authentication namespace (@xep{0078}) */ GLOOX_API extern const std::string XMLNS_AUTH; /** Private XML Storage namespace (@xep{0049}) */ GLOOX_API extern const std::string XMLNS_PRIVATE_XML; /** Last Activity namespace (@xep{0012}) */ GLOOX_API extern const std::string XMLNS_LAST; /** Jabber Search namespace (@xep{0055}) */ GLOOX_API extern const std::string XMLNS_SEARCH; /** Out of Band Data (IQ) namespace (@xep{0066}) */ GLOOX_API extern const std::string XMLNS_IQ_OOB; /** Data Forms namespace (@xep{0004}) */ GLOOX_API extern const std::string XMLNS_X_DATA; /** Message Events (@xep{0022}) */ GLOOX_API extern const std::string XMLNS_X_EVENT; /** Out of Band Data (X) namespace (@xep{0066}) */ GLOOX_API extern const std::string XMLNS_X_OOB; /** Delayed Delivery namespace (@xep{0091}) */ GLOOX_API extern const std::string XMLNS_X_DELAY; /** Current Jabber OpenPGP Usage (Sign.) (@xep{0027}) */ GLOOX_API extern const std::string XMLNS_X_GPGSIGNED; /** Current Jabber OpenPGP Usage (Enc.) (@xep{0027}) */ GLOOX_API extern const std::string XMLNS_X_GPGENCRYPTED; /** vcard-temp namespace (@xep{0054}) */ GLOOX_API extern const std::string XMLNS_VCARD_TEMP; /** vCard-Based Avatars namespace (@xep{0153}) */ GLOOX_API extern const std::string XMLNS_X_VCARD_UPDATE; /** Bookmark Storage namespace (@xep{0048}) */ GLOOX_API extern const std::string XMLNS_BOOKMARKS; /** Annotations namespace (@xep{0145}) */ GLOOX_API extern const std::string XMLNS_ANNOTATIONS; /** Nested Roster Groups namespace (@xep{0083}) */ GLOOX_API extern const std::string XMLNS_ROSTER_DELIMITER; /** XMPP Ping namespace (@xep{0199}) */ GLOOX_API extern const std::string XMLNS_XMPP_PING; /** Stream Initiation namespace (@xep{0095}) */ GLOOX_API extern const std::string XMLNS_SI; /** File transfer profile of Stream Initiation (@xep{0096}) */ GLOOX_API extern const std::string XMLNS_SI_FT; /** SOCKS5 Bytestreams namespace (@xep{0065}) */ GLOOX_API extern const std::string XMLNS_BYTESTREAMS; /** Multi-User Chat namespace (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC; /** Multi-User Chat namespace (user) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_USER; /** Multi-User Chat namespace (admin) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_ADMIN; /** Multi-User Chat namespace (unique) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_UNIQUE; /** Multi-User Chat namespace (owner) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_OWNER; /** Multi-User Chat namespace (roominfo) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_ROOMINFO; /** Multi-User Chat namespace (rooms) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_ROOMS; /** Multi-User Chat namespace (request) (@xep{0045}) */ GLOOX_API extern const std::string XMLNS_MUC_REQUEST; /** PubSub namespace (@xep{0060}) */ GLOOX_API extern const std::string XMLNS_PUBSUB; /** PubSub namespace (errors) (@xep{0060}) */ GLOOX_API extern const std::string XMLNS_PUBSUB_ERRORS; /** PubSub namespace (event) (@xep{0060}) */ GLOOX_API extern const std::string XMLNS_PUBSUB_EVENT; /** PubSub namespace (owner) (@xep{0060}) */ GLOOX_API extern const std::string XMLNS_PUBSUB_OWNER; /** Entity Capabilities namespace (@xep{0115}) */ GLOOX_API extern const std::string XMLNS_CAPS; /** SOCKS5 Fast Mode namespace */ GLOOX_API extern const std::string XMLNS_FT_FASTMODE; /** XMPP stream namespace (RFC 3920) */ GLOOX_API extern const std::string XMLNS_STREAM; /** XMPP stream namespace (RFC 3920) */ GLOOX_API extern const std::string XMLNS_XMPP_STREAM; /** XMPP stanzas namespace (RFC 3920) */ GLOOX_API extern const std::string XMLNS_XMPP_STANZAS; /** TLS Stream Feature namespace (RFC 3920) */ GLOOX_API extern const std::string XMLNS_STREAM_TLS; /** SASL Stream Feature namespace (RFC 3920) */ GLOOX_API extern const std::string XMLNS_STREAM_SASL; /** Resource Bind Stream Feature (RFC 3921) */ GLOOX_API extern const std::string XMLNS_STREAM_BIND; /** Session Create Stream Feature (RFC 3921) */ GLOOX_API extern const std::string XMLNS_STREAM_SESSION; /** Non-SASL Auth. Stream Feature (@xep{0078}) */ GLOOX_API extern const std::string XMLNS_STREAM_IQAUTH; /** In-Band Registration namespace (@xep{0077}) */ GLOOX_API extern const std::string XMLNS_STREAM_IQREGISTER; /** Stream Compression Feature namespace (@xep{0138}) */ GLOOX_API extern const std::string XMLNS_STREAM_COMPRESS; /** General HTTP binding (BOSH) namespace (@xep{0124}) */ GLOOX_API extern const std::string XMLNS_HTTPBIND; /** XMPP-over-BOSH extensions (@xep{0206}) */ GLOOX_API extern const std::string XMLNS_XMPP_BOSH; /** Message Receipt namespace (@xep{0184}) */ GLOOX_API extern const std::string XMLNS_RECEIPTS; /** Message Receipt namespace (@xep{0172}) */ GLOOX_API extern const std::string XMLNS_NICKNAME; /** Jabber RPC namespace (@xep{0009}) */ GLOOX_API extern const std::string XMLNS_JABBER_RPC; /** Jingle namespace (@xep{0166}) */ GLOOX_API extern const std::string XMLNS_JINGLE; /** Jingle error namespace (@xep{0166}) */ GLOOX_API extern const std::string XMLNS_JINGLE_ERRORS; /** Jingle ICE-UDP Transport namespace (@xep{0176}) */ GLOOX_API extern const std::string XMLNS_JINGLE_ICE_UDP; /** Jingle File Transfer namespace (@xep{0234}) */ GLOOX_API extern const std::string XMLNS_JINGLE_FILE_TRANSFER; /** Jingle File Transfer namespace (multiple files) (@xep{0234}) */ GLOOX_API extern const std::string XMLNS_JINGLE_FILE_TRANSFER_MULTI; /** Stanza Headers and Internet Metadata (SHIM) namespace (@xep{0131}) */ GLOOX_API extern const std::string XMLNS_SHIM; /** Attention namespace (@xep{0224}) */ GLOOX_API extern const std::string XMLNS_ATTENTION; /** Stream Management namespace (@xep{0198}) */ GLOOX_API extern const std::string XMLNS_STREAM_MANAGEMENT; /** Stanza Forwarding namespace (@xep{0297}) */ GLOOX_API extern const std::string XMLNS_STANZA_FORWARDING; /** Message Carbons namespace (@xep{0280}) */ GLOOX_API extern const std::string XMLNS_MESSAGE_CARBONS; + /** Shared XML Editing namespace (@xep{0284}) */ + GLOOX_API extern const std::string XMLNS_SXE; + /** Client State Indication namespace (@xep{0352}) */ GLOOX_API extern const std::string XMLNS_CLIENT_STATE_INDICATION; /** Use of Cryptographic Hash Functions in XMPP namespace (@xep{0300}) */ GLOOX_API extern const std::string XMLNS_HASHES; /** IO Data (@xep{0244}) */ GLOOX_API extern const std::string XMLNS_IODATA; + /** Roster Item Exchange (@xep{0144}) */ + GLOOX_API extern const std::string XMLNS_ROSTER_X; + + /** Websocket protocol (RFC 7395) */ + GLOOX_API extern const std::string XMLNS_XMPP_FRAMING; + + /** Chat Markers (@xep{0333}) */ + GLOOX_API extern const std::string XMLNS_CHAT_MARKERS; + + /** Message Markup (@xep{0394}) */ + GLOOX_API extern const std::string XMLNS_MESSAGE_MARKUP; + + /** Message Markup (@xep{0372}) */ + GLOOX_API extern const std::string XMLNS_REFERENCES; + + /** Message Processing Hints (@xep{0334}) */ + GLOOX_API extern const std::string XMLNS_HINTS; + + /** Bits of Binary (@xep{0231}) */ + GLOOX_API extern const std::string XMLNS_BOB; + + /** Data Form Media Element (@xep{0221}) */ + GLOOX_API extern const std::string XMLNS_DATAFORM_MEDIA; + /** Supported stream version (major). */ GLOOX_API extern const std::string XMPP_STREAM_VERSION_MAJOR; /** Supported stream version (minor). */ GLOOX_API extern const std::string XMPP_STREAM_VERSION_MINOR; /** gloox version */ GLOOX_API extern const std::string GLOOX_VERSION; /** gloox caps node */ GLOOX_API extern const std::string GLOOX_CAPS_NODE; /** A string containing "xmlns". */ GLOOX_API extern const std::string XMLNS; /** A string containing "type". */ GLOOX_API extern const std::string TYPE; /** An empty string. */ GLOOX_API extern const std::string EmptyString; /** * This describes the possible states of a stream. */ enum ConnectionState { StateDisconnected, /**< The client is in disconnected state. */ StateConnecting, /**< The client is currently trying to establish a connection. */ StateConnected /**< The client is connected to the server but authentication is not * (yet) done. */ }; /** * Describes stream events that get emitted by means of ConnectionListener::onStreamEvent(). * @since 0.9 */ enum StreamEvent { StreamEventConnecting, /**< The Client is about to initaite the connection. */ StreamEventEncryption, /**< The Client is about to negotiate encryption. */ StreamEventCompression, /**< The Client is about to negotiate compression. */ StreamEventAuthentication, /**< The Client is about to authenticate. */ StreamEventSessionInit, /**< The Client is about to create a session. */ StreamEventResourceBinding, /**< The Client is about to bind a resource to the stream. */ StreamEventSMEnable, /**< The Client is about to request Stream Management (@xep{0198}). * @since 1.0.4 */ StreamEventSMResume, /**< The Client is about to request resumption by means of Stream Management * (@xep{0198}). * @since 1.0.4 */ StreamEventSMResumed, /**< The stream has successfully been resumed by means of Stream Management * (@xep{0198}). * @since 1.0.4 */ StreamEventSMEnableFailed, /**< The attempt to enable Stream Management * (@xep{0198}) failed. This is not critical. * @since 1.0.4 */ StreamEventSMResumeFailed, /**< The attempt to resume an aborted session by means of Stream Management * (@xep{0198}) failed. This is not critical. * @since 1.0.4 */ StreamEventSessionCreation, /**< The Client is about to create a session. * @since 0.9.1 */ StreamEventRoster, /**< The Client is about to request the roster. */ StreamEventFinished /**< The log-in phase is completed. */ }; /** * This describes connection error conditions. */ enum ConnectionError { ConnNoError, /**< Not really an error. Everything went just fine. */ ConnStreamError, /**< A stream error occured. The stream has been closed. * Use ClientBase::streamError() to find the reason. */ ConnStreamVersionError, /**< The incoming stream's version is not supported */ ConnStreamClosed, /**< The stream has been closed (by the server). */ + ConnProxyGatewayTimeout, /**< The server, while acting as a gateway or proxy, did not receive a + * timely response from the upstream server specified by the URI. */ ConnProxyAuthRequired, /**< The HTTP/SOCKS5 proxy requires authentication. * @since 0.9 */ ConnProxyAuthFailed, /**< HTTP/SOCKS5 proxy authentication failed. * @since 0.9 */ ConnProxyNoSupportedAuth, /**< The HTTP/SOCKS5 proxy requires an unsupported auth mechanism. * @since 0.9 */ ConnIoError, /**< An I/O error occured. */ ConnParseError, /**< An XML parse error occurred. */ ConnConnectionRefused, /**< The connection was refused by the server (on the socket level). * @since 0.9 */ ConnDnsError, /**< Resolving the server's hostname failed. * @since 0.9 */ ConnOutOfMemory, /**< Out of memory. Uhoh. */ ConnNoSupportedAuth, /**< The auth mechanisms the server offers are not supported * or the server offered no auth mechanisms at all. */ ConnTlsFailed, /**< The server's certificate could not be verified or the TLS * handshake did not complete successfully. */ ConnTlsNotAvailable, /**< The server didn't offer TLS while it was set to be required, * or TLS was not compiled in. * @since 0.9.4 */ ConnCompressionFailed, /**< Negotiating/initializing compression failed. * @since 0.9 */ ConnAuthenticationFailed, /**< Authentication failed. Username/password wrong or account does * not exist. Use ClientBase::authError() to find the reason. */ ConnUserDisconnected, /**< The user (or higher-level protocol) requested a disconnect. */ - ConnNotConnected /**< There is no active connection. */ + ConnNotConnected, /**< There is no active connection. */ + ConnAttemptTimeout /**< The connection attempt timed out. */ }; /** * ClientBase's policy regarding TLS usage. Use with ClientBase::setTls(). */ enum TLSPolicy { TLSDisabled, /**< Don't use TLS. */ TLSOptional, /**< Use TLS if compiled in and offered by the server. */ TLSRequired /**< Don't attempt to log in if the server didn't offer TLS * or if TLS was not compiled in. Disconnect error will be * ConnTlsNotAvailable. */ }; /** + * The (minimum) required/requested TLS version. Use with ClientBase::setTls() or + * directly with a TLSBase-derived object (setTLSVersion()). + */ + enum TLSVersion + { + SSLv3, /**< Insecure and outdated version. Use at your own risk. + * Possibly not supported by your crypto lib. */ + TLSv1, /**< Use this to require TLS v1 as a minimum. Default. */ + TLSv1_1, /**< Use this to require TLS v1.1 as a minimum. */ + TLSv1_2, /**< Use this to require TLS v1.2 as a minimum. */ +// TLSv1_3, /**< Use this to require TLS v1.3 as a minimum. */ + DTLSv1, /**< Use this to require DTLS v1 as a minimum. + * Requires a datagram-based transport (e.g. UDP). */ + DTLSv1_2 /**< Use this to require DTLS v1.2 as a minimum. + * Requires a datagram-based transport (e.g. UDP). */ + }; + + /** * Supported Stream Features. */ enum StreamFeature { StreamFeatureBind = 1, /**< The server supports resource binding. */ StreamFeatureUnbind = 2, /**< The server supports binding multiple resources. */ StreamFeatureSession = 4, /**< The server supports sessions. */ StreamFeatureStartTls = 8, /**< The server supports <starttls>. */ StreamFeatureIqRegister = 16, /**< The server supports @xep{0077} (In-Band * Registration). */ StreamFeatureIqAuth = 32, /**< The server supports @xep{0078} (Non-SASL * Authentication). */ StreamFeatureCompressZlib = 64, /**< The server supports @xep{0138} (Stream * Compression) (Zlib). */ StreamFeatureCompressDclz = 128, /**< The server supports @xep{0138} (Stream * Compression) (LZW/DCLZ). */ StreamFeatureStreamManagement = 256, /**< The server supports @xep{0198} (Stream Management). */ StreamFeatureClientStateIndication = 512 /**< The server supports @xep{0352} (Client State Indication). */ // SaslMechanism below must be adjusted accordingly. }; /** * Supported SASL mechanisms. */ // must be adjusted with changes to StreamFeature enum above enum SaslMechanism { SaslMechNone = 0, /**< Invalid SASL Mechanism. */ SaslMechScramSha1 = 1024, /**< SASL SCRAM-SHA-1 accroding to RFC 5801 */ SaslMechScramSha1Plus = 2048, /**< SASL SCRAM-SHA-1-PLUS accroding to RFC 5801 */ SaslMechDigestMd5 = 4096, /**< SASL Digest-MD5 according to RFC 2831. */ SaslMechPlain = 8192, /**< SASL PLAIN according to RFC 2595 Section 6. */ SaslMechAnonymous = 16384, /**< SASL ANONYMOUS according to draft-ietf-sasl-anon-05.txt/ * RFC 2245 Section 6. */ SaslMechExternal = 32768, /**< SASL EXTERNAL according to RFC 2222 Section 7.4. */ SaslMechGssapi = 65536, /**< SASL GSSAPI (Win32 only). */ SaslMechNTLM = 131072, /**< SASL NTLM (Win32 only). */ SaslMechAll = 262143 /**< Includes all supported SASL mechanisms. */ }; /** * This describes stream error conditions as defined in RFC 3920 Sec. 4.7.3. */ enum StreamError { StreamErrorBadFormat, /**< The entity has sent XML that cannot be processed; * this error MAY be used instead of the more specific XML-related * errors, such as <bad-namespace-prefix/>, <invalid-xml/>, * <restricted-xml/>, <unsupported-encoding/>, and * <not-well-formed/>, although the more specific errors are * preferred. */ StreamErrorBadNamespacePrefix, /**< The entity has sent a namespace prefix that is unsupported, or has * sent no namespace prefix on an element that requires such a prefix * (see XML Namespace Names and Prefixes (Section 11.2)). */ StreamErrorConflict, /**< The server is closing the active stream for this entity because a * new stream has been initiated that conflicts with the existing * stream. */ StreamErrorConnectionTimeout, /**< The entity has not generated any traffic over the stream for some * period of time (configurable according to a local service policy).*/ StreamErrorHostGone, /**< the value of the 'to' attribute provided by the initiating entity * in the stream header corresponds to a hostname that is no longer * hosted by the server.*/ StreamErrorHostUnknown, /**< The value of the 'to' attribute provided by the initiating entity * in the stream header does not correspond to a hostname that is hosted * by the server. */ StreamErrorImproperAddressing, /**< A stanza sent between two servers lacks a 'to' or 'from' attribute * (or the attribute has no value). */ StreamErrorInternalServerError, /**< the server has experienced a misconfiguration or an * otherwise-undefined internal error that prevents it from servicing the * stream. */ StreamErrorInvalidFrom, /**< The JID or hostname provided in a 'from' address does not match an * authorized JID or validated domain negotiated between servers via SASL * or dialback, or between a client and a server via authentication and * resource binding.*/ StreamErrorInvalidId, /**< The stream ID or dialback ID is invalid or does not match an ID * previously provided. */ StreamErrorInvalidNamespace, /**< The streams namespace name is something other than * "http://etherx.jabber.org/streams" or the dialback namespace name is * something other than "jabber:server:dialback" (see XML Namespace Names * and Prefixes (Section 11.2)). */ StreamErrorInvalidXml, /**< The entity has sent invalid XML over the stream to a server that * performs validation (see Validation (Section 11.3)). */ StreamErrorNotAuthorized, /**< The entity has attempted to send data before the stream has been * authenticated, or otherwise is not authorized to perform an action * related to stream negotiation; the receiving entity MUST NOT process * the offending stanza before sending the stream error. */ StreamErrorPolicyViolation, /**< The entity has violated some local service policy; the server MAY * choose to specify the policy in the <text/> element or an * application-specific condition element. */ StreamErrorRemoteConnectionFailed,/**< The server is unable to properly connect to a remote entity that * is required for authentication or authorization. */ StreamErrorResourceConstraint, /**< the server lacks the system resources necessary to service the * stream. */ StreamErrorRestrictedXml, /**< The entity has attempted to send restricted XML features such as a * comment, processing instruction, DTD, entity reference, or unescaped * character (see Restrictions (Section 11.1)). */ StreamErrorSeeOtherHost, /**< The server will not provide service to the initiating entity but is * redirecting traffic to another host; the server SHOULD specify the * alternate hostname or IP address (which MUST be a valid domain * identifier) as the XML character data of the <see-other-host/> * element. */ StreamErrorSystemShutdown, /**< The server is being shut down and all active streams are being * closed. */ StreamErrorUndefinedCondition, /**< The error condition is not one of those defined by the other * conditions in this list; this error condition SHOULD be used only in * conjunction with an application-specific condition. */ StreamErrorUnsupportedEncoding, /**< The initiating entity has encoded the stream in an encoding that is * not supported by the server (see Character Encoding (Section 11.5)). */ StreamErrorUnsupportedStanzaType,/**< The initiating entity has sent a first-level child of the stream * that is not supported by the server. */ StreamErrorUnsupportedVersion, /**< The value of the 'version' attribute provided by the initiating * entity in the stream header specifies a version of XMPP that is not * supported by the server; the server MAY specify the version(s) it * supports in the <text/> element. */ StreamErrorXmlNotWellFormed, /**< The initiating entity has sent XML that is not well-formed as * defined by [XML]. */ StreamErrorUndefined /**< An undefined/unknown error occured. Also used if a diconnect was * user-initiated. Also set before and during a established connection * (where obviously no error occured). */ }; /** * Describes types of stanza errors. */ enum StanzaErrorType { StanzaErrorTypeAuth, /**< Retry after providing credentials. */ StanzaErrorTypeCancel, /**< Do not retry (the error is unrecoverable). */ StanzaErrorTypeContinue, /**< Proceed (the condition was only a warning). */ StanzaErrorTypeModify, /**< Retry after changing the data sent. */ StanzaErrorTypeWait, /**< Retry after waiting (the error is temporary). */ StanzaErrorTypeUndefined /**< No error. */ }; /** * Describes the defined stanza error conditions of RFC 3920. * Used by, eg., Stanza::error(). */ enum StanzaError { StanzaErrorBadRequest, /**< The sender has sent XML that is malformed or that cannot be * processed (e.g., an IQ stanza that includes an unrecognized value * of the 'type' attribute); the associated error type SHOULD be * "modify". */ StanzaErrorConflict, /**< Access cannot be granted because an existing resource or session * exists with the same name or address; the associated error type * SHOULD be "cancel". */ StanzaErrorFeatureNotImplemented,/**< The feature requested is not implemented by the recipient or * server and therefore cannot be processed; the associated error * type SHOULD be "cancel". */ StanzaErrorForbidden, /**< The requesting entity does not possess the required permissions to * perform the action; the associated error type SHOULD be "auth". */ StanzaErrorGone, /**< The recipient or server can no longer be contacted at this address * (the error stanza MAY contain a new address in the XML character data * of the <gone/> element); the associated error type SHOULD be * "modify". */ StanzaErrorInternalServerError, /**< The server could not process the stanza because of a * misconfiguration or an otherwise-undefined internal server error; the * associated error type SHOULD be "wait". */ StanzaErrorItemNotFound, /**< The addressed JID or item requested cannot be found; the associated * error type SHOULD be "cancel". */ StanzaErrorJidMalformed, /**< The sending entity has provided or communicated an XMPP address * (e.g., a value of the 'to' attribute) or aspect thereof (e.g., a * resource identifier) that does not adhere to the syntax defined in * Addressing Scheme (Section 3); the associated error type SHOULD be * "modify". */ StanzaErrorNotAcceptable, /**< The recipient or server understands the request but is refusing to * process it because it does not meet criteria defined by the recipient * or server (e.g., a local policy regarding acceptable words in * messages); the associated error type SHOULD be "modify". */ StanzaErrorNotAllowed, /**< The recipient or server does not allow any entity to perform the * action; the associated error type SHOULD be "cancel". */ StanzaErrorNotAuthorized, /**< The sender must provide proper credentials before being allowed to * perform the action, or has provided impreoper credentials; the * associated error type should be "auth". */ StanzaErrorNotModified, /**< The item requested has not changed since it was last requested; * the associated error type SHOULD be "continue". */ StanzaErrorPaymentRequired, /**< The requesting entity is not authorized to access the requested * service because payment is required; the associated error type SHOULD * be "auth". */ StanzaErrorRecipientUnavailable,/**< The intended recipient is temporarily unavailable; the associated * error type SHOULD be "wait" (note: an application MUST NOT return * this error if doing so would provide information about the intended * recipient's network availability to an entity that is not authorized * to know such information). */ StanzaErrorRedirect, /**< The recipient or server is redirecting requests for this * information to another entity, usually temporarily (the error * stanza SHOULD contain the alternate address, which MUST be a valid * JID, in the XML character data of the <redirect/> element); * the associated error type SHOULD be "modify". */ StanzaErrorRegistrationRequired,/**< The requesting entity is not authorized to access the requested * service because registration is required; the associated error type * SHOULD be "auth". */ StanzaErrorRemoteServerNotFound,/**< A remote server or service specified as part or all of the JID of * the intended recipient does not exist; the associated error type * SHOULD be "cancel". */ StanzaErrorRemoteServerTimeout, /**< A remote server or service specified as part or all of the JID of * the intended recipient (or required to fulfill a request) could not * be contacted within a reasonable amount of time; the associated error * type SHOULD be "wait". */ StanzaErrorResourceConstraint, /**< The server or recipient lacks the system resources necessary to * service the request; the associated error type SHOULD be "wait". */ StanzaErrorServiceUnavailable, /**< The server or recipient does not currently provide the requested * service; the associated error type SHOULD be "cancel". */ StanzaErrorSubscribtionRequired,/**< The requesting entity is not authorized to access the requested * service because a subscription is required; the associated error type * SHOULD be "auth". */ StanzaErrorUndefinedCondition, /**< The error condition is not one of those defined by the other * conditions in this list; any error type may be associated with this * condition, and it SHOULD be used only in conjunction with an * application-specific condition. */ StanzaErrorUnexpectedRequest, /**< The recipient or server understood the request but was not * expecting it at this time (e.g., the request was out of order); * the associated error type SHOULD be "wait". */ StanzaErrorUnknownSender, /**< The stanza 'from' address specified by a connected client is not * valid for the stream (e.g., the stanza does not include a 'from' * address when multiple resources are bound to the stream); the * associated error type SHOULD be "modify".*/ StanzaErrorUndefined /**< No stanza error occured. */ }; /** * Describes the possible 'available presence' types. */ // enum Presence // { // PresenceUnknown, /**< Unknown status. */ // PresenceAvailable, /**< The entity or resource is online and available. */ // PresenceChat, /**< The entity or resource is actively interested in chatting. */ // PresenceAway, /**< The entity or resource is temporarily away. */ // PresenceDnd, /**< The entity or resource is busy (dnd = "Do Not Disturb"). */ // PresenceXa, /**< The entity or resource is away for an extended period (xa = // * "eXtended Away"). */ // PresenceUnavailable /**< The entity or resource is offline. */ // }; /** * Describes the verification results of a certificate. */ enum CertStatus { CertOk = 0, /**< The certificate is valid and trusted. */ CertInvalid = 1, /**< The certificate is not trusted. */ CertSignerUnknown = 2, /**< The certificate hasn't got a known issuer. */ CertRevoked = 4, /**< The certificate has been revoked. */ CertExpired = 8, /**< The certificate has expired. */ CertNotActive = 16, /**< The certifiacte is not yet active. */ CertWrongPeer = 32, /**< The certificate has not been issued for the * peer we're connected to. */ CertSignerNotCa = 64 /**< The signer is not a CA. */ }; /** + * A list of strings. + */ + typedef std::list StringList; + + /** * Describes the certificate presented by the peer. */ struct CertInfo { int status; /**< Bitwise or'ed CertStatus or CertOK. */ bool chain; /**< Determines whether the cert chain verified ok. */ std::string issuer; /**< The name of the issuing entity.*/ std::string server; /**< The server the certificate has been issued for. */ int date_from; /**< The date from which onwards the certificate is valid * (UNIX timestamp; UTC). * @todo Change type to time_t or long? */ int date_to; /**< The date up to which the certificate is valid * (UNIX timestamp; UTC). * @todo Change type to time_t or long? */ std::string protocol; /**< The encryption protocol used for the connection. */ std::string cipher; /**< The cipher used for the connection. */ std::string mac; /**< The MAC used for the connection. */ std::string compression; /**< The compression used for the connection. */ + StringList listSAN; /**< List of Subject Alternative Names. */ }; /** * Describes the defined SASL (and non-SASL) error conditions. */ enum AuthenticationError { AuthErrorUndefined, /**< No error occurred, or error condition is unknown. */ SaslAborted, /**< The receiving entity acknowledges an <abort/> element sent * by the initiating entity; sent in reply to the <abort/> * element. */ SaslIncorrectEncoding, /**< The data provided by the initiating entity could not be processed * because the [BASE64] encoding is incorrect (e.g., because the encoding * does not adhere to the definition in Section 3 of [BASE64]); sent in * reply to a <response/> element or an <auth/> element with * initial response data. */ SaslInvalidAuthzid, /**< The authzid provided by the initiating entity is invalid, either * because it is incorrectly formatted or because the initiating entity * does not have permissions to authorize that ID; sent in reply to a * <response/> element or an <auth/> element with initial * response data.*/ SaslInvalidMechanism, /**< The initiating entity did not provide a mechanism or requested a * mechanism that is not supported by the receiving entity; sent in reply * to an <auth/> element. */ SaslMalformedRequest, /**< The request is malformed (e.g., the <auth/> element includes * an initial response but the mechanism does not allow that); sent in * reply to an <abort/>, <auth/>, <challenge/>, or * <response/> element. */ SaslMechanismTooWeak, /**< The mechanism requested by the initiating entity is weaker than * server policy permits for that initiating entity; sent in reply to a * <response/> element or an <auth/> element with initial * response data. */ SaslNotAuthorized, /**< The authentication failed because the initiating entity did not * provide valid credentials (this includes but is not limited to the * case of an unknown username); sent in reply to a <response/> * element or an <auth/> element with initial response data. */ SaslTemporaryAuthFailure, /**< The authentication failed because of a temporary error condition * within the receiving entity; sent in reply to an <auth/> element * or <response/> element. */ NonSaslConflict, /**< @xep{0078}: Resource Conflict */ NonSaslNotAcceptable, /**< @xep{0078}: Required Information Not Provided */ NonSaslNotAuthorized /**< @xep{0078}: Incorrect Credentials */ }; /** * Identifies log sources. */ enum LogArea { LogAreaClassParser = 0x000001, /**< Log messages from Parser. */ LogAreaClassConnectionTCPBase = 0x000002, /**< Log messages from ConnectionTCPBase. */ LogAreaClassClient = 0x000004, /**< Log messages from Client. */ LogAreaClassClientbase = 0x000008, /**< Log messages from ClientBase. */ LogAreaClassComponent = 0x000010, /**< Log messages from Component. */ LogAreaClassDns = 0x000020, /**< Log messages from DNS. */ LogAreaClassConnectionHTTPProxy = 0x000040, /**< Log messages from ConnectionHTTPProxy */ LogAreaClassConnectionSOCKS5Proxy = 0x000080, /**< Log messages from ConnectionSOCKS5Proxy */ LogAreaClassConnectionTCPClient = 0x000100, /**< Log messages from ConnectionTCPClient. */ LogAreaClassConnectionTCPServer = 0x000200, /**< Log messages from ConnectionTCPServer. */ LogAreaClassS5BManager = 0x000400, /**< Log messages from SOCKS5BytestreamManager. */ LogAreaClassSOCKS5Bytestream = 0x000800, /**< Log messages from SOCKS5Bytestream. */ LogAreaClassConnectionBOSH = 0x001000, /**< Log messages from ConnectionBOSH */ LogAreaClassConnectionTLS = 0x002000, /**< Log messages from ConnectionTLS */ LogAreaLinkLocalManager = 0x004000, /**< Log messages from LinkLocalManager */ + LogAreaClassConnectionWebSocket = 0x008000, /**< Log messages from ConnectionWebSocket */ LogAreaAllClasses = 0x01FFFF, /**< All log messages from all the classes. */ LogAreaXmlIncoming = 0x020000, /**< Incoming XML. */ LogAreaXmlOutgoing = 0x040000, /**< Outgoing XML. */ LogAreaUser = 0x800000, /**< User-defined sources. */ LogAreaAll = 0xFFFFFF /**< All log sources. */ }; /** * Describes a log message's severity. */ enum LogLevel { LogLevelDebug, /**< Debug messages. */ LogLevelWarning, /**< Non-crititcal warning messages. */ LogLevelError /**< Critical, unrecoverable errors. */ }; /** * The possible Message Events according to @xep{0022}. */ enum MessageEventType { MessageEventOffline = 1, /**< Indicates that the message has been stored offline by the * intended recipient's server. */ MessageEventDelivered = 2, /**< Indicates that the message has been delivered to the * recipient. */ MessageEventDisplayed = 4, /**< Indicates that the message has been displayed */ MessageEventComposing = 8, /**< Indicates that a reply is being composed. */ MessageEventInvalid = 16, /**< Invalid type. */ MessageEventCancel = 32 /**< Cancels the 'Composing' event. */ }; /** * The possible Chat States according to @xep{0085}. */ enum ChatStateType { ChatStateActive = 1, /**< User is actively participating in the chat session. */ ChatStateComposing = 2, /**< User is composing a message. */ ChatStatePaused = 4, /**< User had been composing but now has stopped. */ ChatStateInactive = 8, /**< User has not been actively participating in the chat session. */ ChatStateGone = 16, /**< User has effectively ended their participation in the chat * session. */ ChatStateInvalid = 32 /**< Invalid type. */ }; /** + * The available Chat Marker types according to @xep{0333}. + */ + enum ChatMarkerType + { + ChatMarkerReceived = 1, /**< The message has been received by a client. */ + ChatMarkerDisplayed = 2, /**< The message has been displayed to a user in a active chat + * and not in a system notification. */ + ChatMarkerAcknowledged = 4, /**< The message has been acknowledged by some user interaction + * e.g. pressing an acknowledgement button. */ + ChatMarkerInvalid = 8 /**< Invalid type. */ + }; + + /** * Describes the possible error conditions for resource binding. */ enum ResourceBindError { RbErrorUnknownError, /**< An unknown error occured. */ RbErrorBadRequest, /**< Resource identifier cannot be processed. */ RbErrorNotAllowed, /**< Client is not allowed to bind a resource. */ RbErrorConflict /**< Resource identifier is in use. */ }; /** * Describes the possible error conditions for session establishemnt. */ enum SessionCreateError { ScErrorUnknownError, /**< An unknown error occured. */ ScErrorInternalServerError, /**< Internal server error. */ ScErrorForbidden, /**< Username or resource not allowed to create session. */ ScErrorConflict /**< Server informs newly-requested session of resource * conflict. */ }; /** * Currently implemented message session filters. */ enum MessageSessionFilter { FilterMessageEvents = 1, /**< Message Events (@xep{0022}) */ FilterChatStates = 2 /**< Chat State Notifications (@xep{0085}) */ }; /** * Defined MUC room affiliations. See @xep{0045} for default privileges. */ enum MUCRoomAffiliation { AffiliationNone, /**< No affiliation with the room. */ AffiliationOutcast, /**< The user has been banned from the room. */ AffiliationMember, /**< The user is a member of the room. */ AffiliationOwner, /**< The user is a room owner. */ AffiliationAdmin, /**< The user is a room admin. */ AffiliationInvalid /**< Invalid affiliation. */ }; /** * Defined MUC room roles. See @xep{0045} for default privileges. */ enum MUCRoomRole { RoleNone, /**< Not present in room. */ RoleVisitor, /**< The user visits a room. */ RoleParticipant, /**< The user has voice in a moderatd room. */ RoleModerator, /**< The user is a room moderator. */ RoleInvalid /**< Invalid role. */ }; /** * Configuration flags for a room. */ enum MUCRoomFlag { FlagPasswordProtected = 1<< 1, /**< Password-protected room. */ FlagPublicLogging = 1<< 2, /**< Room conversation is logged. Code: 170 */ FlagPublicLoggingOff = 1<< 3, /**< Room conversation is not logged. Code: 171 */ FlagHidden = 1<< 4, /**< Hidden room. */ FlagMembersOnly = 1<< 5, /**< Members-only room. */ FlagModerated = 1<< 6, /**< Moderated room. */ FlagNonAnonymous = 1<< 7, /**< Non-anonymous room. Code: 100, 172 */ FlagOpen = 1<< 8, /**< Open room. */ FlagPersistent = 1<< 9, /**< Persistent room .*/ FlagPublic = 1<<10, /**< Public room. */ FlagSemiAnonymous = 1<<11, /**< Semi-anonymous room. Code: 173 */ FlagTemporary = 1<<12, /**< Temporary room. */ FlagUnmoderated = 1<<13, /**< Unmoderated room. */ FlagUnsecured = 1<<14, /**< Unsecured room. */ FlagFullyAnonymous = 1<<15 /**< Fully anonymous room. Code: 174 */ // keep in sync with MUCUserFlag below }; /** * Configuration flags for a user. */ // keep in sync with MUCRoomFlag above enum MUCUserFlag { UserSelf = 1<<16, /**< Other flags relate to the current user him/herself. Code: 110 */ UserNickChanged = 1<<17, /**< The user changed his/her nickname. Code: 303 */ UserKicked = 1<<18, /**< The user has been kicked. Code: 307 */ UserBanned = 1<<19, /**< The user has been banned. Code: 301 */ UserAffiliationChanged = 1<<20, /**< The user's affiliation with the room changed and as a result * he/she has been removed from the room. Code: 321 */ UserRoomDestroyed = 1<<21, /**< The room has been destroyed. */ UserNickAssigned = 1<<22, /**< Service has assigned or modified occupant's roomnick. * Code: 210*/ UserNewRoom = 1<<23, /**< The room has been newly created. Code: 201*/ UserMembershipRequired = 1<<24, /**< User is being removed from the room because the room has * been changed to members-only and the user is not a member. * Code: 322 */ UserRoomShutdown = 1<<25, /**< User is being removed from the room because of a system * shutdown. Code: 332 */ UserAffiliationChangedWNR = 1<<26 /**< The user's affiliation changed While Not in the Room. * Code: 101 */ }; /** * Describes possible subscription types according to RFC 3921, Section 9. */ enum SubscriptionType { S10nNone, /**< Contact and user are not subscribed to each other, and * neither has requested a subscription from the other. */ S10nNoneOut, /**< Contact and user are not subscribed to each other, and * user has sent contact a subscription request but contact * has not replied yet. */ S10nNoneIn, /**< Contact and user are not subscribed to each other, and * contact has sent user a subscription request but user has * not replied yet (note: contact's server SHOULD NOT push or * deliver roster items in this state, but instead SHOULD wait * until contact has approved subscription request from user). */ S10nNoneOutIn, /**< Contact and user are not subscribed to each other, contact * has sent user a subscription request but user has not replied * yet, and user has sent contact a subscription request but * contact has not replied yet. */ S10nTo, /**< User is subscribed to contact (one-way). */ S10nToIn, /**< User is subscribed to contact, and contact has sent user a * subscription request but user has not replied yet. */ S10nFrom, /**< Contact is subscribed to user (one-way). */ S10nFromOut, /**< Contact is subscribed to user, and user has sent contact a * subscription request but contact has not replied yet. */ S10nBoth /**< User and contact are subscribed to each other (two-way). */ }; /** * A list of strings. */ typedef std::list StringList; /** * A list of pointers to strings. */ typedef std::list StringPList; /** * A map of strings. */ typedef std::map StringMap; /** * A multimap of strings. */ typedef std::multimap StringMultiMap; class StanzaExtension; /** * A list of StanzaExtensions. */ typedef std::list StanzaExtensionList; } extern "C" { GLOOX_API const char* gloox_version(); } #endif // GLOOX_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/hint.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/hint.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/hint.h (revision 27490) @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2018-2019 by Jakob Schröter + * 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. + */ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_HINTS ) + +#ifndef HINT_H__ +#define HINT_H__ + +#include "gloox.h" +#include "stanzaextension.h" + +#include +#include + +namespace gloox +{ + /** + * This is an abstraction of Message Processing Hints (@xep{0334}). + * + * XEP Version: 0.3.0 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API Hint : public StanzaExtension + { + public: + + /** + * The supported Message Processing Hints types according to @xep{0334}. + */ + enum HintType + { + NoPermanentStore, /**< The message shouldn't be stored in any permanent or semi-permanent + * public or private archive or in logs (such as chatroom logs) */ + NoStore, /**< A message containing this hint should not be stored by a server either + * permanently (as for NoPermanentStore) or temporarily, e.g. for later + * delivery to an offline client, or to users not currently present in a + * chatroom. */ + NoCopy, /**< Messages with this hint should not be copied to addresses other than + * the one to which it is addressed, for example through Message Carbons + * (@xep{0280}). */ + Store, /**< A message containing this hint that is not of type 'error' SHOULD be + * stored by the entity. */ + InvalidType /**< Invalid type. Ignored. */ + }; + + /** + * Constructs a new object from the given Tag. + * @param tag A Tag to parse. + */ + Hint( const Tag* tag ); + + /** + * Constructs a new Hint object of the given type. + * @param ml The hint type. + */ + Hint( HintType type ) + : StanzaExtension( ExtHint ), m_type( type ) + {} + + /** + * Virtual destructor. + */ + virtual ~Hint() {} + + /** + * Lets you retrieve the hint's type. + * @return The hint's type. + */ + HintType type() const { return m_type; } + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new Hint( tag ); + } + + // reimplemented from StanzaExtension + Tag* tag() const; + + // reimplemented from StanzaExtension + virtual Hint* clone() const + { + return new Hint( *this ); + } + + private: + HintType m_type; + + }; + +} + +#endif // HINT_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/hint.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglecontent.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglecontent.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglecontent.h (revision 27490) @@ -1,138 +1,142 @@ /* Copyright (c) 2008-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLECONTENT_H__ #define JINGLECONTENT_H__ #include "jingleplugin.h" #include "tag.h" #include namespace gloox { namespace Jingle { class PluginFactory; /** * @brief An abstraction of a Jingle Content Type. This is part of Jingle (@xep{0166}). * * See @link gloox::Jingle::Session Jingle::Session @endlink for more info on Jingle. * * XEP Version: 1.1 * * @author Jakob Schröter * @since 1.0.5 */ class GLOOX_API Content : public Plugin { public: /** * The original creator of the content type. */ enum Creator { CInitiator, /**< The creator is the initiator of the session. */ CResponder, /**< The creator is the responder. */ InvalidCreator /**< Invalid value. */ }; /** * The parties in the session that will be generating content. */ enum Senders { SInitiator, /**< The initiator generates/sends content. */ SResponder, /**< The responder generates/sends content. */ SBoth, /**< Both parties generate/send content( default). */ SNone, /**< No party generates/sends content. */ InvalidSender /**< Invalid value. */ }; /** * Creates a new Content wrapper. * @param name A unique name for the content type. * @param plugins A list of application formats, transport methods, security preconditions, ... * @param creator Which party originally generated the content type; the defined values are "SInitiator" and "SResponder". * @param senders Which parties in the session will be generating content. * @param disposition How the content definition is to be interpreted by the recipient. The meaning of this attribute * matches the "Content-Disposition" header as defined in RFC 2183 and applied to SIP by RFC 3261. */ Content( const std::string& name, const PluginList& plugins, Creator creator = CInitiator, Senders senders = SBoth, const std::string& disposition = "session" ); /** * Creates a new Content object from the given tag. * @param tag The Tag to parse. * @param factory A PluginFactory instance to use for embedding plugins. */ Content( const Tag* tag = 0, PluginFactory* factory = 0 ); /** * Returns the content's creator. * @return The content's creator. */ Creator creator() const { return m_creator; } /** * Returns the senders. * @return The senders. */ Senders senders() const { return m_senders; } /** * Returns the disposition. * @return The disposition. */ const std::string& disposition() const { return m_disposition; } /** * Returns the content name. * @return The content name. */ const std::string& name() const { return m_name; } /** * Virtual destructor. */ virtual ~Content(); // reimplemented from Plugin virtual const std::string& filterString() const; // reimplemented from Plugin virtual Tag* tag() const; // reimplemented from Plugin virtual Plugin* newInstance( const Tag* tag ) const { return new Content( tag, m_factory ); } // reimplemented from Plugin virtual Plugin* clone() const; private: Creator m_creator; std::string m_disposition; std::string m_name; Senders m_senders; }; } } #endif // JINGLECONTENT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jinglepluginfactory.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jinglepluginfactory.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/jinglepluginfactory.h (revision 27490) @@ -1,82 +1,86 @@ /* Copyright (c) 2013-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + #ifndef JINGLEPLUGINFACTORY_H__ #define JINGLEPLUGINFACTORY_H__ #include "jingleplugin.h" #include "jinglesession.h" namespace gloox { class Tag; namespace Jingle { /** * @brief A factory for which creates Plugin instances based on Tags. This is part of Jingle (@xep{0166}). * * Used by Jingle::SessionManager. You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0.7 */ class PluginFactory { friend class SessionManager; public: /** * Virtual destructor. */ virtual ~PluginFactory(); /** * Registers an empty Plugin as a template with the factory. * @param plugin The plugin to register. */ void registerPlugin( Plugin* plugin ); /** * Based on the template plugins' filter string, this function checks the supplied tag for * supported extensions and adds them as new plugins to the supplied Plugin instance. * @param plugin The Plugin-derived object that will have the newly created plugins embedded. * @param tag The Tag to check for supported extensions. */ void addPlugins( Plugin& plugin, const Tag* tag ); /** * Based on the template plugins' filter string, this function checks the supplied tag for * supported extensions and adds them as new plugins to the supplied Jingle instance. * @param jingle The Jingle object that will have the newly created plugins embedded. * @param tag The Tag to check for supported extensions. */ void addPlugins( Session::Jingle& jingle, const Tag* tag ); private: /** * Creates a new instance. */ PluginFactory(); PluginList m_plugins; }; } } #endif // JINGLEPLUGINFACTORY_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/jingletransport.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/jingletransport.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/jingletransport.h (revision 27490) @@ -0,0 +1,60 @@ +/* + Copyright (c) 2008-2019 by Jakob Schröter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_JINGLE ) + +#ifndef JINGLETRANSPORT_H__ +#define JINGLETRANSPORT_H__ + +#include "jingleplugin.h" + +#include + +namespace gloox +{ + + namespace Jingle + { + + /** + * @brief An abstract base class of a Jingle Transport. This is part of Jingle (@xep{0166}). + * + * You should not need to use this class directly unless you are extending gloox. See + * @link gloox::Jingle::Session Jingle::Session @endlink for more info on Jingle. + * + * XEP Version: 1.1 + * + * @author Jakob Schröter + * @since 1.0.5 + */ + class GLOOX_API Transport : public Plugin + { + public: + /** + * Virtual destructor. + */ + virtual ~Transport() {} + + protected: + /** The Transport's namespace. */ +// const std::string m_xmlns; + + }; + + } + +} + +#endif // JINGLETRANSPORT_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/jingletransport.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/linklocalclient.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/linklocalclient.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/linklocalclient.h (revision 27490) @@ -1,125 +1,129 @@ /* Copyright (c) 2012-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_LINKLOCAL ) + #ifndef LINKLOCALCLIENT_H__ #define LINKLOCALCLIENT_H__ #include "config.h" #ifdef HAVE_MDNS #include "client.h" #include "jid.h" #include #include namespace gloox { class Tag; namespace LinkLocal { /** * @brief An implementation of a link-local client. * * See @ref gloox::LinkLocal::Manager for more information on how to implement * link-local messaging. * * @author Jakob Schröter * @since 1.0.x */ class Client : public gloox::Client { public: /** * Constructs a new instance. * @param jid The local JID to use. */ Client( const JID& jid ); /** * Virtual destructor. */ virtual ~Client(); /** * Internally sets up an already connected connection. * @note Use this function only on a Client instance that you created for an @b incoming connection. */ bool connect(); /** * Starts resolving the given service. Use values from Handler::handleBrowseReply(). * @param service The service to connect to. * @param type The service type. * @param domain The service's domain. * @param iface The network interface the service was found on. May be 0 to try * to resolve the service on all available interfaces. * @return @b True if resolving the service could be started successfully, @b false otherwise. * @note Use this function only for @b outgoing connections. */ bool connect( const std::string& service, const std::string& type, const std::string& domain, int iface = 0 ); /** * Call this periodically to receive data from the underlying socket. * @param timeout An optional timeout in microseconds. Default of -1 means blocking * until data was available. * @return The state of the underlying connection. */ virtual ConnectionError recv( int timeout = -1 ); // reimplemented from ConnectionDataHandler, overwriting ClientBase::handleConnect() virtual void handleConnect( const ConnectionBase* connection ); protected: // reimplemented from ClientBase virtual void handleStartNode( const Tag* start ); private: static void handleResolveReply( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context ); static void handleQueryReply( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl, void *context ); bool resolve( const std::string& serviceName, const std::string& regtype, const std::string& replyDomain ); bool query( const std::string& hostname, int port ); void handleQuery( const std::string& addr ); void sendStart( const std::string& to ); DNSServiceRef m_qRef; DNSServiceRef m_rRef; DNSServiceRef m_currentRef; std::string m_to; int m_interface; int m_port; bool m_streamSent; }; } } #endif // HAVE_MDNS #endif // LINKLOCALCLIENT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/md5.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/md5.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/md5.h (revision 27490) @@ -1,149 +1,157 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ /* Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. L. Peter Deutsch ghost@aladdin.com */ /* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */ /* Independent implementation of MD5 (RFC 1321). This code implements the MD5 Algorithm defined in RFC 1321, whose text is available at http://www.ietf.org/rfc/rfc1321.txt The code is derived from the text of the RFC, including the test suite (section A.5) but excluding the rest of Appendix A. It does not include any code or documentation that is identified in the RFC as being copyrighted. The original and principal author of md5.h is L. Peter Deutsch . Other authors are noted in the change history that follows (in reverse chronological order): 2002-04-13 lpd Removed support for non-ANSI compilers; removed references to Ghostscript; clarified derivation from RFC 1321; now handles byte order either statically or dynamically. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); added conditionalization for C++ compilation from Martin Purschke . 1999-05-03 lpd Original version. */ #ifndef MD5_H__ #define MD5_H__ #include "macros.h" #include namespace gloox { /** * @brief An MD5 implementation. * * This is an implementation of the Message Digest Algorithm as decribed in RFC 1321. * The original code has been taken from an implementation by L. Peter Deutsch. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MD5 { public: /** * Constructs a new MD5 object. */ MD5(); /** * Virtual Destructor. */ virtual ~MD5(); /** * Use this function to feed the hash. * @param data The data to hash. * @param bytes The size of @c data in bytes. */ void feed( const unsigned char* data, int bytes ); /** * Use this function to feed the hash. * @param data The data to hash. */ void feed( const std::string& data ); /** * This function is used to finalize the hash operation. Use it after the last feed() and * before calling hex(). */ void finalize(); /** * Use this function to retrieve the hash value in hex. * @return The hash in hex notation. */ const std::string hex(); /** * Use this function to retrieve the raw binary hash. * @return The raw binary hash. */ const std::string binary(); /** * Use this function to reset the hash. */ void reset(); - private: + /** + * Static function to quickly get an SHA1 hash in hex. + * @param data The data to hash. + * @return The hash in hex. + * @since 1.1 + */ + static const std::string hex( const std::string& data ); + + private: struct MD5State { unsigned int count[2]; /* message length in bits, lsw first */ unsigned int abcd[4]; /* digest buffer */ unsigned char buf[64]; /* accumulate block */ } m_state; void init(); void process( const unsigned char* data ); static const unsigned char pad[64]; bool m_finished; }; } #endif // MD5_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/messagefilter.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/messagefilter.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/messagefilter.h (revision 27490) @@ -1,84 +1,88 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MESSAGESESSION ) + #ifndef MESSAGEFILTER_H__ #define MESSAGEFILTER_H__ #include "messagesession.h" namespace gloox { class Message; /** * @brief Virtual base class for message filters. * * A message filter is fed with all messages passing through a MessageSession. It can * modify the XML/XMPP structure and/or the message content at will. Messages arriving * from the server as well as messages sent to the server can be altered. * * Messages to be sent out are presented to the filter via the decorate() function, incoming * messages can be filtered in the -- filter() method. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API MessageFilter { public: /** * Constructor. * @param parent The MessageSession to attach to. */ MessageFilter( MessageSession* parent ); /** * Virtual Destructor. */ virtual ~MessageFilter(); /** * Attaches this MessageFilter to the given MessageSession and hooks it into * the session's filter chain. * If this filter was attached to a different MessageSession before, it is * unregistered there prior to registering it with the new session. * @param session The MessageSession to hook into. */ virtual void attachTo( MessageSession* session ); /** * This function receives a message right before it is sent out (there may be other filters * which get to see the message after this filter, though). * @param msg The tag to decorate. It contains the message to be sent. */ virtual void decorate( Message& msg ) = 0; /** * This function receives a message stanza right after it was received (there may be other filters * which got to see the stanza before this filter, though). * @param msg The complete message stanza. */ virtual void filter( Message& msg ) = 0; protected: void send( Message& msg ) { if( m_parent ) m_parent->send( msg ); } MessageSession* m_parent; }; } #endif // MESSAGEFILTER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/mucinvitationhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/mucinvitationhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/mucinvitationhandler.h (revision 27490) @@ -1,67 +1,70 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) #ifndef MUCINVITATIONHANDLER_H__ #define MUCINVITATIONHANDLER_H__ #include "clientbase.h" #include "macros.h" #include "jid.h" #include namespace gloox { /** * @brief A handler that can be used to receive invitations to MUC rooms. * * Register a derived class with ClientBase::registerMUCInvitationHandler(). * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MUCInvitationHandler { public: /** * Constructor. Prepares the given ClientBase for receiving MUC invitations.. * @param parent A ClientBase instance to prepare. */ MUCInvitationHandler( ClientBase* parent ); /** * Virtual Destructor. */ virtual ~MUCInvitationHandler() {} /** * This function is called for incoming invitations to MUC rooms. * @param room The JID of the room you're being invited to. * @param from The JID of the inviter. * @param reason A reason for the invitation. * @param body The body of the message. May contain a MUC-service generated invitation message. * @param password Optionally, a password for the room. * @param cont Indicates whether or not the multi-user chat is a continuation of a private chat. * @param thread An optional thread identifier in case this is a * continued chat. */ virtual void handleMUCInvitation( const JID& room, const JID& from, const std::string& reason, const std::string& body, const std::string& password, bool cont, const std::string& thread ) = 0; }; } #endif // MUCINVITATIONHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/mucroom.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/mucroom.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/mucroom.h (revision 27490) @@ -1,994 +1,997 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) #ifndef MUCROOM_H__ #define MUCROOM_H__ #include "discohandler.h" #include "disconodehandler.h" #include "dataform.h" #include "presencehandler.h" #include "iqhandler.h" #include "messagehandler.h" #include "mucroomhandler.h" #include "mucroomconfighandler.h" #include "jid.h" #include "stanzaextension.h" #include namespace gloox { class ClientBase; class MUCMessageSession; class Message; /** * @brief This is an implementation of @xep{0045} (Multi-User Chat). * * Usage is pretty simple: * * Derrive an object from MUCRoomHandler and implement its virtuals: * @code * class MyClass : public MUCRoomHandler * { * ... * }; * @endcode * * Then create a new MUCRoom object and pass it a valid ClientBase, the desired full room JID, * your MUCRoomHandler-derived object, and an optional MUCRoomConfigHandler-derived object. * @code * void MyOtherClass::joinRoom( const std::string& room, const std::string& service, * const std::string& nick ) * { * MyClass* myHandler = new MyClass(...); * JID roomJID( room + "@" + service + "/" + nick ); * m_room = new MUCRoom( m_clientbase, roomJID, myHandler, 0 ); * m_room->join(); * } * @endcode * * When joining the room was successful, the various MUCRoomHandler functions will start to * be called. If joining was not successful, MUCRoomHandler::handleMUCError() will be called, * giving a hint at the reason for the failure. * * To set up your own room, or to configure an existing room, you should also derive a * class from MUCRoomConfigHandler and register it with the MUCRoom (either by using it * with MUCRoom's constructor, or by calling registerMUCRoomConfigHandler()). * * To quickly create an instant room, see InstantMUCRoom. * * To quickly create an instant room to turn a one-to-one chat into a multi-user chat, * see UniqueMUCRoom. * * To send a private message to a room participant, use * @link MessageSession gloox::MessageSession @endlink with the participant's full room JID * (room\@service/nick). * * XEP version: 1.21 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MUCRoom : private DiscoHandler, private PresenceHandler, public IqHandler, private MessageHandler, private DiscoNodeHandler { public: /** * Allowable history request types. To disable sending of history, use any value except * HistoryUnknown and specify a zero-length time span (using setRequestHistory()). */ enum HistoryRequestType { HistoryMaxChars, /**< Limit the total number of characters in the history to "X" * (where the character count is the characters of the complete * XML stanzas, not only their XML character data). */ HistoryMaxStanzas, /**< Limit the total number of messages in the history to "X". */ HistorySeconds, /**< Send only the messages received in the last "X" seconds. */ HistorySince, /**< Send only the messages received since the datetime specified * (which MUST conform to the DateTime profile specified in Jabber * Date and Time Profiles (@xep{0082})). */ HistoryUnknown /**< It is up to the service to decide how much history to send. * This is the default. */ }; /** * Available operations. */ enum MUCUserOperation { OpNone, /**< No operation. */ OpInviteTo, /**< Invitation being sent to soemone. */ OpInviteFrom, /**< Invitation received from someone. */ OpDeclineTo, /**< Someone's invitation declined. */ OpDeclineFrom /**< Someone declined an invitation. */ }; /** * @brief An abstraction of a MUC query. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0 */ class MUC : public StanzaExtension { public: /** * Creates a new MUC object. * @param password An optional room password. * @param historyType The type of room history to request. * @param historySince A string describing the amount of room history. * @param historyValue The amount of requested room history. */ MUC( const std::string& password, HistoryRequestType historyType = HistoryUnknown, const std::string& historySince = EmptyString, int historyValue = 0 ); /** * Constructs a new MUCUser object from the given Tag. * @param tag The Tag to parse. */ MUC( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~MUC(); /** * Returns a pointer to the current password, or 0. * @return A pointer to the current password, or 0. */ const std::string* password() const { return m_password; } /** * Returns a pointer to the description of the amount of room history requested. * @return A pointer to the description of the amount of room history requested. */ const std::string* historySince() const { return m_historySince; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new MUC( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { MUC* m = new MUC(); m->m_password = m_password ? new std::string( *m_password ) : 0; m->m_historySince = m_historySince ? new std::string( *m_historySince ) : 0; m->m_historyType = m_historyType; m->m_historyValue = m_historyValue; return m; } private: std::string* m_password; std::string* m_historySince; HistoryRequestType m_historyType; int m_historyValue; }; /** * @brief An abstraction of a MUC user query. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0 */ class MUCUser : public StanzaExtension { public: /** * Constructor. * @param operation An operation to perform. * @param to The recipient. * @param reason The reason for the operation. * @param thread If this is an invitation, and if the invitation is part of * a transformation of a one-to-one chat to a MUC, include the one-to-one chat's * thread ID here. Defaults to the empty string (i.e. not a continuation). */ MUCUser( MUCUserOperation operation, const std::string& to, const std::string& reason, const std::string& thread = EmptyString ); /** * Constructs a new MUCUser object from the given Tag. * @param tag The Tag to parse. */ MUCUser( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~MUCUser(); /** * Returns the current room flags. * @return The current room flags. */ int flags() const { return m_flags; } /** * Returns the user's current room affiliation. * @return The user's current room affiliation. */ MUCRoomAffiliation affiliation() const { return m_affiliation; } /** * Returns the user's current room role. * @return The user's current room role. */ MUCRoomRole role() const { return m_role; } /** * */ const std::string* jid() const { return m_jid; } /** * */ const std::string* actor() const { return m_actor; } /** * */ const std::string* password() const { return m_password; } /** * */ const std::string* thread() const { return m_thread; } /** * */ const std::string* reason() const { return m_reason; } /** * */ const std::string* newNick() const { return m_newNick; } /** * Returns an alternate venue, if set. * @return An alternate venue, if set. */ const std::string* alternate() const { return m_alternate; } /** * Whether or not the 'continue' flag is set. * @return Whether or not the 'continue' flag is set. */ bool continued() const { return m_continue; } /** * Returns the current operation. * @return The current operation. */ MUCUserOperation operation() const { return m_operation; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new MUCUser( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { MUCUser* m = new MUCUser(); m->m_affiliation = m_affiliation; m->m_role = m_role; m->m_jid = m_jid ? new std::string( *m_jid ) : 0; m->m_actor = m_actor ? new std::string( *m_actor ) : 0; m->m_thread = m_thread ? new std::string( *m_thread ) : 0; m->m_reason = m_reason ? new std::string( *m_reason ) : 0; m->m_newNick = m_newNick ? new std::string( *m_newNick ) : 0; m->m_password = m_password ? new std::string( *m_password ) : 0; m->m_alternate = m_alternate ? new std::string( *m_alternate ) : 0; m->m_operation = m_operation; m->m_flags = m_flags; m->m_del = m_del; m->m_continue = m_continue; return m; } private: static MUCRoomAffiliation getEnumAffiliation( const std::string& affiliation ); static MUCRoomRole getEnumRole( const std::string& role ); MUCRoomAffiliation m_affiliation; MUCRoomRole m_role; std::string* m_jid; std::string* m_actor; std::string* m_thread; std::string* m_reason; std::string* m_newNick; std::string* m_password; std::string* m_alternate; MUCUserOperation m_operation; int m_flags; bool m_del; bool m_continue; }; /** * Creates a new abstraction of a Multi-User Chat room. The room is not joined automatically. * Use join() to join the room, use leave() to leave it. * @param parent The ClientBase object to use for the communication. * @param nick The room's name and service plus the desired nickname in the form * room\@service/nick. * @param mrh The MUCRoomHandler that will listen to room events. May be 0 and may be specified * later using registerMUCRoomHandler(). However, without one, MUC is no joy. * @param mrch The MUCRoomConfigHandler that will listen to room config result. Defaults to 0 * initially. However, at the latest you need one when you create a new room which is not an * instant room. You can set a MUCRoomConfigHandler using registerMUCRoomConfigHandler(). */ MUCRoom( ClientBase* parent, const JID& nick, MUCRoomHandler* mrh, MUCRoomConfigHandler* mrch = 0 ); /** * Virtual Destructor. */ virtual ~MUCRoom(); /** * Use this function to set a password to use when joining a (password protected) * room. * @param password The password to use for this room. * @note This function does not password-protect a room. */ void setPassword( const std::string& password ) { m_password = password; } /** * A convenience function that returns the room's name. * @return The room's name. */ const std::string name() const { return m_nick.username(); } /** * A convenience function that returns the name/address of the MUC service the room is running on * (e.g., conference.jabber.org). * @return The MUC service's name/address. */ const std::string service() const { return m_nick.server(); } /** * A convenience function that returns the user's nickname in the room. * @return The user's nickname. */ const std::string nick() const { return m_nick.resource(); } /** * Join this room. * @param type The presence to join with, defaults to Available. * @param status The presence's optional status text. * @param priority The presence's optional priority, defaults to 0. * ClientBase will automatically include the default Presence extensions added using * @link gloox::ClientBase::addPresenceExtension() ClientBase::addPresenceExtension() @endlink. */ virtual void join( Presence::PresenceType type = Presence::Available, const std::string& status = EmptyString, int priority = 0 ); /** * Leave this room. * @param msg An optional msg indicating the reason for leaving the room. Default: empty. */ void leave( const std::string& msg = EmptyString ); /** * Sends a chat message to the room. * @param message The message to send. */ void send( const std::string& message ); /** * Sets the subject of the room to the given string. * The MUC service may decline the request to set a new subject. You should * not assume the subject was set successfully util it is acknowledged via the MUCRoomHandler. * @param subject The new subject. */ void setSubject( const std::string& subject ); /** * Returns the user's current affiliation with this room. * @return The user's current affiliation. */ MUCRoomAffiliation affiliation() const { return m_affiliation; } /** * Returns the user's current role in this room. * @return The user's current role. */ MUCRoomRole role() const { return m_role; } /** * Use this function to change the user's nickname in the room. * The MUC service may decline the request to set a new nickname. You should not assume * the nick change was successful until it is acknowledged via the MUCRoomHandler. * @param nick The user's new nickname. */ void setNick( const std::string& nick ); /** * Use this function to set the user's presence in this room. It is not possible to * use Unavailable with this function. * @param presence The user's new presence. * @param msg An optional status message. Default: empty. */ void setPresence( Presence::PresenceType presence, const std::string& msg = EmptyString ); /** * Use this function to invite another user to this room. * @param invitee The (bare) JID of the user to invite. * @param reason The user-supplied reason for the invitation. * @param thread If this invitation is part of a transformation of a * one-to-one chat to a MUC, include the one-to-one chat's thread ID here. Defaults * to the empty string (i.e. not a continuation). */ void invite( const JID& invitee, const std::string& reason, const std::string& thread = EmptyString ); /** * Use this function to request basic room info, possibly prior to joining it. * Results are announced using the MUCRoomHandler. */ void getRoomInfo(); /** * Use this function to request information about the current room occupants, * possibly prior to joining it. The room ay be configured not to disclose such * information. * Results are announced using the MUCRoomHandler. */ void getRoomItems(); /** * The MUC spec enables other entities to discover via Service Discovery which rooms * an entity is in. By default, gloox does not publish such info for privacy reasons. * This function can be used to enable publishing the info for @b this room. * @param publish Whether to enable other entities to discover the user's presence in * @b this room. * @param publishNick Whether to publish the nickname used in the room. This parameter * is ignored if @c publish is @b false. */ void setPublish( bool publish, bool publishNick ); /** * Use this function to register a (new) MUCRoomHandler with this room. There can be only one * MUCRoomHandler per room at any one time. * @param mrl The MUCRoomHandler to register. */ void registerMUCRoomHandler( MUCRoomHandler* mrl ) { m_roomHandler = mrl; } /** * Use this function to remove the registered MUCRoomHandler. */ void removeMUCRoomHandler() { m_roomHandler = 0; } /** * Use this function to register a (new) MUCRoomConfigHandler with this room. There can * be only one MUCRoomConfigHandler per room at any one time. * @param mrch The MUCRoomConfigHandler to register. */ void registerMUCRoomConfigHandler( MUCRoomConfigHandler* mrch ) { m_roomConfigHandler = mrch; } /** * Use this function to remove the registered MUCRoomConfigHandler. */ void removeMUCRoomConfigHandler() { m_roomConfigHandler = 0; } /** * Use this function to add history to a (newly created) room. The use case from the MUC spec * is to add history to a room that was created in the process of a transformation of a * one-to-one chat to a multi-user chat. * @param message A reason for declining the invitation. * @param from The JID of the original author of this part of the history. * @param stamp The datetime of the original message in the format: 20061224T12:15:23Z * @note You should not attempt to use this function before * MUCRoomHandler::handleMUCParticipantPresence() was called for the first time. */ void addHistory( const std::string& message, const JID& from, const std::string& stamp ); /** * Use this function to request room history. Set @c value to zero to disable the room * history request. You should not use HistorySince type with this function. * History is sent only once after entering a room. You should use this function before joining. * @param value Represents either the number of requested characters, the number of requested * message stanzas, or the number seconds, depending on the value of @c type. * @param type * @note If this function is not used to request a specific amount of room history, it is up * to the MUC service to decide how much history to send. */ void setRequestHistory( int value, HistoryRequestType type ); /** * Use this function to request room history since specific datetime. * History is sent only once after entering a room. You should use this function before joining. * @param since A string representing a datetime conforming to the DateTime profile specified * in Jabber Date and Time Profiles (@xep{0082}). * @note If this function is not used to request a specific amount of room history, it is up * to the MUC service to decide how much history to send. */ void setRequestHistory( const std::string& since ); /** * This static function allows to formally decline a MUC * invitation received via the MUCInvitationListener. * @param room The JID of the room the invitation came from. * @param invitor The JID of the invitor. * @param reason An optional reason for the decline. * @return A pointer to a Message. You will have to send (and * possibly delete) this Message manually. */ static Message* declineInvitation( const JID& room, const JID& invitor, const std::string& reason = EmptyString); /** * It is not possible for a visitor to speak in a moderated room. Use this function to request * voice from the moderator. */ void requestVoice(); /** * Use this function to kick a user from the room. * Depending on service and/or room configuration and role/affiliation * this may not always succeed. Usually, a role of 'moderator' is necessary. * @note This is a convenience function. It directly uses setRole() with a MUCRoomRole of RoleNone. * @param nick The nick of the user to be kicked. * @param reason An optional reason for the kick. */ void kick( const std::string& nick, const std::string& reason = EmptyString ) { setRole( nick, RoleNone, reason ); } /** * Use this function to ban a user from the room. * Depending on service and/or room configuration and role/affiliation * this may not always succeed. Usually, an affiliation of admin is necessary. * @note This is a convenience function. It directly uses setAffiliation() with a MUCRoomAffiliation * of RoleOutcast. * @param nick The nick of the user to be banned. * @param reason An optional reason for the ban. */ void ban( const std::string& nick, const std::string& reason ) { setAffiliation( nick, AffiliationOutcast, reason ); } /** * Use this function to grant voice to a user in a moderated room. * Depending on service and/or room configuration and role/affiliation * this may not always succeed. Usually, a role of 'moderator' is necessary. * @note This is a convenience function. It directly uses setRole() with a MUCRoomRole * of RoleParticipant. * @param nick The nick of the user to be granted voice. * @param reason An optional reason for the grant. */ void grantVoice( const std::string& nick, const std::string& reason ) { setRole( nick, RoleParticipant, reason ); } /** * Use this function to create a Tag that approves a voice request or registration request * delivered via MUCRoomConfigHandler::handleMUCVoiceRequest(). You will need to send this * Tag off manually using Client/ClientBase. * @param room The room's JID. This is needed because you can use this function outside of * room context (e.g, if the admin is not in the room). * @param df The filled-in DataForm from the voice/registration request. The form object * will be owned by the returned Message. */ static Message* createDataForm( const JID& room, const DataForm* df ); /** * Use this function to revoke voice from a user in a moderated room. * Depending on service and/or room configuration and role/affiliation * this may not always succeed. Usually, a role of 'moderator' is necessary. * @note This is a convenience function. It directly uses setRole() with a MUCRoomRole * of RoleVisitor. * @param nick The nick of the user. * @param reason An optional reason for the revoke. */ void revokeVoice( const std::string& nick, const std::string& reason ) { setRole( nick, RoleVisitor, reason ); } /** * Use this function to change the role of a user in the room. * Usually, at least moderator privileges are required to succeed. * @param nick The nick of the user who's role shall be modfified. * @param role The user's new role in the room. * @param reason An optional reason for the role change. */ void setRole( const std::string& nick, MUCRoomRole role, const std::string& reason = EmptyString ); /** * Use this function to change the affiliation of a user in the room. * Usually, at least admin privileges are required to succeed. * @param nick The nick of the user who's affiliation shall be modfified. * @param affiliation The user's new affiliation in the room. * @param reason An optional reason for the affiliation change. */ void setAffiliation( const std::string& nick, MUCRoomAffiliation affiliation, const std::string& reason ); /** * Use this function to request the room's configuration form. * It can be used either after MUCRoomHandler::handleMUCRoomCreation() was called, * or at any later time. * * Usually owner privileges are required for this action to * succeed. * * Use setRoomConfig() to send the modified room config back. */ void requestRoomConfig(); /** * After requesting (using requestRoomConfig()) and * editing/filling in the room's configuration, * use this function to send it back to the server. * @param form The form to send. The function will delete the * object pointed to. */ void setRoomConfig( DataForm* form ); /** * Use this function to accept the room's default configuration. This function is useful * only after MUCRoomHandler::handleMUCRoomCreation() was called. This is a NOOP at * any other time. */ void acknowledgeInstantRoom() { instantRoom( CreateInstantRoom ); } /** * Use this function to cancel the creation of a room. This function is useful only after * MUCRoomHandler::handleMUCRoomCreation() was called. This is a NOOP at any other time. */ void cancelRoomCreation() { instantRoom( CancelRoomCreation ); } /** * Use this function to destroy the room. All the occupants will be removed from the room. * @param reason An optional reason for the destruction. * @param alternate A pointer to a JID of an alternate venue (e.g., another MUC room). * May be 0. * @param password An optional password for the alternate venue. * * Usually owner privileges are required for this action to succeed. */ void destroy( const std::string& reason = EmptyString, const JID& alternate = JID(), const std::string& password = EmptyString ); /** * Use this function to request a particluar list of room occupants. * @note There must be a MUCRoomConfigHandler registered with this room for this * function to be executed. * @param operation The following types of lists are available: * @li Voice List: List of people having voice in a moderated room. Use RequestVoiceList. * @li Members List: List of members of a room. Use RequestMemberList. * @li Ban List: List of people banned from the room. Use RequestBanList. * @li Moderator List: List of room moderators. Use RequestModeratorList. * @li Admin List: List of room admins. Use RequestAdminList. * @li Owner List: List of room owners. Use RequestOwnerList. * Any other value of @c operation will be ignored. */ void requestList( MUCOperation operation ); /** * Use this function to store a (modified) list for the room. * @param items The list of items. Example:
* You want to set the Voice List. The privilege of Voice refers to the role of Participant. * Furthermore, you only store the delta of the original (Voice)List. (Optionally, you could * probably store the whole list, however, remeber to include those items that were modified, * too.) * You want to, say, add one occupant to the Voice List, and remove another one. * Therefore you store: * @li GuyOne, role participant -- this guy gets voice granted, he/she is now a participant. * @li GuyTwo, role visitor -- this guy gets voice revoked, he/she is now a mere visitor * (Visitor is the Role "below" Participant in the privileges hierarchy). * * For operations modifying Roles, you should specifiy only the new Role in the MUCListItem * structure, for those modifying Affiliations, you should only specify the new Affiliation, * respectively. The nickname is mandatory in the MUCListItem structure. Items without nickname * will be ignored. * * You may specify a reason for the role/affiliation change in the MUCListItem structure. * You should not specify a JID in the MUCListItem structure, it will be ignored. * * @param operation See requestList() for a list of available list types. Any other value will * be ignored. */ void storeList( const MUCListItemList items, MUCOperation operation ); /** * Returns the currently known room flags. * @return ORed MUCRoomFlag's describing the current room configuration. */ int flags() const { return m_flags; } // reimplemented from DiscoHandler virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context ); // reimplemented from DiscoHandler // reimplemented from DiscoHandler virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context ); // reimplemented from DiscoHandler virtual void handleDiscoError( const JID& from, const Error* error, int context ); // reimplemented from PresenceHandler virtual void handlePresence( const Presence& presence ); // reimplemented from MessageHandler virtual void handleMessage( const Message& msg, MessageSession* session = 0 ); // reimplemented from IqHandler virtual bool handleIq( const IQ& iq ) { (void)iq; return false; } // reimplemented from IqHandler virtual void handleIqID( const IQ& iq, int context ); // reimplemented from DiscoNodeHandler virtual StringList handleDiscoNodeFeatures( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::IdentityList handleDiscoNodeIdentities( const JID& from, const std::string& node ); // reimplemented from DiscoNodeHandler virtual Disco::ItemList handleDiscoNodeItems( const JID& from, const JID& to, const std::string& node = EmptyString ); protected: /** * Sets the room's name. * @param name The room's name. */ void setName( const std::string& name ) { m_nick.setUsername( name ); } /** * Acknowledges instant room creation w/o a call to the MUCRoomConfigHandler. * @return Whether an instant room is being created. */ virtual bool instantRoomHook() const { return false; } ClientBase* m_parent; JID m_nick; bool m_joined; private: #ifdef MUCROOM_TEST public: #endif /** * @brief An abstraction of a MUC owner query. * * @author Jakob Schröter * @since 1.0 */ class MUCOwner : public StanzaExtension { public: /** * Describes available query types for the muc#owner namespace. */ enum QueryType { TypeCreate, /**< Create a room. */ TypeRequestConfig, /**< Request room config. */ TypeSendConfig, /**< Submit configuration form to MUC service. */ TypeCancelConfig, /**< Cancel room configuration. */ TypeInstantRoom, /**< Request an instant room */ TypeDestroy, /**< Destroy the room. */ TypeIncomingTag /**< The Query has been created from an incoming Tag. */ }; /** * Creates a new MUCOwner object for the given query, possibly including * the given DataForm. * @param type The intended query type. * @param form An optional pointer to a DataForm. Necessity depends on the query type. */ MUCOwner( QueryType type, DataForm* form = 0 ); /** * Creates a new query that destroys the current room. * @param alternate An optional alternate discussion venue. * @param reason An optional reason for the room destruction. * @param password An optional password for the new room. */ MUCOwner( const JID& alternate = JID(), const std::string& reason = EmptyString, const std::string& password = EmptyString); /** * Creates a new MUCOwner object from the given Tag. * @param tag A Tag to parse. */ MUCOwner( const Tag* tag ); /** * Virtual destructor. */ virtual ~MUCOwner(); /** * Returns a pointer to a DataForm, included in the MUCOwner object. May be 0. * @return A pointer to a configuration form. */ const DataForm* form() const { return m_form; } // reimplemented from StanzaExtension const std::string& filterString() const; // reimplemented from StanzaExtension StanzaExtension* newInstance( const Tag* tag ) const { return new MUCOwner( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { MUCOwner* m = new MUCOwner(); m->m_type = m_type; m->m_jid = m_jid; m->m_reason = m_reason; m->m_pwd = m_pwd; m->m_form = m_form ? new DataForm( *m_form ) : 0; return m; } private: QueryType m_type; JID m_jid; std::string m_reason; std::string m_pwd; DataForm* m_form; }; /** * @brief An abstraction of a MUC admin query. * * @author Jakob Schröter * @since 1.0 */ class MUCAdmin : public StanzaExtension { public: /** * Creates a new object that can be used to change the role of a room participant. * @param role The participant's new role. * @param nick The participant's nick. * @param reason An optional reason for the role change. */ MUCAdmin( MUCRoomRole role, const std::string& nick, const std::string& reason = EmptyString ); /** * Creates a new object that can be used to change the affiliation of a room participant. * @param affiliation The participant's new affiliation. * @param nick The participant's nick. * @param reason An optional reason for the role change. */ MUCAdmin( MUCRoomAffiliation affiliation, const std::string& nick, const std::string& reason = EmptyString ); /** * Creates a new object that can be used to request or store a role/affiliation * list. * @param operation The MUCOperation to carry out. Only the Request* and Store* * operations are valid. Any other value will be ignored. * @param jids A list of bare JIDs. Only the JID member of the MUCListItem * structure should be set. The type of the list will be determined from the * @c operation parameter. */ MUCAdmin( MUCOperation operation, const MUCListItemList& jids = MUCListItemList() ); /** * Constructs a new MUCAdmin object from the given Tag. * @param tag The Tag to parse. */ MUCAdmin( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~MUCAdmin(); /** * Returns the contained list of MUC items. * @return The contained list of MUC items. */ const MUCListItemList& list() const { return m_list; } // reimplemented from StanzaExtension const std::string& filterString() const; // reimplemented from StanzaExtension StanzaExtension* newInstance( const Tag* tag ) const { return new MUCAdmin( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new MUCAdmin( *this ); } private: MUCListItemList m_list; MUCRoomAffiliation m_affiliation; MUCRoomRole m_role; }; void handleIqResult( const IQ& iq, int context ); void handleIqError( const IQ& iq, int context ); void setNonAnonymous(); void setSemiAnonymous(); void setFullyAnonymous(); void acknowledgeRoomCreation(); void instantRoom( int context ); MUCRoomHandler* m_roomHandler; MUCRoomConfigHandler* m_roomConfigHandler; MUCMessageSession* m_session; typedef std::list ParticipantList; ParticipantList m_participants; std::string m_password; std::string m_newNick; MUCRoomAffiliation m_affiliation; MUCRoomRole m_role; HistoryRequestType m_historyType; std::string m_historySince; int m_historyValue; int m_flags; bool m_creationInProgress; bool m_configChanged; bool m_publishNick; bool m_publish; bool m_unique; }; } #endif // MUCROOM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/nonsaslauth.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/nonsaslauth.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/nonsaslauth.h (revision 27490) @@ -1,147 +1,151 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NONSASLAUTH ) + #ifndef NONSASLAUTH_H__ #define NONSASLAUTH_H__ #include "iqhandler.h" #include namespace gloox { class Client; class Stanza; class Tag; /** * @brief This class is an implementation of @xep{0078} (Non-SASL Authentication). * * It is invoked by @ref Client automatically if supported by the server and if SASL authentication * is not supported. * You should not need to use this class manually. * * XEP Version: 2.3 * @author Jakob Schröter * @since 0.3 */ class GLOOX_API NonSaslAuth : public IqHandler { public: /** * Constructor. * @param parent The @ref ClientBase which is used to authenticate. */ NonSaslAuth( Client* parent ); /** * Virtual Destructor. */ virtual ~NonSaslAuth(); /** * Starts authentication by querying the server for the required authentication fields. * Digest authentication is preferred over plain text passwords. * @param sid The session ID given by the server with the stream opening tag. */ void doAuth( 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: #ifdef NONSASLAUTH_TEST public: #endif /** * @brief An abstraction of an IQ extension used for Non-SASL authentication (@xep{0078}). * * @author Jakob Schröter * @since 1.0 */ class Query : public StanzaExtension { public: /** * Creates a new object that can be used to query the server for * authentication filds for the given user. * @param user The user name to fetch authentication fields for. */ Query( const std::string& user ); /** * Creates a now object from the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag = 0 ); /** * Creates a new object on the heap that can be used to * authenticate, based on the current reply. * @param user The uset o authenticate as. * @param sid The stream's ID. * @param pwd The password to use. * @param resource The desired resource identifier. */ Query* newInstance( const std::string& user, const std::string& sid, const std::string& pwd, const std::string& resource ) const; /** * Virtual destructor. */ virtual ~Query() {} // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Query( *this ); } private: std::string m_user; std::string m_pwd; std::string m_resource; bool m_digest; }; enum NonSaslAuthTrack { TrackRequestAuthFields, TrackSendAuth }; Client* m_parent; std::string m_sid; }; } #endif // NONSASLAUTH_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/privacyitem.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/privacyitem.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/privacyitem.h (revision 27490) @@ -1,126 +1,130 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVACYLISTS ) + #ifndef PRIVACYITEM_H__ #define PRIVACYITEM_H__ #include "macros.h" #include "gloox.h" #include namespace gloox { /** * @brief This is an abstraction of a single item of a privacy list, describing an allowed or * forbidden action. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API PrivacyItem { public: /** * Three possible types of an item. Only one is allowed at a time. */ enum ItemType { TypeUndefined, /**< None of the types below is explicitely selected, * "fall-through" case. */ TypeJid, /**< The item affects the JID which is given in the value attribute. */ TypeGroup, /**< The item affects the group which is given in the value attribute and * which must exist at least once in the users roster. */ TypeSubscription /**< The item affects the subscription type which is given in the value * attribute. */ }; /** * Two possible actions. Only one is allowed at a time. */ enum ItemAction { ActionAllow, /**< The item explicitely allows the described packets. */ ActionDeny /**< The item forbids the described packets. */ }; /** * The packet type a privacy item affects (blocks). Combinations are allowed. */ enum ItemPacketType { PacketMessage = 1, /**< The item blocks message stanzas. */ PacketPresenceIn = 2, /**< The item blocks incoming presence stanzas. */ PacketPresenceOut = 4, /**< The item blocks outgoing presence stanzas. */ PacketIq = 8, /**< The item blocks IQ stanzas. */ PacketAll = 15 /**< The item blocks all of these stanza types. */ }; /** * Constructs a new privacy item. * @param type Action is based on matching JID, Group or Subscription. * @param action The action to carry out. (Deny or allow.) * @param packetType Affected packet types. Bit-wise OR'ed ItemPacketType. * @param value The value to check for and match. */ PrivacyItem( const ItemType type = TypeUndefined, const ItemAction action = ActionAllow, const int packetType = 0, const std::string& value = EmptyString ); /** * Virtual destructor. */ virtual ~PrivacyItem(); /** * Returns the item type. * @return The type of the item. */ ItemType type() const { return m_type; } /** * Returns the item's action. * @return The action of the item. */ ItemAction action() const { return m_action; } /** * Returns the packet type the item affects. * @return An OR'ed list of affected packet types. */ int packetType() const { return m_packetType; } /** * Returns the value of the item's 'value' attribute. * @return value The 'value' attribute's value. */ const std::string value() const { return m_value; } /** * Compares the current PrivacyItem with another one. * @param item The item which shall be compared. * @return @b True if both items are equal, @b false otherwise. */ bool operator==( const PrivacyItem& item ) const; private: ItemType m_type; ItemAction m_action; int m_packetType; std::string m_value; }; } #endif // PRIVACYITEM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/privatexmlhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/privatexmlhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/privatexmlhandler.h (revision 27490) @@ -1,73 +1,76 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) #ifndef PRIVATEXMLHANDLER_H__ #define PRIVATEXMLHANDLER_H__ #include "macros.h" #include namespace gloox { class Tag; /** * @brief A virtual interface which can be reimplemented to store and receive private XML data. * * Derived classes can be registered as PrivateXMLHandlers with the PrivateXML object. * Upon an incoming PrivateXML packet @ref handlePrivateXML() will be called. * * @author Jakob Schröter */ class GLOOX_API PrivateXMLHandler { public: /** * Describes the possible results of a 'store' or 'request' operation. */ enum PrivateXMLResult { PxmlStoreOk, /**< Storing was successful. */ PxmlStoreError, /**< An error occurred while storing data in Private XML. */ PxmlRequestError /**< An error occurred while requesting Private XML. */ }; /** * Virtual Destructor. */ virtual ~PrivateXMLHandler() {} /** * Reimplement this function to receive the private XML that was requested earlier using * @c PrivateXML::requestXML(). * @param xml The private xml, i.e. the first child of the <query> tag. * May be 0. You should not delete the object. */ virtual void handlePrivateXML( const Tag* xml ) = 0; /** * This function is called to notify about the result of a 'store' or 'request' operation * (successful requests are announced by means of handlePrivateXML()). * @param uid The ID of the query. * @param pxResult The result of the operation. * @since 0.7 */ virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult ) = 0; }; } #endif // PRIVATEXMLHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pubsubmanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pubsubmanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/pubsubmanager.h (revision 27490) @@ -1,868 +1,873 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PUBSUB ) + #ifndef PUBSUBMANAGER_H__ #define PUBSUBMANAGER_H__ #include "pubsub.h" #include "dataform.h" #include "iqhandler.h" #include "mutex.h" #include #include namespace gloox { class ClientBase; namespace PubSub { class ResultHandler; /** * @brief This manager is used to interact with PubSub services (@xep{0060}). * * @note PubSub support in gloox is still relatively young and you are most * welcome to ask questions, criticize the API and so on. * * A ResultHandler is used to receive a request's result. Depending on the * context, this can be a notification that an item has been succesfully * deleted (or not), or the default node configuration for a service. * * To receive PubSub events: * @li Tell ClientBase that you are interested in PubSub events by registering * an empty PubSub::Event StanzaExtension * @code * m_client->registerStanzaExtension( new PubSub::Event() ); * @endcode * @li Implement a MessageHandler and register it with ClientBase, or use the MessageSession interface, at your choice, * @li When receiving a Message, check it for a PubSub::Event * @code * const PubSub::Event* pse = msg.findExtension( ExtPubSubEvent ); * if( pse ) * { * // use the Event * } * else * { * // no Event * } * @endcode * * To interact with PubSub services, you will need to * instantiate a PubSub::Manager and * implement the ResultHandler virtual interfaces to be notified of the * result of requests. * * @note A null ResultHandler to a query is not allowed and is a no-op. * * XEP Version: 1.12 * * @author Jakob Schröter - * @author Vincent Thomasset + * @author Vincent Thomasset * * @since 1.0 */ class GLOOX_API Manager : public IqHandler { public: /** * Initialize the manager. * @param parent Client to which this manager belongs. */ Manager( ClientBase* parent ); /** * Default virtual destructor. */ virtual ~Manager() {} /** * Subscribe to a node. * * @param service Service hosting the node. * @param node ID of the node to subscribe to. * @param handler The ResultHandler. * @param jid JID to subscribe. If empty, the client's JID will be used * (ie. self subscription). * @param type SubscriptionType of the subscription (Collections only). * @param depth Subscription depth. For 'all', use 0 (Collections only). * @param expire Subscription expiry. Defaults to the empty string. * @return The IQ ID used in the request. * * @see ResultHandler::handleSubscriptionResult */ const std::string subscribe( const JID& service, const std::string& node, ResultHandler* handler, const JID& jid = JID(), SubscriptionObject type = SubscriptionNodes, int depth = 1, const std::string& expire = EmptyString ); /** * Subscribe to a node and configure options. * * @param service Service hosting the node. * @param node ID of the node to subscribe to. * @param handler The ResultHandler. * @param jid JID to subscribe. If empty, the client's JID will be used * (ie. self subscription). * @param options The options to configure while subscribing. * Should be a TypeSubmit form, with a field named FORM_TYPE having the value * http://jabber.org/protocol/pubsub#subscribe_options * See @xep{0060}, "Subscribe and Configure". * Will be owned and deleted by the PubSub object. * @return The IQ ID used in the request. * * @see ResultHandler::handleSubscriptionResult */ const std::string subscribe( const JID& service, const std::string& node, ResultHandler* handler, const JID& jid, DataForm* options ); /** * Unsubscribe from a node. * * @param service Service hosting the node. * @param node ID of the node to unsubscribe from. * @param subid An optional, additional subscription ID. * @param handler ResultHandler receiving the result notification. * @param jid JID to unsubscribe. If empty, the client's JID will be * used (ie self unsubscription). * @return The IQ ID used in the request. * * @see ResultHandler::handleUnsubscriptionResult */ const std::string unsubscribe( const JID& service, const std::string& node, const std::string& subid, ResultHandler* handler, const JID& jid = JID() ); /** * Requests the subscription list from a service. * * @param service Service to query. * @param handler The ResultHandler to handle the result. * @return The IQ ID used in the request. * * @see ResultHandler::handleSubscriptions */ const std::string getSubscriptions( const JID& service, ResultHandler* handler ) { return getSubscriptionsOrAffiliations( service, handler, GetSubscriptionList ); } /** * Requests the affiliation list from a service. * * @param service Service to query. * @param handler The ResultHandler to handle the result. * @return The IQ ID used in the request. * * @see ResultHandler::handleAffiliations */ const std::string getAffiliations( const JID& service, ResultHandler* handler ) { return getSubscriptionsOrAffiliations( service, handler, GetAffiliationList ); } /** * Requests subscription options. * * @param service Service to query. * @param jid Subscribed entity. * @param node Node ID of the node. * @param handler The SubscriptionListHandler to handle the result. * @param subid An optional subscription ID. * @return The IQ ID used in the request. * * @see ResultHandler::handleSubscriptionOptions */ const std::string getSubscriptionOptions( const JID& service, const JID& jid, const std::string& node, ResultHandler* handler, const std::string& subid = EmptyString) { return subscriptionOptions( GetSubscriptionOptions, service, jid, node, handler, 0, subid ); } /** * Modifies subscription options. * * @param service Service to query. * @param jid Subscribed entity. * @param node Node ID of the node. * @param df New configuration. The DataForm will be owned and deleted by the Manager. * @param handler The handler to handle the result. * @param subid An optional subscription ID. * @return The IQ ID used in the request. * * @see ResultHandler::handleSubscriptionOptionsResult */ const std::string setSubscriptionOptions( const JID& service, const JID& jid, const std::string& node, DataForm* df, ResultHandler* handler, const std::string& subid = EmptyString ) { return subscriptionOptions( SetSubscriptionOptions, service, jid, node, handler, df, subid ); } /** * Requests the affiliation list for a node. * * @param service Service to query. * @param node Node ID of the node. * @param handler The AffiliationListHandler to handle the result. * * @see ResultHandler::handleAffiliations */ void getAffiliations( const JID& service, const std::string& node, ResultHandler* handler ); /** * Requests items from a node. * @param service Service to query. * @param node Node ID of the node. * @param subid An optional subscription ID. * @param maxItems The optional maximum number of items to return. * @param handler The handler to handle the result. * @return The ID used in the request. */ const std::string requestItems( const JID& service, const std::string& node, const std::string& subid, int maxItems, ResultHandler* handler); /** * Requests specific items from a node. * @param service Service to query. * @param node Node ID of the node. * @param subid An optional subscription ID. * @param items The list of item IDs to request. * @param handler The handler to handle the result. * @return The ID used in the request. */ const std::string requestItems( const JID& service, const std::string& node, const std::string& subid, const ItemList& items, ResultHandler* handler); /** * Publish an item to a node. The Tag to publish is destroyed * by the function before returning. * * @param service Service hosting the node. * @param node ID of the node to delete the item from. * @param items One or more items to publish. The items will be owned and deleted by the Manager, * even in the error case (empty string returned). * @param options An optional DataForm containing publish options. The DataForm will be owned and deleted by the Manager. * @param handler The handler to handle the result. * @return The ID used in the request. * * @see ResultHandler::handleItemPublication */ const std::string publishItem( const JID& service, const std::string& node, ItemList& items, DataForm* options, ResultHandler* handler ); /** * Delete an item from a node. * * @param service Service hosting the node. * @param node ID of the node to delete the item from. * @param items A list of items to delete (only ID filled in). * @param notify Whether or not to notify subscribers about the deletion. * @param handler The handler to handle the result. * @return The ID used in the request. * * @see ResultHandler::handleItemDeletation */ const std::string deleteItem( const JID& service, const std::string& node, const ItemList& items, bool notify, ResultHandler* handler ); /** * Creates a new node. * * @param service Service where to create the new node. * @param node The ID of the new node. * @param config An optional DataForm that holds the node configuration. * The DataForm will be owned and deleted by the Manager. * @param handler The handler to handle the result. * @return The ID used in the request. * * @see ResultHandler::handleNodeCreation */ const std::string createNode( const JID& service, const std::string& node, DataForm* config, ResultHandler* handler ); /** * Deletes a node. * * @param service Service where to create the new node. * @param node Node ID of the new node. * @param handler The handler to handle the result. * @return The ID used in the request. * * @see ResultHandler::handleNodeDeletion */ const std::string deleteNode( const JID& service, const std::string& node, ResultHandler* handler ); /** * Retrieves the default configuration for a specific NodeType. * * @param service The queried service. * @param type NodeType to get default configuration for. * @param handler ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleDefaultNodeConfig */ const std::string getDefaultNodeConfig( const JID& service, NodeType type, ResultHandler* handler ); /** * Removes all the items from a node. * * @param service Service to query. * @param node Node ID of the node. * @param handler ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleNodePurge */ const std::string purgeNode( const JID& service, const std::string& node, ResultHandler* handler ); /** * Requests the subscriber list for a node. * * @param service Service to query. * @param node Node ID of the node. * @param handler ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleSubscribers */ const std::string getSubscribers( const JID& service, const std::string& node, ResultHandler* handler ) { return subscriberList( GetSubscriberList, service, node, SubscriberList(), handler ); } /** * Modifies the subscriber list for a node. This function SHOULD only set the * subscriber list to those which needs modification. * * @param service Service to query. * @param node Node ID of the node. * @param list The subscriber list. * @param handler The ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleSubscribers */ const std::string setSubscribers( const JID& service, const std::string& node, const SubscriberList& list, ResultHandler* handler ) { return subscriberList( SetSubscriberList, service, node, list, handler ); } /** * Requests the affiliate list for a node. * * @param service Service to query. * @param node Node ID of the node. * @param handler ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleAffiliates */ const std::string getAffiliates( const JID& service, const std::string& node, ResultHandler* handler ) { return affiliateList( GetAffiliateList, service, node, AffiliateList(), handler ); } /** * Modifies the affiliate list for a node. * * @param service Service to query. * @param node Node ID of the node. * @param list ResultHandler. * @param handler ResultHandler. * @return The ID used in the request. * * @see ResultHandler::handleAffiliatesResult */ const std::string setAffiliates( const JID& service, const std::string& node, const AffiliateList& list, ResultHandler* handler ) { return affiliateList( SetAffiliateList, service, node, list, handler ); } /** * Retrieve the configuration (options) of a node. * * @param service Service hosting the node. * @param node ID of the node. * @param handler ResultHandler responsible to handle the request result. * @return The ID used in the request. * * @see ResultHandler::handleNodeConfig */ const std::string getNodeConfig( const JID& service, const std::string& node, ResultHandler* handler ) { return nodeConfig( service, node, 0, handler ); } /** * Changes a node's configuration (options). * * @param service Service to query. * @param node Node ID of the node. * @param config The node's configuration DataForm. * @param handler ResultHandler responsible to handle the request result. * @return The ID used in the request. * * @see ResultHandler::handleNodeConfigResult */ const std::string setNodeConfig( const JID& service, const std::string& node, DataForm* config, ResultHandler* handler ) { return nodeConfig( service, node, config, handler ); } /** * Removes an ID from our tracking lists. * @param id The ID to remove. * @return @b True if the ID was found and removed, @b false otherwise. */ bool removeID( const std::string& id ); // reimplemented from DiscoHandler void handleDiscoInfoResult( IQ* iq, int context ); // reimplemented from DiscoHandler void handleDiscoItemsResult( IQ* iq, int context ); // reimplemented from DiscoHandler void handleDiscoError( IQ* iq, int context ); // reimplemented from DiscoHandler bool handleDiscoSet( IQ* ) { return 0; } // 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: #ifdef PUBSUBMANAGER_TEST public: #endif enum TrackContext { Subscription, Unsubscription, GetSubscriptionOptions, SetSubscriptionOptions, GetSubscriptionList, GetSubscriberList, SetSubscriberList, GetAffiliationList, /**< Requests the list of one's own affiliations from a service (XEP-0060 section 5.7) */ GetAffiliateList, /**< Requests the list of affiliates for a node (XEP-0060 section 8.9.1) */ SetAffiliateList, /**< Sets/modifies/deletes the list of affiliates for a node (XEP-0060 section 8.9.2 */ GetNodeConfig, SetNodeConfig, DefaultNodeConfig, GetItemList, PublishItem, DeleteItem, CreateNode, DeleteNode, PurgeNodeItems, NodeAssociation, NodeDisassociation, GetFeatureList, DiscoServiceInfos, DiscoNodeInfos, DiscoNodeItems, RequestItems, InvalidContext }; class PubSubOwner : public StanzaExtension { public: /** * Creates a new PubSubOwner object that can be used to request the given type. * @param context The requets type. */ PubSubOwner( TrackContext context = InvalidContext ); /** * Creates a new PubSubOwner object by parsing the given Tag. * @param tag The Tag to parse. */ PubSubOwner( const Tag* tag ); /** * Virtual destructor. */ virtual ~PubSubOwner(); /** * Sets the node to use in e.g. subscription requests. * @param node The node to use. */ void setNode( const std::string& node ) { m_node = node; } /** * Returns the pubsub node. * @return The pubsub node. */ const std::string& node() const { return m_node; } /** * Sets an options DataForm. * @param options The DataForm. */ void setConfig( DataForm* config ) { m_form = config; } /** * Returns the config DataForm. * @return The config DataForm. */ const DataForm* config() const { return m_form; } /** * Sets the subscriber list. * @param subList The subscriber list. */ void setSubscriberList( const SubscriberList& subList ) { m_subList = subList; } /** * Sets the affiliate list. * @param affList The affiliate list. */ void setAffiliateList( const AffiliateList& affList ) { m_affList = affList; } /** * Returns the list of affiliates. Don't delete the pointer, it is still owned by PubSubOwner. * @return The list of affiliates. */ const AffiliateList* affiliateList() const { return &m_affList; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new PubSubOwner( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { PubSubOwner* p = new PubSubOwner(); p->m_node = m_node; p->m_ctx = m_ctx; p->m_form = m_form ? new DataForm( *m_form ) : 0; p->m_subList = m_subList; p->m_affList = m_affList; return p; } private: std::string m_node; TrackContext m_ctx; DataForm* m_form; SubscriberList m_subList; AffiliateList m_affList; }; class PubSub : public StanzaExtension { public: /** * Creates a new PubSub object that can be used to request the given type. * @param context The requets type. */ PubSub( TrackContext context = InvalidContext ); /** * Creates a new PubSub object by parsing the given Tag. * @param tag The Tag to parse. */ PubSub( const Tag* tag ); /** * Virtual destructor. */ virtual ~PubSub(); /** * Sets the JID to use in e.g. subscription requests. * @param jid The JID to use. */ void setJID( const JID& jid ) { m_jid = jid; } /** * Returns the pubsub JID (not the service JID). * @return The pubsub JID. */ const JID& jid() const { return m_jid; } /** * Sets the node to use in e.g. subscription requests. * @param node The node to use. */ void setNode( const std::string& node ) { m_node = node; } /** * Returns the pubsub node. * @return The pubsub node. */ const std::string& node() const { return m_node; } /** * Returns the tracking context. * @return The tracking context value. */ TrackContext context() const { return m_ctx; } /** * Sets the Subscription ID to use. * @param subid The Subscription ID to use. */ void setSubscriptionID( const std::string& subid ) { m_subid = subid; } /** * Gets the Subscription ID to use. * @return The Subscription ID to use. */ const std::string& subscriptionID() const { return m_subid; } /** * Sets the subscription options. * @param node The node to set the options for. * @param df The DataForm holding the subscription options. * Will be owned and deleted by the PubSub object */ void setOptions( const std::string& node, DataForm* df ) { m_options.node = node; if( m_options.df != 0 ) delete m_options.df; m_options.df = df; } /** * Returns the subscription options. * @return The subscription options. */ const DataForm* options() const { return m_options.df; } /** * Returns the current Items. * @return The current items. */ const ItemList& items() const { return m_items; } /** * Sets the subscription IDs. * @param ids Subscription IDs. */ void setItems( const ItemList& items ) { m_items = items; } /** * Sets the maximum number of items to request. * @param maxItems The maximum number of items to request. */ void setMaxItems( int maxItems ) { m_maxItems = maxItems; } /** * Returns the subscriptions. * @param The subscriptions. */ const SubscriptionMap& subscriptions() const { return m_subscriptionMap; } /** * Returns the affiliations. * @param The affiliations. */ const AffiliationMap& affiliations() const { return m_affiliationMap; } /** * Sets whether or not a notify element should be included in a 'retract'. * @param notify Indicates whether a notify attribute is included. */ void setNotify( bool notify ) { m_notify = notify; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new PubSub( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; private: AffiliationMap m_affiliationMap; SubscriptionMap m_subscriptionMap; TrackContext m_ctx; struct Options { std::string node; DataForm* df; }; Options m_options; JID m_jid; std::string m_node; std::string m_subid; ItemList m_items; int m_maxItems; bool m_notify; }; /** * This function sets or requests a node's configuration form * (depending on arguments). Does the actual work for requestNodeConfig * and setNodeConfig. * Requests or changes a node's configuration. * @param service Service to query. * @param node Node ID of the node. * @param config If not NULL, the function will request the node config. * Otherwise, it will set the config based on the form. * @param handler ResultHandler responsible to handle the request result. */ const std::string nodeConfig( const JID& service, const std::string& node, DataForm* config, ResultHandler* handler ); /** * This function sets or requests a node's subscribers list form * (depending on arguments). Does the actual work for * requestSubscriberList and setSubscriberList. * Requests or changes a node's configuration. * @param ctx The operation to be performed. * @param service Service to query. * @param node Node ID of the node. * @param config If not NULL, the function will request the node config. * Otherwise, it will set the config based on the form. * @param handler ResultHandler responsible to handle the request result. * @return The ID used in the request. */ const std::string subscriberList( TrackContext ctx, const JID& service, const std::string& node, const SubscriberList& config, ResultHandler* handler ); /** * This function sets or requests a node's affiliates list * (depending on arguments). Does the actual work for * requestAffiliateList and setAffiliateList. * Requests or changes a node's configuration. * @param ctx The operation to be performed. * @param service Service to query. * @param node Node ID of the node. * @param config If not NULL, the function will request the node config. * Otherwise, it will set the config based on the form. * @param handler ResultHandler responsible to handle the request result. * @return The ID used in the request. */ const std::string affiliateList( TrackContext ctx, const JID& service, const std::string& node, const AffiliateList& config, ResultHandler* handler ); const std::string subscriptionOptions( TrackContext context, const JID& service, const JID& jid, const std::string& node, ResultHandler* handler, DataForm* df, const std::string& subid = EmptyString ); const std::string getSubscriptionsOrAffiliations( const JID& service, ResultHandler* handler, TrackContext context ); typedef std::map < std::string, std::string > NodeOperationTrackMap; typedef std::map < std::string, ResultHandler* > ResultHandlerTrackMap; ClientBase* m_parent; NodeOperationTrackMap m_nopTrackMap; ResultHandlerTrackMap m_resultHandlerTrackMap; util::Mutex m_trackMapMutex; }; } } #endif // PUBSUBMANAGER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/registration.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/registration.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/registration.h (revision 27490) @@ -1,339 +1,330 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_REGISTRATION ) + #ifndef REGISTRATION_H__ #define REGISTRATION_H__ #include "iqhandler.h" #include "registrationhandler.h" -#include "dataform.h" #include "jid.h" #include "oob.h" #include #include namespace gloox { class ClientBase; + class DataForm; class Stanza; /** * Holds all the possible fields a server may require for registration according * to Section 14.1, @xep{0077}. */ struct RegistrationFields { std::string username; /**< Desired username. */ std::string nick; /**< User's nickname. */ std::string password; /**< User's password. */ std::string name; /**< User's name. */ std::string first; /**< User's first name.*/ std::string last; /**< User's last name. */ std::string email; /**< User's email address. */ std::string address; /**< User's address. */ std::string city; /**< User's city. */ std::string state; /**< User's state. */ std::string zip; /**< User's ZIP code. */ std::string phone; /**< User's phone number. */ std::string url; /**< User's homepage URL (or other URL). */ std::string date; /**< Date (?) */ - std::string misc; /**< Misc (?) */ - std::string text; /**< Text (?)*/ }; /** * @brief This class is an implementation of @xep{0077} (In-Band Registration). * * Derive your object from @ref RegistrationHandler and implement the * virtual functions offered by that interface. Then use it like this: * @code * void MyClass::myFunc() * { * m_client = new Client( "example.org" ); * m_client->disableRoster(); // a roster is not necessary for registration * m_client->registerConnectionListener( this ); * * m_reg = new Registration( c ); * m_reg->registerRegistrationHandler( this ); * * m_client->connect(); * } * * void MyClass::onConnect() * { * m_reg->fetchRegistrationFields(); * } * @endcode * * In RegistrationHandler::handleRegistrationFields() you should check which information the server * requires to open a new account. You might not always get away with just username and password. * Then call createAccount() with a filled-in RegistrationFields and an @c int representing the bit-wise * ORed fields you want to have included in the registration attempt. For your convenience you can * use the 'fields' argument of handleRegistrationFields(). ;) It's your responsibility to make * sure at least those fields the server requested are filled in. * * Check @c tests/register_test.cpp for an example. * + * XEP Version: 2.4 + * * @author Jakob Schröter * @since 0.2 */ class GLOOX_API Registration : public IqHandler { public: /** * The possible fields of a @xep{0077} account registration. */ enum fieldEnum { FieldUsername = 1, /**< Username requested */ FieldNick = 2, /**< Nickname requested */ FieldPassword = 4, /**< Password requested */ FieldName = 8, /**< Name requested */ FieldFirst = 16, /**< Given name requested */ FieldLast = 32, /**< Family name requested */ FieldEmail = 64, /**< Email address requested */ FieldAddress = 128, /**< Postal address requested */ FieldCity = 256, /**< Locality requested */ FieldState = 512, /**< State/Province requested */ FieldZip = 1024, /**< ZIP requested */ FieldPhone = 2048, /**< Phone no. requested */ FieldUrl = 4096, /**< Homepage or other URL requested */ - FieldDate = 8192, /**< Date requested (unknown purpose; see @xep{0077}) */ - FieldMisc = 16384, /**< Misc data requested (unknown purpose; see @xep{0077}) */ - FieldText = 32768 /**< Extra text requested (unknown purpose; see @xep{0077}) */ + FieldDate = 8192 /**< Date requested (unknown purpose; see @xep{0077}) */ }; /** * @brief A wrapping class for the @xep{0077} <query> element. * * @author Jakob Schröter * @since 1.0 */ class Query : public StanzaExtension { public: /** * Creates a new object that can be used to carry out a registration. * @param form A DataForm containing the registration terms. */ Query( DataForm* form ); /** * Creates a new object that can be used to carry out a registration. * @param del Whether or not to remove the account. */ Query( bool del = false ); /** * Creates a new object that can be used to carry out a registration. * @param fields Bit-wise ORed fieldEnum values describing the valid (i.e., set) * fields in the @b values parameter. * @param values Contains the registration fields. */ Query( int fields, const RegistrationFields& values ); /** * Creates a new object from the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag ); /** * Virtual Destructor. */ virtual ~Query(); /** * Returns the contained registration form, if any. * @return The registration form. May be 0. */ const DataForm* form() const { return m_form; } /** * Returns the registration instructions, if given * @return The registration instructions. */ const std::string& instructions() const { return m_instructions; } /** * Returns the registration fields, if set. * @return The registration fields. */ int fields() const { return m_fields; } /** * */ const RegistrationFields& values() const { return m_values; } /** * Indicates whether the account is already registered. * @return @b True if the <registered> element is present, @b false otherwise. */ bool registered() const { return m_reg; } /** * Indicates whether the account shall be removed. * @return @b True if the <remove> element is present, @b false otherwise. */ bool remove() const { return m_del; } /** * Returns an optional OOB object. * @return A pointer to an OOB object, if present, 0 otherwise. */ const OOB* oob() const { return m_oob; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension - virtual StanzaExtension* clone() const - { - Query* q = new Query(); - q->m_form = m_form ? new DataForm( *m_form ) : 0; - q->m_fields = m_fields; - q->m_values = m_values; - q->m_instructions = m_instructions; - q->m_oob = new OOB( *m_oob ); - q->m_del = m_del; - q->m_reg = m_reg; - return q; - } + virtual StanzaExtension* clone() const; private: DataForm* m_form; int m_fields; RegistrationFields m_values; std::string m_instructions; OOB* m_oob; bool m_del; bool m_reg; }; /** * Constructor. * @param parent The ClientBase which is used for establishing a connection. * @param to The server or service to authenticate with. If empty the currently connected * server will be used. */ Registration( ClientBase* parent, const JID& to ); /** * Constructor. Registration will be attempted with the ClientBase's connected host. * @param parent The ClientBase which is used for establishing a connection. */ Registration( ClientBase* parent ); /** * Virtual destructor. */ virtual ~Registration(); /** * Use this function to request the registration fields the server requires. * The required fields are returned asynchronously to the object registered as * @ref RegistrationHandler by calling @ref RegistrationHandler::handleRegistrationFields(). */ void fetchRegistrationFields(); /** * Attempts to register an account with the given credentials. Only the fields OR'ed in * @c fields will be sent. This can only be called with an unauthenticated parent (@ref Client). * @note It is recommended to use @ref fetchRegistrationFields to find out which fields the * server requires. * @param fields The fields to use to generate the registration request. OR'ed * @ref fieldEnum values. * @param values The struct contains the values which shall be used for the registration. * @return Returns @b true if the registration request was sent successfully, @b false * otherwise. In that case either there's no connected ClientBase available, or * prepping of the username failed (i.e. the username is not valid for use in XMPP). */ bool createAccount( int fields, const RegistrationFields& values ); /** * Attempts to register an account with the given credentials. This can only be called with an * unauthenticated parent (@ref Client). * @note According to @xep{0077}, if the server sends both old-style fields and data form, * implementations SHOULD prefer data forms. * @param form The DataForm containing the registration credentials. */ void createAccount( DataForm* form ); /** * Tells the server to remove the currently authenticated account from the server. */ void removeAccount(); /** * Tells the server to change the password for the current account. * @param username The username to change the password for. You might want to use * Client::username() to get the current prepped username. * @param password The new password. */ void changePassword( const std::string& username, const std::string& password ); /** * Registers the given @c rh as RegistrationHandler. Only one handler is possible at a time. * @param rh The RegistrationHandler to register. */ void registerRegistrationHandler( RegistrationHandler* rh ); /** * Un-registers the current RegistrationHandler. */ void removeRegistrationHandler(); // 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: #ifdef REGISTRATION_TEST public: #endif enum IdType { FetchRegistrationFields, CreateAccount, RemoveAccount, ChangePassword }; Registration operator=( const Registration& ); void init(); ClientBase* m_parent; const JID m_to; RegistrationHandler* m_registrationHandler; }; } #endif // REGISTRATION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/rosteritemdata.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosteritemdata.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosteritemdata.h (revision 27490) @@ -1,232 +1,154 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 ROSTERITEMBASE_H__ -#define ROSTERITEMBASE_H__ +#ifndef ROSTERITEMDATA_H__ +#define ROSTERITEMDATA_H__ +#include "rosterxitemdata.h" +#include "rosteritembase.h" #include "gloox.h" #include "jid.h" #include "tag.h" #include #include namespace gloox { /** - * @brief A class holding roster item data. + * @brief A class holding (some more) roster item data. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 1.0 */ - class GLOOX_API RosterItemData + class GLOOX_API RosterItemData : public RosterItemBase { public: /** * Constructs a new item of the roster. * @param jid The JID of the contact. * @param name The displayed name of the contact. * @param groups A list of groups the contact belongs to. */ RosterItemData( const JID& jid, const std::string& name, const StringList& groups ) - : m_jid( jid.full() ), m_jidJID( jid ), m_name( name ), m_groups( groups ), - m_subscription( S10nNone ), m_changed( false ), m_remove( false ) + : RosterItemBase( jid, name, groups ), + m_subscription( S10nNone ), m_remove( false ) {} /** * Constructs a new item of the roster, scheduled for removal. * @param jid The JID of the contact to remove. */ RosterItemData( const JID& jid ) - : m_jid( jid.full() ), m_jidJID( jid ), m_subscription( S10nNone ), m_changed( false ), - m_remove( true ) + : RosterItemBase( jid, EmptyString, StringList() ), + m_subscription( S10nNone ), m_remove( true ) {} /** * Copy constructor. * @param right The RosterItemData to copy. */ RosterItemData( const RosterItemData& right ) - : m_jid( right.m_jid ), m_jidJID( right.m_jidJID ), m_name( right.m_name ), - m_groups( right.m_groups ), m_subscription( right.m_subscription ), - m_changed( right.m_changed ), m_remove( right.m_remove ) - {} - - /** - * Constructs a new item of the roster. - * @param jid The JID of the contact. - * @param name The displayed name of the contact. - * @param groups A list of groups the contact belongs to. - * @deprecated Will be removed for 1.1. - */ - GLOOX_DEPRECATED_CTOR RosterItemData( const std::string& jid, const std::string& name, - const StringList& groups ) - : m_jid( jid ), m_jidJID( jid), m_name( name ), m_groups( groups ), - m_subscription( S10nNone ), m_changed( false ), m_remove( false ) - {} - - /** - * Constructs a new item of the roster, scheduled for removal. - * @param jid The JID of the contact to remove. - * @deprecated Will be removed for 1.1. - */ - GLOOX_DEPRECATED_CTOR RosterItemData( const std::string& jid ) - : m_jid( jid ), m_jidJID( jid), m_subscription( S10nNone ), m_changed( false ), - m_remove( true ) + : RosterItemBase( right ), + m_subscription( right.m_subscription ), m_remove( right.m_remove ) {} /** * Virtual destructor. */ virtual ~RosterItemData() {} /** - * Returns the contact's bare JID. - * @return The contact's bare JID. - * @deprecated Will be removed for 1.1. - */ - GLOOX_DEPRECATED const std::string& jid() const { return m_jid; } - - /** - * Returns the contact's bare JID. - * @return The contact's bare JID. - * @todo Rename to jid() for 1.1. - */ - const JID& jidJID() const { return m_jidJID; } - - /** - * Sets the displayed name of a contact/roster item. - * @param name The contact's new name. - */ - void setName( const std::string& name ) - { - m_name = name; - m_changed = true; - } - - /** - * Retrieves the displayed name of a contact/roster item. - * @return The contact's name. - */ - const std::string& name() const { return m_name; } - - /** * Sets the current subscription status of the contact. * @param subscription The current subscription. * @param ask Whether a subscription request is pending. */ void setSubscription( const std::string& subscription, const std::string& ask ) { m_sub = subscription.empty() ? "none" : subscription; m_ask = ask; if( m_sub == "from" && ask.empty() ) m_subscription = S10nFrom; else if( m_sub == "from" && !ask.empty() ) m_subscription = S10nFromOut; else if( m_sub == "to" && ask.empty() ) m_subscription = S10nTo; else if( m_sub == "to" && !ask.empty() ) m_subscription = S10nToIn; else if( m_sub == "none" && ask.empty() ) m_subscription = S10nNone; else if( m_sub == "none" && !ask.empty() ) m_subscription = S10nNoneOut; else if( m_sub == "both" ) m_subscription = S10nBoth; } /** * Returns the current subscription type between the remote and the local entity. * @return The subscription type. */ SubscriptionType subscription() const { return m_subscription; } /** - * Sets the groups this RosterItem belongs to. - * @param groups The groups to set for this item. - */ - void setGroups( const StringList& groups ) - { - m_groups = groups; - m_changed = true; - } - - /** - * Returns the groups this RosterItem belongs to. - * @return The groups this item belongs to. - */ - const StringList& groups() const { return m_groups; } - - /** * Whether the item has unsynchronized changes. * @return @b True if the item has unsynchronized changes, @b false otherwise. */ bool changed() const { return m_changed; } /** * Whether the item is scheduled for removal. * @return @b True if the item is subject to a removal or scheduled for removal, @b false * otherwise. */ bool remove() const { return m_remove; } /** * Removes the 'changed' flag from the item. */ void setSynchronized() { m_changed = false; } /** * Retruns a Tag representation of the roster item data. * @return A Tag representation. */ - Tag* tag() const + virtual Tag* tag() const { - Tag* i = new Tag( "item" ); - i->addAttribute( "jid", m_jidJID.full() ); + Tag* i = RosterItemBase::tag(); if( m_remove ) i->addAttribute( "subscription", "remove" ); else { - i->addAttribute( "name", m_name ); - StringList::const_iterator it = m_groups.begin(); - for( ; it != m_groups.end(); ++it ) - new Tag( i, "group", (*it) ); i->addAttribute( "subscription", m_sub ); i->addAttribute( "ask", m_ask ); } return i; } protected: - GLOOX_DEPRECATED std::string m_jid; /**< @deprecated Will be removed for 1.1. */ - JID m_jidJID; /**< @todo Rename to m_jid for 1.1. */ - std::string m_name; - StringList m_groups; SubscriptionType m_subscription; std::string m_sub; std::string m_ask; - bool m_changed; bool m_remove; }; } -#endif // ROSTERITEMBASE_H__ +#endif // ROSTERITEMDATA_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/rosterxitemdata.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosterxitemdata.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosterxitemdata.h (revision 27490) @@ -0,0 +1,90 @@ +/* + Copyright (c) 2004-2019 by Jakob Schröter + 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. +*/ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + +#ifndef ROSTERXITEMDATA_H__ +#define ROSTERXITEMDATA_H__ + +#include "gloox.h" +#include "rosteritembase.h" + +#include + +namespace gloox +{ + + class JID; + class Tag; + class RosterItemBase; + + /** + * @brief An bastraction of a @xep{0144} (Roster Item Exchange) roster item. + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API RosterXItemData : public RosterItemBase + { + public: + /** + * A list of supported actions. + */ + enum XActions + { + XAdd, /**< Addition suggested. */ + XDelete, /**< Deletion suggested. */ + XModify, /**< Modification suggested. */ + XInvalid /**< Invalid action. */ + }; + + /** + * Creates a new item with the given data. + * @param action The suggested action. + * @param jid The contact's JID. + * @param name The contact's name. + * @param group A list of groups the contact belongs to. + */ + RosterXItemData( XActions action, const JID& jid, const std::string& name, + const StringList& groups ); + + /** + * Creates a new item from the given Tag. + * @param tag The Tag to parse. + */ + RosterXItemData( const Tag* tag ); + + /** + * Virtual destructor. + */ + virtual ~RosterXItemData() {} + + /** + * Returns the suggested action. + * @return The suggested action. + */ + XActions action() const { return m_action; } + + // reimplemented from RosterItemBase + virtual Tag* tag() const; + + private: + XActions m_action; + + }; + +} + +#endif // ROSTERXITEMDATA_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/rosterxitemdata.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/shim.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/shim.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/shim.h (revision 27490) @@ -1,91 +1,96 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SHIM ) + #ifndef SHIM_H__ #define SHIM_H__ #include "stanzaextension.h" #include "macros.h" #include #include namespace gloox { class Tag; /** * @brief An implementation/abstraction of Stanza Headers and Internet Metadata (SHIM, @xep{0131}). * * XEP Version: 1.2 * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API SHIM : public StanzaExtension { public: /** * A list of SHIM headers (name & value). */ typedef std::map HeaderList; /** * Creates a new SHIM object containing the given headers. * @param hl The list of headers. */ SHIM( const HeaderList& hl ); /** * Creates a new SHIM object from the given Tag. * @param tag The Tag to parse. */ SHIM( const Tag* tag = 0 ); /** * Returns the headers. * @return The headers. */ const HeaderList& headers() const { return m_headers; } /** * Virtual destructor. */ virtual ~SHIM(); // re-implemented from StanzaExtension virtual const std::string& filterString() const; // re-implemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new SHIM( tag ); } // re-implemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new SHIM( *this ); } private: HeaderList m_headers; }; } #endif // SHIM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/siprofilefthandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/siprofilefthandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/siprofilefthandler.h (revision 27490) @@ -1,104 +1,108 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SI ) + #ifndef SIPROFILEFTHANDLER_H__ #define SIPROFILEFTHANDLER_H__ #include "jid.h" #include namespace gloox { class JID; class IQ; class Bytestream; /** * @brief An abstract base class to handle file transfer (FT) requests. * * See SIProfileFT for more information regarding file transfer. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SIProfileFTHandler { public: /** * Virtual destructor. */ virtual ~SIProfileFTHandler() {} /** * This function is called to handle incoming file transfer requests, i.e. a remote entity requested * to send a file to you. You should use either SIProfileFT::acceptFT() or * SIProfileFT::declineFT() to accept or reject the request, respectively. * @param from The file transfer requestor. * @param to The file transfer recipient. Usuall oneself. Used in component scenario. * @param sid The requested stream's ID. This sid MUST be supplied to SIProfileFT::acceptFT() * and SIProfileFT::declineFT(), respectively. * @param name The file name. * @param size The file size. * @param hash The file content's MD5 sum. * @param date The file's last modification time. * @param mimetype The file's mime-type. * @param desc The file's description. * @param stypes An ORed list of @link gloox::SIProfileFT::StreamType SIProfileFT::StreamType @endlink * indicating the StreamTypes the initiator supports. */ 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; /** * This function is called to handle a request error or decline. * @param iq The complete error stanza. * @param sid The request's SID. */ virtual void handleFTRequestError( const IQ& iq, const std::string& sid ) = 0; /** * This function is called to pass a negotiated bytestream (SOCKS5 or IBB). * The bytestream is not yet open and not ready to send/receive data. * @note To initialize the bytestream and to prepare it for data transfer * do the following, preferable in that order: * @li register a BytestreamDataHandler with the Bytestream, * @li set up a separate thread for the bytestream or integrate it into * your main loop, * @li call its connect() method and check the return value. * To not block your application while the data transfer and/or the connection * attempts last, you most likely want to put the bytestream into its own * thread or process (before calling connect() on it). It is safe to do so * without additional synchronization. * @param bs The bytestream. */ virtual void handleFTBytestream( Bytestream* bs ) = 0; /** * This function is called if the contact chose OOB as the mechanism. * @param from The remote contact's JID. * @param to The local recipient's JID. Usually oneself. Used in component scenario. * @param sid The stream's ID. * @return The file's URL. */ virtual const std::string handleOOBRequestResult( const JID& from, const JID& to, const std::string& sid ) = 0; }; } #endif // SIPROFILEFTHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreamserver.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreamserver.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreamserver.h (revision 27490) @@ -1,149 +1,153 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef SOCKS5BYTESTREAMSERVER_H__ #define SOCKS5BYTESTREAMSERVER_H__ #include "macros.h" #include "connectionhandler.h" #include "connectiontcpserver.h" #include "logsink.h" #include "mutex.h" namespace gloox { /** * @brief A server listening for SOCKS5 bytestreams. * * @note You can use a single SOCKS5BytestreamServer instance with multiple Client objects. * * @note It is safe to put a SOCKS5BytestreamServer instance into a separate thread. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SOCKS5BytestreamServer : public ConnectionHandler, public ConnectionDataHandler { friend class SOCKS5BytestreamManager; public: /** * Constructs a new SOCKS5BytestreamServer. * @param logInstance A LogSink to use. * @param port The local port to listen on. * @param ip The local IP to bind to. If empty, the server will listen on all local interfaces. */ SOCKS5BytestreamServer( const LogSink& logInstance, int port, const std::string& ip = EmptyString ); /** * Destructor. */ ~SOCKS5BytestreamServer(); /** * Starts listening on the specified interface and port. * @return Returns @c ConnNoError on success, @c ConnIoError on failure (e.g. if the port * is already in use). */ ConnectionError listen(); /** * Call this function repeatedly to check for incoming connections and to negotiate * them. * @param timeout The timeout to use for select in microseconds. * @return The state of the listening socket. */ ConnectionError recv( int timeout ); /** * Stops listening and unbinds from the interface and port. */ void stop(); /** * Expose our TCP Connection localPort * Returns the local port. * @return The local port. */ int localPort() const; /** * Expose our TCP Connection localInterface * Returns the locally bound IP address. * @return The locally bound IP address. */ const std::string localInterface() const; /** * Exposes the local socket. * @return The local socket. */ int serverSocket() const { return m_tcpServer->socket(); } // reimplemented from ConnectionHandler virtual void handleIncomingConnection( ConnectionBase* server, ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); private: SOCKS5BytestreamServer& operator=( const SOCKS5BytestreamServer& ); void registerHash( const std::string& hash ); void removeHash( const std::string& hash ); ConnectionBase* getConnection( const std::string& hash ); enum NegotiationState { StateDisconnected, StateUnnegotiated, StateAuthmethodAccepted, StateAuthAccepted, StateDestinationAccepted, StateActive }; struct ConnectionInfo { NegotiationState state; std::string hash; }; typedef std::map ConnectionMap; ConnectionMap m_connections; typedef std::list ConnectionList; ConnectionList m_oldConnections; typedef std::list HashMap; HashMap m_hashes; ConnectionTCPServer* m_tcpServer; util::Mutex m_mutex; const LogSink& m_logInstance; std::string m_ip; int m_port; }; } #endif // SOCKS5BYTESTREAMSERVER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsbase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsbase.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsbase.h (revision 27490) @@ -1,161 +1,172 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 TLSBASE_H__ #define TLSBASE_H__ #include "gloox.h" #include "mutex.h" #include "tlshandler.h" namespace gloox { /** * @brief An abstract base class for TLS implementations. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API TLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. * @param server The server to use in certificate verification. */ TLSBase( TLSHandler* th, const std::string server ) - : m_handler( th ), m_server( server ), m_secure( false ), m_valid( false ), m_initLib( true ) + : m_handler( th ), m_server( server ), m_tlsVersion( TLSv1 ), m_secure( false ), m_valid( false ), m_initLib( true ) {} /** * Virtual destructor. */ virtual ~TLSBase() {} /** * Initializes the TLS module. This function must be called (and execute successfully) * before the module can be used. * @param clientKey The absolute path to the user's private key in PEM format. * @param clientCerts A path to a certificate bundle in PEM format. * @param cacerts A list of absolute paths to CA root certificate files in PEM format. * @return @b False if initialization failed, @b true otherwise. * @since 1.0 */ virtual bool init( const std::string& clientKey = EmptyString, const std::string& clientCerts = EmptyString, const StringList& cacerts = StringList() ) = 0; /** * Enables/disables initialization of the underlying TLS library. By default, * initialization is performed. You may want to switch it off if the TLS library * is used elsewhere in your application as well and you have no control over the * initialization. * @param init Whether or not to intialize the underlying TLS library. */ void setInitLib( bool init ) { m_initLib = init; } /** + * This function is used to set the minimum required/requested TLS version. Default is to use + * at least TLS v1. This should be called before init() is called. + * @param tlsVersion The TLS version. + */ + void setTLSVersion( TLSVersion tlsVersion ) { m_tlsVersion = tlsVersion; } + + /** * Use this function to feed unencrypted data to the encryption implementation. * The encrypted result will be pushed to the TLSHandler's handleEncryptedData() function. * @param data The data to encrypt. * @return Whether or not the data was used successfully. */ virtual bool encrypt( const std::string& data ) = 0; /** * Use this function to feed encrypted data or received handshake data to the * encryption implementation. Handshake data will be eaten, unencrypted data * will be pushed to the TLSHandler's handleDecryptedData() function. * @param data The data to decrypt. * @return The number of bytes used from the input. */ virtual int decrypt( const std::string& data ) = 0; /** * This function performs internal cleanup and will be called after a failed handshake attempt. */ virtual void cleanup() = 0; /** * This functiopn performs the TLS handshake. Handshake data from the server side should be * fed in using decrypt(). Handshake data that is to be sent to the other side is pushed through * TLSBase's handleEncryptedData(). * @return @b True if the handshake was successful or if more input is needed, @b false if the * handshake failed. */ virtual bool handshake() = 0; /** * Returns the state of the encryption. * @return The state of the encryption. */ virtual bool isSecure() const { return m_secure; } /** - * This function indicates whether the underlying TLS implementation supports channel binding (used in e.g. SASL SCRAM-SHA-1-PLUS). + * This function indicates whether the underlying TLS implementation supports channel binding + * (used in e.g. SASL SCRAM-SHA-1-PLUS). * @return @b True if channel binding is supported, @b false otherwise. */ virtual bool hasChannelBinding() const { return false; } /** * Returns the channel binding data for the established connection. * @return The channel binding data, if any, or the empty string. */ virtual const std::string channelBinding() const { return EmptyString; } /** * Use this function to set a number of trusted root CA certificates which shall be * used to verify a servers certificate. * @param cacerts A list of absolute paths to CA root certificate files in PEM format. */ virtual void setCACerts( const StringList& cacerts ) = 0; /** * This function is used to retrieve certificate and connection info of a encrypted connection. * @return Certificate information. */ virtual const CertInfo& fetchTLSInfo() const { return m_certInfo; } /** * Use this function to set the user's certificate and private key. The certificate will * be presented to the server upon request and can be used for SASL EXTERNAL authentication. * The user's certificate file should be a bundle of more than one certificate in PEM format. * The first one in the file should be the user's certificate, each cert following that one * should have signed the previous one. * @note These certificates are not necessarily the same as those used to verify the server's * certificate. * @param clientKey The absolute path to the user's private key in PEM format. * @param clientCerts A path to a certificate bundle in PEM format. */ virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ) = 0; protected: TLSHandler* m_handler; StringList m_cacerts; std::string m_clientKey; std::string m_clientCerts; std::string m_server; CertInfo m_certInfo; util::Mutex m_mutex; + util::Mutex m_mutexCryptOp; + util::Mutex m_mutexDeCryptOp; + TLSVersion m_tlsVersion; bool m_secure; bool m_valid; bool m_initLib; }; } #endif // TLSBASE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/nickname.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/nickname.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/nickname.h (revision 27490) @@ -1,87 +1,92 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_NICKNAME ) + #ifndef NICKNAME_H__ #define NICKNAME_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief An implementation of User Nickname (@xep{0172}) as a StanzaExtension. * * XEP version: 1.0 * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Nickname : public StanzaExtension { public: /** * Constructs a new object from the given Tag. * @param tag A Tag to parse. */ Nickname( const Tag* tag ); /** * Constructs a new Nickname object. * @param nick The nickname to include. */ Nickname( const std::string& nick ) : StanzaExtension( ExtNickname ), m_nick( nick ) {} /** * Virtual destructor. */ virtual ~Nickname() {} /** * Returns the extension's saved nickname. * @return The nickname. */ const std::string nick() const { return m_nick; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Nickname( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Nickname( *this ); } private: std::string m_nick; }; } #endif // NICKNAME_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/presence.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/presence.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/presence.h (revision 27490) @@ -1,161 +1,165 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 PRESENCE_H__ #define PRESENCE_H__ #include "stanza.h" #include namespace gloox { +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CAPABILITIES ) class Capabilities; +#endif // GLOOX_MINIMAL class JID; /** * @brief An abstraction of a presence stanza. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Presence : public Stanza { friend class ClientBase; public: /** * Describes the different valid presence types. */ enum PresenceType { Available, /**< The entity is online. */ Chat, /**< The entity is 'available for chat'. */ Away, /**< The entity is away. */ DND, /**< The entity is DND (Do Not Disturb). */ XA, /**< The entity is XA (eXtended Away). */ Unavailable, /**< The entity is offline. */ Probe, /**< This is a presence probe. */ Error, /**< This is a presence error. */ Invalid /**< The stanza is invalid. */ }; /** * Creates a Presence request. * @param type The presence type. * @param to The intended receiver. Use an empty JID to create a broadcast packet. * @param status An optional status message (e.g. "gone fishing"). * @param priority An optional presence priority. Legal range is between -128 and +127. * Defaults to 0. * @param xmllang An optional xml:lang for the status message. */ Presence( PresenceType type, const JID& to, const std::string& status = EmptyString, int priority = 0, const std::string& xmllang = EmptyString ); /** * Destructor. */ virtual ~Presence(); /** * Returns the presence's type. * @return The presence's type. */ PresenceType subtype() const { return m_subtype; } +#if !defined( GLOOX_MINIMAL ) || defined( WANT_CAPABILITIES ) /** * A convenience function returning the stanza's Capabilities, if any. May be 0. * @return A pointer to a Capabilities object, or 0. */ const Capabilities* capabilities() const; +#endif // GLOOX_MINIMAL /** * Returns the presence's type. * @return The presence's type. */ //#warning FIXME return something useful (only 'show' values?) or kill this func PresenceType presence() const { return m_subtype; } /** * Sets the presence type. * @param type The presence type. */ void setPresence( PresenceType type ) { m_subtype = type; } /** * Returns the status text of a presence stanza for the given language if available. * If the requested language is not available, the default status text (without a xml:lang * attribute) will be returned. * @param lang The language identifier for the desired language. It must conform to * section 2.12 of the XML specification and RFC 3066. If empty, the default body * will be returned, if any. * @return The status text set by the sender. */ const std::string status( const std::string& lang = "default" ) const { return findLang( m_stati, m_status, lang ); } /** * Adds a (possibly translated) status message. * @param status The status message. * @param lang The language identifier for the desired language. It must conform to * section 2.12 of the XML specification and RFC 3066. */ void addStatus( const std::string& status, const std::string& lang = EmptyString ) { setLang( &m_stati, m_status, status, lang ); } /** * Resets the default status message as well as all language-specific ones. */ void resetStatus(); /** * Returns the presence priority in the legal range: -128 to +127. * @return The priority information contained in the stanza, defaults to 0. */ int priority() const { return m_priority; } /** * Sets the priority. Legal range: -128 to +127. * @param priority The priority to set. */ void setPriority( int priority ); // reimplemented from Stanza virtual Tag* tag() const; private: #ifdef PRESENCE_TEST public: #endif /** * Creates a Presence request from the given Tag. The original Tag will be ripped off. * @param tag The Tag to parse. */ Presence( Tag* tag ); PresenceType m_subtype; StringMap* m_stati; std::string m_status; int m_priority; }; } #endif // PRESENCE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/privatexml.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/privatexml.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/privatexml.h (revision 27490) @@ -1,160 +1,163 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) #ifndef PRIVATEXML_H__ #define PRIVATEXML_H__ #include "iqhandler.h" #include "privatexmlhandler.h" #include #include #include namespace gloox { class ClientBase; class Tag; class Stanza; /** * @brief This class implements @xep{0049} (Private XML Storage). * * @author Jakob Schröter */ class GLOOX_API PrivateXML : public IqHandler { public: /** * Constructor. * Creates a new PrivateXML client that registers as IqHandler * with @c ClientBase. * @param parent The ClientBase used for XMPP communication */ PrivateXML( ClientBase* parent ); /** * Virtual destructor. */ virtual ~PrivateXML(); /** * Use this function to request the private XML stored in the given namespace. * @param tag Child element of the query element used to identify the requested XML fragment. * @param xmlns The namespace which qualifies the tag. * @param pxh The handler to receive the result. * @return The ID of the sent query. */ std::string requestXML( const std::string& tag, const std::string& xmlns, PrivateXMLHandler* pxh ); /** * Use this function to store private XML stored in the given namespace. * @param tag The XML to store. This is the complete tag including the unique namespace. * It is deleted automatically after sending it. * @param pxh The handler to receive the result. * @return The ID of the sent query. */ std::string storeXML( const Tag* tag, PrivateXMLHandler* pxh ); // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ) { (void)iq; return false; } // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); protected: ClientBase* m_parent; private: #ifdef PRIVATEXML_TEST public: #endif /** * @brief An implementation of the Private XML Storage protocol as StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class Query : public StanzaExtension { public: /** * Constructs a new Query object suitable for use with Private XML Storage. * @param tag The private XML's element name. * @param xmlns The private XML's namespace. */ Query( const std::string& tag, const std::string& xmlns ) : StanzaExtension( ExtPrivateXML ) { m_privateXML = new Tag( tag, XMLNS, xmlns ); } /** * Constructs a new Query object suitable for storing an XML fragment in * Private XML Storage. * @param tag The private XML element to store. The Query object will own the Tag. */ Query( const Tag* tag = 0 ); /** * Destructor. */ ~Query() { delete m_privateXML; } /** * Returns the private XML fragment. The Tag is owned by the Query object. * @return The stored private XML fragment. */ const Tag* privateXML() const { return m_privateXML; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { Query* q = new Query(); q->m_privateXML = m_privateXML ? m_privateXML->clone() : 0; return q; } private: const Tag* m_privateXML; }; enum IdType { RequestXml, StoreXml }; typedef std::map TrackMap; TrackMap m_track; }; } #endif // PRIVATEXML_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pubsubitem.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pubsubitem.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/pubsubitem.h (revision 27490) @@ -1,102 +1,106 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PUBSUB ) + #ifndef PUBSUBITEM_H__ #define PUBSUBITEM_H__ #include "gloox.h" #include namespace gloox { class Tag; namespace PubSub { /** * @brief Abstracts a PubSub Item (@xep{0060}). * * XEP Version: 1.12 * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Item { public: /** * Constructs a new empty Item. */ Item(); /** * Constructs a new Item from the given Tag. * @param tag The Tag to parse. */ Item( const Tag* tag ); /** * Copy constructor. * @param item The Item to be copied. */ Item( const Item& item ); /** * Destructor. */ ~Item(); /** * Returns the Item's payload. * @return The layload. */ const Tag* payload() const { return m_payload; } /** * Sets the item's payload. * @param tag A payload tag. */ void setPayload( Tag* tag ); /** * Returns the item ID. * @return The item ID. */ const std::string& id() const { return m_id; } /** * Sets the item's ID. * @param id The item's ID. */ void setID( const std::string& id ) { m_id = id; } /** * Creates and returns a Tag representation of the Item. * @return An XML representation of the Item. */ Tag* tag() const; private: Tag* m_payload; std::string m_id; }; } } #endif // PUBSUBITEM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/reference.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/reference.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/reference.h (revision 27490) @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2018-2019 by Jakob Schröter + * 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. + */ + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_REFERENCES ) + +#ifndef REFERENCE_H__ +#define REFERENCE_H__ + +#include "gloox.h" +#include "stanzaextension.h" + +#include +#include + +namespace gloox +{ + /** + * This is an abstraction of References (@xep{0372}). + * + * XEP Version: 0.2 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API Reference : public StanzaExtension + { + public: + + /** + * The supported Message Markup types according to @xep{0394}. + */ + enum ReferenceType + { + Mention, /**< Mentions are a reference to a user's bare JID. */ + Data, /**< Data references are a generic reference without additional information. */ + InvalidType /**< Invalid/unknown type. Ignored. */ + }; + + /** + * Constructs a new object from the given Tag. + * @param tag A Tag to parse. + */ + Reference( const Tag* tag ); + + /** + * Constructs a new Reference object with the given markups. + * @param type The reference type. + * @param uri The referencing URI. + */ + Reference( ReferenceType type, const std::string& uri ) + : StanzaExtension( ExtReference ), m_type( type ), m_uri( uri ) + {} + + /** + * Virtual destructor. + */ + virtual ~Reference() {} + + /** + * Sets the start position of the @c mention. See @xep{0372}. + * @param begin The start position of the @c mention. + */ + void setBegin( const int begin ) { m_begin = begin; } + + /** + * Returns the start position of the mention. + * @return The start position of the mention. + */ + int begin() const { return m_begin; } + + /** + * Sets the end position of the @c mention. See @xep{0372}. + * @param end The end position of the @c mention. + */ + void setEnd( const int end ) { m_end = end; } + + /** + * Returns the end position of the mention. See @xep{0372}. + * @return The end position of the mention. + */ + int end() const { return m_end; } + + /** + * An anchor, i.e. an uri to a previous message. See @xep{0372}. + * @param anchor The anchor. + */ + void setAnchor( const std::string& anchor ) { m_anchor = anchor; } + + /** + * Returns the anchor. See @xep{0372}. + * @return The anchor. + */ + const std::string& anchor() const { return m_anchor; } + + /** + * Returns the URI. See @xep{0372}. + * @return The URI. + */ + const std::string& uri() const { return m_uri; } + + /** + * Returns the reference type. See @xep{0372}. + * @return The reference type. + */ + ReferenceType type() const { return m_type; } + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new Reference( tag ); + } + + // reimplemented from StanzaExtension + Tag* tag() const; + + // reimplemented from StanzaExtension + virtual Reference* clone() const + { + return new Reference( *this ); + } + + private: + ReferenceType m_type; + std::string m_uri; + std::string m_anchor; + int m_begin; + int m_end; + + }; + +} + +#endif // REFERENCE_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/reference.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/rosteritembase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosteritembase.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosteritembase.h (revision 27490) @@ -0,0 +1,146 @@ +/* + Copyright (c) 2015-2019 by Jakob Schröter + 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 ROSTERITEMBASE_H__ +#define ROSTERITEMBASE_H__ + +#include "gloox.h" +#include "jid.h" +#include "tag.h" + +#include +#include + + +namespace gloox +{ + + /** + * @brief A base class holding some roster item data. + * + * You should not need to use this class directly. + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API RosterItemBase + { + + public: + /** + * Constructs a new item of the roster. + * @param jid The JID of the contact. + * @param name The displayed name of the contact. + * @param groups A list of groups the contact belongs to. + */ + RosterItemBase( const JID& jid, const std::string& name, + const StringList& groups ) + : m_jid( jid ), m_name( name ), m_groups( groups ), m_changed( false ) + {} + + /** + * Constructs a new item from the given Tag. + * @param tag The Tag to parse. + */ + RosterItemBase( const Tag* tag ) + { + if( !tag || tag->name() != "item" ) + return; + + m_jid.setJID( tag->findAttribute( "jid" ) ); + m_name = tag->findAttribute( "name" ); + const ConstTagList& g = tag->findTagList( "item/group" ); + ConstTagList::const_iterator it = g.begin(); + for( ; it != g.end(); ++it ) + m_groups.push_back( (*it)->cdata() ); + } + + /** + * Copy constructor. + * @param right The RosterItemBase to copy. + */ + RosterItemBase( const RosterItemBase& right ) + : m_jid( right.m_jid ), m_name( right.m_name ), + m_groups( right.m_groups ), m_changed( right.m_changed ) + {} + + /** + * Virtual destructor. + */ + virtual ~RosterItemBase() {} + + /** + * Returns the contact's bare JID. + * @return The contact's bare JID. + */ + const JID& jid() const { return m_jid; } + + /** + * Sets the displayed name of a contact/roster item. + * @param name The contact's new name. + */ + void setName( const std::string& name ) + { + m_name = name; + m_changed = true; + } + + /** + * Retrieves the displayed name of a contact/roster item. + * @return The contact's name. + */ + const std::string& name() const { return m_name; } + + /** + * Sets the groups this RosterItem belongs to. + * @param groups The groups to set for this item. + */ + void setGroups( const StringList& groups ) + { + m_groups = groups; + m_changed = true; + } + + /** + * Returns the groups this RosterItem belongs to. + * @return The groups this item belongs to. + */ + const StringList& groups() const { return m_groups; } + + /** + * Retruns a Tag representation of the roster item data. + * @return A Tag representation. + */ + virtual Tag* tag() const + { + Tag* i = new Tag( "item" ); + i->addAttribute( "jid", m_jid.full() ); + i->addAttribute( "name", m_name ); + StringList::const_iterator it = m_groups.begin(); + for( ; it != m_groups.end(); ++it ) + new Tag( i, "group", (*it) ); + + return i; + } + + protected: + JID m_jid; + std::string m_name; + StringList m_groups; + bool m_changed; + + }; + +} + +#endif // ROSTERITEMBASE_H__ Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/rosteritembase.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/rosterx.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosterx.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosterx.h (revision 27490) @@ -0,0 +1,104 @@ +/* + Copyright (c) 2015-2019 by Jakob Schröter + 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. +*/ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + +#ifndef ROSTERX_H__ +#define ROSTERX_H__ + +#include "gloox.h" +#include "stanzaextension.h" +#include "rosterxitemdata.h" + +#include +#include + +namespace gloox +{ + + class Tag; + + /** + * A list of Roster Item Exchange items. + */ + typedef std::list RosterXItemList; + + /** + * @brief A Roster Item Exchange (@xep{0144}) abstraction implemented as a StanzaExtension. + * + * @xep{0144} defines a protocol for exchanging roster items between entities. To receive + * items proposed for addition, deletion, or modification by another entity, @link + * RosterListener::handleRosterItemExchange() RosterListener's handleRosterItemExchange() @endlink + * has to be implemented. Incoming items should then be treated according to the rules established + * in @xep{0144}. + * + * To send roster items to another entity, an instance of this RosterX class should be created and + * items added using setItems(), again following the rules established in @xep{0144}. + * This RosterX should then be added to an IQ or Message stanza (see @xep{0144}) and sent off. + * + * XEP Version: 1.1.1 + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API RosterX : public StanzaExtension + { + public: + /** + * Constructs a new object from the given Tag. + * @param tag The Tag to parse. + */ + RosterX( const Tag* tag = 0 ); + + /** + * Virtual destructor. + */ + virtual ~RosterX(); + + /** + * Returns the list of exchanged items. + * @return The list of exchanged items. + */ + const RosterXItemList& items() const { return m_list; } + + /** + * Sets a list of roster items. The objects pointed to by the list are owned by RosterX + * and will be deleted upon destruction or on any future call of setItems(). + * @param items The list of roster items to set. + */ + void setItems( const RosterXItemList& items ); + + // reimplemented from StanzaExtension + virtual const std::string& filterString() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new RosterX( tag ); + } + + // reimplemented from StanzaExtension + virtual Tag* tag() const; + + // reimplemented from StanzaExtension + virtual StanzaExtension* clone() const; + + private: + RosterXItemList m_list; + + }; + +} + +#endif // ROSTERX_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/rosterx.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/sha.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/sha.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/sha.h (revision 27490) @@ -1,98 +1,106 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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 SHA_H__ #define SHA_H__ #include "macros.h" #include namespace gloox { /** * @brief An implementation of SHA1. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SHA { public: /** * Constructs a new SHA object. */ SHA(); /** * Virtual Destructor. */ virtual ~SHA(); /** * Resets the internal state. */ void reset(); /** * Finalizes the hash computation. */ void finalize(); /** * Returns the message digest in hex notation. Finalizes the hash if finalize() * has not been called before. * @return The message digest. */ const std::string hex(); /** * Returns the raw binary message digest. Finalizes the hash if finalize() * has not been called before. * @return The message raw binary digest. */ const std::string binary(); /** * Provide input to SHA1. * @param data The data to compute the digest of. * @param length The size of the data in bytes. */ void feed( const unsigned char* data, unsigned length ); /** * Provide input to SHA1. * @param data The data to compute the digest of. */ void feed( const std::string& data ); + /** + * Static function to quickly get an SHA1 hash in hex. + * @param data The data to hash. + * @return The hash in hex. + * @since 1.1 + */ + static const std::string hex( const std::string& data ); + private: void process(); void pad(); inline unsigned shift( int bits, unsigned word ); void init(); unsigned H[5]; unsigned Length_Low; unsigned Length_High; unsigned char Message_Block[64]; int Message_Block_Index; bool m_finished; bool m_corrupted; }; } #endif // SHA_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/siprofileft.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/siprofileft.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/siprofileft.h (revision 27490) @@ -1,341 +1,346 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SI ) + #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 #include namespace gloox { class ClientBase; class InBandBytestream; class IQ; class JID; class SIProfileFTHandler; class SOCKS5Bytestream; /** * @brief An implementation of the file transfer SI profile (@xep{0096}). * * An SIProfileFT object acts as a 'plugin' to the SIManager. SIProfileFT * manages most of the file transfer functionality. The naming comes from the fact that * File Transfer (FT) is a profile of Stream Initiation (SI). * * Usage: * * Create a new SIProfileFT object. It needs a ClientBase -derived object (e.g. Client) * as well as a SIProfileFTHandler -derived object that will receive file transfer-related events. * If you already use SI and the SIManager somewhere else, you should pass a pointer to that * SIManager object as third parameter to SIProfileFT's constructor. * @code * class MyFileTransferHandler : public SIProfileFTHandler * { * // ... * }; * * Client* client = new Client( ... ); * // ... * MyFileTransferHandler* mh = new MyFileTransferHandler( ... ); * * SIProfileFT* ft = new SIProfileFT( client, mh ); * @endcode * * You are now, basically, ready to send and receive files. * * A couple of notes: * @li There are two (actually two and a half) possible "techniques" to transfer files * using SI. The first is using a peer-to-peer SOCKS5 bytestream, optionally via a * (special) SOCKS5 proxy. * The second techniques is using an in-band bytestream, i.e. the data is encapsulated in XMPP stanzas * and sent through the server. * * @li To be able to send files using the former method (SOCKS5 bytestreams), you may need * access to a SOCKS5 bytestream proxy (called StreamHost). This is especially true if either * or both of sender and receiver are behind NATs or are otherwise blocked from establishing * direct TCP connections. You should use Disco to query a potential SOCKS5 proxy * for its host and port parameters and feed that information into SIProfileFT: * @code * ft->addStreamHost( JID( "proxy.server.dom" ), "101.102.103.104", 6677 ); * @endcode * You should @b not hard-code this information (esp. host/IP and port) into your app since * the proxy may go down occasionally or vanish completely. * * @li In addition to (or even instead of) using external SOCKS5 proxies, you can use a * SOCKS5BytestreamServer object that gloox provides: * @code * SOCKS5BytestreamServer* server = new SOCKS5BytestreamServer( client->logInstance(), 1234 ); * if( server->listen() != ConnNoError ) * printf( "port in use\n" ); * * ft->addStreamHost( client->jid(), my_ip, 1234 ); * ft->registerSOCKS5BytestreamServer( server ); * @endcode * This listening server should then be integrated into your mainloop to have its * @link gloox::SOCKS5BytestreamServer::recv() recv() @endlink method called from time to time. * It is safe to put the server into its own thread. * * @li When you finally receive a Bytestream via the SIProfileFTHandler, you will need * to integrate this bytestream with your mainloop, or put it into a separate thread (if * occasional blocking is not acceptable). You will need to call * @link gloox::Bytestream::connect() connect() @endlink on that Bytestream. For SOCKS5 bytestreams, * this function will try to connect to each of the given StreamHosts and block until it has established * a connection with one of them (or until all attempts failed). Further, if you want to receive * a file via the bytestream, you will have to call recv() on the object from time to time. * For in-band bytestreams, @link gloox::Bytestream::connect() connect() @endlink will send an "open the * bytestream" request to the contact. * * @li For both stream types, * @link gloox::BytestreamDataHandler::handleBytestreamOpen() BytestreamDataHandler::handleBytestreamOpen() @endlink * will announce the established bytestream. The stream then is ready to send and receive data. * * @li In general, both types of streams can be handled equally, i.e. there's no need to know whether * the underlying stream really is a SOCKS5Bytestream or an InBandBytestream. * @link gloox::Bytestream::type() Bytestream::type() @endlink tells anyway. Note, however, that * sending large amounts of data using in-band bytestreams may trigger rate limiting in some servers. * * @li If you e.g. told Client to connect through a @link gloox::ConnectionHTTPProxy HTTP proxy @endlink * or a @link gloox::ConnectionSOCKS5Proxy SOCKS5 proxy @endlink, or any other ConnectionBase -derived * method, or even chains thereof, SIProfileFT will use the same connection types with the same * configuration to connect to the Stream Host/SOCKS5 proxy. If this is inappropriate because you have * e.g. a local SOCKS5 proxy inside your local network, use SOCKS5Bytestream::setConnectionImpl() to * override the above default connection(s). * * @li Do @b not delete Bytestream objects manually. Use dispose() instead. * * @li When using the Client's JID as the first argument to addStreamHost() as in the code snippet * above, make sure the JID is actually a full JID. If you let the server pick a resource, the call * to Client::jid() needs to be made @b after the connection has been established and authenticated, * because only then Client knows its full JID. This is generally a good idea, since the server * may choose to change the resource, even if you provided one at login. * * @li The interal SOCKS5BytestreamServer will obviously not work across NATs. * * @li Using addStreamHost(), you can add as many potential StreamHosts as you like. However, you * should add the best options (e.g. the local SOCKS5BytestreamServer) first. * * When cleaning up, delete the objectes you created above in the opposite order of * creation: * * @code * delete server * delete ft; * delete client; * @endcode * * For usage examples see src/examples/ft_send.cpp and src/examples/ft_recv.cpp. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SIProfileFT : public SIProfileHandler, public SIHandler, public BytestreamHandler, public IqHandler { public: /** * Supported stream types. */ enum StreamType { FTTypeS5B = 1, /**< SOCKS5 Bytestreams. */ FTTypeIBB = 2, /**< In-Band Bytestreams. */ FTTypeOOB = 4, /**< Out-of-Band Data. */ FTTypeAll = 0xFF /**< All types. */ }; /** * Constructor. * @param parent The ClientBase to use for signaling. * @param sipfth The SIProfileFTHandler to receive events. * @param manager An optional SIManager to register with. If this is zero, SIProfileFT * will create its own SIManager. You should pass a valid SIManager here if you are * already using one with the @c parent ClientBase above. * @param s5Manager An optional SOCKS5BytestreamManager to use. If this is zero, SIProfileFT * will create its own SOCKS5BytestreamManager. You should pass a valid SOCKS5BytestreamManager * here if you are already using one with the @c parent ClientBase above. * @note If you passed a SIManager and/or SOCKS5BytestreamManager and/or InBandBytestreamManager * to SIProfileFT's constructor, these objects will @b not be deleted on desctruction of SIProfileFT. */ SIProfileFT( ClientBase* parent, SIProfileFTHandler* sipfth, SIManager* manager = 0, SOCKS5BytestreamManager* s5Manager = 0 ); /** * Virtual destructor. */ virtual ~SIProfileFT(); /** * Starts negotiating a file transfer with a remote entity. * @param to The entity to send the file to. Must be a full JID. * @param name The file's name. Mandatory and must not be empty. * @param size The file's size. Mandatory and must be > 0. * @param hash The file content's MD5 hash. * @param desc A description. * @param date The file's last modification date/time. See @xep{0082} for details. * @param mimetype The file's mime-type. Defaults to 'binary/octet-stream' if empty. * @param streamTypes ORed StreamType that can be used for this transfer. * @param from An optional 'from' address to stamp outgoing requests with. * Used in component scenario only. Defaults to empty JID. * @param sid Optionally specify a stream ID (SID). If empty, one will be generated. * @return The requested stream's ID (SID). Empty if conditions above (file name, size) * are not met. */ 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 ); /** * Call this function to accept a file transfer request previously announced by means of * @link gloox::SIProfileFTHandler::handleFTRequest() SIProfileFTHandler::handleFTRequest() @endlink. * @param to The requestor. * @param sid The request's sid, as passed to SIProfileHandler::handleFTRequest(). * @param type The desired stream type to use for this file transfer. Defaults to * SOCKS5 Bytestream. You should not use @c FTTypeAll here. * @param from An optional 'from' address to stamp outgoing stanzas with. * Used in component scenario only. Defaults to empty JID. */ void acceptFT( const JID& to, const std::string& sid, StreamType type = FTTypeS5B, const JID& from = JID() ); /** * Call this function to decline a FT request previously announced by means of * @link gloox::SIProfileFTHandler::handleFTRequest() SIProfileFTHandler::handleFTRequest() @endlink. * @param to The requestor. * @param sid The request's sid, as passed to SIProfileFTHandler::handleFTRequest(). * @param reason The reason for the reject. * @param text An optional human-readable text explaining the decline. */ void declineFT( const JID& to, const std::string& sid, SIManager::SIError reason, const std::string& text = EmptyString ); /** * Cancels the given bytestream. Most useful for SOCKS5 bytestreams where no proxies could be found. * The given Bytestream will be deleted. * @param bs The Bytestream to cancel. * @note Can also be used with IBB. */ void cancel( Bytestream* bs ); /** * To get rid of a bytestream (i.e., close and delete it), call this function. * The remote entity will be notified about the closing of the stream. * @param bs The bytestream to dispose. It will be deleted here. */ void dispose( Bytestream* bs ); /** * Registers a handler that will be informed about incoming file transfer * requests, i.e. when a remote entity wishes to send a file. * @param sipfth A SIProfileFTHandler to register. Only one handler can be registered * at any one time. */ void registerSIProfileFTHandler( SIProfileFTHandler* sipfth ) { m_handler = sipfth; } /** * Removes the previously registered file transfer request handler. */ void removeSIProfileFTHandler() { m_handler = 0; } /** * Sets a list of StreamHosts that will be used for subsequent SOCKS5 bytestream requests. * @note At least one StreamHost is required. * @param hosts A list of StreamHosts. */ void setStreamHosts( StreamHostList hosts ); /** * Adds one StreamHost to the list of SOCKS5 StreamHosts. * @param jid The StreamHost's JID. * @param host The StreamHost's hostname. * @param port The StreamHost's port. */ void addStreamHost( const JID& jid, const std::string& host, int port ); /** * Tells the interal SOCKS5BytestreamManager which SOCKS5BytestreamServer handles * peer-2-peer SOCKS5 bytestreams. * @param server The SOCKS5BytestreamServer to use. */ void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server ) { if( m_socks5Manager ) m_socks5Manager->registerSOCKS5BytestreamServer( server ); } /** * Un-registers any local SOCKS5BytestreamServer. */ 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; + util::Mutex m_id2sidMutex; bool m_delManager; bool m_delS5Manager; }; } #endif // SIPROFILEFT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreammanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreammanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestreammanager.h (revision 27490) @@ -1,307 +1,311 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef SOCKS5BYTESTREAMMANAGER_H__ #define SOCKS5BYTESTREAMMANAGER_H__ #include "iqhandler.h" #include "jid.h" #include "stanzaextension.h" namespace gloox { class BytestreamHandler; class SOCKS5BytestreamServer; class SOCKS5Bytestream; class ClientBase; /** * Describes a single StreamHost. */ struct StreamHost { JID jid; /**< The StreamHost's JID. */ std::string host; /**< The StreamHost's IP or host name. */ int port; /**< The StreamHost's port. */ // std::string zeroconf; /**< A zeroconf identifier. */ }; /** * A list of StreamHosts. */ typedef std::list StreamHostList; /** * @brief An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SOCKS5BytestreamManager : public IqHandler { friend class SOCKS5Bytestream; public: /** * Supported transport layer protocols. */ enum S5BMode { S5BTCP, /**< Use TCP on the transport layer. */ S5BUDP, /**< Use UDP on the transport layer. Not currently supported. */ S5BInvalid /**< Invalid mode. */ }; /** * Constructs a new SOCKS5BytestreamManager. * @param parent The ClientBase to use for sending data. * @param s5bh A SOCKS5BytestreamManager -derived object that will receive * incoming and outgoing SOCKS5Bytestreams. */ SOCKS5BytestreamManager( ClientBase* parent, BytestreamHandler* s5bh ); /** * Virtual destructor. */ virtual ~SOCKS5BytestreamManager(); /** * Sets a list of StreamHosts that will be used for subsequent bytestream requests. * @note At least one StreamHost is required. * @param hosts A list of StreamHosts. */ void setStreamHosts( StreamHostList hosts ) { m_hosts = hosts; } /** * Adds one StreamHost to the list of StreamHosts. * @param jid The StreamHost's JID. * @param host The StreamHost's hostname. * @param port The StreamHost's port. */ void addStreamHost( const JID& jid, const std::string& host, int port ); /** * This function requests a bytestream with the remote entity. * Data can only be sent over an open stream. Use isOpen() to find out what the stream's * current state is. However, successful opening/initiation will be announced by means of the * BytestreamHandler interface. Multiple bytestreams (even per JID) can be initiated * without waiting for success. * @param to The recipient of the requested bytestream. * @param mode The desired transport layer protocol. * @param sid The bytestream's stream ID, if previously negotiated e.g. using SI (@xep{0095}). * @param from An optional 'from' address to stamp outgoing * requests with. Only useful in component scenarios. Defaults to empty JID. * @return @b False in case of an error, @b true otherwise. A return value of @b true does * @b not indicate that the bytestream has been opened. This is announced by means of the * BytestreamHandler. */ bool requestSOCKS5Bytestream( const JID& to, S5BMode mode, const std::string& sid = EmptyString, const JID& from = JID() ); /** * To get rid of a bytestream (i.e., close and delete it), call this function. You * should then not use the bytestream any more. * The remote entity will be notified of the closing of the stream. * @param s5b The bytestream to dispose. It will be deleted here. */ bool dispose( SOCKS5Bytestream* s5b ); /** * Use this function to accept an incoming bytestream. * @param sid The stream's id as passed to BytestreamHandler::handleIncomingSOCKS5Bytestream(). */ void acceptSOCKS5Bytestream( const std::string& sid ); /** * Use this function to reject an incoming bytestream. * @param sid The stream's id as passed to BytestreamHandler::handleIncomingSOCKS5Bytestream(). * @param reason The reason for the reject. */ void rejectSOCKS5Bytestream( const std::string& sid, StanzaError reason = StanzaErrorNotAcceptable ); /** * Use this function to register an object that will receive new @b incoming bytestream * requests from the SOCKS5BytestreamManager. Only one BytestreamHandler can be * registered at any one time. * @param s5bh The BytestreamHandler derived object to receive notifications. */ void registerBytestreamHandler( BytestreamHandler* s5bh ) { m_socks5BytestreamHandler = s5bh; } /** * Removes the registered BytestreamHandler. */ void removeBytestreamHandler() { m_socks5BytestreamHandler = 0; } /** * Tells the SOCKS5BytestreamManager which SOCKS5BytestreamServer handles peer-2-peer SOCKS5 * bytestreams. * @param server The SOCKS5BytestreamServer to use. */ void registerSOCKS5BytestreamServer( SOCKS5BytestreamServer* server ) { m_server = server; } /** * Un-registers any local SOCKS5BytestreamServer. */ void removeSOCKS5BytestreamServer() { m_server = 0; } // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); private: #ifdef SOCKS5BYTESTREAMMANAGER_TEST public: #endif class Query : public StanzaExtension { public: /** * Constructs a new empty Query object. */ Query(); /** * Constructs a new Query (streamhost) object from the given parameters. * @param sid The stream ID. * @param mode The stream mode (TCP or UDP). * @param hosts A list of stream hosts. */ Query( const std::string& sid, S5BMode mode, const StreamHostList& hosts ); /** * Constructs a new Query (streamhost-used or activate) object, including the given JID. * @param jid The JID. * @param sid The stream ID. * @param activate Determines whether the object will be an 'activate' (@b true) or * 'streamhost-used' (@b false) one. */ Query( const JID& jid, const std::string& sid, bool activate ); /** * Constructs a new Query object from the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag ); /** * Virtual destructor. */ virtual ~Query(); /** * Returns the current stream ID. * @return The current stream ID. */ const std::string& sid() const { return m_sid; } /** * Returns the current JID. * @return The current JID. */ const JID& jid() const { return m_jid; } /** * Returns the current mode. * @return The current mode. */ S5BMode mode() const { return m_mode; } /** * Returns the current list of stream hosts. * @return The current list of stream hosts. */ const StreamHostList& hosts() const { return m_hosts; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Query( *this ); } private: enum QueryType { TypeSH, TypeSHU, TypeA, TypeInvalid }; std::string m_sid; JID m_jid; SOCKS5BytestreamManager::S5BMode m_mode; StreamHostList m_hosts; QueryType m_type; }; SOCKS5BytestreamManager& operator=( const SOCKS5BytestreamManager&); void rejectSOCKS5Bytestream( const JID& from, const std::string& id, StanzaError reason = StanzaErrorNotAcceptable ); bool haveStream( const JID& from ); const StreamHost* findProxy( const JID& from, const std::string& hostjid, const std::string& sid ); void acknowledgeStreamHost( bool success, const JID& jid, const std::string& sid ); enum IBBActionType { S5BOpenStream, S5BCloseStream, S5BActivateStream }; typedef std::map S5BMap; S5BMap m_s5bMap; struct AsyncS5BItem { JID from; JID to; std::string id; StreamHostList sHosts; bool incoming; }; typedef std::map AsyncTrackMap; AsyncTrackMap m_asyncTrackMap; ClientBase* m_parent; BytestreamHandler* m_socks5BytestreamHandler; SOCKS5BytestreamServer* m_server; StreamHostList m_hosts; StringMap m_trackMap; }; } #endif // SOCKS5BYTESTREAMMANAGER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/sxe.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/sxe.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/sxe.h (revision 27490) @@ -0,0 +1,159 @@ +/* + Copyright (c) 2019 by Jakob Schröter + 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 SXE_H__ +#define SXE_H__ + +#include "stanzaextension.h" + +#include +#include +#include + +namespace gloox +{ + + enum SxeType + { + SxeInvalid, + SxeConnect, + SxeStateOffer, + SxeAcceptState, + SxeRefuseState, + SxeState + }; + + enum StateChangeType + { + StateChangeDocumentBegin, + StateChangeDocumentEnd, + StateChangeNew, + StateChangeRemove, + StateChangeSet + }; + + struct DocumentBegin + { + const char* prolog; + }; + + struct DocumentEnd + { + const char* last_sender; + const char* last_id; + }; + + struct New + { + const char* rid; + const char* type; + const char* name; + const char* ns; + const char* parent; + const char* chdata; + }; + + struct Remove + { + const char* target; + }; + + struct Set + { + const char* target; + const char* version; + const char* parent; + const char* name; + const char* ns; + const char* chdata; + }; + + struct StateChange + { + StateChangeType type; + union + { + DocumentBegin document_begin; + DocumentEnd document_end; + New new_; + Remove remove; + Set set; + }; + }; + + /** + * @brief An implementation/abstraction of Shared XML Editing (SXE, @xep{0284}) + * + * XEP Version: 0.1.1 + * + * @author Emmanuel Gil Peyrot + * @since 1.0.23 + */ + class GLOOX_API Sxe : public StanzaExtension + { + private: + Sxe( std::string session, std::string id, SxeType type, std::vector state_offer_xmlns, std::vector state_changes ); + + public: + /** + * Creates a new SXE object from the given Tag. + * @param tag The Tag to parse. + */ + Sxe( const Tag* tag = 0 ); + + /** + * Virtual destructor. + */ + virtual ~Sxe() {} + + /** + * Returns a Tag representing a SXE extension. + * @return A Tag representing a SXE extension. + */ + virtual Tag* tag() const; + + /** + * Returns a new instance of SXE. + * @return The new SXE instance. + */ + virtual StanzaExtension* newInstance( const Tag* tag ) const + { + return new Sxe( tag ); + } + + /** + * Returns an identical copy of the current SXE. + * @return an identical copy of the current SXE. + */ + virtual StanzaExtension* clone() const + { + return new Sxe( *this ); + } + + /** + * Returns an XPath expression that describes a path to the SXE element. + * @return The SXE filter string. + */ + virtual const std::string& filterString() const; + + private: + std::string m_session; + std::string m_id; + SxeType m_type; + std::vector m_state_offer_xmlns; + std::vector m_state_changes; + + }; + +} + +#endif // SXE_H__ Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/sxe.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/mucroomhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/mucroomhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/mucroomhandler.h (revision 27490) @@ -1,216 +1,219 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) #ifndef MUCROOMHANDLER_H__ #define MUCROOMHANDLER_H__ #include "gloox.h" #include "presence.h" #include "disco.h" #include namespace gloox { class JID; class MUCRoom; class Message; class DataForm; /** * Describes a participant in a MUC room. */ struct MUCRoomParticipant { JID* nick; /**< Pointer to a JID holding the participant's full JID * in the form @c room\@service/nick.
* @note The MUC server @b may change the chosen nickname. * If the @b self member of this struct is true, one should * check the resource of this member if the actual nickname * is important. */ MUCRoomAffiliation affiliation; /**< The participant's affiliation with the room. */ MUCRoomRole role; /**< The participant's role with the room. */ JID* jid; /**< Pointer to the occupant's full JID in a non-anonymous room or * in a semi-anonymous room if the user (of gloox) has a role of * moderator. * 0 if the MUC service doesn't provide the JID. */ int flags; /**< ORed MUCUserFlag values. Indicate conditions like: user has * been kicked or banned from the room. Also may indicate that * this struct refers to this instance's user. * (MUC servers send presence to all room occupants, including * the originator of the presence.) */ std::string reason; /**< If the presence change is the result of an action where the * actor can provide a reason for the action, this reason is stored * here. Examples: Kicking, banning, leaving the room. */ JID* actor; /**< If the presence change is the result of an action of a room * member, a pointer to the actor's JID is stored here, if the * actor chose to disclose his or her identity. Examples: Kicking * and banning. * 0 if the identity is not disclosed. */ std::string newNick; /**< In case of a nickname change, this holds the new nick, while the * nick member holds the old room nick (in JID form). @c newNick is only * set if @c flags contains @b UserNickChanged. If @c flags contains * @b UserSelf as well, a foregoing nick change request (using * MUCRoom::setNick()) can be considered acknowledged. In any case * the user's presence sent with the nick change acknowledgement * is of type @c unavailable. Another presence of type @c available * (or whatever the user's presence was at the time of the nick change * request) will follow (not necessarily immediately) coming from the * user's new nickname. Empty if there is no nick change in progress. */ std::string status; /**< If the presence packet contained a status message, it is stored * here. */ JID* alternate; /**< If @c flags contains UserRoomDestroyed, and if the user who * destroyed the room specified an alternate room, this member holds * a pointer to the alternate room's JID, else it is 0. */ }; /** * @brief This interface enables inheriting classes to be notified about certain events in a MUC room. * * See MUCRoom for examples how to use this interface. * * @note This interface does not notify about room configuration related events. Use * MUCRoomConfigHandler for that puprose. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MUCRoomHandler { public: /** * Virtual Destructor. */ virtual ~MUCRoomHandler() {} /** * This function is called whenever a room occupant enters the room, changes presence * inside the room, or leaves the room. * @note The MUCRoomParticipant struct, including pointers to JIDs, will be cleaned up after * this function returned. * @param room The room. * @param participant A struct describing the occupant's status and/or action. * @param presence The occupant's full presence. */ virtual void handleMUCParticipantPresence( MUCRoom* room, const MUCRoomParticipant participant, const Presence& presence ) = 0; /** * This function is called when a message arrives through the room. * @note This may be a private message! If the message is private, and you want to answer * it privately, you should create a new MessageSession to the user's full room nick and use * that for any further private communication with the user. * @param room The room the message came from. * @param msg The entire Message. * @param priv Indicates whether this is a private message. * @note The sender's nick name can be obtained with this call: * @code * const std::string nick = msg.from().resource(); * @endcode * @note The message may contain an extension of type DelayedDelivery describing the * date/time when the message was originally sent. The presence of such an extension * usually indicates that the message is sent as part of the room history. This extension * can be obtained with this call: * @code * const DelayedDelivery* dd = msg.when(); // may be 0 if no such extension exists * @endcode */ virtual void handleMUCMessage( MUCRoom* room, const Message& msg, bool priv ) = 0; /** * This function is called if the room that was just joined didn't exist prior to the attempted * join. Therfore the room was created by MUC service. To accept the default configuration of * the room assigned by the MUC service, return @b true from this function. The room will be opened * by the MUC service and available for other users to join. If you don't want to accept the default * room configuration, return @b false from this function. The room will stay locked until it is * either fully configured, created as an instant room, or creation is canceled. * * If you returned false from this function you should use one of the following options: * @li use MUCRoom::cancelRoomCreation() to abort creation and delete the room, * @li use MUCRoom::acknowledgeInstantRoom() to accept the room's default configuration, or * @li use MUCRoom::requestRoomConfig() to request the room's configuration form. * * @param room The room. * @return @b True to accept the default room configuration, @b false to keep the room locked * until configured manually by the room owner. */ virtual bool handleMUCRoomCreation( MUCRoom* room ) = 0; /** * This function is called when the room subject has been changed. * @param room The room. * @param nick The nick of the occupant that changed the room subject. * @note With some MUC services the nick may be empty when a room is first entered. * @param subject The new room subject. */ virtual void handleMUCSubject( MUCRoom* room, const std::string& nick, const std::string& subject ) = 0; /** * This function is called when the user invited somebody (e.g., by using MUCRoom::invite()) * to the room, but the invitation was declined by that person. * @param room The room. * @param invitee The JID if the person that declined the invitation. * @param reason An optional reason for declining the invitation. */ virtual void handleMUCInviteDecline( MUCRoom* room, const JID& invitee, const std::string& reason ) = 0; /** * This function is called when an error occurs in the room or when entering the room. * @note The following error conditions are specified for MUC: * @li @b Not @b Authorized: Password required. * @li @b Forbidden: Access denied, user is banned. * @li @b Item @b Not @b Found: The room does not exist. * @li @b Not @b Allowed: Room creation is restricted. * @li @b Not @b Acceptable: Room nicks are locked down. * @li @b Registration @b Required: User is not on the member list. * @li @b Conflict: Desired room nickname is in use or registered by another user. * @li @b Service @b Unavailable: Maximum number of users has been reached. * * Other errors might appear, depending on the service implementation. * @param room The room. * @param error The error. */ virtual void handleMUCError( MUCRoom* room, StanzaError error ) = 0; /** * This function usually (see below) is called in response to a call to MUCRoom::getRoomInfo(). * @param room The room. * @param features ORed MUCRoomFlag's. * @param name The room's name as returned by Service Discovery. * @param infoForm A DataForm containing extended room information. May be 0 if the service * doesn't support extended room information. See Section 15.5 of @xep{0045} for defined * field types. You should not delete the form. * * @note This function may be called without a prior call to MUCRoom::getRoomInfo(). This * happens if the room config is changed, e.g. by a room admin. */ virtual void handleMUCInfo( MUCRoom* room, int features, const std::string& name, const DataForm* infoForm ) = 0; /** * This function is called in response to a call to MUCRoom::getRoomItems(). * @param room The room. * @param items A map of room participants. The key is the name, the value is the occupant's * room JID. The map may be empty if such info is private. */ virtual void handleMUCItems( MUCRoom* room, const Disco::ItemList& items ) = 0; }; } #endif// MUCROOMHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pinghandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pinghandler.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/pinghandler.h (revision 27490) @@ -0,0 +1,69 @@ +/* + Copyright (c) 2004-2019 by Jakob Schröter + 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. +*/ + + + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PING ) + +#ifndef PINGHANDLER_H__ +#define PINGHANDLER_H__ + +#include "gloox.h" + +#include + +namespace gloox +{ + + /** + * @brief A virtual interface which can be reimplemented to receive ping stanzas. + * + * Derived classes can be registered as PingHandlers with the Client. + * Upon an incoming Ping or Pong packet @ref handlePing() will be called. + * + * @author Jakob Schröter + * @since 1.1 + */ + class GLOOX_API PingHandler + { + public: + + /** + * The supported ping types. + */ + enum PingType + { + websocketPing = 0, /**< A WebSocket Ping. */ + websocketPong, /**< A WebSocket Pong (ping reply). */ + whitespacePing /**< A whitespace ping. */ + }; + + /** + * Virtual Destructor. + */ + virtual ~PingHandler() {} + + /** + * Reimplement this function if you want to be updated on + * incoming ping or pong notifications. + * @param body The content of the ping or pong stanza. + * @since 1.1 + */ + virtual void handlePing( PingType type, const std::string& body ) = 0; + + }; + +} + +#endif // PINGHANDLER_H__ + +#endif // GLOOX_MINIMAL Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/pinghandler.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/privacymanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/privacymanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/privacymanager.h (revision 27490) @@ -1,231 +1,235 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVACYLISTS ) + #ifndef PRIVACYMANAGER_H__ #define PRIVACYMANAGER_H__ #include "iqhandler.h" #include "privacylisthandler.h" #include "stanzaextension.h" #include namespace gloox { class ClientBase; /** * @brief This class implements a manager for privacy lists as defined in section 10 of RFC 3921. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API PrivacyManager : public IqHandler { public: /** * Constructs a new PrivacyManager. * @param parent The ClientBase to use for communication. */ PrivacyManager( ClientBase* parent ); /** * Virtual destructor. */ virtual ~PrivacyManager(); /** * Stores the given list on the server. If a list with the given name exists, the existing * list is overwritten. * @param name The list's name. * @param list A non empty list of privacy items which describe the list. */ std::string store( const std::string& name, const PrivacyListHandler::PrivacyList& list ); /** * Triggers the request of the privacy lists currently stored on the server. */ std::string requestListNames() { return operation( PLRequestNames, EmptyString ); } /** * Triggers the retrieval of the named privacy lists. * @param name The name of the list to retrieve. */ std::string requestList( const std::string& name ) { return operation( PLRequestList, name ); } /** * Removes a list by its name. * @param name The name of the list to remove. */ std::string removeList( const std::string& name ) { return operation( PLRemove, name ); } /** * Sets the named list as the default list, i.e. active by default after login. * @param name The name of the list to set as default. */ std::string setDefault( const std::string& name ) { return operation( PLDefault, name ); } /** * This function declines the use of any default list. */ std::string unsetDefault() { return operation( PLUnsetDefault, EmptyString ); } /** * Sets the named list as active, i.e. active for this session * @param name The name of the list to set active. */ std::string setActive( const std::string& name ) { return operation( PLActivate, name ); } /** * This function declines the use of any active list. */ std::string unsetActive() { return operation( PLUnsetActivate, EmptyString ); } /** * Use this function to register an object as PrivacyListHandler. * Only one PrivacyListHandler at a time is possible. * @param plh The object to register as handler for privacy list related events. */ void registerPrivacyListHandler( PrivacyListHandler* plh ) { m_privacyListHandler = plh; } /** * Use this function to clear the registered PrivacyListHandler. */ void removePrivacyListHandler() { m_privacyListHandler = 0; } // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); private: enum IdType { PLRequestNames, PLRequestList, PLActivate, PLDefault, PLUnsetActivate, PLUnsetDefault, PLRemove, PLStore }; class Query : public StanzaExtension { public: /** * Creates a new query for storing or requesting a * privacy list. * @param context The context of the list. * @param name The list's name. * @param list The list's (optional) content. */ Query( IdType context, const std::string& name, const PrivacyListHandler::PrivacyList& list = PrivacyListHandler::PrivacyList() ); /** * Creates a new query from the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag = 0 ); /** * Virtual destructor. */ virtual ~Query(); /** * Returns the name of the active list, if given. * @return The active list's name. */ const std::string& active() const { return m_active; } /** * Returns the name of the default list, if given. * @return The default list's name. */ const std::string& def() const { return m_default; } /** * Returns a list of privacy items, if given. * @return A list of PrivacyItems. */ const PrivacyListHandler::PrivacyList& items() const { return m_items; } /** * Returns a list of list names. * @return A list of list names. */ const StringList& names() const { return m_names; } /** * A convenience function that returns the first name of the list that * names() would return, or an empty string. * @return A list name. */ const std::string& name() const { if( m_names.empty()) return EmptyString; else return (*m_names.begin()); } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Query( *this ); } private: IdType m_context; StringList m_names; std::string m_default; std::string m_active; PrivacyListHandler::PrivacyList m_items; }; std::string operation( IdType context, const std::string& name ); ClientBase* m_parent; PrivacyListHandler* m_privacyListHandler; }; } #endif // PRIVACYMANAGER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pubsubevent.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pubsubevent.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/pubsubevent.h (revision 27490) @@ -1,180 +1,178 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PUBSUB ) + #ifndef PUBSUBEVENT_H__ #define PUBSUBEVENT_H__ #include "stanzaextension.h" #include "pubsub.h" #include "gloox.h" namespace gloox { class Tag; namespace PubSub { /** * @brief This is an implementation of a PubSub Notification as a StanzaExtension. * * @author Vincent Thomasset * @since 1.0 */ class GLOOX_API Event : public StanzaExtension { public: /** * Stores a retract or item notification. */ struct ItemOperation { /** * Constructor. * * @param remove Whether this is a retract operation or not (ie item). * @param itemid Item ID of this item. * @param pld Payload for this object (in the case of a non transient * item notification). */ ItemOperation( bool remove, const std::string& itemid, const Tag* pld = 0 ) : retract( remove ), item( itemid ), payload( pld ) {} /** * Copy constructor. * @param right The ItemOperation to copy from. */ ItemOperation( const ItemOperation& right ); bool retract; std::string item; const Tag* payload; }; /** * A list of ItemOperations. */ typedef std::list ItemOperationList; /** - * PubSub event notification Stanza Extension. This constructor can - * be used to create an empty instance for registering the - * StanzaExtension. - */ - Event(); - - /** * PubSub event notification Stanza Extension. * @param event A tag to parse. */ - Event( const Tag* event ); + Event( const Tag* event = 0 ); /** * PubSub event notification Stanza Extension. * @param node The node's ID for which the notification is sent. * @param type The event's type. */ Event( const std::string& node, PubSub::EventType type ); /** * Virtual destructor. */ virtual ~Event(); /** * Returns the event's type. * @return The event's type. */ PubSub::EventType type() const { return m_type; } /** * Returns the list of subscription IDs for which this notification * is valid. * @return The list of subscription IDs. */ const StringList& subscriptions() const { return m_subscriptionIDs ? *m_subscriptionIDs : m_emptyStringList; } /** * Returns the list of ItemOperations for EventItems(Retract) notification. * @return The list of ItemOperations. */ const ItemOperationList& items() const { return m_itemOperations ? *m_itemOperations : m_emptyOperationList; } /** * Add an item to the list of ItemOperations for EventItems(Retract) notification. * After calling, the PubSub::Event object owns the ItemOperation and will free it. * @param op An ItemOperation to add. */ void addItem( ItemOperation* op ); /** * Returns the node's ID for which the notification is sent. * @return The node's ID. */ const std::string& node() const { return m_node; } /** * Returns the subscribe/unsubscribed JID. Only set for subscription notifications * (type() == EventSubscription). * @return The affected JID. */ const JID& jid() { return m_jid; } /** * Returns the subscription state. Only set for subscription notifications * (type() == EventSubscription). * @return @b True if the subscription request was approved, @b false otherwise. */ bool subscription() { return m_subscription; } // reimplemented from StanzaExtension const std::string& filterString() const; // reimplemented from StanzaExtension StanzaExtension* newInstance( const Tag* tag ) const { return new Event( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; private: Event& operator=( const Event& ); PubSub::EventType m_type; std::string m_node; StringList* m_subscriptionIDs; JID m_jid; Tag* m_config; ItemOperationList* m_itemOperations; std::string m_collection; bool m_subscription; const ItemOperationList m_emptyOperationList; const StringList m_emptyStringList; }; } } #endif // PUBSUBEVENT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/receipt.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/receipt.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/receipt.h (revision 27490) @@ -1,103 +1,108 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_RECEIPT ) + #ifndef RECEIPT_H__ #define RECEIPT_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief An implementation of Message Receipts (@xep{0184}) as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API Receipt : public StanzaExtension { public: /** * Contains valid receipt types (@xep{0184}). */ enum ReceiptType { Request, /**< Requests a receipt. */ Received, /**< The receipt. */ Invalid /**< Invalid type. */ }; /** * Constructs a new object from the given Tag. * @param tag A Tag to parse. */ - Receipt( const Tag* tag ); + Receipt( const Tag* tag = 0 ); /** * Constructs a new object of the given type. * @param rcpt The receipt type. * @param id The message ID. */ Receipt( ReceiptType rcpt, const std::string& id = EmptyString ) : StanzaExtension( ExtReceipt ), m_rcpt( rcpt ), m_id( id ) {} /** * Virtual destructor. */ virtual ~Receipt() {} /** * Returns the object's state. * @return The object's state. */ ReceiptType rcpt() const { return m_rcpt; } /** * Returns the message id for acknowledgement tracking. * @return The message ID for acknowledgement tracking. */ std::string id() const { return m_id; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Receipt( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new Receipt( *this ); } private: ReceiptType m_rcpt; std::string m_id; }; } #endif // RECEIPT_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/rosteritem.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosteritem.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosteritem.h (revision 27490) @@ -1,210 +1,202 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 ROSTERITEM_H__ #define ROSTERITEM_H__ #include "jid.h" #include "gloox.h" #include "resource.h" #include "presence.h" #include #include namespace gloox { class RosterItemData; /** * @brief An abstraction of a roster item. * * For each RosterItem all resources that are available (online in some way) are stored in * a ResourceMap. This map is accessible using the resources() function. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API RosterItem { friend class RosterManager; public: /** * A list of resources for the given JID. */ typedef std::map ResourceMap; /** * An empty string. */ const JID EmptyJID; /** * Constructs a new item of the roster. * @param jid The JID of the contact. * @param name The displayed name of the contact. */ RosterItem( const std::string& jid, const std::string& name = EmptyString ); /** * Constructs a new RosterItem using the data holding class. * @param data The RosterItemData to construct the item from. The new * item will own the data object. */ RosterItem( const RosterItemData& data ); /** * Virtual destructor. */ virtual ~RosterItem(); /** * Sets the displayed name of a contact/roster item. * @param name The contact's new name. */ void setName( const std::string& name ); /** * Retrieves the displayed name of a contact/roster item. * @return The contact's name. */ const std::string& name() const; /** * Returns the contact's bare JID. * @return The contact's bare JID. - * @deprecated Use jidJID() for now. In 1.1, jidJID() will be renamed back to jid(). */ - GLOOX_DEPRECATED const std::string& jid() const; - - /** - * Returns the contact's bare JID. - * @return The contact's bare JID. - * @todo Rename to jid() for 1.1. - */ - const JID& jidJID() const; + const JID& jid() const; /** * Sets the current subscription status of the contact. * @param subscription The current subscription. * @param ask Whether a subscription request is pending. */ void setSubscription( const std::string& subscription, const std::string& ask ); /** * Returns the current subscription type between the remote and the local entity. * @return The subscription type. */ SubscriptionType subscription() const; /** * Sets the groups this RosterItem belongs to. * @param groups The groups to set for this item. */ void setGroups( const StringList& groups ); /** * Returns the groups this RosterItem belongs to. * @return The groups this item belongs to. */ const StringList groups() const; /** * Whether the item has unsynchronized changes. * @return @b True if the item has unsynchronized changes, @b false otherwise. */ bool changed() const; /** * Indicates whether this item has at least one resource online (in any state). * @return @b True if at least one resource is online, @b false otherwise. */ bool online() const; /** * Returns the contact's resources. * @return The contact's resources. */ const ResourceMap& resources() const { return m_resources; } /** * Returns the Resource for a specific resource string. * @param res The resource string. * @return The Resource if found, 0 otherwise. */ const Resource* resource( const std::string& res ) const; /** * Returns the Resource with the highest priority. * @return The Resource with the highest priority. */ const Resource* highestResource() const; protected: /** * Sets the current presence of the resource. * @param resource The resource to set the presence for. * @param presence The current presence. */ void setPresence( const std::string& resource, Presence::PresenceType presence ); /** * Sets the current status message of the resource. * @param resource The resource to set the status message for. * @param msg The current status message, i.e. from the presence info. */ void setStatus( const std::string& resource, const std::string& msg ); /** * Sets the current priority of the resource. * @param resource The resource to set the status message for. * @param priority The resource's priority, i.e. from the presence info. */ void setPriority( const std::string& resource, int priority ); /** * Sets the resource's presence extensions. * @param resource The resource to set the extensions for. * @param exts The extensions to set. */ void setExtensions( const std::string& resource, const StanzaExtensionList& exts ); /** * Removes the 'changed' flag from the item. */ void setSynchronized(); /** * This function is called to remove subsequent resources from a RosterItem. * @param resource The resource to remove. */ void removeResource( const std::string& resource ); /** * This function deletes the internal RosterItemData and replaces it with the provided * one. The RosterItem will own the RosterItemData instance. */ void setData( const RosterItemData& rid ); private: RosterItemData* m_data; ResourceMap m_resources; }; } #endif // ROSTERITEM_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/rostermanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rostermanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/rostermanager.h (revision 27490) @@ -1,283 +1,308 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 ROSTERMANAGER_H__ #define ROSTERMANAGER_H__ #include "subscriptionhandler.h" #include "privatexmlhandler.h" #include "iqhandler.h" #include "presencehandler.h" #include "rosterlistener.h" +#include "messagehandler.h" +#include "message.h" #include #include #include namespace gloox { class ClientBase; class Stanza; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) class PrivateXML; +#endif // GLOOX_MINIMAL +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + class Message; + class MessageSession; +#endif // GLOOX_MINIMAL class RosterItem; /** * @brief This class implements Jabber/XMPP roster handling in the @b jabber:iq:roster namespace. * * It takes care of changing presence, subscriptions, etc. * You can modify any number of RosterItems within the Roster at any time. These changes must be * synchronized with the server by calling @ref synchronize(). Note that incoming Roster pushes * initiated by other resources may overwrite changed values. * Additionally, @xep{0083} (Nested Roster Groups) is implemented herein. * * @author Jakob Schröter * @since 0.3 */ - class GLOOX_API RosterManager : public IqHandler, public PresenceHandler, public SubscriptionHandler, - public PrivateXMLHandler + class GLOOX_API RosterManager : public IqHandler, public PresenceHandler, +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) + public PrivateXMLHandler, +#endif // GLOOX_MINIMAL +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + public MessageHandler, +#endif + public SubscriptionHandler { public: /** * Creates a new RosterManager. * @param parent The ClientBase which is used for communication. */ RosterManager( ClientBase* parent ); /** * Virtual destructor. */ virtual ~RosterManager(); /** * This function does the initial filling of the roster with * the current server-side roster. */ void fill(); /** * This function returns the roster. * @return Returns a map of JIDs with their current presence. */ Roster* roster(); /** * Use this function to subscribe to a new JID. The contact is added to the roster automatically * (by compliant servers, as required by RFC 3921). * @param jid The address to subscribe to. * @param name The displayed name of the contact. * @param groups A list of groups the contact belongs to. * @param msg A message sent along with the request. */ void subscribe( const JID& jid, const std::string& name = EmptyString, const StringList& groups = StringList(), const std::string& msg = EmptyString ); /** * Synchronizes locally modified RosterItems back to the server. */ void synchronize(); /** * Use this function to add a contact to the roster. No subscription request is sent. * @note Use @ref unsubscribe() to remove an item from the roster. * @param jid The JID to add. * @param name The displayed name of the contact. * @param groups A list of groups the contact belongs to. */ void add( const JID& jid, const std::string& name, const StringList& groups ); /** * Use this function to unsubscribe from a contact's presence. You will no longer * receive presence from this contact. * @param jid The address to unsubscribe from. * @param msg A message to send along with the request. * @since 0.9 * @note Use remove() to remove a contact from the roster and to cancel its subscriptions. */ void unsubscribe( const JID& jid, const std::string& msg = EmptyString ); /** * Use this function to cancel the contact's subscription to your presence. The contact will * no longer receive presence from you. * @param jid The contact's JID. * @param msg A message to send along with the request. * @since 0.9 * @note Use remove() to remove a contact from the roster and to cancel its subscriptions. */ void cancel( const JID& jid, const std::string& msg = EmptyString ); /** * Use this function to remove a contact from the roster. Subscription is implicitely * cancelled. * @param jid The contact's JID. * @since 0.9 */ void remove( const JID& jid ); /** * Use this function to acknowledge a subscription request if you requested asynchronous * subscription request handling. * @param to The JID to authorize/decline. * @param ack Whether to authorize or decline the contact's request. */ void ackSubscriptionRequest( const JID& to, bool ack ); +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) /** * Use this function to retrieve the delimiter of Nested Roster Groups (@xep{0083}). * @return The group delimiter. * @since 0.7 */ const std::string& delimiter() const { return m_delimiter; } /** * Use this function to set the group delimiter (@xep{0083}). * @param delimiter The group delimiter. * @since 0.7 */ void setDelimiter( const std::string& delimiter ); +#endif // GLOOX_MINIMAL /** * Lets you retrieve the RosterItem that belongs to the given JID. * @param jid The JID to return the RosterItem for. */ RosterItem* getRosterItem( const JID& jid ); /** * Register @c rl as object that receives updates on roster operations. * For GUI applications it may be necessary to display a dialog or whatever to * the user without blocking. If you want that, use asynchronous subscription * requests. If you want to answer a request right away, make it synchronous. * @param rl The object that receives roster updates. * @param syncSubscribeReq Indicates whether (Un)SubscriptionRequests shall * be handled synchronous (@b true) or asynchronous (@b false). Default: synchronous. */ void registerRosterListener( RosterListener* rl, bool syncSubscribeReq = true ); /** * Complementary function to @ref registerRosterListener. Removes the current RosterListener. * Roster events will not be delivered anywhere. */ void removeRosterListener(); // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ); // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); // reimplemented from PresenceHandler. virtual void handlePresence( const Presence& presence ); // reimplemented from SubscriptionHandler. virtual void handleSubscription( const Subscription& subscription ); +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) // reimplemented from PrivateXMLHandler virtual void handlePrivateXML( const Tag* xml ); // reimplemented from PrivateXMLHandler virtual void handlePrivateXMLResult( const std::string& uid, PrivateXMLResult pxResult ); +#endif // GLOOX_MINIMAL + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + // reimplemented from MessageHandler + virtual void handleMessage( const Message& msg, MessageSession* session = 0 ); +#endif private: #ifdef ROSTERMANAGER_TEST public: #endif typedef std::list RosterData; /** * @brief An implementation of StanzaExtension that helps in roster management. * * @author Jakob Schröter * @since 1.0 */ class Query : public StanzaExtension { public: /** * Constructs a new object that can be used to add a contact to the roster. * @param jid The contact's JID. * @param name The contact's optional user-defined name. * @param groups An optional list of groups the contact belongs to. */ Query( const JID& jid, const std::string& name, const StringList& groups ); /** * Constructs a new object that can be used to remove a contact from the roster. * @param jid The contact's JID. */ Query( const JID& jid ); /** * Creates a new Query object from teh given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag = 0 ); /** * Destructor. */ ~Query(); /** * Retruns the internal roster that was created by the ctors (either from an * incoming packet or passed arguments). * This is not necessarily the full roster, but may be a single item. * @return The (possibly partial) roster). */ const RosterData& roster() const { return m_roster; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const; private: RosterData m_roster; }; void mergePush( const RosterData& data ); void mergeRoster( const RosterData& data ); RosterListener* m_rosterListener; Roster m_roster; ClientBase* m_parent; +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVATEXML ) PrivateXML* m_privateXML; +#endif // GLOOX_MINIMAL RosterItem* m_self; std::string m_delimiter; bool m_syncSubscribeReq; enum RosterContext { RequestRoster, AddRosterItem, RemoveRosterItem, SynchronizeRoster }; }; } #endif // ROSTER_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/searchhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/searchhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/searchhandler.h (revision 27490) @@ -1,195 +1,199 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SEARCH ) + #ifndef SEARCHHANDLER_H__ #define SEARCHHANDLER_H__ #include "stanza.h" #include namespace gloox { class DataForm; /** * Holds all the possible fields a server may require for searching according * to Section 7, @xep{0055}. * * @author Jakob Schröter * @since 1.0 */ class SearchFieldStruct { public: /** * */ SearchFieldStruct() {} /** * */ SearchFieldStruct( const std::string& first, const std::string& last, const std::string& nick, const std::string& email ) : m_first( first ), m_last( last ), m_nick( nick ), m_email( email ) {} /** * */ SearchFieldStruct( const Tag* tag ) { if( !tag || tag->name() != "item" || !tag->hasAttribute( "jid" ) ) return; m_jid.setJID( tag->findAttribute( "jid" ) ); const TagList& l = tag->children(); TagList::const_iterator it = l.begin(); for( ; it != l.end(); ++it ) { if( (*it)->name() == "first" ) m_first = (*it)->cdata(); else if( (*it)->name() == "last" ) m_last = (*it)->cdata(); else if( (*it)->name() == "email" ) m_email = (*it)->cdata(); else if( (*it)->name() == "nick" ) m_nick = (*it)->cdata(); } } /** * */ ~SearchFieldStruct() {} /** * */ const std::string first() const { return m_first; } /** * */ const std::string last() const { return m_last; } /** * */ const std::string email() const { return m_email; } /** * */ const std::string nick() const { return m_nick; } /** * */ Tag* tag() const { Tag* t = new Tag( "item" ); t->addAttribute( "jid", m_jid.bare() ); new Tag( t, "first", m_first ); new Tag( t, "last", m_last ); new Tag( t, "nick", m_nick ); new Tag( t, "email", m_email ); return t; } private: std::string m_first; /**< User's first name. */ std::string m_last; /**< User's last name. */ std::string m_nick; /**< User's nickname. */ std::string m_email; /**< User's email. */ JID m_jid; /**< User's JID. */ }; /** * The possible fields of a @xep{0055} user search. */ enum SearchFieldEnum { SearchFieldFirst = 1, /**< Search in first names. */ SearchFieldLast = 2, /**< Search in last names. */ SearchFieldNick = 4, /**< Search in nicknames. */ SearchFieldEmail = 8 /**< Search in email addresses. */ }; /** * A list of directory entries returned by a search. */ typedef std::list SearchResultList; /** * @brief A virtual interface that enables objects to receive Jabber Search (@xep{0055}) results. * * A class implementing this interface can receive the result of a Jabber Search. * * @author Jakob Schröter * @since 0.8.5 */ class GLOOX_API SearchHandler { public: /** * Virtual Destructor. */ virtual ~SearchHandler() {} /** * This function is called to announce the searchable fields a directory supports. It is the result * of a call to @link gloox::Search::fetchSearchFields Search::fetchSearchFields() @endlink. * @param directory The directory that was queried. * @param fields Bit-wise ORed SearchFieldEnum values. * @param instructions Plain-text instructions for the end user. */ virtual void handleSearchFields( const JID& directory, int fields, const std::string& instructions ) = 0; /** * This function is called to announce the searchable fields a directory supports. It is the result * of a call to @link gloox::Search::fetchSearchFields Search::fetchSearchFields() @endlink. * @param directory The directory that was queried. * @param form A DataForm describing the valid searchable fields. Do not delete the form. */ virtual void handleSearchFields( const JID& directory, const DataForm* form ) = 0; /** * This function is called to let the SearchHandler know about the results of the search. * @param directory The searched directory. * @param resultList A list of SearchFieldStructs. May be empty. */ virtual void handleSearchResult( const JID& directory, const SearchResultList& resultList ) = 0; /** * This function is called to let the SearchHandler know about the result of the search. * @param directory The searched directory. * @param form A DataForm containing the search results. Do not delete the form. */ virtual void handleSearchResult( const JID& directory, const DataForm* form ) = 0; /** * This function is called if a error occured as a result to a search or search field request. * @param directory The queried/searched directory. * @param error The error. May be 0. */ virtual void handleSearchError( const JID& directory, const Error* error ) = 0; }; } #endif // SEARCHHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/simanager.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/simanager.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/simanager.h (revision 27490) @@ -1,245 +1,251 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SI ) + #ifndef SIMANAGER_H__ #define SIMANAGER_H__ #include "iqhandler.h" +#include "mutex.h" namespace gloox { class ClientBase; class SIProfileHandler; class SIHandler; /** * @brief This class manages streams initiated using @xep{0095}. * * You need only one SIManager object per ClientBase instance. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SIManager : public IqHandler { public: /** * SI error conditions. */ enum SIError { NoValidStreams, /**< None of the stream types are acceptable */ BadProfile, /**< Profile is not understood. */ RequestRejected /**< SI request was rejected. */ }; class SI : public StanzaExtension { public: /** * Constructs a new SI object from the given Tag. * @param tag The Tag to parse. */ SI( const Tag* tag = 0 ); /** * Constructs a new SI object, wrapping the given Tags. * @param tag1 Tag 1. * @param tag2 Tag 2. */ SI( Tag* tag1, Tag* tag2, const std::string& id = EmptyString, const std::string& mimetype = EmptyString, const std::string& profile = EmptyString ); /** * Virtual destructor. */ virtual ~SI(); /** * Returns the current profile namespace. * @return The profile namespace. */ const std::string& profile() const { return m_profile; }; /** * Returns the mime-type. * @return The mime-type. */ const std::string& mimetype() const { return m_mimetype; }; /** * Returns the SI's ID. * @return The SI's id. */ const std::string& id() const { return m_id; }; /** * Returns the first SI child tag. * @return The first SI child tag. * @todo Use real objects. */ const Tag* tag1() const { return m_tag1; }; /** * Returns the second SI child tag. * @return The second SI child tag. * @todo Use real objects. */ 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; }; /** * Constructor. * @param parent The ClientBase to use for communication. * @param advertise Whether to advertise SI capabilities by disco. Defaults to true. */ SIManager( ClientBase* parent, bool advertise = true ); /** * Virtual destructor. */ virtual ~SIManager(); /** * Starts negotiating a stream with a remote entity. * @param sih The SIHandler to handle the result of this request. * @param to The entity to talk to. * @param profile The SI profile to use. See @xep{0095} for more info. * @param child1 The first of the two allowed children of the SI offer. See * @xep{0095} for more info. * @param child2 The second of the two allowed children of the SI offer. See * @xep{0095} for more info. Defaults to 0. * @param mimetype The stream's/file's mime-type. Defaults to 'binary/octet-stream'. * @param from An optional 'from' address to stamp outgoing requests with. * Used in component scenario only. Defaults to empty JID. * @param sid Optionally specify a stream ID (SID). If empty, one will be generated. * @return The requested stream's ID (SID). Empty if SIHandler or ClientBase are invalid. * @note The SIManager claims ownership of the Tags supplied to this function, and will * delete them after use. */ 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 ); /** * Call this function to accept an SI request previously announced by means of * SIProfileHandler::handleSIRequest(). * @param to The requestor. * @param id The request's id, as passed to SIProfileHandler::handleSIRequest(). * @param child1 The <feature/> child of the SI request. See @xep{0095} for details. * @param child2 The profile-specific child of the SI request. May be 0. See @xep{0095} * for details. * @param from An optional 'from' address to stamp outgoing stanzas with. * Used in component scenario only. Defaults to empty JID. * @note The SIManager claims ownership of the Tags supplied to this function, and will * delete them after use. */ void acceptSI( const JID& to, const std::string& id, Tag* child1, Tag* child2 = 0, const JID& from = JID() ); /** * Call this function to decline an SI request previously announced by means of * SIProfileHandler::handleSIRequest(). * @param to The requestor. * @param id The request's id, as passed to SIProfileHandler::handleSIRequest(). * @param reason The reason for the reject. * @param text An optional human-readable text explaining the decline. */ void declineSI( const JID& to, const std::string& id, SIError reason, const std::string& text = EmptyString ); /** * Registers the given SIProfileHandler to handle requests for the * given SI profile namespace. The profile will be advertised by disco (unless disabled in * the ctor). * @param profile The complete profile namespace, e.g. * http://jabber.org/protocol/si/profile/file-transfer. * @param sih The profile handler. */ void registerProfile( const std::string& profile, SIProfileHandler* sih ); /** * Un-registers the given profile. * @param profile The profile's namespace to un-register. */ 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 TrackMap; TrackMap m_track; + util::Mutex m_trackMutex; ClientBase* m_parent; typedef std::map HandlerMap; HandlerMap m_handlers; bool m_advertise; }; } #endif // SIMANAGER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestream.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestream.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/socks5bytestream.h (revision 27490) @@ -1,136 +1,161 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_BYTESTREAM ) + #ifndef SOCKS5BYTESTREAM_H__ #define SOCKS5BYTESTREAM_H__ #include "bytestream.h" #include "gloox.h" #include "socks5bytestreammanager.h" #include "connectiondatahandler.h" #include namespace gloox { class SOCKS5BytestreamDataHandler; class ConnectionBase; class LogSink; /** * @brief An implementation of a single SOCKS5 Bytestream (@xep{0065}). * * One instance of this class handles one bytestream. * * See SOCKS5BytestreamManager for a detailed description on how to implement * SOCKS5 Bytestreams in your application. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SOCKS5Bytestream : public ConnectionDataHandler, public Bytestream { friend class SOCKS5BytestreamManager; public: /** * Virtual destructor. */ virtual ~SOCKS5Bytestream(); /** * This function starts the connection process. That is, it attempts to connect * to each of the available StreamHosts. Once a working StreamHosts is found, the * SOCKS5BytestreamManager is notified and the function returns. + * @param timeout The timeout to use for select() in milliseconds. Default of -1 means blocking. * @return @b True if a connection to a StreamHost could be established, @b false * otherwise. * @note If @b false is returned you should hand this SOCKS5Bytestream object * to SOCKS5BytestreamManager::dispose() for deletion. * @note Make sure you have a SOCKS5BytestreamDataHandler registered (using * registerSOCKS5BytestreamDataHandler()) before calling this function. */ - virtual bool connect(); + virtual bool connect( int timeout = -1 ); /** * Closes the bytestream. */ virtual void close(); /** * Use this function to send a chunk of data over an open bytestream. There is * no limit for the size of the chunk (other than your machine's memory). * If the stream is not open or has been closed again * (by the remote entity or locally), nothing is sent and @b false is returned. * @param data The block of data to send. * @return @b True if the data has been sent (no guarantee of receipt), @b false * in case of an error. */ virtual bool send( const std::string& data ); /** * Call this function repeatedly to receive data from the socket. You should even do this * if you use the bytestream to merely @b send data. * @param timeout The timeout to use for select in microseconds. Default of -1 means blocking. * @return The state of the connection. */ virtual ConnectionError recv( int timeout = -1 ); /** * Sets the connection to use. * @param connection The connection. The bytestream will own the connection, any * previously set connection gets deleted. */ void setConnectionImpl( ConnectionBase* connection ); /** * This function returns the concrete connection implementation currently in use. * @return The concrete connection implementation. * @since 0.9.7 */ ConnectionBase* connectionImpl( ) { return m_connection; } /** * Use this function to set the available StreamHosts. Usually you should not need to * use this function directly. */ void setStreamHosts( const StreamHostList& hosts ) { m_hosts = hosts; } + /** + * Returns the current list of stream hosts. + * @return The current list of stream hosts. + */ + StreamHostList hosts() const; + + /** + * Returns whether this instance is the stream's initiator. + * @return @True if this instance is the stream's initiator, @b false otherwise. + */ + bool isInitiator() const; + + /** + * Use this function to indicate that this instance is the stream's initiator. + * @param isInitiator Set to @b true if this instance is the stream's + * initiator, set to @b false otherwise. + */ + void setIsInitiator( bool isInitiator ); + // reimplemented from ConnectionDataHandler virtual void handleReceivedData( const ConnectionBase* connection, const std::string& data ); // reimplemented from ConnectionDataHandler virtual void handleConnect( const ConnectionBase* connection ); // reimplemented from ConnectionDataHandler virtual void handleDisconnect( const ConnectionBase* connection, ConnectionError reason ); private: SOCKS5Bytestream( SOCKS5BytestreamManager* manager, ConnectionBase* connection, LogSink& logInstance, const JID& initiator, const JID& target, const std::string& sid ); void activate(); SOCKS5BytestreamManager* m_manager; ConnectionBase* m_connection; ConnectionBase* m_socks5; JID m_proxy; bool m_connected; + bool m_isInitiator; StreamHostList m_hosts; }; } #endif // SOCKS5BYTESTREAM_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/stanzaextension.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/stanzaextension.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/stanzaextension.h (revision 27490) @@ -1,283 +1,290 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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 STANZAEXTENSION_H__ #define STANZAEXTENSION_H__ #include "macros.h" #include namespace gloox { class Tag; class Stanza; /** * Supported Stanza extension types. */ enum StanzaExtensionType { ExtNone, /**< Invalid StanzaExtension. */ ExtVCardUpdate, /**< Extension in the vcard-temp:x:update namespace, * advertising a user avatar's SHA1 hash (@xep{0153}). */ ExtOOB, /**< An extension in the jabber:iq:oob or jabber:x:oob * namespaces (@xep{0066}). */ ExtGPGSigned, /**< An extension containing a GPG/PGP signature * (@xep{0027}). */ ExtGPGEncrypted, /**< An extension containing a GPG/PGP encrypted message * (@xep{0027}). */ ExtReceipt, /**< An extension containing a Message Receipt/Request * (@xep{0184}). */ ExtDelay, /**< An extension containing notice of delayed delivery * (@xep{0203} & @xep{0091}). */ ExtAMP, /**< An extension containing advanced message processing * rules (@xep{0079}). */ ExtError, /**< An extension containing an error. */ ExtCaps, /**< An extension containing Entity Capabilities * (@xep{0115}). */ ExtChatState, /**< An extension containing a chat state (@xep{0085}). */ ExtMessageEvent, /**< An extension containing a message event (@xep{0022}). */ ExtDataForm, /**< An extension containing a Data Form (@xep{0004}). */ ExtNickname, /**< An extension containing a User Nickname (@xep{0172}). */ ExtResourceBind, /**< A resource bind SE (RFC3921). */ ExtSessionCreation, /**< A session establishing SE (RFC3921). */ ExtVersion, /**< An extension containing a Version request/reply * (@xep{0092}). */ ExtXHtmlIM, /**< An extension containing an XHTML message * representation (@xep{0071}) */ ExtDiscoInfo, /**< An extension containing a disco#info element (@xep{0030}). */ ExtDiscoItems, /**< An extension containing a disco#items element (@xep{0030}). */ ExtAdhocCommand, /**< An extension containing a Adhoc Command (@xep{0050}). */ ExtPrivateXML, /**< An extension used for Private XML Storage (@xep{0048}). */ ExtRoster, /**< An extension dealing with the user's roster (RFC-3921). */ ExtFeatureNeg, /**< An extension abstracting a Feature Negotiation element * (@xep{0020}). */ ExtIBB, /**< An extension dealing with IBBs (@xep{0047}). */ ExtNonSaslAuth, /**< An extension for doing Non-SASL Authentication (@xep{0078}). */ ExtMUC, /**< An extension dealing with the muc namespace of @xep{0045}. */ ExtMUCOwner, /**< An extension dealing with the muc#owner namespace of @xep{0045}. */ ExtMUCAdmin, /**< An extension dealing with the muc#admin namespace of @xep{0045}. */ ExtMUCUser, /**< An extension dealing with the muc#user namespace of @xep{0045}. */ ExtMUCUnique, /**< An extension dealing with the muc#unique namespace of @xep{0045}. */ ExtPing, /**< An XMPP Ping (@xep{0199}). */ ExtSearch, /**< A @xep{0055} (Jabber Search) wrapper. */ ExtRegistration, /**< A @xep{0077} (In-Band Registration) wrapper. */ ExtJingle, /**< An extension dealing with Jingle (@xep{0166}) */ ExtVCard, /**< An extension dealing with vcard-temp (@xep{0054}) */ ExtPrivacy, /**< An extension dealing with Privacy Lists (@xep{0016}) */ ExtLastActivity, /**< An extension dealing with Last Activity (@xep{0012}). */ ExtFlexOffline, /**< An extension dealing with Flexible Offline Messages (@xep{0013}). */ ExtSI, /**< An extension dealing with Stream Initiation (@xep{0095}). */ ExtS5BQuery, /**< An extension dealing with stream host offers (@xep{0065}) */ ExtPubSub, /**< An extension dealing with PubSub requests (@xep{0060}). */ ExtPubSubOwner, /**< An extension dealing with PubSub owner requests (@xep{0060}). */ ExtPubSubEvent, /**< An extension for PubSub event notifications * (@xep{0060}) */ ExtSHIM, /**< An extension dealing with Stanza Headers and Internet Metadata (@xep{0131}). */ ExtAttention, /**< An extension dealing with Attention (@xep{0224}). */ ExtForward, /**< An extension dealing with Stanza Forwarding (@xep{0297}). */ ExtCarbons, /**< An extension dealing with Message Carbons (@xep{0280}). */ - ExtIOData, /**< An extension dealing with IO Data (@xep{0244}) (though the IOData extension - * is not actually used as/meant to be a StanzaExtension. */ + ExtIOData, /**< An extension dealing with IO Data (@xep{0244}) (though the IOData + * extension is not actually used as/meant to be a StanzaExtension. */ + ExtRosterX, /**< An extension dealing with Roster Item Exchange (@yep{0144}). */ + ExtChatMarkers, /**< The Chat Markers extension (@xep{0333}). */ + ExtMessageMarkup, /**< The Message Markup extension (@xep{0394}). */ + ExtReference, /**< The References extension (@xep{0372}). */ + ExtHint, /**< The Message Processing Hints extension (@xep{0334}). */ + ExtSXE, /**< An extension dealing with Shared XML Editing (@xep{0284}). */ + ExtBOB, /**< An extension dealing with Bits of Binary (BOB) (@xep{0231}). */ ExtUser /**< User-supplied extensions must use IDs above this. Do * not hard-code ExtUser's value anywhere, it is subject * to change. */ }; /** * @brief This class abstracts a stanza extension, which is usually * an XML child element in a specific namespace inside an XMPP stanza. * * This class is the base class for almost all protocol extensions in gloox. * As such, it should be used whenever an add-on to the core XMPP spec * needs to be made. For simple protocols it may suffice to create a sub-class * of StanzaExtension. For protocols which require keeping of state, an additional * persistent object acting like a manager may be needed. * * A Stanza can be extended by additional namespaced child elements. Obviously, * it is not viable to include all the kinds of extensions possible. To avoid * hard-coding of such extensions into gloox, StanzaExtension can be used to * inform the core of gloox about additional supported extensions without it * needing to know about the exact implementation. * * Note that a StanzaExtension can be used for both sending and receiving * of custom protocols. When receiving, gloox requires an appropriate implementation * of the pure virtuals filterString() and newInstance(). To be able to properly use * the encapsulation, some getters may be necessary. Note that the object you will be * dealing with usually is @em const. * * For sending StanzaExtensions, a custom constructor (as well as some setters, * possibly) is needed. Additionally, an implementation of tag() is required. * * @li Sub-class StanzaExtension and add at least a constructor that accepots a Tag* * (so it can parse an incoming extension in XML format), as well as one accepting * whatever data you need to construct outgoing extension XML. Alternatively to the latter * (or in addition) you can also add setters, of course. One of the constructors should * be able to create an empty instance so it can be passed to ClientBase when registering * your extension type. This empty instance will only be used to create another new instance * using the Tag* constructor when matching extension XML comes in. * * @li Re-implement filterString(). filterString() * is supposed to return an XPath expression that matches the child element * of a stanza that the protocol-to-implement uses. For example, consider this * hypothetical XML format: The protocol is encapsulated inside a <stats> * element in the 'ext:stats' namespace. It uses IQ stanzas for transmission. * @code * * * * * * * 10 * * * @endcode * The idea of filterString() and its XPath expression is to match the * <stats> element such that it can be fed to your * StanzaExtension-derived class' constructor when creating a new instance * of it. For our @e stats protocol, filterString() would return something like: * /iq/stats[\@xmlns='ext:stats'] * * @li When subclassing StanzaExtension, you have to initialize it with an int, the extension's * type. You should choose a value that is not yet used in gloox, and unique to * the given extension you implement. In general, you are free to use values * above @link gloox::ExtUser ExtUser @endlink, e.g ExtUser+1, etc. See * @link gloox::StanzaExtensionType StanzaExtensionType @endlink for existing values. * * @li The next step is to implement newInstance(). Whenever filterString()'s * XPath expression matches a child element of an incoming stanza, newInstance() * is called with the matched Tag. For our example above, this is the <stats> * element (including its children): * @code * * 10 * * @endcode * The purpose of newInstance() is to return a new instance of your specialized * StanzaExtension (implicitly cast to StanzaExtension). This way, gloox can deal * entirely with the abstract base, StanzaExtension, and never ever needs to know * which kind of extension it deals with. The most common implementation of * newInstance() looks like this: * @code * StanzaExtension* StatsExtension::newInstance( const Tag* tag ) const * { * return new StatsExtension( tag ); * } * @endcode * This of course implies that a constructor exists that takes a const Tag* as the * only parameter. * * @li Finally, gloox must be able to serialize the StanzaExtension back * into string'ified XML. This is done by means of the tag() function which * must be reimplemented. The output Tag should -- like the input Tag -- be embeddable * into the respective stanza. * * @li To actually use this you have to register your new extension with * ClientBase::registerStanzaExtension(). Here, an empty instance of your class should be * passed, which will act as a template later (by means of StanzaExtension::clone(), which * you should reimplement). * * @li You can now also register your handlers with ClientBase, * by using the exttype you used in your subclasses with @link ClientBase::registerIqHandler() registerIqHandler() @endlink, * @link ClientBase::registerMessageHandler() registerMessageHandler() @endlink, * @link ClientBase::registerPresenceHandler() registerPresenceHandler() @endlink, or * @link ClientBase::registerSubscriptionHandler() registerSubscriptionHandler() @endlink. * ClientBase will then check incoming stanzas against your filter string(s) and call the respective handlers. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API StanzaExtension { public: /** * Constructs an empty StanzaExtension. * @param type Designates the extension's type. It should be one of StanzaExtensionType * for built-in extensions, and it should be higher than ExtUser for custom types. */ StanzaExtension( int type ) : m_valid( false ), m_extensionType( type ) {} /** * Virtual destructor. */ virtual ~StanzaExtension() {} /** * This function returns the embedded Stanza, if any. * You only have to reimplement it if your protocol flow contains embedded Stanzas. * * @return The embedded Stanza. May be 0. */ virtual Stanza* embeddedStanza() const { return 0; } /** * This function returns the embedded Tag that the embedded Stanza is based on, if any. * You only have to reimplement it if your protocol flow contains embedded Stanzas. * * @return The embedded Tag. May be 0. */ virtual Tag* embeddedTag() const { return 0; } /** * Returns an XPath expression that describes a path to child elements of a * stanza that an extension handles. * * @return The extension's filter string. */ virtual const std::string& filterString() const = 0; /** * Returns a new Instance of the derived type. Usually, for a derived class FooExtension, * the implementation of this function looks like: * @code * StanzaExtension* FooExtension::newInstance( const Tag* tag ) const * { * return new FooExtension( tag ); * } * @endcode * @return The derived extension's new instance. */ virtual StanzaExtension* newInstance( const Tag* tag ) const = 0; /** * Returns a Tag representation of the extension. * @return A Tag representation of the extension. */ virtual Tag* tag() const = 0; /** * Returns an identical copy of the current StanzaExtension. * @return An identical copy of the current StanzaExtension. */ virtual StanzaExtension* clone() const = 0; /** * Returns the extension's type. * @return The extension's type. */ int extensionType() const { return m_extensionType; } protected: bool m_valid; private: int m_extensionType; }; } #endif // STANZAEXTENSION_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/mucroomconfighandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/mucroomconfighandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/mucroomconfighandler.h (revision 27490) @@ -1,226 +1,229 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_MUC ) #ifndef MUCROOMCONFIGHANDLER_H__ #define MUCROOMCONFIGHANDLER_H__ #include "gloox.h" #include "jid.h" #include #include namespace gloox { class MUCRoom; class DataForm; /** * An item in a list of MUC room users. Lists of these items are * used when manipulating the lists of members, admins, owners, etc. * of a room. * * @author Jakob Schröter * @since 1.0 */ class MUCListItem { public: /** * Constructs a new object using the given JID. * @param jid The item's JID. */ MUCListItem( const JID& jid ) : m_jid( jid ), m_affiliation( AffiliationInvalid ), m_role( RoleInvalid ) {} /** * Creates a new object, setting JID, affiliation, role, and nick. * @param jid The item's JID. * @param role The item's role. * @param affiliation The item's affiliation. * @param nick The item's nick. */ MUCListItem( const JID& jid, MUCRoomRole role, MUCRoomAffiliation affiliation, const std::string& nick ) : m_jid( jid ), m_nick( nick ), m_affiliation( affiliation ), m_role( role ) {} /** * Creates a new object, using nick, affiliation and a reason. * @param nick The item's nick. * @param affiliation The item's affiliation. * @param reason A reason. */ MUCListItem( const std::string& nick, MUCRoomAffiliation affiliation, const std::string& reason ) : m_nick( nick ), m_affiliation( affiliation ), m_role( RoleInvalid ), m_reason( reason ) {} /** * Creates a new object, using nick, role and a reason. * @param nick The item's nick. * @param role The item's role. * @param reason A reason. */ MUCListItem( const std::string& nick, MUCRoomRole role, const std::string& reason ) : m_nick( nick ), m_affiliation( AffiliationInvalid ), m_role( role ), m_reason( reason ) {} /** * Destructor. Deletes the @c jid member. */ ~MUCListItem() {} /** * Returns the item's JID. * @return The item's JID. */ const JID& jid() const { return m_jid; } /** * Returns the item's nick. * @return The item's nick. */ const std::string& nick() const { return m_nick; } /** * Returns the item's affiliation. * @return The item's affiliation. */ MUCRoomAffiliation affiliation() const { return m_affiliation; } /** * Returns the item's role. * @return The item's role. */ MUCRoomRole role() const { return m_role; } /** * Returns the reason. * @return The reason. */ const std::string& reason() const { return m_reason; } private: JID m_jid; /**< Pointer to the occupant's JID if available, 0 otherwise. */ std::string m_nick; /**< The occupant's nick in the room. */ MUCRoomAffiliation m_affiliation; /**< The occupant's affiliation. */ MUCRoomRole m_role; /**< The occupant's role. */ std::string m_reason; /**< Use this only when **setting** the item's role/affiliation to * specify a reason for the role/affiliation change. This field is * empty in items fetched from the MUC service. */ }; /** * A list of MUCListItems. */ typedef std::list MUCListItemList; /** * Available operations on a room. */ enum MUCOperation { RequestUniqueName, /**< Request a unique room name. */ CreateInstantRoom, /**< Create an instant room. */ CancelRoomCreation, /**< Cancel room creation process. */ RequestRoomConfig, /**< Request room configuration form. */ SendRoomConfig, /**< Send room configuration */ DestroyRoom, /**< Destroy room. */ GetRoomInfo, /**< Fetch room info. */ GetRoomItems, /**< Fetch room items (e.g., current occupants). */ SetRNone, /**< Set a user's role to None. */ SetVisitor, /**< Set a user's role to Visitor. */ SetParticipant, /**< Set a user's role to Participant. */ SetModerator, /**< Set a user's role to Moderator. */ SetANone, /**< Set a user's affiliation to None. */ SetOutcast, /**< Set a user's affiliation to Outcast. */ SetMember, /**< Set a user's affiliation to Member. */ SetAdmin, /**< Set a user's affiliation to Admin. */ SetOwner, /**< Set a user's affiliation to Owner. */ RequestVoiceList, /**< Request the room's Voice List. */ StoreVoiceList, /**< Store the room's Voice List. */ RequestBanList, /**< Request the room's Ban List. */ StoreBanList, /**< Store the room's Ban List. */ RequestMemberList, /**< Request the room's Member List. */ StoreMemberList, /**< Store the room's Member List. */ RequestModeratorList, /**< Request the room's Moderator List. */ StoreModeratorList, /**< Store the room's Moderator List. */ RequestOwnerList, /**< Request the room's Owner List. */ StoreOwnerList, /**< Store the room's Owner List. */ RequestAdminList, /**< Request the room's Admin List. */ StoreAdminList, /**< Store the room's Admin List. */ InvalidOperation /**< Invalid operation. */ }; /** * @brief An abstract interface that can be implemented for MUC room configuration. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API MUCRoomConfigHandler { public: /** * Virtual Destructor. */ virtual ~MUCRoomConfigHandler() {} /** * This function is called in response to MUCRoom::requestList() if the list was * fetched successfully. * @param room The room for which the list arrived. * @param items The requestd list's items. * @param operation The type of the list. */ virtual void handleMUCConfigList( MUCRoom* room, const MUCListItemList& items, MUCOperation operation ) = 0; /** * This function is called when the room's configuration form arrives. This usually happens * after a call to MUCRoom::requestRoomConfig(). Use * MUCRoom::setRoomConfig() to send the configuration back to the * room. * @param room The room for which the config form arrived. * @param form The configuration form. */ virtual void handleMUCConfigForm( MUCRoom* room, const DataForm& form ) = 0; /** * This function is called in response to MUCRoom::kick(), MUCRoom::storeList(), * MUCRoom::ban(), and others, to indcate the end of the operation. * @param room The room for which the operation ended. * @param success Whether or not the operation was successful. * @param operation The finished operation. */ virtual void handleMUCConfigResult( MUCRoom* room, bool success, MUCOperation operation ) = 0; /** * This function is called when a Voice request or a Registration request arrive through * the room that need to be approved/rejected by the room admin. Use MUCRoom::createDataForm() * to have a Tag created that answers the request. * @param room The room the request arrived from. * @param form A DataForm containing the request. */ virtual void handleMUCRequest( MUCRoom* room, const DataForm& form ) = 0; }; } #endif // MUCROOMCONFIGHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/oob.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/oob.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/oob.h (revision 27490) @@ -1,101 +1,105 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_OOB ) + #ifndef OOB_H__ #define OOB_H__ #include "gloox.h" #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element * as specified in @xep{0066}. * * XEP version: 1.5 * @author Jakob Schröter * @since 0.9 */ class GLOOX_API OOB : public StanzaExtension { public: /** * Constructs an OOB StanzaExtension from teh given URL and description. * @param url The out-of-band URL. * @param description The URL's optional description. * @param iqext Whether this object extends an IQ or a Presence/Message stanza (results in * either jabber:iq:oob or jabber:x:oob namespaced element). */ OOB( const std::string& url, const std::string& description, bool iqext ); /** * Constructs an OOB object from the given Tag. To be recognized properly, the Tag must * have either a name of 'x' in the jabber:x:oob namespace, or a name of 'query' in the * jabber:iq:oob namespace. * @param tag The Tag to parse. */ OOB( const Tag* tag ); /** * Virtual destructor. */ virtual ~OOB(); /** * Returns the out-of-band URL. * @return The out-of-band URL. */ const std::string& url() const { return m_url; } /** * Returns the URL's description. * @return The URL's description. */ const std::string& desc() const { return m_desc; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new OOB( tag ); } // reimplemented from StanzaExtension Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new OOB( *this ); } private: std::string m_xmlns; std::string m_url; std::string m_desc; bool m_iqext; bool m_valid; }; } #endif // OOB_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/privacylisthandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/privacylisthandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/privacylisthandler.h (revision 27490) @@ -1,99 +1,103 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PRIVACYLISTS ) + #ifndef PRIVACYLISTHANDLER_H__ #define PRIVACYLISTHANDLER_H__ #include "privacyitem.h" #include "gloox.h" #include #include namespace gloox { /** * The possible results of an operation on a privacy list. */ enum PrivacyListResult { ResultStoreSuccess, /**< Storing was successful. */ ResultActivateSuccess, /**< Activation was successful. */ ResultDefaultSuccess, /**< Setting the default list was successful. */ ResultRemoveSuccess, /**< Removing a list was successful. */ ResultRequestNamesSuccess, /**< Requesting the list names was successful. */ ResultRequestListSuccess, /**< The list was requested successfully. */ ResultConflict, /**< A conflict occurred when activating a list or setting the default * list. */ ResultItemNotFound, /**< The requested list does not exist. */ ResultBadRequest, /**< Bad request. */ ResultUnknownError /**< An unknown error occured. */ }; /** * @brief A virtual interface that allows to retrieve Privacy Lists. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API PrivacyListHandler { public: /** * A list of PrivacyItems. */ typedef std::list PrivacyList; /** * Virtual Destructor. */ virtual ~PrivacyListHandler() {} /** * Reimplement this function to retrieve the list of privacy list names after requesting it using * PrivacyManager::requestListNames(). * @param active The name of the active list. * @param def The name of the default list. * @param lists All the lists. */ virtual void handlePrivacyListNames( const std::string& active, const std::string& def, const StringList& lists ) = 0; /** * Reimplement this function to retrieve the content of a privacy list after requesting it using * PrivacyManager::requestList(). * @param name The name of the list. * @param items A list of PrivacyItem's. */ virtual void handlePrivacyList( const std::string& name, const PrivacyList& items ) = 0; /** * Reimplement this function to be notified about new or changed lists. * @param name The name of the new or changed list. */ virtual void handlePrivacyListChanged( const std::string& name ) = 0; /** * Reimplement this function to receive results of stores etc. * @param id The ID of the request, as returned by the initiating function. * @param plResult The result of an operation. */ virtual void handlePrivacyListResult( const std::string& id, PrivacyListResult plResult ) = 0; }; } #endif // PRIVACYLISTHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pubsub.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pubsub.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/pubsub.h (revision 27490) @@ -1,249 +1,254 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PUBSUB ) + #ifndef PUBSUB_H__ #define PUBSUB_H__ #include #include #include "gloox.h" #include "jid.h" namespace gloox { /** * @brief Namespace holding all the Pubsub-related structures and definitions. */ namespace PubSub { class Item; /** * Describes the different node types. */ enum NodeType { NodeLeaf, /**< A node that contains published items only. It is NOT * a container for other nodes. */ NodeCollection, /**< A node that contains nodes and/or other collections but * no published items. Collections make it possible to represent * hierarchial node structures. */ NodeInvalid /**< Invalid node type */ }; /** * Describes the different node affiliation types. */ enum AffiliationType { AffiliationNone, /**< No particular affiliation type. */ AffiliationPublisher, /**< Entity is allowed to publish items. */ AffiliationOwner, /**< Manager for the node. */ AffiliationOutcast, /**< Entity is disallowed from subscribing or publishing. */ AffiliationInvalid /**< Invalid Affiliation type. */ }; /** * Describes the different subscription types. */ enum SubscriptionType { SubscriptionNone, /**< The node MUST NOT send event notifications or payloads to the * Entity. */ SubscriptionSubscribed, /**< An entity is subscribed to a node. The node MUST send all event * notifications (and, if configured, payloads) to the entity while it * is in this state. */ SubscriptionPending, /**< An entity has requested to subscribe to a node and the request * has not yet been approved by a node owner. The node MUST NOT send * event notifications or payloads to the entity while it is in this * state. */ SubscriptionUnconfigured, /**< An entity has subscribed but its subscription options have not yet * been configured. The node MAY send event notifications or payloads * to the entity while it is in this state. The service MAY timeout * unconfigured subscriptions. */ SubscriptionInvalid /**< Invalid subscription type. */ }; /** * Event types. */ enum EventType { EventCollection, /**< A Collection node has been created. */ EventConfigure, /**< A node's configuration has changed. */ EventDelete, /**< A node has been deleted. */ EventItems, /**< An item has been created or modified. */ EventItemsRetract, /**< An item has been deleted. */ EventPurge, /**< A Leaf node has been purged. */ EventSubscription, /**< A user's subscription has been processed. */ EventUnknown /**< Unknown event. */ }; /** * Describes the different subscription types. */ enum SubscriptionObject { SubscriptionNodes, /**< Receive notification of new nodes only. */ SubscriptionItems /**< Receive notification of new items only. */ }; /** * Describes the access types. */ enum AccessModel { AccessOpen, /**< Any entity may subscribe to the node (i.e., without the necessity * for subscription approval) and any entity may retrieve items from the * node (i.e., without being subscribed); this SHOULD be the default * access model for generic pubsub services. */ AccessPresence, /**< Any entity with a subscription of type "from" or "both" may subscribe * to the node and retrieve items from the node; this access model applies * mainly to instant messaging systems (see RFC 3921). */ AccessRoster, /**< Any entity in the specified roster group(s) may subscribe to the node * and retrieve items from the node; this access model applies mainly to * instant messaging systems (see RFC 3921). */ AccessAuthorize, /**< The node owner must approve all subscription requests, and only * subscribers may retrieve items from the node. */ AccessWhitelist, /**< An entity may be subscribed only through being added to a whitelist * by the node owner (unsolicited subscription requests are rejected), and * only subscribers may retrieve items from the node. In effect, the * default affiliation is outcast. The node owner MUST automatically be * on the whitelist. In order to add entities to the whitelist, the * node owner SHOULD use the protocol specified in the Manage Affiliated * Entities section of this document. */ AccessDefault /**< Unspecified (default) Access Model (does not represent a real access * type by itself). */ }; /** * Describes the different PubSub features (@xep{0060} Sect. 10). */ enum PubSubFeature { FeatureCollections = 1, /**< Collection nodes are supported. RECOMMENDED */ FeatureConfigNode = 1<<1, /**< Configuration of node options is supported. RECOMMENDED */ FeatureCreateAndConfig = 1<<2, /**< Simultaneous creation and configuration of nodes is * supported. RECOMMENDED */ FeatureCreateNodes = 1<<3, /**< Creation of nodes is supported. RECOMMENDED */ FeatureDeleteAny = 1<<4, /**< Any publisher may delete an item (not only the originating * publisher). OPTIONAL */ FeatureDeleteNodes = 1<<5, /**< Deletion of nodes is supported. RECOMMENDED */ FeatureGetPending = 1<<6, /**< Retrieval of pending subscription approvals is supported. * OPTIONAL */ FeatureInstantNodes = 1<<7, /**< Creation of instant nodes is supported. RECOMMENDED */ FeatureItemIDs = 1<<8, /**< Publishers may specify item identifiers. RECOMMENDED */ FeatureLeasedSubscription = 1<<9, /**< Time-based subscriptions are supported. OPTIONAL */ FeatureManageSubscriptions = 1<<10, /**< Node owners may manage subscriptions. OPTIONAL */ FeatureMetaData = 1<<11, /**< Node meta-data is supported. RECOMMENDED */ FeatureModifyAffiliations = 1<<12, /**< Node owners may modify affiliations. OPTIONAL */ FeatureMultiCollection = 1<<13, /**< A single leaf node may be associated with multiple * collections. OPTIONAL */ FeatureMultiSubscribe = 1<<14, /**< A single entity may subscribe to a node multiple times. * OPTIONAL */ FeaturePutcastAffiliation = 1<<15, /**< The outcast affiliation is supported. RECOMMENDED */ FeaturePersistentItems = 1<<16, /**< Persistent items are supported. RECOMMENDED */ FeaturePresenceNotifications = 1<<17, /**< Presence-based delivery of event notifications is supported. * OPTIONAL */ FeaturePublish = 1<<18, /**< Publishing items is supported (note: not valid for collection * nodes). REQUIRED */ FeaturePublisherAffiliation = 1<<19, /**< The publisher affiliation is supported. OPTIONAL */ FeaturePurgeNodes = 1<<20, /**< Purging of nodes is supported. OPTIONAL */ FeatureRetractItems = 1<<21, /**< Item retraction is supported. OPTIONAL */ FeatureRetrieveAffiliations = 1<<22, /**< Retrieval of current affiliations is supported. * RECOMMENDED */ FeatureRetrieveDefault = 1<<23, /**< Retrieval of default node configuration is supported. * RECOMMENDED */ FeatureRetrieveItems = 1<<24, /**< Item retrieval is supported. RECOMMENDED */ FeatureRetrieveSubscriptions = 1<<25, /**< Retrieval of current subscriptions is supported. * RECOMMENDED */ FeatureSubscribe = 1<<26, /**< Subscribing and unsubscribing are supported. REQUIRED */ FeatureSubscriptionOptions = 1<<27, /**< Configuration of subscription options is supported. * OPTIONAL */ FeatureSubscriptionNotifs = 1<<28, /**< Notification of subscription state changes is supported. */ FeatureUnknown = 1<<29 /**< Unrecognized feature */ }; // [Persistent - Notification] /* Publisher MUST include an <item/> element, which MAY be empty or contain a payload; if item ID is not provided by publisher, it MUST be generated by pubsub service */ // [Persistent - Payload] /* Publisher MUST include an <item/> element that contains the payload; if item ID is not provided by publisher, it MUST be generated by pubsub service */ // [Transient - Notification] /* Publisher MUST NOT include an <item/> element (therefore item ID is neither provided nor generated) but the notification will include an empty <items/> element */ // [Transient - Payload] /* Publisher MUST include an <item/> element that contains the payload, but the item ID is OPTIONAL */ /** * Describes a subscribed entity. */ struct Subscriber { Subscriber( const JID& _jid, SubscriptionType _type, const std::string& _subid = EmptyString) : jid( _jid ), type( _type ), subid( _subid ) {} JID jid; SubscriptionType type; std::string subid; }; /** * Describes an Affiliate. */ struct Affiliate { Affiliate( const JID& _jid, AffiliationType _type ) : jid( _jid ), type( _type ) {} JID jid; AffiliationType type; }; typedef std::list SubscriberList; typedef std::list AffiliateList; /** * Struct used to track info between requests. * */ struct TrackedInfo { JID service; std::string node; std::string item; std::string sid; }; /** * Struct used for subscription info. */ struct SubscriptionInfo { SubscriptionType type; JID jid; std::string subid; }; typedef std::list SubscriptionList; typedef std::map SubscriptionMap; typedef std::map AffiliationMap; typedef std::list ItemList; } } #endif // PUBSUB_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/pubsubresulthandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/pubsubresulthandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/pubsubresulthandler.h (revision 27490) @@ -1,395 +1,399 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_PUBSUB ) + #ifndef PUBSUBRESULTHANDLER_H__ #define PUBSUBRESULTHANDLER_H__ #include "error.h" #include "jid.h" #include "macros.h" #include "pubsub.h" #include "tag.h" #include #include #include namespace gloox { class Tag; class Error; class DataForm; namespace PubSub { /** * @brief A virtual interface to receive item related requests results. * * Derive from this interface and pass it to item related requests. * * As a general rule, methods receive an Error pointer which will be null * (when the request was successful) or describe the problem. Requests * asking for information will have their "pointer to information" set to * null when an error occured (that is they're mutually exclusive). In both * cases, gloox takes care of deleting these objects. * * @author Vincent Thomasset * @since 1.0 */ class GLOOX_API ResultHandler { public: /** * Virtual destructor. */ virtual ~ResultHandler() {} /** * Receives the payload for an item. * * @param service Service hosting the queried node. * @param node ID of the parent node. * @param entry The complete item Tag (do not delete). */ virtual void handleItem( const JID& service, const std::string& node, const Tag* entry ) = 0; /** * Receives the list of Items for a node. * * @param id The reply IQ's id. * @param service Service hosting the queried node. * @param node ID of the queried node (empty for the root node). * @param itemList List of contained items. * @param error Describes the error case if the request failed. * * @see Manager::requestItems() */ virtual void handleItems( const std::string& id, const JID& service, const std::string& node, const ItemList& itemList, const Error* error = 0 ) = 0; /** * Receives the result for an item publication. * * @param id The reply IQ's id. * @param service Service hosting the queried node. * @param node ID of the queried node. If empty, the root node has been queried. * @param itemList List of contained items. * @param error Describes the error case if the request failed. * * @see Manager::publishItem */ virtual void handleItemPublication( const std::string& id, const JID& service, const std::string& node, const ItemList& itemList, const Error* error = 0 ) = 0; /** * Receives the result of an item removal. * * @param id The reply IQ's id. * @param service Service hosting the queried node. * @param node ID of the queried node. If empty, the root node has been queried. * @param itemList List of contained items. * @param error Describes the error case if the request failed. * * @see Manager::deleteItem */ virtual void handleItemDeletion( const std::string& id, const JID& service, const std::string& node, const ItemList& itemList, const Error* error = 0 ) = 0; /** * Receives the subscription results. In case a problem occured, the * Subscription ID and SubscriptionType becomes irrelevant. * * @param id The reply IQ's id. * @param service PubSub service asked for subscription. * @param node Node asked for subscription. * @param sid Subscription ID. * @param jid Subscribed entity. * @param subType Type of the subscription. * @param error Subscription Error. * * @see Manager::subscribe */ virtual void handleSubscriptionResult( const std::string& id, const JID& service, const std::string& node, const std::string& sid, const JID& jid, const SubscriptionType subType, const Error* error = 0 ) = 0; /** * Receives the unsubscription results. In case a problem occured, the * subscription ID becomes irrelevant. * * @param id The reply IQ's id. * @param service PubSub service. * @param error Unsubscription Error. * * @see Manager::unsubscribe */ virtual void handleUnsubscriptionResult( const std::string& id, const JID& service, const Error* error = 0 ) = 0; /** * Receives the subscription options for a node. * * @param id The reply IQ's id. * @param service Service hosting the queried node. * @param jid Subscribed entity. * @param node ID of the node. * @param options Options DataForm. * @param sid An optional subscription ID. * @param error Subscription options retrieval Error. * * @see Manager::getSubscriptionOptions */ virtual void handleSubscriptionOptions( const std::string& id, const JID& service, const JID& jid, const std::string& node, const DataForm* options, const std::string& sid = EmptyString, const Error* error = 0 ) = 0; /** * Receives the result for a subscription options modification. * * @param id The reply IQ's id. * @param service Service hosting the queried node. * @param jid Subscribed entity. * @param node ID of the queried node. * @param sid An optional subscription ID. * @param error Subscription options modification Error. * * @see Manager::setSubscriptionOptions */ virtual void handleSubscriptionOptionsResult( const std::string& id, const JID& service, const JID& jid, const std::string& node, const std::string& sid = EmptyString, const Error* error = 0 ) = 0; /** * Receives the list of subscribers to a node. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the queried node. * @param list Subscriber list. * @param error Subscription options modification Error. * * @see Manager::getSubscribers */ virtual void handleSubscribers( const std::string& id, const JID& service, const std::string& node, const SubscriptionList& list, const Error* error = 0 ) = 0; /** * Receives the result of a subscriber list modification. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the queried node. * @param list Subscriber list. * @param error Subscriber list modification Error. * * @see Manager::setSubscribers */ virtual void handleSubscribersResult( const std::string& id, const JID& service, const std::string& node, const SubscriberList* list, const Error* error = 0 ) = 0; /** * Receives the affiliate list for a node. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the queried node. * @param list Affiliation list. * @param error Affiliation list retrieval Error. * * @see Manager::getAffiliates */ virtual void handleAffiliates( const std::string& id, const JID& service, const std::string& node, const AffiliateList* list, const Error* error = 0 ) = 0; /** * Handle the affiliate list for a specific node. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param list The Affiliate list. * @param error Affiliation list modification Error. * * @see Manager::setAffiliations */ virtual void handleAffiliatesResult( const std::string& id, const JID& service, const std::string& node, const AffiliateList* list, const Error* error = 0 ) = 0; /** * Receives the configuration for a specific node. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param config Configuration DataForm. * @param error Configuration retrieval Error. * * @see Manager::getNodeConfig */ virtual void handleNodeConfig( const std::string& id, const JID& service, const std::string& node, const DataForm* config, const Error* error = 0 ) = 0; /** * Receives the result of a node's configuration modification. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param error Configuration modification Error. * * @see Manager::setNodeConfig */ virtual void handleNodeConfigResult( const std::string& id, const JID& service, const std::string& node, const Error* error = 0 ) = 0; /** * Receives the result of a node creation. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param error Node creation Error. * * @see Manager::setNodeConfig */ virtual void handleNodeCreation( const std::string& id, const JID& service, const std::string& node, const Error* error = 0 ) = 0; /** * Receives the result for a node removal. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param error Node removal Error. * * @see Manager::deleteNode */ virtual void handleNodeDeletion( const std::string& id, const JID& service, const std::string& node, const Error* error = 0 ) = 0; /** * Receives the result of a node purge request. * * @param id The reply IQ's id. * @param service Service hosting the node. * @param node ID of the node. * @param error Node purge Error. * * @see Manager::purgeNode */ virtual void handleNodePurge( const std::string& id, const JID& service, const std::string& node, const Error* error = 0 ) = 0; /** * Receives the Subscription list for a specific service. * * @param id The reply IQ's id. * @param service The queried service. * @param subMap The map of node's subscription. * @param error Subscription list retrieval Error. * * @see Manager::getSubscriptions */ virtual void handleSubscriptions( const std::string& id, const JID& service, const SubscriptionMap& subMap, const Error* error = 0) = 0; /** * Receives the Affiliation map for a specific service. * * @param id The reply IQ's id. * @param service The queried service. * @param affMap The map of node's affiliation. * @param error Affiliation list retrieval Error. * * @see Manager::getAffiliations */ virtual void handleAffiliations( const std::string& id, const JID& service, const AffiliationMap& affMap, const Error* error = 0 ) = 0; /** * Receives the default configuration for a specific node type. * * @param id The reply IQ's id. * @param service The queried service. * @param config Configuration form for the node type. * @param error Default node config retrieval Error. * * @see Manager::getDefaultNodeConfig */ virtual void handleDefaultNodeConfig( const std::string& id, const JID& service, const DataForm* config, const Error* error = 0 ) = 0; }; } } #endif // PUBSUBRESULTHANDLER_H__ +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/registrationhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/registrationhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/registrationhandler.h (revision 27490) @@ -1,131 +1,136 @@ /* Copyright (c) 2005-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_REGISTRATION ) #ifndef REGISTRATIONHANDLER_H__ #define REGISTRATIONHANDLER_H__ #include "oob.h" #include namespace gloox { class OOB; class JID; class DataForm; + class Error; /** * Possible results of a @xep{0077} operation. */ enum RegistrationResult { RegistrationSuccess = 0, /**< The last operation (account registration, account * deletion or password change) was successful. */ RegistrationNotAcceptable, /**< 406: Not all necessary information provided */ RegistrationConflict, /**< 409: Username alreday exists. */ RegistrationNotAuthorized, /**< Account removal: Unregistered entity waits too long * before authentication or performs tasks other than * authentication after registration.
* Password change: The server or service does not consider * the channel safe enough to enable a password change. */ RegistrationBadRequest, /**< Account removal: The <remove/> element was not * the only child element of the <query/> element. * Should not happen when only gloox functions are being * used.
* Password change: The password change request does not * contain complete information (both <username/> and * <password/> are required). */ RegistrationForbidden, /**< Account removal: The sender does not have sufficient * permissions to cancel the registration. */ RegistrationRequired, /**< Account removal: The entity sending the remove * request was not previously registered. */ RegistrationUnexpectedRequest, /**< Account removal: The host is an instant messaging * server and the IQ get does not contain a 'from' * address because the entity is not registered with * the server.
* Password change: The host is an instant messaging * server and the IQ set does not contain a 'from' * address because the entity is not registered with * the server. */ RegistrationNotAllowed, /**< Password change: The server or service does not allow * password changes. */ RegistrationConstraint, /**< Resource constraint: The server or recipient lacks the * system resources necessary to service the request,for * example if users are not allowed to register accounts so quickly. */ RegistrationUnknownError /**< An unknown error condition occured. */ }; /** * @brief A virtual interface that receives events from an Registration object. * * Derived classes can be registered as RegistrationHandlers with an * Registration object. Incoming results for operations initiated through * the Registration object are forwarded to this handler. * * @author Jakob Schröter * @since 0.2 */ class GLOOX_API RegistrationHandler { public: /** * Virtual Destructor. */ virtual ~RegistrationHandler() {} /** * Reimplement this function to receive results of the * @ref Registration::fetchRegistrationFields() function. * @param from The server or service the registration fields came from. * @param fields The OR'ed fields the server requires. From @ref Registration::fieldEnum. * @param instructions Any additional information the server sends along. */ virtual void handleRegistrationFields( const JID& from, int fields, std::string instructions ) = 0; /** * This function is called if @ref Registration::createAccount() was called on an authenticated * stream and the server lets us know about this. */ virtual void handleAlreadyRegistered( const JID& from ) = 0; /** * This funtion is called to notify about the result of an operation. * @param from The server or service the result came from. * @param regResult The result of the last operation. + * @param error If registration failed, this is the Error object sent by the server (if any), 0 otherwise. @since 1.1 */ - virtual void handleRegistrationResult( const JID& from, RegistrationResult regResult ) = 0; + virtual void handleRegistrationResult( const JID& from, RegistrationResult regResult, const Error* error ) = 0; /** * This function is called additionally to @ref handleRegistrationFields() if the server * supplied a data form together with legacy registration fields. * @param from The server or service the data form came from. * @param form The DataForm containing registration information. */ virtual void handleDataForm( const JID& from, const DataForm& form ) = 0; /** * This function is called if the server does not offer in-band registration * but wants to refer the user to an external URL. * @param from The server or service the referal came from. * @param oob The OOB object describing the external URL. */ virtual void handleOOB( const JID& from, const OOB& oob ) = 0; }; } #endif // REGISTRATIONHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/rosterlistener.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/rosterlistener.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/rosterlistener.h (revision 27490) @@ -1,173 +1,186 @@ /* Copyright (c) 2004-2019 by Jakob Schröter 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 ROSTERLISTENER_H__ #define ROSTERLISTENER_H__ #include "rosteritem.h" +#include "rosterx.h" #include #include namespace gloox { class IQ; class Presence; /** * A map of JID/RosterItem pairs. */ typedef std::map Roster; /** * @brief A virtual interface which can be reimplemented to receive roster updates. * * A class implementing this interface and being registered as RosterListener with the * RosterManager object receives notifications about all the changes in the server-side * roster. Only one RosterListener per Roster at a time is possible. * * @author Jakob Schröter * @since 0.3 */ class GLOOX_API RosterListener { public: /** * Virtual Destructor. */ virtual ~RosterListener() {} /** * Reimplement this function if you want to be notified about new items * on the server-side roster (items subject to a so-called Roster Push). * This function will be called regardless who added the item, either this * resource or another. However, it will not be called for JIDs for which * presence is received without them being on the roster. * @param jid The new item's full address. */ virtual void handleItemAdded( const JID& jid ) = 0; /** * Reimplement this function if you want to be notified about items * which authorised subscription. * @param jid The authorising item's full address. */ virtual void handleItemSubscribed( const JID& jid ) = 0; /** * Reimplement this function if you want to be notified about items that * were removed from the server-side roster (items subject to a so-called Roster Push). * This function will be called regardless who deleted the item, either this resource or * another. * @param jid The removed item's full address. */ virtual void handleItemRemoved( const JID& jid ) = 0; /** * Reimplement this function if you want to be notified about items that * were modified on the server-side roster (items subject to a so-called Roster Push). * A roster push is initiated if a second resource of this JID modifies an item stored on the * server-side contact list. This can include modifying the item's name, its groups, or the * subscription status. These changes are pushed by the server to @b all connected resources. * This is why this function will be called if you modify a roster item locally and synchronize * it with the server. * @param jid The modified item's full address. */ virtual void handleItemUpdated( const JID& jid ) = 0; /** * Reimplement this function if you want to be notified about items which * removed subscription authorization. * @param jid The item's full address. */ virtual void handleItemUnsubscribed( const JID& jid ) = 0; /** * Reimplement this function if you want to receive the whole server-side roster * on the initial roster push. After successful authentication, RosterManager asks the * server for the full server-side roster. Invocation of this method announces its arrival. * Roster item status is set to 'unavailable' until incoming presence info updates it. A full * roster push only happens once per connection. * @param roster The full roster. */ virtual void handleRoster( const Roster& roster ) = 0; /** * This function is called on every status change of an item in the roster. * If the presence is of type Unavailable, then the resource has already been * removed from the RosterItem. * @param item The roster item. * @param resource The resource that changed presence. * @param presence The item's new presence. * @param msg The status change message. * @since 0.9 */ virtual void handleRosterPresence( const RosterItem& item, const std::string& resource, Presence::PresenceType presence, const std::string& msg ) = 0; /** * This function is called on every status change of a JID that matches the Client's * own JID. * If the presence is of type Unavailable, then the resource has already been * removed from the RosterItem. * @param item The self item. * @param resource The resource that changed presence. * @param presence The item's new presence. * @param msg The status change message. * @since 0.9 */ virtual void handleSelfPresence( const RosterItem& item, const std::string& resource, Presence::PresenceType presence, const std::string& msg ) = 0; /** * This function is called when an entity wishes to subscribe to this entity's presence. * If the handler is registered as a asynchronous handler for subscription requests, * the return value of this function is ignored. In this case you should use * RosterManager::ackSubscriptionRequest() to answer the request. * @param jid The requesting item's address. * @param msg A message sent along with the request. * @return Return @b true to allow subscription and subscribe to the remote entity's * presence, @b false to ignore the request. */ virtual bool handleSubscriptionRequest( const JID& jid, const std::string& msg ) = 0; /** * This function is called when an entity unsubscribes from this entity's presence. * If the handler is registered as a asynchronous handler for subscription requests, * the return value of this function is ignored. In this case you should use * RosterManager::unsubscribe() if you want to unsubscribe yourself from the contct's * presence and to remove the contact from the roster. * @param jid The item's address. * @param msg A message sent along with the request. * @return Return @b true to unsubscribe from the remote entity, @b false to ignore. */ virtual bool handleUnsubscriptionRequest( const JID& jid, const std::string& msg ) = 0; /** * This function is called whenever presence from an entity is received which is not in * the roster. * @param presence The full presence stanza. */ virtual void handleNonrosterPresence( const Presence& presence ) = 0; /** * This function is called if the server returned an error. * @param iq The error stanza. */ virtual void handleRosterError( const IQ& iq ) = 0; + +#if !defined( GLOOX_MINIMAL ) || defined( WANT_ROSTER_ITEM_EXCHANGE ) + /** + * This function is called for incoming Roster Item Exchange (@xep{0144}) suggestions. See RosterX. + * @param from The entity suggesting the Roster Item exchange. + * @param items The suggested item(s). Check the items' action() function to find out whether + * this is a suggested addition/deletion/modification. + * @since 1.1 + */ + virtual void handleRosterItemExchange( const JID& from, const RosterX* items ) = 0; +#endif // GLOOX_MINIMAL + }; } #endif // ROSTERLISTENER_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/search.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/search.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/search.h (revision 27490) @@ -1,215 +1,218 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SEARCH ) #ifndef SEARCH_H__ #define SEARCH_H__ #include "gloox.h" #include "searchhandler.h" #include "discohandler.h" #include "iqhandler.h" #include "stanzaextension.h" #include "dataform.h" #include namespace gloox { class ClientBase; class IQ; class Disco; /** * @brief An implementation of @xep{0055} (Jabber Search) * * To perform a search in a directory (e.g., a User Directory): * * @li Inherit from SearchHandler and implement the virtual functions. * @li Create a new Search object. * @li Ask the directory for the supported fields using fetchSearchFields(). Depending on the directory, * the result can be either an integer (bit-wise ORed supported fields) or a DataForm. * @li Search by either using a DataForm or the SearchFieldStruct. * @li The results can be either a (empty) list of SearchFieldStructs or a DataForm. * * @author Jakob Schröter * @since 0.8.5 */ class GLOOX_API Search : public IqHandler { public: /** * Creates a new Search object. * @param parent The ClientBase to use. */ Search( ClientBase* parent ); /** * Virtual Destructor. */ ~Search(); /** * Use this function to check which fields the directory supports. * @param directory The (user) directory to fetch the available/searchable fields from. * @param sh The SearchHandler to notify about the results. */ void fetchSearchFields( const JID& directory, SearchHandler* sh ); /** * Initiates a search on the given directory, with the given data form. The given SearchHandler * is notified about the results. * @param directory The (user) directory to search. * @param form The DataForm contains the phrases the user wishes to search for. * Search will delete the form eventually. * @param sh The SearchHandler to notify about the results. */ void search( const JID& directory, DataForm* form, SearchHandler* sh ); /** * Initiates a search on the given directory, with the given phrases. The given SearchHandler * is notified about the results. * @param directory The (user) directory to search. * @param fields Bit-wise ORed FieldEnum values describing the valid (i.e., set) fields in * the @b values parameter. * @param values Contains the phrases to search for. * @param sh The SearchHandler to notify about the results. */ void search( const JID& directory, int fields, const SearchFieldStruct& values, SearchHandler* sh ); // reimplemented from IqHandler. virtual bool handleIq( const IQ& iq ) { (void)iq; return false; } // reimplemented from IqHandler. virtual void handleIqID( const IQ& iq, int context ); protected: enum IdType { FetchSearchFields, DoSearch }; typedef std::map TrackMap; TrackMap m_track; ClientBase* m_parent; Disco* m_disco; private: #ifdef SEARCH_TEST public: #endif /** * @brief A wrapping class for the @xep{0055} <query> element. * * @author Jakob Schröter * @since 1.0 */ class Query : public StanzaExtension { public: /** * Creates a new object that can be used to carry out a search. * @param form A DataForm containing the search terms. */ Query( DataForm* form ); /** * Creates a new object that can be used to carry out a search. * @param fields Bit-wise ORed FieldEnum values describing the valid (i.e., set) * fields in the @b values parameter. * @param values Contains the phrases to search for. */ Query( int fields, const SearchFieldStruct& values ); /** * Creates a new object that can be used to request search fields. * Optionally, it can parse the given Tag. * @param tag The Tag to parse. */ Query( const Tag* tag = 0 ); /** * Virtual Destructor. */ virtual ~Query(); /** * Returns the contained search form, if any. * @return The search form. May be 0. */ const DataForm* form() const { return m_form; } /** * Returns the search instructions, if given * @return The search instructions. */ const std::string& instructions() const { return m_instructions; } /** * Returns the search fields, if set. * @return The search fields. */ int fields() const { return m_fields; } /** * Returns the search's result, if available in legacy form. Use form() otherwise. * @return The search's result. */ const SearchResultList& result() const { return m_srl; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new Query( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { Query* q = new Query(); q->m_form = m_form ? new DataForm( *m_form ) : 0; q->m_fields = m_fields; q->m_values = m_values; q->m_instructions = m_instructions; SearchResultList::const_iterator it = m_srl.begin(); for( ; it != m_srl.end(); ++it ) q->m_srl.push_back( new SearchFieldStruct( *(*it) ) ); return q; } private: #ifdef SEARCH_TEST public: #endif DataForm* m_form; int m_fields; SearchFieldStruct m_values; std::string m_instructions; SearchResultList m_srl; }; }; } #endif // SEARCH_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/sihandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/sihandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/sihandler.h (revision 27490) @@ -1,70 +1,74 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SI ) + #ifndef SIHANDLER_H__ #define SIHANDLER_H__ #include "macros.h" #include "simanager.h" #include namespace gloox { class IQ; class Tag; class JID; /** * @brief An abstract base class to handle results of outgoing SI requests, i.e. you requested a stream * (using SIManager::requestSI()) to send a file to a remote entity. * * You should usually not need to use this class directly, unless your profile is not supported * by gloox. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SIHandler { public: /** * Virtual destructor. */ virtual ~SIHandler() {} /** * This function is called to handle results of outgoing SI requests, i.e. you requested a stream * (using SIManager::requestSI()) to send a file to a remote entity. * @param from The remote SI receiver. * @param to The SI requestor. Usually oneself. Used in component scenario. * @param sid The stream ID. * @param si The request's complete SI. */ virtual void handleSIRequestResult( const JID& from, const JID& to, const std::string& sid, const SIManager::SI& si ) = 0; /** * This function is called to handle a request error or decline. * @param iq The complete error stanza. * @param sid The request's SID. */ virtual void handleSIRequestError( const IQ& iq, const std::string& sid ) = 0; }; } #endif // SIHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/siprofilehandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/siprofilehandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/siprofilehandler.h (revision 27490) @@ -1,62 +1,66 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SI ) + #ifndef SIPROFILEHANDLER_H__ #define SIPROFILEHANDLER_H__ #include "jid.h" #include "simanager.h" #include namespace gloox { class Tag; class JID; /** * @brief An abstract base class to handle SI requests for a specific profile, e.g. file transfer. * * You should usually not need to use this class directly, unless your profile is not supported * by gloox. * * @author Jakob Schröter * @since 0.9 */ class GLOOX_API SIProfileHandler { public: /** * Virtual destructor. */ virtual ~SIProfileHandler() {} /** * This function is called to handle incoming SI requests, i.e. a remote entity requested * a stream to send a file to you. You should use either SIManager::acceptSI() or * SIManager::declineSI() to accept or reject the request, respectively. * @param from The SI requestor. * @param to The SI recipient, usually oneself. Used in component scenario. * @param id The request's id (@b not the stream's id). This id MUST be supplied to either * SIManager::acceptSI() or SIManager::declineSI(). * @param si The request's complete SI. */ virtual void handleSIRequest( const JID& from, const JID& to, const std::string& id, const SIManager::SI& si ) = 0; }; } #endif // SIPROFILEHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/softwareversion.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/softwareversion.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/softwareversion.h (revision 27490) @@ -1,101 +1,104 @@ /* Copyright (c) 2008-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_SOFTWAREVERSION ) #ifndef SOFTWAREVERSION_H__ #define SOFTWAREVERSION_H__ #include "stanzaextension.h" #include namespace gloox { class Tag; /** * @brief This is an implementation of @xep{0092} as a StanzaExtension. * * @author Jakob Schröter * @since 1.0 */ class GLOOX_API SoftwareVersion : public StanzaExtension { public: /** * Constructs a new object with the given resource string. * @param name The software's name. * @param version The software's version. * @param os The software's operating system. */ SoftwareVersion( const std::string& name, const std::string& version, const std::string& os ); /** * Constructs a new object from the given Tag. * @param tag The Tag to parse. */ SoftwareVersion( const Tag* tag = 0 ); /** * Virtual Destructor. */ virtual ~SoftwareVersion(); /** * Returns the application's name. * @return The application's name. */ const std::string& name() const { return m_name; } /** * Returns the application's version. * @return The application's version. */ const std::string& version() const { return m_version; } /** * Returns the application's Operating System. * @return The application's OS. */ const std::string& os() const { return m_os; } // reimplemented from StanzaExtension virtual const std::string& filterString() const; // reimplemented from StanzaExtension virtual StanzaExtension* newInstance( const Tag* tag ) const { return new SoftwareVersion( tag ); } // reimplemented from StanzaExtension virtual Tag* tag() const; // reimplemented from StanzaExtension virtual StanzaExtension* clone() const { return new SoftwareVersion( *this ); } private: std::string m_name; std::string m_version; std::string m_os; }; } #endif// SOFTWAREVERSION_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserveranon.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserveranon.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserveranon.h (revision 27490) @@ -1,75 +1,78 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 TLSGNUTLSSERVERANON_H__ #define TLSGNUTLSSERVERANON_H__ #include "tlsgnutlsbase.h" #include "config.h" #ifdef HAVE_GNUTLS #include #include namespace gloox { /** * @brief This class implements (stream) encryption using GnuTLS server-side. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GnuTLSServerAnon : public GnuTLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. */ GnuTLSServerAnon( TLSHandler* th ); /** * Virtual destructor. */ virtual ~GnuTLSServerAnon(); // reimplemented from TLSBase virtual bool init( const std::string& clientKey = EmptyString, const std::string& clientCerts = EmptyString, const StringList& cacerts = StringList() ); // reimplemented from TLSBase + virtual void setTLSVersion( TLSVersion tlsVersion ); + + // reimplemented from TLSBase virtual void cleanup(); private: virtual void getCertInfo(); void generateDH(); gnutls_anon_server_credentials_t m_anoncred; gnutls_dh_params_t m_dhParams; const int m_dhBits; }; } #endif // HAVE_GNUTLS #endif // TLSGNUTLSSERVERANON_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserver.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserver.h (nonexistent) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserver.h (revision 27490) @@ -0,0 +1,83 @@ +/* + Copyright (c) 2007-2019 by Jakob Schröter + 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 TLSGNUTLSSERVER_H__ +#define TLSGNUTLSSERVER_H__ + +#include "tlsgnutlsbase.h" + +#include "config.h" + +#ifdef HAVE_GNUTLS + +#include +#include + +namespace gloox +{ + + /** + * @brief This class implements (stream) encryption using GnuTLS server-side. + * + * You should not need to use this class directly. + * + * @author Jakob Schröter + * @since 1.0 + */ + class GnuTLSServer : public GnuTLSBase + { + public: + /** + * Constructor. + * @param th The TLSHandler to handle TLS-related events. + */ + GnuTLSServer( TLSHandler* th ); + + /** + * Virtual destructor. + */ + virtual ~GnuTLSServer(); + + // reimplemented from TLSBase + virtual bool init( const std::string& clientKey = EmptyString, + const std::string& clientCerts = EmptyString, + const StringList& cacerts = StringList() ); + + // reimplemented from TLSBase + virtual void cleanup(); + + private: + // reimplemented from TLSBase + virtual void setCACerts( const StringList& cacerts ); + + // reimplemented from TLSBase + virtual void setClientCert( const std::string& clientKey, + const std::string& clientCerts ); + + virtual void getCertInfo(); + void generateDH(); + + gnutls_certificate_credentials_t m_x509cred; +// gnutls_priority_t m_priorityCache; + gnutls_dh_params_t m_dhParams; + gnutls_rsa_params_t m_rsaParams; + const int m_dhBits; + + }; + +} + +#endif // HAVE_GNUTLS + +#endif // TLSGNUTLSSERVER_H__ Property changes on: ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsserver.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslserver.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslserver.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslserver.h (revision 27490) @@ -1,64 +1,65 @@ /* Copyright (c) 2009-2019 by Jakob Schröter 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 TLSOPENSSLSERVER_H__ #define TLSOPENSSLSERVER_H__ #include "tlsopensslbase.h" #include "config.h" #ifdef HAVE_OPENSSL #include namespace gloox { /** * This class implements a TLS server backend using OpenSSL. * * @author Jakob Schröter * @since 1.0 */ class OpenSSLServer : public OpenSSLBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. */ OpenSSLServer( TLSHandler* th ); /** * Virtual destructor. */ virtual ~OpenSSLServer(); private: // reimplemented from OpenSSLBase virtual bool privateInit(); - // reimplemented from OpenSSLBase - virtual bool setType(); + + // reimplemented from TLSOpenSSLBase + virtual bool createCTX(); // reimplemented from OpenSSLBase virtual int handshakeFunction(); }; } #endif // HAVE_OPENSSL #endif // TLSOPENSSLSERVER_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclientanon.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclientanon.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclientanon.h (revision 27490) @@ -1,70 +1,73 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 TLSGNUTLSCLIENTANON_H__ #define TLSGNUTLSCLIENTANON_H__ #include "tlsgnutlsbase.h" #include "config.h" #ifdef HAVE_GNUTLS #include #include namespace gloox { /** * @brief This class implements an anonymous TLS backend using GnuTLS. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GnuTLSClientAnon : public GnuTLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. */ GnuTLSClientAnon( TLSHandler* th ); /** * Virtual destructor. */ virtual ~GnuTLSClientAnon(); // reimplemented from TLSBase virtual bool init( const std::string& clientKey = EmptyString, const std::string& clientCerts = EmptyString, const StringList& cacerts = StringList() ); // reimplemented from TLSBase + virtual void setTLSVersion( TLSVersion tlsVersion ); + + // reimplemented from TLSBase virtual void cleanup(); private: virtual void getCertInfo(); gnutls_anon_client_credentials_t m_anoncred; }; } #endif // HAVE_GNUTLS #endif // TLSGNUTLSCLIENTANON_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslclient.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslclient.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslclient.h (revision 27490) @@ -1,69 +1,69 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 TLSOPENSSLCLIENT_H__ #define TLSOPENSSLCLIENT_H__ #include "tlsopensslbase.h" #include "config.h" #ifdef HAVE_OPENSSL #include namespace gloox { /** * This class implements a TLS client backend using OpenSSL. * * @author Jakob Schröter * @since 0.9 */ class OpenSSLClient : public OpenSSLBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. * @param server The server to use in certificate verification. */ OpenSSLClient( TLSHandler* th, const std::string& server ); /** * Virtual destructor. */ virtual ~OpenSSLClient(); // reimplemented from TLSBase virtual bool hasChannelBinding() const; // reimplemented from TLSBase virtual const std::string channelBinding() const; private: - // reimplemented from OpenSSLBase - virtual bool setType(); + // reimplemented from TLSOpenSSLBase + virtual bool createCTX(); // reimplemented from OpenSSLBase virtual int handshakeFunction(); }; } #endif // HAVE_OPENSSL #endif // TLSOPENSSLCLIENT_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclient.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclient.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsgnutlsclient.h (revision 27490) @@ -1,81 +1,84 @@ /* Copyright (c) 2007-2019 by Jakob Schröter 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 TLSGNUTLSCLIENT_H__ #define TLSGNUTLSCLIENT_H__ #include "tlsgnutlsbase.h" #include "config.h" #ifdef HAVE_GNUTLS #include #include namespace gloox { /** - * @brief This class implements a TLS backend using GnuTLS. + * @brief This class implements a TLS client backend using GnuTLS. * * You should not need to use this class directly. * * @author Jakob Schröter * @since 0.9 */ class GnuTLSClient : public GnuTLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. * @param server The server to use in certificate verification. */ GnuTLSClient( TLSHandler* th, const std::string& server ); /** * Virtual destructor. */ virtual ~GnuTLSClient(); // reimplemented from TLSBase virtual bool init( const std::string& clientKey = EmptyString, const std::string& clientCerts = EmptyString, const StringList& cacerts = StringList() ); // reimplemented from TLSBase virtual void setCACerts( const StringList& cacerts ); // reimplemented from TLSBase virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ); // reimplemented from TLSBase + virtual void setTLSVersion( TLSVersion tlsVersion ); + + // reimplemented from TLSBase virtual void cleanup(); private: virtual void getCertInfo(); bool verifyAgainst( gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer ); bool verifyAgainstCAs( gnutls_x509_crt_t cert, gnutls_x509_crt_t *CAList, int CAListSize ); gnutls_certificate_credentials_t m_credentials; }; } #endif // HAVE_GNUTLS #endif // TLSGNUTLSCLIENT_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslbase.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslbase.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsopensslbase.h (revision 27490) @@ -1,108 +1,137 @@ /* Copyright (c) 2009-2019 by Jakob Schröter 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 TLSOPENSSLBASE_H__ #define TLSOPENSSLBASE_H__ #include "tlsbase.h" #include "config.h" #ifdef HAVE_OPENSSL #include +#ifdef HAVE_PTHREAD +#include +#endif + namespace gloox { /** * This is a common base class for client and server-side TLS * stream encryption implementations using OpenSSL. * * @author Jakob Schröter * @since 1.0 */ class OpenSSLBase : public TLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. * @param server The server to use in certificate verification. */ OpenSSLBase( TLSHandler* th, const std::string& server = EmptyString ); /** * Virtual destructor. */ virtual ~OpenSSLBase(); // reimplemented from TLSBase virtual bool init( const std::string& clientKey = EmptyString, const std::string& clientCerts = EmptyString, const StringList& cacerts = StringList() ); // reimplemented from TLSBase virtual bool encrypt( const std::string& data ); // reimplemented from TLSBase virtual int decrypt( const std::string& data ); // reimplemented from TLSBase virtual void cleanup(); // reimplemented from TLSBase virtual bool handshake(); // reimplemented from TLSBase virtual void setCACerts( const StringList& cacerts ); // reimplemented from TLSBase virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ); protected: - virtual bool setType() = 0; + /** + * Possible results of hostname verification. + */ + enum HostnameValidationResult { + MatchFound, + MatchNotFound, + NoSANPresent, + MalformedCertificate, + Error + }; + + virtual bool createCTX() = 0; virtual int handshakeFunction() = 0; SSL* m_ssl; SSL_CTX* m_ctx; BIO* m_ibio; BIO* m_nbio; private: void pushFunc(); virtual bool privateInit() { return true; } enum TLSOperation { TLSHandshake, TLSWrite, TLSRead }; void doTLSOperation( TLSOperation op ); int ASN1Time2UnixTime( ASN1_TIME* time ); + HostnameValidationResult matchesCommonName( const char* hostname, const X509* server_cert ); + HostnameValidationResult matchesSubjectAlternativeName( const char* hostname, const X509* server_cert ); + HostnameValidationResult validateHostname( const char* hostname, const X509* server_cert, + StringList& listSAN ); + void fillSubjectAlternativeName( StringList& list, const X509 *server_cert ); +#ifdef HAVE_PTHREAD + static void lockCallback( int mode, int type, char *file, int line ); + static unsigned long threadId(); + void initLocks(); + void killLocks(); +#endif std::string m_recvBuffer; std::string m_sendBuffer; char* m_buf; const int m_bufsize; +#ifdef HAVE_PTHREAD + static pthread_mutex_t **lockarray; +#endif }; } #endif // HAVE_OPENSSL #endif // TLSOPENSSLBASE_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/tlsschannel.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/tlsschannel.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/tlsschannel.h (revision 27490) @@ -1,114 +1,115 @@ /* * Copyright (c) 2007-2019 by Jakob Schröter * 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 TLSSCHANNEL_H__ #define TLSSCHANNEL_H__ #include "tlsbase.h" #include "config.h" #ifdef HAVE_WINTLS #include #define SECURITY_WIN32 #include #include #include namespace gloox { /** * This class implements a TLS backend using SChannel. * * @author Jakob Schröter * @since 0.9 */ class SChannel : public TLSBase { public: /** * Constructor. * @param th The TLSHandler to handle TLS-related events. * @param server The server to use in certificate verification. */ SChannel( TLSHandler* th, const std::string& server ); /** * Virtual destructor. */ virtual ~SChannel(); // reimplemented from TLSBase virtual bool init( const std::string& /*clientKey*/ = EmptyString, const std::string& /*clientCerts*/ = EmptyString, const StringList& /*cacerts*/ = StringList() ) { return true; } // reimplemented from TLSBase virtual bool encrypt( const std::string& data ); // reimplemented from TLSBase virtual int decrypt( const std::string& data ); // reimplemented from TLSBase virtual void cleanup(); // reimplemented from TLSBase virtual bool handshake(); // reimplemented from TLSBase virtual bool hasChannelBinding() const; // reimplemented from TLSBase virtual const std::string channelBinding() const; // reimplemented from TLSBase virtual void setCACerts( const StringList& cacerts ); // reimplemented from TLSBase virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts ); private: void handshakeStage( const std::string& data ); void setSizes(); int filetime2int( FILETIME t ); void validateCert(); void connectionInfos(); void certData(); void setCertinfos(); CredHandle m_credHandle; CtxtHandle m_context; SecPkgContext_StreamSizes m_sizes; size_t m_header_max; size_t m_message_max; size_t m_trailer_max; std::string m_buffer; + std::string m_bufferDecrypt; bool m_cleanedup; // windows error outputs // void print_error( int errorcode, const char* place = 0 ); }; } #endif // HAVE_WINTLS #endif // TLSSCHANNEL_H__ Index: ps/trunk/libraries/win32/gloox/include/gloox/vcardhandler.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/vcardhandler.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/vcardhandler.h (revision 27490) @@ -1,75 +1,79 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_VCARD ) + #ifndef VCARDHANDLER_H__ #define VCARDHANDLER_H__ #include "macros.h" #include "vcard.h" #include "jid.h" namespace gloox { class VCard; /** * @brief A virtual interface that helps requesting Jabber VCards. * * Derive from this interface and register with the VCardManager. * See @link gloox::VCardManager VCardManager @endlink for info on how to * fetch VCards. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API VCardHandler { public: /** * Describes possible operation contexts. */ enum VCardContext { FetchVCard, /**< Operation involves fetching a VCard. */ StoreVCard /**< Operation involves storing a VCard. */ }; /** * Virtual destructor. */ virtual ~VCardHandler() {} /** * This function is called when a VCard has been successfully fetched. * @param jid The JID to which this VCard belongs. * @param vcard The fetched VCard. Zero if there is no VCard for this contact. * Do @b not delete the VCard. It will be deleted after this function returned. */ virtual void handleVCard( const JID& jid, const VCard* vcard ) = 0; /** * This function is called to indicate the result of a VCard store operation * or any error that occurs. * @param context The operation which yielded the result. * @param jid The JID involved. * @param se The error, if any. If equal to @c StanzaErrorUndefined no error occured. */ virtual void handleVCardResult( VCardContext context, const JID& jid, StanzaError se = StanzaErrorUndefined ) = 0; }; } #endif // VCARDHANDLER_H__ + +#endif // GLOOX_MINIMAL Index: ps/trunk/libraries/win32/gloox/lib/gloox-1.0.lib =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: ps/trunk/libraries/win32/gloox/include/gloox/vcard.h =================================================================== --- ps/trunk/libraries/win32/gloox/include/gloox/vcard.h (revision 27489) +++ ps/trunk/libraries/win32/gloox/include/gloox/vcard.h (revision 27490) @@ -1,627 +1,631 @@ /* Copyright (c) 2006-2019 by Jakob Schröter 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. */ +#if !defined( GLOOX_MINIMAL ) || defined( WANT_VCARD ) + #ifndef VCARD_H__ #define VCARD_H__ #include "gloox.h" #include "stanzaextension.h" namespace gloox { class Tag; /** * @brief A VCard abstraction. * * See @link gloox::VCardManager VCardManager @endlink for info on how to * fetch VCards. * * @author Jakob Schröter * @since 0.8 */ class GLOOX_API VCard : public StanzaExtension { public: /** * Addressing type indicators. * @note @c AddrTypeDom and @c AddrTypeIntl are mutually exclusive. If both are present, * @c AddrTypeDom takes precendence. * @note Also note that not all adress types are applicable everywhere. For example, * @c AddrTypeIsdn does not make sense for a postal address. Check @xep{0054} * for details. */ enum AddressType { AddrTypeHome = 1, /**< Home address. */ AddrTypeWork = 2, /**< Work address. */ AddrTypePref = 4, /**< Preferred address. */ AddrTypeX400 = 8, /**< X.400 address. */ AddrTypeInet = 16, /**< Internet address. */ AddrTypeParcel = 32, /**< Parcel address. */ AddrTypePostal = 64, /**< Postal address. */ AddrTypeDom = 128, /**< Domestic(?) address. */ AddrTypeIntl = 256, /**< International(?) address. */ AddrTypeVoice = 512, /**< Voice number. */ AddrTypeFax = 1024, /**< Fax number. */ AddrTypePager = 2048, /**< Pager. */ AddrTypeMsg = 4096, /**< MSG(?) */ AddrTypeCell = 8192, /**< Cell phone number. */ AddrTypeVideo = 16384, /**< Video chat(?). */ AddrTypeBbs = 32768, /**< BBS. */ AddrTypeModem = 65536, /**< Modem. */ AddrTypeIsdn = 131072, /**< ISDN. */ AddrTypePcs = 262144 /**< PCS. */ }; /** * A person's full name. */ struct Name { std::string family; /**< Family name. */ std::string given; /**< Given name. */ std::string middle; /**< Middle name. */ std::string prefix; /**< Name prefix. */ std::string suffix; /**< Name suffix. */ }; /** * Classifies the VCard. */ enum VCardClassification { ClassNone = 0, /**< Not classified. */ ClassPublic = 1, /**< Public. */ ClassPrivate = 2, /**< Private. */ ClassConfidential = 4 /**< Confidential. */ }; /** * Describes an email field. */ struct Email { std::string userid; /**< Email address. */ bool home; /**< Whether this is a personal address. */ bool work; /**< Whether this is a work address. */ bool internet; /**< Whether this is an internet address(?). */ bool pref; /**< Whether this is the preferred address. */ bool x400; /**< Whether this is an X.400 address. */ }; /** * A list of email fields. */ typedef std::list EmailList; /** * Describes a telephone number entry. */ struct Telephone { std::string number; /**< The phone number. */ bool home; /**< Whether this is a personal number. */ bool work; /**< Whether this is a work number. */ bool voice; /**< Whether this is a voice number. */ bool fax; /**< Whether this is a fax number. */ bool pager; /**< Whether this is a pager. */ bool msg; /**< MSG(?) */ bool cell; /**< Whether this is a cell phone. */ bool video; /**< Whether this is a video chat(?). */ bool bbs; /**< Whether this is a BBS. */ bool modem; /**< Whether this is a modem. */ bool isdn; /**< Whether this is a ISDN line(?) */ bool pcs; /**< PCS(?) */ bool pref; /**< Whether this is the preferred number. */ }; /** * A list of telephone entries. */ typedef std::list TelephoneList; /** * Describes an address entry. */ struct Address { std::string pobox; /**< Pobox. */ std::string extadd; /**< Extended address. */ std::string street; /**< Street. */ std::string locality; /**< Locality. */ std::string region; /**< Region. */ std::string pcode; /**< Postal code. */ std::string ctry; /**< Country. */ bool home; /**< Whether this is a personal address. */ bool work; /**< Whether this is a work address. */ bool postal; /**< Whether this is a postal address(?). */ bool parcel; /**< Whether this is a arcel address(?). */ bool pref; /**< Whether this is the preferred address. */ bool dom; /**< Whether this is a domestic(?) address. */ bool intl; /**< Whether this is an international(?) address. */ }; /** * Describes an address label. */ struct Label { StringList lines; /**< A list of lines. */ bool home; /**< Whether this is a personal address. */ bool work; /**< Whether this is a work address. */ bool postal; /**< Whether this is a postal address(?). */ bool parcel; /**< Whether this is a arcel address(?). */ bool pref; /**< Whether this is the preferred address. */ bool dom; /**< Whether this is a domestic(?) address. */ bool intl; /**< Whether this is an international(?) address. */ }; /** * Describes geo information. */ struct Geo { std::string latitude; /**< Longitude. */ std::string longitude; /**< Latitude. */ }; /** * Describes organization information. */ struct Org { std::string name; /**< The organizations name. */ StringList units; /**< A list of units in the organization * (the VCard's owner belongs to?). */ }; /** * Describes photo/logo information. */ struct Photo { std::string extval; /**< The photo is not stored inside the VCard. This is a hint (URL?) * where to look for it. */ std::string binval; /**< This is the photo (binary). */ std::string type; /**< This is a hint at the mime-type. May be forged! */ }; /** * A list of address entries. */ typedef std::list
AddressList; /** * A list of address labels. */ typedef std::list