brandingserver/BSClient/cbsbrandobserver.cpp
changeset 31 9dbc70490d9a
equal deleted inserted replaced
30:1fa9b890f29c 31:9dbc70490d9a
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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:  cbsbrandobserver.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 //  INCLUDE FILES
       
    19 
       
    20 #include "cbsbrandobserver.h"
       
    21 #include <mbsbrandchangeobserver.h>
       
    22 #include <mbsbackuprestorestateobserver.h>
       
    23 #include "mbsbrandobserverregistrar.h"
       
    24 
       
    25 CBSBrandObserver* CBSBrandObserver::NewL( MBSBrandChangeObserver* aObserver,
       
    26 										  MBSBackupRestoreStateObserver* aBackupObserver,
       
    27 									   	  MBSBrandObserverRegistrar* aRegistrar )
       
    28     {
       
    29 	CBSBrandObserver* self = new ( ELeave ) CBSBrandObserver( aObserver, aBackupObserver, aRegistrar ) ;
       
    30     CleanupStack::PushL( self );
       
    31     self->ConstructL();
       
    32     CleanupStack::Pop( self );  //self
       
    33     return self;
       
    34     }
       
    35 
       
    36 
       
    37 void CBSBrandObserver::ConstructL()
       
    38     {
       
    39     iContinueBackupStateObserving = ETrue ;
       
    40     iContinueDataUpdateObserving = ETrue ;
       
    41     
       
    42 	CActiveScheduler::Add( this );
       
    43 	iRegistrar->RegisterObserverToServerL( iStatus );
       
    44 	SetActive();
       
    45     }
       
    46 
       
    47 
       
    48 CBSBrandObserver::~CBSBrandObserver()
       
    49     {
       
    50     Cancel();
       
    51     }
       
    52 
       
    53 
       
    54 CBSBrandObserver::CBSBrandObserver( MBSBrandChangeObserver* aObserver,
       
    55 									MBSBackupRestoreStateObserver* aBackupObserver,
       
    56 									MBSBrandObserverRegistrar* aRegistrar )
       
    57 : CActive( CActive::EPriorityIdle ), iObserver( aObserver ), iBackupObserver( aBackupObserver ),
       
    58 									 iRegistrar( aRegistrar )
       
    59 	{
       
    60 	}
       
    61 
       
    62 void CBSBrandObserver::RunL()
       
    63 	{
       
    64 	
       
    65 	// Pankaj - chk for what has changed..
       
    66 	TInt isBackupRestore = iRegistrar->GetBackupRestoreL() ;
       
    67 	if(isBackupRestore)
       
    68 		{
       
    69 		// if client donot want to listen backup state event any more donot call its observer..
       
    70 		if(iBackupObserver && iContinueBackupStateObserving)
       
    71 			{
       
    72 			TInt activeState = iRegistrar->GetBackupStateL() ;
       
    73 			iContinueBackupStateObserving = iBackupObserver->BackupRestoreActivated(activeState) ;
       
    74 			}
       
    75 		}
       
    76 	else
       
    77 		{
       
    78 		// if client donot want to listen update data event any more donot call its observer..
       
    79 		if(iObserver && iContinueDataUpdateObserving)
       
    80 			{
       
    81 			TInt newVersion = iRegistrar->GetNewVersionL();
       
    82 			iContinueDataUpdateObserving = iObserver->BrandUpdateAvailable( newVersion ) ;
       
    83 			}
       
    84 		}
       
    85 		
       
    86 	if(iContinueBackupStateObserving || iContinueDataUpdateObserving)
       
    87 		{
       
    88 		iRegistrar->RegisterObserverToServerL( iStatus );
       
    89 		SetActive();
       
    90 		}
       
    91 	}
       
    92 	
       
    93 void CBSBrandObserver::DoCancel()
       
    94 	{
       
    95 	
       
    96 	}
       
    97 
       
    98 
       
    99 //  END OF FILE