BatteryLevel-CTelephony Class

Login to reply to this topic.
Thu, 2006-04-20 02:03
Joined: 2006-03-28
Forum posts: 29
I want to retrieve battery level using CTelephony class.
------------
Header File:
------------
#include <e32base.h>
#include <Etel3rdParty.h>

class CClientApp : public CActive
{

private:
CTelephony* iTelephony;
CTelephony::TBatteryInfoV1 iBatteryInfoV1;
CTelephony::TBatteryInfoV1Pckg iBatteryInfoV1Pckg;

public:
CClientApp(CTelephony* aTelephony);
void SomeFunction();

private:
/*
These are the pure virtual methods from CActive that
MUST be implemented by all active objects
*/
void RunL();
void DoCancel();
};
---------------------------------------------------------------------

--------
cpp file:
--------
#include "ClientApp.h"

CClientApp::CClientApp(CTelephony* aTelephony)
: CActive(EPriorityStandard),
iTelephony(aTelephony),
iBatteryInfoV1Pckg(iBatteryInfoV1)
{
//default constructor
}

void CClientApp::SomeFunction()
{
iTelephony->GetBatteryInfo(iStatus, iBatteryInfoV1Pckg);
SetActive();
}

void CClientApp::RunL()
{
if(iStatus==KErrNone)
{
CTelephony::TBatteryStatus batteryStatus = iBatteryInfoV1.iStatus;
TUint chargeLevel = iBatteryInfoV1.iChargeLevel;
}
}

void CClientApp::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EGetBatteryInfoCancel);
}
---------------------------------------------------------------------

when i build my application it generates following errors:

'TBatteryInfoV1' : is not a member of 'CTelephony'
.h(48) : see declaration of 'CTelephony'
syntax error : missing ';' before identifier 'iBatteryInfoV1'
'TBatteryInfoV1' : missing storage-class or type specifiers
'iBatteryInfoV1' : missing storage-class or type specifiers
'TBatteryInfoV1Pckg' : is not a member of 'CTelephony'
.h(48) : see declaration of 'CTelephony'
syntax error : missing ';' before identifier 'iBatteryInfoV1Pckg'
'TBatteryInfoV1Pckg' : missing storage-class or type specifiers
'iBatteryInfoV1Pckg' : missing storage-class or type specifiers
: 'iBatteryInfoV1' : undeclared identifier
: 'CClientApp' : illegal member initialization: 'iBatteryInfoV1Pckg'

9: 'GetBatteryInfo' : is not a member of 'CTelephony'
.h(48) : see declaration of 'CTelephony'
5: 'iBatteryInfoV1Pckg' : undeclared identifier
9: 'TBatteryStatus' : is not a member of 'CTelephony'
.h(48) : see declaration of 'CTelephony'
5: 'TBatteryStatus' : undeclared identifier
6: syntax error : missing ';' before identifier 'batteryStatus'
5: 'batteryStatus' : undeclared identifier
8: left of '.iStatus' must have class/struct/union type
8: left of '.iChargeLevel' must have class/struct/union type
9: 'CancelAsync' : is not a member of 'CTelephony'
.h(48) : see declaration of 'CTelephony'
9: 'EGetBatteryInfoCancel' : is not a member of 'CTelephony'

.h(48) : see declaration of 'CTelephony'
5: 'EGetBatteryInfoCancel' : undeclared identifier
------------------------------------------------------------------

Please Help me Out:
Thanking u in advance.
Edit/Delete Message

Thu, 2006-04-20 23:59
Joined: 2006-03-28
Forum posts: 29
Re: BatteryLevel-CTelephony Class
The problem got solved. I was using 7.0, now i m using 8.0a.
8.0a solved my problem.

But new problem arised:
When i call SomeFunction() from appui's switch case, emulator crashes n generates following error:

KERN EXEC-3 on reaching iTelephony->GetBatteryInfo(iStatus, iBatteryInfoV1Pckg); line.

Please help me out.
Thanks.
  • Login to reply to this topic.