|
1 /* |
|
2 * Copyright (c) 2004 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: Generic event and message channel for Connection UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CCNUIGROUPCHANNEL_H |
|
21 #define __CCNUIGROUPCHANNEL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "MIMPSSharedData.h" |
|
25 #include "MIMPSSharedDataObserver.h" |
|
26 #include "IMPSSharedDataDefs.h" |
|
27 |
|
28 #include <E32Base.h> |
|
29 #include <impspresenceconnectionuiconstsng.h> |
|
30 |
|
31 //CONTANTS |
|
32 _LIT( KGroupChannelKeyNameFormatter, "MC%dG%d" ); |
|
33 _LIT( KGroupChannelDataKeyNameFormatter, "DC%dG%d" ); |
|
34 |
|
35 _LIT( KGlobalChannelKeyNameFormatter, "GMC%d" ); |
|
36 _LIT( KGlobalChannelDataKeyNameFormatter, "GDC%d" ); |
|
37 |
|
38 _LIT( KGlobalChannelPermanentKeyIdentifier, "P" ); |
|
39 _LIT( KGlobalChannelTemporaryKeyIdentifier, "T" ); |
|
40 |
|
41 //Identifier is inserted in the start of key ==> index 0 |
|
42 const TInt KGlobalChannelTypeIdPosition = 0; |
|
43 |
|
44 |
|
45 const TInt KMaxChannelKeyLength = 10; |
|
46 const TInt KMaxChannelIdValue = 10; |
|
47 |
|
48 |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 class MCnUiGroupChannelListener; |
|
52 |
|
53 |
|
54 /** |
|
55 * Notification group id for global (client group wide) |
|
56 * notifications |
|
57 * @since 2.1 |
|
58 */ |
|
59 enum TGCSpecialGroupIds |
|
60 { |
|
61 ECnUiGlobalGroup = EIMPSConnClientPEC - 1, |
|
62 }; |
|
63 |
|
64 |
|
65 /** |
|
66 * Notification channel ID's |
|
67 * @since 2.1 |
|
68 */ |
|
69 enum TGCChannelID |
|
70 { |
|
71 ECnUiClientLoginLogoutStateChannel = 0, |
|
72 ECnUiLoginLogoutEventChannel = 1, |
|
73 ECnUiSSClientReqistrationChannel = 2, |
|
74 ECnUiGlobalOperationSignalChannel = 3, |
|
75 ECnUiRemoteUiNotificationsChannel = 4 |
|
76 }; |
|
77 |
|
78 |
|
79 |
|
80 // CLASS DECLARATION |
|
81 |
|
82 /** |
|
83 * Generic event and message channel for Connection UI. |
|
84 * |
|
85 * @since 2.1 |
|
86 */ |
|
87 NONSHARABLE_CLASS( CCnUiGroupChannel ) : public CBase, |
|
88 public MIMPSSharedDataObserver |
|
89 { |
|
90 public: // Two-phased constructors and destructor |
|
91 |
|
92 /** |
|
93 * Two-phased constructor, constructs the |
|
94 * CCnUiGroupChannel object. |
|
95 * |
|
96 * @since 2.1 |
|
97 * @param aGroupId The channel group ID. |
|
98 * @param aChannelId The channel ID. |
|
99 * @param aTemporary Is the channel temporary or permanent. |
|
100 * @return is pointer to CCnUiGroupChannel object. |
|
101 */ |
|
102 static CCnUiGroupChannel* NewLC( TInt aGroupId, |
|
103 TGCChannelID aChannelId, |
|
104 TBool aTemporary = ETrue ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Two-phased constructor, constructs the |
|
109 * CCnUiGroupChannel object. |
|
110 * |
|
111 * @since 2.1 |
|
112 * @param aGroupId The channel group ID. |
|
113 * @param aChannelId The channel ID. |
|
114 * @param aTemporary Is the channel temporary or permanent. |
|
115 * @return is pointer to CCnUiGroupChannel object. |
|
116 */ |
|
117 static CCnUiGroupChannel* NewL( TInt aGroupId, |
|
118 TGCChannelID aChannelId, |
|
119 TBool aTemporary = ETrue ); |
|
120 |
|
121 |
|
122 /** |
|
123 * Destructor. |
|
124 */ |
|
125 ~CCnUiGroupChannel(); |
|
126 |
|
127 |
|
128 private: //Constructors |
|
129 |
|
130 /** |
|
131 * C++ default constructor. |
|
132 */ |
|
133 CCnUiGroupChannel( TInt aGroupId, |
|
134 TGCChannelID aChannelId ); |
|
135 |
|
136 /** |
|
137 * By default Symbian 2nd phase constructor is private. |
|
138 */ |
|
139 void ConstructL( TBool aTemporary ); |
|
140 |
|
141 |
|
142 public: //New methods |
|
143 |
|
144 /** |
|
145 * Writes the given message to opened channel. |
|
146 * |
|
147 * @since 2.1 |
|
148 * @param aMsg The message to write. |
|
149 */ |
|
150 void WriteL( TInt aMsg ); |
|
151 |
|
152 /** |
|
153 * Writes the given message to opened channel. |
|
154 * Writes the given extra data channel data subchannel. |
|
155 * |
|
156 * @since 2.1 |
|
157 * @param aMsg The message to write. |
|
158 * @param aExtraData The extra data to write. |
|
159 */ |
|
160 void WriteL( TInt aMsg, const TDesC& aExtraData ); |
|
161 |
|
162 /** |
|
163 * Reads a last message from channel. |
|
164 * |
|
165 * @since 2.1 |
|
166 * @param aMsg On the return contains the readed message. |
|
167 * @return KErrNone if succesful. |
|
168 * KErrNotFound if no data previously stored to channel, |
|
169 * or it wasn't in numeric format. |
|
170 */ |
|
171 TInt Read( TInt& aMsg ); |
|
172 |
|
173 |
|
174 /** |
|
175 * Reads a last extra data from channel. |
|
176 * |
|
177 * @since 2.1 |
|
178 * @param aExtraData On the return contains the readed message. |
|
179 * If no data previously stored to channel, returns empty |
|
180 * buffer. |
|
181 */ |
|
182 void ReadL( HBufC*& aExtraData ); |
|
183 |
|
184 |
|
185 /** |
|
186 * Signals the channel. |
|
187 * Increases the channel value with 1. |
|
188 * |
|
189 * @since 2.1 |
|
190 * @return KErrNone if succesful. |
|
191 * KErrInUse if channel is already signalled by this object. |
|
192 */ |
|
193 TInt SignalL(); |
|
194 |
|
195 |
|
196 /** |
|
197 * Signals the channel. |
|
198 * Increases the channel value with 1. |
|
199 * Updates also the data subchannel value to given one. |
|
200 * |
|
201 * @since 2.1 |
|
202 * @param aExtraData The extra data to store to data sub channel. |
|
203 * @return KErrNone if succesful. |
|
204 * KErrInUse if channel is already signalled by this object. |
|
205 */ |
|
206 TInt SignalL( const TDesC& aExtraData ); |
|
207 |
|
208 |
|
209 /** |
|
210 * Cancels any previously by this object issued signal. |
|
211 * @since 2.1 |
|
212 */ |
|
213 void CancelSignal(); |
|
214 |
|
215 |
|
216 /** |
|
217 * Registeres to listen channel events. |
|
218 * @since 2.1 |
|
219 * @param aListener The listener to notify channel events. |
|
220 * Leaves with KErrInUse, if listening already started. |
|
221 * Leaves with KErrArgument, if listener is NULL. |
|
222 */ |
|
223 void ListenL( MCnUiGroupChannelListener* aListener ); |
|
224 |
|
225 |
|
226 /** |
|
227 * Cancels any previously issued listen. |
|
228 * @since 2.1 |
|
229 */ |
|
230 void CancelListen(); |
|
231 |
|
232 |
|
233 /** |
|
234 * Gets channel group ID. |
|
235 * @since 2.1 |
|
236 * @return Channel group ID. |
|
237 */ |
|
238 TInt GroupID(); |
|
239 |
|
240 |
|
241 /** |
|
242 * Gets channel channel ID. |
|
243 * @since 2.1 |
|
244 * @return Channel ID. |
|
245 */ |
|
246 TGCChannelID ChannelId(); |
|
247 |
|
248 private: //helpers |
|
249 |
|
250 void WriteExtraDataL( const TDesC& aExtraData ); |
|
251 |
|
252 /** |
|
253 * Handles notify from permanent keys' changes |
|
254 * @param aUid uid of the dll |
|
255 * @param aKey the shared data key |
|
256 * @param aValue the value of the key |
|
257 */ |
|
258 void HandlePermanentKeyNotifyL( const TUid aUid, |
|
259 const TIMPSSharedKeys aKey ); |
|
260 |
|
261 /** |
|
262 * Handles notify from temporary keys' changes |
|
263 * @param aUid uid of the dll |
|
264 * @param aKey the shared data key |
|
265 * @param aValue the value of the key |
|
266 */ |
|
267 void HandleTemporaryKeyNotifyL( const TUid aUid, |
|
268 const TIMPSSharedKeys aKey ); |
|
269 |
|
270 |
|
271 private: //data |
|
272 |
|
273 ///<The channel ID's, owned |
|
274 const TInt iGroupId; |
|
275 const TGCChannelID iChannelId; |
|
276 |
|
277 ///<Channel & sub channel name keys, owned |
|
278 TBuf<KMaxChannelKeyLength> iChannelKey; |
|
279 TBuf<KMaxChannelKeyLength> iChannelDataKey; |
|
280 |
|
281 ///<Registered listener, not owned. |
|
282 MCnUiGroupChannelListener* iListener; |
|
283 |
|
284 ///<Signal flag, owned |
|
285 TBool iChannelSignaled; |
|
286 |
|
287 // the converted channel key |
|
288 TIMPSSharedKeys iKey; |
|
289 |
|
290 // the converted channel data key |
|
291 TIMPSSharedKeys iDataKey; |
|
292 |
|
293 //Array of key pairs |
|
294 RArray<TIMPSSharedKeyPairs> iKeys; |
|
295 |
|
296 // Owns: the shared data handler |
|
297 MIMPSSharedData *iSharedData; |
|
298 |
|
299 // UID |
|
300 TUid iUid; |
|
301 |
|
302 }; |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 // CLASS DECLARATION |
|
308 |
|
309 /** |
|
310 * Listener interface to listen channel events. |
|
311 * |
|
312 * @since 2.1 |
|
313 */ |
|
314 NONSHARABLE_CLASS( MCnUiGroupChannelListener ) |
|
315 { |
|
316 public: // Handle events |
|
317 |
|
318 /** |
|
319 * Callback method to be called after channel event. |
|
320 * |
|
321 * @since 2.1 |
|
322 * @param aGroupId The originating channel group. |
|
323 * @param aChannelId The originating channel. |
|
324 * @param aChannelMsg The channel message. |
|
325 */ |
|
326 virtual void HandleChannelMsg( TInt aGroupId, |
|
327 TGCChannelID aChannelId, |
|
328 TInt aChannelMsg ) = 0; |
|
329 |
|
330 |
|
331 protected: //Destructor |
|
332 |
|
333 /** |
|
334 * Virtual inline destructor. |
|
335 * Observer can't be destructed using this interface. |
|
336 * |
|
337 * @since 2.1 |
|
338 */ |
|
339 virtual ~MCnUiGroupChannelListener() {}; |
|
340 |
|
341 }; |
|
342 |
|
343 |
|
344 #endif //__CCNUIGROUPCHANNEL_H |
|
345 |
|
346 // End of File |