|
1 /* |
|
2 * Copyright (c) 2008-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: Keeps up the call index |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "tccecallindex.h" |
|
20 |
|
21 #include "mccecallarray.h" |
|
22 #include "mccecallinfo.h" |
|
23 #include "cccelogger.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 TCCECallIndex::TCCECallIndex( MCCECallArray& aCallArray ) : |
|
32 iCallArray( aCallArray ) |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Checks smallest available call index |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 TInt TCCECallIndex::CurrentCallIndex() const |
|
41 { |
|
42 CCELOGSTRING( "TCCECallIndex::CurrentCallIndex(): In" ); |
|
43 TInt smallestAvailableCallIndex = 1; // Smallest call index is 1 |
|
44 |
|
45 // Iterate until call index value has not changed. |
|
46 // TODO: There has to be better way to solve call index. |
|
47 TBool callIndexChanged( ETrue ); |
|
48 while( callIndexChanged ) |
|
49 { |
|
50 // Iterate over the calls and check if smallestAvailableCallIndex is in use |
|
51 // with some call. |
|
52 callIndexChanged = EFalse; |
|
53 for ( TInt i = 0; i < iCallArray.MaxNumberOfCalls(); i++ ) |
|
54 { |
|
55 if( CheckAndIncrementCallIndex( iCallArray.CallInfo( i ), smallestAvailableCallIndex ) ) |
|
56 { |
|
57 callIndexChanged = ETrue; |
|
58 } |
|
59 } |
|
60 if ( CheckAndIncrementCallIndex( iCallArray.EmergencyCallInfo(), smallestAvailableCallIndex ) ) |
|
61 { |
|
62 callIndexChanged = ETrue; |
|
63 } |
|
64 } |
|
65 CCELOGSTRING2( "TCCECallIndex::CurrentCallIndex(): Smallest avail call index = %d", smallestAvailableCallIndex ); |
|
66 CCELOGSTRING( "TCCECallIndex::CurrentCallIndex(): Out" ); |
|
67 return smallestAvailableCallIndex; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Checks and increments the call index. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 TBool TCCECallIndex::CheckAndIncrementCallIndex( |
|
75 MCCECallInfo* aCallInfo, |
|
76 TInt& aCallIndex ) const |
|
77 { |
|
78 if ( aCallInfo && aCallInfo->State() != CCPCall::EStateIdle ) |
|
79 { |
|
80 if ( aCallIndex == aCallInfo->CallIndex() ) |
|
81 { |
|
82 aCallIndex++; |
|
83 return ETrue; |
|
84 } |
|
85 } |
|
86 return EFalse; |
|
87 } |
|
88 |