24
|
1 |
// Copyright (c) 2001-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 |
//
|
|
15 |
|
|
16 |
#include "CSimPhone.h"
|
|
17 |
#include "CSimVoiceCall.h"
|
|
18 |
#include "Simlog.h"
|
|
19 |
#include "et_struct.h"
|
|
20 |
|
|
21 |
_LIT(KCommonCallName,"VoiceCall%d"); // < Voice call name template.
|
|
22 |
const TInt KVoiceCallGranularity=2; // < Granularity of voice call list array.
|
|
23 |
|
|
24 |
/**
|
|
25 |
* @file
|
|
26 |
*
|
|
27 |
* This file contains the implementation of the Similator TSY Voice line functionality.
|
|
28 |
* The line classes process the line-based requests made by ETel clients
|
|
29 |
* and passed down to the TSY by the ETel Server.
|
|
30 |
*/
|
|
31 |
|
|
32 |
CSimVoiceLine* CSimVoiceLine::NewL(CSimPhone* aPhone,const TDesC& aName)
|
|
33 |
/**
|
|
34 |
* Standard two phase constructor.
|
|
35 |
*
|
|
36 |
* @param aPhone pointer to the phone object.
|
|
37 |
* @param aName name of the line to be constructed
|
|
38 |
* @return CSimVoiceLine pointer to the voice line object created
|
|
39 |
* @leave Leaves if no memory or object is not created for any reason
|
|
40 |
*/
|
|
41 |
{
|
|
42 |
CSimVoiceLine* voiceLine=new(ELeave) CSimVoiceLine(aPhone);
|
|
43 |
TCleanupItem newLineVoiceClose(CloseLine,voiceLine);
|
|
44 |
CleanupStack::PushL(newLineVoiceClose);
|
|
45 |
voiceLine->ConstructL(aName);
|
|
46 |
CleanupStack::Pop();
|
|
47 |
return voiceLine;
|
|
48 |
}
|
|
49 |
|
|
50 |
CSimVoiceLine::CSimVoiceLine(CSimPhone* aPhone)
|
|
51 |
:CSimLine(aPhone)
|
|
52 |
/**
|
|
53 |
* Trivial constructor. Calls CSimLine to initialise its members
|
|
54 |
*/
|
|
55 |
{
|
|
56 |
iICProperty.iCategory = KUidPSSimTsyCategory;
|
|
57 |
iICProperty.iKey = KPSSimTsyIncomingVoiceCall;
|
|
58 |
iICProperty.iType = KPSSimTsyIncomingVoiceCallKeyType;
|
|
59 |
|
|
60 |
iRHProperty.iCategory = KUidPSSimTsyCategory;
|
|
61 |
iRHProperty.iKey = KPSSimTsyRemoteHangup;
|
|
62 |
iRHProperty.iType = KPSSimTsyRemoteHangupKeyType;
|
|
63 |
}
|
|
64 |
|
|
65 |
void CSimVoiceLine::ConstructL(const TName& aName)
|
|
66 |
/**
|
|
67 |
* Pre-allocate a pool of voice calls and allocate one to be the default to
|
|
68 |
* contain information about an incoming call.
|
|
69 |
*
|
|
70 |
* @param aName name of the voice line to be constructed
|
|
71 |
*/
|
|
72 |
{
|
|
73 |
iCaps=Caps();
|
|
74 |
CSimLine::ConstructL(aName);
|
|
75 |
iCalls=new(ELeave) CArrayFixFlat<CSimCall*>(KVoiceCallGranularity);
|
|
76 |
TName callName;
|
|
77 |
iSpareCall=CreateNewCallL(callName,ECallTypeSpareCall);
|
|
78 |
iAnswerNextIncomingCall=iSpareCall;
|
|
79 |
}
|
|
80 |
|
|
81 |
CSimVoiceLine::~CSimVoiceLine()
|
|
82 |
/**
|
|
83 |
* Destroy the spare call - all the others will be closed by the client (or server).
|
|
84 |
*/
|
|
85 |
{
|
|
86 |
if ((iAnswerNextIncomingCall!=iSpareCall) && (iAnswerNextIncomingCall))
|
|
87 |
{
|
|
88 |
iAnswerNextIncomingCall->Close();
|
|
89 |
}
|
|
90 |
if(iSpareCall)
|
|
91 |
{
|
|
92 |
iSpareCall->Close();
|
|
93 |
}
|
|
94 |
if(iCalls)
|
|
95 |
{
|
|
96 |
iCalls->Delete(0,iCalls->Count());
|
|
97 |
delete iCalls;
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
CTelObject* CSimVoiceLine::OpenNewObjectByNameL(const TDesC& aName)
|
|
102 |
/**
|
|
103 |
* Opens a voice call by name.
|
|
104 |
* This will be called if the user opens a pre-alloc'ed call by name.
|
|
105 |
*
|
|
106 |
* @param aName name of call to be opened
|
|
107 |
* @return CTelObject pointer to the object opened by name
|
|
108 |
* @leave Leaves if name given does not match the required name
|
|
109 |
*/
|
|
110 |
{
|
|
111 |
LOGVOICE1(">>CSimVoiceLine::OpenNewObjectByNameL");
|
|
112 |
TInt i;
|
|
113 |
TInt count=iCalls->Count();
|
|
114 |
|
|
115 |
for(i=0;i<count;i++)
|
|
116 |
{
|
|
117 |
LOGVOICE2(">>CSimVoiceLine::OpenNewObjectByNameL %s",&(iCalls->At(i)->iName));
|
|
118 |
if(iCalls->At(i)->iName.MatchF(aName)==0)
|
|
119 |
{
|
|
120 |
iCalls->At(i)->Open();
|
|
121 |
return iCalls->At(i);
|
|
122 |
}
|
|
123 |
}
|
|
124 |
|
|
125 |
LOGVOICE1("<<CSimVoiceLine::OpenNewObjectByNameL");
|
|
126 |
User::Leave(KErrNotFound);
|
|
127 |
return NULL;
|
|
128 |
}
|
|
129 |
|
|
130 |
CTelObject* CSimVoiceLine::OpenNewObjectL(TDes& aNewName)
|
|
131 |
/**
|
|
132 |
* Open a voice call and return a name.
|
|
133 |
* This function creates a new call object and returns its pointer.
|
|
134 |
*
|
|
135 |
* @param aNewName name of call to be opened
|
|
136 |
* @return CTelObject pointer to the object allocated
|
|
137 |
* @leave Leaves if no memory available
|
|
138 |
*/
|
|
139 |
{
|
|
140 |
return CreateNewCallL(aNewName,ECallTypeNormalCall);
|
|
141 |
}
|
|
142 |
|
|
143 |
CSimCall* CSimVoiceLine::CreateNewCallL(TDes& aNewName,TCallType aCallType)
|
|
144 |
{
|
|
145 |
aNewName.Format(KCommonCallName,iCallCnt++);
|
|
146 |
CSimVoiceCall* newCall=CSimVoiceCall::NewL(this,aNewName,iPhone);
|
|
147 |
CleanupStack::PushL(newCall);
|
|
148 |
iCalls->AppendL(newCall);
|
|
149 |
if(aCallType!=ECallTypeSpareCall)
|
|
150 |
{
|
|
151 |
HandleNewCallAddedNotification(aNewName);
|
|
152 |
}
|
|
153 |
LOGVOICE2(">>CSimVoiceLine::CreateNewCallL 0x%08x",newCall);
|
|
154 |
CleanupStack::Pop(newCall);
|
|
155 |
return newCall;
|
|
156 |
}
|
|
157 |
|
|
158 |
TInt CSimVoiceLine::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage)
|
|
159 |
/**
|
|
160 |
* ExtFunc is called by the server when it has a "extended", i.e. non-core ETel request
|
|
161 |
* for the TSY to process
|
|
162 |
* A request handle, request type and request data are passed to the TSY
|
|
163 |
*
|
|
164 |
* @param aTsyReqHandle
|
|
165 |
* @param aIpc IPc number representing the request
|
|
166 |
* @param aPackage data for the request
|
|
167 |
* @return KErrNone
|
|
168 |
*/
|
|
169 |
{
|
|
170 |
|
|
171 |
TAny* dataPtr=aPackage.Ptr1();
|
|
172 |
|
|
173 |
// The request data has to extracted from TDataPackage and the TAny* pointers have to
|
|
174 |
// be "cast" to the expected request data type
|
|
175 |
|
|
176 |
switch (aIpc)
|
|
177 |
{
|
|
178 |
//
|
|
179 |
// No Flow Control OR Multiple Completion
|
|
180 |
//
|
|
181 |
case EMobileLineGetMobileLineStatus:
|
|
182 |
return GetMobileLineStatus(aTsyReqHandle,
|
|
183 |
REINTERPRET_CAST(RMobileCall::TMobileCallStatus*,dataPtr));
|
|
184 |
|
|
185 |
//
|
|
186 |
// Multiple Completion Services with Immediate Server Repost
|
|
187 |
// (Usually Notifications)
|
|
188 |
//
|
|
189 |
case EMobileLineNotifyMobileLineStatusChange:
|
|
190 |
return NotifyMobileLineStatusChange(aTsyReqHandle,
|
|
191 |
REINTERPRET_CAST(RMobileCall::TMobileCallStatus*, dataPtr));
|
|
192 |
|
|
193 |
default:
|
|
194 |
return KErrNotSupported;
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
TInt CSimVoiceLine::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle)
|
|
199 |
/**
|
|
200 |
* Cancel an outstanding request.
|
|
201 |
* @param aIpc The IPC number of the request that must be cancelled. Note: this is not the
|
|
202 |
* IPC number of the cancel request itself.
|
|
203 |
* @param aTsyReqHandle The TSY Request Handle of the request to be cancelled.
|
|
204 |
*/
|
|
205 |
{
|
|
206 |
switch(aIpc)
|
|
207 |
{
|
|
208 |
case EEtelLineNotifyStatusChange:
|
|
209 |
// Always returns KErrNone
|
|
210 |
(void)NotifyStatusChangeCancel(aTsyReqHandle);
|
|
211 |
return KErrNone;
|
|
212 |
|
|
213 |
case EEtelLineNotifyIncomingCall:
|
|
214 |
// Always returns KErrNone
|
|
215 |
(void)NotifyIncomingCallCancel(aTsyReqHandle);
|
|
216 |
return KErrNone;
|
|
217 |
|
|
218 |
case EEtelLineNotifyHookChange:
|
|
219 |
// Always returns KErrNone
|
|
220 |
(void)NotifyHookChangeCancel(aTsyReqHandle);
|
|
221 |
return KErrNone;
|
|
222 |
|
|
223 |
case EEtelLineNotifyCallAdded:
|
|
224 |
// Always returns KErrNone
|
|
225 |
(void)NotifyCallAddedCancel(aTsyReqHandle);
|
|
226 |
return KErrNone;
|
|
227 |
|
|
228 |
case EMobileLineNotifyMobileLineStatusChange:
|
|
229 |
// Always returns KErrNone
|
|
230 |
(void)NotifyMobileLineStatusChangeCancel(aTsyReqHandle);
|
|
231 |
return KErrNone;
|
|
232 |
|
|
233 |
default:
|
|
234 |
break;
|
|
235 |
}
|
|
236 |
|
|
237 |
return CLineBase::CancelService(aIpc,aTsyReqHandle);
|
|
238 |
}
|
|
239 |
|
|
240 |
TInt CSimVoiceLine::EnumerateCall(const TTsyReqHandle aTsyReqHandle,TInt* aParams)
|
|
241 |
/**
|
|
242 |
* Count and return the number of voice calls used.
|
|
243 |
*
|
|
244 |
* @param aTsyReqHandle
|
|
245 |
* @return KErrNone
|
|
246 |
* @param aParams pointer to the number of calls used
|
|
247 |
*/
|
|
248 |
{
|
|
249 |
*aParams=iCalls->Count();
|
|
250 |
ReqCompleted(aTsyReqHandle,KErrNone);
|
|
251 |
return KErrNone;
|
|
252 |
}
|
|
253 |
|
|
254 |
TInt CSimVoiceLine::GetCallInfo(const TTsyReqHandle aTsyReqHandle,TCallInfoIndex* aCallInfoIndex)
|
|
255 |
/**
|
|
256 |
* Retrieve the Call Information relevant to the numbered call.
|
|
257 |
* Returns the name, the current call status and the call capabilities
|
|
258 |
* TCallInfoIndex specifies which call info is requested.
|
|
259 |
*
|
|
260 |
* @param aTsyReqHandle
|
|
261 |
* @param aCallInfoIndex pointer to the call info
|
|
262 |
* @return KErrNone
|
|
263 |
*/
|
|
264 |
{
|
|
265 |
TInt& i=aCallInfoIndex->iIndex;
|
|
266 |
aCallInfoIndex->iInfo.iCallName.Copy(iCalls->At(i)->iName);
|
|
267 |
aCallInfoIndex->iInfo.iStatus=(RCall::TStatus)iCalls->At(i)->iState;
|
|
268 |
aCallInfoIndex->iInfo.iCallCapsFlags=iCalls->At(i)->Caps();
|
|
269 |
ReqCompleted(aTsyReqHandle,KErrNone);
|
|
270 |
return KErrNone;
|
|
271 |
}
|
|
272 |
|
|
273 |
TInt CSimVoiceLine::FindActiveVoiceCall(CSimVoiceCall*& aCall)
|
|
274 |
/**
|
|
275 |
* Find an active voice call. Return KErrNotFound if no voice calls active.
|
|
276 |
* @param aCall Pointer to active voice call.
|
|
277 |
* @return TInt Standard return error.
|
|
278 |
*/
|
|
279 |
{
|
|
280 |
TInt i;
|
|
281 |
for(i=0;i<iCalls->Count();i++)
|
|
282 |
{
|
|
283 |
if(iCalls->At(i)->iState==RMobileCall::EStatusConnected)
|
|
284 |
{
|
|
285 |
aCall=(CSimVoiceCall*)iCalls->At(i);
|
|
286 |
return KErrNone;
|
|
287 |
}
|
|
288 |
}
|
|
289 |
return KErrNotFound;
|
|
290 |
}
|
|
291 |
|
|
292 |
TInt CSimVoiceLine::FindActiveCall(CSimCall*& aCall)
|
|
293 |
/**
|
|
294 |
* Find an active voice call. Return KErrNotFound if no voice calls active.
|
|
295 |
* @param aCall Pointer to active voice call.
|
|
296 |
* @return TInt Standard return error.
|
|
297 |
*/
|
|
298 |
{
|
|
299 |
TInt i;
|
|
300 |
for(i=0;i<iCalls->Count();i++)
|
|
301 |
{
|
|
302 |
if(iCalls->At(i)->iState==RMobileCall::EStatusConnected)
|
|
303 |
{
|
|
304 |
aCall=(CSimVoiceCall*)iCalls->At(i);
|
|
305 |
return KErrNone;
|
|
306 |
}
|
|
307 |
}
|
|
308 |
return KErrNotFound;
|
|
309 |
}
|
|
310 |
|
|
311 |
TUint CSimVoiceLine::Caps()
|
|
312 |
/**
|
|
313 |
* Return the current capabilities of this line.
|
|
314 |
* @return TUint Current line capabilities.
|
|
315 |
*/
|
|
316 |
{
|
|
317 |
TUint caps=RLine::KCapsVoice;
|
|
318 |
if(iState==RMobileCall::EStatusIdle)
|
|
319 |
caps|=RLine::KCapsEventIncomingCall;
|
|
320 |
return caps;
|
|
321 |
}
|