|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : Sipimsprofileusimprovider.cpp |
|
15 // Part of : ProfileAgent |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "Sipimsprofileusimprovider.h" |
|
22 #include "sipprofileimsauthorization.h" |
|
23 #include "sipprofilesimauthorization.h" |
|
24 #include "sipimsprofilemccandmnc.h" |
|
25 #include "msipprofileimsauthenticationdataobserver.h" |
|
26 #include "Sipimsprofilesimrecord.h" |
|
27 #include "SipProfileLog.h" |
|
28 #include "authinfomonitor.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================== |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CSIPProfileUsimProvider::NewL |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CSIPProfileUsimProvider* CSIPProfileUsimProvider::NewL( |
|
37 CSIPProfileSIMRecord& aUserRecord, |
|
38 RTelServer& aTelServer, |
|
39 const RTelServer::TPhoneInfo& aPhoneInfo, |
|
40 MSIPProfileIMSAuthenticationDataObserver& aObserver ) |
|
41 { |
|
42 CSIPProfileUsimProvider* self = |
|
43 new (ELeave) CSIPProfileUsimProvider( aUserRecord, aObserver ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL( aTelServer, aPhoneInfo ); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CSIPProfileUsimProvider::CSIPProfileUsimProvider |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CSIPProfileUsimProvider::CSIPProfileUsimProvider( |
|
55 CSIPProfileSIMRecord& aUserRecord, |
|
56 MSIPProfileIMSAuthenticationDataObserver& aObserver ) |
|
57 : iProfileSIMRecord( aUserRecord ), |
|
58 iObserver( aObserver ), |
|
59 iSIMSupported( EFalse ), |
|
60 iUSimSupported( EFalse ) |
|
61 { |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CSIPProfileUsimProvider::ConstructL |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 void CSIPProfileUsimProvider::ConstructL( |
|
69 RTelServer& aTelServer, |
|
70 const RTelServer::TPhoneInfo& aPhoneInfo ) |
|
71 { |
|
72 PROFILE_DEBUG1("CSIPProfileUsimProvider::ConstructL") |
|
73 |
|
74 User::LeaveIfError( iPhone.Open( aTelServer, aPhoneInfo.iName ) ); |
|
75 |
|
76 TUint32 caps; |
|
77 User::LeaveIfError(iPhone.GetIccAccessCaps(caps)); |
|
78 if(caps & RMobilePhone::KCapsSimAccessSupported) |
|
79 { |
|
80 iSIMSupported = ETrue; |
|
81 } |
|
82 |
|
83 if(caps & RMobilePhone::KCapsRUimAccessSupported) |
|
84 { |
|
85 } |
|
86 |
|
87 //usim supported |
|
88 if(caps & RMobilePhone::KCapsUSimAccessSupported) |
|
89 { |
|
90 iUSimSupported = ETrue; |
|
91 } |
|
92 |
|
93 if(!iUSimSupported && iSIMSupported) |
|
94 { |
|
95 delete iAuthorization; |
|
96 iAuthorization = NULL; |
|
97 iAuthorizationSIM = |
|
98 CSIPProfileSIMAuthorization::NewL( *this , iPhone); |
|
99 iAuthorizationHomeNetwork = |
|
100 CSIPIMSProfileMCCandMNC::NewL( *this , iPhone); |
|
101 } |
|
102 else |
|
103 { |
|
104 if(iUSimSupported) |
|
105 { |
|
106 iAuthorization = CSIPProfileIMSAuthorization::NewL( *this, |
|
107 iPhone ); |
|
108 iAuthorizationSIM = |
|
109 CSIPProfileSIMAuthorization::NewL( *this , iPhone); |
|
110 iAuthorizationHomeNetwork = |
|
111 CSIPIMSProfileMCCandMNC::NewL( *this , iPhone); |
|
112 iAuthInfoMonitor = CAuthInfoMonitor::NewL( *this, iPhone ); |
|
113 } |
|
114 } |
|
115 if(!iUSimSupported && !iSIMSupported) |
|
116 { |
|
117 User::Leave(KErrNotSupported); |
|
118 } |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CSIPProfileUsimProvider::IsSIMSupported |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 TBool CSIPProfileUsimProvider::IsSIMSupported() |
|
126 { |
|
127 return iSIMSupported; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CSIPProfileUsimProvider::IsUsimSupported |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 TBool CSIPProfileUsimProvider::IsUsimSupported() |
|
135 { |
|
136 return iUSimSupported; |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CSIPProfileUsimProvider::~CSIPProfileUsimProvider |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 CSIPProfileUsimProvider::~CSIPProfileUsimProvider() |
|
144 { |
|
145 delete iAuthorization; |
|
146 delete iAuthorizationSIM; |
|
147 delete iAuthorizationHomeNetwork; |
|
148 delete iAuthInfoMonitor; |
|
149 iPhone.Close(); |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CSIPProfileUsimProvider::RequestL |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 void CSIPProfileUsimProvider::RequestL(TBool /*aUseSIM*/) |
|
157 { |
|
158 TBool requestmade = EFalse; |
|
159 if (!iProfileSIMRecord.SIMPrivateIdentity().Length()) |
|
160 { |
|
161 if (iAuthorizationSIM) |
|
162 { |
|
163 iAuthorizationSIM->RequestL(); |
|
164 requestmade = ETrue; |
|
165 } |
|
166 else |
|
167 { |
|
168 User::Leave(KErrArgument); |
|
169 } |
|
170 } |
|
171 |
|
172 if (IsUsimSupported()) |
|
173 { |
|
174 if (!iProfileSIMRecord.PrivateIdentity().Length()) |
|
175 { |
|
176 iAuthorization->RequestL(); |
|
177 requestmade = ETrue; |
|
178 } |
|
179 } |
|
180 if (!requestmade) |
|
181 { |
|
182 iObserver.AsyncDeltaTimer(); |
|
183 } |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------------------------- |
|
187 // CSIPProfileUsimProvider::Cancel |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 void CSIPProfileUsimProvider::Cancel() |
|
191 { |
|
192 if (iAuthorization) |
|
193 { |
|
194 iAuthorization->Cancel(); |
|
195 } |
|
196 if(iAuthorizationSIM) |
|
197 { |
|
198 iAuthorizationSIM->Cancel(); |
|
199 } |
|
200 if(iAuthorizationHomeNetwork) |
|
201 { |
|
202 iAuthorizationHomeNetwork->Cancel(); |
|
203 } |
|
204 } |
|
205 |
|
206 // ---------------------------------------------------------------------------- |
|
207 // CSIPProfileUsimProvider::AuthorizedL |
|
208 // ---------------------------------------------------------------------------- |
|
209 // |
|
210 void CSIPProfileUsimProvider::AuthorizedL() |
|
211 { |
|
212 if (iAuthorization) |
|
213 { |
|
214 RMobilePhone::CImsAuthorizationInfoV5& authorization = |
|
215 iAuthorization->Response(); |
|
216 |
|
217 iProfileSIMRecord.SetPrivateIdL(authorization.iIMPI); |
|
218 iProfileSIMRecord.SetFirstPublicUserNameL(authorization.iIMPUArray[0]); |
|
219 iProfileSIMRecord.SetHomeNetworkDomainNameL( |
|
220 authorization.iHomeNetworkDomainName); |
|
221 iProfileSIMRecord.SetISIMPresent( |
|
222 authorization.iAuthenticationDataSource == RMobilePhone::EFromISIM); |
|
223 |
|
224 iObserver.AuthorizedL(); |
|
225 } |
|
226 } |
|
227 |
|
228 // ---------------------------------------------------------------------------- |
|
229 // CSIPProfileUsimProvider::AuthorizedSubscriberIdL |
|
230 // ---------------------------------------------------------------------------- |
|
231 // |
|
232 void CSIPProfileUsimProvider::AuthorizedSubscriberIdL() |
|
233 { |
|
234 iAuthorizationHomeNetwork->RequestL(); |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // CSIPProfileUsimProvider::AuthorizedHomeNetworkIdL |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 void CSIPProfileUsimProvider::AuthorizedHomeNetworkIdL() |
|
242 { |
|
243 DeriveValuesL(); |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CSIPProfileUsimProvider::DeriveValuesL |
|
248 // ---------------------------------------------------------------------------- |
|
249 // |
|
250 void CSIPProfileUsimProvider::DeriveValuesL() |
|
251 { |
|
252 _LIT8(Kimsmnc, "ims.mnc"); |
|
253 _LIT8(Kmcc, ".mcc"); |
|
254 _LIT8(K3gppnetwork, ".3gppnetwork.org"); |
|
255 _LIT8(Kato, "@"); |
|
256 _LIT8(Ksip, "sip:"); |
|
257 _LIT8(KZero, "0"); |
|
258 |
|
259 //homenetwork domain name |
|
260 TUint mncmcclength = |
|
261 iAuthorizationHomeNetwork->NetworkIdentityCode().Length() |
|
262 + iAuthorizationHomeNetwork->NetworkCountryCode().Length(); |
|
263 if (iAuthorizationHomeNetwork->NetworkIdentityCode().Length() == 2) |
|
264 { |
|
265 mncmcclength = mncmcclength + 1; |
|
266 } |
|
267 |
|
268 TUint appendlength = Kimsmnc().Length() + Kmcc().Length() |
|
269 + K3gppnetwork().Length() + mncmcclength; |
|
270 |
|
271 HBufC8* appendingResult = HBufC8::NewL(appendlength); |
|
272 TPtr8 appendingResultPtr = appendingResult->Des(); |
|
273 |
|
274 appendingResultPtr.Append(Kimsmnc); |
|
275 if (iAuthorizationHomeNetwork->NetworkIdentityCode().Length() == 2) |
|
276 { |
|
277 appendingResultPtr.Append(KZero); |
|
278 } |
|
279 appendingResultPtr.Append(iAuthorizationHomeNetwork->NetworkIdentityCode()); |
|
280 appendingResultPtr.Append(Kmcc); |
|
281 appendingResultPtr.Append(iAuthorizationHomeNetwork->NetworkCountryCode()); |
|
282 appendingResultPtr.Append(K3gppnetwork); |
|
283 CleanupStack::PushL(appendingResult); |
|
284 iProfileSIMRecord.SetSIMHomeNetworkDomainNameL(*appendingResult); |
|
285 CleanupStack::Pop(appendingResult); |
|
286 delete appendingResult; |
|
287 appendingResult = NULL; |
|
288 |
|
289 //private user identity |
|
290 appendlength = 0; |
|
291 appendlength = iAuthorizationSIM->IMSI().Length() + Kato().Length() |
|
292 + Kimsmnc().Length() + mncmcclength + Kmcc().Length() |
|
293 + K3gppnetwork().Length(); |
|
294 |
|
295 HBufC8* result = HBufC8::NewL(appendlength); |
|
296 TPtr8 resultPtr = result->Des(); |
|
297 resultPtr.Append(iAuthorizationSIM->IMSI()); |
|
298 resultPtr.Append(Kato); |
|
299 resultPtr.Append(Kimsmnc); |
|
300 if (iAuthorizationHomeNetwork->NetworkIdentityCode().Length() == 2) |
|
301 { |
|
302 resultPtr.Append(KZero); |
|
303 } |
|
304 resultPtr.Append(iAuthorizationHomeNetwork->NetworkIdentityCode()); |
|
305 resultPtr.Append(Kmcc); |
|
306 resultPtr.Append(iAuthorizationHomeNetwork->NetworkCountryCode()); |
|
307 resultPtr.Append(K3gppnetwork); |
|
308 CleanupStack::PushL(result); |
|
309 iProfileSIMRecord.SetSIMPrivateIdL(*result); |
|
310 CleanupStack::Pop(result); |
|
311 delete result; |
|
312 result = NULL; |
|
313 |
|
314 //public user identity |
|
315 |
|
316 appendlength = Ksip().Length() + |
|
317 iProfileSIMRecord.SIMPrivateIdentity().Length(); |
|
318 HBufC8* temp = HBufC8::NewL(appendlength); |
|
319 TPtr8 tempPtr = temp->Des(); |
|
320 tempPtr = temp->Des(); |
|
321 tempPtr.Append(Ksip); |
|
322 tempPtr.Append(iProfileSIMRecord.SIMPrivateIdentity()); |
|
323 |
|
324 CleanupStack::PushL(temp); |
|
325 iProfileSIMRecord.SetSIMFirstPublicUserNameL(*temp); |
|
326 CleanupStack::Pop(temp); |
|
327 delete temp; |
|
328 temp = NULL; |
|
329 iObserver.AuthorizedL(); |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------------------------- |
|
333 // CSIPProfileUsimProvider::AuthorizationFailed |
|
334 // ---------------------------------------------------------------------------- |
|
335 // |
|
336 void CSIPProfileUsimProvider::AuthorizationFailed() |
|
337 { |
|
338 iProfileSIMRecord.UserRecordFailed(KErrArgument); |
|
339 |
|
340 iObserver.AuthorizationFailed(); |
|
341 } |
|
342 |
|
343 // ---------------------------------------------------------------------------- |
|
344 // CSIPProfileUsimProvider::AuthorizationSIMFailed |
|
345 // ---------------------------------------------------------------------------- |
|
346 // |
|
347 void CSIPProfileUsimProvider::AuthorizationSIMFailed() |
|
348 { |
|
349 iProfileSIMRecord.UserRecordFailed(KErrArgument); |
|
350 |
|
351 iObserver.AuthorizationSIMFailed(); |
|
352 } |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 // CSIPProfileUsimProvider::AuthInfoUpdatedL |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 void CSIPProfileUsimProvider::AuthInfoUpdatedL() |
|
359 { |
|
360 iProfileSIMRecord.ResetISIMValuesL(); |
|
361 iObserver.UpdateRegistrationsL(); |
|
362 if (!iProfileSIMRecord.PrivateIdentity().Length()) |
|
363 { |
|
364 iAuthorization->RequestL(); |
|
365 } |
|
366 } |
|
367 |
|
368 // End of File |