controlpanelui/src/tonefetcher/tonefetcherengine/private/symbian/toneselectionengine_p.cpp
changeset 24 f5dfdd5e4a1b
parent 14 23411a3be0db
equal deleted inserted replaced
17:4a9568303383 24:f5dfdd5e4a1b
    21 #include <bautils.h>
    21 #include <bautils.h>
    22 #include "tonepreviewprivate.h"
    22 #include "tonepreviewprivate.h"
    23 #include "tonefetcherengine.h"
    23 #include "tonefetcherengine.h"
    24 #include <centralrepository.h>
    24 #include <centralrepository.h>
    25 #include <ProfileEngineDomainCRKeys.h>
    25 #include <ProfileEngineDomainCRKeys.h>
       
    26 #include <cplogger.h>
       
    27 
       
    28 
       
    29 CTimeOutTimer* CTimeOutTimer::NewL(ToneSelectionEnginePrivate& aObserver)
       
    30     {
       
    31     CTimeOutTimer* self = CTimeOutTimer::NewLC(aObserver);
       
    32     CleanupStack::Pop(self);
       
    33     return self;
       
    34     }
       
    35 
       
    36  
       
    37 
       
    38 CTimeOutTimer* CTimeOutTimer::NewLC(ToneSelectionEnginePrivate& aObserver)
       
    39     {
       
    40     CTimeOutTimer* self = new (ELeave) CTimeOutTimer(aObserver);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     return self;
       
    44     } 
       
    45 
       
    46  
       
    47 
       
    48 CTimeOutTimer::CTimeOutTimer(ToneSelectionEnginePrivate& aObserver)
       
    49     : CTimer(EPriorityStandard),
       
    50       iObserver( aObserver )
       
    51     { 
       
    52 
       
    53     }
       
    54 
       
    55  
       
    56 
       
    57 CTimeOutTimer::~CTimeOutTimer()
       
    58     {
       
    59     Cancel();
       
    60     }
       
    61 
       
    62  
       
    63 
       
    64 void CTimeOutTimer::ConstructL()
       
    65     {
       
    66     CTimer::ConstructL();
       
    67     CActiveScheduler::Add(this);
       
    68     }
       
    69 
       
    70  
       
    71 
       
    72 void CTimeOutTimer::RunL()
       
    73     {
       
    74     iObserver.ChangeObject();
       
    75     }
    26 
    76 
    27 ToneSelectionEnginePrivate::ToneSelectionEnginePrivate( ToneFetcherEngine *engine ) : mServiceEngine( engine )
    77 ToneSelectionEnginePrivate::ToneSelectionEnginePrivate( ToneFetcherEngine *engine ) : mServiceEngine( engine )
    28 
    78 
    29     {
    79     {
    30     iSession = CMdESession::NewL( *this );
    80     iSession = CMdESession::NewL( *this );
       
    81     
       
    82     iTimer = CTimeOutTimer::NewLC( *this );
       
    83     iContinue = EFalse;
       
    84     iTimerStarted = EFalse;
       
    85     iFreshing = EFalse;
       
    86     CleanupStack::Pop();
       
    87     
    31     
    88     
    32     }
    89     }
    33 
    90 
    34 ToneSelectionEnginePrivate::~ToneSelectionEnginePrivate()
    91 ToneSelectionEnginePrivate::~ToneSelectionEnginePrivate()
    35     {
    92     {
    76     {
   133     {
    77     }
   134     }
    78 
   135 
    79 void ToneSelectionEnginePrivate::HandleObjectNotification( CMdESession& /*aSession*/, 
   136 void ToneSelectionEnginePrivate::HandleObjectNotification( CMdESession& /*aSession*/, 
    80                                         TObserverNotificationType aType,
   137                                         TObserverNotificationType aType,
    81                                         const RArray<TItemId>& /*aObjectIdArray*/ )
   138                                         const RArray<TItemId>& aObjectIdArray )
    82     {    
   139     {    
    83     if ( aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove )
   140     if ( aObjectIdArray.Count() > 0 && ( aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove ) )
    84         {
   141         {
    85         emit notifyObjectChanged();
   142         CPFW_LOG("ToneSelectionEnginePrivate::HandleObjectNotification count = " + QVariant(aObjectIdArray.Count()).toString() + " type = " + QVariant(aType).toString());
       
   143         const TInt KOneSecond = 1000*1000;
       
   144         if ( !iFreshing )
       
   145             {
       
   146             emit notifyRefreshStart();
       
   147             iFreshing = ETrue;
       
   148             }
       
   149         if ( !iTimerStarted ) 
       
   150             {            
       
   151             iTimer->After( 5 * KOneSecond );
       
   152             iTimerStarted = ETrue;
       
   153             }        
       
   154         iContinue = ETrue;        
    86         }
   155         }
    87     }
   156     }
    88 
   157 
    89 void ToneSelectionEnginePrivate::AddObjectObserverL()
   158 void ToneSelectionEnginePrivate::AddObjectObserverL()
    90     {
   159     {
   101 void ToneSelectionEnginePrivate::HandleObjectPresentNotification( CMdESession& /*aSession*/, 
   170 void ToneSelectionEnginePrivate::HandleObjectPresentNotification( CMdESession& /*aSession*/, 
   102                          TBool /*aPresent*/, const RArray<TItemId>& aObjectIdArray )
   171                          TBool /*aPresent*/, const RArray<TItemId>& aObjectIdArray )
   103     {
   172     {
   104     if( aObjectIdArray.Count() > 0 )
   173     if( aObjectIdArray.Count() > 0 )
   105         {
   174         {
   106         emit notifyObjectChanged();
   175         const TInt KOneSecond = 1000*1000;
       
   176         if ( !iFreshing )
       
   177             {
       
   178             emit notifyRefreshStart();
       
   179             iFreshing = ETrue;
       
   180             }
       
   181         if ( !iTimerStarted ) 
       
   182             {            
       
   183             iTimer->After( 5 * KOneSecond );
       
   184             iTimerStarted = ETrue;
       
   185             }        
       
   186         iContinue = ETrue;       
   107         }    
   187         }    
   108     }
   188     }
   109 
   189 
   110 void ToneSelectionEnginePrivate::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
   190 void ToneSelectionEnginePrivate::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
   111     {
   191     {
   266             {
   346             {
   267             break;
   347             break;
   268             }
   348             }
   269         }
   349         }
   270 }
   350 }
       
   351 
       
   352 void ToneSelectionEnginePrivate::ChangeObject()
       
   353     {    
       
   354     if ( iTimerStarted )
       
   355         {
       
   356         emit notifyObjectChanged();
       
   357         iTimerStarted = EFalse;
       
   358         }
       
   359     
       
   360     if ( iContinue  )
       
   361         {
       
   362         iContinue = EFalse;
       
   363         iTimer->After( 5000*1000 );
       
   364         iTimerStarted = ETrue;
       
   365         }
       
   366     else 
       
   367         {
       
   368         if ( iFreshing )
       
   369             {
       
   370             emit notifyRefreshFinish();
       
   371             iFreshing = EFalse;
       
   372             }        
       
   373         }
       
   374     }
   271 // End of File
   375 // End of File
   272 
   376