27 #include "cesmrpolicymanager.h" |
27 #include "cesmrpolicymanager.h" |
28 #include "tesmrscenariodata.h" |
28 #include "tesmrscenariodata.h" |
29 #include "cesmrpolicy.h" |
29 #include "cesmrpolicy.h" |
30 //</cmail> |
30 //</cmail> |
31 |
31 |
32 #include "cesmrentryprocessor.h" |
32 #include "cmrentryprocessor.h" |
33 #include "mesmrmeetingrequestentry.h" |
33 #include "mesmrmeetingrequestentry.h" |
34 #include "cesmrtaskfactory.h" |
34 #include "cesmrtaskfactory.h" |
35 #include "mesmrtask.h" |
35 #include "mesmrtask.h" |
36 #include "cesmrtaskextensionimpl.h" |
36 #include "cesmrtaskextensionimpl.h" |
37 #include "esmrinternaluid.h" |
37 #include "esmrinternaluid.h" |
38 #include "esmrhelper.h" |
38 #include "esmrhelper.h" |
|
39 #include "esmrentryhelper.h" |
39 |
40 |
40 // From System |
41 // From System |
41 #include <coemain.h> |
42 #include <coemain.h> |
42 #include <calentry.h> |
43 #include <calentry.h> |
43 #include <calinstance.h> |
44 #include <calinstance.h> |
51 |
52 |
52 // CONSTANTS |
53 // CONSTANTS |
53 /// Unnamed namespace for local definitions |
54 /// Unnamed namespace for local definitions |
54 namespace { |
55 namespace { |
55 |
56 |
56 _LIT( KESMRPolicyResourceFile, "esmrpolicies.rsc" ); |
|
57 |
|
58 #ifdef _DEBUG |
57 #ifdef _DEBUG |
59 |
58 |
60 // Definition for MR UTILS panic text |
59 // Definition for MR UTILS panic text |
61 _LIT(KESMRUtilsPanicTxt, "ESMRUtils" ); |
60 _LIT(KESMRUtilsPanicTxt, "ESMRUtils" ); |
62 |
61 |
63 // MR VIEWER ctrl panic codes |
62 // MR VIEWER ctrl panic codes |
64 enum TESMRUtilsPanicCode |
63 enum TESMRUtilsPanicCode |
65 { |
64 { |
66 EESMRUtilsEntryProcessorNull = 0, // Entry processon is NULL |
65 EESMRUtilsEntryProcessorNull = 0, // Entry processon is NULL |
67 EESMRUtilsInvalidEntry = 1, // Invalid calendar entry, |
66 EESMRUtilsInvalidEntry = 1, // Invalid calendar entry, |
68 EESMRUtilsNULLCoeEnv = 2 // CCoeEnv is NULL |
67 EESMRUtilsNULLCoeEnv = 2, // CCoeEnv is NULL |
|
68 EESMRUtilsInvalidType |
69 }; |
69 }; |
70 |
70 |
71 void Panic(TESMRUtilsPanicCode aPanicCode) |
71 void Panic(TESMRUtilsPanicCode aPanicCode) |
72 { |
72 { |
73 User::Panic( KESMRUtilsPanicTxt, aPanicCode ); |
73 User::Panic( KESMRUtilsPanicTxt, aPanicCode ); |
94 // CESMRUtils::~CESMRUtils |
94 // CESMRUtils::~CESMRUtils |
95 // ---------------------------------------------------------------------------- |
95 // ---------------------------------------------------------------------------- |
96 // |
96 // |
97 EXPORT_C CESMRUtils::~CESMRUtils() |
97 EXPORT_C CESMRUtils::~CESMRUtils() |
98 { |
98 { |
99 FUNC_LOG; |
99 FUNC_LOG; |
100 delete iCalDBMgr; |
|
101 delete iPolicyManager; |
100 delete iPolicyManager; |
102 delete iEntryProcessor; |
101 delete iEntryProcessor; |
103 delete iMRMailboxUtils; |
102 delete iMRMailboxUtils; |
104 delete iTaskFactory; |
103 delete iTaskFactory; |
105 delete iTaskExtension; |
104 delete iTaskExtension; |
|
105 delete iCalDBMgr; |
106 } |
106 } |
107 |
107 |
108 // ---------------------------------------------------------------------------- |
108 // ---------------------------------------------------------------------------- |
109 // CESMRUtils::NewL |
109 // CESMRUtils::NewL |
110 // ---------------------------------------------------------------------------- |
110 // ---------------------------------------------------------------------------- |
125 // ---------------------------------------------------------------------------- |
125 // ---------------------------------------------------------------------------- |
126 // |
126 // |
127 void CESMRUtils::ConstructL() |
127 void CESMRUtils::ConstructL() |
128 { |
128 { |
129 FUNC_LOG; |
129 FUNC_LOG; |
130 CCoeEnv* coeEnv = CCoeEnv::Static(); |
130 |
131 __ASSERT_DEBUG( coeEnv, Panic(EESMRUtilsNULLCoeEnv) ); |
|
132 |
|
133 TFileName mruiPolicyResource; |
|
134 User::LeaveIfError( |
|
135 ESMRHelper::LocateResourceFile( |
|
136 KESMRPolicyResourceFile, |
|
137 KDC_RESOURCE_FILES_DIR, |
|
138 mruiPolicyResource, |
|
139 &coeEnv->FsSession() ) ); |
|
140 |
|
141 iPolicyManager = CESMRPolicyManager::NewL(); |
131 iPolicyManager = CESMRPolicyManager::NewL(); |
142 iPolicyManager->ReadPolicyFromResourceL( |
132 } |
143 mruiPolicyResource, |
133 |
144 R_ESMR_POLICIES ); |
134 // ---------------------------------------------------------------------------- |
|
135 // CESMRUtils::CreateExtensionsL |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C void CESMRUtils::CreateExtensionsL( |
|
139 TESMRCalendarEventType aEntryType ) |
|
140 { |
|
141 FUNC_LOG; |
|
142 |
|
143 CESMRTaskFactory* taskFactory = CESMRTaskFactory::NewL( |
|
144 aEntryType, |
|
145 *iCalDBMgr ); |
|
146 CleanupStack::PushL( taskFactory ); |
|
147 |
|
148 CMREntryProcessor* entryProcessor = CMREntryProcessor::NewL( |
|
149 aEntryType, |
|
150 *iCalDBMgr ); |
|
151 CleanupStack::PushL( entryProcessor ); |
|
152 |
|
153 MESMRTaskExtension* taskExtension = |
|
154 CESMRTaskExtenstionImpl::NewL( *taskFactory ); |
|
155 |
|
156 __ASSERT_DEBUG( taskFactory |
|
157 && entryProcessor |
|
158 && taskExtension, |
|
159 Panic( EESMRUtilsInvalidType) ); |
|
160 |
|
161 delete iTaskFactory; |
|
162 iTaskFactory = taskFactory; |
|
163 |
|
164 delete iEntryProcessor; |
|
165 iEntryProcessor = entryProcessor; |
|
166 |
|
167 delete iTaskExtension; |
|
168 iTaskExtension = taskExtension; |
|
169 |
|
170 CleanupStack::Pop( 2, taskFactory ); |
145 } |
171 } |
146 |
172 |
147 // ---------------------------------------------------------------------------- |
173 // ---------------------------------------------------------------------------- |
148 // CESMRUtils::DeleteWithUiL |
174 // CESMRUtils::DeleteWithUiL |
149 // ---------------------------------------------------------------------------- |
175 // ---------------------------------------------------------------------------- |
155 FUNC_LOG; |
181 FUNC_LOG; |
156 RPointerArray<CCalEntry> entries; |
182 RPointerArray<CCalEntry> entries; |
157 CleanupClosePushL( entries ); |
183 CleanupClosePushL( entries ); |
158 User::LeaveIfError( entries.Append( &aEntry ) ); |
184 User::LeaveIfError( entries.Append( &aEntry ) ); |
159 |
185 |
160 CESMREntryProcessor* processor = |
186 CreateExtensionsL( ESMREntryHelper::EventTypeL( aEntry ) ); |
161 CESMREntryProcessor::NewL( |
187 |
162 *iMRMailboxUtils, |
188 iEntryProcessor->ProcessL( &entries ); |
163 *iCalDBMgr ); |
189 |
164 |
190 MESMRMeetingRequestEntry& mrEntry = |
165 CleanupStack::PushL( processor ); |
191 static_cast< MESMRMeetingRequestEntry& >( |
166 |
192 iEntryProcessor->ESMREntryL() ); |
167 processor->ProcessL( &entries ); |
193 |
168 |
|
169 MESMRMeetingRequestEntry& mrEntry = processor->ESMREntryL(); |
|
170 if ( mrEntry.IsRecurrentEventL() ) |
194 if ( mrEntry.IsRecurrentEventL() ) |
171 { |
195 { |
172 mrEntry.SetModifyingRuleL( |
196 mrEntry.SetModifyingRuleL( |
173 MESMRMeetingRequestEntry::EESMRAllInSeries ); |
197 MESMRMeetingRequestEntry::EESMRAllInSeries ); |
174 } |
198 } |
192 EXPORT_C TInt CESMRUtils::DeleteWithUiL( |
215 EXPORT_C TInt CESMRUtils::DeleteWithUiL( |
193 CCalInstance* aInstance, |
216 CCalInstance* aInstance, |
194 TMsvId /*aMailbox*/ ) |
217 TMsvId /*aMailbox*/ ) |
195 { |
218 { |
196 FUNC_LOG; |
219 FUNC_LOG; |
197 CESMREntryProcessor* processor = |
220 |
198 CESMREntryProcessor::NewL( |
221 CreateExtensionsL( ESMREntryHelper::EventTypeL( aInstance->Entry() ) ); |
199 *iMRMailboxUtils, |
222 |
200 *iCalDBMgr ); |
223 iEntryProcessor->ProcessL( *aInstance ); |
201 |
224 |
202 CleanupStack::PushL( processor ); |
225 MESMRMeetingRequestEntry& mrEntry = |
203 |
226 static_cast< MESMRMeetingRequestEntry& >( |
204 processor->ProcessL( *aInstance ); |
227 iEntryProcessor->ESMREntryL() ); |
205 |
228 |
206 MESMRMeetingRequestEntry& mrEntry = processor->ESMREntryL(); |
|
207 mrEntry.SetModifyingRuleL( |
229 mrEntry.SetModifyingRuleL( |
208 MESMRMeetingRequestEntry::EESMRThisOnly ); |
230 MESMRMeetingRequestEntry::EESMRThisOnly ); |
209 |
231 |
210 mrEntry.MarkMeetingCancelledL(); |
232 mrEntry.MarkMeetingCancelledL(); |
211 |
233 |
212 iTaskExtension->DeleteAndSendMRL( |
234 iTaskExtension->DeleteAndSendMRL( |
213 EESMRCmdDeleteMR, |
235 EESMRCmdDeleteMR, |
214 mrEntry ); |
236 mrEntry ); |
215 |
|
216 // prosessor and aInstance |
|
217 CleanupStack::PopAndDestroy( processor ); |
|
218 |
237 |
219 // aInstance is not added to CleanupStack, because calendar |
238 // aInstance is not added to CleanupStack, because calendar |
220 // already has it. |
239 // already has it. |
221 delete aInstance; |
240 delete aInstance; |
222 return KErrNone; |
241 return KErrNone; |
233 FUNC_LOG; |
252 FUNC_LOG; |
234 RPointerArray<CCalEntry> entries; |
253 RPointerArray<CCalEntry> entries; |
235 CleanupClosePushL( entries ); |
254 CleanupClosePushL( entries ); |
236 User::LeaveIfError( entries.Append( &aEntry ) ); |
255 User::LeaveIfError( entries.Append( &aEntry ) ); |
237 |
256 |
238 CESMREntryProcessor* processor = |
257 CreateExtensionsL( ESMREntryHelper::EventTypeL( aEntry ) ); |
239 CESMREntryProcessor::NewL( |
258 |
240 *iMRMailboxUtils, |
259 iEntryProcessor->ProcessL( &entries ); |
241 *iCalDBMgr ); |
260 |
242 |
261 //MESMRMeetingRequestEntry& = processor->ESMREntryL(); |
243 CleanupStack::PushL( processor ); |
262 MESMRMeetingRequestEntry& mrEntry = |
244 |
263 static_cast< MESMRMeetingRequestEntry& >( |
245 processor->ProcessL( &entries ); |
264 iEntryProcessor->ESMREntryL() ); |
246 |
|
247 MESMRMeetingRequestEntry& mrEntry = processor->ESMREntryL(); |
|
248 |
265 |
249 if ( mrEntry.IsRecurrentEventL() ) |
266 if ( mrEntry.IsRecurrentEventL() ) |
250 { |
267 { |
251 mrEntry.SetModifyingRuleL( |
268 mrEntry.SetModifyingRuleL( |
252 MESMRMeetingRequestEntry::EESMRAllInSeries ); |
269 MESMRMeetingRequestEntry::EESMRAllInSeries ); |
254 |
271 |
255 iTaskExtension->ForwardMRAsEmailL( |
272 iTaskExtension->ForwardMRAsEmailL( |
256 EESMRCmdForwardAsMail, |
273 EESMRCmdForwardAsMail, |
257 mrEntry ); |
274 mrEntry ); |
258 |
275 |
259 CleanupStack::PopAndDestroy( processor ); |
|
260 CleanupStack::PopAndDestroy( &entries ); |
276 CleanupStack::PopAndDestroy( &entries ); |
261 } |
277 } |
262 // ---------------------------------------------------------------------------- |
278 // ---------------------------------------------------------------------------- |
263 // CESMRUtils::ExtensionL |
279 // CESMRUtils::ExtensionL |
264 // ---------------------------------------------------------------------------- |
280 // ---------------------------------------------------------------------------- |
301 // Asynchronous initialization of CESMRServicesCalDbMgr: |
317 // Asynchronous initialization of CESMRServicesCalDbMgr: |
302 iCalDBMgr = CESMRCalDbMgr::NewL( aCalSession, |
318 iCalDBMgr = CESMRCalDbMgr::NewL( aCalSession, |
303 *this ); |
319 *this ); |
304 |
320 |
305 iMRMailboxUtils = CMRMailboxUtils::NewL( aMsvSession ); |
321 iMRMailboxUtils = CMRMailboxUtils::NewL( aMsvSession ); |
306 |
|
307 iTaskFactory = CESMRTaskFactory::NewL( *iCalDBMgr, *iMRMailboxUtils ); |
|
308 |
|
309 iEntryProcessor = CESMREntryProcessor::NewL( |
|
310 *iMRMailboxUtils, |
|
311 *iCalDBMgr ); |
|
312 |
|
313 iTaskExtension = |
|
314 CESMRTaskExtenstionImpl::NewL( |
|
315 *iCalDBMgr, |
|
316 *iMRMailboxUtils, |
|
317 *iPolicyManager, |
|
318 *iEntryProcessor, |
|
319 *iTaskFactory ); |
|
320 } |
322 } |
321 |
323 |
322 // ---------------------------------------------------------------------------- |
324 // ---------------------------------------------------------------------------- |
323 // CESMRUtils::HandleCalEngStatus |
325 // CESMRUtils::HandleCalEngStatus |
324 // ---------------------------------------------------------------------------- |
326 // ---------------------------------------------------------------------------- |