|
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: Implementation of CPhoneCallForwardQueryHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <featmgr.h> |
|
19 #include <StringLoader.h> |
|
20 #include <mpeengineinfo.h> |
|
21 |
|
22 #include "cphonecallforwardqueryhandler.h" |
|
23 #include "cphonelogger.h" |
|
24 #include "mphonestatemachine.h" |
|
25 #include "phonerssvoip.h" |
|
26 #include "phoneappvoipcommands.hrh" |
|
27 #include "cphonestate.h" |
|
28 #include "cphonestateincall.h" |
|
29 #include "tphonecmdparamcustomdialer.h" |
|
30 #include "tphonecmdparaminteger.h" |
|
31 #include "tphonecmdparamstring.h" |
|
32 #include "tphonecmdparamquery.h" |
|
33 #include "tphonecmdparamglobalnote.h" |
|
34 #include "cphonemainresourceresolver.h" |
|
35 #include "cphonestatemachinevoip.h" |
|
36 #include "tphonecmdparamstring.h" |
|
37 #include "phoneviewcommanddefinitions.h" |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CPhoneCallForwardQueryHandler::CPhoneCallForwardQueryHandler |
|
43 // C++ constructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CPhoneCallForwardQueryHandler::CPhoneCallForwardQueryHandler( |
|
47 MPhoneStateMachine& aStateMachine, |
|
48 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
49 : iStateMachine( aStateMachine ), |
|
50 iViewCommandHandle( aViewCommandHandle ), |
|
51 iMultipleChoicesArray( NULL ) |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CPhoneCallForwardQueryHandler::ConstructL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CPhoneCallForwardQueryHandler::ConstructL() |
|
62 { |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CPhoneCallForwardQueryHandler::NewL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CPhoneCallForwardQueryHandler* CPhoneCallForwardQueryHandler::NewL( |
|
71 MPhoneStateMachine& aStateMachine, |
|
72 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
73 { |
|
74 CPhoneCallForwardQueryHandler* self = |
|
75 CPhoneCallForwardQueryHandler::NewLC( |
|
76 aStateMachine, aViewCommandHandle ); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CPhoneCallForwardQueryHandler::NewLC |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CPhoneCallForwardQueryHandler* CPhoneCallForwardQueryHandler::NewLC( |
|
87 MPhoneStateMachine& aStateMachine, |
|
88 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
89 { |
|
90 CPhoneCallForwardQueryHandler* self = |
|
91 new( ELeave ) CPhoneCallForwardQueryHandler( |
|
92 aStateMachine, aViewCommandHandle ); |
|
93 CleanupStack::PushL( self ); |
|
94 self->ConstructL(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CPhoneCallForwardQueryHandler::~CPhoneCallForwardQueryHandler |
|
101 // Destructor. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CPhoneCallForwardQueryHandler::~CPhoneCallForwardQueryHandler() |
|
105 { |
|
106 delete iMultipleChoicesArray; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CPhoneCallForwardQueryHandler::ShowMovedPermanentlyQueryL |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CPhoneCallForwardQueryHandler::ShowMovedPermanentlyQueryL( |
|
114 TInt aCallId ) |
|
115 { |
|
116 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
117 "CPhoneCallForwardQueryHandler::ShowMovedPermanentlyQueryL" ) |
|
118 |
|
119 iCallId = aCallId; |
|
120 iAddressArray = iStateMachine.PhoneEngineInfo()-> |
|
121 ForwardAddressChoices( aCallId ); |
|
122 |
|
123 if ( NULL == iAddressArray ) |
|
124 { |
|
125 User::Leave( KErrNotSupported ); |
|
126 } |
|
127 |
|
128 iQueryType = EPhoneMovedPermanently; |
|
129 TPhoneCmdParamQuery queryParam; |
|
130 queryParam.SetQueryCommandObserver( *this ); |
|
131 queryParam.SetTone( EAvkonSIDInformationTone ); |
|
132 queryParam.SetQueryType( EPhoneGlobalQueryDialog ); |
|
133 |
|
134 HBufC* queryPrompt = StringLoader::LoadLC( |
|
135 CPhoneMainResourceResolver::Instance()->ResolveResourceID( |
|
136 EPhoneVoIPMovedPermanentlyQueryHeader )); |
|
137 |
|
138 queryParam.SetQueryPrompt( *queryPrompt ); |
|
139 |
|
140 queryParam.SetDefaultCba( |
|
141 CPhoneMainResourceResolver::Instance()-> |
|
142 ResolveResourceID( EPhoneVoIPMovedPermanentlySoftkeys ) ); |
|
143 |
|
144 iCommandProcessed = EFalse; |
|
145 |
|
146 iViewCommandHandle.ExecuteCommandL( EPhoneViewShowQuery, &queryParam ); |
|
147 |
|
148 CleanupStack::PopAndDestroy( queryPrompt ); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CPhoneCallForwardQueryHandler::ShowMultipleChoicesQueryL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CPhoneCallForwardQueryHandler::ShowMultipleChoicesQueryL( |
|
156 TInt aCallId ) |
|
157 { |
|
158 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
159 "CPhoneCallForwardQueryHandler::ShowMultipleChoicesQueryL" ) |
|
160 |
|
161 iCallId = aCallId; |
|
162 iAddressArray = iStateMachine.PhoneEngineInfo()-> |
|
163 ForwardAddressChoices( aCallId ); |
|
164 |
|
165 if ( NULL == iAddressArray ) |
|
166 { |
|
167 User::Leave( KErrNotSupported ); |
|
168 } |
|
169 |
|
170 ResetMultipleChoicesArrayL( *iAddressArray ); |
|
171 |
|
172 iQueryType = EPhoneMultipleChoices; |
|
173 TPhoneCmdParamQuery queryParam; |
|
174 queryParam.SetQueryCommandObserver( *this ); |
|
175 queryParam.SetTone( EAvkonSIDInformationTone ); |
|
176 queryParam.SetQueryType( EPhoneCustomListQueryDialog ); |
|
177 queryParam.SetItemTextArrayForListQuery( |
|
178 static_cast<MDesCArray&> ( *iMultipleChoicesArray ) ); |
|
179 |
|
180 queryParam.SetQueryResourceId( |
|
181 CPhoneMainResourceResolver::Instance()->ResolveResourceID( |
|
182 EPhoneVoIPMultipleChoicesListQuery ) ); |
|
183 |
|
184 iCommandProcessed = EFalse; |
|
185 |
|
186 iViewCommandHandle.ExecuteCommandL( EPhoneViewShowQuery, &queryParam ); |
|
187 |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CPhoneCallForwardQueryHandler::AddToContacsL |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CPhoneCallForwardQueryHandler::AddToContacsL( |
|
195 TBool aCreateNew ) |
|
196 { |
|
197 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
198 "CPhoneCallForwardQueryHandler::AddToContacsL" ) |
|
199 |
|
200 if ( !iAddressArray || |
|
201 0 == iAddressArray->Count() ) |
|
202 { |
|
203 User::Leave( KErrNotFound ); |
|
204 } |
|
205 |
|
206 HBufC* buf = HBufC::NewLC( iAddressArray->MdcaPoint(0).Length() ); |
|
207 buf->Des().Copy( iAddressArray->MdcaPoint(0) ); |
|
208 TPtr ptr( buf->Des() ); |
|
209 |
|
210 iCommandProcessed = EFalse; |
|
211 |
|
212 TPhoneCmdParamString stringParam; |
|
213 stringParam.SetString( &ptr ); |
|
214 iViewCommandHandle.ExecuteCommandL( |
|
215 aCreateNew ? EPhoneViewAddContactByString : |
|
216 EPhoneViewUpdateContactByString, |
|
217 &stringParam ); |
|
218 |
|
219 CleanupStack::PopAndDestroy( buf ); |
|
220 |
|
221 // Forward call to array index 0 |
|
222 ForwardCallToAddressL( 0 ); |
|
223 } |
|
224 |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CPhoneCallForwardQueryHandler::SaveAddressToContactsL |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CPhoneCallForwardQueryHandler::SaveAddressToContactsL() |
|
231 { |
|
232 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
233 "CPhoneCallForwardQueryHandler::SaveAddressToContactsL" ) |
|
234 |
|
235 TPhoneCmdParamQuery queryDialogParam; |
|
236 iQueryType = EPhoneQueryAddToContacts; |
|
237 queryDialogParam.SetQueryCommandObserver( *this ); |
|
238 queryDialogParam.SetQueryType( EPhoneContactsListQuery ); |
|
239 queryDialogParam.SetQueryResourceId( |
|
240 CPhoneMainResourceResolver::Instance()-> |
|
241 ResolveResourceID( EPhoneAddtoContactsListQuery ) ); |
|
242 |
|
243 iCommandProcessed = EFalse; |
|
244 |
|
245 // Display dialog |
|
246 iViewCommandHandle.ExecuteCommandL( EPhoneViewShowQuery, |
|
247 &queryDialogParam ); |
|
248 |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // CPhoneCallForwardQueryHandler::ProcessCommandL |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CPhoneCallForwardQueryHandler::ProcessCommandL( |
|
256 TInt aCommandId ) |
|
257 { |
|
258 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
259 "CPhoneCallForwardQueryHandler::ProcessCommandL" ) |
|
260 |
|
261 if ( iCommandProcessed ) |
|
262 { |
|
263 return; |
|
264 } |
|
265 |
|
266 iCommandProcessed = ETrue; |
|
267 |
|
268 if ( iQueryType == EPhoneQueryAddToContacts ) |
|
269 { |
|
270 switch ( aCommandId ) |
|
271 { |
|
272 case EPhoneNumberAcqCmdSave: |
|
273 AddToContacsL( ETrue ); |
|
274 break; |
|
275 |
|
276 case EPhoneNumberAcqCmdAddToName: |
|
277 AddToContacsL( EFalse ); |
|
278 break; |
|
279 case EAknSoftkeyCancel: |
|
280 iStateMachine.SendPhoneEngineMessage( |
|
281 MPEPhoneModel::EPEMessageRelease ); |
|
282 break; |
|
283 } |
|
284 } |
|
285 else if ( iQueryType == EPhoneMovedPermanently ) |
|
286 { |
|
287 switch ( aCommandId ) |
|
288 { |
|
289 case EAknSoftkeyOk: |
|
290 SaveAddressToContactsL(); |
|
291 break; |
|
292 |
|
293 default: |
|
294 iStateMachine.SendPhoneEngineMessage( |
|
295 MPEPhoneModel::EPEMessageRelease ); |
|
296 break; |
|
297 } |
|
298 } |
|
299 else if ( iQueryType == EPhoneMultipleChoices ) |
|
300 { |
|
301 if ( iAddressArray && aCommandId >= 0 && |
|
302 aCommandId < iAddressArray->MdcaCount() ) |
|
303 { |
|
304 ForwardCallToAddressL( aCommandId ); |
|
305 } |
|
306 else |
|
307 { |
|
308 iStateMachine.SendPhoneEngineMessage( |
|
309 MPEPhoneModel::EPEMessageRelease ); |
|
310 } |
|
311 } |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CPhoneCallForwardQueryHandler::ShowCallForwardedNoteL |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CPhoneCallForwardQueryHandler::ShowCallForwardedNoteL() |
|
319 { |
|
320 __LOGMETHODSTARTEND(PhoneUIVoIPExtension, |
|
321 "CPhoneCallForwardQueryHandler::ShowCallForwardedNoteL( ) "); |
|
322 |
|
323 CPhoneState* phoneState = |
|
324 static_cast< CPhoneState* >( iStateMachine.State() ); |
|
325 |
|
326 phoneState->SendGlobalInfoNoteL( EPhoneRemoteForwarding ); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CPhoneCallForwardQueryHandler::ResetMultipleChoicesArrayL |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 void CPhoneCallForwardQueryHandler::ResetMultipleChoicesArrayL( |
|
334 const MDesC8Array& aAddressArray ) |
|
335 { |
|
336 __LOGMETHODSTARTEND(PhoneUIVoIPExtension, |
|
337 "CPhoneCallForwardQueryHandler::ResetMultipleChoicesArrayL( ) "); |
|
338 |
|
339 delete iMultipleChoicesArray; |
|
340 iMultipleChoicesArray = NULL; |
|
341 |
|
342 iMultipleChoicesArray = |
|
343 new(ELeave) CDesC16ArrayFlat( aAddressArray.MdcaCount() ); |
|
344 |
|
345 for ( TInt i=0; i< aAddressArray.MdcaCount() ; i++ ) |
|
346 { |
|
347 HBufC* buf = HBufC::NewLC( aAddressArray.MdcaPoint(i).Length() ); |
|
348 buf->Des().Copy( aAddressArray.MdcaPoint(i) ); |
|
349 iMultipleChoicesArray->AppendL( *buf ); |
|
350 CleanupStack::PopAndDestroy( buf ); |
|
351 } |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CPhoneCallForwardQueryHandler::ForwardCallToAddressL |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CPhoneCallForwardQueryHandler::ForwardCallToAddressL( |
|
359 TInt aIndex ) |
|
360 { |
|
361 __LOGMETHODSTARTEND(PhoneUIVoIPExtension, |
|
362 "CPhoneCallForwardQueryHandler::ForwardCallToAddressL( ) "); |
|
363 |
|
364 ShowCallForwardedNoteL(); |
|
365 iStateMachine.PhoneEngineInfo()->SetForwardAddressIndex( aIndex ); |
|
366 iStateMachine.SendPhoneEngineMessage( |
|
367 MPEPhoneModel::EPEMessageForwardCallToAddress ); |
|
368 } |
|
369 |
|
370 // End of File |