|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Sub session for accessory related settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "AccSrvsubSettings.h" |
|
22 #include "AccSrvMainSession.h" |
|
23 #include "AccClientServerMessages.h" |
|
24 #include "AccSrvSettingsHandler.h" |
|
25 #include "acc_debug.h" |
|
26 #include "AccPolAccessoryPolicy.h" |
|
27 #include <AccModeSetting.h> |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // MACROS |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 // MODULE DATA STRUCTURES |
|
40 |
|
41 // LOCAL FUNCTION PROTOTYPES |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 |
|
45 // ============================= LOCAL FUNCTIONS =============================== |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CAccSrvSubSettings::CAccSrvSubSettings |
|
51 // C++ default constructor can NOT contain any code, that |
|
52 // might leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CAccSrvSubSettings::CAccSrvSubSettings( CASYProxyAPI* aProxy, |
|
56 CAccSrvConnectionController* aConnectionController, |
|
57 CAccSrvServerModel* aServerModel ) |
|
58 : CAccSrvSubBase( aProxy, aConnectionController, aServerModel ) |
|
59 { |
|
60 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::CAccSrvSubSettings()" ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CAccSrvSubSettings::ConstructL |
|
65 // Symbian 2nd phase constructor can leave. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CAccSrvSubSettings::ConstructL() |
|
69 { |
|
70 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::ConstructL()" ); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CAccSrvSubSettings::NewL |
|
75 // |
|
76 // Two-phased constructor. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CAccSrvSubSettings* CAccSrvSubSettings::NewL( CASYProxyAPI* aProxy, |
|
80 CAccSrvConnectionController* aConnectionController, |
|
81 CAccSrvServerModel* aServerModel ) |
|
82 { |
|
83 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::NewL()" ); |
|
84 |
|
85 if( !aProxy ) |
|
86 { |
|
87 User::Leave( KErrArgument ); |
|
88 } |
|
89 |
|
90 CAccSrvSubSettings* self = new (ELeave) CAccSrvSubSettings( aProxy, |
|
91 aConnectionController, |
|
92 aServerModel ); |
|
93 |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::NewL - return self" ); |
|
99 |
|
100 return self; |
|
101 } |
|
102 |
|
103 // Destructor |
|
104 CAccSrvSubSettings::~CAccSrvSubSettings() |
|
105 { |
|
106 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::~CAccSrvSubSettings()" ); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CAccSrvSubSettings::DispatchMessageL |
|
111 // Handles client request |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CAccSrvSubSettings::DispatchMessageL( const RMessage2& aMessage ) |
|
115 { |
|
116 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::DispatchMessageL()" ); |
|
117 |
|
118 TInt function = aMessage.Function(); |
|
119 |
|
120 switch ( function ) |
|
121 { |
|
122 case EAccSrvGetSupportedHWDevices: |
|
123 { |
|
124 GetSupportedHWDevicesL( aMessage ); |
|
125 break; |
|
126 } |
|
127 case EAccSrvGetHWDeviceSettings: |
|
128 { |
|
129 GetHWDeviceSettingsL( aMessage ); |
|
130 break; |
|
131 } |
|
132 case EAccSrvSetHWDeviceSettings: |
|
133 { |
|
134 SetHWDeviceSettingsL( aMessage ); |
|
135 break; |
|
136 } |
|
137 case EAccSrvGetAccessoryModeSetting: |
|
138 { |
|
139 GetAccessoryModeSettingL( aMessage ); |
|
140 break; |
|
141 } |
|
142 case EAccSrvSetAccessoryModeSetting: |
|
143 { |
|
144 SetAccessoryModeSettingL( aMessage ); |
|
145 break; |
|
146 } |
|
147 case EAccSrvGetAccessoryModeSettings: |
|
148 { |
|
149 GetAccessoryModeSettingsL( aMessage ); |
|
150 break; |
|
151 } |
|
152 case EAccSrvSetAccessoryModeSettings: |
|
153 { |
|
154 SetAccessoryModeSettingsL( aMessage ); |
|
155 break; |
|
156 } |
|
157 default: |
|
158 { |
|
159 TRACE_ASSERT_ALWAYS; |
|
160 COM_TRACE_1( "[AccFW:AccServer] CAccSrvSubSettings::DispatchMessageL - unhandled function %d", function ); |
|
161 User::Leave( KErrGeneral ); |
|
162 break; |
|
163 } |
|
164 } // switch( function ) |
|
165 |
|
166 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::DispatchMessageL - return void" ); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CAccSrvSubSettings::GetSupportedHWDevicesL |
|
171 // |
|
172 // (other items were commented in a header). |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CAccSrvSubSettings::GetSupportedHWDevicesL( const RMessage2& aMessage ) |
|
176 { |
|
177 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetSupportedHWDevicesL()" ); |
|
178 TUint32 supportedDevices( 0 ); |
|
179 |
|
180 supportedDevices = iServerModel->SupportedDevicesL(); |
|
181 |
|
182 // Write settings to client request |
|
183 TPckgBuf<TUint32> TPckgSettings( supportedDevices ); |
|
184 aMessage.WriteL( KAccServParamPosFirst, TPckgSettings ); |
|
185 |
|
186 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetSupportedHWDevicesL - return void" ); |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CAccSrvSubSettings::SetHWDeviceSettingsL |
|
191 // |
|
192 // (other items were commented in a header). |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CAccSrvSubSettings::SetHWDeviceSettingsL( const RMessage2& aMessage ) |
|
196 { |
|
197 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetHWDeviceSettingsL()" ); |
|
198 |
|
199 TUint32 settings( 0 ); |
|
200 TBool enable( EFalse ); |
|
201 TBool force( EFalse ); |
|
202 TPckgBuf<TUint32> TPckgSettings( settings ); |
|
203 TPckgBuf<TBool> TPckgEnable( enable ); |
|
204 TPckgBuf<TBool> TPckgForce( force ); |
|
205 |
|
206 // Read client parameters |
|
207 aMessage.ReadL( KAccServParamPosFirst, TPckgSettings ); |
|
208 aMessage.ReadL( KAccServParamPosSecond, TPckgEnable ); |
|
209 aMessage.ReadL( KAccServParamPosThird, TPckgForce ); |
|
210 settings = TPckgSettings(); |
|
211 enable = TPckgEnable(); |
|
212 force = TPckgForce(); |
|
213 |
|
214 // Update Model |
|
215 iConnectionController->SettingsHandler().SetHWDeviceSettingsL( |
|
216 settings, |
|
217 enable, |
|
218 force ); |
|
219 |
|
220 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetHWDeviceSettingsL - return void" ); |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CAccSrvSubSettings::GetHWDeviceSettingsL |
|
225 // |
|
226 // (other items were commented in a header). |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CAccSrvSubSettings::GetHWDeviceSettingsL( const RMessage2& aMessage ) |
|
230 { |
|
231 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetHWDeviceSettingsL()" ); |
|
232 |
|
233 // Get settings |
|
234 TUint32 settings = iConnectionController-> |
|
235 SettingsHandler().GetHWDeviceSettings(); |
|
236 |
|
237 // Write settings to client request |
|
238 TPckgBuf<TUint32> TPckgSettings( settings ); |
|
239 aMessage.WriteL( KAccServParamPosFirst, TPckgSettings ); |
|
240 |
|
241 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetHWDeviceSettingsL - return void" ); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CAccSrvSubSettings::SetAccessoryModeSettingL |
|
246 // |
|
247 // (other items were commented in a header). |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 void CAccSrvSubSettings::SetAccessoryModeSettingL( const RMessage2& aMessage ) |
|
251 { |
|
252 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetAccessoryModeSettingL()" ); |
|
253 |
|
254 TAccMode mode( EAccModeHandPortable ); |
|
255 TPckgBuf<TAccMode> TPckgMode( mode ); |
|
256 TAccModeSetting setting; |
|
257 TPckgBuf<TAccModeSetting> TPckgSetting( setting ); |
|
258 |
|
259 // Read client parameters |
|
260 aMessage.ReadL( KAccServParamPosFirst, TPckgMode ); |
|
261 aMessage.ReadL( KAccServParamPosSecond, TPckgSetting ); |
|
262 mode = TPckgMode(); |
|
263 setting = TPckgSetting(); |
|
264 |
|
265 // Update Model |
|
266 iConnectionController-> |
|
267 SettingsHandler().SetAccessoryModeSettingL( mode, setting ); |
|
268 |
|
269 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetAccessoryModeSettingL - return void" ); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CAccSrvSubSettings::GetAccessoryModeSettingL |
|
274 // |
|
275 // (other items were commented in a header). |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CAccSrvSubSettings::GetAccessoryModeSettingL( const RMessage2& aMessage ) |
|
279 { |
|
280 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetAccessoryModeSettingL()" ); |
|
281 |
|
282 TAccMode mode( EAccModeHandPortable ); |
|
283 TPckgBuf<TAccMode> TPckgMode( mode ); |
|
284 TAccModeSetting setting; |
|
285 TPckgBuf<TAccModeSetting> TPckgSettingIn( setting ); |
|
286 |
|
287 // Read client parameters |
|
288 aMessage.ReadL( KAccServParamPosFirst, TPckgMode ); |
|
289 aMessage.ReadL( KAccServParamPosSecond, TPckgSettingIn ); |
|
290 mode = TPckgMode(); |
|
291 setting = TPckgSettingIn(); |
|
292 |
|
293 // Get setting |
|
294 iConnectionController-> |
|
295 SettingsHandler().GetAccessoryModeSettingL( mode, setting ); |
|
296 |
|
297 // Write settings to client request |
|
298 TPckgBuf<TAccModeSetting> TPckgSettingOut( setting ); |
|
299 aMessage.WriteL( KAccServParamPosSecond, TPckgSettingOut ); |
|
300 |
|
301 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetAccessoryModeSettingL - return void" ); |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CAccSrvSubSettings::SetAccessoryModeSettingsL |
|
306 // |
|
307 // (other items were commented in a header). |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CAccSrvSubSettings::SetAccessoryModeSettingsL( const RMessage2& aMessage ) |
|
311 { |
|
312 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetAccessoryModeSettingsL()" ); |
|
313 |
|
314 TAccMode mode( EAccModeHandPortable ); |
|
315 TPckgBuf<TAccMode> TPckgMode( mode ); |
|
316 TAccModeSettingArray array; |
|
317 TPckgBuf<TAccModeSettingArray> TPckgSettingArray( array ); |
|
318 |
|
319 |
|
320 // Read client parameters |
|
321 aMessage.ReadL( KAccServParamPosFirst, TPckgMode ); |
|
322 aMessage.ReadL( KAccServParamPosSecond, TPckgSettingArray ); |
|
323 mode = TPckgMode(); |
|
324 array = TPckgSettingArray(); |
|
325 |
|
326 // Update Model |
|
327 iConnectionController-> |
|
328 SettingsHandler().SetAccessoryModeSettingsL( mode, array ); |
|
329 |
|
330 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::SetAccessoryModeSettingsL - return void" ); |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CAccSrvSubSettings::GetAccessoryModeSettingsL |
|
335 // |
|
336 // (other items were commented in a header). |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void CAccSrvSubSettings::GetAccessoryModeSettingsL( const RMessage2& aMessage ) |
|
340 { |
|
341 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetAccessoryModeSettingsL()" ); |
|
342 |
|
343 TAccMode mode( EAccModeHandPortable ); |
|
344 TPckgBuf<TAccMode> TPckgMode( mode ); |
|
345 TAccModeSettingArray array; |
|
346 TPckgBuf<TAccModeSettingArray> TPckgSettingArrayIn( array ); |
|
347 |
|
348 // Read client parameters |
|
349 aMessage.ReadL( KAccServParamPosFirst, TPckgMode ); |
|
350 aMessage.ReadL( KAccServParamPosSecond, TPckgSettingArrayIn ); |
|
351 mode = TPckgMode(); |
|
352 array = TPckgSettingArrayIn(); |
|
353 |
|
354 // Get setting |
|
355 iConnectionController-> |
|
356 SettingsHandler().GetAccessoryModeSettingsL( mode, array ); |
|
357 |
|
358 // Write settings to client request |
|
359 TPckgBuf<TAccModeSettingArray> TPckgSettingArrayOut( array ); |
|
360 aMessage.WriteL( KAccServParamPosSecond, TPckgSettingArrayOut ); |
|
361 |
|
362 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubSettings::GetAccessoryModeSettingsL - return void" ); |
|
363 } |
|
364 |
|
365 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
366 |
|
367 // End of File |