|
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: Implementation for ESMR calendar event task |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmrtodomarkasdonetask.h" |
|
19 #include "cesmrcaldbmgr.h" |
|
20 #include "mesmrcalentry.h" |
|
21 |
|
22 #include <caltime.h> |
|
23 #include <calentry.h> |
|
24 |
|
25 #include "emailtrace.h" |
|
26 |
|
27 namespace { // codescanner::namespace |
|
28 |
|
29 }//namespace |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CESMRTodoMarkAsDoneTask::CESMRTodoMarkAsDoneTask |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CESMRTodoMarkAsDoneTask::CESMRTodoMarkAsDoneTask( MESMRCalEntry& aEntry, |
|
38 MESMRCalDbMgr& aCalDbMgr ) |
|
39 : iEntry( aEntry ), |
|
40 iCalDbMgr( aCalDbMgr ) |
|
41 { |
|
42 FUNC_LOG; |
|
43 //do nothing |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CESMRTodoMarkAsDoneTask::~CESMRTodoMarkAsDoneTask |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CESMRTodoMarkAsDoneTask::~CESMRTodoMarkAsDoneTask() |
|
51 { |
|
52 FUNC_LOG; |
|
53 //do nothing |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CESMRTodoMarkAsDoneTask::NewL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CESMRTodoMarkAsDoneTask* CESMRTodoMarkAsDoneTask::NewL( MESMRCalEntry& aEntry, |
|
61 MESMRCalDbMgr& aCalDbMgr ) |
|
62 { |
|
63 FUNC_LOG; |
|
64 CESMRTodoMarkAsDoneTask* self = |
|
65 new( ELeave )CESMRTodoMarkAsDoneTask( aEntry, aCalDbMgr ); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CESMRTodoMarkAsDoneTask::ConstructL |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CESMRTodoMarkAsDoneTask::ConstructL() |
|
77 { |
|
78 FUNC_LOG; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CESMRTodoMarkAsDoneTask::ExecuteTaskL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CESMRTodoMarkAsDoneTask::ExecuteTaskL() |
|
86 { |
|
87 FUNC_LOG; |
|
88 |
|
89 // Mark to-do as done |
|
90 MarkTodoAsDoneL(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CESMRTodoMarkAsDoneTask::MarkTodoAsDoneL |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CESMRTodoMarkAsDoneTask::MarkTodoAsDoneL() |
|
98 { |
|
99 FUNC_LOG; |
|
100 |
|
101 TTime now; |
|
102 now.HomeTime(); |
|
103 TCalTime caltime; |
|
104 caltime.SetTimeLocalL( now ); |
|
105 |
|
106 // Set to-do as completed |
|
107 TRAPD( err, iEntry.Entry().SetCompletedL( ETrue, caltime ) ); |
|
108 |
|
109 // Update entry time stamp before storing |
|
110 iEntry.UpdateTimeStampL(); |
|
111 |
|
112 if( err == KErrNone ) |
|
113 { |
|
114 // Check storing result |
|
115 MESMRUtilsTombsExt::TESMRUtilsDbResult res = |
|
116 iCalDbMgr.StoreEntryCondL( iEntry.Entry(), EFalse, ETrue ); |
|
117 |
|
118 // Check that entry can be saved |
|
119 if ( MESMRUtilsTombsExt::ECheckedValidNew == res || |
|
120 MESMRUtilsTombsExt::ECheckedValidUpdate == res || |
|
121 iEntry.IsEntryEditedL() ) |
|
122 { |
|
123 // Validate entry before storing it to calendar db |
|
124 CCalEntry* validatedEntry = iEntry.ValidateEntryL(); |
|
125 CleanupStack::PushL( validatedEntry ); |
|
126 |
|
127 iCalDbMgr.StoreEntryCondL( *validatedEntry, EFalse ); |
|
128 |
|
129 CleanupStack::PopAndDestroy( validatedEntry ); |
|
130 |
|
131 iEntry.UpdateEntryAfterStoringL(); |
|
132 } |
|
133 } |
|
134 } |
|
135 |
|
136 // EOF |
|
137 |