|
1 /* |
|
2 * Copyright (c) 2007 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: SIMPLE Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32std.h> |
|
22 #include <centralrepository.h> |
|
23 |
|
24 #include "simpleplugincommon.h" |
|
25 #include "simplepluginvariation.h" |
|
26 #include "presencefwsimpleadptprivatecrkeys.h" |
|
27 |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CSimplePluginVariation::CSimplePluginVariation |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CSimplePluginVariation::CSimplePluginVariation( ) |
|
36 : iDefaultRuleAction(ERuleConfirm), iBlockRuleAction(ERulePoliteBlock) |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CSimplePluginVariation::ConstructL |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CSimplePluginVariation::ConstructL( ) |
|
45 { |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CSimplePluginVariation::NewL |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CSimplePluginVariation* CSimplePluginVariation::NewL( ) |
|
53 { |
|
54 CSimplePluginVariation* self = |
|
55 new( ELeave ) CSimplePluginVariation(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL( ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CSimplePluginVariation::~CSimplePluginVariation |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CSimplePluginVariation::~CSimplePluginVariation() |
|
67 { |
|
68 delete iGrantAllRuleName; |
|
69 delete iGrantOwnRuleName; |
|
70 delete iDefaultRuleName; |
|
71 delete iBlockRuleName; |
|
72 delete iRlsGroupUriTemplate; |
|
73 delete iSharedXdmTop; |
|
74 delete iGrantListName; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CSimplePluginVariation::InitL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CSimplePluginVariation::InitL() |
|
82 { |
|
83 // Read Central Repository settings |
|
84 CRepository* repository = NULL; |
|
85 |
|
86 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
87 |
|
88 TRAP_IGNORE( repository = |
|
89 CRepository::NewL( KCRUIDPresencefwSimpleadptVariation )); |
|
90 |
|
91 CleanupStack::PushL( repository ); |
|
92 |
|
93 // initialize strings |
|
94 delete iGrantAllRuleName; |
|
95 iGrantAllRuleName = NULL; |
|
96 delete iGrantOwnRuleName; |
|
97 iGrantOwnRuleName = NULL; |
|
98 delete iDefaultRuleName; |
|
99 iDefaultRuleName = NULL; |
|
100 delete iBlockRuleName; |
|
101 iBlockRuleName = NULL; |
|
102 delete iRlsGroupUriTemplate; |
|
103 iRlsGroupUriTemplate = NULL; |
|
104 delete iSharedXdmTop; |
|
105 iSharedXdmTop = NULL; |
|
106 delete iGrantListName; |
|
107 iGrantListName = NULL; |
|
108 |
|
109 // Read values from CenRep |
|
110 InitGrantRuleNameL( repository ); |
|
111 InitGrantOwnRuleNameL( repository ); |
|
112 InitDefaultRuleNameL( repository ); |
|
113 InitBlockRuleNameL( repository ); |
|
114 InitDefaultRuleActionL( repository ); |
|
115 InitBlockRuleActionL( repository ); |
|
116 InitRlsGroupUriTemplateL( repository ); |
|
117 InitSharedXdmTopL( repository ); |
|
118 InitGrantListNameL( repository ); |
|
119 |
|
120 CleanupStack::PopAndDestroy( repository ); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CSimplePluginVariation::GrantRuleName |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 TPtrC CSimplePluginVariation::GrantRuleName() |
|
128 { |
|
129 return iGrantAllRuleName ? iGrantAllRuleName->Des() : TPtrC(); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CSimplePluginVariation::GrantOwnRuleName |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 TPtrC CSimplePluginVariation::GrantOwnRuleName() |
|
137 { |
|
138 return iGrantOwnRuleName ? iGrantOwnRuleName->Des() : TPtrC(); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CSimplePluginVariation::DefaultRuleName |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 TPtrC CSimplePluginVariation::DefaultRuleName() |
|
146 { |
|
147 return iDefaultRuleName ? iDefaultRuleName->Des() : TPtrC(); |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CSimplePluginVariation::BlockRuleName |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 TPtrC CSimplePluginVariation::BlockRuleName() |
|
155 { |
|
156 return iBlockRuleName ? iBlockRuleName->Des() : TPtrC(); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CSimplePluginVariation::DefaultRuleAction |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CSimplePluginVariation::TSimplePluginAuthRule CSimplePluginVariation::DefaultRuleAction() |
|
164 { |
|
165 return iDefaultRuleAction; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CSimplePluginVariation::BlockRuleAction |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 CSimplePluginVariation::TSimplePluginAuthRule CSimplePluginVariation::BlockRuleAction() |
|
173 { |
|
174 return iBlockRuleAction; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CSimplePluginVariation::RlsGroupUriTemplate |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 TPtrC CSimplePluginVariation::RlsGroupUriTemplate() |
|
182 { |
|
183 return iRlsGroupUriTemplate ? iRlsGroupUriTemplate->Des() : TPtrC(); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CSimplePluginVariation::SharedXdmTop |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 TPtrC CSimplePluginVariation::SharedXdmTop() |
|
191 { |
|
192 return iSharedXdmTop ? iSharedXdmTop->Des() : TPtrC(); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CSimplePluginVariation::GrantListName |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 TPtrC CSimplePluginVariation::GrantListName() |
|
200 { |
|
201 return iGrantListName ? iGrantListName->Des() : TPtrC(); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CSimplePluginVariation::InitGrantRuleNameL |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CSimplePluginVariation::InitGrantRuleNameL( CRepository* aRepository ) |
|
209 { |
|
210 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
211 |
|
212 if ( !aRepository || aRepository->Get( KPrFwSimpleGrantAllRuleName, myBuffer )) |
|
213 { |
|
214 // Use deault value when not found in Central Repository |
|
215 myBuffer = KSimpleXdmGrantRule; |
|
216 } |
|
217 iGrantAllRuleName = myBuffer.AllocL( ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CSimplePluginVariation::InitGrantOwnRuleNameL |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CSimplePluginVariation::InitGrantOwnRuleNameL( CRepository* aRepository ) |
|
225 { |
|
226 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
227 |
|
228 if ( !aRepository || aRepository->Get( KPrFwSimpleGrantOwnRuleName, myBuffer )) |
|
229 { |
|
230 // Use deault value when not found in Central Repository |
|
231 myBuffer = KSimpleXdmOwnGrantRule; |
|
232 } |
|
233 iGrantOwnRuleName = myBuffer.AllocL( ); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CSimplePluginVariation::InitDefaultRuleNameL |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 void CSimplePluginVariation::InitDefaultRuleNameL( CRepository* aRepository ) |
|
241 { |
|
242 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
243 |
|
244 if ( !aRepository || aRepository->Get( KPrFwSimpleDefaultRuleName, myBuffer )) |
|
245 { |
|
246 // Use deault value when not found in Central Repository |
|
247 myBuffer = KSimpleXdmDefaultRule; |
|
248 } |
|
249 iDefaultRuleName = myBuffer.AllocL( ); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CSimplePluginVariation::InitBlockRuleNameL |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 void CSimplePluginVariation::InitBlockRuleNameL( CRepository* aRepository ) |
|
257 { |
|
258 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
259 |
|
260 if ( !aRepository || aRepository->Get( KPrFwSimpleBlockRuleName, myBuffer )) |
|
261 { |
|
262 // Use deault value when not found in Central Repository |
|
263 myBuffer = KSimpleXdmBlockRule; |
|
264 } |
|
265 iBlockRuleName = myBuffer.AllocL( ); |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // CSimplePluginVariation::InitDefaultRuleActionL |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CSimplePluginVariation::InitDefaultRuleActionL( CRepository* aRepository ) |
|
273 { |
|
274 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
275 |
|
276 using namespace NSimplePlugin::NSimpleOma; |
|
277 |
|
278 iDefaultRuleAction = ERuleAllow; |
|
279 if ( aRepository && !aRepository->Get( KPrFwSimpleDefaultRuleAction, myBuffer )) |
|
280 { |
|
281 if ( !myBuffer.CompareF( KSimpleBlock )) |
|
282 { |
|
283 iDefaultRuleAction = ERuleBlock; |
|
284 } |
|
285 else if ( !myBuffer.CompareF( KSimplePoliteBlock )) |
|
286 { |
|
287 iDefaultRuleAction = ERulePoliteBlock; |
|
288 } |
|
289 else if ( !myBuffer.CompareF( KSimpleConfirm )) |
|
290 { |
|
291 iDefaultRuleAction = ERuleConfirm; |
|
292 } |
|
293 else if ( !myBuffer.CompareF( KSimpleAllow )) |
|
294 { |
|
295 iDefaultRuleAction = ERuleAllow; |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CSimplePluginVariation::InitBlockRuleActionL |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CSimplePluginVariation::InitBlockRuleActionL( CRepository* aRepository ) |
|
305 { |
|
306 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
307 |
|
308 using namespace NSimplePlugin::NSimpleOma; |
|
309 |
|
310 iBlockRuleAction = ERuleBlock; |
|
311 if ( aRepository && !aRepository->Get( KPrFwSimpleBlockRuleAction, myBuffer )) |
|
312 { |
|
313 if ( myBuffer.CompareF( KSimpleBlock )) |
|
314 { |
|
315 iBlockRuleAction = ERulePoliteBlock; |
|
316 } |
|
317 else |
|
318 { |
|
319 // default value is used |
|
320 } |
|
321 } |
|
322 else |
|
323 { |
|
324 // default value is used |
|
325 } |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CSimplePluginVariation::InitRlsGroupUriTemplateL |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CSimplePluginVariation::InitRlsGroupUriTemplateL( CRepository* aRepository ) |
|
333 { |
|
334 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
335 |
|
336 if ( !aRepository || aRepository->Get( KPrFwSimpleRlsGroupUriTemplate, myBuffer )) |
|
337 { |
|
338 myBuffer = KSimpleRlsGroupUriTemplate; |
|
339 } |
|
340 iRlsGroupUriTemplate = myBuffer.AllocL(); |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------------------------- |
|
344 // CSimplePluginVariation::InitSharedXdmTopL |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 void CSimplePluginVariation::InitSharedXdmTopL( CRepository* aRepository ) |
|
348 { |
|
349 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
350 |
|
351 if ( !aRepository || aRepository->Get( KPrFwSimpleSharedXdmTop, myBuffer )) |
|
352 { |
|
353 myBuffer = KSimpleOMABuddyList; |
|
354 } |
|
355 iSharedXdmTop = myBuffer.AllocL(); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CSimplePluginVariation::InitGrantListNameL |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 void CSimplePluginVariation::InitGrantListNameL( CRepository* aRepository ) |
|
363 { |
|
364 TBuf<KSimplePluginMaxRuleLength> myBuffer; |
|
365 |
|
366 if ( !aRepository || aRepository->Get( KPrFwSimpleGrantListName, myBuffer )) |
|
367 { |
|
368 myBuffer = KSimpleS60GrantedList; |
|
369 } |
|
370 iGrantListName = myBuffer.AllocL(); |
|
371 } |
|
372 |
|
373 // End of file |