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: |
|
15 * Implementation of the store for WidgetManager |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlayoutscalable_apps.cdl.h> |
|
21 #include <aknlayoutscalable_avkon.cdl.h> |
|
22 #include <layoutmetadata.cdl.h> |
|
23 #include <AknUtils.h> |
|
24 #include <AknsDrawUtils.h> |
|
25 #include <AknBidiTextUtils.h> |
|
26 #include <AknsFrameBackgroundControlContext.h> |
|
27 #include <gulicon.h> |
|
28 #include <avkon.mbg> |
|
29 #include <widgetmanager.mbg> |
|
30 #include <apgcli.h> |
|
31 #include <apgtask.h> |
|
32 #include <widgetregistryclient.h> // widgetreqistry |
|
33 #include <bacline.h> |
|
34 #include <escapeutils.h> |
|
35 #include <browserlauncher.h> |
|
36 #include <centralrepository.h> |
|
37 #include <aknlayoutscalable_avkon.cdl.h> |
|
38 |
|
39 #include "wmimageconverter.h" |
|
40 #include "wmstore.h" |
|
41 #include "wmcommon.h" |
|
42 #include "wmplugin.h" |
|
43 #include "wmresourceloader.h" |
|
44 #include "wmmaincontainer.h" |
|
45 #include "wmconfiguration.h" |
|
46 #include "wmprocessmonitor.h" |
|
47 |
|
48 // CONSTANTS |
|
49 |
|
50 // MEMBER FUNCTIONS |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CWmStore::NewL |
|
54 // --------------------------------------------------------- |
|
55 // |
|
56 CWmStore* CWmStore::NewL( CWmConfItem& aWmConfItem, |
|
57 CWmResourceLoader& aResourceLoader ) |
|
58 { |
|
59 CWmStore* self = new (ELeave) CWmStore( aWmConfItem ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL( aResourceLoader ); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CWmStore::~CWmStore |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 CWmStore::~CWmStore() |
|
71 { |
|
72 delete iIcon; |
|
73 delete iMask; |
|
74 |
|
75 // if MAknIconFileProvider was used to create image from icon string |
|
76 // then it'll try accessing imageconverter after bitmap deletion |
|
77 // for de-reference open file count, so it should be deleted last. |
|
78 delete iImageConverter; |
|
79 delete iProcessMonitor; |
|
80 delete iBrowserLauncher; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CWmStore::CWmStore |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 CWmStore::CWmStore( CWmConfItem& aWmConfItem ) |
|
88 : iWmConfItem( aWmConfItem ) |
|
89 { |
|
90 iIcon = NULL; |
|
91 iMask = NULL; |
|
92 iProcessMonitor = NULL; |
|
93 iBrowserLauncher = NULL; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CWmStore::ConstructL |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CWmStore::ConstructL( CWmResourceLoader& aResourceLoader ) |
|
101 { |
|
102 // start image converter for the icon |
|
103 iImageConverter = CWmImageConverter::NewL(); |
|
104 |
|
105 // get size of icon for double large style list |
|
106 TRect rect; |
|
107 TAknLayoutRect layout; |
|
108 |
|
109 layout.LayoutRect( rect, |
|
110 AknLayoutScalable_Avkon::list_double_large_graphic_pane_g1( 0 ).LayoutLine() ); |
|
111 |
|
112 TSize iconSize( layout.Rect().Width(), |
|
113 layout.Rect().Height() ); |
|
114 |
|
115 // create icon |
|
116 TInt err = iImageConverter->HandleIconString( |
|
117 iconSize, |
|
118 iWmConfItem.Icon(), |
|
119 iIcon, |
|
120 iMask, |
|
121 ETrue ); // force scaling for non scaleble icons |
|
122 |
|
123 if ( err != KErrNone ) |
|
124 { |
|
125 // lets use basket icon |
|
126 // skin( 0x101f86e3 0x23f6 ):mif( z:\resource\apps\widgetmanager.mif 16388 16389 ) |
|
127 _LIT( KSkinMifIconFormat, "skin( 0x%x 0x%x ):mif( %S %d %d )"); |
|
128 const TInt KMaxIconDescriptorLength = 256; |
|
129 TBuf<KMaxIconDescriptorLength> buf; |
|
130 buf.Format( KSkinMifIconFormat(), |
|
131 EAknsMajorGeneric, EAknsMinorGenericQgnPropLmShopping, |
|
132 &aResourceLoader.IconFilePath(), |
|
133 EMbmWidgetmanagerQgn_menu_shopping, |
|
134 EMbmWidgetmanagerQgn_menu_shopping_mask ); |
|
135 |
|
136 iImageConverter->HandleIconString( |
|
137 iconSize, |
|
138 buf, |
|
139 iIcon, |
|
140 iMask, |
|
141 EFalse ); // force scaling for non scaleble icons |
|
142 } |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // CWmStore::StoreIcon |
|
147 // --------------------------------------------------------- |
|
148 // |
|
149 CFbsBitmap* CWmStore::StoreIcon() |
|
150 { |
|
151 return iIcon; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CWmStore::StoreMask |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 CFbsBitmap* CWmStore::StoreMask() |
|
159 { |
|
160 return iMask; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CWmStore::Heading |
|
165 // --------------------------------------------------------- |
|
166 // |
|
167 const TDesC& CWmStore::Heading() |
|
168 { |
|
169 return iWmConfItem.Title(); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CWmStore::Order |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 TInt CWmStore::Order() const |
|
177 { |
|
178 return iWmConfItem.Order(); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------- |
|
182 // CWmStore::ExecuteL |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 void CWmStore::ExecuteL() |
|
186 { |
|
187 if ( iWmConfItem.Id() == EOvi ) |
|
188 { |
|
189 if ( !iProcessMonitor ) |
|
190 { |
|
191 iProcessMonitor = CWmProcessMonitor::NewL(); |
|
192 } |
|
193 // if process monitor is active laucher was allready started. |
|
194 // this is for ignoring multiple presses |
|
195 if ( !iProcessMonitor->IsActive() ) |
|
196 { |
|
197 RunOviL(); |
|
198 } |
|
199 } |
|
200 else if ( iWmConfItem.Id() >= EStore1 && iWmConfItem.Id() < ELastItem ) |
|
201 { |
|
202 // if this leaves it means we need to start browser |
|
203 // becouse application info was not given |
|
204 TRAPD( err, RunApplicationL() ) |
|
205 if ( err != KErrNone ) |
|
206 { |
|
207 StartBrowserL( iWmConfItem.BrowserUrl() ); |
|
208 } |
|
209 } |
|
210 else |
|
211 { |
|
212 // Not supported |
|
213 User::Leave( KErrGeneral ); |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------- |
|
218 // CWmStore::RunOviL |
|
219 // --------------------------------------------------------- |
|
220 // |
|
221 void CWmStore::RunOviL() |
|
222 { |
|
223 RApaLsSession session; |
|
224 User::LeaveIfError( session.Connect() ); |
|
225 CleanupClosePushL( session ); |
|
226 |
|
227 //get app info |
|
228 TApaAppInfo appInfo; |
|
229 if ( session.GetAppInfo( appInfo, iWmConfItem.AppUid() ) == KErrNone ) |
|
230 { |
|
231 // Form parameter |
|
232 HBufC* param = HBufC::NewLC( iWmConfItem.AppParam().Length() ); |
|
233 param->Des().Copy( iWmConfItem.AppParam() ); |
|
234 |
|
235 // do the launch |
|
236 RProcess process; |
|
237 User::LeaveIfError( process.Create( appInfo.iFullName, *param ) ); |
|
238 |
|
239 iProcessMonitor->Monitor( process ); |
|
240 process.Resume(); |
|
241 |
|
242 CleanupStack::PopAndDestroy( param ); |
|
243 } |
|
244 |
|
245 CleanupStack::PopAndDestroy( &session ); |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------- |
|
249 // CWmStore::StartBrowserL |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 void CWmStore::StartBrowserL( const TDesC& aUrl ) |
|
253 { |
|
254 // already running/or request launch or url is empty |
|
255 if ( iBrowserLauncher || !aUrl.Length() ) { return; } |
|
256 |
|
257 _LIT( KUrlPrefix, "4 "); |
|
258 HBufC* param = HBufC::NewLC( aUrl.Length() + KUrlPrefix().Length() ); |
|
259 param->Des().Append( KUrlPrefix ); |
|
260 param->Des().Append( aUrl ); |
|
261 |
|
262 // Create browser launcher |
|
263 CBrowserLauncher* launcher = CBrowserLauncher::NewLC(); |
|
264 |
|
265 // Asynchronous operation to launch the browser with given URL |
|
266 launcher->LaunchBrowserEmbeddedL( |
|
267 *param, NULL, this, NULL ); |
|
268 |
|
269 CleanupStack::Pop( launcher ); |
|
270 iBrowserLauncher = launcher; |
|
271 launcher = NULL; |
|
272 |
|
273 CleanupStack::PopAndDestroy( param ); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CWmStore::HandleServerAppExit |
|
278 // --------------------------------------------------------- |
|
279 // |
|
280 void CWmStore::HandleServerAppExit( TInt aReason ) |
|
281 { |
|
282 MAknServerAppExitObserver::HandleServerAppExit( aReason ); |
|
283 delete iBrowserLauncher; |
|
284 iBrowserLauncher = NULL; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CWmStore::RunApplicationL |
|
289 // --------------------------------------------------------- |
|
290 // |
|
291 void CWmStore::RunApplicationL() |
|
292 { |
|
293 CWmConfiguration::TStoreAppType type = iWmConfItem.AppType(); |
|
294 if ( type == CWmConfiguration::EUnknown || |
|
295 type >= CWmConfiguration::EReserved ) |
|
296 { |
|
297 // Leave if not found |
|
298 User::Leave( KErrArgument ); |
|
299 } |
|
300 |
|
301 switch( type ) |
|
302 { |
|
303 case CWmConfiguration::ES60: |
|
304 case CWmConfiguration::EQt: |
|
305 { |
|
306 StartProcessL( iWmConfItem.AppUid(), |
|
307 iWmConfItem.AppParam() ); |
|
308 } |
|
309 break; |
|
310 case CWmConfiguration::ECwrt: |
|
311 { |
|
312 StartWidgetL( iWmConfItem.AppUid(), |
|
313 iWmConfItem.AppParam() ); |
|
314 } |
|
315 break; |
|
316 case CWmConfiguration::EWrt: |
|
317 { |
|
318 StartWidgetL( iWmConfItem.AppUid(), KNullDesC ); |
|
319 } |
|
320 break; |
|
321 } |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // CWmStore::StartProcessL |
|
326 // --------------------------------------------------------- |
|
327 // |
|
328 void CWmStore::StartProcessL( TUid aUid, const TDesC& aParam ) |
|
329 { |
|
330 RApaLsSession session; |
|
331 User::LeaveIfError( session.Connect() ); |
|
332 CleanupClosePushL( session ); |
|
333 |
|
334 //get app info |
|
335 TApaAppInfo appInfo; |
|
336 User::LeaveIfError( session.GetAppInfo( appInfo, aUid ) ); |
|
337 // do the launch |
|
338 RProcess process; |
|
339 User::LeaveIfError( process.Create( appInfo.iFullName, aParam ) ); |
|
340 process.Resume(); |
|
341 |
|
342 CleanupStack::PopAndDestroy( &session ); |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // CWmStore::StartWidgetL |
|
347 // --------------------------------------------------------- |
|
348 // |
|
349 void CWmStore::StartWidgetL( TUid aAppUid, const TDesC& aParams ) |
|
350 { |
|
351 if ( aAppUid == KNullUid ) |
|
352 User::Leave( KErrArgument ); |
|
353 |
|
354 HBufC* params = aParams.AllocLC(); |
|
355 |
|
356 RApaLsSession appArc; |
|
357 User::LeaveIfError( appArc.Connect() ); |
|
358 CleanupClosePushL( appArc ); |
|
359 |
|
360 TThreadId threadId; |
|
361 User::LeaveIfError( appArc.StartDocument( *params, aAppUid, threadId ) ); |
|
362 |
|
363 CleanupStack::PopAndDestroy( &appArc ); |
|
364 CleanupStack::PopAndDestroy( params ); |
|
365 } |
|
366 |
|
367 // End of file |
|