114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 |
#include <liwcommon.h>
|
|
19 |
#include <liwservicehandler.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
|
|
22 |
#include "cpserveractionmanager.h"
|
|
23 |
#include "cpdebug.h"
|
|
24 |
#include "cpglobals.h"
|
|
25 |
|
|
26 |
using namespace LIW;
|
|
27 |
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
// C++ destructor
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
CCPActionManager::~CCPActionManager()
|
|
33 |
{
|
|
34 |
if ( iInterface )
|
|
35 |
{
|
|
36 |
iInterface->Close( );
|
|
37 |
}
|
|
38 |
delete iServiceHandler;
|
|
39 |
}
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CCPActionManager* CCPActionManager::NewL()
|
|
46 |
{
|
|
47 |
CCPActionManager* self = CCPActionManager::NewLC( );
|
|
48 |
CleanupStack::Pop( self );
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CCPActionManager* CCPActionManager::NewLC()
|
|
57 |
{
|
|
58 |
CCPActionManager* self = new( ELeave ) CCPActionManager;
|
|
59 |
CleanupStack::PushL( self );
|
|
60 |
self->ConstructL( );
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
// C++ constructor.
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
CCPActionManager::CCPActionManager()
|
|
69 |
{
|
|
70 |
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// Standard 2nd phase constructor.
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
void CCPActionManager::ConstructL()
|
|
78 |
{
|
|
79 |
CP_DEBUG( _L8("CCPActionManager::ConstructL()") );
|
|
80 |
iServiceHandler = CLiwServiceHandler::NewL( );
|
|
81 |
}
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// CCPActionManager::ExecuteL
|
|
85 |
// --------------- --------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CCPActionManager::ExecuteL( const CLiwGenericParamList& aList )
|
|
88 |
{
|
|
89 |
CP_DEBUG( _L8("CCPActionManager::ExecuteL()") );
|
|
90 |
if ( !iInterface )
|
|
91 |
{
|
|
92 |
PrepareServiceL( iInterface );
|
|
93 |
}
|
|
94 |
CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC( );
|
|
95 |
CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC( );
|
|
96 |
PrepareInputListL( aList, *inparam );
|
|
97 |
|
|
98 |
iInterface->ExecuteCmdL( KCmdExecute, *inparam, *outparam ) ;
|
|
99 |
TInt pos(0);
|
|
100 |
outparam->FindFirst( pos, EGenericParamError );
|
|
101 |
if ( pos != KErrNotFound )
|
|
102 |
{
|
|
103 |
User::LeaveIfError( ( *outparam )[pos].Value().AsTInt32( ) );
|
|
104 |
}
|
|
105 |
else
|
|
106 |
{
|
|
107 |
User::Leave( KErrNotFound );
|
|
108 |
}
|
|
109 |
CleanupStack::PopAndDestroy( outparam );
|
|
110 |
CleanupStack::PopAndDestroy( inparam );
|
|
111 |
}
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// CCPActionManager::ExecuteL
|
|
115 |
// --------------- --------------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CCPActionManager::PrepareServiceL( MLiwInterface*& aInterface )
|
|
118 |
{
|
|
119 |
CP_DEBUG( _L8("CCPActionManager::PrepareServiceL()") );
|
|
120 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL( ) );
|
|
121 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL( ) );
|
|
122 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL( 1,
|
|
123 |
KActionHandlerInterface, KActionHandlerService );
|
|
124 |
CleanupStack::PushL( crit );
|
|
125 |
crit->SetServiceClass( TUid::Uid( KLiwClassBase ) );
|
|
126 |
RCriteriaArray array;
|
|
127 |
CleanupClosePushL( array );
|
|
128 |
array.AppendL( crit );
|
|
129 |
iServiceHandler->AttachL( array );
|
|
130 |
iServiceHandler->ExecuteServiceCmdL( *crit, *inparam, *outparam );
|
|
131 |
CleanupStack::PopAndDestroy( &array );
|
|
132 |
CleanupStack::PopAndDestroy( crit );
|
|
133 |
TInt pos = 0;
|
|
134 |
outparam->FindFirst( pos, KActionHandlerInterface );
|
|
135 |
if ( pos != KErrNotFound )
|
|
136 |
{
|
|
137 |
aInterface = ( *outparam )[pos].Value().AsInterface( );
|
|
138 |
}
|
|
139 |
else
|
|
140 |
{
|
|
141 |
User::Leave( KErrNotFound );
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
// CCPActionManager::PrepareInputListL
|
|
147 |
// --------------- --------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CCPActionManager::PrepareInputListL( const CLiwGenericParamList& aList,
|
|
150 |
CLiwGenericParamList& aTarget )
|
|
151 |
{
|
|
152 |
CP_DEBUG( _L8("CCPActionManager::PrepareInputListL()") );
|
|
153 |
const TLiwGenericParam* param= NULL;
|
|
154 |
TInt pos( 0);
|
|
155 |
param = aList.FindFirst( pos, KListMap, EVariantTypeMap );
|
|
156 |
if ( param && pos !=KErrNotFound )
|
|
157 |
{
|
|
158 |
ExtractUidAndMapL( *param->Value().AsMap(), aTarget );
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
User::Leave( KErrNotFound );
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
// CCPActionManager::ExtractUidAndMapL
|
|
168 |
// --------------- --------------------------------------------------------------
|
|
169 |
//
|
|
170 |
void CCPActionManager::ExtractUidAndMapL( const CLiwMap& aMap,
|
|
171 |
CLiwGenericParamList& aTarget )
|
|
172 |
{
|
|
173 |
CP_DEBUG( _L8("CCPActionManager::ExtractUidAndMapL()") );
|
|
174 |
TLiwVariant variant;
|
|
175 |
variant.PushL( );
|
|
176 |
if ( aMap.FindL( KActionMap, variant ) )
|
|
177 |
{
|
|
178 |
TLiwVariant valueVariant;
|
|
179 |
valueVariant.PushL( );
|
|
180 |
if ( variant.TypeId() == EVariantTypeMap )
|
|
181 |
{
|
|
182 |
if ( variant.AsMap()->FindL( KDataForActionHandler, valueVariant ) )
|
|
183 |
{
|
|
184 |
TLiwGenericParam param( KDataForActionHandler, valueVariant);
|
|
185 |
aTarget.AppendL( param );
|
|
186 |
}
|
|
187 |
if ( variant.AsMap()->FindL( KPluginUid, valueVariant ) )
|
|
188 |
{
|
|
189 |
TLiwGenericParam param( KPluginUid, valueVariant);
|
|
190 |
aTarget.AppendL( param );
|
|
191 |
}
|
|
192 |
}
|
|
193 |
CleanupStack::PopAndDestroy( &valueVariant );
|
|
194 |
}
|
|
195 |
CleanupStack::PopAndDestroy( &variant );
|
|
196 |
}
|
|
197 |
|