|
1 /* |
|
2 * Copyright (c) 2007-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: Open meeting request command implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include "cesmricalvieweropenmrcmd.h" |
|
22 #include "cesmricalviewerloadmrdatacmd.h" |
|
23 #include "cesmricalvieweremailasynccmd.h" |
|
24 #include "cesmricalvieweremailsynccmd.h" |
|
25 #include "cesmruilauncher.h" |
|
26 #include "cmrattachmentinfofetcher.h" |
|
27 #include "esmricalviewerutils.h" |
|
28 |
|
29 //<cmail> |
|
30 #include "esmricalvieweropcodes.hrh" |
|
31 //</cmail> |
|
32 #include <calsession.h> |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd( |
|
40 MESMRIcalViewerCallback& aCallback, |
|
41 CFSMailClient& aMailClient, |
|
42 CCalSession& aCalSession ) |
|
43 : CESMRIcalViewerAsyncCommand( EESMRViewLaunch, aCalSession ), |
|
44 iCallback( aCallback ), |
|
45 iMailClient( aMailClient ), |
|
46 iCurrentCbCommand( EESMREmailCommand ) |
|
47 { |
|
48 FUNC_LOG; |
|
49 iResult.iResultCode = KErrNone; |
|
50 iResult.iOpType = OperationType(); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CESMRIcalViewerOpenMRCmd::~CESMRIcalViewerOpenMRCmd() |
|
58 { |
|
59 FUNC_LOG; |
|
60 CancelCommand(); |
|
61 delete iLoadMRDataCmd; |
|
62 delete iUILauncher; |
|
63 delete iAttachmentInfoFetcher; |
|
64 |
|
65 if( iEmailCommand ) |
|
66 { |
|
67 delete iEmailCommand; |
|
68 iEmailCommand = NULL; |
|
69 } |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CESMRIcalViewerOpenMRCmd* CESMRIcalViewerOpenMRCmd::NewL( |
|
77 MESMRIcalViewerCallback& aCallback, |
|
78 CFSMailClient& aMailClient, |
|
79 CCalSession& aCalSession ) |
|
80 { |
|
81 FUNC_LOG; |
|
82 CESMRIcalViewerOpenMRCmd* self = |
|
83 new (ELeave) CESMRIcalViewerOpenMRCmd( |
|
84 aCallback, |
|
85 aMailClient, |
|
86 aCalSession ); |
|
87 |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CESMRIcalViewerOpenMRCmd::ConstructL() |
|
99 { |
|
100 FUNC_LOG; |
|
101 BaseConstructL(); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CESMRIcalViewerOpenMRCmd::ExecuteAsyncCommandL() |
|
109 { |
|
110 FUNC_LOG; |
|
111 iResult.iOpType = OperationType(); |
|
112 iResult.iMessage = Message(); |
|
113 iResult.iResultCode = KErrNone; |
|
114 |
|
115 iLoadMRDataCmd = |
|
116 CESMRIcalViewerLoadMRDataCmd::NewL( |
|
117 CalSession(), |
|
118 iMailClient, |
|
119 iInputParameters ); |
|
120 |
|
121 iLoadMRDataCmd->ExecuteCommandL( *Message(), *this ); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CESMRIcalViewerOpenMRCmd::CancelAsyncCommand() |
|
129 { |
|
130 FUNC_LOG; |
|
131 if ( iLoadMRDataCmd ) |
|
132 { |
|
133 iLoadMRDataCmd->CancelCommand(); |
|
134 } |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CESMRIcalViewerOpenMRCmd::OperationCompleted( |
|
142 MESMRIcalViewerObserver::TIcalViewerOperationResult aResult ) |
|
143 { |
|
144 FUNC_LOG; |
|
145 TRAPD( err, HandleOperationCompeletedL( aResult ) ); |
|
146 HandleError( err ); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CESMRIcalViewerOpenMRCmd::CESMRIcalViewerOpenMRCmd |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CESMRIcalViewerOpenMRCmd::OperationError( |
|
154 MESMRIcalViewerObserver::TIcalViewerOperationResult aResult ) |
|
155 { |
|
156 FUNC_LOG; |
|
157 iResult = aResult; |
|
158 iResult.iOpType = OperationType(); |
|
159 |
|
160 if ( EESMRLaunchUI == aResult.iOpType ) |
|
161 { |
|
162 delete iUILauncher; |
|
163 iUILauncher = NULL; |
|
164 } |
|
165 if ( !iUILauncher && |
|
166 EESMREmailCommand == iCurrentCbCommand && |
|
167 KErrCancel == aResult.iResultCode ) |
|
168 { |
|
169 // We would like to launch mr again |
|
170 iInputParameters.iMailClient = &iMailClient; |
|
171 iInputParameters.iMailMessage = Message(); |
|
172 iInputParameters.iCommand = EESMRCmdUndefined; |
|
173 iInputParameters.iSpare = 0; |
|
174 TRAPD( err, LaunchUIL() ); |
|
175 iResult.iResultCode = err; |
|
176 |
|
177 if ( err != KErrNone ) |
|
178 { |
|
179 Observer()->OperationError( iResult ); |
|
180 } |
|
181 } |
|
182 else |
|
183 { |
|
184 Observer()->OperationError( iResult ); |
|
185 } |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CESMRIcalViewerOpenMRCmd::ProcessCommandL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CESMRIcalViewerOpenMRCmd::ProcessCommandL(TInt aCommandId) |
|
193 { |
|
194 FUNC_LOG; |
|
195 ProcessCommandWithResultL( aCommandId ); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CESMRIcalViewerOpenMRCmd::ProcessCommandWithResultL |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 TInt CESMRIcalViewerOpenMRCmd::ProcessCommandWithResultL( TInt aCommandId ) |
|
203 { |
|
204 FUNC_LOG; |
|
205 |
|
206 TInt retValue( KErrNotSupported ); |
|
207 |
|
208 if ( IsCommandAvailable( aCommandId ) ) |
|
209 { |
|
210 iMRViewerCommand = aCommandId; |
|
211 |
|
212 iCurrentCbCommand = |
|
213 ESMRIcalViewerUtils::EmailOperation(aCommandId); |
|
214 |
|
215 TBool asyncCommand( |
|
216 ESMRIcalViewerUtils::IsAsyncEmailCommand( iCurrentCbCommand ) ); |
|
217 |
|
218 if( iEmailCommand ) |
|
219 { |
|
220 delete iEmailCommand; |
|
221 iEmailCommand = NULL; |
|
222 } |
|
223 |
|
224 if ( asyncCommand ) |
|
225 { |
|
226 iEmailCommand = CESMRIcalViewerEmailAsyncCmd::NewL( |
|
227 iCurrentCbCommand, |
|
228 CalSession(), |
|
229 iCallback ); |
|
230 } |
|
231 else |
|
232 { |
|
233 iEmailCommand = CESMRIcalViewerEmailSyncCmd::NewL( |
|
234 iCurrentCbCommand, |
|
235 CalSession(), |
|
236 iCallback ); |
|
237 } |
|
238 |
|
239 iEmailCommand->ExecuteCommandL( *Message(), *this ); |
|
240 |
|
241 if ( !asyncCommand ) |
|
242 { |
|
243 // Email specific sync command has been executed. |
|
244 iCurrentCbCommand = EESMREmailCommand; |
|
245 } |
|
246 retValue = KErrNone; |
|
247 } |
|
248 |
|
249 |
|
250 return retValue; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CESMRIcalViewerOpenMRCmd::IsCommandAvailable |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TBool CESMRIcalViewerOpenMRCmd::IsCommandAvailable( TInt aCommandId ) |
|
258 { |
|
259 FUNC_LOG; |
|
260 |
|
261 TESMRIcalViewerOperationType command( |
|
262 ESMRIcalViewerUtils::EmailOperation(aCommandId) ); |
|
263 |
|
264 TBool canProcessCommand( iCallback.CanProcessCommand( command ) ); |
|
265 |
|
266 return canProcessCommand; |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CESMRIcalViewerOpenMRCmd::HandleOperationCompeletedL |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CESMRIcalViewerOpenMRCmd::HandleOperationCompeletedL( |
|
274 MESMRIcalViewerObserver::TIcalViewerOperationResult aResult ) |
|
275 { |
|
276 FUNC_LOG; |
|
277 |
|
278 |
|
279 if ( EESMRLaunchUI == aResult.iOpType ) |
|
280 { |
|
281 delete iUILauncher; |
|
282 iUILauncher = NULL; |
|
283 } |
|
284 else if ( aResult.iOpType == EESMRLoadMRData ) |
|
285 { |
|
286 // MR data is loaded |
|
287 FillAttachmentInfoL(); |
|
288 } |
|
289 else if( aResult.iOpType == EESMRFetchAttachmentInfo ) |
|
290 { |
|
291 // Attachment information is loaded |
|
292 iInputParameters.iMailClient = &iMailClient; |
|
293 iInputParameters.iMailMessage = Message(); |
|
294 iInputParameters.iCommand = EESMRCmdUndefined; |
|
295 iInputParameters.iSpare = 0; |
|
296 LaunchUIL(); |
|
297 } |
|
298 else if ( aResult.iOpType == iCurrentCbCommand ) |
|
299 { |
|
300 TBool asyncCommand( ESMRIcalViewerUtils::IsAsyncEmailCommand(iCurrentCbCommand) ); |
|
301 |
|
302 switch ( aResult.iOpType ) |
|
303 { |
|
304 case EESMRCmdOpenAttachment://fallthrough |
|
305 case EESMRCmdOpenAttachmentView://fallthrough |
|
306 case EESMRCmdDownloadAttachment://fallthrough |
|
307 case EESMRCmdDownloadAllAttachments://fallthrough |
|
308 case EESMRCmdSaveAttachment://fallthrough |
|
309 case EESMRCmdSaveAllAttachments://fallthrough |
|
310 { |
|
311 if ( ESMRIcalViewerUtils::ContainsAttachments(iInputParameters) && |
|
312 iMRViewerCommand != iCurrentCbCommand ) |
|
313 { |
|
314 iInputParameters.iCommand = |
|
315 ESMRIcalViewerUtils::MRResponseCommandWithoutAttachmentCheck( |
|
316 iMRViewerCommand); |
|
317 } |
|
318 iCurrentCbCommand = EESMREmailCommand; |
|
319 LaunchUIL(); |
|
320 } |
|
321 break; |
|
322 |
|
323 case EESMRCmdMailForwardAsMessage://fallthrough |
|
324 case EESMRCmdMailCopyMessage://fallthrough |
|
325 case EESMRCmdMailComposeMessage://fallthrough |
|
326 case EESMRCmdMailMessageDetails://fallthrough |
|
327 case EESMRCmdDownloadManager://fallthrough |
|
328 case EESMRCmdMailReply://fallthrough |
|
329 case EESMRCmdMailReplyAll://fallthrough |
|
330 { |
|
331 // Ui needs to be relaunched |
|
332 iCurrentCbCommand = EESMREmailCommand; |
|
333 LaunchUIL(); |
|
334 } |
|
335 break; |
|
336 |
|
337 case EESMRCmdMailMoveMessage: |
|
338 { |
|
339 iCurrentCbCommand = EESMREmailCommand; |
|
340 if ( KErrCancel == aResult.iResultCode ) |
|
341 { |
|
342 LaunchUIL(); |
|
343 } |
|
344 } |
|
345 break; |
|
346 |
|
347 case EESMRCmdMailPreviousMessage: |
|
348 case EESMRCmdMailNextMessage: |
|
349 case EESMRCmdMailMoveMessageToDrafts: |
|
350 case EESMRCmdMailDelete: |
|
351 { |
|
352 //ui won't be relaunched |
|
353 iCurrentCbCommand = EESMREmailCommand; |
|
354 } |
|
355 break; |
|
356 default: |
|
357 break; |
|
358 } |
|
359 } |
|
360 |
|
361 if ( !iUILauncher && |
|
362 EESMREmailCommand == iCurrentCbCommand && |
|
363 aResult.iOpType != EESMRLoadMRData) |
|
364 { |
|
365 iResult.iAttendeeStatus = |
|
366 ESMRIcalViewerUtils::UserResponsedToMRL( |
|
367 *iInputParameters.iCalEntry ); |
|
368 Observer()->OperationCompleted( iResult ); |
|
369 } |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CESMRIcalViewerOpenMRCmd::HandleError |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 void CESMRIcalViewerOpenMRCmd::HandleError( TInt aError ) |
|
377 { |
|
378 FUNC_LOG; |
|
379 if ( KErrNone != aError ) |
|
380 { |
|
381 iResult.iResultCode = aError; |
|
382 Observer()->OperationError( iResult ); |
|
383 } |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------------------------- |
|
387 // CESMRIcalViewerOpenMRCmd::LaunchUIL |
|
388 // --------------------------------------------------------------------------- |
|
389 // |
|
390 void CESMRIcalViewerOpenMRCmd::LaunchUIL() |
|
391 { |
|
392 FUNC_LOG; |
|
393 if ( !iUILauncher ) |
|
394 { |
|
395 iUILauncher = CESMRUiLauncher::NewL( |
|
396 CalSession(), |
|
397 iInputParameters, |
|
398 *this ); |
|
399 } |
|
400 |
|
401 iUILauncher->ExecuteCommandL( *Message(), *this ); |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // CESMRIcalViewerOpenMRCmd::FillAttachmentInfoL |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 void CESMRIcalViewerOpenMRCmd::FillAttachmentInfoL() |
|
409 { |
|
410 FUNC_LOG; |
|
411 |
|
412 if ( !iAttachmentInfoFetcher ) |
|
413 { |
|
414 iAttachmentInfoFetcher = |
|
415 CMRAttachmentInfoFetcher::NewL( |
|
416 iMailClient, |
|
417 CalSession(), |
|
418 *(iInputParameters.iCalEntry) ); |
|
419 } |
|
420 |
|
421 iAttachmentInfoFetcher->ExecuteCommandL( *Message(), *this ); |
|
422 } |
|
423 |
|
424 // EOF |
|
425 |
|
426 |