|
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 "TCmdGetRepositoryIntValue.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 TCmdGetRepositoryIntValue::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 |
|
62 TInt err( KErrNone ); |
|
63 CRepository* repository = CRepository::NewLC( repositoryUid ); |
|
64 |
|
65 TInt repValue = 0; |
|
66 |
|
67 if ( paramKey != KDefaultValue ) |
|
68 { |
|
69 err = repository->Get( paramKey, repValue ); |
|
70 } |
|
71 else |
|
72 { |
|
73 err = repository->Delete( paramKey ); |
|
74 if ( err == KErrNotFound ) |
|
75 { |
|
76 // Trying to delete a non-existent parameter is not an error |
|
77 err = KErrNone; |
|
78 } |
|
79 } |
|
80 |
|
81 CleanupStack::PopAndDestroy( repository ); |
|
82 |
|
83 AddIntegerResponseL( KParamRepositoryIntValue, repValue ); |
|
84 |
|
85 User::LeaveIfError( err ); |
|
86 } |
|
87 |
|
88 TBool TCmdGetRepositoryIntValue::Match( const TTcIdentifier& aId ) |
|
89 { |
|
90 return TTcSIPCommandBase::Match( aId, _L8("GetRepositoryIntValue") ); |
|
91 } |
|
92 |
|
93 TTcCommandBase* TCmdGetRepositoryIntValue::CreateL( MTcTestContext& aContext ) |
|
94 { |
|
95 return new( ELeave ) TCmdGetRepositoryIntValue( aContext ); |
|
96 } |