25
|
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: ESMR MRUtils implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
//INCLUDE FILES
|
|
20 |
#include "emailtrace.h"
|
|
21 |
#include "cesmrutils.h"
|
|
22 |
#include "cesmrcaldbmgr.h"
|
|
23 |
|
|
24 |
// From ESMRSERVICES
|
|
25 |
#include <esmrpolicies.rsg>
|
|
26 |
//<cmail>
|
|
27 |
#include "cesmrpolicymanager.h"
|
|
28 |
#include "tesmrscenariodata.h"
|
|
29 |
#include "cesmrpolicy.h"
|
|
30 |
//</cmail>
|
|
31 |
|
|
32 |
#include "cmrentryprocessor.h"
|
|
33 |
#include "mesmrmeetingrequestentry.h"
|
|
34 |
#include "cesmrtaskfactory.h"
|
|
35 |
#include "mesmrtask.h"
|
|
36 |
#include "cesmrtaskextensionimpl.h"
|
|
37 |
#include "esmrinternaluid.h"
|
|
38 |
#include "esmrhelper.h"
|
|
39 |
#include "esmrentryhelper.h"
|
|
40 |
|
|
41 |
// From System
|
|
42 |
#include <coemain.h>
|
|
43 |
#include <calentry.h>
|
|
44 |
#include <calinstance.h>
|
|
45 |
#include <calsession.h>
|
|
46 |
#include <calcommon.h>
|
|
47 |
#include <caluser.h>
|
|
48 |
#include <cmrmailboxutils.h>
|
|
49 |
#include <msvapi.h>
|
|
50 |
#include <msvstd.h>
|
|
51 |
#include <data_caging_path_literals.hrh>
|
|
52 |
|
|
53 |
// CONSTANTS
|
|
54 |
/// Unnamed namespace for local definitions
|
|
55 |
namespace {
|
|
56 |
|
|
57 |
#ifdef _DEBUG
|
|
58 |
|
|
59 |
// Definition for MR UTILS panic text
|
|
60 |
_LIT(KESMRUtilsPanicTxt, "ESMRUtils" );
|
|
61 |
|
|
62 |
// MR VIEWER ctrl panic codes
|
|
63 |
enum TESMRUtilsPanicCode
|
|
64 |
{
|
|
65 |
EESMRUtilsEntryProcessorNull = 0, // Entry processon is NULL
|
|
66 |
EESMRUtilsInvalidEntry = 1, // Invalid calendar entry,
|
|
67 |
EESMRUtilsNULLCoeEnv = 2, // CCoeEnv is NULL
|
|
68 |
EESMRUtilsInvalidType
|
|
69 |
};
|
|
70 |
|
|
71 |
void Panic(TESMRUtilsPanicCode aPanicCode)
|
|
72 |
{
|
|
73 |
User::Panic( KESMRUtilsPanicTxt, aPanicCode );
|
|
74 |
}
|
|
75 |
|
|
76 |
#endif
|
|
77 |
|
|
78 |
} // namespace
|
|
79 |
|
|
80 |
// ======== MEMBER FUNCTIONS ========
|
|
81 |
|
|
82 |
// ----------------------------------------------------------------------------
|
|
83 |
// CESMRUtils::CESMRUtils
|
|
84 |
// ----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CESMRUtils::CESMRUtils(
|
|
87 |
MMRUtilsObserver& aObserver )
|
|
88 |
: iObserver( aObserver )
|
|
89 |
{
|
|
90 |
FUNC_LOG;
|
|
91 |
}
|
|
92 |
|
|
93 |
// ----------------------------------------------------------------------------
|
|
94 |
// CESMRUtils::~CESMRUtils
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
EXPORT_C CESMRUtils::~CESMRUtils()
|
|
98 |
{
|
|
99 |
FUNC_LOG;
|
|
100 |
delete iPolicyManager;
|
|
101 |
delete iEntryProcessor;
|
|
102 |
delete iMRMailboxUtils;
|
|
103 |
delete iTaskFactory;
|
|
104 |
delete iTaskExtension;
|
|
105 |
delete iCalDBMgr;
|
|
106 |
}
|
|
107 |
|
|
108 |
// ----------------------------------------------------------------------------
|
|
109 |
// CESMRUtils::NewL
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
EXPORT_C CESMRUtils* CESMRUtils::NewL(
|
|
113 |
MMRUtilsObserver& aObserver )
|
|
114 |
{
|
|
115 |
FUNC_LOG;
|
|
116 |
CESMRUtils* self = new ( ELeave ) CESMRUtils( aObserver );
|
|
117 |
CleanupStack::PushL( self );
|
|
118 |
self->ConstructL();
|
|
119 |
CleanupStack::Pop();
|
|
120 |
return self;
|
|
121 |
}
|
|
122 |
|
|
123 |
// ----------------------------------------------------------------------------
|
|
124 |
// CESMRUtils::ConstructL
|
|
125 |
// ----------------------------------------------------------------------------
|
|
126 |
//
|
|
127 |
void CESMRUtils::ConstructL()
|
|
128 |
{
|
|
129 |
FUNC_LOG;
|
|
130 |
|
|
131 |
iPolicyManager = CESMRPolicyManager::NewL();
|
|
132 |
}
|
|
133 |
|
|
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 );
|
|
171 |
}
|
|
172 |
|
|
173 |
// ----------------------------------------------------------------------------
|
|
174 |
// CESMRUtils::DeleteWithUiL
|
|
175 |
// ----------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
EXPORT_C TInt CESMRUtils::DeleteWithUiL(
|
|
178 |
const CCalEntry& aEntry,
|
|
179 |
TMsvId /*aMailbox*/ )
|
|
180 |
{
|
|
181 |
FUNC_LOG;
|
|
182 |
RPointerArray<CCalEntry> entries;
|
|
183 |
CleanupClosePushL( entries );
|
|
184 |
User::LeaveIfError( entries.Append( &aEntry ) );
|
|
185 |
|
|
186 |
CreateExtensionsL( ESMREntryHelper::EventTypeL( aEntry ) );
|
|
187 |
|
|
188 |
iEntryProcessor->ProcessL( &entries );
|
|
189 |
|
|
190 |
MESMRMeetingRequestEntry& mrEntry =
|
|
191 |
static_cast< MESMRMeetingRequestEntry& >(
|
|
192 |
iEntryProcessor->ESMREntryL() );
|
|
193 |
|
|
194 |
if ( mrEntry.IsRecurrentEventL() )
|
|
195 |
{
|
|
196 |
mrEntry.SetModifyingRuleL(
|
|
197 |
MESMRMeetingRequestEntry::EESMRAllInSeries );
|
|
198 |
}
|
|
199 |
|
|
200 |
mrEntry.MarkMeetingCancelledL();
|
|
201 |
|
|
202 |
iTaskExtension->DeleteAndSendMRL(
|
|
203 |
EESMRCmdDeleteMR,
|
|
204 |
mrEntry );
|
|
205 |
|
|
206 |
CleanupStack::PopAndDestroy( &entries );
|
|
207 |
|
|
208 |
return KErrNone;
|
|
209 |
}
|
|
210 |
|
|
211 |
// ----------------------------------------------------------------------------
|
|
212 |
// CESMRUtils::DeleteWithUiL
|
|
213 |
// ----------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
EXPORT_C TInt CESMRUtils::DeleteWithUiL(
|
|
216 |
CCalInstance* aInstance,
|
|
217 |
TMsvId /*aMailbox*/ )
|
|
218 |
{
|
|
219 |
FUNC_LOG;
|
|
220 |
|
|
221 |
CreateExtensionsL( ESMREntryHelper::EventTypeL( aInstance->Entry() ) );
|
|
222 |
|
|
223 |
iEntryProcessor->ProcessL( *aInstance );
|
|
224 |
|
|
225 |
MESMRMeetingRequestEntry& mrEntry =
|
|
226 |
static_cast< MESMRMeetingRequestEntry& >(
|
|
227 |
iEntryProcessor->ESMREntryL() );
|
|
228 |
|
|
229 |
mrEntry.SetModifyingRuleL(
|
|
230 |
MESMRMeetingRequestEntry::EESMRThisOnly );
|
|
231 |
|
|
232 |
mrEntry.MarkMeetingCancelledL();
|
|
233 |
|
|
234 |
iTaskExtension->DeleteAndSendMRL(
|
|
235 |
EESMRCmdDeleteMR,
|
|
236 |
mrEntry );
|
|
237 |
|
|
238 |
// aInstance is not added to CleanupStack, because calendar
|
|
239 |
// already has it.
|
|
240 |
delete aInstance;
|
|
241 |
return KErrNone;
|
|
242 |
}
|
|
243 |
|
|
244 |
// ----------------------------------------------------------------------------
|
|
245 |
// CESMRUtils::SendWithUiL
|
|
246 |
// ----------------------------------------------------------------------------
|
|
247 |
//
|
|
248 |
EXPORT_C void CESMRUtils::SendWithUiL(
|
|
249 |
const CCalEntry& aEntry ,
|
|
250 |
TMsvId /*aMailbox*/ )
|
|
251 |
{
|
|
252 |
FUNC_LOG;
|
|
253 |
RPointerArray<CCalEntry> entries;
|
|
254 |
CleanupClosePushL( entries );
|
|
255 |
User::LeaveIfError( entries.Append( &aEntry ) );
|
|
256 |
|
|
257 |
CreateExtensionsL( ESMREntryHelper::EventTypeL( aEntry ) );
|
|
258 |
|
|
259 |
iEntryProcessor->ProcessL( &entries );
|
|
260 |
|
|
261 |
//MESMRMeetingRequestEntry& = processor->ESMREntryL();
|
|
262 |
MESMRMeetingRequestEntry& mrEntry =
|
|
263 |
static_cast< MESMRMeetingRequestEntry& >(
|
|
264 |
iEntryProcessor->ESMREntryL() );
|
|
265 |
|
|
266 |
if ( mrEntry.IsRecurrentEventL() )
|
|
267 |
{
|
|
268 |
mrEntry.SetModifyingRuleL(
|
|
269 |
MESMRMeetingRequestEntry::EESMRAllInSeries );
|
|
270 |
}
|
|
271 |
|
|
272 |
iTaskExtension->ForwardMRAsEmailL(
|
|
273 |
EESMRCmdForwardAsMail,
|
|
274 |
mrEntry );
|
|
275 |
|
|
276 |
CleanupStack::PopAndDestroy( &entries );
|
|
277 |
}
|
|
278 |
// ----------------------------------------------------------------------------
|
|
279 |
// CESMRUtils::ExtensionL
|
|
280 |
// ----------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
EXPORT_C TAny* CESMRUtils::ExtensionL( TUid aExtensionUid )
|
|
283 |
{
|
|
284 |
FUNC_LOG;
|
|
285 |
TAny* extension = NULL;
|
|
286 |
|
|
287 |
switch ( aExtensionUid.iUid )
|
|
288 |
{
|
|
289 |
case KESMRPolicyMgrUid:
|
|
290 |
extension = static_cast<TAny*>(iPolicyManager);
|
|
291 |
break;
|
|
292 |
case KESMRMREntryProcessorUid:
|
|
293 |
extension = static_cast<TAny*>(iEntryProcessor);
|
|
294 |
break;
|
|
295 |
case KESMRTaskExtensionUid:
|
|
296 |
extension = static_cast<TAny*>(iTaskExtension);
|
|
297 |
break;
|
|
298 |
default:
|
|
299 |
extension = NULL;
|
|
300 |
break;
|
|
301 |
}
|
|
302 |
return extension;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ----------------------------------------------------------------------------
|
|
306 |
// CESMRUtils::SessionSetupL
|
|
307 |
// This template method is called as a part of the ECom plugin construction.
|
|
308 |
// This replaces much of the ordinary ConstructL() functionality, a template
|
|
309 |
// method is easier for transmitting parameters.
|
|
310 |
// ----------------------------------------------------------------------------
|
|
311 |
//
|
|
312 |
EXPORT_C void CESMRUtils::SessionSetupL(
|
|
313 |
CCalSession& aCalSession,
|
|
314 |
CMsvSession* aMsvSession )
|
|
315 |
{
|
|
316 |
FUNC_LOG;
|
|
317 |
// Asynchronous initialization of CESMRServicesCalDbMgr:
|
|
318 |
iCalDBMgr = CESMRCalDbMgr::NewL( aCalSession,
|
|
319 |
*this );
|
|
320 |
|
|
321 |
iMRMailboxUtils = CMRMailboxUtils::NewL( aMsvSession );
|
|
322 |
}
|
|
323 |
|
|
324 |
// ----------------------------------------------------------------------------
|
|
325 |
// CESMRUtils::HandleCalEngStatus
|
|
326 |
// ----------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
void CESMRUtils::HandleCalEngStatus( TMRUtilsCalEngStatus aStatus )
|
|
329 |
{
|
|
330 |
FUNC_LOG;
|
|
331 |
iCalEngStatus = aStatus;
|
|
332 |
iObserver.HandleCalEngStatus( iCalEngStatus );
|
|
333 |
}
|
|
334 |
|
|
335 |
// ----------------------------------------------------------------------------
|
|
336 |
// CESMRUtils::HandleOperation
|
|
337 |
// ----------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void CESMRUtils::HandleOperation(
|
|
340 |
TInt /*aType*/,
|
|
341 |
TInt /*aPercentageCompleted*/,
|
|
342 |
TInt /*aStatus*/ )
|
|
343 |
{
|
|
344 |
FUNC_LOG;
|
|
345 |
// Do nothing
|
|
346 |
}
|
|
347 |
|
|
348 |
// End of file
|
|
349 |
|