author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include "tsysbattery.h" |
19 | 21 |
#include "sysinfoservice.h" |
22 |
#include "entitykeys.h" |
|
23 |
#include "tbatstrnoti.h" |
|
24 |
||
25 |
using namespace SysInfo; |
|
26 |
||
27 |
CBatStrengthNoti* CBatStrengthNoti::NewL(CStifLogger* aLog) |
|
28 |
{ |
|
29 |
CBatStrengthNoti* self = new(ELeave) CBatStrengthNoti(aLog); |
|
30 |
self->ConstructL(); |
|
31 |
return self; |
|
32 |
} |
|
33 |
||
34 |
CBatStrengthNoti::~CBatStrengthNoti() |
|
35 |
{ |
|
36 |
Cancel(); |
|
37 |
||
38 |
if(iWaitSchedular->IsStarted()) |
|
39 |
iWaitSchedular->AsyncStop(); |
|
40 |
||
41 |
delete iSysInfoService; |
|
42 |
delete iWaitSchedular; |
|
43 |
delete iTimer; |
|
44 |
} |
|
45 |
||
46 |
void CBatStrengthNoti::ConstructL() |
|
47 |
{ |
|
48 |
iSysInfoService = CSysInfoService::NewL(); |
|
49 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
50 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
51 |
CActiveScheduler::Add(this); |
|
52 |
} |
|
53 |
||
54 |
CBatStrengthNoti::CBatStrengthNoti(CStifLogger* aLog) |
|
55 |
:CActive(EPriorityStandard), |
|
56 |
iLog(aLog) |
|
57 |
{ |
|
58 |
} |
|
59 |
||
60 |
void CBatStrengthNoti::DoCancel() |
|
61 |
{ |
|
62 |
} |
|
63 |
||
64 |
void CBatStrengthNoti::RunL() |
|
65 |
{ |
|
66 |
TestFuncL(); |
|
67 |
} |
|
68 |
||
69 |
void CBatStrengthNoti::Start() |
|
70 |
{ |
|
71 |
SetActive(); |
|
72 |
TRequestStatus* temp = &iStatus; |
|
73 |
User::RequestComplete(temp, KErrNone); |
|
74 |
iWaitSchedular->Start(); |
|
75 |
} |
|
76 |
||
77 |
TInt CBatStrengthNoti::Result() |
|
78 |
{ |
|
79 |
return iResult; |
|
80 |
} |
|
81 |
||
82 |
void CBatStrengthNoti::TestFuncL() |
|
83 |
{ |
|
84 |
const TTimeIntervalMicroSeconds32 OneMinute(60000000); |
|
85 |
iSysInfoService->GetNotificationL(KBattery,KBatteryStrength,1,this); |
|
86 |
iTimer->After(OneMinute); |
|
87 |
} |
|
88 |
||
89 |
void CBatStrengthNoti::HandleResponseL(const TDesC& aEntity,const TDesC& aKey, |
|
90 |
CSysData* aOutput, TInt32 aTransID, TSysRequest::TRequestType /*aType*/,TInt aError) |
|
91 |
{ |
|
92 |
delete iTimer; |
|
93 |
iTimer = NULL; |
|
94 |
||
95 |
iLog->Log(_L("Entity: %s, Key: %s "),aEntity.Ptr(),aKey.Ptr()); |
|
96 |
||
97 |
if(aEntity.Compare(KBattery) || aKey.Compare(KBatteryStrength)) |
|
98 |
iLog->Log(_L("Incorrect Entity,Key..")); |
|
99 |
||
100 |
iLog->Log(_L("Battery Strength changed..")); |
|
101 |
||
102 |
if(!aError) |
|
103 |
{ |
|
104 |
TInt32 tid = aTransID; |
|
105 |
if(tid != 1) |
|
106 |
{ |
|
107 |
iResult = FAIL; |
|
108 |
iLog->Log(_L("Incorrect TID Retured.. %d"),tid); |
|
109 |
} |
|
110 |
||
111 |
TInt BatteryStrength = ((CStatus*)aOutput)->Status(); |
|
112 |
||
113 |
iLog->Log(_L("Battery Strength: %d"),BatteryStrength); |
|
114 |
||
115 |
if( !(BatteryStrength > 0 && BatteryStrength <= 100) ) |
|
116 |
{ |
|
117 |
iResult = FAIL; |
|
118 |
iLog->Log(_L("Battery Strength is out of range")); |
|
119 |
} |
|
120 |
delete aOutput; |
|
121 |
} |
|
122 |
else |
|
123 |
{ |
|
124 |
iLog->Log(_L("ERROR SET")); |
|
125 |
iResult = FAIL; |
|
126 |
} |
|
127 |
iWaitSchedular->AsyncStop(); |
|
128 |
} |
|
129 |
||
130 |
void CBatStrengthNoti::HandleTimeOut() |
|
131 |
{ |
|
132 |
iLog->Log(_L("CBatStrengthNoti Notification TimeOut reached...")); |
|
133 |
iSysInfoService->Cancel(1); |
|
134 |
iResult = FAIL; |
|
135 |
iWaitSchedular->AsyncStop(); |
|
136 |
} |
|
137 |