15 #ifndef CLIENTBASE_H__
16 #define CLIENTBASE_H__
20 #include "eventdispatcher.h"
21 #include "iqhandler.h"
25 #include "taghandler.h"
26 #include "statisticshandler.h"
27 #include "connectiondatahandler.h"
29 #include "tlshandler.h"
35 #if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
37 #define SECURITY_WIN32
52 class MessageSessionHandler;
53 class ConnectionListener;
56 class PresenceHandler;
57 class SubscriptionHandler;
58 class MUCInvitationHandler;
62 class ConnectionCompression;
63 class StanzaExtensionFactory;
89 ClientBase(
const std::string& ns,
const std::string& server,
int port = -1 );
100 ClientBase(
const std::string& ns,
const std::string& password,
101 const std::string& server,
int port = -1 );
120 bool connect(
bool block =
true );
135 virtual const std::string&
username()
const {
return m_jid.username(); }
144 const JID&
jid() {
return m_authzid ? m_authzid : m_jid; }
181 void setServer(
const std::string &server );
187 void setPassword(
const std::string &password ) { m_password = password; }
193 const std::string&
server()
const {
return m_server; }
199 bool sasl()
const {
return m_sasl; }
218 int port()
const {
return m_port; }
224 virtual const std::string&
password()
const {
return m_password; }
237 const std::string getID();
246 void send(
Tag* tag );
257 void send(
IQ& iq,
IqHandler* ih,
int context,
bool del =
false );
263 void send(
const IQ& iq );
269 void send(
const Message& msg );
299 const std::string&
xmlLang()
const {
return m_xmllang; }
307 void setXmlLang(
const std::string& xmllang ) { m_xmllang = xmllang; }
329 void whitespacePing();
356 void setAuthcid(
const std::string& authcid ) { m_authcid = authcid; }
381 bool removeStanzaExtension(
int ext );
398 void registerIqHandler(
IqHandler* ih,
int exttype );
468 void registerTagHandler(
TagHandler* th,
const std::string& tag,
469 const std::string& xmlns );
492 void removeIqHandler(
IqHandler* ih,
int exttype );
520 void removeTagHandler(
TagHandler* th,
const std::string& tag,
521 const std::string& xmlns );
526 void removeStatisticsHandler();
546 void setClientCert(
const std::string& clientKey,
const std::string& clientCerts );
583 const std::string& streamErrorText(
const std::string& lang =
"default" )
const;
623 void removeMUCInvitationHandler();
639 bool removePresenceExtension(
int type );
648 virtual void handleTag(
Tag* tag );
651 virtual void handleReceivedData(
const ConnectionBase* connection,
const std::string& data );
666 virtual void handleHandshakeResult(
const TLSBase* base,
bool success,
CertInfo &certinfo );
674 void notifyOnResourceBindError(
const Error* error );
680 void notifyOnResourceBind(
const std::string& resource );
687 void notifyOnSessionCreateError(
const Error* error );
696 bool notifyOnTLSConnect(
const CertInfo& info );
701 void notifyOnConnect();
740 virtual bool checkStreamVersion(
const std::string& version );
751 void processSASLSuccess();
757 void processSASLChallenge(
const std::string& challenge );
763 void processSASLError(
Tag* tag );
781 bool hasCompression();
796 GLOOX_DEPRECATED std::string m_selectedResource;
805 std::string m_server;
808 bool m_compressionActive;
810 bool m_encryptionActive;
823 #ifdef CLIENTBASE_TEST
847 virtual const std::string& filterString()
const;
857 virtual Tag* tag()
const
876 virtual void handleStartNode() = 0;
883 virtual bool handleNormalNode(
Tag* tag ) = 0;
884 virtual void rosterFilled() = 0;
885 virtual void cleanup() {}
886 virtual void handleIqIDForward(
const IQ& iq,
int context ) { (void) iq; (void) context; }
888 void parse(
const std::string& data );
890 void handleStreamError( Tag* tag );
892 void notifyIqHandlers( IQ& iq );
893 void notifyMessageHandlers( Message& msg );
894 void notifyPresenceHandlers( Presence& presence );
895 void notifySubscriptionHandlers( Subscription& s10n );
896 void notifyTagHandlers( Tag* tag );
898 void send(
const std::string& xml );
899 void addFrom( Tag* tag );
900 void addNamespace( Tag* tag );
903 virtual bool handleIq(
const IQ& iq );
906 virtual void handleIqID(
const IQ& iq,
int context );
915 struct TagHandlerStruct
922 struct JidPresHandlerStruct
933 typedef std::list<ConnectionListener*> ConnectionListenerList;
934 typedef std::multimap<const std::string, IqHandler*> IqHandlerMapXmlns;
935 typedef std::multimap<const int, IqHandler*> IqHandlerMap;
936 typedef std::map<const std::string, TrackStruct> IqTrackMap;
937 typedef std::map<const std::string, MessageHandler*> MessageHandlerMap;
938 typedef std::list<MessageSession*> MessageSessionList;
939 typedef std::list<MessageHandler*> MessageHandlerList;
940 typedef std::list<PresenceHandler*> PresenceHandlerList;
941 typedef std::list<JidPresHandlerStruct> PresenceJidHandlerList;
942 typedef std::list<SubscriptionHandler*> SubscriptionHandlerList;
943 typedef std::list<TagHandlerStruct> TagHandlerList;
945 ConnectionListenerList m_connectionListeners;
946 IqHandlerMapXmlns m_iqNSHandlers;
947 IqHandlerMap m_iqExtHandlers;
948 IqTrackMap m_iqIDHandlers;
949 MessageSessionList m_messageSessions;
950 MessageHandlerList m_messageHandlers;
951 PresenceHandlerList m_presenceHandlers;
952 PresenceJidHandlerList m_presenceJidHandlers;
953 SubscriptionHandlerList m_subscriptionHandlers;
954 TagHandlerList m_tagHandlers;
955 StatisticsHandler * m_statisticsHandler;
956 MUCInvitationHandler * m_mucInvitationHandler;
957 MessageSessionHandler * m_messageSessionHandlerChat;
958 MessageSessionHandler * m_messageSessionHandlerGroupchat;
959 MessageSessionHandler * m_messageSessionHandlerHeadline;
960 MessageSessionHandler * m_messageSessionHandlerNormal;
962 util::Mutex m_iqHandlerMapMutex;
963 util::Mutex m_iqExtHandlerMapMutex;
968 StanzaExtensionFactory* m_seFactory;
969 EventDispatcher m_dispatcher;
974 std::string m_streamErrorCData;
975 Tag* m_streamErrorAppCondition;
977 ConnectionBase* m_transportConnection;
979 StatisticsStruct m_stats;
983 std::string m_ntlmDomain;
984 bool m_autoMessageSession;
986 #if defined( _WIN32 ) && !defined( __SYMBIAN32__ )
987 CredHandle m_credHandle;
988 CtxtHandle m_ctxtHandle;
995 #endif // CLIENTBASE_H__