14 * Description: |
14 * Description: |
15 * Main plugin class |
15 * Main plugin class |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 |
19 #include "ipssosaopluginheaders.h" |
20 #include "emailtrace.h" |
|
21 #include <AlwaysOnlineManagerClient.h> |
|
22 #include <SendUiConsts.h> |
|
23 #include <msvids.h> |
|
24 #include <msvuids.h> |
|
25 |
|
26 // becuase of RD_IPS_AO_PLUGIN flag, can be removed |
|
27 // when flag is removed |
|
28 #include "ipsplgsosbaseplugin.hrh" |
|
29 |
|
30 #include "IpsSosAOImapPopLogic.h" |
|
31 #include "IpsSosAOMboxLogic.h" |
|
32 #include "IpsSosAOEMNResolver.h" |
|
33 #include "ipssetdataapi.h" |
|
34 |
|
35 |
|
36 |
|
37 #include "ipsplgcommon.h" |
|
38 |
20 |
39 //const TInt KAOSmtpStartDelaySeconds = 310; |
21 //const TInt KAOSmtpStartDelaySeconds = 310; |
40 const TInt KIpsSosAOImapPopLogicDefGra = 1; |
22 const TInt KIpsSosAOImapPopLogicDefGra = 1; |
41 //const TInt KIpsSosAoImapPopLogicEventGra = 2; |
23 //const TInt KIpsSosAoImapPopLogicEventGra = 2; |
42 |
24 |
82 // |
66 // |
83 void CIpsSosAOImapPopLogic::ConstructL() |
67 void CIpsSosAOImapPopLogic::ConstructL() |
84 { |
68 { |
85 FUNC_LOG; |
69 FUNC_LOG; |
86 iEmnResolver = CIpsSosAOEMNResolver::NewL(); |
70 iEmnResolver = CIpsSosAOEMNResolver::NewL(); |
87 iDataApi = CIpsSetDataApi::NewL( iSession ); |
71 //<QMail> |
|
72 |
|
73 //</QMail> |
88 } |
74 } |
89 |
75 |
90 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
91 // ---------------------------------------------------------------------------- |
77 // ---------------------------------------------------------------------------- |
92 // |
78 // |
214 case EAOManagerAOSchdulerError: |
200 case EAOManagerAOSchdulerError: |
215 default: |
201 default: |
216 result = KErrNotSupported; |
202 result = KErrNotSupported; |
217 break; |
203 break; |
218 } |
204 } |
219 |
|
220 |
|
221 // </cmail> |
|
222 return result; |
205 return result; |
223 } |
206 } |
224 |
207 |
225 // ---------------------------------------------------------------------------- |
208 // ---------------------------------------------------------------------------- |
226 // ---------------------------------------------------------------------------- |
209 // ---------------------------------------------------------------------------- |
227 // |
210 // |
228 void CIpsSosAOImapPopLogic::HandleMsvSessionEventL( |
211 void CIpsSosAOImapPopLogic::HandleMsvSessionEventL( |
229 // <cmail> RD_IPS_AO_PLUGIN flag removed |
|
230 MMsvSessionObserver::TMsvSessionEvent aEvent, |
212 MMsvSessionObserver::TMsvSessionEvent aEvent, |
231 TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/ ) |
213 TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/ ) |
232 { |
214 { |
233 FUNC_LOG; |
215 FUNC_LOG; |
234 switch( aEvent ) |
216 switch( aEvent ) |
236 case MMsvSessionObserver::EMsvEntriesCreated: |
218 case MMsvSessionObserver::EMsvEntriesCreated: |
237 break; |
219 break; |
238 case MMsvSessionObserver::EMsvEntriesChanged: |
220 case MMsvSessionObserver::EMsvEntriesChanged: |
239 { |
221 { |
240 TMsvId parent = (*(TMsvId*) (aArg2)); |
222 TMsvId parent = (*(TMsvId*) (aArg2)); |
241 //we check that parent is the root. if not, it cannot be a |
223 //we check that parent is the root. if not, it cannot be an |
242 //event from service, thus can't be from connection change.. |
224 //event from service, thus can't be from connection change.. |
243 if ( parent == KMsvRootIndexEntryId ) |
225 if ( parent == KMsvRootIndexEntryId ) |
244 { |
226 { |
245 const CMsvEntrySelection* selection = |
227 const CMsvEntrySelection* selection = |
246 static_cast<CMsvEntrySelection*>( aArg1 ); |
228 static_cast<CMsvEntrySelection*>( aArg1 ); |
260 } |
242 } |
261 } |
243 } |
262 } |
244 } |
263 break; |
245 break; |
264 case MMsvSessionObserver::EMsvEntriesDeleted: |
246 case MMsvSessionObserver::EMsvEntriesDeleted: |
265 // NOTE: if mailbox is deleted somewhere else than ips plugin |
247 { |
266 // in here need to put logic for removing corresponding |
248 TMsvId parent = (*(TMsvId*) (aArg2)); |
267 // mailboxlogic object |
249 //we check that parent is the root. if not, it cannot be an |
|
250 //event indicating deleted mailbox entry |
|
251 if ( parent == KMsvRootIndexEntryId ) |
|
252 { |
|
253 RemoveOrphanLogicsL(); |
|
254 } |
|
255 } |
|
256 break; |
268 case MMsvSessionObserver::EMsvEntriesMoved: |
257 case MMsvSessionObserver::EMsvEntriesMoved: |
269 default: |
258 default: |
270 break; |
259 break; |
271 }; |
260 }; |
272 // </cmail> |
|
273 } |
261 } |
274 |
262 |
275 // ---------------------------------------------------------------------------- |
263 // ---------------------------------------------------------------------------- |
276 // ---------------------------------------------------------------------------- |
264 // ---------------------------------------------------------------------------- |
277 // |
265 // |
335 elements.mailbox, iMailboxLogics ); |
323 elements.mailbox, iMailboxLogics ); |
336 |
324 |
337 if ( index != KErrNotFound ) |
325 if ( index != KErrNotFound ) |
338 { |
326 { |
339 CIpsSosAOMBoxLogic* logic = iMailboxLogics[index]; |
327 CIpsSosAOMBoxLogic* logic = iMailboxLogics[index]; |
340 //<cmail> |
328 |
341 if ( !logic->FirstEMNReceived() ) |
329 if ( !logic->FirstEMNReceived() ) |
342 { |
330 { |
343 logic->SetFirstEMNReceived(); |
331 logic->SetFirstEMNReceived(); |
344 } |
332 } |
345 if ( !iNoNWOpsAllowed && |
333 if ( !iNoNWOpsAllowed && |
346 !logic->IsMailboxRoamingStoppedL() ) |
334 !logic->IsMailboxRoamingStoppedL() ) |
347 //</cmail> |
|
348 { |
335 { |
349 SendCommandToSpecificMailboxL( |
336 SendCommandToSpecificMailboxL( |
350 logic->GetMailboxId(), // faulty CS warning |
337 logic->GetMailboxId(), // faulty CS warning |
351 CIpsSosAOMBoxLogic::ECommandStartSync ); |
338 CIpsSosAOMBoxLogic::ECommandStartSync ); |
352 } |
339 } |
353 else |
340 else |
354 { |
341 { |
355 //<cmail> |
342 logic->SetEmnReceivedFlagL( ETrue ); |
356 logic->SetEmnReceivedFlagL( ETrue ); |
|
357 //</cmail> |
|
358 } |
343 } |
359 logic = NULL; |
344 logic = NULL; |
360 } |
345 } |
361 /*<cmail> |
346 |
362 else |
|
363 { |
|
364 } |
|
365 </cmail>*/ |
|
366 } |
347 } |
367 } |
348 } |
368 |
349 |
369 // ---------------------------------------------------------------------------- |
350 // ---------------------------------------------------------------------------- |
370 // ---------------------------------------------------------------------------- |
351 // ---------------------------------------------------------------------------- |
403 if ( iMailboxLogics[j]->GetMailboxId() == mboxId ) |
384 if ( iMailboxLogics[j]->GetMailboxId() == mboxId ) |
404 { |
385 { |
405 found = ETrue; |
386 found = ETrue; |
406 } |
387 } |
407 } |
388 } |
|
389 //<QMail> |
|
390 CIpsSosAOSettingsHandler* settings = |
|
391 CIpsSosAOSettingsHandler::NewL(iSession, mboxId); |
|
392 CleanupStack::PushL(settings); |
|
393 |
|
394 if ( !found && ( settings->AlwaysOnlineState() |
|
395 != IpsServices::EMailAoOff || |
|
396 settings->EmailNotificationState() |
|
397 != IpsServices::EMailEmnOff || |
|
398 !settings->FirstEmnReceived() ) |
|
399 ) |
|
400 { |
|
401 CIpsSosAOMBoxLogic* newLogic = CIpsSosAOMBoxLogic::NewL( |
|
402 iSession, mboxId ); |
|
403 CleanupStack::PushL( newLogic ); |
|
404 iMailboxLogics.AppendL( newLogic ); |
|
405 CleanupStack::Pop( newLogic ); |
|
406 } |
|
407 else if ( found && settings->AlwaysOnlineState() |
|
408 == IpsServices::EMailAoOff && |
|
409 settings->EmailNotificationState() |
|
410 == IpsServices::EMailEmnOff && |
|
411 settings->FirstEmnReceived() ) |
|
412 { |
|
413 StopAndRemoveMailboxL( mboxId ); |
|
414 } |
408 |
415 |
409 CIpsSetDataExtension* extSet = CIpsSetDataExtension::NewLC(); |
416 CleanupStack::PopAndDestroy(settings); |
410 TRAPD( error, iDataApi->LoadExtendedSettingsL( |
417 //</QMail> |
411 mboxId, *extSet ) ); |
418 } |
412 if ( error == KErrNone ) |
419 |
413 { |
420 //finally, check for orphans ( mailbox has been deleted ) |
414 if ( !found && ( extSet->AlwaysOnlineState() != EMailAoOff || |
421 RemoveOrphanLogicsL(); |
415 extSet->EmailNotificationState() != EMailEmnOff || |
|
416 !extSet->FirstEmnReceived() ) |
|
417 ) |
|
418 { |
|
419 CIpsSosAOMBoxLogic* newLogic = CIpsSosAOMBoxLogic::NewL( |
|
420 iSession, mboxId ); |
|
421 CleanupStack::PushL( newLogic ); |
|
422 iMailboxLogics.AppendL( newLogic ); |
|
423 CleanupStack::Pop( newLogic ); |
|
424 } |
|
425 else if ( found && extSet->AlwaysOnlineState() == EMailAoOff && |
|
426 extSet->EmailNotificationState() == EMailEmnOff && |
|
427 extSet->FirstEmnReceived() ) |
|
428 { |
|
429 StopAndRemoveMailboxL( mboxId ); |
|
430 } |
|
431 } |
|
432 CleanupStack::PopAndDestroy( extSet ); |
|
433 } |
|
434 } |
422 } |
435 |
423 |
436 // ---------------------------------------------------------------------------- |
424 // ---------------------------------------------------------------------------- |
437 // ---------------------------------------------------------------------------- |
425 // ---------------------------------------------------------------------------- |
438 // |
426 // |
493 } |
481 } |
494 } |
482 } |
495 return index; |
483 return index; |
496 } |
484 } |
497 |
485 |
|
486 // ---------------------------------------------------------------------------- |
|
487 // ---------------------------------------------------------------------------- |
|
488 // |
|
489 void CIpsSosAOImapPopLogic::RemoveOrphanLogicsL() |
|
490 { |
|
491 CMsvEntry* cEntry = iSession.GetEntryL( KMsvRootIndexEntryId ); |
|
492 CleanupStack::PushL( cEntry ); |
|
493 |
|
494 CMsvEntrySelection* popEntries = cEntry->ChildrenWithMtmL( KSenduiMtmPop3Uid ); |
|
495 CleanupStack::PushL( popEntries ); |
|
496 |
|
497 CMsvEntrySelection* imapEntries = cEntry->ChildrenWithMtmL( KSenduiMtmImap4Uid ); |
|
498 CleanupStack::PushL( imapEntries ); |
|
499 |
|
500 |
|
501 TInt count = iMailboxLogics.Count(); |
|
502 |
|
503 for(TInt i=count-1; i>-1;i--) |
|
504 { |
|
505 if( popEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound && |
|
506 imapEntries->Find(iMailboxLogics[i]->GetMailboxId()) == KErrNotFound) |
|
507 { |
|
508 StopAndRemoveMailboxL( iMailboxLogics[i]->GetMailboxId() ); |
|
509 } |
|
510 } |
|
511 |
|
512 CleanupStack::PopAndDestroy( 3, cEntry ); |
|
513 } |
498 // End of file |
514 // End of file |
499 |
515 |