|
1 /* |
|
2 * Copyright (c) 2009 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: Class implementing WLAN BgScan AWS communications |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 1 % |
|
20 */ |
|
21 |
|
22 #ifndef WLANBGSCANAWSCOMMS_H |
|
23 #define WLANBGSCANAWSCOMMS_H |
|
24 |
|
25 #include "awsinterface.h" |
|
26 #include "awsenginebase.h" |
|
27 #include "wlantimerservices.h" |
|
28 #include "wlanbgscancommandlistener.h" |
|
29 #include "wlanbgscancommand.h" |
|
30 |
|
31 // forward declarations |
|
32 class CWlanBgScan; |
|
33 |
|
34 /** |
|
35 * WLAN Background Scan AWS communications |
|
36 * This class implements WLAN Background Scan AWS communications. |
|
37 * |
|
38 * @since S60 S60 v5.2 |
|
39 */ |
|
40 NONSHARABLE_CLASS( CWlanBgScanAwsComms ) : |
|
41 public CActive, |
|
42 public MAwsBgScanProvider, |
|
43 public MWlanBgScanCommandListener |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 /** |
|
49 * AWS commands. |
|
50 */ |
|
51 enum TAwsCommand |
|
52 { |
|
53 EStart = 0, |
|
54 EStop, |
|
55 ESetPowerSaveMode, |
|
56 EAwsCommandMax //not a real command |
|
57 }; |
|
58 |
|
59 /** |
|
60 * AWS message. |
|
61 */ |
|
62 struct TAwsMessage |
|
63 { |
|
64 TAwsCommand iCmd; |
|
65 TInt iParameter; |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 static CWlanBgScanAwsComms* NewL( CWlanBgScan& aBgScan ); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CWlanBgScanAwsComms(); |
|
77 |
|
78 /** |
|
79 * From MWlanBgScanCommandListener. |
|
80 * DoSetInterval. |
|
81 * This method is called by the command queue when |
|
82 * interval change request is processed. |
|
83 * @param aNewInterval new interval to be taken into use |
|
84 */ |
|
85 void DoSetInterval( TUint32 aNewInterval ); |
|
86 |
|
87 /** |
|
88 * From MAwsBgScanProvider. |
|
89 * Set new background scan interval. |
|
90 * |
|
91 * @since S60 v5.2 |
|
92 * @param aNewInterval new interval to be taken into use |
|
93 * @param aStatus Status of the calling active object. On successful |
|
94 * completion contains KErrNone, otherwise one of the |
|
95 * system-wide error codes. |
|
96 */ |
|
97 void SetInterval( TUint32 aNewInterval, TRequestStatus& aStatus ); |
|
98 |
|
99 /** |
|
100 * Send or queue a message to be sent to AWS. |
|
101 * |
|
102 * @param aMessage Message to be sent |
|
103 * @since S60 v5.2 |
|
104 */ |
|
105 void SendOrQueueAwsCommand( TAwsMessage& aMessage ); |
|
106 |
|
107 /** |
|
108 * Whether AWS is present in system. |
|
109 * |
|
110 * @since S60 v5.2 |
|
111 * @return ETrue if present, EFalse if not |
|
112 */ |
|
113 TBool IsAwsPresent(); |
|
114 |
|
115 private: // From CActive |
|
116 |
|
117 /** |
|
118 * Handles an active object's request completion event. |
|
119 */ |
|
120 void RunL(); |
|
121 |
|
122 /** |
|
123 * Cancels asynchronous request. |
|
124 */ |
|
125 void DoCancel(); |
|
126 |
|
127 /** |
|
128 * Handles a leave occurring in RunL(). |
|
129 * @param aError Error that caused RunL to leave. |
|
130 */ |
|
131 TInt RunError( TInt aError ); |
|
132 |
|
133 private: |
|
134 |
|
135 /** |
|
136 * Constructor. |
|
137 */ |
|
138 CWlanBgScanAwsComms( CWlanBgScan& aBgScan ); |
|
139 |
|
140 /** |
|
141 * Default Constructor (no implementation). |
|
142 */ |
|
143 CWlanBgScanAwsComms(); |
|
144 |
|
145 /** |
|
146 * Two-phased constructor. |
|
147 */ |
|
148 void ConstructL(); |
|
149 |
|
150 /** |
|
151 * Clean-up ECOM array |
|
152 * |
|
153 * @since S60 v5.2 |
|
154 * @param aArray ECOM objec array |
|
155 */ |
|
156 static void CleanupEComArray(TAny* aArray); |
|
157 |
|
158 /** |
|
159 * Start AWS in it's own thread. |
|
160 */ |
|
161 void StartAwsThreadL(); |
|
162 |
|
163 /** |
|
164 * Main function for AWS thread. |
|
165 * |
|
166 * @param aThisPtr Pointer to CWlanBgScan instance. |
|
167 * @return Symbian specific error code. |
|
168 */ |
|
169 static TInt AwsThreadEntryPoint( TAny* aThisPtr ); |
|
170 |
|
171 /** |
|
172 * Instantiate AWS ECOM Plugin. |
|
173 */ |
|
174 void InstantiateAwsPluginL(); |
|
175 |
|
176 /** |
|
177 * Send message to AWS. |
|
178 * |
|
179 * @param aMessage Message to be sent |
|
180 * @since S60 v5.2 |
|
181 */ |
|
182 void SendAwsCommand( TAwsMessage& aMessage ); |
|
183 |
|
184 private: // data |
|
185 |
|
186 /** |
|
187 * Reference to BgScan component. |
|
188 */ |
|
189 CWlanBgScan& iBgScan; |
|
190 |
|
191 /** |
|
192 * Reference to Adaptive WLAN Scanning component. |
|
193 */ |
|
194 CAwsEngineBase* iAws; |
|
195 |
|
196 /** |
|
197 * Reference to AWS ECOM plugin implementation info. |
|
198 */ |
|
199 CImplementationInformation* iAwsImplInfo; |
|
200 |
|
201 /** |
|
202 * Command Handler. |
|
203 */ |
|
204 CWlanBgScanCommand* iCommandHandler; |
|
205 |
|
206 /** |
|
207 * Version of AWS. |
|
208 */ |
|
209 TUint iAwsVersion; |
|
210 |
|
211 /** |
|
212 * Command queue for commands to be sent to AWS. |
|
213 */ |
|
214 RArray<TAwsMessage> iAwsMsgQueue; |
|
215 |
|
216 /** |
|
217 * Currently pending command that has been sent to AWS. |
|
218 */ |
|
219 TAwsCommand iPendingCommand; |
|
220 |
|
221 /** |
|
222 * If AWS instantiation was successful. |
|
223 */ |
|
224 TBool iAwsOk; |
|
225 |
|
226 }; |
|
227 |
|
228 #endif // WLANBGSCANAWSCOMMS_H |