68 User::RequestComplete(status, KErrNone); |
68 User::RequestComplete(status, KErrNone); |
69 SetActive(); |
69 SetActive(); |
70 } |
70 } |
71 |
71 |
72 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
73 // Finishes the initialisation |
73 // Finishes the initialization |
74 // --------------------------------------------------------------------------- |
74 // --------------------------------------------------------------------------- |
75 // |
75 // |
76 void CFSNotificationHandlerMgr::RunL() |
76 void CFSNotificationHandlerMgr::RunL() |
77 { |
77 { |
78 FUNC_LOG; |
78 FUNC_LOG; |
187 |
187 |
188 iHandlers.ResetAndDestroy(); |
188 iHandlers.ResetAndDestroy(); |
189 |
189 |
190 iHSConnection = NULL; |
190 iHSConnection = NULL; |
191 |
191 |
192 if( iMailClient ) |
192 if( iMailClient ) |
193 { |
193 { |
194 iMailClient->Close(); |
194 iMailClient->Close(); |
195 iMailClient = NULL; |
195 iMailClient = NULL; |
196 } |
196 } |
197 |
197 |
198 //<cmail> |
198 iAppUi = NULL; |
199 iAppUi = NULL; |
|
200 //</cmail> |
|
201 |
199 |
202 // Finished using ECom |
200 // Finished using ECom |
203 // ECom used at least in CFSMailHSUpdateHandler |
201 // ECom used at least in CFSMailHSUpdateHandler |
204 REComSession::FinalClose(); |
202 REComSession::FinalClose(); |
205 } |
203 } |
229 iMailClient->GetBrandManagerL().UpdateMailboxNamesL( aMailbox ); |
227 iMailClient->GetBrandManagerL().UpdateMailboxNamesL( aMailbox ); |
230 break; |
228 break; |
231 } |
229 } |
232 case TFSEventMailboxDeleted: |
230 case TFSEventMailboxDeleted: |
233 { |
231 { |
234 // Don't have to do anything here. Observing has ended when the |
232 // Observing has ended when the mailbox is deleted. |
235 // mailbox is deleted. |
233 |
|
234 // reset mailbox cached values |
|
235 iPreviousParentFolderId = TFSMailMsgId(); |
|
236 iPreviousMailbox = TFSMailMsgId(); |
236 break; |
237 break; |
237 } |
238 } |
238 case TFSMailboxAvailable: // Flow through |
239 case TFSMailboxAvailable: // Flow through |
239 case TFSMailboxUnavailable: // Flow through |
240 case TFSMailboxUnavailable: // Flow through |
240 case TFSEventMailboxRenamed: |
241 case TFSEventMailboxRenamed: |
241 { |
242 { |
242 break; |
243 break; |
243 } |
244 } |
244 case TFSEventNewMail: |
245 case TFSEventNewMail: |
245 { |
246 { |
246 // If this is a preinstalled version and we receive a new mail we |
247 // If this is a pre-installed version and we receive a new mail we |
247 // update the current status of the HS here before passing |
248 // update the current status of the HS here before passing |
248 // the events to handlers so they don't have to do it. If they |
249 // the events to handlers so they don't have to do it. If they |
249 // do it, it is done several times which is not desired. |
250 // do it, it is done several times which is not desired. |
250 // The drawback is that by doing it here we might also do it |
251 // The drawback is that by doing it here we might also do it |
251 // in situations where the handlers would actually not need it. |
252 // in situations where the handlers would actually not need it. |
252 // Possibly the best solution would be to initialise the |
253 // Possibly the best solution would be to initialize the |
253 // iHSConnection once and then let it observe for changes in |
254 // iHSConnection once and then let it observe for changes in |
254 // central repository. Currently that solution is not implemented |
255 // central repository. Currently that solution is not implemented |
255 // as it would require more time to implement. |
256 // as it would require more time to implement. |
256 } |
257 } |
257 default: |
258 default: |
267 |
268 |
268 while ( handlerIndex < handlerCount ) |
269 while ( handlerIndex < handlerCount ) |
269 { |
270 { |
270 // Event is passed to each handler. If one fails the |
271 // Event is passed to each handler. If one fails the |
271 // event is still passed to others as they are not |
272 // event is still passed to others as they are not |
272 // necessarily dependant on the same services. This way |
273 // necessarily dependent on the same services. This way |
273 // If one fails the others can still succeed. |
274 // If one fails the others can still succeed. |
274 TRAP_IGNORE( |
275 TRAP_IGNORE( |
275 iHandlers[handlerIndex]->EventL( aEvent, |
276 iHandlers[handlerIndex]->EventL( aEvent, |
276 aMailbox, |
277 aMailbox, |
277 aParam1, |
278 aParam1, |
337 CFsEmailAuthenticationDialog* dialog = CFsEmailAuthenticationDialog::NewL( aStatus, aMailboxName, aPassword ); |
338 CFsEmailAuthenticationDialog* dialog = CFsEmailAuthenticationDialog::NewL( aStatus, aMailboxName, aPassword ); |
338 TRAPD( err, dialog->ExecuteLD( R_FS_MSERVER_DIALOG_AUTHENTICATION ) ); |
339 TRAPD( err, dialog->ExecuteLD( R_FS_MSERVER_DIALOG_AUTHENTICATION ) ); |
339 return err; |
340 return err; |
340 } |
341 } |
341 |
342 |
|
343 |
|
344 TFSFolderType CFSNotificationHandlerMgr::GetFolderTypeL( TFSMailMsgId& aMailbox, TFSMailMsgId* parentFolderId ) |
|
345 { |
|
346 TFSFolderType folderType( EFSInbox ); |
|
347 if ( parentFolderId ) |
|
348 { |
|
349 if ( (*parentFolderId) == iPreviousParentFolderId && |
|
350 aMailbox == iPreviousMailbox ) |
|
351 { |
|
352 // we assume that folder with some id does not change |
|
353 // its type during mail synchronization |
|
354 folderType = iPreviousParentFolderType; |
|
355 } |
|
356 else |
|
357 { |
|
358 iPreviousParentFolderId = (*parentFolderId); |
|
359 // Get the parent folder object |
|
360 CFSMailFolder* parentFolder = iMailClient->GetFolderByUidL( |
|
361 aMailbox, *parentFolderId ); |
|
362 if ( parentFolder ) |
|
363 { |
|
364 folderType = parentFolder->GetFolderType(); |
|
365 iPreviousParentFolderType = folderType; |
|
366 delete parentFolder; |
|
367 parentFolder = NULL; |
|
368 } |
|
369 } |
|
370 } |
|
371 |
|
372 return folderType; |
|
373 } |
342 // --------------------------------------------------------------------------- |
374 // --------------------------------------------------------------------------- |
343 // |
375 // |
344 // --------------------------------------------------------------------------- |
376 // --------------------------------------------------------------------------- |
345 // |
377 // |
346 void CFSNotificationHandlerMgr::StartObservingL() |
378 void CFSNotificationHandlerMgr::StartObservingL() |
417 // --------------------------------------------------------------------------- |
449 // --------------------------------------------------------------------------- |
418 // Function cleans up downloaded files of mailboxes if disk space is low |
450 // Function cleans up downloaded files of mailboxes if disk space is low |
419 // --------------------------------------------------------------------------- |
451 // --------------------------------------------------------------------------- |
420 // |
452 // |
421 void CFSNotificationHandlerMgr::CleanTempFilesIfNeededL() |
453 void CFSNotificationHandlerMgr::CleanTempFilesIfNeededL() |
422 { |
454 { |
423 FUNC_LOG; |
455 FUNC_LOG; |
424 RFs fsSession; |
456 RFs fsSession; |
425 User::LeaveIfError(fsSession.Connect()); |
457 User::LeaveIfError(fsSession.Connect()); |
426 CleanupClosePushL(fsSession); |
458 CleanupClosePushL(fsSession); |
427 // Check whether disk space is below 3MB, in that case start cleaning up |
459 // Check whether disk space is below 3MB, in that case start cleaning up |
428 // downloaded attachments from mailboxes. |
460 // downloaded attachments from mailboxes. |
429 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fsSession, 3*KMegaByte, EDriveC ) ) |
461 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fsSession, 3*KMegaByte, EDriveC ) ) |
430 { |
462 { |
431 RPointerArray<CFSMailBox> mailBoxList; |
463 RPointerArray<CFSMailBox> mailBoxList; |
432 // Null id given as a plugin id. mailboxes of all plugins retrieved. |
464 // Null id given as a plugin id. mailboxes of all plugins retrieved. |
433 // Notice that ownership of the mailboxes is not passed to here. |
465 // Notice that ownership of the mailboxes is not passed to here. |
434 iMailClient->ListMailBoxes( TFSMailMsgId(), mailBoxList ); |
466 iMailClient->ListMailBoxes( TFSMailMsgId(), mailBoxList ); |
435 for ( TInt i = 0 ; i < mailBoxList.Count() ; ++i ) |
467 for ( TInt i = 0 ; i < mailBoxList.Count() ; ++i ) |
436 { |
468 { |
437 TRAP_IGNORE( mailBoxList[i]->RemoveDownLoadedAttachmentsL() ); |
469 TRAP_IGNORE( mailBoxList[i]->RemoveDownLoadedAttachmentsL() ); |
438 } |
470 } |
439 mailBoxList.ResetAndDestroy(); |
471 mailBoxList.ResetAndDestroy(); |
440 } |
472 } |
441 CleanupStack::PopAndDestroy( &fsSession ); |
473 CleanupStack::PopAndDestroy( &fsSession ); |
442 } |
474 } |
443 |
475 |
444 |
476 |
445 //<cmail> |
477 //<cmail> |
446 // --------------------------------------------------------------------------- |
478 // --------------------------------------------------------------------------- |
447 // CFSNotificationHandlerMgr::SendAppUiToBackground() |
479 // CFSNotificationHandlerMgr::SendAppUiToBackground() |