author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:16:48 +0300 | |
changeset 77 | 2be0b271d017 |
parent 64 | 6aaf0276100e |
permissions | -rw-r--r-- |
37 | 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: Central Repository proxy. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <e32std.h> |
|
21 |
#include <e32def.h> |
|
22 |
#include <e32base.h> |
|
23 |
#include <telinternalcrkeys.h> |
|
24 |
#include <pslninternalcrkeys.h> |
|
25 |
#include <LogsDomainCRKeys.h> |
|
26 |
#include <accessoriescrkeys.h> |
|
27 |
#include <settingsinternalcrkeys.h> |
|
28 |
#include <UiklafInternalCRKeys.h> |
|
29 |
#include <ProfileEngineDomainCRKeys.h> |
|
30 |
#include <DRMHelperServerInternalCRKeys.h> |
|
31 |
#include <btengdomaincrkeys.h> |
|
32 |
#include <utf.h> |
|
33 |
||
34 |
#include "phoneui.pan" |
|
35 |
#include "cphonecenrepproxy.h" |
|
36 |
#include "mphonecenrepobserver.h" |
|
37 |
#include "cphonecenrepeventhandler.h" |
|
38 |
#include "phoneconstants.h" |
|
39 |
#include "phonelogger.h" |
|
40 |
#include "telprivatecrkeys.h" |
|
41 |
#include "tphonecmdparamappinfo.h" |
|
42 |
||
43 |
//CONSTANTS |
|
44 |
const TInt KMaxParamLength = 1024; |
|
45 |
||
46 |
// ================= MEMBER FUNCTIONS ======================= |
|
47 |
||
48 |
// --------------------------------------------------------- |
|
49 |
// CPhoneCenRepProxy::Instance |
|
50 |
// Initializes the singleton object |
|
51 |
// (other items were commented in a header). |
|
52 |
// --------------------------------------------------------- |
|
53 |
// |
|
54 |
EXPORT_C CPhoneCenRepProxy* CPhoneCenRepProxy::Instance() |
|
55 |
{ |
|
56 |
CPhoneCenRepProxy* instance = static_cast<CPhoneCenRepProxy*> |
|
57 |
( CCoeEnv::Static ( KUidCenRepProxySingleton ) ); |
|
58 |
||
59 |
if( !instance ) |
|
60 |
{ |
|
61 |
TRAPD( err, instance = CPhoneCenRepProxy::NewL() ); |
|
62 |
if ( err ) |
|
63 |
{ |
|
64 |
Panic( EPhoneUtilsCouldNotCreateSingleton ); |
|
65 |
} |
|
66 |
} |
|
67 |
return instance; |
|
68 |
} |
|
69 |
||
70 |
// --------------------------------------------------------- |
|
71 |
// CPhoneCenRepProxy::CancelAllNotifies |
|
72 |
// Cancel the notification if the singleton still exists. |
|
73 |
// (other items were commented in a header). |
|
74 |
// --------------------------------------------------------- |
|
75 |
// |
|
76 |
EXPORT_C void CPhoneCenRepProxy::CancelAllNotifies( |
|
77 |
MPhoneCenRepObserver* aObserver ) |
|
78 |
{ |
|
79 |
CPhoneCenRepProxy* instance = static_cast<CPhoneCenRepProxy*> |
|
80 |
( CCoeEnv::Static( KUidCenRepProxySingleton ) ); |
|
81 |
||
82 |
// Ignore the call since the singleton has already been destroyed and the |
|
83 |
// notifications removed |
|
84 |
if( instance != NULL ) |
|
85 |
{ |
|
86 |
instance->CancelAllObserverNotifies( aObserver ); |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
// --------------------------------------------------------- |
|
91 |
// CPhoneCenRepProxy::NewL |
|
92 |
// --------------------------------------------------------- |
|
93 |
// |
|
94 |
CPhoneCenRepProxy* CPhoneCenRepProxy::NewL() |
|
95 |
{ |
|
96 |
CPhoneCenRepProxy* self = |
|
97 |
new (ELeave) CPhoneCenRepProxy(); |
|
98 |
||
99 |
CleanupStack::PushL( self ); |
|
100 |
self->ConstructL(); |
|
101 |
CleanupStack::Pop( self ); |
|
102 |
||
103 |
return self; |
|
104 |
} |
|
105 |
||
106 |
// --------------------------------------------------------- |
|
107 |
// CPhoneCenRepProxy::~CPhoneCenRepProxy |
|
108 |
// --------------------------------------------------------- |
|
109 |
// |
|
110 |
EXPORT_C CPhoneCenRepProxy::~CPhoneCenRepProxy() |
|
111 |
{ |
|
112 |
// The Cancel should be always called before destroy the object |
|
113 |
CancelAllNotifies(); |
|
114 |
||
115 |
delete iCenRepAccessoryEventHandler; |
|
116 |
delete iCenRepNetworkEventHandler; |
|
117 |
delete iCenRepThemesEventHandler; |
|
118 |
delete iCenRepLanguageEventHandler; |
|
119 |
delete iCenRepQwertyEventHandler; |
|
120 |
delete iCenRepKDRMHelperEventHandler; |
|
121 |
delete iObserverArray; |
|
122 |
} |
|
123 |
||
124 |
// --------------------------------------------------------- |
|
125 |
// CPhoneCenRepProxy::CPhoneCenRepProxy |
|
126 |
// --------------------------------------------------------- |
|
127 |
// |
|
128 |
CPhoneCenRepProxy::CPhoneCenRepProxy() : |
|
129 |
CCoeStatic( KUidCenRepProxySingleton, EThread ) |
|
130 |
{ |
|
131 |
} |
|
132 |
||
133 |
// --------------------------------------------------------- |
|
134 |
// CPhoneCenRepProxy::ConstructL |
|
135 |
// --------------------------------------------------------- |
|
136 |
// |
|
137 |
void CPhoneCenRepProxy::ConstructL() |
|
138 |
{ |
|
139 |
iObserverArray = new ( ELeave ) CArrayFixFlat<TCenRepObserverTag>( |
|
140 |
KPhoneCenRepObserversGranularity ); |
|
141 |
||
142 |
iTelephonyVariantReadOnlyValues = KPhoneVariantReadOnlyDefaultValue; |
|
143 |
iPhoneUIVariantReadOnlyValues = KPhoneVariantReadOnlyDefaultValue; |
|
144 |
||
145 |
User::LeaveIfError( GetTelephonyVariantData() ); |
|
146 |
User::LeaveIfError( GetPhoneUIVariantData() ); |
|
147 |
} |
|
148 |
||
149 |
// --------------------------------------------------------- |
|
150 |
// CPhoneCenRepProxy::HandleNotifyL |
|
151 |
// --------------------------------------------------------- |
|
152 |
// |
|
153 |
void CPhoneCenRepProxy::HandleNotify( |
|
154 |
const TUid& aUid, |
|
155 |
const TUint aId ) |
|
156 |
{ |
|
157 |
TInt index = FindByUidId( aUid, aId, 0 ); |
|
158 |
while ( index != KErrNotFound ) |
|
159 |
{ |
|
160 |
__ASSERT_DEBUG( index < iObserverArray->Count(), |
|
161 |
Panic( EPhoneUtilsIndexOutOfBounds ) ); |
|
162 |
const TCenRepObserverTag& observerTag = iObserverArray->At( index ); |
|
163 |
TRAP_IGNORE( observerTag.iObserver->HandleCenRepChangeL( aUid, aId ) ); |
|
164 |
index = FindByUidId( aUid, aId, index+1 ); |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
// --------------------------------------------------------- |
|
169 |
// CPhoneCenRepProxy::SetInt |
|
170 |
// --------------------------------------------------------- |
|
171 |
// |
|
172 |
EXPORT_C TInt CPhoneCenRepProxy::SetInt( |
|
173 |
const TUid& aUid, |
|
174 |
const TUint aId, |
|
175 |
const TInt aValue ) |
|
176 |
{ |
|
177 |
CRepository* repository = NULL; |
|
178 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
179 |
if ( err == KErrNone ) |
|
180 |
{ |
|
181 |
err = repository->Set( aId, aValue ); |
|
182 |
} |
|
183 |
delete repository; |
|
184 |
||
185 |
if ( err != KErrNone ) |
|
186 |
{ |
|
187 |
__PHONELOG1( |
|
188 |
EBasic, |
|
189 |
EPhonePhoneapp, |
|
190 |
"CPhoneCenRepProxy::SetInt() error: %d", |
|
191 |
err ); |
|
192 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
193 |
} |
|
194 |
||
195 |
return err; |
|
196 |
} |
|
197 |
||
198 |
// --------------------------------------------------------- |
|
199 |
// CPhoneCenRepProxy::SetString |
|
200 |
// --------------------------------------------------------- |
|
201 |
// |
|
202 |
EXPORT_C TInt CPhoneCenRepProxy::SetString( |
|
203 |
const TUid& aUid, |
|
204 |
const TUint aId, |
|
205 |
const TDesC& aValue ) |
|
206 |
{ |
|
207 |
CRepository* repository = NULL; |
|
208 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
209 |
if ( err == KErrNone ) |
|
210 |
{ |
|
211 |
err = repository->Set( aId, aValue ); |
|
212 |
} |
|
213 |
delete repository; |
|
214 |
||
215 |
if ( err != KErrNone ) |
|
216 |
{ |
|
217 |
__PHONELOG1( |
|
218 |
EBasic, |
|
219 |
EPhonePhoneapp, |
|
220 |
"CPhoneCenRepProxy::SetString() error: %d", |
|
221 |
err ); |
|
222 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
223 |
} |
|
224 |
||
225 |
return err; |
|
226 |
} |
|
227 |
||
228 |
// --------------------------------------------------------- |
|
229 |
// CPhoneCenRepProxy::SetReal |
|
230 |
// --------------------------------------------------------- |
|
231 |
// |
|
232 |
EXPORT_C TInt CPhoneCenRepProxy::SetReal( |
|
233 |
const TUid& aUid, |
|
234 |
const TUint aId, |
|
235 |
const TReal aValue ) |
|
236 |
{ |
|
237 |
CRepository* repository = NULL; |
|
238 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
239 |
if ( err == KErrNone ) |
|
240 |
{ |
|
241 |
err = repository->Set( aId, aValue ); |
|
242 |
} |
|
243 |
delete repository; |
|
244 |
||
245 |
if ( err != KErrNone ) |
|
246 |
{ |
|
247 |
__PHONELOG1( |
|
248 |
EBasic, |
|
249 |
EPhonePhoneapp, |
|
250 |
"CPhoneCenRepProxy::SetReal() error: %d", |
|
251 |
err ); |
|
252 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
253 |
} |
|
254 |
||
255 |
return err; |
|
256 |
} |
|
257 |
||
258 |
// --------------------------------------------------------- |
|
259 |
// CPhoneCenRepProxy::GetInt |
|
260 |
// --------------------------------------------------------- |
|
261 |
// |
|
262 |
EXPORT_C TInt CPhoneCenRepProxy::GetInt( |
|
263 |
const TUid& aUid, |
|
264 |
const TUint aId, |
|
265 |
TInt& aValue ) const |
|
266 |
{ |
|
267 |
CRepository* repository = NULL; |
|
268 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
269 |
if ( err == KErrNone ) |
|
270 |
{ |
|
271 |
err = repository->Get( aId, aValue ); |
|
272 |
delete repository; |
|
273 |
} |
|
274 |
||
275 |
if ( err != KErrNone) |
|
276 |
{ |
|
277 |
__PHONELOG1( |
|
278 |
EBasic, |
|
279 |
EPhonePhoneapp, |
|
280 |
"CPhoneCenRepProxy::GetInt() error: %d", |
|
281 |
err ); |
|
282 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
283 |
} |
|
284 |
||
285 |
return err; |
|
286 |
} |
|
287 |
||
288 |
// --------------------------------------------------------- |
|
289 |
// CPhoneCenRepProxy::GetString |
|
290 |
// --------------------------------------------------------- |
|
291 |
// |
|
292 |
EXPORT_C TInt CPhoneCenRepProxy::GetString( |
|
293 |
const TUid& aUid, |
|
294 |
const TUint aId, |
|
295 |
TDes& aValue ) const |
|
296 |
{ |
|
297 |
CRepository* repository = NULL; |
|
298 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
299 |
if ( err == KErrNone ) |
|
300 |
{ |
|
301 |
err = repository->Get( aId, aValue ); |
|
302 |
delete repository; |
|
303 |
} |
|
304 |
||
305 |
if ( err != KErrNone) |
|
306 |
{ |
|
307 |
__PHONELOG1( |
|
308 |
EBasic, |
|
309 |
EPhonePhoneapp, |
|
310 |
"CPhoneCenRepProxy::GetString() error: %d", |
|
311 |
err ); |
|
312 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
313 |
} |
|
314 |
||
315 |
return err; |
|
316 |
} |
|
317 |
||
318 |
// --------------------------------------------------------- |
|
319 |
// CPhoneCenRepProxy::GetReal |
|
320 |
// --------------------------------------------------------- |
|
321 |
// |
|
322 |
EXPORT_C TInt CPhoneCenRepProxy::GetReal( |
|
323 |
const TUid& aUid, |
|
324 |
const TUint aId, |
|
325 |
TReal& aValue ) const |
|
326 |
{ |
|
327 |
CRepository* repository = NULL; |
|
328 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
329 |
if ( err == KErrNone ) |
|
330 |
{ |
|
331 |
err = repository->Get( aId, aValue ); |
|
332 |
delete repository; |
|
333 |
} |
|
334 |
||
335 |
if ( err != KErrNone) |
|
336 |
{ |
|
337 |
__PHONELOG1( |
|
338 |
EBasic, |
|
339 |
EPhonePhoneapp, |
|
340 |
"CPhoneCenRepProxy::GetReal() error: %d", |
|
341 |
err ); |
|
342 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
343 |
} |
|
344 |
||
345 |
return err; |
|
346 |
} |
|
347 |
||
348 |
// --------------------------------------------------------- |
|
349 |
// CPhoneCenRepProxy::NotifyChangeL |
|
350 |
// --------------------------------------------------------- |
|
351 |
// |
|
352 |
EXPORT_C void CPhoneCenRepProxy::NotifyChangeL( |
|
353 |
const TUid& aUid, |
|
354 |
const TUint aId, |
|
355 |
MPhoneCenRepObserver* aObserver ) |
|
356 |
{ |
|
357 |
// Make sure this request hasn't been request by this observer yet |
|
358 |
if ( FindByUidIdObserver( aUid, aId, aObserver ) == KErrNotFound ) |
|
359 |
{ |
|
360 |
TCenRepObserverTag tag; |
|
361 |
tag.iUid = aUid; |
|
362 |
tag.iId = aId; |
|
363 |
tag.iObserver = aObserver; |
|
364 |
||
365 |
iObserverArray->AppendL( tag ); |
|
366 |
} |
|
367 |
} |
|
368 |
||
369 |
// --------------------------------------------------------- |
|
370 |
// CPhoneCenRepProxy::CancelNotify |
|
371 |
// --------------------------------------------------------- |
|
372 |
// |
|
373 |
EXPORT_C void CPhoneCenRepProxy::CancelNotify( |
|
374 |
MPhoneCenRepObserver* aObserver, |
|
375 |
const TUint aId ) |
|
376 |
{ |
|
377 |
TInt index = FindByObserverId( aObserver, aId ); |
|
378 |
// This class may be destroyded by CCoeEnv::DestroyEnvironmentStatic() |
|
379 |
// before CancelNotifys are called. |
|
380 |
if( index == KErrNotFound ) |
|
381 |
{ |
|
382 |
return; |
|
383 |
} |
|
384 |
||
385 |
__ASSERT_DEBUG( index < iObserverArray->Count(), |
|
386 |
Panic( EPhoneUtilsIndexOutOfBounds ) ); |
|
387 |
||
388 |
TCenRepObserverTag observerTag = iObserverArray->At( index ); |
|
389 |
iObserverArray->Delete( index ); |
|
390 |
} |
|
391 |
||
392 |
// --------------------------------------------------------- |
|
393 |
// CPhoneCenRepProxy::CancelAllObserverNotifies |
|
394 |
// --------------------------------------------------------- |
|
395 |
// |
|
396 |
void CPhoneCenRepProxy::CancelAllObserverNotifies( |
|
397 |
MPhoneCenRepObserver* aObserver ) |
|
398 |
{ |
|
399 |
const TInt count = iObserverArray->Count(); |
|
400 |
for ( TInt i = count-1; i >=0; i-- ) |
|
401 |
{ |
|
402 |
const TCenRepObserverTag& observerTag = iObserverArray->At( i ); |
|
403 |
if ( observerTag.iObserver == aObserver ) |
|
404 |
{ |
|
405 |
iObserverArray->Delete( i ); |
|
406 |
} |
|
407 |
} |
|
408 |
} |
|
409 |
||
410 |
// --------------------------------------------------------- |
|
411 |
// CPhoneCenRepProxy::CancelAllNotifies |
|
412 |
// --------------------------------------------------------- |
|
413 |
// |
|
414 |
void CPhoneCenRepProxy::CancelAllNotifies() |
|
415 |
{ |
|
416 |
const TInt count = iObserverArray->Count(); |
|
417 |
for ( TInt i = count-1; i >=0; i-- ) |
|
418 |
{ |
|
64
6aaf0276100e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
45
diff
changeset
|
419 |
iObserverArray->At( i ); |
37 | 420 |
iObserverArray->Delete( i ); |
421 |
} |
|
422 |
} |
|
423 |
||
424 |
// --------------------------------------------------------- |
|
425 |
// CPhoneCenRepProxy::FindByUidId |
|
426 |
// --------------------------------------------------------- |
|
427 |
// |
|
428 |
TInt CPhoneCenRepProxy::FindByUidId( |
|
429 |
const TUid& aUid, |
|
430 |
const TUint aId, |
|
431 |
TInt aFromIndex ) |
|
432 |
{ |
|
433 |
const TInt count = iObserverArray->Count(); |
|
434 |
TInt result = KErrNotFound; |
|
435 |
for ( TInt i = aFromIndex; i < count; i++ ) |
|
436 |
{ |
|
437 |
const TCenRepObserverTag& observerTag = iObserverArray->At( i ); |
|
438 |
if ( observerTag.iUid == aUid && observerTag.iId == aId ) |
|
439 |
{ |
|
440 |
result = i; |
|
441 |
break; |
|
442 |
} |
|
443 |
} |
|
444 |
return result; |
|
445 |
} |
|
446 |
||
447 |
// --------------------------------------------------------- |
|
448 |
// CPhoneCenRepProxy::FindByObserverId |
|
449 |
// --------------------------------------------------------- |
|
450 |
// |
|
451 |
TInt CPhoneCenRepProxy::FindByObserverId( |
|
452 |
const MPhoneCenRepObserver* aObserver, |
|
453 |
const TUint aId ) |
|
454 |
{ |
|
455 |
const TInt count = iObserverArray->Count(); |
|
456 |
TInt result = KErrNotFound; |
|
457 |
for ( TInt i = 0; i < count; i++ ) |
|
458 |
{ |
|
459 |
const TCenRepObserverTag& observerTag = iObserverArray->At( i ); |
|
460 |
if ( observerTag.iObserver == aObserver && observerTag.iId == aId ) |
|
461 |
{ |
|
462 |
result = i; |
|
463 |
break; |
|
464 |
} |
|
465 |
} |
|
466 |
return result; |
|
467 |
} |
|
468 |
||
469 |
// --------------------------------------------------------- |
|
470 |
// CPhoneCenRepProxy::FindByUidIdObserver |
|
471 |
// --------------------------------------------------------- |
|
472 |
// |
|
473 |
TInt CPhoneCenRepProxy::FindByUidIdObserver( |
|
474 |
const TUid& aUid, |
|
475 |
const TUint aId, |
|
476 |
MPhoneCenRepObserver* aObserver ) |
|
477 |
{ |
|
478 |
TInt pos = FindByUidId( aUid, aId, 0 ); |
|
479 |
TInt result = KErrNotFound; |
|
480 |
while ( pos != KErrNotFound ) |
|
481 |
{ |
|
482 |
__ASSERT_DEBUG( pos < iObserverArray->Count(), |
|
483 |
Panic( EPhoneUtilsIndexOutOfBounds ) ); |
|
484 |
const TCenRepObserverTag& observerTag = iObserverArray->At( pos ); |
|
485 |
if ( observerTag.iObserver == aObserver ) |
|
486 |
{ |
|
487 |
result = pos; |
|
488 |
break; |
|
489 |
} |
|
490 |
||
491 |
pos++; |
|
492 |
pos = FindByUidId( aUid, aId, pos ); |
|
493 |
} |
|
494 |
||
495 |
return result; |
|
496 |
} |
|
497 |
||
498 |
// ----------------------------------------------------------------------------- |
|
499 |
// CPhoneCenRepProxy::IsTelephonyFeatureSupported |
|
500 |
// ----------------------------------------------------------------------------- |
|
501 |
// |
|
502 |
EXPORT_C TBool CPhoneCenRepProxy::IsTelephonyFeatureSupported( |
|
503 |
const TInt aFeatureId ) |
|
504 |
{ |
|
505 |
return ( aFeatureId & iTelephonyVariantReadOnlyValues ); |
|
506 |
} |
|
507 |
||
508 |
// ----------------------------------------------------------------------------- |
|
509 |
// CPhoneCenRepProxy::GetTelephonyVariantData |
|
510 |
// ----------------------------------------------------------------------------- |
|
511 |
// |
|
512 |
TInt CPhoneCenRepProxy::GetTelephonyVariantData() |
|
513 |
{ |
|
514 |
TInt err = KErrNone; |
|
515 |
||
516 |
// Variation data should be unchangable during run-time, |
|
517 |
// therefore, if once succesfully read, later reads are |
|
518 |
// not allowed. |
|
519 |
if( iTelephonyVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue ) |
|
520 |
{ |
|
521 |
err = GetInt( |
|
522 |
KCRUidTelVariation, |
|
523 |
KTelVariationFlags, |
|
524 |
iTelephonyVariantReadOnlyValues ); |
|
525 |
} |
|
526 |
||
527 |
return err; |
|
528 |
} |
|
529 |
||
530 |
// ----------------------------------------------------------------------------- |
|
531 |
// CPhoneCenRepProxy::IsPhoneUIFeatureSupported |
|
532 |
// ----------------------------------------------------------------------------- |
|
533 |
// |
|
534 |
EXPORT_C TBool CPhoneCenRepProxy::IsPhoneUIFeatureSupported( |
|
535 |
const TInt aFeatureId ) |
|
536 |
{ |
|
537 |
return ( aFeatureId & iPhoneUIVariantReadOnlyValues ); |
|
538 |
} |
|
539 |
||
540 |
// ----------------------------------------------------------------------------- |
|
541 |
// CPhoneCenRepProxy::GetPhoneUIVariantData |
|
542 |
// ----------------------------------------------------------------------------- |
|
543 |
// |
|
544 |
TInt CPhoneCenRepProxy::GetPhoneUIVariantData() |
|
545 |
{ |
|
546 |
TInt err = KErrNone; |
|
547 |
/* |
|
548 |
// Variation data should be unchangable during run-time, |
|
549 |
// therefore, if once succesfully read, later reads are |
|
550 |
// not allowed. |
|
551 |
if ( iPhoneUIVariantReadOnlyValues == KPhoneVariantReadOnlyDefaultValue ) |
|
552 |
{ |
|
553 |
err = GetInt( |
|
554 |
KCRUidPhoneAppS60Variation, |
|
555 |
KPhoneAppS60VariationFlags, |
|
556 |
iPhoneAppS60VariantReadOnlyValues ); |
|
557 |
} |
|
558 |
*/ |
|
559 |
return err; |
|
560 |
} |
|
561 |
||
562 |
// --------------------------------------------------------- |
|
563 |
// CPhoneCenRepProxy::Find |
|
564 |
// --------------------------------------------------------- |
|
565 |
// |
|
566 |
EXPORT_C TInt CPhoneCenRepProxy::Find( |
|
567 |
const TUid& aUid, |
|
568 |
const TUint32 aPartial, |
|
569 |
const TUint32 aMask, |
|
570 |
RArray<TUint32>& aValues ) const |
|
571 |
{ |
|
572 |
CRepository* repository = NULL; |
|
573 |
TRAPD( err, repository = CRepository::NewL( aUid ) ); |
|
574 |
if ( err == KErrNone ) |
|
575 |
{ |
|
576 |
TRAP( err, repository->FindL( aPartial, aMask, aValues ) ); |
|
577 |
delete repository; |
|
578 |
} |
|
579 |
||
580 |
if ( err != KErrNone) |
|
581 |
{ |
|
582 |
__PHONELOG1( |
|
583 |
EBasic, |
|
584 |
EPhonePhoneapp, |
|
585 |
"CPhoneCenRepProxy::GetInt() error: %d", |
|
586 |
err ); |
|
587 |
__ASSERT_DEBUG( EFalse, Panic( EPhoneUtilsInvariant ) ); |
|
588 |
} |
|
589 |
||
590 |
return err; |
|
591 |
} |
|
592 |
||
593 |
// ----------------------------------------------------------------------------- |
|
594 |
// CPhoneCenRepProxy::FetchValuesFromCenRepL |
|
595 |
// ----------------------------------------------------------------------------- |
|
596 |
// |
|
597 |
EXPORT_C void CPhoneCenRepProxy::FetchValuesFromCenRepL( |
|
598 |
TPhoneCmdParamAppInfo& aAppInfo, |
|
599 |
TKeyCode aCode, |
|
600 |
HBufC8* aAppParam, |
|
601 |
TBool& aValuesFetched ) |
|
602 |
{ |
|
603 |
const TUint32 KPartialKey = 0xFF0000; |
|
604 |
const TUint32 KLaunchGroupIdMask = 0x00FF00; |
|
605 |
const TUint32 KLaunchPlaceIdMask = 0x0000FF; |
|
606 |
const TUint32 KIdmask = 0xFF0000; |
|
607 |
||
608 |
const TUint32 KLaunchGroupIdShift = 8; |
|
609 |
const TInt KUidId = 2; |
|
610 |
const TInt KParamId = 3; |
|
611 |
||
612 |
RArray<TUint32> foundKeys; |
|
613 |
CleanupClosePushL( foundKeys ); |
|
614 |
||
615 |
CRepository* repository = NULL; |
|
616 |
repository = CRepository::NewL( KCRUidTelPrivateVariation ); |
|
617 |
||
618 |
TInt err( KErrNone ); |
|
619 |
||
620 |
if ( repository ) |
|
621 |
{ |
|
622 |
CleanupStack::PushL( repository ); |
|
623 |
err = repository->FindL( KPartialKey, KIdmask, foundKeys ); |
|
624 |
} |
|
625 |
||
626 |
if ( KErrNone != err ) |
|
627 |
{ |
|
628 |
__PHONELOG1( |
|
629 |
EBasic, |
|
630 |
EPhonePhoneapp, |
|
631 |
"CPhoneCenRepProxy::FetchValuesFromCenRepL() error: %d", |
|
632 |
err ); |
|
633 |
User::Leave( err ); |
|
634 |
} |
|
635 |
||
636 |
TInt uid(0); |
|
637 |
TInt code(0); |
|
638 |
HBufC* param = HBufC::NewL( KMaxParamLength ); |
|
639 |
TPtr paramPtr = param->Des(); |
|
640 |
CleanupStack::PushL( param ); |
|
641 |
||
642 |
for ( TInt i = 0; i < foundKeys.Count(); i++ ) |
|
643 |
{ |
|
644 |
User::LeaveIfError( repository->Get( |
|
645 |
foundKeys[i], code ) ); |
|
646 |
||
647 |
//peekIndex is used to check if foundKeys-array has a next |
|
648 |
//element. For this reason (i+1) is used. |
|
649 |
TInt peekIndex(i+1); |
|
650 |
TInt peekGroupId(0); |
|
651 |
TInt launchGroupID |
|
652 |
= ( foundKeys[i] & KLaunchGroupIdMask ) >> KLaunchGroupIdShift; |
|
653 |
||
654 |
if( peekIndex < foundKeys.Count() && code == aCode ) |
|
655 |
{ |
|
656 |
peekGroupId = |
|
657 |
( foundKeys[peekIndex] & KLaunchGroupIdMask ) |
|
658 |
>> KLaunchGroupIdShift; |
|
659 |
||
660 |
// Check that group Id is the same as for the key fetched earlier |
|
661 |
// (KKeyId) and the key id for this key is (KUidId). |
|
662 |
if( launchGroupID == peekGroupId && |
|
663 |
KUidId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) ) |
|
664 |
{ |
|
665 |
User::LeaveIfError( repository->Get( |
|
666 |
foundKeys[++i], uid ) ); |
|
667 |
} |
|
668 |
||
669 |
peekIndex = i+1; // peekIndex update. The actual value is dependant on |
|
670 |
// whether variable i was incremented or not in previous if. |
|
671 |
||
672 |
if( peekIndex < foundKeys.Count() ) |
|
673 |
{ |
|
674 |
peekGroupId = |
|
675 |
( foundKeys[peekIndex] & KLaunchGroupIdMask ) |
|
676 |
>> KLaunchGroupIdShift; |
|
677 |
// Check that group Id is still the same as for the keys fetched |
|
678 |
// earlier (KKeyId and KUidId) |
|
679 |
// and the key id for this key is (KParamId). |
|
680 |
if( launchGroupID == peekGroupId && |
|
681 |
KParamId == ( foundKeys[peekIndex] & KLaunchPlaceIdMask ) ) |
|
682 |
{ |
|
683 |
User::LeaveIfError( repository->Get( |
|
684 |
foundKeys[++i], paramPtr ) ); |
|
685 |
break; |
|
686 |
} |
|
687 |
} |
|
688 |
} |
|
689 |
else |
|
690 |
{ |
|
691 |
i++; // skip uid index (wrong code) |
|
692 |
i++; // skip parameter index (wrong code) |
|
693 |
} |
|
694 |
} |
|
695 |
||
696 |
if ( uid != 0 ) |
|
697 |
{ |
|
698 |
aAppInfo.SetAppUid( TUid::Uid( uid ) ); |
|
699 |
// TDesc16 to TDesc8 conversion. Central repository supports only |
|
700 |
// 16 bit buffers, setParam function in TPhoneCmdParamAppInfo wants |
|
701 |
// 8 bit. |
|
702 |
TPtr8 eightBitParamPtr = aAppParam->Des(); |
|
703 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( eightBitParamPtr, |
|
704 |
paramPtr ); |
|
705 |
||
706 |
aAppInfo.SetParam( eightBitParamPtr ); |
|
707 |
aValuesFetched = ETrue; |
|
708 |
} |
|
709 |
||
710 |
CleanupStack::PopAndDestroy( param ); |
|
711 |
CleanupStack::PopAndDestroy( repository ); |
|
712 |
CleanupStack::PopAndDestroy( &foundKeys ); |
|
713 |
} |
|
714 |
||
715 |
// End of File |