|
1 /* |
|
2 * Copyright (c) 2007 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 of the class CFsServerMtm. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include <StringLoader.h> |
|
22 #include <centralrepository.h> |
|
23 #include "FreestyleEmailCenRepKeys.h" |
|
24 #include "cfsservermtm.h" |
|
25 #include <msventry.h> |
|
26 #include <mentact.h> |
|
27 #include "cfsmsgconverter.h" |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CFsServerMtm::NewL |
|
31 // Exported factory function |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CFsServerMtm* CFsServerMtm::NewL( |
|
35 CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aInitialEntry) |
|
36 { |
|
37 FUNC_LOG; |
|
38 |
|
39 CleanupStack::PushL( aInitialEntry ); |
|
40 CFsServerMtm* self=new (ELeave) CFsServerMtm( aRegisteredMtmDll, |
|
41 aInitialEntry); |
|
42 CleanupStack::Pop(); |
|
43 |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(); |
|
47 |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CFsServerMtm::CFsServerMtm |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CFsServerMtm::CFsServerMtm( CRegisteredMtmDll& aRegisteredMtmDll, |
|
56 CMsvServerEntry* aInitialEntry ) |
|
57 : CBaseServerMtm( aRegisteredMtmDll, aInitialEntry ) |
|
58 { |
|
59 FUNC_LOG; |
|
60 |
|
61 iProcessingNestedEmail = EFalse; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CFsServerMtm::ConstructL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CFsServerMtm::ConstructL() |
|
69 { |
|
70 FUNC_LOG; |
|
71 |
|
72 CActiveScheduler::Add( this ); |
|
73 |
|
74 // Check configuration status of "email attached in email" from cenrep |
|
75 // and set flag according to that. |
|
76 CRepository* repository = NULL; |
|
77 TRAPD( ret, repository = CRepository::NewL( KFreestyleEmailCenRep ) ); |
|
78 if ( ret == KErrNone ) |
|
79 { |
|
80 CleanupStack::PushL( repository ); |
|
81 TInt rval = KErrNone; |
|
82 TInt hidefeature = 0; |
|
83 rval = repository->Get( KEmailHideFS205UIFeature, hidefeature ); |
|
84 if( rval == KErrNone && hidefeature == EFalse ) |
|
85 { |
|
86 iEmailAttachedInEmail = ETrue; |
|
87 } |
|
88 CleanupStack::PopAndDestroy( repository ); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CFsServerMtm::CFsServerMtm |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CFsServerMtm::~CFsServerMtm() |
|
97 { |
|
98 FUNC_LOG; |
|
99 |
|
100 Cancel(); |
|
101 |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CFsServerMtm::CopyToLocalL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CFsServerMtm::CopyToLocalL( const CMsvEntrySelection& /*aSelection*/, |
|
109 TMsvId /*aDestination*/, TRequestStatus& /*aStatus*/ ) |
|
110 { |
|
111 FUNC_LOG; |
|
112 |
|
113 User::Leave( KErrNotSupported ); |
|
114 |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CFsServerMtm::CopyFromLocalL |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CFsServerMtm::CopyFromLocalL(const CMsvEntrySelection& /*aSelection*/, |
|
122 TMsvId /*aDestination*/, TRequestStatus& /*aStatus*/) |
|
123 { |
|
124 FUNC_LOG; |
|
125 |
|
126 User::Leave( KErrNotSupported ); |
|
127 |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // CFsServerMtm::CopyWithinServiceL |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CFsServerMtm::CopyWithinServiceL( |
|
135 const CMsvEntrySelection& /*aSelection*/, TMsvId /*aDestination*/, |
|
136 TRequestStatus& /*aStatus*/) |
|
137 { |
|
138 FUNC_LOG; |
|
139 |
|
140 User::Leave( KErrNotSupported ); |
|
141 |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CFsServerMtm::MoveToLocalL |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CFsServerMtm::MoveToLocalL(const CMsvEntrySelection& /*aSelection*/, |
|
149 TMsvId /*aDestination*/, TRequestStatus& /*aStatus*/) |
|
150 { |
|
151 FUNC_LOG; |
|
152 |
|
153 User::Leave( KErrNotSupported ); |
|
154 |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CFsServerMtm::MoveFromLocalL |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CFsServerMtm::MoveFromLocalL(const CMsvEntrySelection& /*aSelection*/, |
|
162 TMsvId /*aDestination*/, TRequestStatus& /*aStatus*/) |
|
163 { |
|
164 FUNC_LOG; |
|
165 |
|
166 User::Leave( KErrNotSupported ); |
|
167 |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CFsServerMtm::MoveWithinServiceL |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CFsServerMtm::MoveWithinServiceL(const |
|
175 CMsvEntrySelection& /*aSelection*/, TMsvId /*aDestination*/, |
|
176 TRequestStatus& /*aStatus*/) |
|
177 { |
|
178 FUNC_LOG; |
|
179 |
|
180 User::Leave( KErrNotSupported ); |
|
181 |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CFsServerMtm::DeleteAllL |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CFsServerMtm::DeleteAllL(const CMsvEntrySelection& /*aSelection*/, |
|
189 TRequestStatus& /*aStatus*/) |
|
190 |
|
191 { |
|
192 FUNC_LOG; |
|
193 |
|
194 User::Leave( KErrNotSupported ); |
|
195 |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // CFsServerMtm::CreateL |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CFsServerMtm::CreateL(TMsvEntry /*aNewEntry*/, |
|
203 TRequestStatus& /*aStatus*/) |
|
204 { |
|
205 FUNC_LOG; |
|
206 |
|
207 User::Leave( KErrNotSupported ); |
|
208 |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // CFsServerMtm::ChangeL |
|
213 // This function could change file names in the file system. It would then |
|
214 // also have to change the details field of all the children of a changed |
|
215 // folder name. Not supported for now. |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CFsServerMtm::ChangeL(TMsvEntry /*aNewEntry*/, |
|
219 TRequestStatus& /*aStatus*/) |
|
220 { |
|
221 FUNC_LOG; |
|
222 |
|
223 User::Leave( KErrNotSupported ); |
|
224 |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CFsServerMtm::StartCommandL |
|
229 // Run MTM-specific command on selection of entries |
|
230 // Only command supported is Refresh |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CFsServerMtm::StartCommandL( CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus ) |
|
234 { |
|
235 FUNC_LOG; |
|
236 |
|
237 if ( iEmailAttachedInEmail ) |
|
238 { |
|
239 switch( aCommand ) |
|
240 { |
|
241 // Add an rfc822/MIME email as an attachment. |
|
242 case KEasEmailMTMAddEmailAttachment: |
|
243 { |
|
244 aStatus = KRequestPending; |
|
245 iConvertToNestedEmailRequestStatus = &aStatus; |
|
246 TBuf<256> tmp; |
|
247 tmp.Copy(aParameter); |
|
248 TRAPD( er, AddEmailAsAttachmentL( aSelection[0], tmp ) ); |
|
249 if ( er != KErrNone ) |
|
250 { |
|
251 TRequestStatus* status = &aStatus; |
|
252 User::RequestComplete( status, er ); |
|
253 } |
|
254 break; |
|
255 } |
|
256 case KEasEmailMTMDeleteEntry: |
|
257 { |
|
258 iServerEntry->SetEntry( aSelection[1] ); |
|
259 iServerEntry->SetEntry( aSelection[0] ); |
|
260 iServerEntry->DeleteEntry( aSelection[1] ); |
|
261 |
|
262 TRequestStatus* status = &aStatus; |
|
263 User::RequestComplete( status, KErrNone ); |
|
264 break; |
|
265 } |
|
266 |
|
267 default: |
|
268 User::Leave( KErrNotSupported ); |
|
269 break; |
|
270 } |
|
271 } |
|
272 else |
|
273 { |
|
274 User::Leave( KErrNotSupported ); |
|
275 } |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------------------------- |
|
279 // CFsServerMtm::CommandExpected |
|
280 // Prevent object deletion on command completion |
|
281 // Allow unloading |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 TBool CFsServerMtm::CommandExpected() |
|
285 { |
|
286 FUNC_LOG; |
|
287 return EFalse; |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CFsServerMtm::Progress |
|
292 // Pass-back progress information |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 const TDesC8& CFsServerMtm::Progress() |
|
296 { |
|
297 FUNC_LOG; |
|
298 return KNullDesC8; |
|
299 } |
|
300 |
|
301 // |
|
302 // Active object completion functions |
|
303 // |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CFsServerMtm::DoCancel |
|
307 // Cancel current operation |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CFsServerMtm::DoCancel() |
|
311 { |
|
312 FUNC_LOG; |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // CFsServerMtm::DoComplete |
|
317 // Active object complete leave handler |
|
318 // Never expect this to be called as CFsServerMtm::DoRunL() does not leave |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CFsServerMtm::DoComplete(TInt /*aError*/) |
|
322 { |
|
323 FUNC_LOG; |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // CFsServerMtm::DoRunL |
|
328 // Active object completion |
|
329 // Run is used in this object to clean up after operations have finished. |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CFsServerMtm::DoRunL() |
|
333 { |
|
334 FUNC_LOG; |
|
335 |
|
336 if ( iEmailAttachedInEmail ) |
|
337 { |
|
338 // Is it the AddEmailAsAttachment Command |
|
339 if ( iConvertToNestedEmail && !iConvertToNestedEmail->IsActive() ) |
|
340 { |
|
341 // This should always be the case. |
|
342 if ( *iConvertToNestedEmailRequestStatus != KRequestPending ) |
|
343 { |
|
344 User::Leave( KErrCorrupt ); |
|
345 } |
|
346 iProcessingNestedEmail = EFalse; |
|
347 |
|
348 if ( iConverter ) |
|
349 { |
|
350 delete iConverter; |
|
351 iConverter = NULL; |
|
352 iConvLibrary.Close(); |
|
353 } |
|
354 |
|
355 // If iStatus.Int() > 0 it contains the new ID of the MTM message |
|
356 User::RequestComplete( iConvertToNestedEmailRequestStatus, iStatus.Int() ); |
|
357 } |
|
358 |
|
359 if ( iProcessingNestedEmail ) |
|
360 { |
|
361 SetActive(); |
|
362 } |
|
363 else |
|
364 { |
|
365 } |
|
366 } |
|
367 } |
|
368 |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // CFsServerMtm::AddEmailAsAttachmentL |
|
372 // |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 void CFsServerMtm::AddEmailAsAttachmentL( const TMsvId& aParentEmailId, const TDesC& aAttachmentPath ) |
|
376 { |
|
377 FUNC_LOG; |
|
378 //LOAD EAS LIBRARY TO CONVERT RFC 822 to MTM |
|
379 _LIT( KLauncherFilenameExe, "neasmsgconverter.dll" ); |
|
380 TInt err = iConvLibrary.Load( KLauncherFilenameExe ); |
|
381 if ( err != KErrNone ) |
|
382 { |
|
383 User::Leave( err ); |
|
384 } |
|
385 TLibraryFunction constructor = iConvLibrary.Lookup( 1 ); |
|
386 iConverter = ( CMsgConverter* ) constructor(); |
|
387 |
|
388 iConvertToNestedEmail = iConverter->GetMsgActiveObjectL( |
|
389 aParentEmailId, |
|
390 aAttachmentPath, |
|
391 KNullDesC8, |
|
392 *iServerEntry, |
|
393 ETrue, |
|
394 aParentEmailId ); |
|
395 |
|
396 iConverter->StartL( &iStatus ); |
|
397 iProcessingNestedEmail = ETrue; |
|
398 |
|
399 if ( !IsActive() ) |
|
400 { |
|
401 SetActive(); |
|
402 } |
|
403 } |
|
404 |
|
405 // End of file |