74
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "MPhoneViewCommandHandle.h"
|
|
18 |
#include "TPhoneCommandParam.h"
|
|
19 |
#include "TPhoneCmdParamBoolean.h"
|
|
20 |
#include "TPhoneCmdParamInteger.h"
|
|
21 |
#include "TPhoneCmdParamEmergencyCallHeaderData.h"
|
|
22 |
#include "TPhoneCmdParamCallStateData.h"
|
|
23 |
|
|
24 |
#include "TPhoneCmdParamCallHeaderData.h"
|
|
25 |
|
|
26 |
struct TCmds
|
|
27 |
{
|
|
28 |
public:
|
|
29 |
TInt iCmd;
|
|
30 |
TPhoneUICommandParam* iP;
|
|
31 |
};
|
|
32 |
|
|
33 |
class CPhoneViewController : public MPhoneViewCommandHandle, public CBase
|
|
34 |
{
|
|
35 |
|
|
36 |
|
|
37 |
public: // Constructors and destructor
|
|
38 |
|
|
39 |
CPhoneViewController(){}
|
|
40 |
|
|
41 |
static CPhoneViewController* NewL()
|
|
42 |
{
|
|
43 |
CPhoneViewController* self = new (ELeave) CPhoneViewController();
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Destructor.
|
|
50 |
*/
|
|
51 |
~CPhoneViewController()
|
|
52 |
{
|
|
53 |
if(iCmds)
|
|
54 |
{
|
|
55 |
for(TInt i = 0; i<iCmds->Count(); i++)
|
|
56 |
{
|
|
57 |
TCmds t = iCmds->At(i);
|
|
58 |
delete t.iP;
|
|
59 |
|
|
60 |
}
|
|
61 |
|
|
62 |
iCmds->Reset();
|
|
63 |
}
|
|
64 |
|
|
65 |
delete iCmds;
|
|
66 |
};
|
|
67 |
|
|
68 |
public: // New functions
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Execute Command with given Command Id
|
|
72 |
* @param aCmdId Command Id
|
|
73 |
* @return None
|
|
74 |
*/
|
|
75 |
void ExecuteCommandL(
|
|
76 |
TPhoneViewCommandId aCmdId )
|
|
77 |
{
|
|
78 |
if(iCmds == NULL)
|
|
79 |
iCmds = new (ELeave) CArrayFixFlat<TCmds> (10);
|
|
80 |
TCmds cmd;
|
|
81 |
cmd.iCmd = aCmdId;
|
|
82 |
cmd.iP = NULL;
|
|
83 |
iCmds->AppendL( cmd );
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Execute Command with given Command Id and Call Id
|
|
88 |
* @param aCmdId Command Id
|
|
89 |
* @param aCallId Call Id
|
|
90 |
* @return None
|
|
91 |
*/
|
|
92 |
void ExecuteCommandL(
|
|
93 |
TPhoneViewCommandId aCmdId,
|
|
94 |
TInt /*aCallId*/ )
|
|
95 |
{
|
|
96 |
ExecuteCommandL( aCmdId );
|
|
97 |
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Execute Command with given command id, call id and command parameter.
|
|
102 |
* @param aCmdId Command Id
|
|
103 |
* @param aCommandParam Command parameter
|
|
104 |
* @return None
|
|
105 |
*/
|
|
106 |
void ExecuteCommandL(
|
|
107 |
TPhoneViewCommandId aCmdId,
|
|
108 |
TPhoneCommandParam* aCommandParam )
|
|
109 |
{
|
|
110 |
if( iCmds == NULL )
|
|
111 |
iCmds = new (ELeave) CArrayFixFlat<TCmds> (10);
|
|
112 |
TCmds cmd;
|
|
113 |
cmd.iCmd = aCmdId;
|
|
114 |
|
|
115 |
switch ( aCmdId )
|
|
116 |
{
|
|
117 |
case EPhoneViewGetCountOfActiveCalls:
|
|
118 |
{
|
|
119 |
if ( aCommandParam->ParamId() ==
|
|
120 |
TPhoneCommandParam::EPhoneParamIdInteger )
|
|
121 |
{
|
|
122 |
TPhoneCmdParamInteger* intParam =
|
|
123 |
static_cast<TPhoneCmdParamInteger*>( aCommandParam );
|
|
124 |
|
|
125 |
intParam->SetInteger( iActiveCallCount );
|
|
126 |
}
|
|
127 |
}
|
|
128 |
break;
|
|
129 |
|
|
130 |
case EPhoneViewGetCallExistsInConference:
|
|
131 |
{
|
|
132 |
if ( aCommandParam->ParamId() ==
|
|
133 |
TPhoneCommandParam::EPhoneParamIdBoolean )
|
|
134 |
{
|
|
135 |
static_cast<TPhoneCmdParamBoolean*>(aCommandParam)->SetBoolean( iCallExistsInConference );
|
|
136 |
}
|
|
137 |
}
|
|
138 |
break;
|
|
139 |
}
|
|
140 |
|
|
141 |
if ( aCommandParam->ParamId() == TPhoneCommandParam::EPhoneParamIdBoolean )
|
|
142 |
{
|
|
143 |
TPhoneCmdParamBoolean* value =
|
|
144 |
static_cast<TPhoneCmdParamBoolean*>( aCommandParam );
|
|
145 |
TPhoneCmdParamBoolean* value2 = new (ELeave) TPhoneCmdParamBoolean (*value);
|
|
146 |
cmd.iP = value2;
|
|
147 |
}
|
|
148 |
else if ( aCommandParam->ParamId() == TPhoneCommandParam::EPhoneParamIdInteger )
|
|
149 |
{
|
|
150 |
TPhoneCmdParamInteger* value =
|
|
151 |
static_cast<TPhoneCmdParamInteger*>( aCommandParam );
|
|
152 |
TPhoneCmdParamInteger* value2 = new (ELeave) TPhoneCmdParamInteger (*value);
|
|
153 |
cmd.iP = value2;
|
|
154 |
}
|
|
155 |
else if ( aCommandParam->ParamId() == TPhoneCommandParam::EPhoneParamIdCallHeaderData )
|
|
156 |
{
|
|
157 |
TPhoneCmdParamCallHeaderData* value =
|
|
158 |
static_cast<TPhoneCmdParamCallHeaderData*>( aCommandParam );
|
|
159 |
TPhoneCmdParamCallHeaderData* value2 = new (ELeave) TPhoneCmdParamCallHeaderData( *value);
|
|
160 |
cmd.iP = value2;
|
|
161 |
}
|
|
162 |
else if( aCommandParam->ParamId() == TPhoneCommandParam::EPhoneParamIdEmergencyCallHeaderData)
|
|
163 |
{
|
|
164 |
TPhoneCmdParamEmergencyCallHeaderData* value =
|
|
165 |
static_cast<TPhoneCmdParamEmergencyCallHeaderData*>( aCommandParam );
|
|
166 |
TPhoneCmdParamEmergencyCallHeaderData* value2 = new (ELeave) TPhoneCmdParamEmergencyCallHeaderData( *value);
|
|
167 |
cmd.iP = value2;
|
|
168 |
}
|
|
169 |
else
|
|
170 |
{
|
|
171 |
cmd.iP = NULL;
|
|
172 |
}
|
|
173 |
|
|
174 |
iCmds->AppendL( cmd );
|
|
175 |
}
|
|
176 |
|
|
177 |
/**
|
|
178 |
* Execute Command with given command id, call id and command parameter.
|
|
179 |
* @param aCmdId Command Id
|
|
180 |
* @param aCallId Call Id
|
|
181 |
* @param aCommandParam Command parameter
|
|
182 |
* @return None
|
|
183 |
*/
|
|
184 |
void ExecuteCommandL(
|
|
185 |
TPhoneViewCommandId aCmdId,
|
|
186 |
TInt /*aCallId*/,
|
|
187 |
TPhoneCommandParam* aCommandParam )
|
|
188 |
{
|
|
189 |
ExecuteCommandL( aCmdId, aCommandParam );
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Execute Command with given command id, call id and message.
|
|
194 |
* @param aCmdId Command Id
|
|
195 |
* @param aCallId Call Id
|
|
196 |
* @param aMessage Command message
|
|
197 |
*/
|
|
198 |
void ExecuteCommandL(
|
|
199 |
TPhoneViewCommandId /*aCmdId*/,
|
|
200 |
TInt /*aCallId*/,
|
|
201 |
TDesC& /*aMessage*/ ){}
|
|
202 |
|
|
203 |
/**
|
|
204 |
* From MPhoneViewCommandHandle
|
|
205 |
*/
|
|
206 |
void ExecuteCommand(
|
|
207 |
TPhoneViewCommandId /*aCmdId*/ ){}
|
|
208 |
|
|
209 |
/**
|
|
210 |
* From MPhoneViewCommandHandle
|
|
211 |
*/
|
|
212 |
void ExecuteCommand(
|
|
213 |
TPhoneViewCommandId aCmdId,
|
|
214 |
TPhoneCommandParam* /*aCommandParam*/ )
|
|
215 |
{
|
|
216 |
ExecuteCommandL( aCmdId );
|
|
217 |
}
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Handle Command with given Command Id
|
|
221 |
* @param aCmdId Command Id
|
|
222 |
* @return TPhoneViewResponseId
|
|
223 |
*/
|
|
224 |
TPhoneViewResponseId HandleCommandL(
|
|
225 |
TPhoneViewCommandId /*aCmdId*/ ) { return iViewResponseId; }
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Handle Command with given command id and command parameter.
|
|
229 |
* @param aCmdId Command Id
|
|
230 |
* @param aCommandParam Command parameter
|
|
231 |
* @return TPhoneViewResponseId
|
|
232 |
*/
|
|
233 |
TPhoneViewResponseId HandleCommandL(
|
|
234 |
TPhoneViewCommandId /*aCmdId*/,
|
|
235 |
TPhoneCommandParam* aCommandParam )
|
|
236 |
{
|
|
237 |
|
|
238 |
if ( aCommandParam->ParamId() ==
|
|
239 |
TPhoneCommandParam::EPhoneParamIdCallStateData )
|
|
240 |
{
|
|
241 |
TPhoneCmdParamCallStateData* stateParam =
|
|
242 |
static_cast<TPhoneCmdParamCallStateData*>( aCommandParam );
|
|
243 |
stateParam->SetCallId( iCallId );
|
|
244 |
}
|
|
245 |
|
|
246 |
return iViewResponseId; }
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Execute Command with given Command Id
|
|
250 |
*/
|
|
251 |
const TDesC& FetchContent() { return KNullDesC();}
|
|
252 |
|
|
253 |
//helper functions:
|
|
254 |
|
|
255 |
TInt VerifyViewCommand( const TInt& aCmd )
|
|
256 |
{
|
|
257 |
_LIT(KDesC, "Checking command id = %d ");
|
|
258 |
EUNIT_PRINT( KDesC(), aCmd );
|
|
259 |
|
|
260 |
TInt count = iCmds->Count();
|
|
261 |
TBool cmdFound = EFalse;
|
|
262 |
TInt i = 0;
|
|
263 |
for ( ; i < count; i++ )
|
|
264 |
{
|
|
265 |
TCmds cmd = iCmds->At(i);
|
|
266 |
if( cmd.iCmd == aCmd )
|
|
267 |
{
|
|
268 |
cmdFound = ETrue;
|
|
269 |
break;
|
|
270 |
}
|
|
271 |
}
|
|
272 |
|
|
273 |
EUNIT_ASSERT_DESC( cmdFound, "View Command not ok" );
|
|
274 |
return i;
|
|
275 |
}
|
|
276 |
|
|
277 |
void VerifyViewCommandBoolean( const TInt& aCmd, const TBool& aValue )
|
|
278 |
{
|
|
279 |
TBool paramOk = EFalse;
|
|
280 |
|
|
281 |
for( TInt j = 0 ; j<iCmds->Count(); j++)
|
|
282 |
{
|
|
283 |
TCmds cmd = iCmds->At(j);
|
|
284 |
if( cmd.iCmd == aCmd )
|
|
285 |
{
|
|
286 |
_LIT(KDesC, "Checking command id = %d ");
|
|
287 |
EUNIT_PRINT( KDesC(), aCmd );
|
|
288 |
|
|
289 |
TPhoneUICommandParam* p = cmd.iP;
|
|
290 |
TPhoneCmdParamBoolean* booleanValue =
|
|
291 |
static_cast<TPhoneCmdParamBoolean*>( p );
|
|
292 |
TBool val = booleanValue->Boolean();
|
|
293 |
if( val == aValue )
|
|
294 |
{
|
|
295 |
paramOk = ETrue;
|
|
296 |
break;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
}
|
|
300 |
|
|
301 |
EUNIT_ASSERT_DESC( paramOk, "View Boolean param not ok" );
|
|
302 |
}
|
|
303 |
|
|
304 |
void VerifyViewCommandInteger( const TInt& aCmd, const TInt& aValue )
|
|
305 |
{
|
|
306 |
TBool paramOk = EFalse;
|
|
307 |
|
|
308 |
for( TInt j = 0 ; j< iCmds->Count(); j++)
|
|
309 |
{
|
|
310 |
TCmds cmd = iCmds->At(j);
|
|
311 |
if( cmd.iCmd == aCmd )
|
|
312 |
{
|
|
313 |
_LIT(KDesC, "Checking command id = %d ");
|
|
314 |
EUNIT_PRINT( KDesC(), aCmd );
|
|
315 |
TPhoneCmdParamInteger* value = static_cast<TPhoneCmdParamInteger*>( cmd.iP );
|
|
316 |
|
|
317 |
if( value->Integer() == aValue )
|
|
318 |
{
|
|
319 |
paramOk = ETrue;
|
|
320 |
break;
|
|
321 |
}
|
|
322 |
}
|
|
323 |
}
|
|
324 |
|
|
325 |
EUNIT_ASSERT_DESC( paramOk, "View Integer param not ok" );
|
|
326 |
}
|
|
327 |
|
|
328 |
void VerifyViewCommandCallHeader( const TInt& aCmd, const TPhoneCmdParamCallHeaderData& aValue )
|
|
329 |
{
|
|
330 |
TBool paramOk = EFalse;
|
|
331 |
|
|
332 |
for( TInt j = 0 ; j< iCmds->Count(); j++)
|
|
333 |
{
|
|
334 |
TCmds cmd = iCmds->At(j);
|
|
335 |
if( cmd.iCmd == aCmd )
|
|
336 |
{
|
|
337 |
_LIT(KDesC, "Checking command id = %d ");
|
|
338 |
EUNIT_PRINT( KDesC(), aCmd );
|
|
339 |
TPhoneCmdParamCallHeaderData* value = static_cast<TPhoneCmdParamCallHeaderData*>( cmd.iP );
|
|
340 |
if( CheckCallheaderValues( *value, aValue) == KErrNone )
|
|
341 |
{
|
|
342 |
paramOk = ETrue;
|
|
343 |
break;
|
|
344 |
}
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
EUNIT_ASSERT_DESC( paramOk, "View Call Header param not ok" );
|
|
349 |
}
|
|
350 |
|
|
351 |
TInt CheckCallheaderValues(const TPhoneCmdParamCallHeaderData& aActual,
|
|
352 |
const TPhoneCmdParamCallHeaderData& aExpected )
|
|
353 |
{
|
|
354 |
EUNIT_PRINT(_L("Checking CallHeaderData"));
|
|
355 |
if( aActual.CallState() != aExpected.CallState())
|
|
356 |
{
|
|
357 |
EUNIT_PRINT(_L("CallState does not match."));
|
|
358 |
return KErrNotFound;
|
|
359 |
}
|
|
360 |
|
|
361 |
if(aActual.Line2() != aExpected.Line2() )
|
|
362 |
{
|
|
363 |
EUNIT_PRINT(_L("Line2 does not match."));
|
|
364 |
return KErrNotFound;
|
|
365 |
}
|
|
366 |
|
|
367 |
return KErrNone;
|
|
368 |
}
|
|
369 |
|
|
370 |
void SetViewGetCountOfActiveCalls( TInt aValue )
|
|
371 |
{
|
|
372 |
iActiveCallCount = aValue;
|
|
373 |
}
|
|
374 |
|
|
375 |
|
|
376 |
void SetViewGetCallExistsInConference( TInt aValue )
|
|
377 |
{
|
|
378 |
iCallExistsInConference = aValue;
|
|
379 |
}
|
|
380 |
|
|
381 |
void ResetCommands()
|
|
382 |
{
|
|
383 |
if(iCmds)
|
|
384 |
{
|
|
385 |
for(TInt i = 0; i<iCmds->Count(); i++)
|
|
386 |
{
|
|
387 |
TCmds t = iCmds->At(i);
|
|
388 |
delete t.iP;
|
|
389 |
|
|
390 |
}
|
|
391 |
iCmds->Reset();
|
|
392 |
}
|
|
393 |
}
|
|
394 |
public: // members
|
|
395 |
TPhoneViewResponseId iViewResponseId;
|
|
396 |
CArrayFixFlat<TCmds>* iCmds;
|
|
397 |
TInt iCallId;
|
|
398 |
TInt iActiveCallCount;
|
|
399 |
TBool iCallExistsInConference;
|
|
400 |
TBool iHoldFlag;
|
|
401 |
};
|
|
402 |
|