|
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 CPhoneUnattendedTransferCmdHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <featmgr.h> |
|
19 #include <mpeengineinfo.h> |
|
20 #include "cphoneunattendedtransfercmdhandler.h" |
|
21 |
|
22 #include "cphonelogger.h" |
|
23 #include "mphonestatemachine.h" |
|
24 #include "cphonetransferdialercontroller.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 |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CPhoneUnattendedTransferCmdHandler::CPhoneUnattendedTransferCmdHandler |
|
41 // C++ constructor. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CPhoneUnattendedTransferCmdHandler::CPhoneUnattendedTransferCmdHandler( |
|
45 MPhoneStateMachine& aStateMachine, |
|
46 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
47 : iStateMachine( aStateMachine ), iViewCommandHandle( aViewCommandHandle ) |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CPhoneUnattendedTransferCmdHandler::ConstructL |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CPhoneUnattendedTransferCmdHandler::ConstructL() |
|
58 { |
|
59 iTransferDialerController = CPhoneTransferDialerController::NewL(); |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CPhoneUnattendedTransferCmdHandler::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CPhoneUnattendedTransferCmdHandler* CPhoneUnattendedTransferCmdHandler::NewL( |
|
68 MPhoneStateMachine& aStateMachine, |
|
69 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
70 { |
|
71 CPhoneUnattendedTransferCmdHandler* self = |
|
72 CPhoneUnattendedTransferCmdHandler::NewLC( |
|
73 aStateMachine, aViewCommandHandle ); |
|
74 CleanupStack::Pop( self ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CPhoneUnattendedTransferCmdHandler::NewLC |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CPhoneUnattendedTransferCmdHandler* CPhoneUnattendedTransferCmdHandler::NewLC( |
|
84 MPhoneStateMachine& aStateMachine, |
|
85 MPhoneViewCommandHandle& aViewCommandHandle ) |
|
86 { |
|
87 CPhoneUnattendedTransferCmdHandler* self = |
|
88 new( ELeave ) CPhoneUnattendedTransferCmdHandler( |
|
89 aStateMachine, aViewCommandHandle ); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CPhoneUnattendedTransferCmdHandler::~CPhoneUnattendedTransferCmdHandler |
|
98 // Destructor. |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CPhoneUnattendedTransferCmdHandler::~CPhoneUnattendedTransferCmdHandler() |
|
102 { |
|
103 delete iTransferDialerController; |
|
104 } |
|
105 |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CPhoneUnattendedTransferCmdHandler::HandleCommandL |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void CPhoneUnattendedTransferCmdHandler::HandleCommandL( TInt aCommand ) |
|
112 { |
|
113 switch ( aCommand ) |
|
114 { |
|
115 case EPhoneInCallCmdUnattendedTransfer: |
|
116 ShowTransferDialerL(); |
|
117 break; |
|
118 |
|
119 case EPhoneCmdTransferDialerOk: |
|
120 DoUnattendedTransferL(); |
|
121 break; |
|
122 |
|
123 case EPhoneCmdTransferDialerExit: |
|
124 CloseTransferDialerL(); |
|
125 break; |
|
126 |
|
127 case EPhoneCmdTransferDialerSearch: |
|
128 OpenSingleItemContactFetchL( |
|
129 EPhoneCmdTransferDialerContactFetch ); |
|
130 break; |
|
131 |
|
132 case EPhoneCmdTransferDialerContactFetch: |
|
133 { |
|
134 TBuf<KPhoneNumberEntryBufferSize> fetchContent; |
|
135 fetchContent = iViewCommandHandle.FetchContent(); |
|
136 |
|
137 // Set transfer to address to the phoneengine |
|
138 iStateMachine.PhoneEngineInfo()-> |
|
139 SetTransferTargetCommand( fetchContent ); |
|
140 iStateMachine.SendPhoneEngineMessage( |
|
141 MPEPhoneModel::EPEMessageDoUnattendedTransfer ); |
|
142 |
|
143 ShowWaitingAcceptanceNoteL(); |
|
144 } |
|
145 break; |
|
146 |
|
147 default: |
|
148 __PHONELOG( EOnlyFatal, PhoneUIVoIPExtension, |
|
149 "CPhoneUnattendedTransferCmdHandler::HandleCommandL, DEFAULT" ); |
|
150 ASSERT( EFalse ); |
|
151 } |
|
152 } |
|
153 |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CPhoneUnattendedTransferCmdHandler::ShowTransferDialerL |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CPhoneUnattendedTransferCmdHandler::ShowTransferDialerL() |
|
160 { |
|
161 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
162 "CPhoneUnattendedTransferCmdHandler::ShowTransferDialerL" ) |
|
163 |
|
164 CPhoneState* phoneState = static_cast<CPhoneState*>( iStateMachine.State() ); |
|
165 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
166 { |
|
167 TPhoneCmdParamCustomDialer customDialerParam; |
|
168 customDialerParam.SetDialerController( iTransferDialerController ); |
|
169 |
|
170 // Set dialer to transfer mode. |
|
171 iViewCommandHandle.ExecuteCommandL( |
|
172 EPhoneViewShowCustomizedDialer, |
|
173 &customDialerParam ); |
|
174 |
|
175 // Open transfer dialer |
|
176 phoneState->BeginTransEffectLC( ENumberEntryCreate ); |
|
177 iViewCommandHandle.ExecuteCommandL( EPhoneViewCreateNumberEntry ); |
|
178 phoneState->EndTransEffect(); |
|
179 |
|
180 // Update CBA to transfer dialer CBA |
|
181 TPhoneCmdParamInteger resourceId; |
|
182 resourceId.SetInteger( CPhoneMainResourceResolver::Instance()-> |
|
183 ResolveResourceID( iTransferDialerController->CbaResourceId() ) ); |
|
184 iViewCommandHandle.ExecuteCommandL( EPhoneViewUpdateCba, |
|
185 &resourceId ); |
|
186 } |
|
187 else |
|
188 { |
|
189 HBufC *text = HBufC::NewLC( KPhoneNumberEntryBufferSize ); |
|
190 TPtr ptr( text->Des() ); |
|
191 // Pre-populate the query with the number entry contents, if it exists |
|
192 if ( phoneState->IsNumberEntryUsedL() ) |
|
193 { |
|
194 // get the number entry contents |
|
195 TPhoneCmdParamString stringParam; |
|
196 stringParam.SetString( &ptr ); |
|
197 iViewCommandHandle.ExecuteCommandL( |
|
198 EPhoneViewGetLocalizedNumberFromEntry, |
|
199 &stringParam ); |
|
200 } |
|
201 |
|
202 TPhoneCmdParamQuery queryDialogParam; |
|
203 queryDialogParam.SetQueryType( EPhoneGenericTextQuery ); |
|
204 queryDialogParam.SetQueryResourceId( |
|
205 CPhoneMainResourceResolver::Instance()-> |
|
206 ResolveResourceID( EPhoneVoIPTransferAddressQuery ) ); |
|
207 |
|
208 queryDialogParam.SetDefaultCba( CPhoneMainResourceResolver::Instance()-> |
|
209 ResolveResourceID( EPhoneVoIPTransferAddressQueryEmptySoftkeys ) ); |
|
210 |
|
211 queryDialogParam.SetContentCba( CPhoneMainResourceResolver::Instance()-> |
|
212 ResolveResourceID( EPhoneVoIPTransferAddressQueryNotEmptySoftkeys ) ); |
|
213 |
|
214 queryDialogParam.SetDataText( &ptr ); |
|
215 queryDialogParam.SetSendKeyEnabled( ETrue ); |
|
216 |
|
217 // Display dialog |
|
218 iViewCommandHandle.ExecuteCommandL( |
|
219 EPhoneViewShowQuery, &queryDialogParam ); |
|
220 |
|
221 CleanupStack::PopAndDestroy( text ); |
|
222 } |
|
223 } |
|
224 |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CPhoneUnattendedTransferCmdHandler::DoUnattendedTransferL |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CPhoneUnattendedTransferCmdHandler::DoUnattendedTransferL() |
|
231 { |
|
232 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
233 "CPhoneUnattendedTransferCmdHandler::DoUnattendedTransferL" ) |
|
234 |
|
235 // First get the transfer to address from dialog |
|
236 TPhoneCmdParamString transferTarget; |
|
237 HBufC* content = HBufC::NewLC( KPEPhoneNumberMaxLength ); |
|
238 TPtr ptr( content->Des() ); |
|
239 transferTarget.SetString( &ptr ); |
|
240 CPhoneState* phoneState = |
|
241 static_cast< CPhoneState* >( iStateMachine.State() ); |
|
242 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) && |
|
243 phoneState->IsCustomizedDialerVisibleL() ) |
|
244 { |
|
245 iViewCommandHandle.ExecuteCommand( |
|
246 EPhoneViewGetNumberFromEntry, |
|
247 &transferTarget ); |
|
248 |
|
249 phoneState->CloseCustomizedDialerL(); |
|
250 } |
|
251 else |
|
252 { |
|
253 iViewCommandHandle.ExecuteCommandL( |
|
254 EPhoneViewGetTextQueryContent, &transferTarget ); |
|
255 } |
|
256 |
|
257 // Set transfer to address to the phoneengine |
|
258 iStateMachine.PhoneEngineInfo()->SetTransferTargetCommand( ptr ); |
|
259 iStateMachine.SendPhoneEngineMessage( |
|
260 MPEPhoneModel::EPEMessageDoUnattendedTransfer ); |
|
261 |
|
262 ShowWaitingAcceptanceNoteL(); |
|
263 CleanupStack::PopAndDestroy( content ); |
|
264 } |
|
265 |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CPhoneUnattendedTransferCmdHandler::CloseTransferDialerL |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CPhoneUnattendedTransferCmdHandler::CloseTransferDialerL() |
|
272 { |
|
273 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
274 "CPhoneUnattendedTransferCmdHandler::CloseTransferDialerL" ) |
|
275 |
|
276 CPhoneState* phoneState = |
|
277 static_cast< CPhoneState* >( iStateMachine.State() ); |
|
278 phoneState->CloseCustomizedDialerL(); |
|
279 } |
|
280 |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CPhoneUnattendedTransferCmdHandler::OpenSingleItemContactFetchL |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 void CPhoneUnattendedTransferCmdHandler::OpenSingleItemContactFetchL( |
|
287 TInt aFetchType ) |
|
288 { |
|
289 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
290 "CPhoneUnattendedTransferCmdHandler::OpenSingleItemContactFetchL" ) |
|
291 |
|
292 TPhoneCmdParamInteger integerParam; |
|
293 integerParam.SetInteger( aFetchType ); |
|
294 |
|
295 iViewCommandHandle.HandleCommandL( |
|
296 EPhoneViewOpenSingleItemFetchDialog, |
|
297 &integerParam ); |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CPhoneUnattendedTransferCmdHandler::ShowWaitingAcceptanceNoteL |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CPhoneUnattendedTransferCmdHandler::ShowWaitingAcceptanceNoteL() |
|
305 { |
|
306 __LOGMETHODSTARTEND( PhoneUIVoIPExtension, |
|
307 "CPhoneUnattendedTransferCmdHandler::ShowWaitingAcceptanceNoteL" ) |
|
308 // Show "Waiting acceptance..." note |
|
309 TPhoneCmdParamGlobalNote globalNoteParam; |
|
310 globalNoteParam.SetType( EAknGlobalWaitNote ); |
|
311 globalNoteParam.SetTone( EAvkonSIDNoSound ); |
|
312 globalNoteParam.SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY ); |
|
313 globalNoteParam.SetTextResourceId( CPhoneMainResourceResolver::Instance()-> |
|
314 ResolveResourceID( EPhoneVoIPWaitingAcceptanceNote ) ); |
|
315 iViewCommandHandle.ExecuteCommandL( |
|
316 EPhoneViewShowGlobalNote, &globalNoteParam ); |
|
317 } |