brandingserver/BSClient/cbsbrandobserver.cpp
author hgs
Sun, 11 Apr 2010 15:33:49 +0530
changeset 31 9dbc70490d9a
permissions -rw-r--r--
201014
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  cbsbrandobserver.cpp
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
//  INCLUDE FILES
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "cbsbrandobserver.h"
hgs
parents:
diff changeset
    21
#include <mbsbrandchangeobserver.h>
hgs
parents:
diff changeset
    22
#include <mbsbackuprestorestateobserver.h>
hgs
parents:
diff changeset
    23
#include "mbsbrandobserverregistrar.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
CBSBrandObserver* CBSBrandObserver::NewL( MBSBrandChangeObserver* aObserver,
hgs
parents:
diff changeset
    26
										  MBSBackupRestoreStateObserver* aBackupObserver,
hgs
parents:
diff changeset
    27
									   	  MBSBrandObserverRegistrar* aRegistrar )
hgs
parents:
diff changeset
    28
    {
hgs
parents:
diff changeset
    29
	CBSBrandObserver* self = new ( ELeave ) CBSBrandObserver( aObserver, aBackupObserver, aRegistrar ) ;
hgs
parents:
diff changeset
    30
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    31
    self->ConstructL();
hgs
parents:
diff changeset
    32
    CleanupStack::Pop( self );  //self
hgs
parents:
diff changeset
    33
    return self;
hgs
parents:
diff changeset
    34
    }
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
void CBSBrandObserver::ConstructL()
hgs
parents:
diff changeset
    38
    {
hgs
parents:
diff changeset
    39
    iContinueBackupStateObserving = ETrue ;
hgs
parents:
diff changeset
    40
    iContinueDataUpdateObserving = ETrue ;
hgs
parents:
diff changeset
    41
    
hgs
parents:
diff changeset
    42
	CActiveScheduler::Add( this );
hgs
parents:
diff changeset
    43
	iRegistrar->RegisterObserverToServerL( iStatus );
hgs
parents:
diff changeset
    44
	SetActive();
hgs
parents:
diff changeset
    45
    }
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
CBSBrandObserver::~CBSBrandObserver()
hgs
parents:
diff changeset
    49
    {
hgs
parents:
diff changeset
    50
    Cancel();
hgs
parents:
diff changeset
    51
    }
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
CBSBrandObserver::CBSBrandObserver( MBSBrandChangeObserver* aObserver,
hgs
parents:
diff changeset
    55
									MBSBackupRestoreStateObserver* aBackupObserver,
hgs
parents:
diff changeset
    56
									MBSBrandObserverRegistrar* aRegistrar )
hgs
parents:
diff changeset
    57
: CActive( CActive::EPriorityIdle ), iObserver( aObserver ), iBackupObserver( aBackupObserver ),
hgs
parents:
diff changeset
    58
									 iRegistrar( aRegistrar )
hgs
parents:
diff changeset
    59
	{
hgs
parents:
diff changeset
    60
	}
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
void CBSBrandObserver::RunL()
hgs
parents:
diff changeset
    63
	{
hgs
parents:
diff changeset
    64
	
hgs
parents:
diff changeset
    65
	// Pankaj - chk for what has changed..
hgs
parents:
diff changeset
    66
	TInt isBackupRestore = iRegistrar->GetBackupRestoreL() ;
hgs
parents:
diff changeset
    67
	if(isBackupRestore)
hgs
parents:
diff changeset
    68
		{
hgs
parents:
diff changeset
    69
		// if client donot want to listen backup state event any more donot call its observer..
hgs
parents:
diff changeset
    70
		if(iBackupObserver && iContinueBackupStateObserving)
hgs
parents:
diff changeset
    71
			{
hgs
parents:
diff changeset
    72
			TInt activeState = iRegistrar->GetBackupStateL() ;
hgs
parents:
diff changeset
    73
			iContinueBackupStateObserving = iBackupObserver->BackupRestoreActivated(activeState) ;
hgs
parents:
diff changeset
    74
			}
hgs
parents:
diff changeset
    75
		}
hgs
parents:
diff changeset
    76
	else
hgs
parents:
diff changeset
    77
		{
hgs
parents:
diff changeset
    78
		// if client donot want to listen update data event any more donot call its observer..
hgs
parents:
diff changeset
    79
		if(iObserver && iContinueDataUpdateObserving)
hgs
parents:
diff changeset
    80
			{
hgs
parents:
diff changeset
    81
			TInt newVersion = iRegistrar->GetNewVersionL();
hgs
parents:
diff changeset
    82
			iContinueDataUpdateObserving = iObserver->BrandUpdateAvailable( newVersion ) ;
hgs
parents:
diff changeset
    83
			}
hgs
parents:
diff changeset
    84
		}
hgs
parents:
diff changeset
    85
		
hgs
parents:
diff changeset
    86
	if(iContinueBackupStateObserving || iContinueDataUpdateObserving)
hgs
parents:
diff changeset
    87
		{
hgs
parents:
diff changeset
    88
		iRegistrar->RegisterObserverToServerL( iStatus );
hgs
parents:
diff changeset
    89
		SetActive();
hgs
parents:
diff changeset
    90
		}
hgs
parents:
diff changeset
    91
	}
hgs
parents:
diff changeset
    92
	
hgs
parents:
diff changeset
    93
void CBSBrandObserver::DoCancel()
hgs
parents:
diff changeset
    94
	{
hgs
parents:
diff changeset
    95
	
hgs
parents:
diff changeset
    96
	}
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
hgs
parents:
diff changeset
    99
//  END OF FILE