1 /** \file TocMainWindow.h
2 * \brief Declaration of TocMainWindow class
4 * Tieto Open Communicator - Client for the Telepathy communications framework.
5 * Copyright (c) 2010, Tieto Corporation
8 * Redistribution and use in source and binary forms, with or without modification,
9 * are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * Neither the name of the Tieto Corporation nor the names of its contributors
17 * may be used to endorse or promote products derived from this software without
18 * specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #ifndef TOCMAINWINDOW_H
33 #define TOCMAINWINDOW_H
35 #include <QMainWindow>
36 #include <QListWidgetItem>
37 #include "TocBaseMainWindow"
44 class TocContactListWidget;
45 class TocUserInfoWidget;
46 class TocSettingsWidget;
47 class TocGeneralSettingsWidget;
48 class TocAccountSettingsWidget;
49 class TocAccountIntermediateWidget;
50 class TocNetworkSettingsWidget;
51 class TocThemesSettingsWidget;
56 /** \brief TocMainWindow class
58 * Class responsible for user GUI management
59 * and for communication with TocEngine.
61 class TocMainWindow : public TocBaseMainWindow
64 Q_CLASSINFO("D-Bus Interface", "org.indt.tietoopcom")
71 TocMainWindow( TocBaseEngine* engine, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
80 /** \brief Reimplemented from QWidget
83 virtual void closeEvent(QCloseEvent* event);
86 Q_SCRIPTABLE int top_application();
90 /** \brief Reimplemented from TocBaseMainWindow
93 void onAuthorizationRequest(QString uid);
95 /** \brief Reimplemented from TocBaseMainWindow
98 void onSubscriptionAccepted(QString uid);
100 /** \brief Reimplemented from TocBaseMainWindow
103 void onStatusChange(Status status, Reason reason);
105 /** \brief Reimplemented from TocBaseMainWindow
108 void onPresenceUpdate(Presence presence, QString desc);
110 /** \brief Reimplemented from TocBaseMainWindow
113 void onContactPresenceUpdate(QString uid, Presence presence, QString desc);
115 /** \brief Reimplemented from TocBaseMainWindow
118 void onIncomingMessage(QString uid, Message message);
120 /** \brief Reimplemented from TocBaseMainWindow
123 void onContactListReceived(const TocContactList& cList);
127 /** \brief Shows chat window for the given Uid
129 * If the chat with Uid is already created, just show it,
130 * if not, create a chat with the given Uid and Name
131 * and emit newSessionStarted(Uid) signal.
132 * Note that this is overloaded SLOT, take caution with that.
134 * @param uid Contact's ID
135 * @param name Contact's name
136 * @param presence Contact's current presence
138 void showChat(const QString& uid, const QString& name, Presence presence = Offline);
141 /** \brief Closes a chat for the given Uid
143 * This slot closes a chat for the given Uid
144 * and emits sessionClosed(Uid) signal to the engine.
146 * @param uid Contact's ID
148 void closeChat(const QString& uid);
150 /** \brief Closes all active chat windows
152 * This slot closes all open chat windows
153 * and emits sessionClosed(Uid) signal for each chat.
155 void closeAllOpenChats();
157 /** \brief Closes all active chat windows
159 * This slot closes and deletes all created chat windows
160 * and emits sessionClosed(Uid) signal for each chat.
161 * This is typicaly useful when user changes account data.
163 void clearAllChats();
165 /** \brief Shows window of a given type
167 * Shows a TocWidget of the type == ViewType (except for TocChatWidget)
168 * `ViewType` is static-casted to `int` in a signal emission in the TocSettingsWidget
169 * si it could use a QSignalMapper class.
171 * @param type Type of the view to be shown
173 void showView(/*ViewType*/int type);
175 /** \brief Shows TocUserInfoWidget
177 * Creates and displays TocUserInfoWidget with the data provided by the signal.
179 * @param item Item with contact's data (*item==QListWidgetItem() if You want TocUserInfoWidget to be run in "Add mode")
181 void showUserInfo(QListWidgetItem* item);
183 /** \brief Shows TocContactListWidget
185 * Displays TocContactListWidget.
189 /** \brief Shows TocContactListWidget
191 * Displays TocContactListWidget.
192 * Also informs TocMainToolbar about the change.
194 void returnToContacts();
196 /** \brief Shows TocSettingsWidget
198 * Creates if necessary and displays TocSettingsWidget.
202 /** \brief Shows TocSettingsWidget
204 * Displays TocSettingsWidget .
205 * Also informs TocMainToolbar about the change.
207 void returnToSettings();
209 /** \brief Shows TocAccountSettingsWidget
211 * Creates if necessary and displays TocAccountSettingsWidget.
215 /** \brief Shows TocAccountIntermediateWidget
217 * Creates if necessary and displays TocAccountIntermediateWidget .
219 void returnToIntermediate();
221 /** \brief Shows TocAccountSettingsWidget in `Create mode`
223 * Creates if necessary and displays TocAccountSettingsWidget.
224 * When user clicks `Create` button the account settings are
225 * saved in TocSettings and the `_register` flag of TocSettings is set to "true".
227 void showAccountCreate();
229 /** \brief Changes the displayed name in the application on user request
231 * If a user changes the displayed name using TocUserInfoView in editing mode
232 * the slot changes the name in the TocContactListWidget and, if needed,
233 * in TocMainToolbar and TocChatWidget.
235 * @param uid Contact's ID
236 * @param name Contact's new name
238 void onDisplayedNameChange(const QString& uid, const QString& name);
240 /** \brief Reloads the displayed application theme
242 * Reads file URL from settings and sets the stylesheet as the current one.
246 /** \brief This slot prepares Toc for the account details change
248 * It disconnects, clears the contact list and active sessions list.
250 void onAccountSettingsChanged();
252 /** \brief This slot prepares Toc for the new account creation
254 * It disconnects, clears the contact list and active sessions list.
255 * Then it connects with the `_register` parameter set to true,
256 * when the connection is successfull the account has been created.
258 void onAccountSettingsCreated();
260 /** \brief Shows About info widget
267 /** \brief Returns cached TocChatWidget for the given Uid
269 * If there is a chached chat with the given uid then
270 * it returns pointer to this chat, if not it returns 0.
272 * @param uid Contact's ID
273 * @return Pointer to the chached TocChatWidget or 0 if there is no active chat.
275 TocChatWidget* chatForUid(const QString& uid);
277 /** \brief Returns active/open TocChatWidget for the given Uid
279 * If there is a active/open chat with the given uid then
280 * it returns pointer to this chat, if not it returns 0.
282 * @param uid Contact's ID
283 * @return Pointer to the active/open TocChatWidget or 0 if there is no active chat.
285 TocChatWidget* openChatForUid(const QString& uid);
287 /** \brief Checks if this is FTU
289 * returns true if settings on which FirstTimeUse case is based, are empty
291 * @return bool value indicating FTU use case
295 /** \brief Returns an error string for the given error
297 * @param reason Reason of the error
298 * @return Human readable error string
300 QString errorString(Reason reason);
303 QString _defaultStyle; /// Default application style sheet
305 QList<TocChatWidget*>* _pChatList; /// List of cached chat widgets
306 QList<TocChatWidget*>* _pOpenChatList; /// List of active/open chat widgets
307 TocMainToolbar* _pMainToolbar; /// Pointer to a toolbar that allows user to control the UI
308 QStackedLayout* _pMainLayout; /// Layout displaying all the "following" widgets
309 QWidget* _pCentralWidget; /// Main Window's Central Widget
310 TocContactListWidget* _pContactList; /// Widget displaying list of contacts
311 TocUserInfoWidget* _pUserInfoWidget; /// Widget displaying contact info
312 TocSettingsWidget* _pSettingsWidget; /// Widget displaying settings window
313 TocGeneralSettingsWidget* _pGeneralWidget; /// Widget displaying general settings
314 TocAccountSettingsWidget* _pAccountWidget; /// Widget displaying account settings
315 TocAccountIntermediateWidget* _pIntermediateWidget; /// Widget that lets user to choose account settings mode
316 TocThemesSettingsWidget* _pThemesWidget; /// Widget displaying themes setting
317 bool _register; /// Flag indicating if TietoOpCom is in "Create Account Mode"
322 #endif // TOCMAINWINDOW_H