⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hwrmtestapppropertyobserver.cpp

📁 平台symbian。 功能:获取系统信息。
💻 CPP
字号:
/*
* ==============================================================================
*  Name        : HWRMTestAppPropertyObserver.cpp
*  Part of     : HWRMTestApp
*  Interface   : 
*  Description : Hardware Resource Manager server Light common data object
*                implementation
*  Version     : 
*
*  Copyright (c) 2002-2006 Nokia Corporation.
*  This material, including documentation and any related 
*  computer programs, is protected by copyright controlled by 
*  Nokia Corporation. 
* ==============================================================================
*/

// INCLUDE FILES
#include <HWRMPowerStateSDKPSKeys.h>
#include "HWRMTestAppContainer.h"
#include "HWRMTestAppPropertyObserver.h"


// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::CHWRMTestAppPropertyObserver
// C++ constructor
// -----------------------------------------------------------------------------
//
CHWRMTestAppPropertyObserver::CHWRMTestAppPropertyObserver( 
        const TUid aUid, const TUint32 aKey,
        const CHWRMTestAppContainer* aAppContainer )
            : CActive(EPriority), iUid( aUid ),
              iKey( aKey ), iAppContainer( aAppContainer)
	{
	}

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CHWRMTestAppPropertyObserver* CHWRMTestAppPropertyObserver::NewL(
                                     const TUid aUid, const TUint32 aKey,
                                     const CHWRMTestAppContainer* aAppContainer )
	{
	CHWRMTestAppPropertyObserver* me=
	    new(ELeave) CHWRMTestAppPropertyObserver( aUid, aKey, aAppContainer );
	CleanupStack::PushL(me);
	me->ConstructL();
	CleanupStack::Pop(me);
	return me;
	}

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHWRMTestAppPropertyObserver::ConstructL()
	{
    User::LeaveIfError( iProperty.Attach( iUid, iKey ) );

	CActiveScheduler::Add(this);
	// initial subscription and process current property value
	RunL();
	}

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::~CHWRMTestAppPropertyObserver
// Destructor
// -----------------------------------------------------------------------------
//
CHWRMTestAppPropertyObserver::~CHWRMTestAppPropertyObserver()
	{
	Cancel();
	iProperty.Close();
	}

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::DoCancel
// 
// -----------------------------------------------------------------------------
//
void CHWRMTestAppPropertyObserver::DoCancel()
	{
	iProperty.Cancel();
	}

// -----------------------------------------------------------------------------
// CHWRMTestAppPropertyObserver::RunL
// 
// -----------------------------------------------------------------------------
//
void CHWRMTestAppPropertyObserver::RunL()
	{
	// resubscribe before processing new value to prevent missing updates
    iProperty.Subscribe( iStatus );
	SetActive();

    TBuf<100> msg;

    switch( iKey )
        {
        case KHWRMBatteryLevel:
            {
            _LIT(KBatteryLevel, "KHWRMBatteryLevel updated");
            iAppContainer->AddMessageL( KBatteryLevel );
	        break;
            }
        case KHWRMBatteryStatus:
            {
            _LIT(KBatteryStatus, "KHWRMBatteryStatus updated");
            iAppContainer->AddMessageL( KBatteryStatus );
	        break;
            }
        case KHWRMChargingStatus:
            {
            _LIT(KChargingStatus, "KHWRMChargingStatus updated");
            iAppContainer->AddMessageL( KChargingStatus );
	        break;
            }
        default:
            break;
        }

	// property updated, get new value
	TInt keyValue;
	if( iProperty.Get( keyValue ) == KErrNotFound )
		{
		// property deleted, do necessary actions here...
		_LIT(KPropertyDeleted, "Property deleted!");
        msg.Format( KPropertyDeleted );
        }
	else
		{
		// use new value ...
		_LIT(KNewValue, "New value = %d");
		msg.Format( KNewValue, keyValue );
        }

    iAppContainer->AddMessageL( msg );
	}

//  End of File  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -