|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include "CTcSIPContext.h" |
|
21 #include "TCmdSetRepositoryIntValue.h" |
|
22 #include "SIPConstants.h" |
|
23 |
|
24 |
|
25 /** |
|
26 * KParamRepositoryUid identifies the Central repository. |
|
27 * This parameter is mandatory |
|
28 * |
|
29 * KParamRepositoryParameterKey identifies the integer type parameter within |
|
30 * the selected central repository. This parameter is mandatory. |
|
31 * |
|
32 * KParamRepositoryParameterValue is the value to be set for the parameter. |
|
33 * This parameter is optional. If it is not specified, then the parameter is |
|
34 * deleted from the repository. |
|
35 * |
|
36 * |
|
37 * INPUT: |
|
38 * Headers: - |
|
39 * Parameters: KParamRepositoryUid, |
|
40 * KParamRepositoryParameterKey, |
|
41 * KParamRepositoryParameterValue |
|
42 * IDs: - |
|
43 * |
|
44 * OUTPUT: |
|
45 * Parameters: - |
|
46 * IDs: - |
|
47 */ |
|
48 void TCmdSetRepositoryIntValue::ExecuteL() |
|
49 { |
|
50 // If KParamRepositoryParameterValue is not specified, remove the |
|
51 // parameter from repository. |
|
52 const TInt KDefaultValue = -984079; |
|
53 TInt repositoryUidValue = ExtractIntegerL( KParamRepositoryUid, |
|
54 KDefaultValue, |
|
55 ETrue ); |
|
56 TUid repositoryUid = TUid::Uid( repositoryUidValue ); |
|
57 |
|
58 TInt paramKey = ExtractIntegerL( KParamRepositoryParameterKey, |
|
59 KDefaultValue, |
|
60 ETrue ); |
|
61 TInt paramValue = ExtractIntegerL( KParamRepositoryParameterValue, |
|
62 KDefaultValue, |
|
63 EFalse /* optional */ ); |
|
64 TBool isValueDefined = ( paramValue != KDefaultValue ); |
|
65 |
|
66 TInt err( KErrNone ); |
|
67 CRepository* repository = CRepository::NewLC( repositoryUid ); |
|
68 |
|
69 if ( isValueDefined ) |
|
70 { |
|
71 err = repository->Set( paramKey, paramValue ); |
|
72 } |
|
73 else |
|
74 { |
|
75 err = repository->Delete( paramKey ); |
|
76 if ( err == KErrNotFound ) |
|
77 { |
|
78 // Trying to delete a non-existent parameter is not an error |
|
79 err = KErrNone; |
|
80 } |
|
81 } |
|
82 |
|
83 CleanupStack::PopAndDestroy( repository ); |
|
84 |
|
85 User::LeaveIfError( err ); |
|
86 } |
|
87 |
|
88 TBool TCmdSetRepositoryIntValue::Match( const TTcIdentifier& aId ) |
|
89 { |
|
90 return TTcSIPCommandBase::Match( aId, _L8("SetRepositoryIntValue") ); |
|
91 } |
|
92 |
|
93 TTcCommandBase* TCmdSetRepositoryIntValue::CreateL( MTcTestContext& aContext ) |
|
94 { |
|
95 return new( ELeave ) TCmdSetRepositoryIntValue( aContext ); |
|
96 } |