|
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 task extension implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include "cesmrtaskextensionimpl.h" |
|
20 |
|
21 #include <caluser.h> |
|
22 #include "esmrinternaluid.h" |
|
23 //<cmail> |
|
24 #include "cesmrpolicymanager.h" |
|
25 //</cmail> |
|
26 #include "cesmrentryprocessor.h" |
|
27 #include "mesmrmeetingrequestentry.h" |
|
28 #include "cesmrtaskfactory.h" |
|
29 #include "mesmrtask.h" |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CESMRTaskExtenstionImpl::CESMRTaskExtenstionImpl |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CESMRTaskExtenstionImpl::CESMRTaskExtenstionImpl( |
|
38 MESMRCalDbMgr& aCalDBMgr, |
|
39 CMRMailboxUtils& aMRMailboxUtils, |
|
40 CESMRPolicyManager& aPolicyManager, |
|
41 CESMREntryProcessor& aEntryProcessor, |
|
42 MESMRTaskFactory& aTaskFactory ) |
|
43 : iCalDBMgr( aCalDBMgr ), |
|
44 iMRMailboxUtils( aMRMailboxUtils), |
|
45 iPolicyManager( aPolicyManager ), |
|
46 iEntryProcessor( aEntryProcessor), |
|
47 iTaskFactory( aTaskFactory ) |
|
48 { |
|
49 FUNC_LOG; |
|
50 //do nothing |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CESMRTaskExtenstionImpl::~CESMRTaskExtenstionImpl |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CESMRTaskExtenstionImpl::~CESMRTaskExtenstionImpl() |
|
59 { |
|
60 FUNC_LOG; |
|
61 //do nothing |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CESMRTaskExtenstionImpl::NewL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CESMRTaskExtenstionImpl* CESMRTaskExtenstionImpl::NewL( |
|
69 MESMRCalDbMgr& aCalDBMgr, |
|
70 CMRMailboxUtils& aMRMailboxUtils, |
|
71 CESMRPolicyManager& aPolicyManager, |
|
72 CESMREntryProcessor& aEntryProcessor, |
|
73 MESMRTaskFactory& aTaskFactory ) |
|
74 { |
|
75 FUNC_LOG; |
|
76 CESMRTaskExtenstionImpl* self = |
|
77 new (ELeave) CESMRTaskExtenstionImpl( |
|
78 aCalDBMgr, |
|
79 aMRMailboxUtils, |
|
80 aPolicyManager, |
|
81 aEntryProcessor, |
|
82 aTaskFactory ); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL(); |
|
85 CleanupStack::Pop( self ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CESMRTaskExtenstionImpl::ConstructL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CESMRTaskExtenstionImpl::ConstructL() |
|
94 { |
|
95 FUNC_LOG; |
|
96 //do nothing |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CESMRTaskExtenstionImpl::SendAndStoreResponseL |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CESMRTaskExtenstionImpl::SendAndStoreResponseL( |
|
104 TESMRCommand aCommand, |
|
105 MESMRMeetingRequestEntry& aEntry ) |
|
106 { |
|
107 FUNC_LOG; |
|
108 // First do possible command conversion |
|
109 if ( EESMRAcceptWithoutAttachmentCheck == aCommand ) |
|
110 { |
|
111 aCommand = EESMRCmdAcceptMR; |
|
112 } |
|
113 else if ( EESMRTentativeWithoutAttachmentCheck == aCommand ) |
|
114 { |
|
115 aCommand = EESMRCmdTentativeMR; |
|
116 } |
|
117 else if ( EESMRDeclineWithoutAttachmentCheck == aCommand ) |
|
118 { |
|
119 aCommand = EESMRCmdDeclineMR; |
|
120 } |
|
121 |
|
122 // Check that command is valid |
|
123 if ( !( EESMRCmdAcceptMR == aCommand || |
|
124 EESMRCmdTentativeMR == aCommand || |
|
125 EESMRCmdDeclineMR == aCommand ) ) |
|
126 { |
|
127 // Invalid command --> Leave |
|
128 User::Leave( KErrArgument ); |
|
129 } |
|
130 |
|
131 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CESMRTaskExtenstionImpl::SendAndStoreMRL |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CESMRTaskExtenstionImpl::SendAndStoreMRL( |
|
139 TESMRCommand aCommand, |
|
140 MESMRMeetingRequestEntry& aEntry ) |
|
141 { |
|
142 FUNC_LOG; |
|
143 // Check that command is valid |
|
144 if ( !( EESMRCmdSendMR == aCommand || |
|
145 EESMRCmdSendMRUpdate == aCommand) ) |
|
146 { |
|
147 // Invalid command --> Leave |
|
148 User::Leave( KErrArgument ); |
|
149 } |
|
150 |
|
151 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CESMRTaskExtenstionImpl::SendAndStoreMRL |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CESMRTaskExtenstionImpl::DeleteMRFromLocalDBL( |
|
159 TESMRCommand aCommand, |
|
160 MESMRMeetingRequestEntry& aEntry ) |
|
161 { |
|
162 FUNC_LOG; |
|
163 // Check that command is valid |
|
164 if ( EESMRCmdDeleteMR != aCommand ) |
|
165 { |
|
166 // Invalid command --> Leave |
|
167 User::Leave( KErrArgument ); |
|
168 } |
|
169 |
|
170 // Create and execute task |
|
171 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CESMRTaskExtenstionImpl::SendAndStoreMRL |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CESMRTaskExtenstionImpl::DeleteAndSendMRL( |
|
179 TESMRCommand aCommand, |
|
180 MESMRMeetingRequestEntry& aEntry ) |
|
181 { |
|
182 FUNC_LOG; |
|
183 // Check that command is valid |
|
184 if ( EESMRCmdDeleteMR == aCommand || |
|
185 EESMRCmdRemoveFromCalendar == aCommand || |
|
186 EESMRCmdMailDelete == aCommand ) |
|
187 { |
|
188 // Create And execute task |
|
189 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
190 } |
|
191 else |
|
192 { |
|
193 // Invalid command --> Leave |
|
194 User::Leave( KErrArgument ); |
|
195 } |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // CESMRTaskExtenstionImpl::StoreMRToLocalDBL |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CESMRTaskExtenstionImpl::StoreMRToLocalDBL( |
|
203 TESMRCommand aCommand, |
|
204 MESMRMeetingRequestEntry& aEntry ) |
|
205 { |
|
206 FUNC_LOG; |
|
207 if ( EESMRCmdSaveMR != aCommand ) |
|
208 { |
|
209 // Invalid command --> Leave |
|
210 User::Leave( KErrArgument ); |
|
211 } |
|
212 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CESMRTaskExtenstionImpl::ForwardMRAsEmailL |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CESMRTaskExtenstionImpl::ForwardMRAsEmailL( |
|
220 TESMRCommand aCommand, |
|
221 MESMRMeetingRequestEntry& aEntry ) |
|
222 { |
|
223 FUNC_LOG; |
|
224 // Check that command is valid |
|
225 if ( EESMRCmdForwardAsMail != aCommand ) |
|
226 { |
|
227 // Invalid command --> Leave |
|
228 User::Leave( KErrArgument ); |
|
229 } |
|
230 |
|
231 // Create And exexute task |
|
232 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CESMRTaskExtenstionImpl::ReplyAsEmailL |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CESMRTaskExtenstionImpl::ReplyAsEmailL( |
|
240 TESMRCommand aCommand, |
|
241 MESMRMeetingRequestEntry& aEntry ) |
|
242 { |
|
243 FUNC_LOG; |
|
244 // Check that command is valid |
|
245 if ( EESMRCmdReply != aCommand && EESMRCmdReplyAll != aCommand) |
|
246 { |
|
247 // Invalid command --> Leave |
|
248 User::Leave( KErrArgument ); |
|
249 } |
|
250 |
|
251 // Create And exexute task |
|
252 CreateAndExecuteTaskL( aCommand, aEntry ); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CESMRTaskExtenstionImpl::CreateAndExecuteTaskL |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CESMRTaskExtenstionImpl::CreateAndExecuteTaskL( |
|
260 TESMRCommand aCommand, |
|
261 MESMRMeetingRequestEntry& aEntry ) |
|
262 { |
|
263 FUNC_LOG; |
|
264 MESMRTask* task = iTaskFactory.CreateTaskL( aCommand, aEntry ); |
|
265 |
|
266 if (task ) |
|
267 { |
|
268 CleanupDeletePushL( task ); |
|
269 task->ExecuteTaskL(); |
|
270 CleanupStack::PopAndDestroy(); // task; |
|
271 } |
|
272 else |
|
273 { |
|
274 // Task cannot be constructed --> Leave |
|
275 |
|
276 User::Leave( KErrNotSupported ); |
|
277 } |
|
278 } |
|
279 |
|
280 //EOF |
|
281 |