|
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: Service Provider Settings API, VoIP utilities |
|
15 * implementation file. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "spsettingsvoiputils.h" |
|
21 |
|
22 #include "spsettingsengine.h" |
|
23 #include "spproperty.h" |
|
24 #include "spdefinitions.h" |
|
25 #include "spdefaultvalues.h" |
|
26 |
|
27 #include <featmgr.h> |
|
28 #include <centralrepository.h> |
|
29 #include <settingsinternalcrkeys.h> |
|
30 |
|
31 #include "spsapilogger.h" // For logging |
|
32 |
|
33 // Preferred Telephony value is PS call |
|
34 const TInt KRCSEInternetCallPreferred = 1; |
|
35 |
|
36 // Dynamic VoIP off |
|
37 const TInt KVoIPOFF = 0; |
|
38 |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Constructor |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CSPSettingsVoIPUtils::CSPSettingsVoIPUtils() |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CSPSettingsVoIPUtils::ConstructL() |
|
55 { |
|
56 XSPSLOGSTRING( "CSPSettingsVoIPUtils::ConstructL() - IN" ); |
|
57 iSettingsEngine = CSPSettingsEngine::NewL(); |
|
58 XSPSLOGSTRING( "CSPSettingsVoIPUtils::ConstructL() - OUT" ); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CSPSettingsVoIPUtils* CSPSettingsVoIPUtils::NewL() |
|
66 { |
|
67 CSPSettingsVoIPUtils* self = CSPSettingsVoIPUtils::NewLC(); |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Constructor |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CSPSettingsVoIPUtils* CSPSettingsVoIPUtils::NewLC() |
|
77 { |
|
78 CSPSettingsVoIPUtils* self = new( ELeave ) CSPSettingsVoIPUtils; |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Destructor |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() |
|
89 { |
|
90 XSPSLOGSTRING( |
|
91 "CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() - IN" ); |
|
92 delete iSettingsEngine; |
|
93 XSPSLOGSTRING( |
|
94 "CSPSettingsVoIPUtils::~CSPSettingsVoIPUtils() - OUT" ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // VoIPProfilesExistL - API method |
|
99 // Returns ETrue if VoIP sub service plugin ID have been set for some service. |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TBool CSPSettingsVoIPUtils::VoIPProfilesExistL() const |
|
103 { |
|
104 XSPSLOGSTRING( |
|
105 "CSPSettingsVoIPUtils::VoIPProfilesExistL() - IN" ); |
|
106 |
|
107 TBool profileExists( EFalse ); |
|
108 |
|
109 // Get all service IDs |
|
110 RArray<TServiceId> services; |
|
111 CleanupClosePushL( services ); |
|
112 iSettingsEngine->FindServiceIdsL( services ); |
|
113 const TInt count( services.Count() ); |
|
114 |
|
115 // Check if some service has VoIP sub service plug-in ID |
|
116 TInt err( 0 ); |
|
117 CSPProperty* property = CSPProperty::NewLC(); |
|
118 for( TInt i = 0; i < count && !profileExists; ++i ) |
|
119 { |
|
120 TServiceId id = services[ i ]; |
|
121 if( id == KSPDefaultVoIPServiceId ) |
|
122 { |
|
123 continue; |
|
124 } |
|
125 |
|
126 err = iSettingsEngine->FindPropertyL( id, |
|
127 EPropertyVoIPSubServicePluginId, |
|
128 *property ); |
|
129 |
|
130 profileExists = ( KErrNone == err ? ETrue : EFalse ); |
|
131 } |
|
132 |
|
133 CleanupStack::PopAndDestroy( property ); |
|
134 CleanupStack::PopAndDestroy( &services ); |
|
135 |
|
136 |
|
137 XSPSLOGSTRING( |
|
138 "CSPSettingsVoIPUtils::VoIPProfilesExistL() - OUT" ); |
|
139 return profileExists; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // IsVoIPSupported - API method |
|
144 // Returns ETrue if following items are ON: |
|
145 // Common Voip (Feature Manager) |
|
146 // Dynamic VoIP (Telephony settings) |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C TBool CSPSettingsVoIPUtils::IsVoIPSupported( ) const |
|
150 { |
|
151 XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsVoIPSupported( ) - IN" ); |
|
152 |
|
153 TBool voipSupport( EFalse ); |
|
154 TRAPD( err, voipSupport = IsVoIPSupportedL() ); |
|
155 |
|
156 if ( err != KErrNone ) |
|
157 { |
|
158 voipSupport = EFalse; |
|
159 } |
|
160 |
|
161 XSPSLOGSTRING( "CSPSettingsVoIPUtils::IsVoIPSupported( ) - OUT" ); |
|
162 return voipSupport; |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // IsPreferredTelephonyVoIP - API method |
|
167 // Returns ETrue if following items are ON: |
|
168 // Common Voip (Feature Manager) |
|
169 // Dynamic VoIP (Telephony settings) |
|
170 // Preferred telephony (Rich call settings) |
|
171 // + there is at least one SIP-VoIP profile stored |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C TBool CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() const |
|
175 { |
|
176 XSPSLOGSTRING( |
|
177 "CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() - IN" ); |
|
178 |
|
179 // Check that VoIP is supported |
|
180 TBool voipSupported( IsVoIPSupported() ); |
|
181 |
|
182 XSPSLOGSTRING2( |
|
183 "CSPSettingsVoIPUtils::VoipSupported: %d",voipSupported ); |
|
184 |
|
185 // Check the preferred telephony |
|
186 TBool voipPreferred( EFalse ); |
|
187 TRAP_IGNORE( voipPreferred = IsPreferredTelephonyVoIPL() ); |
|
188 |
|
189 XSPSLOGSTRING2( |
|
190 "CSPSettingsVoIPUtils::VoipPreferred: %d", voipPreferred ); |
|
191 |
|
192 XSPSLOGSTRING( |
|
193 "CSPSettingsVoIPUtils::IsPreferredTelephonyVoIP() - OUT" ); |
|
194 return voipPreferred && voipSupported; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // Get id of the preferred service |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C TInt CSPSettingsVoIPUtils::GetPreferredService( TUint& aServiceId ) |
|
202 const |
|
203 { |
|
204 XSPSLOGSTRING( |
|
205 "CSPSettingsVoIPUtils::GetPreferredService() - IN" ); |
|
206 |
|
207 TRAPD( error, DoGetPreferredServiceL( aServiceId ) ); |
|
208 return error; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Is VoIP supported - Actual implementation |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 TBool CSPSettingsVoIPUtils::IsVoIPSupportedL( ) const |
|
216 { |
|
217 FeatureManager::InitializeLibL(); |
|
218 TBool voipSupportByFM = FeatureManager::FeatureSupported( KFeatureIdCommonVoip ); |
|
219 FeatureManager::UnInitializeLib(); |
|
220 |
|
221 if ( voipSupportByFM ) |
|
222 { |
|
223 TInt voipSupport( KVoIPOFF ); |
|
224 CRepository* repository |
|
225 = CRepository::NewLC( KCRUidTelephonySettings ); |
|
226 repository->Get( KDynamicVoIP, voipSupport ); |
|
227 CleanupStack::PopAndDestroy( repository ); |
|
228 return KVoIPOFF != voipSupport; |
|
229 } |
|
230 else |
|
231 { |
|
232 return EFalse; |
|
233 } |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Is VoIP preferred telephony - Actual implementation |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 TBool CSPSettingsVoIPUtils::IsPreferredTelephonyVoIPL() const |
|
241 { |
|
242 TBool voipPreferred( EFalse ); |
|
243 |
|
244 CRepository* repository = CRepository::NewLC( KCRUidRichCallSettings ); |
|
245 TInt value(0); |
|
246 repository->Get( KRCSEPreferredTelephony, value ); |
|
247 voipPreferred = ( KRCSEInternetCallPreferred == value ? ETrue : EFalse ); |
|
248 CleanupStack::PopAndDestroy( repository ); |
|
249 |
|
250 return voipPreferred && VoIPProfilesExistL(); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // Get Preferred Service - Actual implementation |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CSPSettingsVoIPUtils::DoGetPreferredServiceL( |
|
258 TUint& aServiceId ) const |
|
259 { |
|
260 XSPSLOGSTRING( |
|
261 "CSPSettingsVoIPUtils::DoGetPreferredServiceL() - IN" ); |
|
262 |
|
263 if ( !IsVoIPSupportedL() ) |
|
264 { |
|
265 // Voip not supported |
|
266 User::Leave( KErrNotSupported ); |
|
267 } |
|
268 |
|
269 // Get the preferred service id |
|
270 CRepository* repository = CRepository::NewLC( KCRUidRichCallSettings ); |
|
271 TInt value(0); |
|
272 User::LeaveIfError( repository->Get( KRCSPSPreferredService, value ) ); |
|
273 CleanupStack::PopAndDestroy( repository ); |
|
274 |
|
275 |
|
276 XSPSLOGSTRING2( |
|
277 "CSPSettingsVoIPUtils::DoGetPreferredServiceL() service:%d",value ); |
|
278 if ( 0 == value ) |
|
279 { |
|
280 // Preferred service not setted. |
|
281 User::Leave( KErrNotFound ); |
|
282 } |
|
283 |
|
284 aServiceId = value; |
|
285 } |
|
286 |