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 #include "iqhandler.h"
00019
00020 #include <string>
00021
00022 namespace gloox
00023 {
00024
00025 class RosterManager;
00026 class Disco;
00027 class NonSaslAuth;
00028 class Stanza;
00029
00101 class GLOOX_API Client : public ClientBase
00102 {
00103 public:
00104
00105 friend class NonSaslAuth;
00106 friend class Parser;
00107
00114 Client( const std::string& server );
00115
00126 Client( const JID& jid, const std::string& password, int port = -1 );
00127
00140 Client( const std::string& username, const std::string& password,
00141 const std::string& server, const std::string& resource, int port = -1 );
00142
00146 virtual ~Client();
00147
00153 void bindResource();
00154
00159 virtual const std::string username() const { return m_jid.username(); };
00160
00165 std::string const resource() const { return m_jid.resource(); };
00166
00171 int priority() const { return m_priority; };
00172
00177 void setUsername( const std::string &username );
00178
00183 void setResource( const std::string &resource ) { m_jid.setResource( resource ); };
00184
00189 void setInitialPriority( int priority );
00190
00197 void setAutoPresence( bool autoPresence ) { m_autoPresence = autoPresence; };
00198
00204 GLOOX_DEPRECATED void setForceNonSasl( bool force = true ) { m_forceNonSasl = force; };
00205
00212 void disableDisco();
00213
00219 void disableRoster();
00220
00225 RosterManager* rosterManager();
00226
00231 Disco* disco();
00232
00236 void disconnect();
00237
00238 protected:
00242 void nonSaslLogin();
00243
00244 private:
00245 virtual void handleStartNode() {};
00246 virtual bool handleNormalNode( Stanza *stanza );
00247 virtual void disconnect( ConnectionError reason );
00248 int getStreamFeatures( Stanza *stanza );
00249 int getSaslMechs( Tag *tag );
00250 int getCompressionMethods( Tag *tag );
00251 void processResourceBind( Stanza *stanza );
00252 void processCreateSession( Stanza *stanza );
00253 void sendInitialPresence();
00254 void createSession();
00255 void negotiateCompression( StreamFeature method );
00256 void connected();
00257 virtual void rosterFilled();
00258 virtual void cleanup();
00259
00260 void init();
00261
00262 RosterManager *m_rosterManager;
00263 NonSaslAuth *m_auth;
00264 Disco *m_disco;
00265
00266 bool m_resourceBound;
00267 bool m_autoPresence;
00268 bool m_forceNonSasl;
00269 bool m_manageRoster;
00270 bool m_handleDisco;
00271 bool m_doAuth;
00272
00273 int m_streamFeatures;
00274 int m_priority;
00275
00276 };
00277
00278 }
00279
00280 #endif // CLIENT_H__