Symbian3/SDK/Source/GUID-79CFCC01-7418-5ECA-AF65-1DCAD97AA7A6.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task xml:lang="en" id="GUID-79CFCC01-7418-5ECA-AF65-1DCAD97AA7A6"><title>Battery Information Tutorial</title><shortdesc>This tutorial describes the steps to retrieve the battery information from the device. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> <steps id="GUID-F83E8419-F662-5A61-9323-0D75C9908170"> <step id="GUID-7B5254D8-C262-519B-B3FF-D57A2D7B6243"><cmd/><info>create a new instance of <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony</apiname></xref> with active objects </info> </step> <step id="GUID-0605977A-E621-5C84-AC94-005D21BD2E95"><cmd/><info>use <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony::GetBatteryInfo()</apiname></xref> to get the battery information </info> </step> <step id="GUID-F8997D43-283B-5879-8BD5-AC97DE965229"><cmd/><info>the function returns the information in <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony::TBatteryInfoV1</apiname></xref>  </info> <info>The result contains the battery charge level and the battery status. </info> </step> <step id="GUID-C232F8FF-D1AE-56ED-A608-341892D7716A"><cmd/><info>use <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony::EGetBatteryInfoCancel</apiname></xref> to cancel the asynchronous function </info> </step> <step id="GUID-DD9ABED8-3992-502F-8913-200029FF2B08"><cmd/><info>use <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony::EBatteryInfoChange</apiname></xref> to get the notification of any changes to the battery information </info> </step> <step id="GUID-58FE9960-9B4E-56F7-B36D-3FACD884E8A1"><cmd/><info>pass the enumeration <xref href="GUID-97D402C8-B4B7-385A-92B3-D3FCC0CA575A.dita"><apiname>CTelephony::EBatteryInfoChangeCancel</apiname></xref> to cancel the notification request. </info> </step> </steps> <example id="GUID-A61FA77E-BD0D-5A31-B558-DA98252B6717"><title>Battery information example</title> <codeblock id="GUID-D97E8177-1EE7-579B-AADB-4F3B084CD539" xml:space="preserve">#include &lt;e32base.h&gt;
       
    13 #include &lt;Etel3rdParty.h&gt;
       
    14 
       
    15 class CClientApp : public CActive
       
    16   { 
       
    17 
       
    18 private:
       
    19     CTelephony* iTelephony;
       
    20     CTelephony::TBatteryInfoV1 iBatteryInfoV1;
       
    21     CTelephony::TBatteryInfoV1Pckg iBatteryInfoV1Pckg;
       
    22 
       
    23 public:
       
    24     CClientApp(CTelephony* aTelephony);
       
    25     void SomeFunction();
       
    26 
       
    27 private:
       
    28     /*
       
    29        These are the pure virtual methods from CActive that  
       
    30        MUST be implemented by all active objects
       
    31        */
       
    32     void RunL();
       
    33     void DoCancel();
       
    34    };
       
    35 
       
    36 CClientApp::CClientApp(CTelephony* aTelephony)
       
    37     : CActive(EPriorityStandard),
       
    38       iTelephony(aTelephony),
       
    39       iBatteryInfoV1Pckg(iBatteryInfoV1)
       
    40     {
       
    41     //default constructor
       
    42     }
       
    43 
       
    44 void CClientApp::SomeFunction()
       
    45     {
       
    46     iTelephony-&gt;GetBatteryInfo(iStatus, iBatteryInfoV1Pckg);
       
    47     SetActive();
       
    48     }
       
    49 
       
    50 void CClientApp::RunL()
       
    51     {
       
    52     if(iStatus==KErrNone)
       
    53        {
       
    54        CTelephony::TBatteryStatus batteryStatus = iBatteryInfoV1.iStatus;
       
    55        TUint chargeLevel = iBatteryInfoV1.iChargeLevel;
       
    56        }
       
    57     }
       
    58 
       
    59 void CClientApp::DoCancel()
       
    60     {
       
    61     iTelephony-&gt;CancelAsync(CTelephony::EGetBatteryInfoCancel);
       
    62     }</codeblock> </example> </taskbody></task>