|
1 // Copyright (c) 2006-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 : sipprofilequeuehandling.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <bamdesca.h> |
|
24 #include "sipprofilequeuehandling.h" |
|
25 #include "sipprofilefsmuser.h" |
|
26 #include "sipconcreteprofile.h" |
|
27 #include "sipgendefs.h" |
|
28 #include "sipmanagedprofile.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSIPProfileQueueHandling::NewLC |
|
34 // (other items were commented in a header). |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 EXPORT_C CSIPProfileQueueHandling* CSIPProfileQueueHandling::NewLC( |
|
38 MSIPProfileFSMUser& aUser ) |
|
39 { |
|
40 CSIPProfileQueueHandling* self = |
|
41 new(ELeave)CSIPProfileQueueHandling( aUser ); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CSIPProfileQueueHandling::NewL |
|
49 // (other items were commented in a header). |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CSIPProfileQueueHandling* CSIPProfileQueueHandling::NewL( |
|
53 MSIPProfileFSMUser& aUser ) |
|
54 { |
|
55 CSIPProfileQueueHandling* self = |
|
56 CSIPProfileQueueHandling::NewLC( aUser ); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CSIPProfileQueueHandling::CSIPProfileQueueHandling |
|
63 // (other items were commented in a header). |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CSIPProfileQueueHandling::CSIPProfileQueueHandling( |
|
67 MSIPProfileFSMUser& aUser ) : |
|
68 iUser( aUser ) |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CSIPProfileQueueHandling::ConstructL() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CSIPProfileQueueHandling::ConstructL() |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CSIPProfileQueueHandling::~CSIPProfileQueueHandling |
|
82 // (other items were commented in a header). |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CSIPProfileQueueHandling::~CSIPProfileQueueHandling() |
|
86 { |
|
87 iRegisteringQueue.Close(); |
|
88 iDeregisteringQueue.Close(); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CSIPProfileQueueHandling::AddIntoQueue() |
|
93 // (other items were commented in a header). |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TBool CSIPProfileQueueHandling::AddIntoQueue( |
|
97 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
98 { |
|
99 return iUser.AddProfileIntoQueue( aSIPConcreteProfile ); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSIPProfileQueueHandling::AddIntoDeregisterQueueL() |
|
104 // (other items were commented in a header). |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TBool CSIPProfileQueueHandling::AddIntoDeregisterQueueL( |
|
108 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
109 { |
|
110 TSIPProfileQueueItem item( aSIPConcreteProfile, EFalse ); |
|
111 return AddToQueueNoDuplicatesL( iDeregisteringQueue, item ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CSIPProfileQueueHandling::AddIntoRegisterQueueL() |
|
116 // (other items were commented in a header). |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TBool CSIPProfileQueueHandling::AddIntoRegisterQueueL( |
|
120 CSIPConcreteProfile& aSIPConcreteProfile, |
|
121 TBool aRetryRegistration ) |
|
122 { |
|
123 TSIPProfileQueueItem item( aSIPConcreteProfile, aRetryRegistration ); |
|
124 return AddToQueueNoDuplicatesL( iRegisteringQueue, item ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CSIPProfileQueueHandling::AddDeregisterToQueueL() |
|
129 // (other items were commented in a header). |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TBool CSIPProfileQueueHandling::AddDeregisterToQueueL( |
|
133 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
134 { |
|
135 TBool result = AddIntoQueue( aSIPConcreteProfile ); |
|
136 if (result) |
|
137 { |
|
138 result = AddIntoDeregisterQueueL( aSIPConcreteProfile ); |
|
139 } |
|
140 return result; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CSIPProfileQueueHandling::AddRegisterToQueueL() |
|
145 // (other items were commented in a header). |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C TBool CSIPProfileQueueHandling::AddRegisterToQueueL( |
|
149 CSIPConcreteProfile& aSIPConcreteProfile, |
|
150 TBool aRetryRegistration ) |
|
151 { |
|
152 TBool result = AddIntoQueue( aSIPConcreteProfile ); |
|
153 if (result) |
|
154 { |
|
155 result = AddIntoRegisterQueueL( aSIPConcreteProfile, |
|
156 aRetryRegistration ); |
|
157 } |
|
158 return result; |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CSIPProfileQueueHandling::RegisterFromQueueL() |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C void CSIPProfileQueueHandling::RegisterFromQueueL( |
|
166 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
167 { |
|
168 // Called from ErrorEvent or SIPProfileStatusEvent |
|
169 if ( !CheckRegisterQueueL( aSIPConcreteProfile ) ) |
|
170 { |
|
171 CheckDeregisterQueueL( aSIPConcreteProfile ); |
|
172 } |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CSIPProfileQueueHandling::FoundIPSecProfileCandidate() |
|
177 // (other items were commented in a header). |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C TBool CSIPProfileQueueHandling::FoundIPSecProfileCandidate() |
|
181 { |
|
182 TBool result = EFalse; |
|
183 for (TInt i=0; i< iRegisteringQueue.Count() && !result; i++) |
|
184 { |
|
185 CSIPConcreteProfile& profile = iRegisteringQueue[i].iConcreteProfile; |
|
186 result = profile.IsSecurityNegotiationEnabled() && |
|
187 (!(profile.ServerParameter(KSIPRegistrar, KSIPDigestRealm).Length() |
|
188 && |
|
189 (profile.PrivateIdentity().Length() || |
|
190 profile.ServerParameter(KSIPRegistrar, KSIPDigestUserName).Length()) |
|
191 && |
|
192 profile.ServerParameter(KSIPRegistrar,KSIPDigestPassword).Length())); |
|
193 } |
|
194 return result; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CSIPProfileQueueHandling::CheckDeregisterQueueL() |
|
199 // (other items were commented in a header). |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CSIPProfileQueueHandling::CheckDeregisterQueueL( |
|
203 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
204 { |
|
205 TInt index = FindIndex( aSIPConcreteProfile, iDeregisteringQueue ); |
|
206 if ( index >= 0 ) |
|
207 { |
|
208 CSIPConcreteProfile& profile = |
|
209 iDeregisteringQueue[index].iConcreteProfile; |
|
210 iUser.DeregisterProfileAfterQueueL( profile ); |
|
211 iDeregisteringQueue.Remove(index); |
|
212 iDeregisteringQueue.Compress(); |
|
213 } |
|
214 return (index >= 0); |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CSIPProfileQueueHandling::CheckRegisterQueueL() |
|
219 // (other items were commented in a header). |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 TBool CSIPProfileQueueHandling::CheckRegisterQueueL( |
|
223 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
224 { |
|
225 TInt index = FindIndex( aSIPConcreteProfile, iRegisteringQueue ); |
|
226 if ( index >= 0 ) |
|
227 { |
|
228 CSIPConcreteProfile& profile = |
|
229 iRegisteringQueue[index].iConcreteProfile; |
|
230 if ( iRegisteringQueue[index].iRetryRegistration ) |
|
231 { |
|
232 iUser.RetryProfileRegistrationAfterQueueL( profile ); |
|
233 } |
|
234 else |
|
235 { |
|
236 iUser.RegisterProfileAfterQueueL( profile ); |
|
237 } |
|
238 iRegisteringQueue.Remove(index); |
|
239 iRegisteringQueue.Compress(); |
|
240 } |
|
241 return (index >= 0); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CSIPProfileQueueHandling::FindIndex() |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 TInt CSIPProfileQueueHandling::FindIndex( |
|
249 CSIPConcreteProfile& aSIPConcreteProfile, |
|
250 RArray<TSIPProfileQueueItem>& aProfileArray ) |
|
251 { |
|
252 TInt index = KErrNotFound; |
|
253 for (TInt i=0; i< aProfileArray.Count() && index == KErrNotFound; i++) |
|
254 { |
|
255 if ( aProfileArray[i].iConcreteProfile.Server( KSIPRegistrar ).Compare( |
|
256 aSIPConcreteProfile.Server( KSIPRegistrar ) ) == 0 ) |
|
257 { |
|
258 index = i; |
|
259 } |
|
260 } |
|
261 return index; |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CSIPProfileQueueHandling::IPSecProfileCandidate() |
|
266 // (other items were commented in a header). |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C CSIPConcreteProfile* CSIPProfileQueueHandling::IPSecProfileCandidate( |
|
270 TBool& aRegistering ) |
|
271 { |
|
272 CSIPConcreteProfile* profile = NULL; |
|
273 TBool found = EFalse; |
|
274 aRegistering = ETrue; |
|
275 |
|
276 for (TInt i=0; i<iRegisteringQueue.Count() && !found; i++) |
|
277 { |
|
278 CSIPConcreteProfile& tmp = iRegisteringQueue[i].iConcreteProfile; |
|
279 found = tmp.IsSecurityNegotiationEnabled() && |
|
280 (!(tmp.ServerParameter(KSIPRegistrar, KSIPDigestRealm).Length() |
|
281 && |
|
282 (tmp.PrivateIdentity().Length() || |
|
283 tmp.ServerParameter(KSIPRegistrar, KSIPDigestUserName).Length()) |
|
284 && |
|
285 tmp.ServerParameter(KSIPRegistrar,KSIPDigestPassword).Length())); |
|
286 |
|
287 if (found) |
|
288 { |
|
289 profile = &tmp; |
|
290 iRegisteringQueue.Remove(i); |
|
291 iRegisteringQueue.Compress(); |
|
292 } |
|
293 } |
|
294 |
|
295 for (TInt i=0; i< iDeregisteringQueue.Count() && !found; i++) |
|
296 { |
|
297 CSIPConcreteProfile& tmp = iDeregisteringQueue[i].iConcreteProfile; |
|
298 found = tmp.IsSecurityNegotiationEnabled() && |
|
299 (!(tmp.ServerParameter(KSIPRegistrar, KSIPDigestRealm).Length() |
|
300 && |
|
301 (tmp.PrivateIdentity().Length() || |
|
302 tmp.ServerParameter(KSIPRegistrar, KSIPDigestUserName).Length()) |
|
303 && |
|
304 tmp.ServerParameter(KSIPRegistrar,KSIPDigestPassword).Length())); |
|
305 aRegistering = EFalse; |
|
306 } |
|
307 |
|
308 return profile; |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CSIPProfileQueueHandling::WaitingForAllowedNetworkProfile() |
|
313 // (other items were commented in a header). |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 EXPORT_C CSIPConcreteProfile* |
|
317 CSIPProfileQueueHandling::WaitingForAllowedNetworkProfile( |
|
318 TBool /*aOnHomeNetwork*/ ) |
|
319 { |
|
320 // This function call and execution has been removed, but still in place as it is Exported and for future Use. |
|
321 return NULL; |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CSIPProfileQueueHandling::RemoveProfileFromRegQueueL() |
|
326 // (other items were commented in a header). |
|
327 // testi versio |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C CSIPConcreteProfile* |
|
331 CSIPProfileQueueHandling::RemoveProfileFromRegQueueL( |
|
332 CSIPConcreteProfile& aSIPConcreteProfile) |
|
333 { |
|
334 TBool found = EFalse; |
|
335 CSIPConcreteProfile* profile = NULL; |
|
336 for (TInt i=0; i< iRegisteringQueue.Count() && !found; i++) |
|
337 { |
|
338 CSIPConcreteProfile& tmp = iRegisteringQueue[ i ].iConcreteProfile; |
|
339 found = ( tmp.Id() == aSIPConcreteProfile.Id() ); |
|
340 profile = NULL; |
|
341 if ( found ) |
|
342 { |
|
343 profile = &tmp; |
|
344 iRegisteringQueue.Remove( i ); |
|
345 iRegisteringQueue.Compress(); |
|
346 } |
|
347 } |
|
348 return profile; |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CSIPProfileQueueHandling::IsEmpty() |
|
353 // (other items were commented in a header). |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 EXPORT_C TBool CSIPProfileQueueHandling::IsEmpty() const |
|
357 { |
|
358 return (iRegisteringQueue.Count() == 0 && |
|
359 iDeregisteringQueue.Count() == 0); |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CSIPProfileQueueHandling::Cleanup() |
|
364 // (other items were commented in a header). |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 EXPORT_C void CSIPProfileQueueHandling::Cleanup( |
|
368 CSIPConcreteProfile& aOldProfile, |
|
369 CSIPConcreteProfile* aNewProfile ) |
|
370 { |
|
371 QueueCleanup( iRegisteringQueue, aOldProfile, aNewProfile ); |
|
372 QueueCleanup( iDeregisteringQueue, aOldProfile, aNewProfile ); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CSIPProfileQueueHandling::IsInQueue() |
|
377 // (other items were commented in a header). |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 EXPORT_C TBool CSIPProfileQueueHandling::IsInQueue( |
|
381 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
382 { |
|
383 for (TInt i=0; i<iRegisteringQueue.Count();i++) |
|
384 { |
|
385 if (iRegisteringQueue[i].iConcreteProfile.Id() == |
|
386 aSIPConcreteProfile.Id() ) |
|
387 { |
|
388 return ETrue; |
|
389 } |
|
390 } |
|
391 return EFalse; |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CSIPProfileQueueHandling::IsRegistrationAllowed |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 EXPORT_C TBool CSIPProfileQueueHandling::IsRegistrationAllowed( |
|
399 CSIPConcreteProfile& /*aSIPConcreteProfile*/, |
|
400 TBool /*aOnHomeNetwork*/ ) |
|
401 { |
|
402 // This function call and execution has been removed, but still in place as it is Exported and for future Use. |
|
403 return EFalse; |
|
404 } |
|
405 |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CSIPProfileQueueHandling::AddToQueueNoDuplicatesL() |
|
409 // (other items were commented in a header). |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 TBool CSIPProfileQueueHandling::AddToQueueNoDuplicatesL( |
|
413 RArray<TSIPProfileQueueItem>& aProfileArray, |
|
414 TSIPProfileQueueItem& aProfileItem ) |
|
415 { |
|
416 for (TInt i=0; i<aProfileArray.Count();i++) |
|
417 { |
|
418 if ( aProfileArray[i].iConcreteProfile.Id() == |
|
419 aProfileItem.iConcreteProfile.Id() ) |
|
420 { |
|
421 return EFalse; |
|
422 } |
|
423 } |
|
424 aProfileArray.AppendL( aProfileItem ); |
|
425 return ETrue; |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CSIPProfileQueueHandling::QueueCleanup() |
|
430 // (other items were commented in a header). |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CSIPProfileQueueHandling::QueueCleanup( |
|
434 RArray<TSIPProfileQueueItem>& aProfileArray, |
|
435 CSIPConcreteProfile& aOldProfile, |
|
436 CSIPConcreteProfile* aNewProfile ) |
|
437 { |
|
438 TInt index = KErrNotFound; |
|
439 for ( TInt i=0; i< aProfileArray.Count() && index == KErrNotFound; i++ ) |
|
440 { |
|
441 if ( &(aProfileArray[i].iConcreteProfile) == &aOldProfile ) |
|
442 { |
|
443 index = i; |
|
444 } |
|
445 } |
|
446 |
|
447 if ( index == KErrNotFound ) |
|
448 { |
|
449 return; |
|
450 } |
|
451 |
|
452 TBool isAutoRegOnForOld( aOldProfile.IsAutoRegistrationEnabled() ); |
|
453 |
|
454 if ( ( !isAutoRegOnForOld && |
|
455 !aOldProfile.IsEnabled() ) || |
|
456 ( aNewProfile && |
|
457 !aNewProfile->IsAutoRegistrationEnabled() && |
|
458 !aNewProfile->IsEnabled() && |
|
459 isAutoRegOnForOld ) ) |
|
460 { |
|
461 aProfileArray.Remove( index ); |
|
462 aProfileArray.Compress(); |
|
463 } |
|
464 } |