206 |
200 |
207 // --------------------------------------------------------------------------- |
201 // --------------------------------------------------------------------------- |
208 // Runs WIDGET method: (launches given widget with parameters) |
202 // Runs WIDGET method: (launches given widget with parameters) |
209 // --------------------------------------------------------------------------- |
203 // --------------------------------------------------------------------------- |
210 // |
204 // |
211 void TryRunWidgetL( const TDesC& aParam, const TDesC& aBundleId ) |
205 void TryRunWidgetL( const TDesC& aBundleId, const TDesC& aParam ) |
212 { |
206 { |
213 RApaLsSession session; |
207 RApaLsSession session; |
214 User::LeaveIfError( session.Connect() ); |
208 User::LeaveIfError( session.Connect() ); |
215 CleanupClosePushL( session ); |
209 CleanupClosePushL( session ); |
216 TApaAppInfo appInfo; |
210 TApaAppInfo appInfo; |
238 CleanupStack::PopAndDestroy( commandLine ); |
232 CleanupStack::PopAndDestroy( commandLine ); |
239 CleanupStack::PopAndDestroy( &session ); |
233 CleanupStack::PopAndDestroy( &session ); |
240 } |
234 } |
241 |
235 |
242 // --------------------------------------------------------------------------- |
236 // --------------------------------------------------------------------------- |
|
237 // Runs APPLICATION method: (launches given application with parameters) |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 void TryRunApplicationL( const TDesC& /*aApplication*/, const TDesC& /*aParam*/ ) |
|
241 { |
|
242 // This method has not been implemented |
|
243 User::Leave( KErrNotSupported ); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
243 // Tries to open a portal with given method and parameters. |
247 // Tries to open a portal with given method and parameters. |
244 // this method may be called twice on a portal button, if a primary |
248 // this method may be called twice on a portal button, if a primary |
245 // method fails. |
249 // method fails. |
246 // --------------------------------------------------------------------------- |
250 // --------------------------------------------------------------------------- |
247 // |
251 // |
248 void TryOpenPortalL( |
252 void TryOpenPortalL( |
249 CWmConfiguration::TMethod aMethod, const TDesC& aParam, |
253 CWmConfiguration::TMethod aMethod, const TDesC& aService, |
250 const TDesC& aBundleId ) |
254 const TDesC& aParam ) |
251 { |
255 { |
252 // open portal according to the method. |
256 // open portal according to the method. |
253 if ( aMethod == CWmConfiguration::EHttp ) |
257 if ( aMethod == CWmConfiguration::EHttp ) |
254 { TryRunHttpL( aParam ); } |
258 { TryRunHttpL( aParam ); } |
255 else if ( aMethod == CWmConfiguration::EWidget ) |
259 else if ( aMethod == CWmConfiguration::EWidget ) |
256 { TryRunWidgetL( aParam, aBundleId ); } |
260 { TryRunWidgetL( aService, aParam ); } |
|
261 else if ( aMethod == CWmConfiguration::EApplication ) |
|
262 { TryRunApplicationL( aService, aParam ); } |
257 else |
263 else |
258 { /* do nothing */ } |
264 { User::Leave( KErrNotSupported ); } |
259 } |
265 } |
260 |
266 |
261 // --------------------------------------------------------------------------- |
267 // --------------------------------------------------------------------------- |
262 // Opens a portal. Called when user presses a portal button. tries the |
268 // Opens a portal. Called when user presses a portal button. tries the |
263 // primary method, and if if fails, tries the secondary. If it fails, |
269 // primary method, and if if fails, tries the secondary. If it fails, |
268 CWmConfiguration& aConfiguration, TInt aPortalIndex ) |
274 CWmConfiguration& aConfiguration, TInt aPortalIndex ) |
269 { |
275 { |
270 TRAPD( err, |
276 TRAPD( err, |
271 TryOpenPortalL( |
277 TryOpenPortalL( |
272 aConfiguration.PortalButtonPrimaryMethod( aPortalIndex ), |
278 aConfiguration.PortalButtonPrimaryMethod( aPortalIndex ), |
273 aConfiguration.PortalButtonPrimaryParams( aPortalIndex ), |
279 aConfiguration.PortalButtonPrimaryService( aPortalIndex ), |
274 aConfiguration.PortalButtonBundleId( aPortalIndex ) ); ); |
280 aConfiguration.PortalButtonPrimaryParams( aPortalIndex ) ); ); |
275 if ( err != KErrNone ) |
281 if ( err != KErrNone ) |
276 { |
282 { |
277 // if secondary method fails, leave will be propagated. |
283 // if secondary method fails, leave will be propagated. |
278 TryOpenPortalL( |
284 TryOpenPortalL( |
279 aConfiguration.PortalButtonSecondaryMethod( aPortalIndex ), |
285 aConfiguration.PortalButtonSecondaryMethod( aPortalIndex ), |
280 aConfiguration.PortalButtonSecondaryParams( aPortalIndex ), |
286 aConfiguration.PortalButtonSecondaryService( aPortalIndex ), |
281 aConfiguration.PortalButtonBundleId( aPortalIndex ) ); |
287 aConfiguration.PortalButtonSecondaryParams( aPortalIndex ) ); |
282 } |
288 } |
283 } |
289 } |
284 |
290 |
285 // --------------------------------------------------------- |
291 // --------------------------------------------------------- |
286 // CWmPortalButton::ExecuteL |
292 // CWmPortalButton::ExecuteL |
427 CAknButtonState* state = State(); |
433 CAknButtonState* state = State(); |
428 if ( state ) |
434 if ( state ) |
429 { |
435 { |
430 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
436 TBool landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
431 |
437 |
432 |
|
433 // draw image if one exists |
438 // draw image if one exists |
434 if ( iButtonIcon && iButtonIconMask ) |
439 if ( iButtonIcon && iButtonIconMask ) |
435 { |
440 { |
436 TAknLayoutRect imageLayout; |
441 TAknLayoutRect imageLayout; |
437 // todo: 2-button layout |
442 imageLayout.LayoutRect( rect, |
438 if ( iWmMainContainer->Configuration().PortalButtonCount() == 1 ) |
443 AknLayoutScalable_Apps::wgtman_btn_pane_g1( |
439 { |
444 landscape ? 1 : 0).LayoutLine() ); |
440 imageLayout.LayoutRect( rect, |
|
441 AknLayoutScalable_Apps::wgtman_btn_pane_g1( |
|
442 landscape ? 1 : 0).LayoutLine() ); |
|
443 } |
|
444 imageLayout.DrawImage( gc, iButtonIcon, iButtonIconMask ); |
445 imageLayout.DrawImage( gc, iButtonIcon, iButtonIconMask ); |
445 } |
446 } |
446 |
447 |
447 // draw text if portrait |
448 // draw text if portrait |
448 if ( !landscape ) |
449 if ( !landscape ) |
449 { |
450 { |
450 TAknTextComponentLayout leftLayout; |
451 TAknTextComponentLayout leftLayout; |
451 // todo: 2-button layout |
452 leftLayout = AknLayoutScalable_Apps::wgtman_btn_pane_t1( |
452 if ( iWmMainContainer->Configuration().PortalButtonCount() == 1 ) |
453 landscape ? 1 : 0 ); |
453 { |
|
454 leftLayout = AknLayoutScalable_Apps::wgtman_btn_pane_t1( |
|
455 landscape ? 1 : 0 ); |
|
456 } |
|
457 DrawText( gc, state->Text(), leftLayout, 1 ); |
454 DrawText( gc, state->Text(), leftLayout, 1 ); |
458 } |
455 } |
459 } |
456 } |
460 } |
457 } |
461 |
458 |