ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp
changeset 23 2dc6caa42ec3
parent 20 ecc8def7944a
child 51 d845db10c0d4
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    86     TMsvEntry tEntry;
    86     TMsvEntry tEntry;
    87     TMsvId service;
    87     TMsvId service;
    88     
    88     
    89     TInt err = iSession.GetEntry( aMailboxId.Id(), service, tEntry );
    89     TInt err = iSession.GetEntry( aMailboxId.Id(), service, tEntry );
    90 
    90 
    91     if ( err != KErrNone || !tEntry.Connected() || iOperationsRef.Count() == 0 )
    91     if ( err != KErrNone || iOperationsRef.Count() == 0 )
    92         {
    92         {
    93         // no sync ongoing if not connected
       
    94         return Idle;
    93         return Idle;
       
    94         }
       
    95 
       
    96     // If the mailbox is not online but it has some connection operation
       
    97     // already running, it means that it will be synchronized when the mailbox
       
    98     // goes online. So we need to check is there any connection operation
       
    99     // ongoing and return StartingSync in that case.
       
   100     if( !tEntry.Connected() )
       
   101         {
       
   102         if( ConnOpRunning( aMailboxId ) )
       
   103             {
       
   104             // Some connection operation already processing, so the sync
       
   105             // will start soon
       
   106             return StartingSync;
       
   107             }
       
   108         else
       
   109             {
       
   110             // no sync ongoing if not connected and no connection operations
       
   111             // started
       
   112             return Idle;
       
   113             }
    95         }
   114         }
    96 
   115 
    97 #ifndef RD_101_EMAIL    
   116 #ifndef RD_101_EMAIL    
    98 // <cmail> RD_IPS_AO_PLUGIN flaf removed
   117 // <cmail> RD_IPS_AO_PLUGIN flaf removed
    99     RAlwaysOnlineClientSession aosession;
   118     RAlwaysOnlineClientSession aosession;
   123    for ( TInt i = 0; i < iOperationsRef.Count(); i++ )
   142    for ( TInt i = 0; i < iOperationsRef.Count(); i++ )
   124        {
   143        {
   125        const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation();
   144        const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation();
   126        
   145        
   127        if ( baseOp && baseOp->FSMailboxId() == aMailboxId &&
   146        if ( baseOp && baseOp->FSMailboxId() == aMailboxId &&
   128               ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp
   147             ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp ||
   129                || baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp
   148               baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp ||
   130                || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) )
   149               baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) )
   131            {
   150            {
   132            // check syncing mailbox, to prevent sync icon running 
   151            // Due to timing problems we might in some rare cases report
   133            // all the time
   152            // EmailSyncing here even if the actual syncing is already
   134            if ( FindMailbox( aMailboxId.Id() ) == KIpsSosEmailSyncCompleted )
   153            // finsihed, because the operation is removed from the array
   135                {
   154            // with an async function call. HandlePropertyEventL events
   136                return Idle;
   155            // seem to be even more unreliable (sync start event comes with
   137                }
   156            // big delay), so we can't trust those either. Some kind of
   138            else
   157            // redesign is needed to get this sync state query more reliable.
   139                {
   158            return EmailSyncing;
   140                return EmailSyncing;
       
   141                }
       
   142            }
   159            }
   143        }
   160        }
   144     return Idle;
   161     return Idle;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // ---------------------------------------------------------------------------
       
   166 TBool CIpsPlgSyncStateHandler::ConnOpRunning( const TFSMailMsgId& aMailBoxId  )
       
   167     {
       
   168     FUNC_LOG;
       
   169     for ( TInt i = 0; i < iOperationsRef.Count(); i++ )
       
   170        {
       
   171        const CIpsPlgBaseOperation* baseOp = iOperationsRef[i]->BaseOperation();
       
   172 
       
   173        if ( baseOp && baseOp->FSMailboxId() == aMailBoxId &&
       
   174               ( baseOp->IpsOpType() == EIpsOpTypePop3SyncOp
       
   175                || baseOp->IpsOpType() == EIpsOpTypeImap4SyncOp
       
   176                || baseOp->IpsOpType() == EIpsOpTypeOnlineOp
       
   177                || baseOp->IpsOpType() == EIpsOpTypeImap4PopulateOp ) )
       
   178            {
       
   179            // Due to timing problems we might in some rare cases report
       
   180            // EmailSyncing here even if the actual syncing is already
       
   181            // finsihed, because the operation is removed from the array
       
   182            // with an async function call. HandlePropertyEventL events
       
   183            // seem to be even more unreliable (sync start event comes with
       
   184            // big delay), so we can't trust those either. Some kind of
       
   185            // redesign is needed to get this sync state query more reliable.
       
   186            return ETrue;
       
   187            }
       
   188        }
       
   189     return EFalse;
   145     }
   190     }
   146 
   191 
   147 // ---------------------------------------------------------------------------
   192 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------    
   193 // ---------------------------------------------------------------------------    
   149 TInt CIpsPlgSyncStateHandler::FindSyncingMailbox( TMsvId aMailbox )
   194 TInt CIpsPlgSyncStateHandler::FindSyncingMailbox( TMsvId aMailbox )
   257         CMsvSession& /*aSession*/, TMsvId /*aService*/ )
   302         CMsvSession& /*aSession*/, TMsvId /*aService*/ )
   258     {
   303     {
   259     FUNC_LOG;
   304     FUNC_LOG;
   260     TTime now;
   305     TTime now;
   261     now.HomeTime();
   306     now.HomeTime();
       
   307 // <qmail>
   262     //CIpsSetDataExtension* extendedSettings = CIpsSetDataExtension::NewLC();
   308     //CIpsSetDataExtension* extendedSettings = CIpsSetDataExtension::NewLC();
   263     //CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( aSession );
   309     //CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( aSession );
   264     //CleanupStack::PushL( dataApi );
   310     //CleanupStack::PushL( dataApi );
   265     //dataApi->LoadExtendedSettingsL( aService, *extendedSettings );
   311     //dataApi->LoadExtendedSettingsL( aService, *extendedSettings );
   266     //TAOInfo info;
   312     //TAOInfo info;
   269     //extendedSettings->SetLastUpdateInfo( info );
   315     //extendedSettings->SetLastUpdateInfo( info );
   270     // clear flag
   316     // clear flag
   271     //extendedSettings->SetEmnReceivedButNotSyncedFlag( EFalse );
   317     //extendedSettings->SetEmnReceivedButNotSyncedFlag( EFalse );
   272     //dataApi->SaveExtendedSettingsL( *extendedSettings );
   318     //dataApi->SaveExtendedSettingsL( *extendedSettings );
   273     //CleanupStack::PopAndDestroy( 2, extendedSettings );
   319     //CleanupStack::PopAndDestroy( 2, extendedSettings );
       
   320 // </qmail>
   274     }
   321     }
   275 
   322 
   276 
   323 
   277 // End of file
   324 // End of file
   278 
   325