1 /* |
1 /* |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
33 #include "cesmrresponsedialog.h" |
33 #include "cesmrresponsedialog.h" |
34 #include "tesmrinputparams.h" |
34 #include "tesmrinputparams.h" |
35 #include "esmrconfig.hrh" |
35 #include "esmrconfig.hrh" |
36 #include "cesmrcaldbmgr.h" |
36 #include "cesmrcaldbmgr.h" |
37 //<cmail> |
37 //<cmail> |
38 #include "CFSMailCommon.h" |
38 #include "cfsmailcommon.h" |
39 #include "CFSMailClient.h" |
39 #include "cfsmailclient.h" |
40 #include "CFSMailMessage.h" |
40 #include "cfsmailmessage.h" |
41 #include "CFSMailBox.h" |
41 #include "cfsmailbox.h" |
42 //</cmail> |
42 //</cmail> |
43 |
43 |
44 |
44 |
45 namespace { |
45 namespace { |
46 |
46 |
102 |
102 |
103 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
104 // Queries response query from user. |
104 // Queries response query from user. |
105 // --------------------------------------------------------------------------- |
105 // --------------------------------------------------------------------------- |
106 // |
106 // |
107 HBufC* QuerySendResponseQueryFromUserLC( |
107 HBufC* QuerySendResponseQueryFromUserL( |
108 TESMRCommand aCommand, |
108 TESMRCommand aCommand, |
109 TESMRResponseType& aResponseType, |
109 TESMRResponseType& aResponseType, |
110 MESMRMeetingRequestEntry& aEntry ) |
110 MESMRMeetingRequestEntry& aEntry ) |
111 { |
111 { |
112 HBufC* responseMessage = NULL; |
112 HBufC* responseMessage = NULL; |
175 { |
175 { |
176 CESMRResponseDialog* respDlg = |
176 CESMRResponseDialog* respDlg = |
177 CESMRResponseDialog::NewL( responseMessage ); |
177 CESMRResponseDialog::NewL( responseMessage ); |
178 CleanupStack::PushL( respDlg ); |
178 CleanupStack::PushL( respDlg ); |
179 |
179 |
180 TBool dialogRetValue( respDlg->ExecuteDlgLD() ); |
180 TInt dialogRetValue( respDlg->ExecuteDlgLD() ); |
181 // Dialog has deleted itself --> Only pop from cleanup stack |
181 // Dialog has deleted itself --> Only pop from cleanup stack |
182 CleanupStack::Pop( respDlg ); |
182 CleanupStack::Pop( respDlg ); |
183 |
183 |
184 if ( !dialogRetValue ) |
184 if ( !dialogRetValue ) |
185 { |
185 { |
186 aEntry.Entry().SetStatusL( CCalEntry::ETentative ); |
186 aEntry.Entry().SetStatusL( CCalEntry::ETentative ); |
187 User::Leave( KErrCancel ); |
187 User::Leave( KErrCancel ); |
188 } |
188 } |
189 } |
189 else if ( dialogRetValue == EAknCmdExit ) |
190 if ( responseMessage ) |
190 { |
191 { |
191 aResponseType = EESMRResponseDontSend; |
192 CleanupStack::PushL( responseMessage ); |
192 } |
|
193 else if ( !responseMessage |
|
194 && dialogRetValue == EESMRCmdSendMR ) |
|
195 { |
|
196 // Send command is triggered but response is empty |
|
197 aResponseType = EESMRResponsePlain; |
|
198 responseMessage = KNullDesC().AllocL(); |
|
199 } |
193 } |
200 } |
194 else |
201 else |
195 { |
202 { |
196 responseMessage = KNullDesC().AllocLC(); |
203 responseMessage = KNullDesC().AllocL(); |
197 } |
204 } |
|
205 |
198 return responseMessage; |
206 return responseMessage; |
199 } |
207 } |
200 |
208 |
201 } // namespace |
209 } // namespace |
202 |
210 |
247 |
255 |
248 MESMRTask* task = NULL; |
256 MESMRTask* task = NULL; |
249 |
257 |
250 MESMRMeetingRequestEntry& mrEntry = |
258 MESMRMeetingRequestEntry& mrEntry = |
251 static_cast< MESMRMeetingRequestEntry& >( aEntry ); |
259 static_cast< MESMRMeetingRequestEntry& >( aEntry ); |
252 |
260 |
253 switch (aCommand) |
261 switch (aCommand) |
254 { |
262 { |
255 case EESMRCmdAcceptMR: |
263 case EESMRCmdAcceptMR: |
256 case EESMRCmdTentativeMR: |
264 case EESMRCmdTentativeMR: |
257 case EESMRCmdDeclineMR: |
265 case EESMRCmdDeclineMR: |
312 { |
320 { |
313 FUNC_LOG; |
321 FUNC_LOG; |
314 |
322 |
315 CESMRCombinedTask* task = NULL; |
323 CESMRCombinedTask* task = NULL; |
316 TESMRRole role = aEntry.RoleL(); |
324 TESMRRole role = aEntry.RoleL(); |
317 |
325 |
318 TBool syncObjectPresent( aEntry.IsSyncObjectPresent() ); |
326 TBool syncObjectPresent( aEntry.IsSyncObjectPresent() ); |
319 TBool isStored( aEntry.IsStoredL() ); |
327 TBool isStored( aEntry.IsStoredL() ); |
320 |
328 |
321 if ( EESMRRoleRequiredAttendee == role || |
329 if ( EESMRRoleRequiredAttendee == role || |
322 EESMRRoleOptionalAttendee == role || |
330 EESMRRoleOptionalAttendee == role || |
326 CESMRCombinedTask::EESMRTrap ); |
334 CESMRCombinedTask::EESMRTrap ); |
327 |
335 |
328 CleanupStack::PushL( task ); |
336 CleanupStack::PushL( task ); |
329 |
337 |
330 TESMRResponseType responseType( EESMRResponsePlain ); |
338 TESMRResponseType responseType( EESMRResponsePlain ); |
331 HBufC* responseMessage = QuerySendResponseQueryFromUserLC( |
339 HBufC* responseMessage = QuerySendResponseQueryFromUserL( |
332 aCommand, |
340 aCommand, |
333 responseType, |
341 responseType, |
334 aEntry ); |
342 aEntry ); |
335 |
343 |
336 if ( !syncObjectPresent && EESMRCmdDeclineMR != aCommand) |
344 // If response message is NULL, it means that user |
337 { |
345 // has cancelled response editing and wants to only exit |
338 // Entry is stored or deleted from calendar DB if |
346 // application |
339 // sync object is not present |
347 if( responseMessage ) |
340 // Store MR task |
348 { |
341 AppendTaskL( *task, |
349 CleanupStack::PushL( responseMessage ); |
342 CESMRStoreMRTask::NewL( |
350 |
343 iCalDbMgr, |
351 if ( !syncObjectPresent && EESMRCmdDeclineMR != aCommand) |
344 aEntry, |
352 { |
345 aEntry.MailboxUtils() ) ); |
353 // Entry is stored or deleted from calendar DB if |
346 } |
354 // sync object is not present |
347 |
355 // Store MR task |
348 if ( EESMRResponseDontSend != responseType || |
356 AppendTaskL( *task, |
349 aEntry.IsSyncObjectPresent() ) |
357 CESMRStoreMRTask::NewL( |
350 { |
358 iCalDbMgr, |
351 // Send MR response via mail freestyle task |
359 aEntry, |
352 AppendTaskL( *task, |
360 aEntry.MailboxUtils() ) ); |
353 CESMRSendMRRespFSMailTask::NewL( |
361 } |
354 aCommand, |
362 |
355 iCalDbMgr, |
363 if ( EESMRResponseDontSend != responseType ) |
356 aEntry, |
364 { |
357 aEntry.MailboxUtils(), |
365 // Send MR response via mail freestyle task |
358 responseType, |
366 AppendTaskL( *task, |
359 *responseMessage ) ); |
367 CESMRSendMRRespFSMailTask::NewL( |
360 } |
368 aCommand, |
361 CleanupStack::PopAndDestroy( responseMessage ); |
369 iCalDbMgr, |
362 |
370 aEntry, |
363 if ( !syncObjectPresent && EESMRCmdDeclineMR == aCommand && |
371 aEntry.MailboxUtils(), |
364 isStored ) |
372 responseType, |
365 { |
373 *responseMessage ) ); |
366 // Entry is deleted from calendar DB if |
374 } |
367 // sync object is not present and entry exits in database |
375 |
368 // Declined --> Delete MR from cal DB task |
376 CleanupStack::PopAndDestroy( responseMessage ); |
369 AppendTaskL( *task, |
377 |
370 CESMRDeleteMRFromDbTask::NewL( |
378 if ( !syncObjectPresent && EESMRCmdDeclineMR == aCommand && |
371 iCalDbMgr, |
379 isStored ) |
372 aEntry, |
380 { |
373 aEntry.MailboxUtils() ) ); |
381 // Entry is deleted from calendar DB if |
374 } |
382 // sync object is not present and entry exits in database |
375 |
383 // Declined --> Delete MR from cal DB task |
376 CleanupStack::Pop( task ); |
384 AppendTaskL( *task, |
|
385 CESMRDeleteMRFromDbTask::NewL( |
|
386 iCalDbMgr, |
|
387 aEntry, |
|
388 aEntry.MailboxUtils() ) ); |
|
389 } |
|
390 } |
|
391 |
|
392 CleanupStack::Pop( task ); |
377 } |
393 } |
378 else |
394 else |
379 { |
395 { |
380 // Only (opt-)attendees and non-participants can send |
396 // Only (opt-)attendees and non-participants can send |
381 // responses |
397 // responses |
560 TUint attendeeFlags( |
576 TUint attendeeFlags( |
561 EESMRRoleRequiredAttendee | EESMRRoleOptionalAttendee); |
577 EESMRRoleRequiredAttendee | EESMRRoleOptionalAttendee); |
562 if ( aEntry.AttendeeCountL( attendeeFlags ) && aEntry.IsSentL() |
578 if ( aEntry.AttendeeCountL( attendeeFlags ) && aEntry.IsSentL() |
563 && !aEntry.OccursInPastL() ) |
579 && !aEntry.OccursInPastL() ) |
564 { |
580 { |
565 // if enrey doesn't need to send canellation, don't query |
581 // If entry doesn't need to send cancellation, don't query |
566 if( aEntry.SendCanellationAvailable()) |
582 if( aEntry.SendCanellationAvailable()) |
567 { |
583 { |
568 // Meeting request contains attendees --> Cancellation message |
584 // Meeting request contains attendees --> Cancellation message |
569 // needs to be sent |
585 // needs to be sent |
570 if ( CESMRConfirmationQuery::ExecuteL( |
586 if ( CESMRConfirmationQuery::ExecuteL( |
695 if ( aEntry.IsSyncObjectPresent() ) |
711 if ( aEntry.IsSyncObjectPresent() ) |
696 { |
712 { |
697 __ASSERT_DEBUG( EFalse, Panic( EESMRTaskFactoryIllegalTask ) ); |
713 __ASSERT_DEBUG( EFalse, Panic( EESMRTaskFactoryIllegalTask ) ); |
698 User::Leave( KErrNotSupported ); |
714 User::Leave( KErrNotSupported ); |
699 } |
715 } |
700 |
716 |
701 // Create combined task |
717 // Create combined task |
702 CESMRCombinedTask* task = CESMRCombinedTask::NewL( |
718 CESMRCombinedTask* task = CESMRCombinedTask::NewL( |
703 aEntry, |
719 aEntry, |
704 CESMRCombinedTask::EESMRTrap ); |
720 CESMRCombinedTask::EESMRTrap ); |
705 |
721 |
706 CleanupStack::PushL( task ); |
722 CleanupStack::PushL( task ); |
707 |
723 |
708 if ( !aEntry.IsOpenedFromMail() ) |
724 if ( !aEntry.IsOpenedFromMail() ) |
709 { |
725 { |
710 // When deleting from the calendar --> Store first modifying entry |
726 // When deleting from the calendar --> Store first modifying entry |
711 // And then delete that from calendar DB. |
727 // And then delete that from calendar DB. |
712 // |
728 // |
718 CESMRStoreMRTask::NewL( |
734 CESMRStoreMRTask::NewL( |
719 iCalDbMgr, |
735 iCalDbMgr, |
720 aEntry, |
736 aEntry, |
721 aEntry.MailboxUtils() ) ); |
737 aEntry.MailboxUtils() ) ); |
722 } |
738 } |
723 |
739 |
724 // Delete entry from old db |
740 // Delete entry from old db |
725 AppendTaskL( |
741 AppendTaskL( |
726 *task, |
742 *task, |
727 CESMRDeleteMRFromDbTask::NewL( |
743 CESMRDeleteMRFromDbTask::NewL( |
728 iCalDbMgr, |
744 iCalDbMgr, |
729 aEntry, |
745 aEntry, |
730 aEntry.MailboxUtils() ) ); |
746 aEntry.MailboxUtils() ) ); |
731 |
747 |
732 // Store entry to current db |
748 // Store entry to current db |
733 AppendTaskL( |
749 AppendTaskL( |
734 *task, |
750 *task, |
735 CESMRStoreMRTask::NewL( |
751 CESMRStoreMRTask::NewL( |
736 iCalDbMgr, |
752 iCalDbMgr, |
737 aEntry, |
753 aEntry, |
738 aEntry.MailboxUtils() ) ); |
754 aEntry.MailboxUtils() ) ); |
739 |
755 |
740 CleanupStack::Pop( task ); |
756 CleanupStack::Pop( task ); |
741 return task; |
757 return task; |
742 } |
758 } |
743 |
759 |
744 // EOF |
760 // EOF |