Thursday, January 18, 2007

Retrieving battery strength on S60 2nd Edition

below is the code to Get the battery info on Device.

/*

Location: saclient.h
Link against: sysagt.lib

const TInt KUidBatteryBarsValue = 0x100052D3;
const TUid KUidBatteryBars ={KUidBatteryBarsValue};

enum TSABatteryBars
{
ESABBars_0,
ESABBars_1,
ESABBars_2,
ESABBars_3,
ESABBars_4,
ESABBars_5,
ESABBars_6,
ESABBars_7
};
*/

RSystemAgent systemAgent;
User::LeaveIfError(systemAgent.Connect());
TInt strength = systemAgent.GetState(KUidBatteryBarsValue);

// strength will be of type TSABatteryBars;

Tuesday, January 02, 2007

Profile data on 3rd edition

On 1st edition and early 2nd edition FPs, there was no officially sanctioned way to get profile data, although CProfileAPI was easy enough to generate from the LIB files. Later we got CSettingInfo. In 3rd edition profile data is kept in the central repository, and you can access some of it with the keys in profileenginesdkcrkeys.h.

But the documented keys only provide access to a subset of the profile data, for example not to vibrating alert status or the ringing tone. And it’s read-only.

Luckily, CRepository allows you to enumerate keys. You just open the repository with the CRepository::NewL(KCRUidProfileEngine), and enumerate them with:

CRepository* iRep;
iRep=CRepository::NewL(KCRUidProfileEngine);
RArray found;
iRep->FindL(0, 0, found);
for (int i=0; i key=found[i];
/* do something with the key*/

Read full Post here
}
stats counter