20
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Implements the class CPhoneHandlerCallArray
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <callinformation.h>
|
|
19 |
#include "PhoneHandlerCallArray.h"
|
|
20 |
|
|
21 |
// ---------------------------------------------------------------------------
|
|
22 |
// CPhoneHandlerCallArray::NewL.
|
|
23 |
// ---------------------------------------------------------------------------
|
|
24 |
//
|
|
25 |
CPhoneHandlerCallArray* CPhoneHandlerCallArray::NewL( )
|
|
26 |
{
|
|
27 |
CPhoneHandlerCallArray* self = new ( ELeave ) CPhoneHandlerCallArray( );
|
|
28 |
return self;
|
|
29 |
}
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// Destructs the array including remaining calls.
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CPhoneHandlerCallArray::~CPhoneHandlerCallArray( )
|
|
36 |
{
|
|
37 |
TInt callCount = iCallArray.Count();
|
|
38 |
|
|
39 |
for (TInt callIndex = 0; callIndex < callCount; callIndex++)
|
|
40 |
{
|
|
41 |
TCallInfo* call = iCallArray[ callIndex ];
|
|
42 |
delete call;
|
|
43 |
}
|
|
44 |
|
|
45 |
iCallArray.Reset();
|
|
46 |
iCallArray.Close();
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// Iterates through call objects finding the call matching the given call index.
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
TCallInfo* CPhoneHandlerCallArray::FindCall( TInt aCallIndex )
|
|
54 |
{
|
|
55 |
TInt callCount = iCallArray.Count();
|
|
56 |
for (TInt callIndex = 0; callIndex < callCount; callIndex++)
|
|
57 |
{
|
|
58 |
TCallInfo* call = iCallArray[ callIndex ];
|
|
59 |
if ( call )
|
|
60 |
{
|
|
61 |
if ( call->CallIndex() == aCallIndex )
|
|
62 |
{
|
|
63 |
return call;
|
|
64 |
}
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
return NULL;
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// CPhoneHandlerCallArray::Add
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CPhoneHandlerCallArray::AddL( const MCall* aCall )
|
|
76 |
{
|
|
77 |
//take heap based copy and add it to the array
|
|
78 |
TCallInfo* call = new( ELeave )TCallInfo;
|
|
79 |
|
|
80 |
call->iIndex = aCall->CallIndex();
|
|
81 |
call->iState = aCall->CallState();
|
|
82 |
call->iType = aCall->CallType();
|
|
83 |
call->iDirection = aCall->CallDirection();
|
|
84 |
call->iEmergencyCall = aCall->IsEmergency();
|
|
85 |
call->iServiceId = aCall->ServiceId();
|
|
86 |
|
|
87 |
CleanupStack::PushL( call );
|
|
88 |
iCallArray.AppendL( call );
|
|
89 |
CleanupStack::Pop( call );
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
// CPhoneHandlerCallArray::Remove
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
TInt CPhoneHandlerCallArray::Remove( TCallInfo* aCall )
|
|
97 |
{
|
|
98 |
TInt index = iCallArray.Find( aCall );
|
|
99 |
if ( index != KErrNotFound )
|
|
100 |
{
|
|
101 |
TCallInfo* call = iCallArray[ index ];
|
|
102 |
delete call;
|
|
103 |
iCallArray.Remove( index );
|
|
104 |
return KErrNone;
|
|
105 |
}
|
|
106 |
return KErrNotFound;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// CPhoneHandlerCallArray::CallCount
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
TInt CPhoneHandlerCallArray::CallCount( )
|
|
114 |
{
|
|
115 |
return iCallArray.Count();
|
|
116 |
}
|
|
117 |
|
|
118 |
//---------------------------------------------------------------------------
|
|
119 |
// CPhoneHandlerCallArray::CallByState
|
|
120 |
// ---------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
TCallInfo* CPhoneHandlerCallArray::CallByState( TInt aState )
|
|
123 |
{
|
|
124 |
TCallInfo* call;
|
|
125 |
TInt callCount = iCallArray.Count();
|
|
126 |
for (TInt callIndex = 0; callIndex < callCount; callIndex++)
|
|
127 |
{
|
|
128 |
call = iCallArray[ callIndex ];
|
|
129 |
|
|
130 |
if( call->CallState() == aState)
|
|
131 |
{
|
|
132 |
return call;
|
|
133 |
}
|
|
134 |
}
|
|
135 |
return NULL;
|
|
136 |
}
|
|
137 |
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
// Constructs the monitor.
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
CPhoneHandlerCallArray::CPhoneHandlerCallArray()
|
|
143 |
{
|
|
144 |
}
|
|
145 |
|
|
146 |
//---------------------------------------------------------------------------
|
|
147 |
// CPhoneHandlerCallArray::ConnectedCallCount
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
TInt CPhoneHandlerCallArray::ConnectedCallCount()
|
|
151 |
{
|
|
152 |
TInt callCount = iCallArray.Count();
|
|
153 |
TInt connectedCalls = 0;
|
|
154 |
for ( TInt callIndex = 0; callIndex < callCount; callIndex++ )
|
|
155 |
{
|
|
156 |
MCall* call = iCallArray[ callIndex ];
|
|
157 |
if ( CCPCall::EStateConnected == call->CallState() )
|
|
158 |
{
|
|
159 |
connectedCalls++;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
return connectedCalls;
|
|
163 |
}
|
|
164 |
|
|
165 |
//---------------------------------------------------------------------------
|
|
166 |
// CPhoneHandlerCallArray::ExistingCallCount
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
TInt CPhoneHandlerCallArray::ExistingCallCount()
|
|
170 |
{
|
|
171 |
TInt callCount = iCallArray.Count();
|
|
172 |
TInt existingCalls = 0;
|
|
173 |
for ( TInt callIndex = 0; callIndex < callCount; callIndex++ )
|
|
174 |
{
|
|
175 |
TCallInfo* call = iCallArray[ callIndex ];
|
|
176 |
CCPCall::TCallState callState = call->CallState();
|
|
177 |
|
|
178 |
if( CCPCall::EStateIdle != callState
|
|
179 |
&& CCPCall::EStateDisconnecting != callState )
|
|
180 |
{
|
|
181 |
existingCalls++;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
return existingCalls;
|
|
185 |
}
|
|
186 |
|
|
187 |
// End of File
|