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 #include "stanza.h"
00020
00021 #include <string>
00022
00023 namespace gloox
00024 {
00025
00026 class RosterManager;
00027 class NonSaslAuth;
00028
00097 class GLOOX_API Client : public ClientBase
00098 {
00099 public:
00100
00101 friend class NonSaslAuth;
00102 friend class Parser;
00103
00110 Client( const std::string& server );
00111
00122 Client( const JID& jid, const std::string& password, int port = -1 );
00123
00136 Client( const std::string& username, const std::string& password,
00137 const std::string& server, const std::string& resource, int port = -1 );
00138
00142 virtual ~Client();
00143
00149 void bindResource();
00150
00155 const std::string& resource() const { return m_jid.resource(); }
00156
00161 int priority() const { return m_priority; }
00162
00167 void setUsername( const std::string &username );
00168
00173 void setResource( const std::string &resource ) { m_jid.setResource( resource ); }
00174
00186 void setPresence( Presence presence, int priority = 0, const std::string& msg = "" );
00187
00192 Presence presence() const { return m_presence; }
00193
00198 const std::string& status() const { return m_status; }
00199
00211 void addPresenceExtension( StanzaExtension *se );
00212
00216 void removePresenceExtensions();
00217
00223 GLOOX_DEPRECATED void setForceNonSasl( bool force = true ) { m_forceNonSasl = force; }
00224
00230 void disableRoster();
00231
00236 RosterManager* rosterManager() { return m_rosterManager; }
00237
00241 void disconnect();
00242
00243 protected:
00247 void nonSaslLogin();
00248
00249 private:
00250 virtual void handleStartNode() {}
00251 virtual bool handleNormalNode( Stanza *stanza );
00252 virtual void disconnect( ConnectionError reason );
00253 int getStreamFeatures( Stanza *stanza );
00254 int getSaslMechs( Tag *tag );
00255 int getCompressionMethods( Tag *tag );
00256 void processResourceBind( Stanza *stanza );
00257 void processCreateSession( Stanza *stanza );
00258 void sendPresence();
00259 void createSession();
00260 void negotiateCompression( StreamFeature method );
00261 void connected();
00262 virtual void rosterFilled();
00263 virtual void cleanup();
00264
00265 void init();
00266
00267 RosterManager *m_rosterManager;
00268 NonSaslAuth *m_auth;
00269
00270 StanzaExtensionList m_presenceExtensions;
00271
00272 Presence m_presence;
00273 std::string m_status;
00274
00275 bool m_resourceBound;
00276 bool m_forceNonSasl;
00277 bool m_manageRoster;
00278 bool m_doAuth;
00279
00280 int m_streamFeatures;
00281 int m_priority;
00282
00283 };
00284
00285 }
00286
00287 #endif // CLIENT_H__