00001 /*************************************************************************** 00002 connectionmanager.h - description 00003 ------------------- 00004 begin : lun avr 3 2006 00005 copyright : (C) 2006 by 00006 - Sylvain Archenault <sylvain.archenault@laposte.net> 00007 - Yves Houpert <yves.houpert@insa-rouen.fr> 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 00019 #ifndef CONNECTIONMANAGER_H 00020 #define CONNECTIONMANAGER_H 00021 00022 #include <Kernel/basemanager.h> 00023 #include <qobject.h> 00024 00025 class ConnectionProcess; 00026 class QTimer; 00027 class Contact; 00028 class ContactList; 00029 class ListeWidget; 00030 class KernelMessenger; 00031 class SocketManager; 00032 class BaseMessage; 00033 00041 class ConnectionManager : public QObject, public BaseManager 00042 { 00043 Q_OBJECT 00044 friend class ConnectionProcess; 00045 00046 public: // public methods 00050 ConnectionManager(KernelMessenger& rKernel, ListeWidget& rWidget); 00051 00053 virtual ~ConnectionManager(); 00054 00061 void setConnection(const Contact& contact, const ContactList& list); 00062 00069 void connectionEstablished(const bool bResult, const Contact& contact); 00070 00076 void newConnection(const std::string& username, const std::string& password); 00077 00083 void contactListReceived(const bool bResult, const ContactList& list); 00084 00086 void closeConnection(); 00087 00091 void connectionFailed(); 00092 00094 void stopConnectionProcess(); 00095 00098 void setSocketStatus(const bool bStatus); 00099 00102 void writeMessage(const BaseMessage& message); 00103 00108 void connectToHost(const std::string& hostname, const int port); 00109 00111 void close(); 00112 00116 void setConnectionOptions(const std::string& hostname, const int port); 00117 00118 private : //private methods 00122 void cleanConnectionProcess(); 00123 00124 private slots: //private slots 00126 void connectionTimeout(); 00127 00128 public : // public members 00130 static const char* DEFAULT_HOST; 00132 static const int DEFAULT_PORT; 00134 static const int TIMEOUT; 00135 00136 private: // private members 00138 ConnectionProcess* m_pConnectionProcess; 00139 00145 QTimer* m_pTimer; 00146 00150 QTimer* m_pTimeout; 00151 00155 std::auto_ptr<SocketManager> m_pSocketManager; 00156 00158 std::string m_sHostname; 00159 00161 int m_iPort; 00162 00163 }; 00164 00165 #endif
1.4.6