|
1 /* |
|
2 * Copyright (c) 2007 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: Publish & Subscribe watcher client for battery states.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CIPTVBATTERYWATCHER_H |
|
21 #define CIPTVBATTERYWATCHER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32property.h> |
|
25 |
|
26 class MBatteryWatcherObserver; |
|
27 |
|
28 /** |
|
29 * Publish & Subscribe watcher client for battery states. |
|
30 * |
|
31 * @lib iptvscheduleddownloadplugin.dll |
|
32 */ |
|
33 class CIptvBatteryWatcher : public CActive |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Two-phased constructor. |
|
39 */ |
|
40 static CIptvBatteryWatcher* NewL(); |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 */ |
|
45 static CIptvBatteryWatcher* NewLC(); |
|
46 |
|
47 /** |
|
48 * Destructor. |
|
49 */ |
|
50 virtual ~CIptvBatteryWatcher(); |
|
51 |
|
52 /** |
|
53 * Helper method that returns the battery status. |
|
54 * |
|
55 * @param aBatteryStatus The battery status. |
|
56 * @return Possible error code. |
|
57 */ |
|
58 TInt GetBatteryStatus( TInt& aBatteryStatus ); |
|
59 |
|
60 /** |
|
61 * Helper method that returns the charger status. |
|
62 * |
|
63 * @param aChargerStatus The charger status. |
|
64 * @return Possible error code. |
|
65 */ |
|
66 TInt GetChargerStatus( TInt& aChargerStatus ); |
|
67 |
|
68 /** |
|
69 * Helper method that returns ETrue if the battery is low and |
|
70 * no charger is connected or if the battery is empty. |
|
71 * |
|
72 * @return ETrue if there is no power. |
|
73 */ |
|
74 TBool IsLowPower(); |
|
75 |
|
76 /** |
|
77 * Add the observer. |
|
78 * |
|
79 * @param aObserver The observer to add. |
|
80 */ |
|
81 void AddObserverL( MBatteryWatcherObserver* aObserver ); |
|
82 |
|
83 /** |
|
84 * Remove the observer. |
|
85 * |
|
86 * @param aObserver The observer to remove. |
|
87 */ |
|
88 void RemoveObserver( MBatteryWatcherObserver* aObserver ); |
|
89 |
|
90 private: // from base class CActive |
|
91 |
|
92 /** |
|
93 * Battery status has been changed, inform observers if battery is low. |
|
94 */ |
|
95 void RunL(); |
|
96 |
|
97 /** |
|
98 * Cancel the battery status property watching. |
|
99 */ |
|
100 void DoCancel(); |
|
101 |
|
102 private: |
|
103 |
|
104 /** |
|
105 * C++ constructor |
|
106 */ |
|
107 CIptvBatteryWatcher(); |
|
108 |
|
109 /** |
|
110 * By default Symbian 2nd phase constructor is private. |
|
111 */ |
|
112 void ConstructL(); |
|
113 |
|
114 private: // data |
|
115 |
|
116 /** |
|
117 * The property used to watch the battery status. |
|
118 */ |
|
119 RProperty iProperty; |
|
120 |
|
121 /** |
|
122 * A list of observers. Not own. |
|
123 */ |
|
124 RPointerArray<MBatteryWatcherObserver> iObservers; |
|
125 }; |
|
126 |
|
127 #endif // CIPTVBATTERYWATCHER_H |