|
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 <featurecontrol.h> |
|
21 #include <featmgr.h> |
|
22 #include <data_caging_path_literals.hrh> |
|
23 #include <bautils.h> |
|
24 #include "wlanctrldcmoadapter.h" |
|
25 #include "hbtextresolversymbian.h" |
|
26 |
|
27 _LIT( KdcmoResourceFileName, "deviceupdates_" ); |
|
28 _LIT( KdcmoResourceFilePath, "z:/resource/qt/translations/" ); |
|
29 _LIT( KWlanCtrlProperty, "WLAN" ); |
|
30 _LIT( KDisableWlanDescription, "Used to enable/disable the WLAN connectivity." ); // Description |
|
31 |
|
32 |
|
33 TDCMOStatus CWLanCtrlDCMOAdapter::MapFeatureControlError( TInt aErrorCode ) |
|
34 { |
|
35 TDCMOStatus status( EDcmoFail ); |
|
36 |
|
37 switch ( aErrorCode ) |
|
38 { |
|
39 case KErrNone: |
|
40 status = EDcmoSuccess; |
|
41 break; |
|
42 case KErrPermissionDenied: |
|
43 case KErrAccessDenied: |
|
44 status = EDcmoAccessDenied; |
|
45 break; |
|
46 case KErrNotFound: |
|
47 status = EDcmoNotFound; |
|
48 break; |
|
49 default: |
|
50 break; |
|
51 } |
|
52 return status; |
|
53 } |
|
54 |
|
55 // Construction and destruction functions |
|
56 |
|
57 CWLanCtrlDCMOAdapter* CWLanCtrlDCMOAdapter::NewL( TAny* aParams ) |
|
58 { |
|
59 CWLanCtrlDCMOAdapter* self = new ( ELeave ) CWLanCtrlDCMOAdapter( aParams ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 CWLanCtrlDCMOAdapter::~CWLanCtrlDCMOAdapter() |
|
67 { |
|
68 FeatureManager::UnInitializeLib(); |
|
69 |
|
70 delete iProperty; |
|
71 delete iDescription; |
|
72 } |
|
73 |
|
74 CWLanCtrlDCMOAdapter::CWLanCtrlDCMOAdapter( TAny* aInitParams ) |
|
75 : iInitParams( ( CDCMOInterface::TDCMOInterfaceInitParams* ) aInitParams ) |
|
76 { |
|
77 // See ConstructL() for initialisation completion. |
|
78 } |
|
79 |
|
80 void CWLanCtrlDCMOAdapter::ConstructL() |
|
81 { |
|
82 // Set up the data to pass back |
|
83 iProperty = KWlanCtrlProperty().AllocL(); |
|
84 iDescription = KDisableWlanDescription().AllocL(); |
|
85 |
|
86 FeatureManager::InitializeLibL(); |
|
87 |
|
88 } |
|
89 |
|
90 |
|
91 // Implementation of CDCMOInterface |
|
92 TDCMOStatus CWLanCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue) |
|
93 { |
|
94 TDCMOStatus status(EDcmoFail); |
|
95 TInt err( KErrNone ); |
|
96 |
|
97 switch( aId ) |
|
98 { |
|
99 case EDenyUserEnable: |
|
100 status = EDcmoNotSupported; |
|
101 break; |
|
102 case ENotifyUser: |
|
103 status = EDcmoNotSupported; |
|
104 break; |
|
105 case EEnable: |
|
106 { |
|
107 RFeatureControl featureControl; |
|
108 TUid wlanUid( TUid::Uid( KFeatureIdProtocolWlan ) ); |
|
109 err = featureControl.Connect(); |
|
110 |
|
111 if ( err == KErrNone ) |
|
112 { |
|
113 if( aValue == 0 ) |
|
114 { |
|
115 // Disable WLAN |
|
116 err = featureControl.DisableFeature( wlanUid ); |
|
117 } |
|
118 else if ( aValue == 1 ) |
|
119 { |
|
120 // Enable WLAN |
|
121 err = featureControl.EnableFeature( wlanUid ); |
|
122 } |
|
123 status = MapFeatureControlError( err ); |
|
124 featureControl.Close(); |
|
125 } |
|
126 |
|
127 } |
|
128 break; |
|
129 default: |
|
130 break; |
|
131 } |
|
132 |
|
133 return status; |
|
134 } |
|
135 |
|
136 TDCMOStatus CWLanCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue) |
|
137 { |
|
138 TDCMOStatus status( EDcmoSuccess ); |
|
139 |
|
140 switch(aId) |
|
141 { |
|
142 case EGroup: |
|
143 aValue = EConnectivity; |
|
144 break; |
|
145 case EAttached: |
|
146 aValue = EFalse; |
|
147 break; |
|
148 case EEnabled: |
|
149 aValue = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ); |
|
150 break; |
|
151 case EDenyUserEnable: |
|
152 aValue = EFalse; |
|
153 break; |
|
154 case ENotifyUser: |
|
155 aValue = ETrue; |
|
156 break; |
|
157 case EEnable: |
|
158 status = EDcmoAccessDenied; |
|
159 break; |
|
160 default: |
|
161 break; |
|
162 } |
|
163 |
|
164 return status; |
|
165 } |
|
166 |
|
167 TDCMOStatus CWLanCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL( TDCMONode /* aId */, |
|
168 const TDes& /* aStrValue */ ) |
|
169 { |
|
170 // Nothing to do |
|
171 TDCMOStatus status( EDcmoFail ); |
|
172 |
|
173 return status; |
|
174 } |
|
175 |
|
176 TDCMOStatus CWLanCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL( TDCMONode aId, TDes& aStrValue ) |
|
177 { |
|
178 TDCMOStatus status( EDcmoSuccess ); |
|
179 switch( aId ) |
|
180 { |
|
181 case EProperty: |
|
182 aStrValue = *iProperty; |
|
183 break; |
|
184 case EDescription: |
|
185 aStrValue = *iDescription; |
|
186 break; |
|
187 default: |
|
188 status = EDcmoNotFound; |
|
189 break; |
|
190 } |
|
191 |
|
192 return status; |
|
193 } |
|
194 |
|
195 void CWLanCtrlDCMOAdapter::GetLocalizedNameL( HBufC*& aLocName ) |
|
196 { |
|
197 TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath ); |
|
198 _LIT(KTextWLAN, "txt_device_update_info_wlan"); |
|
199 aLocName = HbTextResolverSymbian::LoadL(KTextWLAN); |
|
200 } |