Initial commit
[tietoopcom] / include / TocUi / tocbasemainwindow.h
1 /** \file TocBaseMainWindow.h
2  * \brief Declaration of TocBaseMainWindow class
3  * 
4  * Tieto Open Communicator - Client for the Telepathy communications framework.
5  * Copyright (c) 2010, Tieto Corporation
6  *
7  * All rights reserved.
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
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.
19  *
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.
29  * 
30  */
31
32 #ifndef TOCBASEMAINWINDOW_H
33 #define TOCBASEMAINWINDOW_H
34
35 #include <QtGui/QMainWindow>
36 #include "defs.h"
37
38 class TocBaseEngine;
39
40 /** \brief TocBaseMainWindow class
41  * 
42  * A base class for any Ui class that 
43  * wants to comunicate with TocEngine.  
44  *
45  */
46 class TocBaseMainWindow : public QMainWindow
47 {
48     Q_OBJECT
49
50 public:
51     TocBaseMainWindow( TocBaseEngine* engine, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
52     ~TocBaseMainWindow();
53
54 signals:
55
56         /** \brief Emited when a user wants to change presence
57          * 
58          * This signal is emited when user changes presence in TocMainToolbar.
59          * Note: this is only a request, You should wait for the PresenceUpdated signal from TocEngine
60          * to actualy show to the user his new presence.
61          * 
62          * @param presence Requested presence
63          * @param desc Requested description
64          */
65         void presenceChanged(Presence presence, QString desc);
66
67         /** \brief Emited when a session is finished
68          * 
69          * This signal is emited when a TocChatWidget is closed.
70          * 
71          * @param uid Contact's ID
72          */
73         void sessionClosed(QString uid);
74
75         /** \brief Emited when a new message is ready to send
76          * 
77          * This signal is emited when user sends a message in one of chatwindows.
78          * 
79          * @param uid Contact's ID
80          * @param message Message to be sent
81          */
82         void newMessageReady(QString uid, Message message);
83
84         /** \brief Emited when user adds a new contact
85          * 
86          * This should be emited when user prepares new contact data
87          * using TocUserInfoWidget in "Add mode".
88          * 
89          * @param pContact      Pointer to a contact to be added.
90          */
91         void addContact(TocContact* pContact);
92
93         /** \brief Emited when user edits an existing contact
94          * 
95          * This signal is emited when user changes contact data
96          * using TocUserInfoWidget in "Edit mode".
97          * 
98          * @param pContact      Pointer to a contact to be altered.
99          * @param oldUid Previous Contact's ID
100          */
101         void editContact(TocContact* pContact, QString oldUid);
102
103         /** \brief Emited when user deletes an existing contact
104          * 
105          * This should be emited when user removes a contact from contact list.
106          * 
107          * @param uid Contact's ID
108          */
109         void removeContact(QString uid);
110
111         /** \brief Emited when user creates a new account
112          * 
113          * This signal is emited when user decides to accept or deny request for subscription from someone. 
114          * 
115          * @param uid User ID of the new account
116          * @param authorized Flag that indicates the answer 
117          */     
118         void subscriptionAccepted(QString uid, bool authorized);
119
120         /** \brief Emited when user changes the account settings
121          * 
122          */
123         void accountSettingsChanged();
124         
125 protected slots:
126
127         /** \brief Slot invoked when someone wants to add us to his contact list
128          *
129          * We just received request for subsciption and need to decide whether accept it 
130          * or discard. This should be connected to the TocEngine's `AuthorizationRequest` signal.
131          * 
132          * @param uid An identificator of a peer that wants to subscribe our account to his contact list
133          */
134         virtual void onAuthorizationRequest(QString uid) = 0;
135         
136         /** \brief Slot invoked when our request for subscription has been accepted
137          * 
138          * This should be connected to the TocEngine's `SubscriptionAccepted` signal.
139          * 
140          * @param uid An identificator of a contact that was requested for subscription  
141          */     
142         virtual void onSubscriptionAccepted(QString uid) = 0;
143         
144         /** \brief Slot handling own status change
145          * 
146          * Thanks this UI can be informed about change in account status.
147          * This should be connected to the TocEngine's `StatusChanged` signal.
148          * 
149          * @param status New status of the account
150          * @param reason The reason of the change
151          */
152         virtual void onStatusChange(Status status, Reason reason) = 0;
153
154         /** \brief Slot handling own presence change
155          * 
156          * This should be connected to the TocEngine's `PresenceUpdated` signal.
157          * 
158          * @param presence New presence of the account
159          * @param desc New presence description of the account
160          */
161         virtual void onPresenceUpdate(Presence presence, QString desc) = 0;
162
163         /** \brief Slot handling contact's presence change
164          * 
165          * This should be connected to the TocEngine's `ContactPresenceUpdated` signal.
166          * 
167          * @param uid Contact's ID
168          * @param presence New presence of the contact
169          * @param desc New presence description of the contact
170          */
171         virtual void onContactPresenceUpdate(QString uid, Presence presence, QString desc) = 0;
172
173         /** \brief Slot handling incoming message
174          * 
175          * This should be connected to the TocEngine's `MessageReceived` signal.
176          * 
177          * @param uid Contact's ID
178          * @param message New message to be handled
179          */
180         virtual void onIncomingMessage(QString uid, Message message) = 0;
181         
182         /** \brief Invoked when new contact list is available
183          * 
184          * This should be connected to the TocEngine's `NewContactList` signal.
185          * 
186          * @param cList New contact list to be used
187          */ 
188         virtual void onContactListReceived(const TocContactList& cList) = 0;
189
190 };
191
192 #endif // TOCBASEMAINWINDOW_H