|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "mussettingskeys.h" |
|
20 #include "centralrepository.h" |
|
21 #include "e32property.h" |
|
22 #include <badesca.h> |
|
23 |
|
24 /// CenRep UIDs and keys |
|
25 const TUid KCRUidSIPClientResolverConfig = { 0x10282EE7 }; |
|
26 |
|
27 const TUid KCRUidInCallVolume = {0x102828B1}; |
|
28 const TUint32 KTelIncallEarVolume = 0x00000001; |
|
29 const TUint32 KTelIncallLoudspeakerVolume = 0x00000002; |
|
30 |
|
31 |
|
32 // Values for static variables |
|
33 MusSettingsKeys::TOperatorVariant CRepository::iOperatorVariant = |
|
34 MusSettingsKeys::EStandard; |
|
35 TBool CRepository::iEmulateSawfishRepository = EFalse; |
|
36 HBufC8* CRepository::iStaticAvcConfigKeys = NULL; |
|
37 TBool CRepository::iStaticWriteAvcKeysToStaticData = EFalse; |
|
38 TInt CRepository::iForceFailWithCode = KErrNone; |
|
39 TInt CRepository::iStaticEncoderUid = 0; |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CRepository* CRepository::NewL( TUid aRepositoryUid ) |
|
47 { |
|
48 CRepository* self = CRepository::NewLC( aRepositoryUid ); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CRepository* CRepository::NewLC( TUid aRepositoryUid ) |
|
59 { |
|
60 CRepository* self = new (ELeave) CRepository( aRepositoryUid ); |
|
61 CleanupStack::PushL( self ); |
|
62 |
|
63 // This UID cannot be used in normal variant |
|
64 if ( aRepositoryUid == KCRUidSIPClientResolverConfig && |
|
65 !iEmulateSawfishRepository ) |
|
66 { |
|
67 User::Leave( KErrNotFound ); |
|
68 } |
|
69 |
|
70 // Add a few keys |
|
71 if ( self->iRepositoryUid == KCRUidInCallVolume ) |
|
72 { |
|
73 User::LeaveIfError( self->Set ( KTelIncallEarVolume, 4 ) ); |
|
74 User::LeaveIfError( self->Set ( KTelIncallLoudspeakerVolume, 4 ) ); |
|
75 } |
|
76 else if ( self->iRepositoryUid == MusSettingsKeys::KRepositoryUid ) |
|
77 { |
|
78 // Set default values for numeric values which are not handled by static |
|
79 // variables |
|
80 User::LeaveIfError( |
|
81 self->Set ( MusSettingsKeys::KActivation, |
|
82 MusSettingsKeys::EAlwaysActive ) ); |
|
83 User::LeaveIfError( |
|
84 self->Set ( MusSettingsKeys::KAuditoryNotification, |
|
85 MusSettingsKeys::EAuditoryNotificationOff ) ); |
|
86 User::LeaveIfError( |
|
87 self->Set ( MusSettingsKeys::KPopupNotification, |
|
88 MusSettingsKeys::EPopupNotificationOff ) ); |
|
89 User::LeaveIfError( |
|
90 self->Set ( MusSettingsKeys::KPopupNotificationType, |
|
91 MusSettingsKeys::ENotificationTypeQueryUser ) ); |
|
92 User::LeaveIfError( |
|
93 self->Set ( MusSettingsKeys::KEdgeDtmSupport, |
|
94 MusSettingsKeys::EDtmModeNotAllowed ) ); |
|
95 User::LeaveIfError( |
|
96 self->Set ( MusSettingsKeys::KForceInternetSignaling, |
|
97 MusSettingsKeys::EFollowProfileConfiguration ) ); |
|
98 User::LeaveIfError( |
|
99 self->Set ( MusSettingsKeys::KAutoRecord, |
|
100 MusSettingsKeys::EAutoRecordOn ) ); |
|
101 User::LeaveIfError( |
|
102 self->Set ( MusSettingsKeys::KSipProfileId, |
|
103 0 /*default profile*/ ) ); |
|
104 User::LeaveIfError( |
|
105 self->Set ( MusSettingsKeys::KUiOrientation, |
|
106 MusSettingsKeys::EPortrait ) ); |
|
107 User::LeaveIfError( |
|
108 self->Set ( MusSettingsKeys::KCapabilityQuery, |
|
109 MusSettingsKeys::ENoOptions ) ); |
|
110 |
|
111 // No variation keys defined |
|
112 } |
|
113 |
|
114 self->iDesC8Values = new (ELeave) CDesC8ArrayFlat( 1 ); |
|
115 |
|
116 return self; |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C CRepository::~CRepository() |
|
125 { |
|
126 iKeys.Reset(); |
|
127 iValues.Reset(); |
|
128 iDesC8Keys.Reset(); |
|
129 delete iDesC8Values; |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C TInt CRepository::Create(TUint32 /*aKey*/, TInt /*aValue*/ ) |
|
138 { |
|
139 return KErrNotSupported; |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C TInt CRepository::Create(TUint32 /*aKey*/, const TDesC8& /*aValue*/) |
|
148 { |
|
149 return KErrNotSupported; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C TInt CRepository::Delete( TUint32 /*aPartialKey*/, |
|
158 TUint32 /*aMask*/, |
|
159 TUint32& /*aErrorKey*/ ) |
|
160 { |
|
161 return KErrNotSupported; |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C TInt CRepository::Get(TUint32 aKey, TInt& aValue) |
|
170 { |
|
171 // fail simulation |
|
172 if ( iForceFailWithCode != KErrNone ) |
|
173 { |
|
174 TInt returnValue = iForceFailWithCode; |
|
175 iForceFailWithCode = KErrNone; |
|
176 return returnValue; |
|
177 } |
|
178 |
|
179 // Setting of encoding device |
|
180 if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid && |
|
181 aKey == MusSettingsKeys::KEncodingDevice ) |
|
182 { |
|
183 aValue = CRepository::iStaticEncoderUid; |
|
184 return KErrNone; |
|
185 } |
|
186 |
|
187 if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid && |
|
188 aKey == MusSettingsKeys::KOperatorVariant ) |
|
189 { |
|
190 aValue = CRepository::iOperatorVariant; |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 TInt err = RProperty::Get( MusSettingsKeys::KRepositoryUid, aKey, aValue ); |
|
195 if ( err != KErrNone ) |
|
196 { |
|
197 for ( TInt i = 0; i < iKeys.Count(); ++i ) |
|
198 { |
|
199 if ( iKeys[i] == aKey ) |
|
200 { |
|
201 aValue = iValues[i]; |
|
202 return KErrNone; |
|
203 } |
|
204 } |
|
205 } |
|
206 |
|
207 return err; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue ) |
|
215 { |
|
216 // fail simulation |
|
217 if ( iForceFailWithCode != KErrNone ) |
|
218 { |
|
219 TInt returnValue = iForceFailWithCode; |
|
220 iForceFailWithCode = KErrNone; |
|
221 return returnValue; |
|
222 } |
|
223 |
|
224 if ( aKey == MusSettingsKeys::KEncoderConfigurationInfo && |
|
225 iStaticAvcConfigKeys ) |
|
226 { |
|
227 // Use static data instead of member data |
|
228 aValue.Copy( *iStaticAvcConfigKeys ); |
|
229 return KErrNone; |
|
230 } |
|
231 |
|
232 for ( TInt i = 0; i < iDesC8Keys.Count(); ++i ) |
|
233 { |
|
234 if ( iDesC8Keys[i] == aKey ) |
|
235 { |
|
236 TPtrC8 value = iDesC8Values->MdcaPoint( i ); |
|
237 aValue.Copy( value ); |
|
238 return KErrNone; |
|
239 } |
|
240 } |
|
241 |
|
242 return KErrNotFound; |
|
243 } |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C TInt CRepository::Set( TUint32 aKey, const TDesC8& aValue ) |
|
251 { |
|
252 TBool error( EFalse ); |
|
253 |
|
254 // fail simulation |
|
255 if ( iForceFailWithCode != KErrNone ) |
|
256 { |
|
257 error = iForceFailWithCode; |
|
258 iForceFailWithCode = KErrNone; |
|
259 return error; |
|
260 } |
|
261 |
|
262 TBool keyFound( EFalse ); |
|
263 |
|
264 // Replace possibly existing value |
|
265 for ( TInt i = 0; i < iDesC8Keys.Count(); ++i ) |
|
266 { |
|
267 if ( iDesC8Keys[i] == aKey ) |
|
268 { |
|
269 iDesC8Values->Delete( i ); |
|
270 iDesC8Values->Compress(); |
|
271 TRAP( error, iDesC8Values->InsertL( i, aValue ) ); |
|
272 if ( error != KErrNone ) |
|
273 { |
|
274 return error; |
|
275 } |
|
276 |
|
277 keyFound = ETrue; |
|
278 } |
|
279 } |
|
280 |
|
281 // If no existing value, add new one |
|
282 if ( !keyFound ) |
|
283 { |
|
284 error = iDesC8Keys.Append( aKey ); |
|
285 if ( error == KErrNone ) |
|
286 { |
|
287 TRAP( error, iDesC8Values->AppendL( aValue ) ) |
|
288 } |
|
289 } |
|
290 |
|
291 if ( iStaticWriteAvcKeysToStaticData && |
|
292 aKey == MusSettingsKeys::KEncoderConfigurationInfo ) |
|
293 { |
|
294 // Write also to static data |
|
295 TRAP( error, SetStubAvcConfigKeysL( aValue ) ); |
|
296 } |
|
297 |
|
298 return error; |
|
299 } |
|
300 |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes& aValue) |
|
307 { |
|
308 // fail simulation |
|
309 if ( iForceFailWithCode != KErrNone ) |
|
310 { |
|
311 TInt returnValue = iForceFailWithCode; |
|
312 iForceFailWithCode = KErrNone; |
|
313 return returnValue; |
|
314 } |
|
315 |
|
316 _LIT( KSampleValue, "\\data\\videos\\"); |
|
317 TInt err = RProperty::Get( MusSettingsKeys::KRepositoryUid, aKey, aValue ); |
|
318 if ( err != KErrNone ) |
|
319 { |
|
320 aValue.Append( KSampleValue() ); |
|
321 } |
|
322 return KErrNone; |
|
323 } |
|
324 |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C TInt CRepository::Set(TUint32 /*aKey*/, const TDesC& /*aValue*/) |
|
331 { |
|
332 return KErrNotSupported; |
|
333 } |
|
334 |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 EXPORT_C TInt CRepository::Set(TUint32 aKey, TInt aValue) |
|
341 { |
|
342 // fail simulation |
|
343 if ( iForceFailWithCode != KErrNone ) |
|
344 { |
|
345 TInt returnValue = iForceFailWithCode; |
|
346 iForceFailWithCode = KErrNone; |
|
347 return returnValue; |
|
348 } |
|
349 |
|
350 // Setting of encoding device |
|
351 if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid && |
|
352 aKey == MusSettingsKeys::KEncodingDevice ) |
|
353 { |
|
354 CRepository::iStaticEncoderUid = aValue; |
|
355 return KErrNone; |
|
356 } |
|
357 |
|
358 // Setting of operator variant value |
|
359 if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid && |
|
360 aKey == MusSettingsKeys::KOperatorVariant ) |
|
361 { |
|
362 CRepository::iOperatorVariant = |
|
363 ( MusSettingsKeys::TOperatorVariant ) aValue; |
|
364 return KErrNone; |
|
365 } |
|
366 |
|
367 RProperty::Set( MusSettingsKeys::KRepositoryUid, aKey, aValue ); |
|
368 |
|
369 // Setting of any other value |
|
370 for ( TInt i = 0; i < iKeys.Count(); ++i ) |
|
371 { |
|
372 if ( iKeys[i] == aKey ) |
|
373 { |
|
374 iValues[i] = aValue; |
|
375 return KErrNone; |
|
376 } |
|
377 } |
|
378 |
|
379 // No wise error handling implemented |
|
380 TInt error = iKeys.Append( aKey ); |
|
381 if ( error == KErrNone ) |
|
382 { |
|
383 error = iValues.Append( aValue ); |
|
384 } |
|
385 |
|
386 return error; |
|
387 } |
|
388 |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 EXPORT_C TInt CRepository::FindL( TUint32 /*aPartialKey*/, |
|
395 TUint32 /*aMask*/, |
|
396 RArray<TUint32>& /*aFoundKeys*/ ) |
|
397 { |
|
398 User::Leave( KErrNotSupported ); |
|
399 return KErrNotSupported; |
|
400 } |
|
401 |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 EXPORT_C TInt CRepository::FindEqL( TUint32 /*aPartialKey*/, |
|
408 TUint32 /*aMask*/, |
|
409 const TDesC8& /*aValue*/, |
|
410 RArray<TUint32>& /*aFoundKeys*/ ) |
|
411 { |
|
412 User::Leave( KErrNotSupported ); |
|
413 return KErrNotSupported; |
|
414 } |
|
415 |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 EXPORT_C TInt CRepository::StartTransaction( TTransactionMode /*aMode*/ ) |
|
422 { |
|
423 return KErrNotSupported; |
|
424 } |
|
425 |
|
426 |
|
427 /// ----------------------------------------------------------------------------- |
|
428 // |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C TInt CRepository::CommitTransaction(TUint32& /*aKeyInfo*/) |
|
432 { |
|
433 return KErrNotSupported; |
|
434 } |
|
435 |
|
436 |
|
437 |
|
438 // ------- Functions that are not present in real CRepository but are ---------- |
|
439 // ------- defined here exclusively for stubbing purposes ---------- |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CRepository::ResetKeysAndValues() |
|
446 { |
|
447 iKeys.Reset(); |
|
448 iValues.Reset(); |
|
449 |
|
450 iDesC8Keys.Reset(); |
|
451 iDesC8Values->Reset(); |
|
452 |
|
453 iEmulateSawfishRepository = EFalse; |
|
454 |
|
455 delete iStaticAvcConfigKeys; |
|
456 iStaticAvcConfigKeys = NULL; |
|
457 } |
|
458 |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CRepository::SetStubAvcConfigKeysL( const TDesC8& aConfigKeys ) |
|
465 { |
|
466 HBufC8* newConfigKeys = aConfigKeys.AllocL(); |
|
467 CRepository::DeleteStubAvcConfigKeys(); |
|
468 iStaticAvcConfigKeys = newConfigKeys; |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 |
|
476 void CRepository::DeleteStubAvcConfigKeys() |
|
477 { |
|
478 delete iStaticAvcConfigKeys; |
|
479 iStaticAvcConfigKeys = NULL; |
|
480 } |
|
481 |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 CRepository::CRepository( TUid aRepositoryUid ) |
|
488 :iRepositoryUid( aRepositoryUid ) |
|
489 { |
|
490 } |
|
491 |
|
492 |