|
1 /* |
|
2 * Copyright (c) 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: Used for handling system events (events with EventHandler-prefix). |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <LiwServiceHandler.h> |
|
19 #include <LiwVariant.h> |
|
20 #include <LiwCommon.h> |
|
21 #include <UikonInternalPSKeys.h> |
|
22 #include <e32property.h> |
|
23 |
|
24 #include "aieventhandler.h" |
|
25 #include "aixmluiconstants.h" |
|
26 #include "xmluicontroller.h" |
|
27 #include "appui.h" |
|
28 #include "xndomnode.h" |
|
29 #include "xnuiengineappif.h" |
|
30 #include "xnnodeappif.h" |
|
31 #include "aistrcnv.h" |
|
32 |
|
33 #include <csxhelp/hmsc.hlp.hrh> |
|
34 #include <hlplch.h> |
|
35 |
|
36 using namespace AiXmlUiController; |
|
37 |
|
38 // Action Handler LIW commands |
|
39 _LIT8( KAHInterface, "IDataAction"); |
|
40 _LIT8( KAHService, "Service.ActionHandler"); |
|
41 |
|
42 _LIT( KLaunchApplication, "launch_application" ); |
|
43 _LIT( KViewActivation, "view_activation" ); |
|
44 _LIT( KCmdLine, "cmd_line"); |
|
45 |
|
46 _LIT8( KType, "type" ); |
|
47 _LIT8( KLaunchMethod, "launch_method" ); |
|
48 _LIT8( KApplicationUid, "application_uid" ); |
|
49 _LIT8( KViewId, "view_id" ); |
|
50 _LIT8( KViewAppUid, "view_app_uid" ); |
|
51 _LIT8( KMessageUid, "message_uid" ); |
|
52 _LIT8( KAdditionalData, "additional_data" ); |
|
53 _LIT8( KPluginId, "plugin_id" ); |
|
54 _LIT8( KData, "data"); |
|
55 _LIT8( KExecute, "Execute" ); |
|
56 |
|
57 const TInt32 KCASpaAppLauncherPlugin = {0x10282E5F}; |
|
58 const TUid KVoiceCallUidViewId = { 0x10282D81 }; |
|
59 const TUid KVideoCallUid = { 0x101F8681 }; |
|
60 |
|
61 // ======== LOCAL FUNCTIONS ======== |
|
62 // ---------------------------------------------------------------------------- |
|
63 // Shows the Homescreen specific help item |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 static void ShowHelpL( const TDesC& aHelpString ) |
|
67 { |
|
68 TUid fwUid = TUid::Uid( AI_UID3_AIFW_COMMON ); |
|
69 TCoeContextName helpString; |
|
70 helpString.Copy( aHelpString ); |
|
71 |
|
72 CArrayFixFlat<TCoeHelpContext>* array = |
|
73 new (ELeave) CArrayFixFlat<TCoeHelpContext>(1); |
|
74 CleanupStack::PushL( array ); |
|
75 |
|
76 array->AppendL( TCoeHelpContext( fwUid, helpString ) ); |
|
77 |
|
78 HlpLauncher::LaunchHelpApplicationL( |
|
79 CCoeEnv::Static()->WsSession(), array ); |
|
80 |
|
81 CleanupStack::Pop( array ); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Activates Phone application either in video call or normal view |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 static void ActivatePhoneViewL( CXmlUiController& aUiController ) |
|
89 { |
|
90 TInt topMostAppId = 0; |
|
91 RProperty::Get( KPSUidUikon, KUikVideoCallTopApp, topMostAppId ); |
|
92 TUid appId(TUid::Uid(topMostAppId)); |
|
93 if( appId == KVideoCallUid) |
|
94 { |
|
95 const TVwsViewId viewId(appId, appId); |
|
96 aUiController.AppUi()->ActivateViewL( viewId, KNullUid, KNullDesC8()); |
|
97 } |
|
98 else |
|
99 { |
|
100 const TVwsViewId viewId(appId, KVoiceCallUidViewId); |
|
101 aUiController.AppUi()->ActivateViewL( viewId, KVoiceCallUidViewId, KNullDesC8()); |
|
102 } |
|
103 } |
|
104 // ======== MEMBER FUNCTIONS ======== |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CAIXuikonEventHandler::CAIXuikonEventHandler() |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 CAIEventHandler::CAIEventHandler( CXmlUiController& aUiController ) |
|
110 : iUiController( aUiController ) |
|
111 { |
|
112 } |
|
113 |
|
114 // ---------------------------------------------------------------------------- |
|
115 // CAISystemEventHandler::ConstructL() |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 void CAIEventHandler::ConstructL() |
|
119 { |
|
120 } |
|
121 |
|
122 // ---------------------------------------------------------------------------- |
|
123 // CAISystemEventHandler::NewL() |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 CAIEventHandler* CAIEventHandler::NewL( CXmlUiController& aUiController ) |
|
127 { |
|
128 CAIEventHandler* self = |
|
129 new ( ELeave ) CAIEventHandler( aUiController ); |
|
130 CleanupStack::PushL( self ); |
|
131 self->ConstructL(); |
|
132 CleanupStack::Pop( self ); |
|
133 return self; |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CAISystemEventHandler::~CAISystemEventHandler() |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 CAIEventHandler::~CAIEventHandler() |
|
141 { |
|
142 if( iServiceHandler ) |
|
143 { |
|
144 iServiceHandler->Reset(); |
|
145 } |
|
146 delete iServiceHandler; |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // Handles the restricted ( can be triggered only from view) events and forwards |
|
151 // the rest into appropriate functions. |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 void CAIEventHandler::HandleEventL( const TDesC8& aEventText, CXnDomNode& aEvent ) |
|
155 { |
|
156 const TDesC8& prefix( AiUiDef::xml::event::KEventHandlerPrefix ); |
|
157 const TDesC8& event( aEventText.Mid( prefix.Length() ) ); |
|
158 const TDesC8& ns( iUiController.UiEngineL()->ActiveView()->Namespace() ); |
|
159 // These events can be excuted from view only |
|
160 if( aEvent.Namespace() == ns) |
|
161 { |
|
162 if ( event == AiUiDef::xml::event::KEventSetOnline ) |
|
163 { |
|
164 iUiController.AppUi()->SetOnlineStateL( ETrue ); |
|
165 } |
|
166 else if ( event == AiUiDef::xml::event::KEventSetOffline ) |
|
167 { |
|
168 iUiController.AppUi()->SetOnlineStateL( EFalse ); |
|
169 } |
|
170 else if ( event == AiUiDef::xml::event::KEventShowHelp ) |
|
171 { |
|
172 if( iUiController.UiEngineL()->IsEditMode() ) |
|
173 { |
|
174 ShowHelpL( KSET_HLP_HOME_SCREEN_EDIT ); |
|
175 } |
|
176 else |
|
177 { |
|
178 ShowHelpL( KSET_HLP_HOME_SCREEN ); |
|
179 } |
|
180 } |
|
181 else if ( event == AiUiDef::xml::event::KEventActivatePhoneView ) |
|
182 { |
|
183 ActivatePhoneViewL( iUiController ); |
|
184 } |
|
185 } |
|
186 |
|
187 if( event == AiUiDef::xml::event::KEventLaunchApp ) |
|
188 { |
|
189 LaunchAppL( aEvent ); |
|
190 } |
|
191 else if( event == AiUiDef::xml::event::KEventActivateView ) |
|
192 { |
|
193 ActivateViewL( aEvent ); |
|
194 } |
|
195 } |
|
196 |
|
197 // ---------------------------------------------------------------------------- |
|
198 // Launches app using Action Handler |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 void CAIEventHandler::LaunchAppL( CXnDomNode& aEventNode ) |
|
202 { |
|
203 const TDesC8& uidStr( aEventNode.AttributeValue( AiUiDef::xml::property::KUid )); |
|
204 TInt32 uid( 0 ); |
|
205 User::LeaveIfError( AiUtility::ParseInt( uid, uidStr ) ); |
|
206 |
|
207 CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
208 map->PushL(); |
|
209 map->InsertL( KType, TLiwVariant( KLaunchApplication )); |
|
210 map->InsertL( KLaunchMethod, TLiwVariant( KCmdLine )); |
|
211 map->InsertL( KApplicationUid, TLiwVariant( uid )); |
|
212 |
|
213 ExecuteAppLauncherL( *map ); |
|
214 |
|
215 CleanupStack::PopAndDestroy( map ); |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------------------------- |
|
219 // Activates view using Action Handler |
|
220 // ---------------------------------------------------------------------------- |
|
221 // |
|
222 void CAIEventHandler::ActivateViewL( CXnDomNode& aEventNode ) |
|
223 { |
|
224 const TDesC8& uidStr( aEventNode.AttributeValue( AiUiDef::xml::property::KUid )); |
|
225 const TDesC8& viewIdStr( aEventNode.AttributeValue( AiUiDef::xml::property::KViewId )); |
|
226 const TDesC8& messageIdStr( aEventNode.AttributeValue( AiUiDef::xml::property::KMessageId )); |
|
227 const TDesC8& messageStr( aEventNode.AttributeValue( AiUiDef::xml::property::KMessage )); |
|
228 |
|
229 CLiwDefaultMap* map = CLiwDefaultMap :: NewL(); |
|
230 map->PushL(); |
|
231 map->InsertL( KType, TLiwVariant( KViewActivation )); |
|
232 TInt32 uid( 0 ); |
|
233 User::LeaveIfError( AiUtility::ParseInt( uid, uidStr ) ); |
|
234 map->InsertL( KViewAppUid, TLiwVariant( uid )); |
|
235 |
|
236 TInt32 viewId( 0 ); |
|
237 User::LeaveIfError( AiUtility::ParseInt( viewId, viewIdStr ) ); |
|
238 map->InsertL( KViewId, TLiwVariant( viewId )); |
|
239 |
|
240 if( messageIdStr.Length() != 0 ) |
|
241 { |
|
242 TInt32 messageId( 0 ); |
|
243 User::LeaveIfError( AiUtility::ParseInt( messageId, messageIdStr ) ); |
|
244 map->InsertL( KMessageUid, TLiwVariant( messageId )); |
|
245 |
|
246 map->InsertL( KAdditionalData, TLiwVariant( messageStr )); |
|
247 } |
|
248 |
|
249 ExecuteAppLauncherL( *map ); |
|
250 |
|
251 CleanupStack::PopAndDestroy( map ); |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // Calls the actual LIW interface |
|
256 // ---------------------------------------------------------------------------- |
|
257 // |
|
258 void CAIEventHandler::ExecuteAppLauncherL( CLiwDefaultMap& aMap ) |
|
259 { |
|
260 MLiwInterface* msgInterface = ActionHandlerInterfaceL( ); |
|
261 if( msgInterface && iServiceHandler ) |
|
262 { |
|
263 CLiwGenericParamList& inparam = iServiceHandler->InParamListL(); |
|
264 CLiwGenericParamList& outparam = iServiceHandler->OutParamListL(); |
|
265 |
|
266 TLiwGenericParam pluginUid( KPluginId, TLiwVariant( TUid::Uid( KCASpaAppLauncherPlugin ))); |
|
267 inparam.AppendL( pluginUid ); |
|
268 |
|
269 TLiwGenericParam data( KData, TLiwVariant( &aMap )); |
|
270 inparam.AppendL( data ); |
|
271 |
|
272 TRAPD(err, msgInterface ->ExecuteCmdL(KExecute, inparam, outparam)); |
|
273 msgInterface->Close(); |
|
274 |
|
275 outparam.Reset(); |
|
276 inparam.Reset(); |
|
277 } |
|
278 } |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // Gets the Action Handler interface |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 MLiwInterface* CAIEventHandler::ActionHandlerInterfaceL( ) |
|
285 { |
|
286 if( !iServiceHandler ) |
|
287 { |
|
288 iServiceHandler = CLiwServiceHandler::NewL(); |
|
289 } |
|
290 CLiwGenericParamList& inParam = iServiceHandler->InParamListL(); |
|
291 CLiwGenericParamList& outParam = iServiceHandler->OutParamListL(); |
|
292 |
|
293 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL( KLiwCmdAsStr, KAHInterface, KAHService); |
|
294 |
|
295 CleanupStack::PushL( crit ); |
|
296 crit->SetServiceClass( TUid::Uid( KLiwClassBase )); |
|
297 |
|
298 RCriteriaArray a; |
|
299 a.AppendL(crit); |
|
300 |
|
301 iServiceHandler->AttachL(a); |
|
302 iServiceHandler->ExecuteServiceCmdL( *crit, inParam, outParam ); |
|
303 |
|
304 CleanupStack::PopAndDestroy( crit ); |
|
305 a.Reset(); |
|
306 |
|
307 // find service interface |
|
308 TInt pos = 0; |
|
309 MLiwInterface* msgInterface = NULL; |
|
310 outParam.FindFirst( pos, KAHInterface ); |
|
311 if ( pos != KErrNotFound ) |
|
312 { |
|
313 msgInterface = (outParam)[pos].Value().AsInterface(); |
|
314 } |
|
315 |
|
316 outParam.Reset(); |
|
317 inParam.Reset(); |
|
318 |
|
319 return msgInterface; |
|
320 } |
|
321 |
|
322 // End of file |