|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: An implementation for receiving command/event notifications and info. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef MEDIATORNOTIFICATIONSBODY_H |
|
19 #define MEDIATORNOTIFICATIONSBODY_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "MediatorServerClient.h" |
|
25 #include "MediatorNotifications.h" |
|
26 #include "MediatorCommon.h" |
|
27 |
|
28 // NAMESPACE |
|
29 using namespace MediatorService; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * A class used for receiving Mediator Service events. |
|
39 * |
|
40 * @lib MediatorClient.lib |
|
41 * @since S60 3.1 |
|
42 */ |
|
43 NONSHARABLE_CLASS(CMediatorNotificationsBody) : public CActive |
|
44 { |
|
45 public: // Constructors and destructor |
|
46 |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 * |
|
50 * @return a new CMediatorNotificationsBody instance |
|
51 */ |
|
52 static CMediatorNotificationsBody* NewL(); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CMediatorNotificationsBody(); |
|
58 |
|
59 public: // Event subscribtion |
|
60 |
|
61 /** |
|
62 * Register a registration observer. Any changes in the registration |
|
63 * information will be notified via the observer interface. |
|
64 * |
|
65 * @since S60 3.1 |
|
66 * @param aObserver An observer for Mediator Server. |
|
67 * @return TInt an error value. |
|
68 */ |
|
69 TInt RegisterNotificationObserver( |
|
70 MMediatorNotifications* aObserver ); |
|
71 |
|
72 /** |
|
73 * Unregister a registration observer. |
|
74 * |
|
75 * @since S60 3.1 |
|
76 * @return TInt an error value. |
|
77 */ |
|
78 TInt UnregisterNotificationObserver(); |
|
79 |
|
80 /** |
|
81 * Get a list of registered domains. |
|
82 * |
|
83 * @since S60 3.1 |
|
84 * @param aDomains The list of registered domains. |
|
85 * @return TInt an error value. |
|
86 */ |
|
87 TInt GetDomains( RDomainList& aDomains ); |
|
88 |
|
89 /** |
|
90 * Get a list of registered categories. |
|
91 * |
|
92 * @since S60 3.1 |
|
93 * @param aDomain The identifier of the domain. |
|
94 * @param aCategories The list of registered categories for the domain. |
|
95 * @return TInt an error value. |
|
96 */ |
|
97 TInt GetCategories( TUid aDomain, |
|
98 RCategoryList& aCategories ); |
|
99 |
|
100 /** |
|
101 * Get a list of registered events. |
|
102 * |
|
103 * @since S60 3.1 |
|
104 * @param aDomain The identifier of the domain. |
|
105 * @param aCategory The identifier of the category. |
|
106 * @param aEvents The list of registered events for the category. |
|
107 * @return TInt an error value. |
|
108 */ |
|
109 TInt GetEvents( TUid aDomain, |
|
110 TUid aCategory, |
|
111 REventList& aEvents ); |
|
112 |
|
113 /** |
|
114 * Get a list of registered commands. |
|
115 * |
|
116 * @since S60 3.1 |
|
117 * @param aDomain The identifier of the domain. |
|
118 * @param aCategory The identifier of the category. |
|
119 * @param aCommands The list of registered commands for the category. |
|
120 * @return TInt an error value. |
|
121 */ |
|
122 TInt GetCommands( TUid aDomain, |
|
123 TUid aCategory, |
|
124 RCommandList& aCommands ); |
|
125 |
|
126 private: // From CActive |
|
127 |
|
128 /** |
|
129 * From CActive::RunL |
|
130 */ |
|
131 void RunL(); |
|
132 |
|
133 /** |
|
134 * From CActive::DoCancel() |
|
135 */ |
|
136 void DoCancel(); |
|
137 |
|
138 /** |
|
139 * From CActive::RunError() |
|
140 */ |
|
141 TInt RunError( TInt aError ); |
|
142 |
|
143 private: // New functions |
|
144 |
|
145 /** |
|
146 * Receives notifications from the server |
|
147 * |
|
148 * @since S60 3.1 |
|
149 * @return None. |
|
150 */ |
|
151 void ReceiveNotificationsL(); |
|
152 |
|
153 /** |
|
154 * Sets the size of the event list. |
|
155 * |
|
156 * @since S60 3.1 |
|
157 * @param aEventCount new size |
|
158 * @return None. |
|
159 */ |
|
160 void ResizeEventListL( TInt aEventCount ); |
|
161 |
|
162 /** |
|
163 * Sets the size of the command list. |
|
164 * |
|
165 * @since S60 3.1 |
|
166 * @param aEventCount new size |
|
167 * @return None. |
|
168 */ |
|
169 void ResizeCommandListL( TInt aCommandCount ); |
|
170 |
|
171 /** |
|
172 * Retrieves syncronously event list from the server |
|
173 * after a notification has been received. |
|
174 * |
|
175 * @since S60 3.1 |
|
176 * @return None. |
|
177 */ |
|
178 void FetchEventListL(); |
|
179 |
|
180 /** |
|
181 * Retrieves syncronously command list from the server |
|
182 * after a notification has been received. |
|
183 * |
|
184 * @since S60 3.1 |
|
185 * @return None. |
|
186 */ |
|
187 void FetchCommandListL(); |
|
188 |
|
189 private: |
|
190 |
|
191 /** |
|
192 * C++ default constructor. |
|
193 */ |
|
194 CMediatorNotificationsBody(); |
|
195 |
|
196 /** |
|
197 * By default Symbian 2nd phase constructor is private. |
|
198 */ |
|
199 void ConstructL(); |
|
200 |
|
201 private: // Data |
|
202 |
|
203 // A session class to mediator server |
|
204 RMediatorServer iMediatorServer; |
|
205 |
|
206 // Observer for event callbacks (not owned) |
|
207 MMediatorNotifications* iObserver; |
|
208 |
|
209 // List for notified events |
|
210 REventList iEventList; |
|
211 |
|
212 // List for notitifer commands |
|
213 RCommandList iCommandList; |
|
214 |
|
215 // Pointers for return array data |
|
216 TPtr8 iCommandArrayPtr; |
|
217 TPtr8 iEventArrayPtr; |
|
218 |
|
219 // Domain and category information |
|
220 TMediatorCategory iCategory; |
|
221 TMediatorCategoryRetBuffer iCategoryBuffer; |
|
222 |
|
223 // Notification type |
|
224 TMediatorNotificationType iNotificationType; |
|
225 TNotificationTypeRetBuffer iNotificationTypeBuffer; |
|
226 |
|
227 // Stores information whether destructor has been called, checked in RunL |
|
228 TBool* iDestroyed; |
|
229 |
|
230 }; |
|
231 |
|
232 #endif // MEDIATORNOTIFICATIONSBODY_H |
|
233 |
|
234 // End of File |