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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SYSTEMOBSERVER_H |
|
20 #define SYSTEMOBSERVER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <npscript.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // State enum and member variable |
|
31 |
|
32 // CLASS DECLARATIONS |
|
33 |
|
34 /** |
|
35 * MSystemInfoObserverClient is an interface to whatever data is being |
|
36 * observed (RProperty, int, string, etc). |
|
37 * @lib npSystemInfoPlugin.lib |
|
38 * @since S60 v3.2 |
|
39 */ |
|
40 class MSystemInfoObserverClient |
|
41 { |
|
42 public: |
|
43 virtual void SubscribeL( TInt aId, TRequestStatus& aStatus ) = 0; |
|
44 virtual void UpdateL( TInt aId ) = 0; |
|
45 virtual void Cancel( TInt aId ) = 0; |
|
46 virtual void Close( TInt aId ) = 0; |
|
47 /* |
|
48 * Outline of use for a publish and subscribe variable |
|
49 * #include <e32property.h> |
|
50 * #include <hwrmpowerstatesdkpskeys.h> |
|
51 * RProperty iProperty; |
|
52 * iProperty.Attach( KPSUidHWRMPowerState, KHWRMBatteryLevel ); |
|
53 * SubscribeL => iProperty.Subscribe( status ); |
|
54 * UpdateL => iProperty.Get( value ); |
|
55 * Cancel => iProperty.Cancel(); |
|
56 * Close => iProperty.Close(); |
|
57 * The ID parameter is there so that a class can contain |
|
58 * multiple observers and differentiate them in these methods by ID. |
|
59 * You can also use it for state in a state machine. |
|
60 */ |
|
61 }; |
|
62 |
|
63 /** |
|
64 * CSystemInfoObserver. |
|
65 * Active class for monitoring variables. |
|
66 * @lib npSystemInfoPlugin.lib |
|
67 * @since S60 v3.2 |
|
68 */ |
|
69 NONSHARABLE_CLASS(CSystemInfoObserver) : public CActive |
|
70 { |
|
71 public: |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 */ |
|
75 static CSystemInfoObserver* NewL( MSystemInfoObserverClient* aClient, TInt aId ); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 virtual ~CSystemInfoObserver(); |
|
81 |
|
82 private: |
|
83 /** |
|
84 * C++ default constructor. |
|
85 */ |
|
86 CSystemInfoObserver( MSystemInfoObserverClient* aClient, TInt aId ); |
|
87 |
|
88 /** |
|
89 * By default Symbian 2nd phase constructor is private. |
|
90 * @param none |
|
91 * @return void |
|
92 */ |
|
93 void ConstructL(); |
|
94 |
|
95 public: |
|
96 /** |
|
97 * Request observed status change notification |
|
98 * @since 3.2 |
|
99 * @param none |
|
100 * @return void |
|
101 */ |
|
102 void RequestNotificationL(); |
|
103 |
|
104 protected: // CActive |
|
105 /** |
|
106 * Implements cancellation of an outstanding request. |
|
107 * @param none |
|
108 * @return void |
|
109 */ |
|
110 void DoCancel(); |
|
111 |
|
112 /** |
|
113 * Handles an active object’s request completion event. |
|
114 * @param none |
|
115 * @return void |
|
116 */ |
|
117 void RunL(); |
|
118 |
|
119 /** |
|
120 * Handles an active object’s error |
|
121 * @param error |
|
122 * @return void |
|
123 */ |
|
124 TInt RunError(TInt aError); |
|
125 |
|
126 private: |
|
127 MSystemInfoObserverClient* iClient; |
|
128 TInt iId; |
|
129 }; |
|
130 |
|
131 #endif // SYSTEMOBSERVER_H |
|
132 |
|
133 // End of File |
|