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: Tests battery notifications |
|
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 "tsysbatterynot.h" |
|
24 |
||
25 |
using namespace SysInfo; |
|
26 |
||
27 |
CBatteryNot* CBatteryNot::NewL(CStifLogger* aLog, TInt aCmdId) |
|
28 |
{ |
|
29 |
CBatteryNot* self = new(ELeave) CBatteryNot(aLog,aCmdId ); |
|
30 |
self->ConstructL(); |
|
31 |
return self; |
|
32 |
} |
|
33 |
||
34 |
CBatteryNot::~CBatteryNot() |
|
35 |
{ |
|
36 |
Cancel(); |
|
37 |
||
38 |
if(iWaitScheduler->IsStarted()) |
|
39 |
iWaitScheduler->AsyncStop(); |
|
40 |
||
41 |
delete iSysInfoService; |
|
42 |
delete iWaitScheduler; |
|
43 |
delete iTimer; |
|
44 |
} |
|
45 |
||
46 |
void CBatteryNot::ConstructL() |
|
47 |
{ |
|
48 |
iSysInfoService = CSysInfoService::NewL(); |
|
49 |
iWaitScheduler = new(ELeave) CActiveSchedulerWait(); |
|
50 |
iTimer = CWatchTimer::NewL(EPriorityNormal,this); |
|
51 |
CActiveScheduler::Add(this); |
|
52 |
} |
|
53 |
||
54 |
CBatteryNot::CBatteryNot(CStifLogger* aLog, TInt aCmdId) |
|
55 |
:CActive(EPriorityStandard), |
|
56 |
iLog(aLog), iCmdId(aCmdId) |
|
57 |
{ |
|
58 |
} |
|
59 |
||
60 |
void CBatteryNot::DoCancel() |
|
61 |
{ |
|
62 |
} |
|
63 |
||
64 |
void CBatteryNot::RunL() |
|
65 |
{ |
|
66 |
if(iCmdId == EWrongData) |
|
67 |
{ |
|
68 |
TRAP(iResult,TestFuncL()); |
|
69 |
} |
|
70 |
||
71 |
else if(iCmdId == EWrongKey) |
|
72 |
{ |
|
73 |
TRAP(iResult,TestFunc1L()); |
|
74 |
} |
|
75 |
iWaitScheduler->AsyncStop(); |
|
76 |
} |
|
77 |
||
78 |
void CBatteryNot::Start() |
|
79 |
{ |
|
80 |
SetActive(); |
|
81 |
TRequestStatus* temp = &iStatus; |
|
82 |
User::RequestComplete(temp, KErrNone); |
|
83 |
iWaitScheduler->Start(); |
|
84 |
} |
|
85 |
||
86 |
TInt CBatteryNot::Result() |
|
87 |
{ |
|
88 |
return iResult ; |
|
89 |
} |
|
90 |
||
91 |
void CBatteryNot::TestFuncL() |
|
92 |
{ |
|
93 |
_LIT(KSample,"Simple") ; |
|
94 |
// const TTimeIntervalMicroSeconds32 threeMin(180000000); |
|
95 |
CStringData* inputData = CStringData::NewL(KSample) ; |
|
96 |
CleanupStack::PushL(inputData); |
|
97 |
iSysInfoService->GetNotificationL(KBattery,KBatteryStrength,1,this,inputData); |
|
98 |
// iTimer->After(threeMin); |
|
99 |
// delete inputData ; |
|
100 |
CleanupStack::PopAndDestroy() ; |
|
101 |
} |
|
102 |
||
103 |
void CBatteryNot::TestFunc1L() |
|
104 |
{ |
|
105 |
_LIT(KSample,"Simple") ; |
|
106 |
CStringData* inputData = CStringData::NewL(KSample) ; |
|
107 |
CleanupStack::PushL(inputData); |
|
108 |
iSysInfoService->GetNotificationL(KBattery,KSample,1,this,inputData); |
|
109 |
CleanupStack::PopAndDestroy() ; |
|
110 |
} |
|
111 |
||
112 |
void CBatteryNot::HandleResponseL(const TDesC& /*aEntity*/,const TDesC& /*aKey*/, |
|
113 |
CSysData* aOutput, TInt32 /*aTransID*/,TSysRequest::TRequestType /*aType*/, TInt /*aError*/) |
|
114 |
{ |
|
115 |
||
116 |
delete aOutput ; |
|
117 |
||
118 |
} |
|
119 |
||
120 |
void CBatteryNot::HandleTimeOut() |
|
121 |
{ |
|
122 |
||
123 |
} |