1 /* |
|
2 * Copyright (c) 2006 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: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPRESENCEPLUGINXDMPRESRULES_H |
|
20 #define CPRESENCEPLUGINXDMPRESRULES_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ximpbase.h> |
|
24 |
|
25 #include "presenceplugincommon.h" |
|
26 #include "presencelogger.h" |
|
27 |
|
28 class CXdmEngine; |
|
29 class CXdmDocument; |
|
30 class CXdmDocumentNode; |
|
31 class TRequestStatus; |
|
32 class MPresRulesAsyncHandler; |
|
33 |
|
34 /** |
|
35 * CPresencePluginXdmPresRules |
|
36 * |
|
37 * Simple Engine Connection |
|
38 * |
|
39 * @lib presenceplugin.dll |
|
40 * @since S60 v3.2 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CPresencePluginXdmPresRules ): public CActive |
|
43 { |
|
44 public: // Constructor and destructor |
|
45 |
|
46 /** |
|
47 * XDM presrules state |
|
48 */ |
|
49 enum TPluginPresRulesXdmState |
|
50 { |
|
51 EStateIdle, |
|
52 EGetXdmRules, |
|
53 EUpdateXdmRules, |
|
54 ECreateXdmPresrules |
|
55 }; |
|
56 |
|
57 /** |
|
58 * Operation state for rules update |
|
59 */ |
|
60 enum TPluginPresRulesUpdateState |
|
61 { |
|
62 EStateNoOperation, |
|
63 EStateAddToWhiteList, |
|
64 EStateAddToBlockList, |
|
65 EStateRemoveFromWhiteList, |
|
66 EStateRemoveFromBlackList, |
|
67 EStateInitializeRules |
|
68 }; |
|
69 |
|
70 /** |
|
71 * Current operation |
|
72 */ |
|
73 enum TPluginPresRulesXdmOperation |
|
74 { |
|
75 ENoOperation, |
|
76 ECancelDocument, |
|
77 EXdmInit, |
|
78 EXdmDeleteAll, |
|
79 EXdmCancel, |
|
80 EXdmGetRulesFromServer, |
|
81 EXdmInitialPresDoc, |
|
82 EXdmUpdateRules, |
|
83 EXdmUpdateRulesFromServer |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Two-phased constructor. |
|
88 * |
|
89 * @param aXmdId xdm settings id |
|
90 * @param aLocalMode, local or server mode TRUE/FALSE |
|
91 */ |
|
92 static CPresencePluginXdmPresRules* NewL( const TInt aXmdId, TBool ); |
|
93 |
|
94 /** |
|
95 * Two-phased constructor. |
|
96 * |
|
97 * @param aXmdId xdm settings id |
|
98 * @param aLocalMode, local or server mode TRUE/FALSE |
|
99 */ |
|
100 static CPresencePluginXdmPresRules* NewLC( |
|
101 const TInt aSettingId, |
|
102 TBool aLocalMode ); |
|
103 |
|
104 /** |
|
105 * Standard C++ destructor |
|
106 */ |
|
107 virtual ~CPresencePluginXdmPresRules( ); |
|
108 |
|
109 public: // Own functions |
|
110 |
|
111 /** |
|
112 * Updates XDM rules into server |
|
113 * |
|
114 * @since S60 3.2 |
|
115 * @param aHandler, MPresRulesAssyncHandler |
|
116 * @return TInt, Error code |
|
117 */ |
|
118 TInt UpdateXdmRulesL( MPresRulesAsyncHandler* const aHandler ); |
|
119 |
|
120 /** |
|
121 * Add white list tag to presrules document |
|
122 * |
|
123 * @since S60 3.2 |
|
124 * @param aRoot, xml document root |
|
125 * @return none |
|
126 */ |
|
127 void AddWhiteListL( CXdmDocumentNode* aRoot ); |
|
128 |
|
129 /** |
|
130 * Add black list tag to presrules document |
|
131 * |
|
132 * @since S60 3.2 |
|
133 * @param aRoot, xml document root |
|
134 * @return none |
|
135 */ |
|
136 void AddBlackListL( CXdmDocumentNode* aRoot ); |
|
137 |
|
138 /** |
|
139 * Get presence rules from server |
|
140 * |
|
141 * @since S60 3.2 |
|
142 * @param aHandler, PresRules assync handler |
|
143 * @return TInt, error code |
|
144 */ |
|
145 TInt GetXdmRulesL( MPresRulesAsyncHandler* const aHandler ); |
|
146 |
|
147 /** |
|
148 * Making initial presence rules document |
|
149 * |
|
150 * @since S60 3.2 |
|
151 * @param aHandler, PresRules assync handler |
|
152 * @return none |
|
153 */ |
|
154 void MakeInitialRulesDocumentL( |
|
155 MPresRulesAsyncHandler* const aHandler ); |
|
156 |
|
157 /** |
|
158 * Remove entiry from blocked rules |
|
159 * |
|
160 * @since S60 3.2 |
|
161 * @param aUri, entity url |
|
162 * @aHandler, PresRules assync handler |
|
163 * @return none |
|
164 */ |
|
165 void RemoveEntityBlockedRulesL( |
|
166 const TDesC& aUri, |
|
167 MPresRulesAsyncHandler* const aHandler ); |
|
168 |
|
169 /** |
|
170 * Remove entity from presrules white list |
|
171 * |
|
172 * @since S60 3.2 |
|
173 * @param aUri, entity url |
|
174 * @aHandler, PresRules assync handler |
|
175 * @return none |
|
176 */ |
|
177 void RemoveEntityFromWhiteListL( |
|
178 const TDesC& aUri, |
|
179 MPresRulesAsyncHandler* const aHandler ); |
|
180 |
|
181 /** |
|
182 * Add entity to presrules white list |
|
183 * |
|
184 * @since S60 3.2 |
|
185 * @param aUri, entity url |
|
186 * @aHandler, PresRules assync handler |
|
187 * @return none |
|
188 */ |
|
189 void AddEntityToWhiteListL( |
|
190 const TDesC& aUri, |
|
191 MPresRulesAsyncHandler* const aHandler ); |
|
192 |
|
193 /** |
|
194 * Add entity to blocked rules |
|
195 * |
|
196 * @since S60 3.2 |
|
197 * @param aUri, entity url |
|
198 * @aHandler, PresRules assync handler |
|
199 * @return none |
|
200 */ |
|
201 void AddEntityToBlockedRulesL( |
|
202 const TDesC& aUri, |
|
203 MPresRulesAsyncHandler* const aHandler ); |
|
204 |
|
205 /** |
|
206 * Remove one from rule list |
|
207 * |
|
208 * @since S60 3.2 |
|
209 * @param aRule, presence rule name |
|
210 * @param aUri, entity url |
|
211 * @return none |
|
212 */ |
|
213 void RemoveOneFromRuleL( |
|
214 const TDesC& aRule, |
|
215 const TDesC& aUri ); |
|
216 |
|
217 /** |
|
218 * Add one to rule list |
|
219 * |
|
220 * @since S60 3.2 |
|
221 * @param aRule, presence rule name |
|
222 * @param aUri, entity url |
|
223 * @return none |
|
224 */ |
|
225 void DoOneAddUserL( |
|
226 const TDesC& aList, |
|
227 const TDesC& aUri ); |
|
228 |
|
229 /** |
|
230 * Update presence document from server |
|
231 * |
|
232 * @since S60 3.2 |
|
233 * @param none |
|
234 * @return TInt, error code |
|
235 */ |
|
236 TInt UpdateFromServerL( MPresRulesAsyncHandler* const aHandler ); |
|
237 |
|
238 private: |
|
239 |
|
240 /** |
|
241 * Standard C++ constructor |
|
242 * @param aXmdId, XDM settings id |
|
243 */ |
|
244 CPresencePluginXdmPresRules( const TInt aXmdId ); |
|
245 |
|
246 /** |
|
247 * Performs the 2nd phase of construction. |
|
248 * |
|
249 * @param aXmdId, xdm settings id |
|
250 * @param aLocalMode, clinet localmode state |
|
251 */ |
|
252 void ConstructL( const TInt aXmdId, TBool aLocalMode ); |
|
253 |
|
254 private: // own functions |
|
255 |
|
256 /** |
|
257 * GetRulesL |
|
258 * |
|
259 * @since S60 3.2 |
|
260 * @param aRuleArray, rule array |
|
261 * @return TBool, rules found |
|
262 */ |
|
263 CXdmDocumentNode* GetRulesL( const TDesC& aRule, |
|
264 RPointerArray<CXdmDocumentNode>& aRuleArray ); |
|
265 |
|
266 /** |
|
267 * Remove rule group from pres-rules document |
|
268 * |
|
269 * @since S60 3.2 |
|
270 * @param aRule, presence rule name |
|
271 * @return none |
|
272 */ |
|
273 void RemoveRuleGroupL( const TDesC& aRule ); |
|
274 |
|
275 /** |
|
276 * Search list under parent |
|
277 * |
|
278 * @since S60 3.2 |
|
279 * @param aParent. document node |
|
280 * @param aName, name of search |
|
281 * @return none |
|
282 */ |
|
283 CXdmDocumentNode* SearchListUnderParentL( |
|
284 CXdmDocumentNode* aParent, |
|
285 const TDesC& aName ); |
|
286 |
|
287 /** |
|
288 * Create root if need |
|
289 * |
|
290 * @since S60 3.2 |
|
291 * @param none |
|
292 * @return none |
|
293 */ |
|
294 void CreateRootIfNeededL(); |
|
295 |
|
296 static void ResetAndDestroy1( TAny* aPointerArray ); |
|
297 static void ResetAndDestroy2( TAny* aPointerArray ); |
|
298 |
|
299 /** |
|
300 * Find rule from presrules xml |
|
301 * |
|
302 * @since S60 3.2 |
|
303 * @param aRule, rule name |
|
304 * @return TBool |
|
305 */ |
|
306 TBool FindRuleL( const TDesC& aRule, TBool aCreateRule ); |
|
307 |
|
308 /** |
|
309 * Check if one already exist |
|
310 * |
|
311 * @since S60 3.2 |
|
312 * @param aList, listname |
|
313 * @param aUri, entity url |
|
314 * @return TBool |
|
315 */ |
|
316 TBool CheckIfOneExistL( |
|
317 const TDesC& aRule, |
|
318 const TDesC& aUri ); |
|
319 |
|
320 protected: // from base class CActive |
|
321 |
|
322 /** |
|
323 * Defined in a base class |
|
324 */ |
|
325 void RunL(); |
|
326 |
|
327 /** |
|
328 * Defined in a base class |
|
329 */ |
|
330 TInt RunError( TInt aError ); |
|
331 |
|
332 /** |
|
333 * Defined in a base class |
|
334 */ |
|
335 void DoCancel(); |
|
336 |
|
337 private: // Data |
|
338 |
|
339 /** |
|
340 * XDM Engine |
|
341 * Own. |
|
342 */ |
|
343 CXdmEngine* iXdmEngine; |
|
344 |
|
345 /** |
|
346 * XDM Settings id |
|
347 * Own. |
|
348 */ |
|
349 TInt iSettingsId; |
|
350 |
|
351 /** |
|
352 * Presence rules document |
|
353 * Own |
|
354 */ |
|
355 CXdmDocument* iPresRulesDoc; |
|
356 |
|
357 /** |
|
358 * Current state |
|
359 * Own. |
|
360 */ |
|
361 TPluginPresRulesXdmState iXdmState; |
|
362 |
|
363 /** |
|
364 * TPluginPresRulesUpdateState |
|
365 * Own. |
|
366 */ |
|
367 TPluginPresRulesUpdateState iRulesUpdateState; |
|
368 |
|
369 /** |
|
370 * client statutus. |
|
371 * Not own. |
|
372 */ |
|
373 TRequestStatus* iClientStatus; |
|
374 |
|
375 /** |
|
376 * Whether Presence XDM is up-to-date |
|
377 * Own. |
|
378 */ |
|
379 TBool iPresXdmOk; |
|
380 |
|
381 /** |
|
382 * Entity uri |
|
383 * own |
|
384 */ |
|
385 HBufC* iEntityUri; |
|
386 |
|
387 /** |
|
388 * Async request |
|
389 * Own. |
|
390 */ |
|
391 TPluginPresRulesXdmOperation iAsyncReq; |
|
392 |
|
393 /** |
|
394 * Async handler |
|
395 * Own. |
|
396 */ |
|
397 MPresRulesAsyncHandler* iAsyncHandler; |
|
398 |
|
399 SIMPLE_UNIT_TEST( T_CPresencePluginXdmPresRules ) |
|
400 }; |
|
401 |
|
402 #endif // CPRESENCEPLUGINXDMPRESRULES_H |
|