00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KERNELMESSENGER_H
00021 #define KERNELMESSENGER_H
00022
00023 #include <contact.h>
00024 #include <string>
00025 #include <memory>
00026 #include <xercesc/sax/SAXParseException.hpp>
00027
00028 class ListeWidget;
00029 class DiscussionManager;
00030 class ConnectionManager;
00031 class ContactManager;
00032 class ContactList;
00033 class BaseMessage;
00034
00035 XERCES_CPP_NAMESPACE_USE;
00036
00037
00044 class KernelMessenger
00045 {
00046
00047 friend class ConnectionManager;
00048 friend class Socket;
00049
00050 public:
00051
00053 enum MessageBoxTypes{
00054 InformationBox,
00055 SorryBox,
00056 ErrorBox,
00057 QuestionBox
00058 };
00059
00062 static KernelMessenger& getInstance() { return *(m_sTheKernelMessenger); }
00063
00067 static std::auto_ptr<KernelMessenger> createKernelMessenger(ListeWidget* pWidget);
00068
00070 void closeConnection();
00071
00074 void addContact(const Contact& contact);
00075
00078 void removeContact(const Contact& contact);
00079
00082 void removeContact(const int ID);
00083
00088 void setUser(const Contact& contact);
00089
00092 const Contact& getUser() const { return m_User; }
00093
00096 void setContactList(const ContactList& list);
00097
00100 void writeMessage(const BaseMessage& message);
00101
00106 void newMessage(const int fromID, const std::string message);
00107
00115 void connectionEstablished(const bool bResult, const Contact& contact);
00116
00123 void contactListReceived(const bool bResult, const ContactList& list);
00124
00128 void newConnection(const std::string& username, const std::string& password);
00129
00133 void setConnectionOptions(const std::string& hostname, const int port);
00134
00137 void stopDiscussion(const int contactID);
00138
00141 void newDiscussion(const Contact& contact);
00142
00146 void changeContactStatus(const int contactID, const Contact::Status newStatus);
00147
00150 void changeUserStatus(Contact::Status newStatus);
00151
00154 const Contact* const getContact(int contactID) const;
00155
00157 virtual ~KernelMessenger();
00158
00161 void errorReceived(const std::string& sDescription);
00162
00169 int popup(const MessageBoxTypes type, const std::string& message, const std::string& title) const;
00170
00174 void parsingError(const SAXParseException* e);
00175
00176 private:
00179 KernelMessenger(ListeWidget* pWidget);
00180
00185 KernelMessenger(const KernelMessenger& rKernel);
00186
00191 KernelMessenger& operator=(const KernelMessenger& rKernel);
00192
00193 private:
00195 static KernelMessenger* m_sTheKernelMessenger;
00196
00198 Contact m_User;
00199
00201 ListeWidget* m_pWidget;
00202
00204 std::auto_ptr<DiscussionManager> m_pDiscussionManager;
00205
00207 std::auto_ptr<ConnectionManager> m_pConnectionManager;
00208
00210 std::auto_ptr<ContactManager> m_pContactManager;
00211 };
00212
00213 #endif