author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 22:59:08 +0300 | |
branch | RCL_3 |
changeset 46 | 5146369cfdc9 |
parent 5 | 989d2f495d90 |
permissions | -rw-r--r-- |
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: CSysInfoObserver class implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include <liwgenericparam.h> |
|
21 |
#include <liwcommon.h> |
|
22 |
||
23 |
#include "sysinfointerface.h" |
|
24 |
#include "sysinfoobserver.h" |
|
25 |
#include "../../inc/serviceerrno.h" |
|
26 |
#include "sysinfoaiwparams.hrh" |
|
27 |
||
28 |
using namespace LIW; |
|
29 |
using namespace sysinfoaiwparams; |
|
30 |
||
31 |
// ============================ MEMBER FUNCTIONS =============================== |
|
32 |
||
33 |
// ----------------------------------------------------------------------------- |
|
34 |
// CSysInfoObserver::NewL( CSysInfoInterface* aSysInfoIf ) |
|
35 |
// Two-phased constructor. |
|
36 |
// ----------------------------------------------------------------------------- |
|
37 |
// |
|
38 |
CSysInfoObserver* CSysInfoObserver::NewL( CSysInfoInterface* aSysInfoIf ) |
|
39 |
{ |
|
40 |
CSysInfoObserver* self = new (ELeave) CSysInfoObserver(aSysInfoIf); |
|
41 |
return self; |
|
42 |
} |
|
43 |
||
44 |
// ----------------------------------------------------------------------------- |
|
45 |
// CSysInfoObserver::CSysInfoObserver( CSysInfoInterface* aSysInfoIf ) |
|
46 |
// C++ default constructor can NOT contain any code, that might leave. |
|
47 |
// ----------------------------------------------------------------------------- |
|
48 |
// |
|
49 |
CSysInfoObserver::CSysInfoObserver( CSysInfoInterface* aSysInfoIf ) |
|
50 |
:iSysInfoIf(aSysInfoIf) |
|
51 |
{ |
|
52 |
} |
|
53 |
||
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// CSysInfoObserver::HandleResponseL( const TDesC& aEntity,const TDesC& aKey, |
|
56 |
// CSysData* aOutput, TInt32 aTransID,TInt aError) |
|
57 |
// Pack the outputs and call the callback function. |
|
58 |
// ----------------------------------------------------------------------------- |
|
59 |
// |
|
60 |
void CSysInfoObserver::HandleResponseL(const TDesC& aEntity,const TDesC& aKey, |
|
61 |
CSysData* aOutput, TInt32 aTransID, |
|
62 |
TSysRequest::TRequestType aType, |
|
63 |
TInt aError ) |
|
64 |
{ |
|
65 |
TInt SapiErr = SErrNone; |
|
66 |
TBool ownership(EFalse); |
|
67 |
MLiwNotifyCallback* callback=NULL; |
|
68 |
//retrieve callback |
|
69 |
if( TSysRequest::EASyncONESHOT == aType ) |
|
70 |
callback = iSysInfoIf->GetCallbackAndRemove(aTransID); |
|
71 |
else |
|
72 |
callback = iSysInfoIf->GetCallback(aTransID); |
|
73 |
||
74 |
if( !callback ) |
|
75 |
{ |
|
76 |
delete aOutput; |
|
77 |
return; |
|
78 |
} |
|
79 |
||
80 |
//Create param list |
|
81 |
CLiwGenericParamList* eventParamList = CLiwGenericParamList::NewL(); |
|
82 |
CleanupStack::PushL(eventParamList); |
|
83 |
CLiwGenericParamList* inParamList = CLiwGenericParamList::NewL(); |
|
84 |
CleanupStack::PushL(inParamList); |
|
85 |
||
86 |
if ( aError != KErrNone ) |
|
87 |
{ |
|
88 |
SapiErr = iSysInfoIf->SapiError(aError); |
|
89 |
eventParamList->AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)SapiErr))); |
|
90 |
TRAP_IGNORE(callback->HandleNotifyL(aTransID, KLiwEventError, |
|
91 |
*eventParamList,*inParamList)); |
|
92 |
} |
|
93 |
else |
|
94 |
{ |
|
95 |
//pack to aOutParamList |
|
96 |
eventParamList->AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)SapiErr))); |
|
97 |
CLiwMap* outparam=NULL; |
|
98 |
||
46
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
if(aOutput) |
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
{ |
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
if( (aOutput->DataType() == CSysData::EAccessoryList) || |
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
(aOutput->DataType() == CSysData::EConnectionList) ) |
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
ownership = ETrue; |
5146369cfdc9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
} |
5 | 105 |
CSysInfoInterface::ConvertSysData2AiwParamL(aOutput,outparam); |
106 |
//Add Entity and Key to the output map. |
|
107 |
if(outparam) |
|
108 |
{ |
|
109 |
outparam->InsertL(KEntity,TLiwVariant(aEntity)); |
|
110 |
outparam->InsertL(KKey,TLiwVariant(aKey)); |
|
111 |
} |
|
112 |
||
113 |
eventParamList->AppendL(TLiwGenericParam(KReturnValue,TLiwVariant(outparam))); |
|
114 |
outparam->DecRef(); |
|
115 |
if( TSysRequest::EASyncONESHOT == aType ) |
|
116 |
{ |
|
117 |
TRAP_IGNORE(callback->HandleNotifyL(aTransID, KLiwEventCompleted, |
|
118 |
*eventParamList,*inParamList)); |
|
119 |
} |
|
120 |
else |
|
121 |
{ |
|
122 |
TRAP_IGNORE(callback->HandleNotifyL(aTransID, KLiwEventInProgress, |
|
123 |
*eventParamList,*inParamList)); |
|
124 |
} |
|
125 |
||
126 |
if(!ownership) |
|
127 |
{ |
|
128 |
delete aOutput; |
|
129 |
aOutput = NULL; |
|
130 |
} |
|
131 |
} |
|
132 |
CleanupStack::PopAndDestroy(inParamList); |
|
133 |
CleanupStack::PopAndDestroy(eventParamList); |
|
134 |
} |
|
135 |
||
136 |
//End of file |
|
137 |
||
138 |