|
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: Contains the implementation of class CSPServiceSettingsHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "cspservicesettingshandler.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <spsettings.h> |
|
24 #include <spentry.h> |
|
25 |
|
26 // INTERNAL INCLUDES |
|
27 #include "csplogger.h" |
|
28 |
|
29 |
|
30 _LIT(KLineNameVoice, "CS"); |
|
31 |
|
32 |
|
33 |
|
34 CSPServiceSettingsHandler* CSPServiceSettingsHandler::NewL( ) |
|
35 { |
|
36 CSPServiceSettingsHandler* self |
|
37 = new ( ELeave ) CSPServiceSettingsHandler( ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL( ); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor of the object. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CSPServiceSettingsHandler::~CSPServiceSettingsHandler( ) |
|
49 { |
|
50 CSPLOGSTRING(CSPOBJECT, "CSPServiceSettingsHandler::~CSPServiceSettingsHandler()" ); |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Finds service ID by name. |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CSPServiceSettingsHandler::FindByNameL( const TDesC& aName, |
|
58 TUint32& aServiceId ) |
|
59 { |
|
60 CSPLOGSTRING(CSPINT, "CSPServiceSettingsHandler::FindByNameL()" ); |
|
61 CSPLOGSTRING2(CSPINT, "CSPServiceSettingsHandler::FindByNameL() Name=%S", &aName ); |
|
62 CSPSettings* settingsApi = CSPSettings::NewLC(); |
|
63 RIdArray idArray; |
|
64 CleanupClosePushL( idArray ); |
|
65 TInt err = settingsApi->FindServiceIdsL( idArray ); |
|
66 |
|
67 TBool found = EFalse; |
|
68 if ( KErrNone == err ) |
|
69 { |
|
70 TInt idCount = idArray.Count(); |
|
71 if( idCount > 0 ) |
|
72 { |
|
73 |
|
74 for ( TInt i = 0; !found && i < idCount; i++ ) |
|
75 { |
|
76 CSPEntry* entry = CSPEntry::NewLC(); |
|
77 TInt ferr = settingsApi->FindEntryL( idArray[i], *entry ); |
|
78 |
|
79 if( ferr == KErrNone |
|
80 && aName.Compare( entry->GetServiceName() ) == 0 ) |
|
81 { |
|
82 aServiceId = idArray[i]; |
|
83 found = ETrue; |
|
84 } |
|
85 CleanupStack::PopAndDestroy( entry ); |
|
86 } |
|
87 } |
|
88 else |
|
89 { |
|
90 err = KErrNotFound; |
|
91 } |
|
92 } |
|
93 |
|
94 if ( !found ) |
|
95 { |
|
96 err = KErrNotFound; |
|
97 } |
|
98 |
|
99 CleanupStack::PopAndDestroy( &idArray ); |
|
100 CleanupStack::PopAndDestroy( settingsApi ); |
|
101 CSPLOGSTRING3(CSPINT, "CSProvider::FindByNameL() err = %d serv_id = %u", |
|
102 err, aServiceId ); |
|
103 User::LeaveIfError( err ); |
|
104 } |
|
105 |
|
106 |
|
107 |
|
108 TInt CSPServiceSettingsHandler::ReadCSServiceId( TUint32& aServiceId ) |
|
109 { |
|
110 TRAPD( err, FindByNameL( KLineNameVoice, aServiceId ) ); |
|
111 |
|
112 if ( err ) |
|
113 { |
|
114 CSPLOGSTRING2(CSPINT, |
|
115 "CSPServiceSettingsHandler::FindByNameL() leave %d", |
|
116 err ); |
|
117 } |
|
118 return err; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Constructs the requester. |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 CSPServiceSettingsHandler::CSPServiceSettingsHandler( ) |
|
126 { |
|
127 CSPLOGSTRING(CSPOBJECT, "CSPServiceSettingsHandler::CSPServiceSettingsHandler()" ); |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Constructs the requester in the second phase. |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CSPServiceSettingsHandler::ConstructL( ) |
|
135 { |
|
136 } |
|
137 |
|
138 |