|
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 base task |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include "cesmrstoremrtask.h" |
|
20 |
|
21 #include <calentry.h> |
|
22 #include <calinstance.h> |
|
23 //<cmail> |
|
24 #include "mesmrutilstombsext.h" |
|
25 //</cmail> |
|
26 #include "cesmrcaldbmgr.h" |
|
27 #include "mesmrmeetingrequestentry.h" |
|
28 |
|
29 namespace { // codescanner::namespace |
|
30 |
|
31 #ifdef _DEBUG |
|
32 |
|
33 // Literal for panics |
|
34 _LIT( KESMRStoreMR, "ESMRStoreMR" ); |
|
35 |
|
36 // Panic codes |
|
37 enum TESMRStoreMRPanic |
|
38 { |
|
39 EESMRStoreMRNotMeetingRequest // Entry is not meeting request |
|
40 }; |
|
41 |
|
42 // ======== LOCAL FUNCTIONS ======== |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Panic wrapper method |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 void Panic( TESMRStoreMRPanic aPanic ) |
|
49 { |
|
50 User::Panic( KESMRStoreMR, aPanic ); |
|
51 } |
|
52 |
|
53 #endif // _DEBUG |
|
54 |
|
55 }//namespace |
|
56 |
|
57 // ======== MEMBER FUNCTIONS ======== |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CESMRStoreMRTask::CESMRStoreMRTask |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CESMRStoreMRTask::CESMRStoreMRTask( |
|
64 MESMRCalDbMgr& aCalDbMgr, |
|
65 MESMRMeetingRequestEntry& aEntry, |
|
66 CMRMailboxUtils& aMRMailboxUtils ) |
|
67 : CESMRTaskBase( aCalDbMgr, aEntry, aMRMailboxUtils ) |
|
68 { |
|
69 FUNC_LOG; |
|
70 //do nothing |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CESMRStoreMRTask::~CESMRStoreMRTask |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CESMRStoreMRTask::~CESMRStoreMRTask() |
|
78 { |
|
79 FUNC_LOG; |
|
80 //do nothing |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CESMRStoreMRTask::NewL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CESMRStoreMRTask* CESMRStoreMRTask::NewL( |
|
88 MESMRCalDbMgr& aCalDbMgr, |
|
89 MESMRMeetingRequestEntry& aEntry, |
|
90 CMRMailboxUtils& aMRMailboxUtils ) |
|
91 { |
|
92 FUNC_LOG; |
|
93 |
|
94 CESMRStoreMRTask* self = |
|
95 new (ELeave) CESMRStoreMRTask( |
|
96 aCalDbMgr, |
|
97 aEntry, |
|
98 aMRMailboxUtils ); |
|
99 |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(); |
|
102 CleanupStack::Pop(self); |
|
103 |
|
104 |
|
105 return self; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CESMRStoreMRTask::ConstructL |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 void CESMRStoreMRTask::ConstructL() |
|
113 { |
|
114 FUNC_LOG; |
|
115 BaseConstructL(); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CESMRStoreMRTask::ExecuteTaskL |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CESMRStoreMRTask::ExecuteTaskL() |
|
123 { |
|
124 FUNC_LOG; |
|
125 |
|
126 // Store to calendar DB |
|
127 StoreEntryToDbL(); |
|
128 |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CESMRStoreMRTask::StoreEntryToDbL |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CESMRStoreMRTask::StoreEntryToDbL() |
|
136 { |
|
137 FUNC_LOG; |
|
138 |
|
139 MESMRMeetingRequestEntry& mrEntry = ESMREntry(); |
|
140 CCalEntry& entry = mrEntry.Entry(); |
|
141 |
|
142 const CCalEntry::TType KMRType( |
|
143 CCalEntry::EAppt ); |
|
144 |
|
145 CCalEntry::TType entryType( entry.EntryTypeL() ); |
|
146 |
|
147 // Check entry type |
|
148 #ifdef _DEBUG |
|
149 |
|
150 __ASSERT_DEBUG( |
|
151 KMRType == entryType, |
|
152 Panic(EESMRStoreMRNotMeetingRequest) ); |
|
153 |
|
154 #else |
|
155 |
|
156 if ( KMRType != entryType ) |
|
157 { |
|
158 User::Leave( KErrArgument ); |
|
159 } |
|
160 |
|
161 #endif // _DEBUG |
|
162 |
|
163 TBool isEdited( mrEntry.IsEntryEditedL() ); |
|
164 TBool forwarded( mrEntry.IsForwardedL() ); |
|
165 |
|
166 if ( !forwarded ) |
|
167 { |
|
168 // Check storing result |
|
169 MESMRUtilsTombsExt::TESMRUtilsDbResult res = |
|
170 CalDbMgr().StoreEntryCondL( entry, EFalse, ETrue ); |
|
171 |
|
172 // Check that entry can be saved |
|
173 if ( MESMRUtilsTombsExt::ECheckedValidNew == res || |
|
174 MESMRUtilsTombsExt::ECheckedValidUpdate == res || |
|
175 isEdited ) |
|
176 { |
|
177 CCalEntry* validatedEntry = mrEntry.ValidateEntryL(); |
|
178 CleanupStack::PushL( validatedEntry ); |
|
179 |
|
180 CalDbMgr().StoreEntryCondL( *validatedEntry, EFalse ); |
|
181 |
|
182 CleanupStack::PopAndDestroy( validatedEntry ); |
|
183 |
|
184 mrEntry.UpdateEntryAfterStoringL(); |
|
185 } |
|
186 } |
|
187 |
|
188 } |
|
189 |
|
190 // EOF |
|
191 |