|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <spsettings.h> |
|
20 #include <spentry.h> |
|
21 #include <crcseprofileregistry.h> |
|
22 #include <sipmanagedprofile.h> |
|
23 #include <sipmanagedprofileregistry.h> |
|
24 #include "csvtsettingshandler.h" |
|
25 |
|
26 // ======== LOCAL FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // ResetAndDestroy for RCSE profile entry array. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void ResetAndDestroy( TAny* aAny ) |
|
33 { |
|
34 if ( aAny ) |
|
35 { |
|
36 static_cast<RPointerArray<CRCSEProfileEntry>*>( aAny ) |
|
37 ->ResetAndDestroy(); |
|
38 } |
|
39 } |
|
40 |
|
41 |
|
42 // ======== MEMBER FUNCTIONS ======== |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CSvtSettingsHandler::CSvtSettingsHandler |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CSvtSettingsHandler::CSvtSettingsHandler( TUint aServiceId ) |
|
49 : iServiceId( aServiceId ) |
|
50 { |
|
51 |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CSvtSettingsHandler::ConstructL |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CSvtSettingsHandler::ConstructL() |
|
60 { |
|
61 TBool isServiceConfigured = IsServiceConfiguredL( iServiceId ); |
|
62 __ASSERT_ALWAYS( isServiceConfigured, User::Leave( KErrNotFound ) ); |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CSvtSettingsHandler::NewL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CSvtSettingsHandler* CSvtSettingsHandler::NewL( TUint aServiceId ) |
|
71 { |
|
72 CSvtSettingsHandler* self = CSvtSettingsHandler::NewLC( aServiceId ); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CSvtSettingsHandler::NewLC |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CSvtSettingsHandler* CSvtSettingsHandler::NewLC( TUint aServiceId ) |
|
83 { |
|
84 CSvtSettingsHandler* self = new( ELeave ) CSvtSettingsHandler( aServiceId ); |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL(); |
|
87 return self; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CSvtSettingsHandler::~CSvtSettingsHandler |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CSvtSettingsHandler::~CSvtSettingsHandler() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CSvtSettingsHandler::DomainPartClippingSetting() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 TInt CSvtSettingsHandler::DomainPartClippingSetting() const |
|
106 { |
|
107 const TInt KNoDomainPartClipping = 0; |
|
108 TInt setting( KNoDomainPartClipping ); |
|
109 |
|
110 CRCSEProfileEntry* profile = NULL; |
|
111 TRAP_IGNORE( profile = RcseProfileForServiceL( iServiceId ) ) |
|
112 if ( profile ) |
|
113 { |
|
114 setting = profile->iIgnoreAddrDomainPart; |
|
115 delete profile; |
|
116 } |
|
117 |
|
118 return setting; |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CSvtSettingsHandler::GetUserAorL() |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CSvtSettingsHandler::GetUserAorL( RBuf& aUserAor ) |
|
127 { |
|
128 aUserAor = KNullDesC(); |
|
129 |
|
130 TInt sipProfileId = SipProfileIdForServiceL( iServiceId ); |
|
131 |
|
132 // fetch sip profile based on sip profile id |
|
133 CSIPManagedProfileRegistry* sipProfileRegistry = |
|
134 CreateSipProfileRegistryLC(); |
|
135 CSIPManagedProfile* profile = static_cast<CSIPManagedProfile*> |
|
136 ( sipProfileRegistry->ProfileL( sipProfileId ) ); |
|
137 CleanupStack::PushL( profile ); |
|
138 |
|
139 // Read user aor setting from fetched sip profile. |
|
140 const TDesC8* userAor = NULL; |
|
141 User::LeaveIfError( profile->GetParameter( KSIPUserAor, userAor ) ); |
|
142 if ( userAor ) |
|
143 { |
|
144 if ( aUserAor.Length() < userAor->Length() ) |
|
145 { |
|
146 aUserAor.ReAllocL( userAor->Length() ); |
|
147 } |
|
148 |
|
149 aUserAor.Copy( *userAor ); |
|
150 } |
|
151 |
|
152 CleanupStack::PopAndDestroy( profile ); |
|
153 CleanupStack::PopAndDestroy( sipProfileRegistry ); |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // From class MSIPProfileRegistryObserver. |
|
159 // Implementation currently not needed because SIP profile registry is used |
|
160 // only in function scope. |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CSvtSettingsHandler::ProfileRegistryEventOccurred( |
|
164 TUint32 /*aProfileId*/, TEvent /*aEvent*/ ) |
|
165 { |
|
166 |
|
167 } |
|
168 |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // From class MSIPProfileRegistryObserver. |
|
172 // Implementation currently not needed because SIP profile registry is used |
|
173 // only in function scope. |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CSvtSettingsHandler::ProfileRegistryErrorOccurred( |
|
177 TUint32 /*aProfileId*/, TInt /*aError*/ ) |
|
178 { |
|
179 |
|
180 } |
|
181 |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CSvtSettingsHandler::IsServiceConfiguredL |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 TBool CSvtSettingsHandler::IsServiceConfiguredL( TUint aServiceId ) const |
|
188 { |
|
189 CSPSettings* settings = CreateServiceProviderSettingsL(); |
|
190 CleanupStack::PushL( settings ); |
|
191 |
|
192 RIdArray ids; |
|
193 CleanupClosePushL( ids ); |
|
194 TBool result = |
|
195 ( KErrNone == settings->FindServiceIdsL( ids ) |
|
196 && KErrNotFound != ids.Find( aServiceId ) ); |
|
197 CleanupStack::PopAndDestroy( &ids ); |
|
198 |
|
199 CleanupStack::PopAndDestroy( settings ); |
|
200 return result; |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CSvtSettingsHandler::CreateServiceProviderSettingsL() |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 CSPSettings* CSvtSettingsHandler::CreateServiceProviderSettingsL() const |
|
209 { |
|
210 return CSPSettings::NewL(); |
|
211 } |
|
212 |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // CSvtSettingsHandler::CreateRcseProfileRegistryLC() |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 CRCSEProfileRegistry* CSvtSettingsHandler::CreateRcseProfileRegistryLC() const |
|
219 { |
|
220 return CRCSEProfileRegistry::NewLC(); |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CSvtSettingsHandler::CreateRcseProfileRegistryLC() |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 CSIPManagedProfileRegistry* CSvtSettingsHandler::CreateSipProfileRegistryLC() |
|
229 { |
|
230 return CSIPManagedProfileRegistry::NewLC( *this ); |
|
231 } |
|
232 |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CSvtSettingsHandler::RcseProfileForServiceL() |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 CRCSEProfileEntry* CSvtSettingsHandler::RcseProfileForServiceL( |
|
239 TUint aServiceId ) const |
|
240 { |
|
241 CRCSEProfileEntry* rcseProfile = NULL; |
|
242 CRCSEProfileRegistry* registry = CreateRcseProfileRegistryLC(); |
|
243 RPointerArray<CRCSEProfileEntry> profileEntries; |
|
244 CleanupStack::PushL( TCleanupItem( ResetAndDestroy, &profileEntries ) ); |
|
245 |
|
246 registry->FindByServiceIdL( aServiceId, profileEntries ); |
|
247 if ( profileEntries.Count() && profileEntries[ 0 ] ) |
|
248 { |
|
249 rcseProfile = profileEntries[ 0 ]; |
|
250 profileEntries.Remove( 0 ); |
|
251 } |
|
252 |
|
253 CleanupStack::PopAndDestroy( &profileEntries ); |
|
254 CleanupStack::PopAndDestroy( registry ); |
|
255 return rcseProfile; |
|
256 } |
|
257 |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CSvtSettingsHandler::SipProfileIdForServiceL() |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 TInt CSvtSettingsHandler::SipProfileIdForServiceL( TUint aServiceId ) const |
|
264 { |
|
265 TInt sipProfileId( KErrNotFound ); |
|
266 |
|
267 CRCSEProfileEntry* rcseProfile = RcseProfileForServiceL( aServiceId ); |
|
268 if ( NULL != rcseProfile ) |
|
269 { |
|
270 const TInt KSipProfileIdIndex = 0; |
|
271 sipProfileId = rcseProfile->iIds[ KSipProfileIdIndex ].iProfileId; |
|
272 delete rcseProfile; |
|
273 } |
|
274 |
|
275 return sipProfileId; |
|
276 } |