client.h

00001 /*
00002   Copyright (c) 2004-2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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 
00250       bool login();
00251 
00252     protected:
00256       void nonSaslLogin();
00257 
00258     private:
00259       virtual void handleStartNode() {}
00260       virtual bool handleNormalNode( Stanza *stanza );
00261       virtual void disconnect( ConnectionError reason );
00262       int getStreamFeatures( Stanza *stanza );
00263       int getSaslMechs( Tag *tag );
00264       int getCompressionMethods( Tag *tag );
00265       void processResourceBind( Stanza *stanza );
00266       void processCreateSession( Stanza *stanza );
00267       void sendPresence();
00268       void createSession();
00269       void negotiateCompression( StreamFeature method );
00270       void connected();
00271       virtual void rosterFilled();
00272       virtual void cleanup();
00273 
00274       void init();
00275 
00276       RosterManager *m_rosterManager;
00277       NonSaslAuth *m_auth;
00278 
00279       StanzaExtensionList m_presenceExtensions;
00280 
00281       Presence m_presence;
00282       std::string m_status;
00283 
00284       bool m_resourceBound;
00285       bool m_forceNonSasl;
00286       bool m_manageRoster;
00287       bool m_doAuth;
00288 
00289       int m_streamFeatures;
00290       int m_priority;
00291 
00292   };
00293 
00294 }
00295 
00296 #endif // CLIENT_H__

Generated on Sun Apr 27 11:08:13 2008 for gloox by  doxygen 1.5.5