|
1 /* |
|
2 * ============================================================================== |
|
3 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * Nokia Corporation - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 * ============================================================================== |
|
18 */ |
|
19 |
|
20 #include <stringresourcereader.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <bautils.h> |
|
23 |
|
24 #include <dcmo.rsg> |
|
25 #include <btfeaturescfg.h> |
|
26 |
|
27 #include "btctrldcmoadapter.h" |
|
28 |
|
29 _LIT(KBluetoothDcmoPanicName, "BT DCMO Adapter"); |
|
30 |
|
31 _LIT( KBluetoothControlProperty, "Bluetooth" ); |
|
32 _LIT( KDisableBluetoothDescription, "Used to enable/disable the Bluetooth connectivity." ); // Description |
|
33 _LIT( KRuntimeResourceFileName, "z:dcmo.rsc" ); |
|
34 |
|
35 TDCMOStatus CBluetoothCtrlDcmoAdapter::MapFeatureControlError(TInt aErrorCode) |
|
36 { |
|
37 TDCMOStatus status = EDcmoFail; |
|
38 |
|
39 switch (aErrorCode) |
|
40 { |
|
41 case KErrNone: |
|
42 status = EDcmoSuccess; |
|
43 break; |
|
44 case KErrPermissionDenied: |
|
45 case KErrAccessDenied: |
|
46 status = EDcmoAccessDenied; |
|
47 break; |
|
48 case KErrNotFound: |
|
49 status = EDcmoNotFound; |
|
50 break; |
|
51 default: |
|
52 break; |
|
53 } |
|
54 return status; |
|
55 } |
|
56 |
|
57 // Construction and destruction functions |
|
58 |
|
59 CBluetoothCtrlDcmoAdapter* CBluetoothCtrlDcmoAdapter::NewL(TAny* aParams) |
|
60 { |
|
61 CBluetoothCtrlDcmoAdapter* self = new (ELeave ) CBluetoothCtrlDcmoAdapter(aParams); |
|
62 return self; |
|
63 } |
|
64 |
|
65 CBluetoothCtrlDcmoAdapter::~CBluetoothCtrlDcmoAdapter() |
|
66 { |
|
67 } |
|
68 |
|
69 CBluetoothCtrlDcmoAdapter::CBluetoothCtrlDcmoAdapter(TAny* aInitParams) |
|
70 : iInitParams(reinterpret_cast<CDCMOInterface::TDCMOInterfaceInitParams*>(aInitParams)) |
|
71 { |
|
72 } |
|
73 |
|
74 // Implementation of CDCMOInterface |
|
75 |
|
76 // |
|
77 // See excerpts from OMA DCMO spec below |
|
78 // |
|
79 TDCMOStatus CBluetoothCtrlDcmoAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue) |
|
80 { |
|
81 TDCMOStatus status = EDcmoFail; |
|
82 |
|
83 switch(aId) |
|
84 { |
|
85 /* |
|
86 This node is used with Exec command to enable the Device Capability to transfer the Device Capability |
|
87 from Disabled State to Enabled state. |
|
88 */ |
|
89 case EEnable: |
|
90 { |
|
91 BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EDisabled; |
|
92 switch (aValue) |
|
93 { |
|
94 case 0: |
|
95 mode = BluetoothFeatures::EDisabled; |
|
96 break; |
|
97 case 1: |
|
98 mode = BluetoothFeatures::EEnabled; |
|
99 break; |
|
100 case 2: |
|
101 mode = BluetoothFeatures::EDataProfilesDisabled; |
|
102 break; |
|
103 default: |
|
104 User::Leave(KErrArgument); |
|
105 } |
|
106 TRAPD(err,BluetoothFeatures::SetEnterpriseEnablementL(mode)); |
|
107 status = MapFeatureControlError(err); |
|
108 } |
|
109 break; |
|
110 default: |
|
111 break; |
|
112 } |
|
113 |
|
114 return status; |
|
115 } |
|
116 |
|
117 // |
|
118 // See excerpts from OMA DCMO spec below |
|
119 // |
|
120 TDCMOStatus CBluetoothCtrlDcmoAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue) |
|
121 { |
|
122 TDCMOStatus status = EDcmoSuccess; |
|
123 |
|
124 switch(aId) |
|
125 { |
|
126 /* |
|
127 This node specifies the group name, defined in section 6.1 “Grouping of properties” of [DPE-TS], |
|
128 for a collection of Device Capabilities |
|
129 */ |
|
130 case EGroup: |
|
131 aValue = EConnectivity; |
|
132 break; |
|
133 /* |
|
134 This leaf node indicates whether the Device Capability is removable and whether it is currently |
|
135 attached to the device. |
|
136 If the leaf exists then the Device Capability is removable. |
|
137 If the value of this node is “True” the Device Capability is currently attached to the device; |
|
138 if the value of this node is “False” the Device Capability is currently detached from the device; |
|
139 |
|
140 NB: Returning EFalse here prevents the node from being inserted into DDF, so Bluetooth is NON-removable media. |
|
141 */ |
|
142 case EAttached: |
|
143 aValue = EFalse; |
|
144 break; |
|
145 /* |
|
146 This leaf node indicates whether the Device Capability is enabled regardless whether |
|
147 the Device Capability is attached or not. |
|
148 If the value of this node is “True” the Device Capability is in Enabled State. |
|
149 If the value of is “False” the Device Capability is in Disabled State; |
|
150 The ‘Attached’ property is independent of ‘Enabled’ property. A Device Capability MAY have ‘True’ |
|
151 as value for ‘Enabled’ node while having ‘False’ as value for the ‘Attached’ node. That means |
|
152 the Device Capability is still not available and can’t be used until it is attached to the Device, |
|
153 but will be useable once the Device Capability is attached. |
|
154 */ |
|
155 case EEnabled: |
|
156 { |
|
157 BluetoothFeatures::TEnterpriseEnablementMode mode = BluetoothFeatures::EnterpriseEnablementL(); |
|
158 switch (mode) |
|
159 { |
|
160 case BluetoothFeatures::EDisabled: |
|
161 aValue = 0; |
|
162 break; |
|
163 case BluetoothFeatures::EEnabled: |
|
164 aValue = 1; |
|
165 break; |
|
166 case BluetoothFeatures::EDataProfilesDisabled: |
|
167 aValue = 2; |
|
168 break; |
|
169 default: |
|
170 User::Leave(KErrArgument); |
|
171 } |
|
172 } |
|
173 break; |
|
174 /* |
|
175 This leaf node specifies whether the user is able to enable a Device Capability. |
|
176 If the node is not present or the value is False, the user is allowed to enable the Device Capability. |
|
177 If the node is present and the value is True, the user is not allowed to enable the Device Capability. |
|
178 */ |
|
179 case EDenyUserEnable: |
|
180 aValue = ETrue; |
|
181 break; |
|
182 /* |
|
183 This leaf node specifies whether the user is notified with the DCMO Operation result when |
|
184 enable/disable Primitive is executed. |
|
185 If the node is not present or the value is ‘False’, the user will not be notified about the result of |
|
186 the operation. |
|
187 If the node is present and the value is ‘True’, the user will be notified about the result of |
|
188 the operation. |
|
189 */ |
|
190 case ENotifyUser: |
|
191 aValue = ETrue; |
|
192 break; |
|
193 default: |
|
194 break; |
|
195 } |
|
196 |
|
197 return status; |
|
198 } |
|
199 |
|
200 TDCMOStatus CBluetoothCtrlDcmoAdapter::SetDCMOPluginStrAttributeValueL(TDCMONode /* aId */, |
|
201 const TDes& /* aStrValue */) |
|
202 { |
|
203 // Nothing to do |
|
204 return EDcmoFail; |
|
205 } |
|
206 |
|
207 TDCMOStatus CBluetoothCtrlDcmoAdapter::GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue) |
|
208 { |
|
209 TDCMOStatus status = EDcmoSuccess; |
|
210 switch(aId) |
|
211 { |
|
212 /* |
|
213 This leaf node specifies the property name, which is defined in section 6.2 “DPE vocabulary List” |
|
214 of [DPE-TS], for a Device Capability. |
|
215 */ |
|
216 case EProperty: |
|
217 __ASSERT_DEBUG(aStrValue.MaxLength() >= KBluetoothControlProperty().Length(),Panic(CBluetoothCtrlDcmoAdapter::EPropertyBufferTooSmall)); |
|
218 aStrValue = KBluetoothControlProperty().Left(aStrValue.MaxLength()); |
|
219 break; |
|
220 /* |
|
221 This leaf node specifies the description for this Device Capability. |
|
222 */ |
|
223 case EDescription: |
|
224 __ASSERT_DEBUG(aStrValue.MaxLength() >= KDisableBluetoothDescription().Length(),Panic(CBluetoothCtrlDcmoAdapter::EDescriptionBufferTooSmall)); |
|
225 aStrValue = KDisableBluetoothDescription().Left(aStrValue.MaxLength()); |
|
226 break; |
|
227 default: |
|
228 status = EDcmoNotFound; |
|
229 break; |
|
230 } |
|
231 |
|
232 return status; |
|
233 } |
|
234 |
|
235 void CBluetoothCtrlDcmoAdapter::GetLocalizedNameL(HBufC*& aLocName) |
|
236 { |
|
237 TFileName* fileName = new(ELeave) TFileName; |
|
238 CleanupStack::PushL(fileName); |
|
239 TParse* parseObj = new(ELeave) TParse(); |
|
240 CleanupStack::PushL(parseObj); |
|
241 User::LeaveIfError(parseObj->Set(KRuntimeResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL)); |
|
242 *fileName = parseObj->FullName(); |
|
243 CleanupStack::PopAndDestroy(parseObj); |
|
244 |
|
245 CStringResourceReader* resReader = CStringResourceReader::NewL(*fileName); |
|
246 CleanupStack::PushL(resReader); |
|
247 |
|
248 TPtrC buf; |
|
249 buf.Set(resReader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH)); |
|
250 aLocName = buf.AllocL() ; |
|
251 |
|
252 CleanupStack::PopAndDestroy(2,fileName); //resReader,fileName |
|
253 } |
|
254 |
|
255 void CBluetoothCtrlDcmoAdapter::Panic(TBluetoothDcmoPanic aPanic) |
|
256 { |
|
257 User::Panic(KBluetoothDcmoPanicName, aPanic); |
|
258 } |