diff options
Diffstat (limited to 'Swiften/Client/CoreClient.h')
| -rw-r--r-- | Swiften/Client/CoreClient.h | 107 | 
1 files changed, 42 insertions, 65 deletions
| diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h index eb9c42c..16813de 100644 --- a/Swiften/Client/CoreClient.h +++ b/Swiften/Client/CoreClient.h @@ -6,35 +6,34 @@  #pragma once -#include "Swiften/Base/boost_bsignals.h" +#include <string>  #include <boost/shared_ptr.hpp> +#include <Swiften/Base/boost_bsignals.h> -#include "Swiften/Network/PlatformDomainNameResolver.h" -#include "Swiften/Network/Connector.h" -#include "Swiften/Base/Error.h" -#include "Swiften/Client/ClientSession.h" -#include "Swiften/Client/ClientError.h" -#include "Swiften/Elements/Presence.h" -#include "Swiften/Elements/Message.h" -#include "Swiften/JID/JID.h" -#include <string> -#include "Swiften/Client/StanzaChannel.h" -#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" -#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"  #include <Swiften/Entity/Entity.h> - -#include "Swiften/Client/ClientSessionStanzaChannel.h" +#include <Swiften/JID/JID.h> +#include <Swiften/Client/ClientError.h> +#include <Swiften/Client/ClientOptions.h> +#include <Swiften/Base/SafeByteArray.h>  namespace Swift { +	class ChainedConnector; +	class Message; +	class Presence; +	class Error;  	class IQRouter;  	class TLSContextFactory;  	class ConnectionFactory; +	class Connection;  	class TimerFactory;  	class ClientSession; +	class StanzaChannel; +	class Stanza;  	class BasicSessionStream;  	class PlatformTLSFactories;  	class CertificateTrustChecker;  	class NetworkFactories; +	class ClientSessionStanzaChannel;  	/**   	 * The central class for communicating with an XMPP server. @@ -48,16 +47,11 @@ namespace Swift {  	 */  	class CoreClient : public Entity {  		public:  -			enum UseTLS { -				NeverUseTLS, -				UseTLSWhenAvailable -			}; -  			/**  			 * Constructs a client for the given JID with the given password.  			 * The given eventLoop will be used to post events to.  			 */ -			CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories); +			CoreClient(const JID& jid, const SafeByteArray& password, NetworkFactories* networkFactories);  			~CoreClient();  			void setCertificate(const std::string& certificate); @@ -68,7 +62,7 @@ namespace Swift {  			 * After the connection is established, the client will set   			 * initialize the stream and authenticate.  			 */ -			void connect(); +			void connect(const ClientOptions& = ClientOptions());  			/**  			 * Disconnects the client from the server. @@ -80,12 +74,12 @@ namespace Swift {  			/**  			 * Sends a message.  			 */ -			void sendMessage(Message::ref); +			void sendMessage(boost::shared_ptr<Message>);  			/**  			 * Sends a presence stanza.  			 */ -			void sendPresence(Presence::ref); +			void sendPresence(boost::shared_ptr<Presence>);  			/**  			 * Sends raw, unchecked data. @@ -103,9 +97,7 @@ namespace Swift {  			 * Checks whether the client is connected to the server,  			 * and stanzas can be sent.  			 */ -			bool isAvailable() const { -				return stanzaChannel_->isAvailable(); -			} +			bool isAvailable() const;  			/**  			 * Checks whether the client is active. @@ -118,14 +110,7 @@ namespace Swift {  			 * Returns the JID of the client.   			 * After the session was initialized, this returns the bound JID.  			 */ -			const JID& getJID() const { -				if (session_) { -					return session_->getLocalJID(); -				} -				else { -					return jid_; -				} -			} +			const JID& getJID() const;  			/**  			 * Checks whether stream management is enabled. @@ -135,13 +120,9 @@ namespace Swift {  			 *  			 * \see onStanzaAcked  			 */ -			bool getStreamManagementEnabled() const { -				return stanzaChannel_->getStreamManagementEnabled(); -			} +			bool getStreamManagementEnabled() const; -			StanzaChannel* getStanzaChannel() const { -				return stanzaChannel_; -			} +			StanzaChannel* getStanzaChannel() const;  			/**  			 * Sets the certificate trust checker. @@ -153,16 +134,6 @@ namespace Swift {  			 */  			void setCertificateTrustChecker(CertificateTrustChecker*); -			/** -			 * Sets whether ZLib stream compression should be used when available. -			 */ -			void setUseStreamCompression(bool b); - -			/** -			 * Sets whether TLS encryption should be used. -			 */ -			void setUseTLS(UseTLS useTLS); -  		public:  			/**  			 * Emitted when the client was disconnected from the network. @@ -184,7 +155,7 @@ namespace Swift {  			 * This signal is emitted before the XML data is parsed,  			 * so this data is unformatted.  			 */ -			boost::signal<void (const std::string&)> onDataRead; +			boost::signal<void (const SafeByteArray&)> onDataRead;  			/**  			 * Emitted when the client sends data. @@ -192,17 +163,17 @@ namespace Swift {  			 * This signal is emitted after the XML was serialized, and   			 * is unformatted.  			 */ -			boost::signal<void (const std::string&)> onDataWritten; +			boost::signal<void (const SafeByteArray&)> onDataWritten;  			/**  			 * Emitted when a message is received.  			 */ -			boost::signal<void (Message::ref)> onMessageReceived; +			boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived;  			/**  			 * Emitted when a presence stanza is received.  			 */ -			boost::signal<void (Presence::ref) > onPresenceReceived; +			boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived;  			/**  			 * Emitted when the server acknowledges receipt of a @@ -210,28 +181,34 @@ namespace Swift {  			 *  			 * \see getStreamManagementEnabled()  			 */ -			boost::signal<void (Stanza::ref)> onStanzaAcked; +			boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaAcked; + +		protected: +			boost::shared_ptr<ClientSession> getSession() const { +				return session_; +			}  		private:  			void handleConnectorFinished(boost::shared_ptr<Connection>);  			void handleStanzaChannelAvailableChanged(bool available);  			void handleSessionFinished(boost::shared_ptr<Error>);  			void handleNeedCredentials(); -			void handleDataRead(const std::string&); -			void handleDataWritten(const std::string&); -			void handlePresenceReceived(Presence::ref); -			void handleMessageReceived(Message::ref); -			void handleStanzaAcked(Stanza::ref); +			void handleDataRead(const SafeByteArray&); +			void handleDataWritten(const SafeByteArray&); +			void handlePresenceReceived(boost::shared_ptr<Presence>); +			void handleMessageReceived(boost::shared_ptr<Message>); +			void handleStanzaAcked(boost::shared_ptr<Stanza>); +			void purgePassword();  		private:  			JID jid_; -			std::string password_; +			SafeByteArray password_;  			NetworkFactories* networkFactories; -			bool useStreamCompression; -			UseTLS useTLS;  			ClientSessionStanzaChannel* stanzaChannel_;  			IQRouter* iqRouter_; -			Connector::ref connector_; +			ClientOptions options; +			boost::shared_ptr<ChainedConnector> connector_; +			std::vector<ConnectionFactory*> proxyConnectionFactories;  			PlatformTLSFactories* tlsFactories;  			boost::shared_ptr<Connection> connection_;  			boost::shared_ptr<BasicSessionStream> sessionStream_; | 
 Swift
 Swift