5
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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 the License "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: CSysinfoInterface class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
//INCLUDES
|
|
19 |
#include <e32math.h>
|
|
20 |
#include <liwcommon.h>
|
|
21 |
#include <liwgenericparam.h>
|
|
22 |
#include <NumberConversion.h>
|
|
23 |
#include <PtiEngine.h>
|
|
24 |
|
|
25 |
#include "errormsgs.h"
|
|
26 |
#include "sysinfointerface.h"
|
|
27 |
#include "sysinfoservice.h"
|
|
28 |
#include "sysinfoobserver.h"
|
|
29 |
#include "../../inc/serviceerrno.h"
|
|
30 |
#include "sysinfoaiwparams.hrh"
|
|
31 |
#include "sysinfocallbackmap.h"
|
|
32 |
#include "sysinfolists.h"
|
|
33 |
|
|
34 |
|
|
35 |
using namespace LIW;
|
|
36 |
using namespace sysinfoaiwparams;
|
|
37 |
|
|
38 |
const TUint KMax64BitNumLen(24);
|
|
39 |
const TInt KMaxVersionTxt = 10;
|
|
40 |
const TInt KMinArgumentCount = 2;
|
|
41 |
const TInt KMaxCommandName = 32;
|
|
42 |
|
|
43 |
_LIT(KDriveSeperator,":\\");
|
|
44 |
const TInt KMaxDriveLength = 5;
|
|
45 |
|
|
46 |
// ============================ MEMBER FUNCTIONS =============================
|
|
47 |
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// CSysInfoInterface::NewL()
|
|
50 |
// Two-phased constructor.
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CSysInfoInterface* CSysInfoInterface::NewL()
|
|
54 |
{
|
|
55 |
CSysInfoInterface* self = new (ELeave) CSysInfoInterface();
|
|
56 |
CleanupStack::PushL(self);
|
|
57 |
self->ConstructL();
|
|
58 |
CleanupStack::Pop(self);
|
|
59 |
return self;
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// CSysInfoInterface::~CSysInfoInterface()
|
|
64 |
// Destructor.
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CSysInfoInterface::~CSysInfoInterface()
|
|
68 |
{
|
|
69 |
delete iService;
|
|
70 |
delete iObserver;
|
|
71 |
TInt count = iCallbackMap.Count();
|
|
72 |
for ( TInt i = 0; i < count; ++i )
|
|
73 |
{
|
|
74 |
delete(iCallbackMap[i]);
|
|
75 |
}
|
|
76 |
iCallbackMap.Close();
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// CSysInfoInterface::CSysInfoInterface()
|
|
81 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
CSysInfoInterface::CSysInfoInterface()
|
|
85 |
{
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// CLandmarkFilter::ConstructL()
|
|
90 |
// Symbian 2nd phase constructor can leave.
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CSysInfoInterface::ConstructL()
|
|
94 |
{
|
|
95 |
//instantiate the service class
|
|
96 |
iService = CSysInfoService::NewL();
|
|
97 |
//instantiate observer to handle async requests.
|
|
98 |
iObserver = CSysInfoObserver::NewL(this);
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// CSysInfoInterface::ExecuteCmdL( const TDesC8& aCmdName,
|
|
103 |
// const CLiwGenericParamList& aInParamList,
|
|
104 |
// CLiwGenericParamList& aOutParamList,
|
|
105 |
// TUint aCmdOptions,
|
|
106 |
// MLiwNotifyCallback* aCallback )
|
|
107 |
// This function is called by the user to handle the service commands.
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CSysInfoInterface::ExecuteCmdL( const TDesC8& aCmdName,
|
|
111 |
const CLiwGenericParamList& aInParamList,
|
|
112 |
CLiwGenericParamList& aOutParamList,
|
|
113 |
TUint aCmdOptions,
|
|
114 |
MLiwNotifyCallback* aCallback )
|
|
115 |
{
|
|
116 |
TInt err(KErrNone);
|
|
117 |
iErrBuf.FillZ(0);
|
|
118 |
iErrBuf.Append(KModuleName);
|
|
119 |
TBuf<KMaxCommandName> CommandName;
|
|
120 |
if( aCmdName.Length() < KMaxCommandName )
|
|
121 |
{
|
|
122 |
CommandName.Copy( aCmdName );
|
|
123 |
iErrBuf.Append(CommandName);
|
|
124 |
iErrBuf.Append(KColon);
|
|
125 |
|
|
126 |
//check if any of the service API's leave
|
|
127 |
TRAP(err,SwitchCmdL(aCmdName,aInParamList,aOutParamList,
|
|
128 |
aCmdOptions,aCallback));
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
err = SErrInvalidServiceArgument;
|
|
133 |
iErrBuf.Append(SErrInvalidServiceArgument);
|
|
134 |
}
|
|
135 |
|
|
136 |
TInt SapiErr = SErrNone;
|
|
137 |
if (err)
|
|
138 |
{
|
|
139 |
aOutParamList.AppendL(TLiwGenericParam( KErrorMsg, TLiwVariant(iErrBuf)));
|
|
140 |
SapiErr = SapiError(err);
|
|
141 |
}
|
|
142 |
|
|
143 |
aOutParamList.AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)SapiErr)));
|
|
144 |
}
|
|
145 |
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
// CSysInfoInterface::SapiError( )
|
|
148 |
// This function is called by the user to get mapped SAPI generic error code
|
|
149 |
// from symbian error codes .
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TInt CSysInfoInterface::SapiError( TInt aSymbianErr )
|
|
153 |
{
|
|
154 |
TInt sapiErr(SErrGeneralError);
|
|
155 |
|
|
156 |
switch (aSymbianErr)
|
|
157 |
{
|
|
158 |
case KErrBadName:
|
|
159 |
case KErrArgument:
|
|
160 |
{
|
|
161 |
sapiErr = SErrBadArgumentType;
|
|
162 |
break;
|
|
163 |
}
|
|
164 |
case KErrLanguageNotFound:
|
|
165 |
case KErrNotSupported:
|
|
166 |
{
|
|
167 |
sapiErr = SErrServiceNotSupported;
|
|
168 |
break;
|
|
169 |
}
|
|
170 |
case KErrInUse:
|
|
171 |
{
|
|
172 |
sapiErr = SErrServiceInUse;
|
|
173 |
break;
|
|
174 |
}
|
|
175 |
case KErrAccessDenied:
|
|
176 |
{
|
|
177 |
sapiErr = SErrAccessDenied;
|
|
178 |
break;
|
|
179 |
}
|
|
180 |
case KErrAlreadyExists:
|
|
181 |
{
|
|
182 |
sapiErr = SErrEntryExists;
|
|
183 |
break;
|
|
184 |
}
|
|
185 |
case KErrNotReady:
|
|
186 |
{
|
|
187 |
sapiErr = SErrServiceNotReady;
|
|
188 |
break;
|
|
189 |
}
|
|
190 |
case KErrNotFound:
|
|
191 |
{
|
|
192 |
sapiErr = SErrNotFound;
|
|
193 |
break;
|
|
194 |
}
|
|
195 |
case KErrPathNotFound:
|
|
196 |
{
|
|
197 |
sapiErr = SErrPathNotFound;
|
|
198 |
break;
|
|
199 |
}
|
|
200 |
case SErrMissingArgument:
|
|
201 |
{
|
|
202 |
sapiErr = SErrMissingArgument;
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
case SErrInvalidServiceArgument:
|
|
206 |
{
|
|
207 |
sapiErr = SErrInvalidServiceArgument;
|
|
208 |
break;
|
|
209 |
}
|
|
210 |
}
|
|
211 |
return sapiErr;
|
|
212 |
}
|
|
213 |
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
// CSysInfoInterface::Close( )
|
|
216 |
// This function is called by the user to close the interface.
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void CSysInfoInterface::Close()
|
|
220 |
{
|
|
221 |
delete this;
|
|
222 |
}
|
|
223 |
|
|
224 |
// ---------------------------------------------------------------------------
|
|
225 |
// CSysInfoInterface::GetCallbackAndRemove( TInt32 aTransactionId )
|
|
226 |
// This function returns the callback for the given transaction id and
|
|
227 |
// removes it from the list.
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
MLiwNotifyCallback* CSysInfoInterface::GetCallbackAndRemove( TInt32 aTransactionId )
|
|
231 |
{
|
|
232 |
TInt count = iCallbackMap.Count();
|
|
233 |
for ( TInt i = 0; i < count; ++i )
|
|
234 |
{
|
|
235 |
MLiwNotifyCallback* callback;
|
|
236 |
if ( iCallbackMap[i]->Get(aTransactionId,callback) )
|
|
237 |
{
|
|
238 |
delete(iCallbackMap[i]);
|
|
239 |
iCallbackMap.Remove(i);
|
|
240 |
return callback;
|
|
241 |
}
|
|
242 |
}
|
|
243 |
return NULL;
|
|
244 |
}
|
|
245 |
|
|
246 |
// ---------------------------------------------------------------------------
|
|
247 |
// CSysInfoInterface::GetCallback( TInt32 aTransactionId )
|
|
248 |
// This function returns the callback for the given transaction id
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
MLiwNotifyCallback* CSysInfoInterface::GetCallback( TInt32 aTransactionId )
|
|
252 |
{
|
|
253 |
TInt count = iCallbackMap.Count();
|
|
254 |
for ( TInt i = 0; i < count; ++i )
|
|
255 |
{
|
|
256 |
MLiwNotifyCallback* callback;
|
|
257 |
if ( iCallbackMap[i]->Get(aTransactionId,callback) )
|
|
258 |
{
|
|
259 |
return callback;
|
|
260 |
}
|
|
261 |
}
|
|
262 |
return NULL;
|
|
263 |
}
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
// CSysInfoInterface::SwitchCmdL( const TDesC8& aCmdName,
|
|
267 |
// const CLiwGenericParamList& aInParamList,
|
|
268 |
// CLiwGenericParamList& aOutParamList,
|
|
269 |
// TUint aCmdOptions,
|
|
270 |
// MLiwNotifyCallback* aCallback )
|
|
271 |
// This function calls the appropriate functions based on the command id.
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CSysInfoInterface::SwitchCmdL( const TDesC8& aCmdName,
|
|
275 |
const CLiwGenericParamList& aInParamList,
|
|
276 |
CLiwGenericParamList& aOutParamList,
|
|
277 |
TUint aCmdOptions,
|
|
278 |
MLiwNotifyCallback* aCallback )
|
|
279 |
{
|
|
280 |
if ( ( (KLiwOptASyncronous & aCmdOptions) && !aCallback) ||
|
|
281 |
( !((KLiwOptASyncronous|KLiwOptCancel) & aCmdOptions) && aCallback) )
|
|
282 |
|
|
283 |
{
|
|
284 |
iErrBuf.Append(KErrInCorrectSyncAsyncRequest);
|
|
285 |
User::Leave(KErrArgument);
|
|
286 |
}
|
|
287 |
|
|
288 |
if ( aCmdName == KCancel && (KLiwOptCancel & aCmdOptions) )
|
|
289 |
{
|
|
290 |
CancelL (aInParamList, aOutParamList, aCmdOptions, aCallback );
|
|
291 |
}
|
|
292 |
else if ( !aCmdName.Compare(KGetInfo) )
|
|
293 |
{
|
|
294 |
GetInfoL(aInParamList,aOutParamList,aCmdOptions,aCallback);
|
|
295 |
}
|
|
296 |
else if ( !aCmdName.Compare(KSetInfo) )
|
|
297 |
{
|
|
298 |
if( aCallback )
|
|
299 |
{
|
|
300 |
iErrBuf.Append(KErrASyncVersionNotSupported);
|
|
301 |
User::Leave(KErrArgument);
|
|
302 |
}
|
|
303 |
SetInfoL(aInParamList);
|
|
304 |
}
|
|
305 |
else if ( !aCmdName.Compare(KGetNotification) )
|
|
306 |
{
|
|
307 |
if( !aCallback )
|
|
308 |
{
|
|
309 |
iErrBuf.Append(KErrSyncVersionNotSupported);
|
|
310 |
User::Leave(KErrArgument);
|
|
311 |
}
|
|
312 |
GetNotificationL(aInParamList,aOutParamList,aCmdOptions,aCallback);
|
|
313 |
}
|
|
314 |
else
|
|
315 |
{
|
|
316 |
// invalid command return error in outparam list
|
|
317 |
iErrBuf.Append(KErrCmdNotSupported);
|
|
318 |
User::Leave(KErrNotSupported);
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
// CSysInfoInterface::SetInfoL( const TDesC8& aCmdName,
|
|
324 |
// const CLiwGenericParamList& aInParamList,
|
|
325 |
// CLiwGenericParamList& aOutParamList,
|
|
326 |
// TUint aCmdOptions,
|
|
327 |
// MLiwNotifyCallback* aCallback )
|
|
328 |
// This function reads input params and calls core class SetInfoL function.
|
|
329 |
// ---------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
void CSysInfoInterface::SetInfoL(const CLiwGenericParamList& aInParamList)
|
|
332 |
{
|
|
333 |
TPtrC entity,key;
|
|
334 |
CSysData* insysdata=NULL;
|
|
335 |
|
|
336 |
ReadInputParamsL(aInParamList,entity,key,insysdata);
|
|
337 |
//insysdata must be specified for setinfo operation.
|
|
338 |
if(!insysdata)
|
|
339 |
{
|
|
340 |
iErrBuf.Append(KErrSystemDataMissing);
|
|
341 |
User::Leave(SErrMissingArgument);
|
|
342 |
}
|
|
343 |
|
|
344 |
CleanupStack::PushL(insysdata);
|
|
345 |
iService->SetInfoL(entity,key,insysdata);
|
|
346 |
CleanupStack::PopAndDestroy(insysdata);
|
|
347 |
}
|
|
348 |
|
|
349 |
// ---------------------------------------------------------------------------
|
|
350 |
// CLandmarkInterface::GetInfoL(const CLiwGenericParamList& aInParamList,
|
|
351 |
// CLiwGenericParamList& aOutParamList,
|
|
352 |
// TUint aCmdOptions,
|
|
353 |
// MLiwNotifyCallback* aCallback )
|
|
354 |
// This function parses input params and calls sync/async version of
|
|
355 |
// core class GetInfoL function.
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
void CSysInfoInterface::GetInfoL( const CLiwGenericParamList& aInParamList,
|
|
359 |
CLiwGenericParamList& aOutParamList,
|
|
360 |
TUint /*aCmdOptions*/,
|
|
361 |
MLiwNotifyCallback* aCallback )
|
|
362 |
{
|
|
363 |
TPtrC entity,key;
|
|
364 |
CSysData* insysdata=NULL;
|
|
365 |
//Get entity,key and insysdata.
|
|
366 |
ReadInputParamsL(aInParamList,entity,key,insysdata);
|
|
367 |
CleanupStack::PushL(insysdata);
|
|
368 |
|
|
369 |
//Async Call
|
|
370 |
if ( aCallback )
|
|
371 |
{
|
|
372 |
//Get the transaction ID
|
|
373 |
TInt32 transactionId(aCallback->GetTransactionID());
|
|
374 |
|
|
375 |
CSysInfoCallbackMap* map = new (ELeave) CSysInfoCallbackMap(transactionId,aCallback);
|
|
376 |
CleanupStack::PushL(map);
|
|
377 |
iCallbackMap.AppendL(map);
|
|
378 |
CleanupStack::Pop(map);
|
|
379 |
iService->GetInfoL(entity,key,transactionId,iObserver,insysdata);
|
|
380 |
aOutParamList.AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(TInt32(transactionId))));
|
|
381 |
}
|
|
382 |
else
|
|
383 |
{
|
|
384 |
CSysData* outsysdata = NULL;
|
|
385 |
iService->GetInfoL(entity,key,outsysdata,insysdata);
|
|
386 |
//after this call outsysdata shouldn't be NULL.
|
|
387 |
if(!outsysdata)
|
|
388 |
{
|
|
389 |
iErrBuf.Append(KErrReadingGetInfo);
|
|
390 |
User::Leave(SErrGeneralError);
|
|
391 |
}
|
|
392 |
|
|
393 |
CleanupStack::PushL(outsysdata);
|
|
394 |
//convert outsysdata into a liwmap.
|
|
395 |
CLiwMap* outmapparam=NULL;
|
|
396 |
CSysInfoInterface::ConvertSysData2AiwParamL(outsysdata,outmapparam);
|
|
397 |
|
|
398 |
if((outsysdata->DataType() == CSysData::EAccessoryList) ||
|
|
399 |
(outsysdata->DataType() == CSysData::EConnectionList))
|
|
400 |
CleanupStack::Pop(outsysdata);
|
|
401 |
else
|
|
402 |
CleanupStack::PopAndDestroy(outsysdata);
|
|
403 |
|
|
404 |
CleanupClosePushL(*outmapparam);
|
|
405 |
// append entity and key.
|
|
406 |
outmapparam->InsertL(KEntity,entity);
|
|
407 |
outmapparam->InsertL(KKey,key);
|
|
408 |
aOutParamList.AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(outmapparam)));
|
|
409 |
CleanupStack::PopAndDestroy(outmapparam);
|
|
410 |
}
|
|
411 |
CleanupStack::PopAndDestroy(insysdata);
|
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
// CLandmarkInterface::GetNotificationL(const CLiwGenericParamList& aInParamList,
|
|
416 |
// CLiwGenericParamList& aOutParamList,
|
|
417 |
// TUint aCmdOptions,
|
|
418 |
// MLiwNotifyCallback* aCallback )
|
|
419 |
// This function parses input params and calls core class GetNotificationL
|
|
420 |
// function.
|
|
421 |
// ---------------------------------------------------------------------------
|
|
422 |
//
|
|
423 |
void CSysInfoInterface::GetNotificationL( const CLiwGenericParamList& aInParamList,
|
|
424 |
CLiwGenericParamList& aOutParamList,
|
|
425 |
TUint /*aCmdOptions*/,
|
|
426 |
MLiwNotifyCallback* aCallback )
|
|
427 |
{
|
|
428 |
TPtrC entity,key;
|
|
429 |
CSysData* insysdata=NULL;
|
|
430 |
|
|
431 |
ReadInputParamsL(aInParamList,entity,key,insysdata);
|
|
432 |
CleanupStack::PushL(insysdata);
|
|
433 |
|
|
434 |
//Get the transaction ID
|
|
435 |
TInt32 transactionId(aCallback->GetTransactionID());
|
|
436 |
|
|
437 |
CSysInfoCallbackMap* map = new (ELeave) CSysInfoCallbackMap(transactionId,aCallback);
|
|
438 |
CleanupStack::PushL(map);
|
|
439 |
iCallbackMap.AppendL(map);
|
|
440 |
CleanupStack::Pop(map);
|
|
441 |
|
|
442 |
iService->GetNotificationL(entity,key,transactionId,iObserver,insysdata);
|
|
443 |
aOutParamList.AppendL(TLiwGenericParam(KTransactionId,TLiwVariant(TInt32(transactionId))));
|
|
444 |
|
|
445 |
CleanupStack::PopAndDestroy(insysdata);
|
|
446 |
}
|
|
447 |
|
|
448 |
// ---------------------------------------------------------------------------
|
|
449 |
// CLandmarkInterface::ReadInputParamsL(const CLiwGenericParamList& aInParamList,
|
|
450 |
// TPtrC& aEntity,TPtrC& aKey,
|
|
451 |
// const CSysData*& aSysData)
|
|
452 |
// This function parses input params.
|
|
453 |
// ---------------------------------------------------------------------------
|
|
454 |
//
|
|
455 |
void CSysInfoInterface::ReadInputParamsL(const CLiwGenericParamList& aInParamList,
|
|
456 |
TPtrC& aEntity,TPtrC& aKey,
|
|
457 |
CSysData*& aSysData)
|
|
458 |
{
|
|
459 |
aSysData = NULL;
|
|
460 |
//position to start search in input params.
|
|
461 |
TInt index = 0;
|
|
462 |
//Atleast Entity Key must be specified in input list.
|
|
463 |
if ( aInParamList.Count() < KMinArgumentCount )
|
|
464 |
{
|
|
465 |
//leave since argument is improper
|
|
466 |
iErrBuf.Append(KErrInsufficientArgs);
|
|
467 |
User::Leave(SErrMissingArgument);
|
|
468 |
}
|
|
469 |
|
|
470 |
const TLiwGenericParam* param = &aInParamList[EIndex0];
|
|
471 |
|
|
472 |
if ( param->Name() == KNullDesC8 )
|
|
473 |
{
|
|
474 |
//Position based parsing
|
|
475 |
aEntity.Set(aInParamList[EIndex0].Value().AsDes());
|
|
476 |
if(!(aEntity.Length()))
|
|
477 |
{
|
|
478 |
iErrBuf.Append(KErrEntityMissing);
|
|
479 |
User::Leave(SErrMissingArgument);
|
|
480 |
}
|
|
481 |
|
|
482 |
aKey.Set(aInParamList[EIndex1].Value().AsDes());
|
|
483 |
if(!(aKey.Length()))
|
|
484 |
{
|
|
485 |
iErrBuf.Append(KErrKeyMissing);
|
|
486 |
User::Leave(SErrMissingArgument);
|
|
487 |
}
|
|
488 |
|
|
489 |
if( aInParamList.Count()>KMinArgumentCount )
|
|
490 |
{
|
|
491 |
const TLiwGenericParam aInputData = aInParamList[EIndex2];
|
|
492 |
Convert2SysDataL(aInputData,aSysData);
|
|
493 |
}
|
|
494 |
}
|
|
495 |
else
|
|
496 |
{
|
|
497 |
//Name based parsing
|
|
498 |
//check for Entity.
|
|
499 |
index = 0;
|
|
500 |
param = aInParamList.FindFirst(index,KEntity);
|
|
501 |
if( param )
|
|
502 |
{
|
|
503 |
aEntity.Set(param->Value().AsDes());
|
|
504 |
}
|
|
505 |
else
|
|
506 |
{
|
|
507 |
iErrBuf.Append(KErrEntityMissing);
|
|
508 |
User::Leave(SErrMissingArgument);
|
|
509 |
}
|
|
510 |
|
|
511 |
//check for Key.
|
|
512 |
index = 0;
|
|
513 |
param = aInParamList.FindFirst(index,KKey);
|
|
514 |
if(param)
|
|
515 |
{
|
|
516 |
aKey.Set(param->Value().AsDes());
|
|
517 |
}
|
|
518 |
else
|
|
519 |
{
|
|
520 |
iErrBuf.Append(KErrKeyMissing);
|
|
521 |
User::Leave(SErrMissingArgument);
|
|
522 |
}
|
|
523 |
//check for SysData.
|
|
524 |
index = 0;
|
|
525 |
const TLiwGenericParam* aInputData = aInParamList.FindFirst(index,KSysData);
|
|
526 |
if(aInputData)
|
|
527 |
{
|
|
528 |
Convert2SysDataL(*aInputData,aSysData);
|
|
529 |
}
|
|
530 |
}
|
|
531 |
}
|
|
532 |
|
|
533 |
// ---------------------------------------------------------------------------
|
|
534 |
// CLandmarkInterface::Convert2SysDataL(const CLiwGenericParamList& aInParamList,
|
|
535 |
// const CSysData*& aSysData)
|
|
536 |
// This function converts aiw param to CSysData.
|
|
537 |
// ---------------------------------------------------------------------------
|
|
538 |
//
|
|
539 |
void CSysInfoInterface::Convert2SysDataL(const TLiwGenericParam& aInputParam,
|
|
540 |
CSysData*& aSysData)
|
|
541 |
{
|
|
542 |
aSysData = NULL;
|
|
543 |
const CLiwMap* inmap = aInputParam.Value().AsMap();
|
|
544 |
|
|
545 |
if( !inmap )
|
|
546 |
{
|
|
547 |
iErrBuf.Append(KErrSysdataType);
|
|
548 |
User::Leave(KErrArgument);
|
|
549 |
}
|
|
550 |
|
|
551 |
TLiwVariant indata;
|
|
552 |
// check status information.
|
|
553 |
if( inmap->FindL(KStatus,indata) )
|
|
554 |
{
|
|
555 |
if( indata.TypeId() == EVariantTypeTInt32 )
|
|
556 |
{
|
|
557 |
aSysData = CStatus::NewL(indata.AsTInt32());
|
|
558 |
}
|
|
559 |
else
|
|
560 |
{
|
|
561 |
indata.Reset();
|
|
562 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
563 |
User::Leave(KErrArgument);
|
|
564 |
}
|
|
565 |
}
|
|
566 |
//check Drive information.
|
|
567 |
else if( inmap->FindL(KDriveNo,indata) )
|
|
568 |
{
|
|
569 |
if( indata.TypeId() == EVariantTypeDesC )
|
|
570 |
{
|
|
571 |
TPtrC Path;
|
|
572 |
indata.Get(Path);
|
|
573 |
|
|
574 |
//expected syntax for drive.
|
|
575 |
//[drivename][driveseperator]rest of the path.
|
|
576 |
//Ex.c:\\Others
|
|
577 |
const TInt KDriveLength(1);
|
|
578 |
|
|
579 |
TInt32 driveno(0);
|
|
580 |
TInt offset = Path.Find(KDriveSeperator);
|
|
581 |
if ( KErrNotFound == offset )
|
|
582 |
{
|
|
583 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
584 |
indata.Reset();
|
|
585 |
User::Leave(KErrArgument);
|
|
586 |
}
|
|
587 |
else
|
|
588 |
{
|
|
589 |
if( offset == KDriveLength )
|
|
590 |
{
|
|
591 |
TPtrC Drive(Path.Left(offset));
|
|
592 |
TChar DriveLetter = Drive[0];
|
|
593 |
if( !DriveLetter.IsAlpha() )
|
|
594 |
{
|
|
595 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
596 |
indata.Reset();
|
|
597 |
User::Leave(KErrArgument);
|
|
598 |
}
|
|
599 |
DriveLetter.GetUpperCase();
|
|
600 |
driveno = DriveLetter.GetUpperCase() - 'A';
|
|
601 |
}
|
|
602 |
else
|
|
603 |
{
|
|
604 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
605 |
indata.Reset();
|
|
606 |
User::Leave(KErrArgument);
|
|
607 |
}
|
|
608 |
}
|
|
609 |
// Check if critical space is specified.
|
|
610 |
if ( inmap->FindL(KCriticalSpace,indata) )
|
|
611 |
{
|
|
612 |
if( indata.TypeId() == EVariantTypeTInt32 )
|
|
613 |
{
|
|
614 |
TInt32 criticalspace = indata.AsTInt32();
|
|
615 |
aSysData = CDriveInfo::NewL(driveno,criticalspace);
|
|
616 |
}
|
|
617 |
else
|
|
618 |
{
|
|
619 |
indata.Reset();
|
|
620 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
621 |
User::Leave(KErrArgument);
|
|
622 |
}
|
|
623 |
}
|
|
624 |
else
|
|
625 |
{
|
|
626 |
aSysData = CDriveInfo::NewL(driveno);
|
|
627 |
}
|
|
628 |
}
|
|
629 |
else
|
|
630 |
{
|
|
631 |
indata.Reset();
|
|
632 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
633 |
User::Leave(KErrArgument);
|
|
634 |
}
|
|
635 |
}
|
|
636 |
//check for string data.
|
|
637 |
else if( inmap->FindL(KStringData,indata) )
|
|
638 |
{
|
|
639 |
if( indata.TypeId() == EVariantTypeDesC )
|
|
640 |
{
|
|
641 |
aSysData = CStringData::NewL(indata.AsDes());
|
|
642 |
}
|
|
643 |
else
|
|
644 |
{
|
|
645 |
indata.Reset();
|
|
646 |
iErrBuf.Append(KErrSystemAttributeValue);
|
|
647 |
User::Leave(KErrArgument);
|
|
648 |
}
|
|
649 |
}
|
|
650 |
//Unsupported input data.
|
|
651 |
else
|
|
652 |
{
|
|
653 |
iErrBuf.Append(KErrUnsupportedInput);
|
|
654 |
User::Leave(SErrMissingArgument);
|
|
655 |
}
|
|
656 |
indata.Reset();
|
|
657 |
}
|
|
658 |
|
|
659 |
// ---------------------------------------------------------------------------
|
|
660 |
// CLandmarkInterface::ConvertSysData2AiwParamL(const CLiwGenericParamList&
|
|
661 |
// aInParamList, CLiwMap*& aOutMapParam)
|
|
662 |
// This function converts CSysData to aiw param.
|
|
663 |
// ---------------------------------------------------------------------------
|
|
664 |
//
|
|
665 |
void CSysInfoInterface::ConvertSysData2AiwParamL(const CSysData* aInSysData,
|
|
666 |
CLiwMap*& aOutMapParam)
|
|
667 |
{
|
|
668 |
aOutMapParam = CLiwDefaultMap::NewL();
|
|
669 |
CleanupClosePushL(*aOutMapParam);
|
|
670 |
TInt count = 0;
|
|
671 |
switch (aInSysData->DataType())
|
|
672 |
{
|
|
673 |
case CSysData::EStatus:
|
|
674 |
{
|
|
675 |
TInt32 status = ((CStatus*) aInSysData)->Status();
|
|
676 |
aOutMapParam->InsertL(KStatus,(TInt32)status);
|
|
677 |
}
|
|
678 |
break;
|
|
679 |
case CSysData::EVersion:
|
|
680 |
{
|
|
681 |
TBuf<KMaxVersionTxt> majortxt(KNullDesC);
|
|
682 |
TBuf<KMaxVersionTxt> minortxt(KNullDesC);
|
|
683 |
majortxt.FillZ(0);
|
|
684 |
minortxt.FillZ(0);
|
|
685 |
const CVersion* version = (CVersion*) aInSysData;
|
|
686 |
NumberConversion::AppendFormatNumber (majortxt,
|
|
687 |
version->MajorVersion(),EDigitTypeWestern);
|
|
688 |
aOutMapParam->InsertL(KMajorVersion,majortxt);
|
|
689 |
NumberConversion::AppendFormatNumber (minortxt,
|
|
690 |
version->MinorVersion(),EDigitTypeWestern);
|
|
691 |
aOutMapParam->InsertL(KMinorVersion,minortxt);
|
|
692 |
}
|
|
693 |
break;
|
|
694 |
case CSysData::EConnectionList:
|
|
695 |
{
|
|
696 |
CConnectionList* dataconnections = (CConnectionList*) aInSysData;
|
|
697 |
CSysInfoConnList* connlist = CSysInfoConnList::NewL(dataconnections);
|
|
698 |
CleanupClosePushL(*connlist);
|
|
699 |
aOutMapParam->InsertL(KConnectionList,connlist);
|
|
700 |
CleanupStack::PopAndDestroy(connlist);
|
|
701 |
}
|
|
702 |
break;
|
|
703 |
case CSysData::ENetworkInfo:
|
|
704 |
{
|
|
705 |
const CNetworkInfo* networkinfo = (CNetworkInfo*) aInSysData;
|
|
706 |
aOutMapParam->InsertL(KNetworkName,networkinfo->NetworkName());
|
|
707 |
aOutMapParam->InsertL(KNetworkStatus,
|
|
708 |
(TInt32)networkinfo->NetworkStatus());
|
|
709 |
aOutMapParam->InsertL(KNetworkMode,(TInt32)networkinfo->NetworkMode());
|
|
710 |
aOutMapParam->InsertL(KCountryCode,networkinfo->CountryCode());
|
|
711 |
aOutMapParam->InsertL(KNetworkCode,networkinfo->NetworkCode());
|
|
712 |
aOutMapParam->InsertL(KLocationStatus,
|
|
713 |
networkinfo->ValidLocationAreaCode());
|
|
714 |
aOutMapParam->InsertL(KAreaCode,(TInt32)networkinfo->LocationAreaCode());
|
|
715 |
aOutMapParam->InsertL(KCellId,(TInt32)networkinfo->CellId());
|
|
716 |
}
|
|
717 |
break;
|
|
718 |
case CSysData::EConnectionInfo:
|
|
719 |
{
|
|
720 |
const CConnectionInfo* connectioninfo =
|
|
721 |
((CConnectionInfo*) aInSysData);
|
|
722 |
aOutMapParam->InsertL(KIAPID,(TInt32)connectioninfo->IAPId());
|
|
723 |
aOutMapParam->InsertL(KIAPName,connectioninfo->IAPName());
|
|
724 |
aOutMapParam->InsertL(KIAPConnectionName,
|
|
725 |
connectioninfo->ConnectionName());
|
|
726 |
aOutMapParam->InsertL(KNetworkName,connectioninfo->NetworkName());
|
|
727 |
aOutMapParam->InsertL(KConnectionType,
|
|
728 |
(TInt32)connectioninfo->BearerType());
|
|
729 |
aOutMapParam->InsertL(KConnectionStatus,
|
|
730 |
(TInt32)connectioninfo->ConnectionState());
|
|
731 |
}
|
|
732 |
break;
|
|
733 |
case CSysData::EDriveInfo:
|
|
734 |
{
|
|
735 |
const CDriveInfo* driveinfo = (CDriveInfo*) aInSysData;
|
|
736 |
|
|
737 |
TBuf<KMaxDriveLength> drive;
|
|
738 |
drive.FillZ();
|
|
739 |
drive.Append('A'+driveinfo->DriveNumber());
|
|
740 |
drive.Append(KDriveSeperator);
|
|
741 |
|
|
742 |
aOutMapParam->InsertL(KDriveNo,drive);
|
|
743 |
aOutMapParam->InsertL(KCriticalSpace,
|
|
744 |
(TInt32)driveinfo->CriticalSpace());
|
|
745 |
aOutMapParam->InsertL(KMediaType,(TInt32)driveinfo->MediaType());
|
|
746 |
//totalspace and freespace converted to string .
|
|
747 |
TBuf<KMax64BitNumLen> string64bitnum(KNullDesC);
|
|
748 |
string64bitnum.FillZ(0);
|
|
749 |
string64bitnum.Num(driveinfo->TotalSpace());
|
|
750 |
aOutMapParam->InsertL(KTotalSpace,string64bitnum);
|
|
751 |
string64bitnum.FillZ(0);
|
|
752 |
string64bitnum.Num(driveinfo->FreeSpace());
|
|
753 |
aOutMapParam->InsertL(KFreeSpace,string64bitnum);
|
|
754 |
TPtrC drvname;
|
|
755 |
driveinfo->DriveName(drvname);
|
|
756 |
aOutMapParam->InsertL(KDriveName,drvname);
|
|
757 |
aOutMapParam->InsertL(KBatteryState,(TInt32)driveinfo->BatteryState());
|
|
758 |
}
|
|
759 |
break;
|
|
760 |
|
|
761 |
case CSysData::EAccessoryInfo:
|
|
762 |
{
|
|
763 |
const CAccessoryInfo* accessoryinfo = ((CAccessoryInfo*) aInSysData);
|
|
764 |
aOutMapParam->InsertL(KAccessoryType,
|
|
765 |
(TInt32)accessoryinfo->AccessoryType());
|
|
766 |
aOutMapParam->InsertL(KAccessoryState,
|
|
767 |
(TInt32)accessoryinfo->ConnectionState());
|
|
768 |
}
|
|
769 |
break;
|
|
770 |
case CSysData::EResolution:
|
|
771 |
{
|
|
772 |
const CResolution* resolution = ((CResolution*) aInSysData);
|
|
773 |
aOutMapParam->InsertL(KXPixels,(TInt32)resolution->XPixels());
|
|
774 |
aOutMapParam->InsertL(KYPixels,(TInt32)resolution->YPixels());
|
|
775 |
}
|
|
776 |
break;
|
|
777 |
case CSysData::EStringData:
|
|
778 |
{
|
|
779 |
const CStringData* stringdata = ((CStringData*) aInSysData);
|
|
780 |
TPtrC string;
|
|
781 |
stringdata->StringData(string);
|
|
782 |
aOutMapParam->InsertL(KStringData,string);
|
|
783 |
}
|
|
784 |
break;
|
|
785 |
case CSysData::EAccessoryList:
|
|
786 |
{
|
|
787 |
CAccList* accessories = (CAccList*) aInSysData;
|
|
788 |
CSysInfoAccList* accessorylist = CSysInfoAccList::NewL(accessories);
|
|
789 |
CleanupClosePushL(*accessorylist);
|
|
790 |
aOutMapParam->InsertL(KAccessoryList,accessorylist);
|
|
791 |
CleanupStack::PopAndDestroy(accessorylist);
|
|
792 |
}
|
|
793 |
break;
|
|
794 |
case CSysData::ELanguageList:
|
|
795 |
{
|
|
796 |
CLiwList* langlist = CLiwDefaultList::NewL();
|
|
797 |
CleanupClosePushL(*langlist);
|
|
798 |
const CLanguageList* languages = ((CLanguageList*) aInSysData);
|
|
799 |
count= languages->Count();
|
|
800 |
for(int index=0; index<count; index++ )
|
|
801 |
{
|
|
802 |
TInt language = 0;
|
|
803 |
languages->At(index,language);
|
|
804 |
langlist->AppendL(TLiwVariant(((TInt32)language)));
|
|
805 |
}
|
|
806 |
aOutMapParam->InsertL(KLanguageList,langlist);
|
|
807 |
CleanupStack::PopAndDestroy(langlist);
|
|
808 |
}
|
|
809 |
break;
|
|
810 |
|
|
811 |
case CSysData::EDriveList:
|
|
812 |
{
|
|
813 |
CLiwList* drivelist = CLiwDefaultList::NewL();
|
|
814 |
CleanupClosePushL(*drivelist);
|
|
815 |
const CDriveList* drives = ((CDriveList*) aInSysData);
|
|
816 |
count = drives->Count();
|
|
817 |
for(int index=0; index<count; index++ )
|
|
818 |
{
|
|
819 |
TInt driveVal = 0;
|
|
820 |
drives->At(index,driveVal);
|
|
821 |
TBuf<KMaxDriveLength> drive;
|
|
822 |
drive.FillZ();
|
|
823 |
drive.Append('A'+driveVal);
|
|
824 |
drive.Append(KDriveSeperator);
|
|
825 |
drivelist->AppendL(TLiwVariant(drive));
|
|
826 |
}
|
|
827 |
aOutMapParam->InsertL(KDriveList,drivelist);
|
|
828 |
CleanupStack::PopAndDestroy(drivelist);
|
|
829 |
}
|
|
830 |
break;
|
|
831 |
|
|
832 |
case CSysData::EStringList:
|
|
833 |
{
|
|
834 |
CLiwList* stringlist = CLiwDefaultList::NewL();
|
|
835 |
CleanupClosePushL(*stringlist);
|
|
836 |
CStringList* strings = ((CStringList*) aInSysData);
|
|
837 |
count = strings->Count();
|
|
838 |
for(int index=0; index<count; index++ )
|
|
839 |
{
|
|
840 |
TPtrC string;
|
|
841 |
strings->At(index,string);
|
|
842 |
stringlist->AppendL(TLiwVariant(string));
|
|
843 |
}
|
|
844 |
aOutMapParam->InsertL(KStringList,stringlist);
|
|
845 |
CleanupStack::PopAndDestroy(stringlist);
|
|
846 |
}
|
|
847 |
break;
|
|
848 |
|
|
849 |
default:
|
|
850 |
User::Leave(KErrArgument);
|
|
851 |
}
|
|
852 |
CleanupStack::Pop(aOutMapParam);
|
|
853 |
}
|
|
854 |
|
|
855 |
// ---------------------------------------------------------------------------
|
|
856 |
// CSysInfoInterface::CancelL(const CLiwGenericParamList& aInParamList,
|
|
857 |
// CLiwGenericParamList& /*aOutParamList*/,
|
|
858 |
// TUint /*aCmdOptions*/,
|
|
859 |
// MLiwNotifyCallback* aCallback )
|
|
860 |
// This cancels the ongoing async call.
|
|
861 |
// ---------------------------------------------------------------------------
|
|
862 |
//
|
|
863 |
void CSysInfoInterface::CancelL( const CLiwGenericParamList& aInParamList,
|
|
864 |
CLiwGenericParamList& aOutParamList, TUint /*aCmdOptions*/,
|
|
865 |
MLiwNotifyCallback* /*aCallback*/)
|
|
866 |
{
|
|
867 |
//Input param List must have transactionID specified
|
|
868 |
if ( !aInParamList.Count() )
|
|
869 |
{
|
|
870 |
iErrBuf.Append(KErrTransactionIdMissing);
|
|
871 |
User::Leave(SErrMissingArgument);
|
|
872 |
}
|
|
873 |
|
|
874 |
//position to start search in input params
|
|
875 |
TInt index = 0;
|
|
876 |
//get the transactionid is specified
|
|
877 |
const TLiwGenericParam* param = aInParamList.FindFirst(index,KTransactionId);
|
|
878 |
if ( !param )
|
|
879 |
{
|
|
880 |
//Position based parsing
|
|
881 |
param = &aInParamList[EIndex0];
|
|
882 |
}
|
|
883 |
|
|
884 |
TInt32 transactionId = param->Value().AsTInt32();
|
|
885 |
|
|
886 |
MLiwNotifyCallback* CallbackObj = GetCallbackAndRemove(transactionId);
|
|
887 |
|
|
888 |
if( !CallbackObj )
|
|
889 |
{
|
|
890 |
iErrBuf.Append(KErrCallbackNotPresent);
|
|
891 |
User::Leave(KErrNotFound);
|
|
892 |
}
|
|
893 |
|
|
894 |
iService->Cancel(transactionId);
|
|
895 |
TRAP_IGNORE(CallbackObj->HandleNotifyL(transactionId,
|
|
896 |
KLiwEventCanceled,aOutParamList,aInParamList));
|
|
897 |
}
|
|
898 |
|
|
899 |
//end of file
|