|
1 /* |
|
2 * Copyright (c) 2008 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 "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: Network field intensity sensor implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CNETWORKFIELDINTENSITYSENSOR_H |
|
19 #define CNETWORKFIELDINTENSITYSENSOR_H |
|
20 |
|
21 #include <etel3rdparty.h> |
|
22 #include "csensorbase.h" |
|
23 |
|
24 class CNetworkFieldIntensitySensor : public CSensorBase |
|
25 { |
|
26 // Asynchronous query helper class |
|
27 class CSignalAsyncHandler : public CActive |
|
28 { |
|
29 public: |
|
30 enum TOperation |
|
31 { |
|
32 EOperationNone = 0, |
|
33 EGetSignalIntensity, |
|
34 ENotifySignalIntensityChange |
|
35 }; |
|
36 |
|
37 public: |
|
38 static CSignalAsyncHandler* NewL(CNetworkFieldIntensitySensor& aSensor); |
|
39 virtual ~CSignalAsyncHandler(); |
|
40 |
|
41 protected: |
|
42 CSignalAsyncHandler(CNetworkFieldIntensitySensor& aSensor); |
|
43 void ConstructL(); |
|
44 |
|
45 public: // From CActive |
|
46 void RunL(); |
|
47 void DoCancel(); |
|
48 |
|
49 public: // New methods |
|
50 void SetDataListeningMode(TBool aIsDataListening); |
|
51 void SetConditionListeningMode(TBool aIsConditionListening); |
|
52 |
|
53 private: // New Methods |
|
54 void Start(); |
|
55 |
|
56 private: // Members |
|
57 CNetworkFieldIntensitySensor& iSensor; |
|
58 |
|
59 CTelephony* iTelephony; |
|
60 CTelephony::TSignalStrengthV1 iSigStrengthV1; |
|
61 CTelephony::TSignalStrengthV1Pckg iSigStrengthV1Pckg; |
|
62 CSignalAsyncHandler::TOperation iCurrentOperation; |
|
63 |
|
64 /** |
|
65 * State variables |
|
66 */ |
|
67 TBool iDataListening; |
|
68 TBool iConditionListening; |
|
69 |
|
70 /** |
|
71 * Used to evaluate whether to execute condition evaluation |
|
72 * when conditions are set and data listening is ongoing. |
|
73 */ |
|
74 TInt iPrevSignalStrength; |
|
75 }; |
|
76 |
|
77 public: |
|
78 /** |
|
79 * Creates new CNetworkFieldIntensitySensor |
|
80 */ |
|
81 static CNetworkFieldIntensitySensor* NewL(); |
|
82 |
|
83 /** |
|
84 * Destructor |
|
85 */ |
|
86 virtual ~CNetworkFieldIntensitySensor(); |
|
87 |
|
88 protected: |
|
89 |
|
90 /** |
|
91 * Symbian second phase constructor |
|
92 */ |
|
93 void ConstructL(); |
|
94 |
|
95 /** |
|
96 * Constructor |
|
97 */ |
|
98 CNetworkFieldIntensitySensor(); |
|
99 |
|
100 public: // From Sensor |
|
101 |
|
102 virtual int OpenChannel(SensorListener* aListener); |
|
103 |
|
104 public: // From CSensorBase |
|
105 |
|
106 virtual HBufC* CreateDescriptionLC(); |
|
107 virtual CSensorBase* DuplicateL(); |
|
108 virtual TReal InterpretValue(TReal aValue); |
|
109 |
|
110 virtual void StartDataListeningL(); |
|
111 virtual void CancelDataListeningL(); |
|
112 virtual void CloseChannelL(); |
|
113 virtual void StartConditionListeningL(); |
|
114 virtual void StopConditionListeningL(); |
|
115 |
|
116 public: // New methods |
|
117 /** |
|
118 * Reset data object and those member variables that are |
|
119 * involved in data accumulation round. |
|
120 */ |
|
121 void ResetAccumulationData(); |
|
122 |
|
123 /** |
|
124 * Used by AccumulateDataL to send data to Java side and do |
|
125 * necessary cleanup. |
|
126 */ |
|
127 void SendData(); |
|
128 |
|
129 /** |
|
130 * Callback method called by RunL of iSignalRequest |
|
131 */ |
|
132 void SignalLevelReceivedL(TInt aLevel); |
|
133 |
|
134 /** |
|
135 * Callback method called by RunL of iNotifier |
|
136 */ |
|
137 void SignalLevelChangedL(TInt aLevel); |
|
138 |
|
139 private: // Member data |
|
140 /** |
|
141 * Used to request notifications about signal level changes |
|
142 */ |
|
143 CSignalAsyncHandler* iNotifier; |
|
144 |
|
145 /** |
|
146 * Values used in data accumulation |
|
147 */ |
|
148 TTime iStartTime; |
|
149 TInt iBufferPosition; |
|
150 |
|
151 }; |
|
152 |
|
153 #endif // CNETWORKFIELDINTENSITYSENSOR_H |