1 /* |
|
2 * Copyright (c) 2005-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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "t_wlanmgmtclientdata.h" |
|
22 #include <wlanmgmtclient.h> |
|
23 #include <wdbifwlansettings.h> |
|
24 |
|
25 /*@{*/ |
|
26 //LIT's for Constant |
|
27 _LIT(KScanInfo, "scaninfo"); |
|
28 /*@}*/ |
|
29 |
|
30 /*@{*/ |
|
31 //LIT's for WlanMgmtClientData |
|
32 _LIT(KCmdInstantiateMgmtClient, "NewL"); |
|
33 _LIT(KCmdGetScanResults, "GetScanResults"); |
|
34 _LIT(KCmdDestructor, "~"); |
|
35 /*@}*/ |
|
36 |
|
37 |
|
38 /** |
|
39 * Two phase constructor |
|
40 * |
|
41 * @leave system wide error |
|
42 */ |
|
43 CT_WlanMgmtClientData* CT_WlanMgmtClientData::NewL() |
|
44 { |
|
45 CT_WlanMgmtClientData* ret = new (ELeave) CT_WlanMgmtClientData(); |
|
46 CleanupStack::PushL(ret); |
|
47 ret->ConstructL(); |
|
48 CleanupStack::Pop(ret); |
|
49 return ret; |
|
50 } |
|
51 |
|
52 /** |
|
53 * Public destructor |
|
54 */ |
|
55 CT_WlanMgmtClientData::~CT_WlanMgmtClientData() |
|
56 { |
|
57 DestroyData(); |
|
58 } |
|
59 |
|
60 /** |
|
61 * Private constructor. First phase construction |
|
62 */ |
|
63 CT_WlanMgmtClientData::CT_WlanMgmtClientData() |
|
64 : iData(NULL) |
|
65 { |
|
66 } |
|
67 |
|
68 /** |
|
69 * Second phase construction |
|
70 * |
|
71 * @internalComponent |
|
72 * |
|
73 * @return N/A |
|
74 * |
|
75 * @pre None |
|
76 * @post None |
|
77 * |
|
78 * @leave system wide error |
|
79 */ |
|
80 void CT_WlanMgmtClientData::ConstructL() |
|
81 { |
|
82 } |
|
83 |
|
84 /** |
|
85 * Return a pointer to the object that the data wraps |
|
86 * |
|
87 * @return pointer to the object that the data wraps |
|
88 */ |
|
89 TAny* CT_WlanMgmtClientData::GetObject() |
|
90 { |
|
91 return iData; |
|
92 } |
|
93 |
|
94 |
|
95 /** |
|
96 * Process a command read from the Ini file |
|
97 * @param aCommand The command to process |
|
98 * @param aSection The section get from the *.ini file of the project T_Wlan |
|
99 * @param aAsyncErrorIndex Command index dor async calls to returns errors to |
|
100 * @return TBool ETrue if the command is process |
|
101 * @leave system wide error |
|
102 */ |
|
103 TBool CT_WlanMgmtClientData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
104 { |
|
105 TBool ret = ETrue; |
|
106 if(aCommand == KCmdInstantiateMgmtClient) |
|
107 { |
|
108 DoCmdNewL(); |
|
109 } |
|
110 else if(aCommand == KCmdGetScanResults) |
|
111 { |
|
112 DoCmdGetScanResults(aSection); |
|
113 } |
|
114 else if(aCommand == KCmdDestructor) |
|
115 { |
|
116 DoCmdDestructor(); |
|
117 } |
|
118 else |
|
119 { |
|
120 ERR_PRINTF1(_L("Unknown command.")); |
|
121 ret = EFalse; |
|
122 } |
|
123 return ret; |
|
124 } |
|
125 |
|
126 |
|
127 /** |
|
128 * Creates an Instance of CWlanMgmtClient |
|
129 * @param |
|
130 * @return |
|
131 */ |
|
132 void CT_WlanMgmtClientData::DoCmdNewL() |
|
133 { |
|
134 INFO_PRINTF1(_L("*START* CT_WlanMgmtClientData::DoCmdNewL")); |
|
135 |
|
136 DestroyData(); |
|
137 |
|
138 TRAPD(err,iData = CWlanMgmtClient::NewL()); |
|
139 if(err != KErrNone) |
|
140 { |
|
141 ERR_PRINTF2(_L("CWlanMgmtClient was not constructed, err=%d" ),err); |
|
142 SetError(err); |
|
143 } |
|
144 |
|
145 INFO_PRINTF1(_L("*END* CT_WlanMgmtClientData::DoCmdNewL")); |
|
146 } |
|
147 |
|
148 |
|
149 /** |
|
150 * Test getting Wlan scan info from Wlan management interface. Call |
|
151 * DoCmdNewL for instantiate the CWlanMgmtClient and DoCmdNewL of CWlanScanInfo first. |
|
152 * @param aSection Section to read from the ini file |
|
153 * @return |
|
154 */ |
|
155 void CT_WlanMgmtClientData::DoCmdGetScanResults(const TTEFSectionName& aSection) |
|
156 { |
|
157 INFO_PRINTF1(_L("*START* CT_WlanMgmtClientData::DoCmdGetScanResults")); |
|
158 TBool dataOk = ETrue; |
|
159 |
|
160 TPtrC scanInfoName; |
|
161 if(!GetStringFromConfig(aSection, KScanInfo, scanInfoName)) |
|
162 { |
|
163 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KScanInfo); |
|
164 SetBlockResult(EFail); |
|
165 dataOk = EFalse; |
|
166 } |
|
167 |
|
168 if (dataOk) |
|
169 { |
|
170 CWlanScanInfo* iScanInfo = static_cast<CWlanScanInfo*>(GetDataObjectL(scanInfoName)); |
|
171 if ( iScanInfo != NULL ) |
|
172 { |
|
173 TInt err = iData->GetScanResults( *iScanInfo ) ; |
|
174 if(err == KErrNone) |
|
175 { |
|
176 INFO_PRINTF2(_L("iScanInfo size [%d]"),iScanInfo->Size()); |
|
177 } |
|
178 else |
|
179 { |
|
180 ERR_PRINTF2(_L("iData->GetScanResults( *iScanInfo ) Failed with error %d"), err); |
|
181 SetError(err); |
|
182 } |
|
183 } |
|
184 else |
|
185 { |
|
186 ERR_PRINTF1(_L("iScanInfo is NULL")); |
|
187 SetBlockResult(EFail); |
|
188 } |
|
189 } |
|
190 |
|
191 INFO_PRINTF1(_L("*END* CT_WlanMgmtClientData::DoCmdGetScanResults")); |
|
192 } |
|
193 |
|
194 /** |
|
195 * Destructor for CWlanMgmtClient |
|
196 * @param |
|
197 * @return |
|
198 */ |
|
199 void CT_WlanMgmtClientData::DoCmdDestructor() |
|
200 { |
|
201 INFO_PRINTF1(_L("*START* CT_WlanMgmtClientData::DoCmdDestructor")); |
|
202 DestroyData(); |
|
203 INFO_PRINTF1(_L("*END* CT_WlanMgmtClientData::DoCmdDestructor")); |
|
204 } |
|
205 |
|
206 /** |
|
207 * Destroy the object of CWlanMgmtClient, call made from DoCmdDestructor() |
|
208 * @param |
|
209 * @return |
|
210 */ |
|
211 void CT_WlanMgmtClientData::DestroyData() |
|
212 { |
|
213 if(iData) |
|
214 { |
|
215 delete iData; |
|
216 iData = NULL; |
|
217 } |
|
218 } |
|