|
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: Control for accessory related settings. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CACCSRVSETTINGSHANDLER_H |
|
20 #define CACCSRVSETTINGSHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <AccModeSettingArray.h> |
|
25 #include "AccSrvServerModel.h" |
|
26 |
|
27 // CONSTANTS |
|
28 _LIT_SECURITY_POLICY_C1(KNoCapability, ECapability_None); |
|
29 _LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData); |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // DATA TYPES |
|
34 enum TAccSettingsLights |
|
35 { |
|
36 EAccSettingsLightsNotSet, |
|
37 EAccSettingsLightsOff, |
|
38 EAccSettingsLightsOn |
|
39 }; |
|
40 |
|
41 // FUNCTION PROTOTYPES |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class CAccSrvConnectionController; |
|
45 class CHWRMLight; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Controller for accessory settings functionality. |
|
51 * |
|
52 * @lib AccServer |
|
53 * @since S60 3.1 |
|
54 */ |
|
55 NONSHARABLE_CLASS( CAccSrvSettingsHandler ) : public CBase |
|
56 { |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 */ |
|
62 static CAccSrvSettingsHandler* NewL( CAccSrvConnectionController* aConCtrl, |
|
63 CAccSrvServerModel& aModel ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 virtual ~CAccSrvSettingsHandler(); |
|
69 |
|
70 public: // New functions |
|
71 |
|
72 /** |
|
73 * Should be called to indicate settings handler that connection status |
|
74 * has changed. |
|
75 * |
|
76 * @since S60 3.1 |
|
77 * @param aArray list of ids representing current connection status |
|
78 * @return void |
|
79 */ |
|
80 void ConnectionStatusChangedL( TAccPolGenericIDArray& aArray ); |
|
81 |
|
82 /** |
|
83 * Returns all supported HW devices that can't be properly identified |
|
84 * when they are connected to phone without additional information. |
|
85 * |
|
86 * @since S60 3.1 |
|
87 * @param void |
|
88 * @return supported HW devices in a bit mask |
|
89 */ |
|
90 TUint32 GetSupportedHWDevicesL() const; |
|
91 |
|
92 /** |
|
93 * Sets or removes HW devices. Used to identify HW device properly when |
|
94 * it's connected to phone. |
|
95 * |
|
96 * @since S60 3.1 |
|
97 * @param aSettings Bit mask storing one or several HW devices. |
|
98 * See AccessoryTypes.h for HW device bit mask |
|
99 * definitions. |
|
100 * @param aEnable ETrue: sets HW device. EFalse: removes HW device. |
|
101 * @param aForce Reserved for future use. |
|
102 * @return void |
|
103 * @exception KErrArgument if an argument was invalid or system-wide |
|
104 * error code if failed. |
|
105 */ |
|
106 void SetHWDeviceSettingsL( TUint32 aSettings, |
|
107 TBool aEnable, |
|
108 TBool aForce ) const; |
|
109 |
|
110 /** |
|
111 * Returns current HW devices. |
|
112 * |
|
113 * @since S60 3.1 |
|
114 * @param void |
|
115 * @return HW devices in a bit mask. |
|
116 */ |
|
117 TUint32 GetHWDeviceSettings() const; |
|
118 |
|
119 /** |
|
120 * Sets one setting for specified accessory mode. |
|
121 * |
|
122 * @since S60 3.1 |
|
123 * @param aAccMode Defines an accessory mode. |
|
124 * @param aSetting Defines setting and it's value. |
|
125 * @return void |
|
126 * @exception system-wide error code if failed. |
|
127 */ |
|
128 void SetAccessoryModeSettingL( const TAccMode aAccMode, |
|
129 const TAccModeSetting& aSetting) const; |
|
130 |
|
131 /** |
|
132 * Returns one setting for specified accessory mode. |
|
133 * |
|
134 * @since S60 3.1 |
|
135 * @param aAccMode Defines an accessory mode. |
|
136 * @param aSetting Defines setting and it's value. |
|
137 * @return void |
|
138 * @exception system-wide error code if failed. |
|
139 */ |
|
140 void GetAccessoryModeSettingL( const TAccMode aAccMode, |
|
141 TAccModeSetting& aSetting ) const; |
|
142 |
|
143 /** |
|
144 * Sets several settings for specified accessory mode. |
|
145 * |
|
146 * @since S60 3.1 |
|
147 * @param aAccMode Defines an accessory mode. |
|
148 * @param aArray Defines an array of several setting and value |
|
149 * pairs. |
|
150 * @return void |
|
151 * @exception system-wide error code if failed. |
|
152 */ |
|
153 void SetAccessoryModeSettingsL( const TAccMode aAccMode, |
|
154 const TAccModeSettingArray& aArray ) const; |
|
155 |
|
156 /** |
|
157 * Returns all settings for specified accessory mode. |
|
158 * |
|
159 * @since S60 3.1 |
|
160 * @param aAccMode Defines accessory mode. |
|
161 * @param aArray Defines an array of several setting and value |
|
162 * pairs. |
|
163 * |
|
164 * @return void |
|
165 * @exception system-wide error code if failed. |
|
166 */ |
|
167 void GetAccessoryModeSettingsL( const TAccMode aAccMode, |
|
168 TAccModeSettingArray& aArray ) const; |
|
169 |
|
170 public: // Functions from base classes |
|
171 |
|
172 protected: // New functions |
|
173 |
|
174 protected: // Functions from base classes |
|
175 |
|
176 private: |
|
177 |
|
178 /** |
|
179 * C++ default constructor. |
|
180 */ |
|
181 CAccSrvSettingsHandler( CAccSrvConnectionController* aConCtrl, |
|
182 CAccSrvServerModel& aModel ); |
|
183 |
|
184 /** |
|
185 * By default Symbian 2nd phase constructor is private. |
|
186 */ |
|
187 void ConstructL(); |
|
188 |
|
189 /** |
|
190 * Returns new settings value. Leaves, if new settings contradict with |
|
191 * policy. |
|
192 */ |
|
193 TUint32 ResolveNewSettingsL( TUint32 aSettings, |
|
194 TBool aEnable, |
|
195 TBool aForce ) const; |
|
196 |
|
197 /** |
|
198 * Checks whether vibra can be allowed or not. As a result aVibra will |
|
199 * be modified: aVibra = ETrue -> vibra is allowed, |
|
200 * aVibra = EFalse -> vibra isn't allowed |
|
201 */ |
|
202 void GetVibraAllowed( TAccPolGenericID& aId, |
|
203 TBool& aVibra ) const; |
|
204 |
|
205 /** |
|
206 * Checks whether lights are forced on or not. As a result aLights will |
|
207 * be modified: aLights = ETrue -> lights should be put on, |
|
208 * aLights = EFalse -> lights shouldn't be put on |
|
209 */ |
|
210 void GetLightsAllowedL( TAccPolGenericID& aId, |
|
211 TBool& aLights ) const; |
|
212 |
|
213 /** |
|
214 * Creates CR key dynamically. |
|
215 */ |
|
216 TUint32 CreateCRKeyL( const TAccMode aAccMode, const TInt aId ) const; |
|
217 |
|
218 /** |
|
219 * Converts setting from client format to CR format. |
|
220 */ |
|
221 HBufC* CodeSettingL( const TAccModeSetting& aSetting ) const; |
|
222 |
|
223 /** |
|
224 * Converts setting from CR format to format readable by client. |
|
225 */ |
|
226 void DecodeSettingL( const TDesC& aIn, TAccModeSetting& aOut ) const; |
|
227 |
|
228 /** |
|
229 * Returns ETrue, if setting is known. |
|
230 */ |
|
231 TBool StaticKey( const TInt id ) const; |
|
232 |
|
233 /** |
|
234 * Returns all static keys for accessory mode. |
|
235 */ |
|
236 void GetStaticKeys( const TAccMode aAccMode, |
|
237 RArray< TUint32 >& aArray ) const; |
|
238 |
|
239 public: // Data |
|
240 |
|
241 protected: // Data |
|
242 |
|
243 private: // Data |
|
244 // Controls connection handling |
|
245 CAccSrvConnectionController* iConCtrl; |
|
246 |
|
247 // Model that stores server status when server is running |
|
248 CAccSrvServerModel& iModel; |
|
249 |
|
250 // Lights API services |
|
251 CHWRMLight* iLightsApi; |
|
252 |
|
253 // Tells wheter lights set on or off by accessory server. |
|
254 TAccSettingsLights iLightsOn; |
|
255 |
|
256 public: // Friend classes |
|
257 |
|
258 protected: // Friend classes |
|
259 |
|
260 private: // Friend classes |
|
261 |
|
262 }; |
|
263 |
|
264 #endif // CACCSRVSETTINGSHANDLER_H |
|
265 |
|
266 // End of File |