|
1 /* |
|
2 * Copyright (c) 2008-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: wrapper for Back Stepping Service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // from AIW and LIW |
|
22 #include <liwcommon.h> |
|
23 #include <liwservicehandler.h> |
|
24 |
|
25 #include <glxtracer.h> |
|
26 #include <glxlog.h> |
|
27 |
|
28 // parameter names used by BS Service |
|
29 #include "glxbsserviceconstants.h" |
|
30 |
|
31 // for CleanupResetAndDestroyPushL |
|
32 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
33 |
|
34 |
|
35 #include "glxbackservicewrapper.h" |
|
36 |
|
37 using namespace LIW; |
|
38 |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CGlxBackServiceWrapper::CGlxBackServiceWrapper() |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 void CGlxBackServiceWrapper::ConstructL( const TUid aUid ) |
|
56 { |
|
57 TRACER( "CGlxBackServiceWrapper::ConstructL" ); |
|
58 // create Service Handler and keep as long as access to BS Service needed |
|
59 iServiceHandler = CLiwServiceHandler::NewL(); |
|
60 // for convinience keep pointers to Service Handler param lists |
|
61 iInParamList = &iServiceHandler->InParamListL(); |
|
62 iOutParamList = &iServiceHandler->OutParamListL(); |
|
63 |
|
64 RCriteriaArray criteriaArray; |
|
65 CleanupResetAndDestroyPushL( criteriaArray ); |
|
66 |
|
67 // create Liw criteria |
|
68 CLiwCriteriaItem* criterion = |
|
69 CLiwCriteriaItem::NewLC( KLiwCmdAsStr, KBSInterface, KBSServiceID ); |
|
70 criterion->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
|
71 |
|
72 criteriaArray.AppendL( criterion ); |
|
73 CleanupStack::Pop( criterion ); |
|
74 |
|
75 // attach Liw criteria |
|
76 iServiceHandler->AttachL( criteriaArray ); |
|
77 // get BS Service interface |
|
78 iServiceHandler->ExecuteServiceCmdL( *criterion, |
|
79 *iInParamList, |
|
80 *iOutParamList ); |
|
81 |
|
82 CleanupStack::PopAndDestroy( &criteriaArray ); |
|
83 |
|
84 // extract BS interface from output params |
|
85 TInt pos( 0 ); |
|
86 iOutParamList->FindFirst( pos, KBSInterface ); |
|
87 if( pos != KErrNotFound ) |
|
88 { |
|
89 iBSInterface = (*iOutParamList)[pos].Value().AsInterface(); |
|
90 } |
|
91 |
|
92 if ( !iBSInterface ) |
|
93 { |
|
94 // handle no BS Service |
|
95 User::Leave( KErrNotFound ); |
|
96 } |
|
97 |
|
98 InitializeL( aUid ); |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C CGlxBackServiceWrapper* CGlxBackServiceWrapper::NewL( |
|
107 const TUid aUid ) |
|
108 { |
|
109 TRACER( "CGlxBackServiceWrapper::NewL" ); |
|
110 CGlxBackServiceWrapper* self = |
|
111 CGlxBackServiceWrapper::NewLC( aUid ); |
|
112 CleanupStack::Pop( self ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C CGlxBackServiceWrapper* CGlxBackServiceWrapper::NewLC( |
|
122 const TUid aUid ) |
|
123 { |
|
124 TRACER( "CGlxBackServiceWrapper::NewLC" ); |
|
125 CGlxBackServiceWrapper* self = new( ELeave ) CGlxBackServiceWrapper; |
|
126 CleanupStack::PushL( self ); |
|
127 self->ConstructL( aUid ); |
|
128 return self; |
|
129 } |
|
130 |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 CGlxBackServiceWrapper::~CGlxBackServiceWrapper() |
|
137 { |
|
138 TRACER( "CGlxBackServiceWrapper::~CGlxBackServiceWrapper" ); |
|
139 if ( iBSInterface ) |
|
140 { |
|
141 iBSInterface->Close(); |
|
142 } |
|
143 |
|
144 delete iServiceHandler; |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TInt CGlxBackServiceWrapper::ForwardActivationEventL( const TDesC8& aState, |
|
153 const TBool aEnter ) |
|
154 { |
|
155 TRACER( "CGlxBackServiceWrapper::ForwardActivationEventL" ); |
|
156 iInParamList->Reset(); |
|
157 iOutParamList->Reset(); |
|
158 |
|
159 TLiwGenericParam state( KBSInParamState, TLiwVariant( aState ) ); |
|
160 iInParamList->AppendL( state ); |
|
161 TLiwGenericParam enter( KBSInParamEnter, TLiwVariant( aEnter ) ); |
|
162 iInParamList->AppendL( enter ); |
|
163 |
|
164 iBSInterface->ExecuteCmdL( KBSCmdForwardActivationEvent, |
|
165 *iInParamList, |
|
166 *iOutParamList ); |
|
167 |
|
168 TInt result = HandleResultL(); |
|
169 |
|
170 iInParamList->Reset(); |
|
171 iOutParamList->Reset(); |
|
172 |
|
173 return result; |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TInt CGlxBackServiceWrapper::HandleBackCommandL( const TDesC8& aState, |
|
182 const TBool aCheckOnly) |
|
183 { |
|
184 TRACER( "CGlxBackServiceWrapper::HandleBackCommandL" ); |
|
185 iInParamList->Reset(); |
|
186 iOutParamList->Reset(); |
|
187 |
|
188 TLiwGenericParam state( KBSInParamState, TLiwVariant( aState ) ); |
|
189 iInParamList->AppendL( state ); |
|
190 TLiwGenericParam checkOnly( KBSInParamCheckOnly, TLiwVariant( aCheckOnly ) ); |
|
191 iInParamList->AppendL( checkOnly ); |
|
192 |
|
193 iBSInterface->ExecuteCmdL( KBSCmdHandleBackCommand, |
|
194 *iInParamList, |
|
195 *iOutParamList ); |
|
196 |
|
197 TInt result = HandleResultL(); |
|
198 |
|
199 iInParamList->Reset(); |
|
200 iOutParamList->Reset(); |
|
201 |
|
202 return result; |
|
203 } |
|
204 |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CGlxBackServiceWrapper::InitializeL( const TUid aUid ) |
|
211 { |
|
212 TRACER( "CGlxBackServiceWrapper::InitializeL" ); |
|
213 iInParamList->Reset(); |
|
214 iOutParamList->Reset(); |
|
215 |
|
216 TLiwGenericParam appUid( KBSInParamAppUid, TLiwVariant( aUid.iUid ) ); |
|
217 iInParamList->AppendL( appUid ); |
|
218 |
|
219 iBSInterface->ExecuteCmdL( KBSCmdInitialize, |
|
220 *iInParamList, |
|
221 *iOutParamList ); |
|
222 |
|
223 if ( HandleResultL() != 1 ) |
|
224 { |
|
225 // Initialize command was not consumed - handle failiure |
|
226 User::Leave( KErrArgument ); |
|
227 } |
|
228 |
|
229 iInParamList->Reset(); |
|
230 iOutParamList->Reset(); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 TInt CGlxBackServiceWrapper::HandleResultL() |
|
238 { |
|
239 TRACER( "CGlxBackServiceWrapper::HandleResultL" ); |
|
240 TInt statusInfo( KErrNotFound ); |
|
241 |
|
242 TInt posErr( 0 ); |
|
243 iOutParamList->FindFirst( posErr, EGenericParamError ); |
|
244 if( posErr != KErrNotFound ) |
|
245 { |
|
246 // error code found - extract and handle |
|
247 TInt errorCode( KErrNone ); |
|
248 (*iOutParamList)[posErr].Value().Get( errorCode ); |
|
249 |
|
250 User::LeaveIfError( errorCode ); |
|
251 } |
|
252 |
|
253 // if no error returned, carry on |
|
254 TInt posStat( 0 ); |
|
255 iOutParamList->FindFirst( posStat, KBSOutParamStatusInfo ); |
|
256 if( posStat != KErrNotFound ) |
|
257 { |
|
258 // status info present - extract and return |
|
259 (*iOutParamList)[posStat].Value().Get( statusInfo ); |
|
260 } |
|
261 else |
|
262 { |
|
263 // no return value |
|
264 // this should not happen |
|
265 User::Leave( KErrNotFound ); |
|
266 } |
|
267 |
|
268 return statusInfo; |
|
269 } |