| 1 | /* |
|---|
| 2 | * QuteCom, a voice over Internet phone |
|---|
| 3 | * Copyright (C) 2010 Mbdsys |
|---|
| 4 | * |
|---|
| 5 | * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #ifndef OWTCOIPMANAGER_H |
|---|
| 21 | #define OWTCOIPMANAGER_H |
|---|
| 22 | |
|---|
| 23 | #include <coipmanager_threaded/tcoipmanagerdll.h> |
|---|
| 24 | |
|---|
| 25 | #include <coipmanager/CoIpManagerConfig.h> |
|---|
| 26 | |
|---|
| 27 | #include <util/NonCopyable.h> |
|---|
| 28 | |
|---|
| 29 | #include <QtCore/QThread> |
|---|
| 30 | |
|---|
| 31 | class CoIpManager; |
|---|
| 32 | class TCallSessionManager; |
|---|
| 33 | class TChatSessionManager; |
|---|
| 34 | class TConnectManager; |
|---|
| 35 | class TFileSessionManager; |
|---|
| 36 | class TSMSSessionManager; |
|---|
| 37 | class TUserProfileManager; |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * @defgroup TCoIpManager Threaded CoIpManager |
|---|
| 41 | * |
|---|
| 42 | * Threaded CoIpManager launches an instance of CoIpManager in a Thread, and |
|---|
| 43 | * then provide a non-blocking API to access CoIpManager. It will typically |
|---|
| 44 | * be used by GUI layer. |
|---|
| 45 | * It acts pretty like a Control layer from the PAC Pattern, or a Controller |
|---|
| 46 | * layer from the MVC pattern. |
|---|
| 47 | * It also manages Session memory: CoIpManager does not keep a link to created |
|---|
| 48 | * Session and the user of the library is responsible for deleting such objects. |
|---|
| 49 | * TCoIpManager manages this memory: if a new UserProfile is set, an event |
|---|
| 50 | * will be emitted to say that a Session will be deleted. Then the receiver of |
|---|
| 51 | * the event must tell TCoIpManager that it has released it. When finished, |
|---|
| 52 | * the UserProfile will be set. |
|---|
| 53 | */ |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Entry point for Threaded CoIpManager. |
|---|
| 57 | * |
|---|
| 58 | * @see CoIpManager |
|---|
| 59 | * @ingroup TCoIpManager |
|---|
| 60 | * @author Philippe Bernery |
|---|
| 61 | * @author Tanguy Krotoff |
|---|
| 62 | */ |
|---|
| 63 | class COIPMANAGER_THREADED_API TCoIpManager : public QThread, NonCopyable { |
|---|
| 64 | Q_OBJECT |
|---|
| 65 | |
|---|
| 66 | friend class TAccountManager; |
|---|
| 67 | friend class TCallSession; |
|---|
| 68 | friend class TCallSessionManager; |
|---|
| 69 | friend class TChatSession; |
|---|
| 70 | friend class TChatSessionManager; |
|---|
| 71 | friend class TConnectManager; |
|---|
| 72 | friend class TContactManager; |
|---|
| 73 | friend class TFileSessionManager; |
|---|
| 74 | friend class TSendFileSession; |
|---|
| 75 | friend class TSMSSessionManager; |
|---|
| 76 | friend class TUserProfileFileStorage; |
|---|
| 77 | friend class TUserProfileManager; |
|---|
| 78 | public: |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | * Default constructor. |
|---|
| 82 | * |
|---|
| 83 | * @param coIpManagerConfig config of CoIpManager, copied internally |
|---|
| 84 | */ |
|---|
| 85 | TCoIpManager(const CoIpManagerConfig & coIpManagerConfig); |
|---|
| 86 | |
|---|
| 87 | virtual ~TCoIpManager(); |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | * Releases all TCoIpManager resources. |
|---|
| 91 | * To use TCoIpManager again, call TCoIpManager::start. |
|---|
| 92 | * This method blocks until all resources are freed. |
|---|
| 93 | */ |
|---|
| 94 | void release(); |
|---|
| 95 | |
|---|
| 96 | /** |
|---|
| 97 | * @see CoIpManager::getCoIpManagerConfig() |
|---|
| 98 | */ |
|---|
| 99 | CoIpManagerConfig & getCoIpManagerConfig(); |
|---|
| 100 | |
|---|
| 101 | /** |
|---|
| 102 | * @see CoIpManager::getCallSessionManager() |
|---|
| 103 | */ |
|---|
| 104 | TCallSessionManager & getTCallSessionManager(); |
|---|
| 105 | |
|---|
| 106 | /** |
|---|
| 107 | * @see CoIpManager::getChatSessionManager() |
|---|
| 108 | */ |
|---|
| 109 | TChatSessionManager & getTChatSessionManager(); |
|---|
| 110 | |
|---|
| 111 | /** |
|---|
| 112 | * @see CoIpManager::getConnectManager() |
|---|
| 113 | */ |
|---|
| 114 | TConnectManager & getTConnectManager(); |
|---|
| 115 | |
|---|
| 116 | /** |
|---|
| 117 | * @see CoIpManager::getFileSessionManager() |
|---|
| 118 | */ |
|---|
| 119 | TFileSessionManager & getTFileSessionManager(); |
|---|
| 120 | |
|---|
| 121 | /** |
|---|
| 122 | * @see CoIpManager::getSMSSessionManager() |
|---|
| 123 | */ |
|---|
| 124 | TSMSSessionManager & getTSMSSessionManager(); |
|---|
| 125 | |
|---|
| 126 | /** |
|---|
| 127 | * @see CoIpManager::getUserProfileManager() |
|---|
| 128 | */ |
|---|
| 129 | TUserProfileManager & getTUserProfileManager(); |
|---|
| 130 | |
|---|
| 131 | /** |
|---|
| 132 | * @see CoIpManager::getUserProfileSyncManager() |
|---|
| 133 | */ |
|---|
| 134 | //TUserProfileSyncManager & getTUserProfileSyncManager(); |
|---|
| 135 | |
|---|
| 136 | Q_SIGNALS: |
|---|
| 137 | |
|---|
| 138 | /** |
|---|
| 139 | * Emitted when TCoIpManager is initialized (all pointers are initalized, thus |
|---|
| 140 | * one can register to all signals). |
|---|
| 141 | */ |
|---|
| 142 | void initialized(); |
|---|
| 143 | |
|---|
| 144 | private: |
|---|
| 145 | |
|---|
| 146 | /** From QThread. */ |
|---|
| 147 | virtual void run(); |
|---|
| 148 | |
|---|
| 149 | CoIpManager & getCoIpManager() const; |
|---|
| 150 | |
|---|
| 151 | /** Configuration passed to CoIpManager. */ |
|---|
| 152 | CoIpManagerConfig _coIpManagerConfig; |
|---|
| 153 | |
|---|
| 154 | CoIpManager * _coIpManager; |
|---|
| 155 | |
|---|
| 156 | TCallSessionManager * _tCallSessionManager; |
|---|
| 157 | |
|---|
| 158 | TChatSessionManager * _tChatSessionManager; |
|---|
| 159 | |
|---|
| 160 | TFileSessionManager * _tFileSessionManager; |
|---|
| 161 | |
|---|
| 162 | TSMSSessionManager * _tSMSSessionManager; |
|---|
| 163 | |
|---|
| 164 | TUserProfileManager * _tUserProfileManager; |
|---|
| 165 | |
|---|
| 166 | TConnectManager * _tConnectManager; |
|---|
| 167 | }; |
|---|
| 168 | |
|---|
| 169 | #endif //OWTCOIPMANAGER_H |
|---|