00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef CLIENT_H__
00015 #define CLIENT_H__
00016
00017 #include "clientbase.h"
00018
00019 #include "iqhandler.h"
00020
00021 #include <string>
00022
00023 namespace gloox
00024 {
00025
00026 class RosterManager;
00027 class Disco;
00028 class NonSaslAuth;
00029 class Stanza;
00030
00081 class GLOOX_EXPORT Client : public ClientBase
00082 {
00083 public:
00084
00085 friend class NonSaslAuth;
00086 friend class Parser;
00087
00094 Client( const std::string& server );
00095
00106 Client( const JID& jid, const std::string& password, int port = -1 );
00107
00120 Client( const std::string& username, const std::string& password,
00121 const std::string& server, const std::string& resource,
00122 int port = -1 );
00123
00127 virtual ~Client();
00128
00133 void bindResource();
00134
00139 virtual const std::string username() const { return m_jid.username(); };
00140
00145 std::string const resource() const { return m_jid.resource(); };
00146
00151 int priority() const { return m_priority; };
00152
00157 void setUsername( const std::string &username ) { m_jid.setUsername( username ); };
00158
00163 void setResource( const std::string &resource ) { m_jid.setResource( resource ); };
00164
00169 void setInitialPriority( int priority );
00170
00177 void setAutoPresence( bool autoPresence ) { m_autoPresence = autoPresence; };
00178
00186 GLOOX_DEPRECATED void setForceNonSasl( bool force = true ) { m_forceNonSasl = force; };
00187
00194 void disableDisco();
00195
00201 void disableRoster();
00202
00207 RosterManager* rosterManager();
00208
00213 Disco* disco();
00214
00215 protected:
00216 void nonSaslLogin();
00217
00218 private:
00219 enum StreamFeaturesEnum
00220 {
00221 STREAM_FEATURE_BIND = 1,
00222 STREAM_FEATURE_SESSION = 2,
00223 STREAM_FEATURE_SASL_DIGESTMD5 = 4,
00224 STREAM_FEATURE_SASL_PLAIN = 8,
00225 STREAM_FEATURE_SASL_ANONYMOUS = 16,
00226 STREAM_FEATURE_STARTTLS = 32,
00227 STREAM_FEATURE_IQREGISTER = 64,
00229 STREAM_FEATURE_IQAUTH = 128,
00231 STREAM_FEATURE_ACK = 256,
00232 STREAM_FEATURE_COMPRESS_ZLIB = 512
00234 };
00235
00236 virtual void handleStartNode() {};
00237 virtual bool handleNormalNode( Stanza *stanza );
00238 int getStreamFeatures( Stanza *stanza );
00239 int getSaslMechs( Tag *tag );
00240 int getCompressionMethods( Tag *tag );
00241 void processResourceBind( Stanza *stanza );
00242 void processCreateSession( Stanza *stanza );
00243 void sendInitialPresence();
00244 void createSession();
00245 void negotiateCompression( StreamFeaturesEnum method );
00246 void connected();
00247
00248 void init();
00249
00250 RosterManager *m_rosterManager;
00251 NonSaslAuth *m_auth;
00252 Disco *m_disco;
00253
00254 bool m_resourceBound;
00255 bool m_autoPresence;
00256 bool m_forceNonSasl;
00257 bool m_manageRoster;
00258 bool m_handleDisco;
00259 bool m_doAuth;
00260
00261 int m_streamFeatures;
00262 int m_priority;
00263
00264 };
00265
00266 }
00267
00268 #endif // CLIENT_H__