idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
changeset 1 5315654608de
child 2 08c6ee43b396
equal deleted inserted replaced
0:f72a12da539e 1:5315654608de
       
     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 container control for WidgetManager application.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknViewAppUi.h>
       
    21 #include <eikappui.h>
       
    22 #include <widgetmanagerview.rsg>
       
    23 #include <coemain.h>
       
    24 #include <eikenv.h>
       
    25 #include <barsread.h>
       
    26 #include <AknUtils.h>
       
    27 #include <barsread.h>
       
    28 #include <StringLoader.h>
       
    29 #include <eikenv.h>
       
    30 #include <AknIconArray.h>
       
    31 #include <aknstyluspopupmenu.h> 
       
    32 #include <avkon.loc>
       
    33 #include <aknlayout.cdl.h>
       
    34 #include <layoutmetadata.cdl.h>
       
    35 #include <aknlayoutscalable_avkon.cdl.h>
       
    36 #include <aknlayoutscalable_apps.cdl.h>
       
    37 #include <AknLayout.lag>
       
    38 #include <AknsSkinInstance.h>
       
    39 #include <apgicnfl.h>
       
    40 #include <AknIconUtils.h>
       
    41 #include <AknsDrawUtils.h>
       
    42 #include <aknenv.h>
       
    43 #include <aknlists.h>
       
    44 #include <eikclbd.h>
       
    45 #include <aknsfld.h>
       
    46 #include <AknsBasicBackgroundControlContext.h>
       
    47 #include <apgcli.h>
       
    48 #include <widgetmanager.mbg>
       
    49 #include <avkon.rsg>
       
    50 #include <coecobs.h>
       
    51 #include <coecntrl.h>
       
    52 #include <SWInstApi.h> //installer
       
    53 #include <widgetregistryclient.h> // widgetreqistry
       
    54 #include <schemehandler.h> // for starting the OVI client
       
    55 #include <featmgr.h>     // FeatureManager
       
    56 #include <hlplch.h>      // HlpLauncher
       
    57 #include <csxhelp/hmsc.hlp.hrh>
       
    58 #include <aisystemuids.hrh>
       
    59 #include <centralrepository.h>
       
    60 
       
    61 #include "wmcrkeys.h"
       
    62 #include "wmcommon.h"
       
    63 #include "wmplugin.h"
       
    64 #include "wmmaincontainer.h"
       
    65 #include "wmmaincontainerview.h"
       
    66 #include "wmresourceloader.h"
       
    67 #include "widgetmanager.hrh"
       
    68 #include "wmlistbox.h"
       
    69 #include "wmpersistentwidgetorder.h"
       
    70 #include "wmdetailsdlg.h"
       
    71 #include "wmportalbutton.h"
       
    72 #include "wmwidgetloaderao.h"
       
    73 
       
    74 // CONSTANTS
       
    75 const TInt KTextLimit = 40; // Text-limit for find-field
       
    76 const TInt KMinWidgets = 1; // minimum number of widgets to show findpane
       
    77 _LIT8( KWrtMime, "application/x-nokia-widget");
       
    78 _LIT( KBrowserPrefix, "4 ");
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CWmMainContainer::CWmMainContainer()
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 CWmMainContainer::CWmMainContainer( CWmPlugin& aWmPlugin ) :
       
    85     iWmPlugin( aWmPlugin )
       
    86 	{
       
    87     iWidgetsList = NULL;
       
    88     iFindbox = NULL;
       
    89     iFindPaneIsVisible = EFalse;
       
    90     iBgContext = NULL;
       
    91     iFocusMode = ENowhere;
       
    92     iClosingDown = ETrue;
       
    93 	}
       
    94 
       
    95 // ---------------------------------------------------------
       
    96 // CWmMainContainer::~CWmMainContainer()
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 CWmMainContainer::~CWmMainContainer()
       
   100 	{
       
   101     delete iOviStoreUrl;
       
   102     delete iOviStoreClientBundleId;
       
   103     delete iOviStoreClientParam;
       
   104         
       
   105     RemoveCtrlsFromStack();
       
   106     Components().ResetAndDestroy();
       
   107     delete iWidgetLoader;
       
   108     iWidgetsList = NULL;
       
   109     iOviPortal = NULL;
       
   110     iFindbox = NULL;
       
   111 	delete iBgContext;
       
   112 	}
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CWmMainContainer::NewL
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 CWmMainContainer* CWmMainContainer::NewL( 
       
   119     const TRect& aRect,
       
   120     CWmPlugin& aWmPlugin )
       
   121 	{
       
   122 	CWmMainContainer* self = CWmMainContainer::NewLC( 
       
   123         aRect, 
       
   124         aWmPlugin );
       
   125 	CleanupStack::Pop( self );
       
   126 	return self;
       
   127 	}
       
   128 
       
   129 // ---------------------------------------------------------
       
   130 // CWmMainContainer::NewLC
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 CWmMainContainer* CWmMainContainer::NewLC( 
       
   134     const TRect& aRect,
       
   135     CWmPlugin& aWmPlugin )
       
   136 	{
       
   137 	CWmMainContainer* self = new (ELeave) CWmMainContainer( aWmPlugin );
       
   138 	CleanupStack::PushL( self );
       
   139 	self->ConstructL( aRect );
       
   140 	return self;
       
   141 	}
       
   142 
       
   143 // ---------------------------------------------------------
       
   144 // ScreenRect
       
   145 // rectangle representing the screen
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 TRect ScreenRect()
       
   149     {
       
   150     TRect screen;
       
   151     CCoeEnv* env = CCoeEnv::Static();
       
   152     if ( env )
       
   153         {
       
   154         CWsScreenDevice* screenDevice = env->ScreenDevice();
       
   155         if ( screenDevice )
       
   156             screen.SetRect( TPoint(0,0), screenDevice->SizeInPixels() );
       
   157         }
       
   158     return screen;
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------
       
   162 // CWmMainContainer::ConstructL
       
   163 // ---------------------------------------------------------
       
   164 //
       
   165 void CWmMainContainer::ConstructL( 
       
   166 		const TRect& aRect )
       
   167 	{  
       
   168     // Initialize control array
       
   169 	InitComponentArrayL();
       
   170 	Components().SetControlsOwnedExternally( ETrue );
       
   171 
       
   172     // create the UI
       
   173     CreateWindowL();
       
   174 
       
   175 	// background context
       
   176 	iBgContext = CAknsBasicBackgroundControlContext::NewL( 
       
   177 	        KAknsIIDQsnBgScreen, ScreenRect() , ETrue);
       
   178 
       
   179 	// Read needed values from cenrep
       
   180 	TRAP_IGNORE( FetchRepositoryDataL(); );
       
   181 	
       
   182 	// set up controls
       
   183 	InitializeControlsL( aRect );
       
   184 
       
   185 	// set size and activate
       
   186 	SetRect( aRect );
       
   187     ActivateL();
       
   188 	
       
   189 	}
       
   190 
       
   191 // ---------------------------------------------------------
       
   192 // CWmMainContainer::FetchRepositoryDataL
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 void CWmMainContainer::FetchRepositoryDataL()
       
   196     {
       
   197     iOviStoreUrl = NULL;
       
   198     iOviStoreClientBundleId = NULL;
       
   199     iOviStoreClientParam = NULL;
       
   200     
       
   201     CRepository *repository = CRepository::NewLC( 
       
   202             TUid::Uid( KCrWidgetManagerm ) );
       
   203     TInt err = KErrNone;
       
   204     
       
   205     //read localized data from cenrep
       
   206     TLanguage sysLang = User::Language();
       
   207     for( TUint32 i = KLangId0; i <= KLangId9; i+=4 )
       
   208         {
       
   209         TInt crLang = 0;
       
   210         err = repository->Get( i, crLang );
       
   211 
       
   212         if ( sysLang == crLang && err == KErrNone )
       
   213             {
       
   214             // system langauge matches langauge in cenrep
       
   215             iOviStoreUrl = HBufC::NewL( 
       
   216                     NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   217             TPtr ptr( iOviStoreUrl->Des() );
       
   218             
       
   219             // get localized ovi store url
       
   220             err = repository->Get( i + KOviStoreBrowserUrlOffset, ptr );
       
   221             if ( err != KErrNone )
       
   222                 {
       
   223                 delete iOviStoreUrl;
       
   224                 iOviStoreUrl = NULL;
       
   225                 }
       
   226             }
       
   227         }
       
   228     
       
   229     //read other data from cenrep
       
   230     iOviStoreClientBundleId = HBufC::NewL( 
       
   231             NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   232     TPtr ptr( iOviStoreClientBundleId->Des() );
       
   233     err = repository->Get( KOviStoreBunbleId, ptr );
       
   234     if ( err != KErrNone )
       
   235         {
       
   236         delete iOviStoreClientBundleId;
       
   237         iOviStoreClientBundleId = NULL;
       
   238         }
       
   239     
       
   240     iOviStoreClientParam = HBufC::NewL( 
       
   241             NCentralRepositoryConstants::KMaxUnicodeStringLength );
       
   242     ptr.Set( iOviStoreClientParam->Des() );
       
   243     err = repository->Get( KOviStoreClientParam, ptr );
       
   244     if ( err != KErrNone )
       
   245         {
       
   246         delete iOviStoreClientParam;
       
   247         iOviStoreClientParam = NULL;
       
   248         }
       
   249         
       
   250     CleanupStack::PopAndDestroy( repository );
       
   251     }
       
   252 	
       
   253 // ---------------------------------------------------------
       
   254 // CWmMainContainer::SizeChanged
       
   255 // ---------------------------------------------------------
       
   256 //
       
   257 void CWmMainContainer::SizeChanged()
       
   258 	{
       
   259 	CCoeControl::SizeChanged();
       
   260     iBgContext->SetRect( ScreenRect() );
       
   261 	LayoutControls();
       
   262 	}
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CWmMainContainer::LayoutControls
       
   266 // ---------------------------------------------------------
       
   267 //
       
   268 void CWmMainContainer::LayoutControls()
       
   269 	{
       
   270     TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
       
   271 
       
   272     TAknWindowLineLayout listPane = 
       
   273                 AknLayoutScalable_Apps::listscroll_wgtman_pane(landscape ? 1 : 0).LayoutLine();
       
   274 
       
   275     TAknWindowLineLayout btnPane = 
       
   276                 AknLayoutScalable_Apps::wgtman_btn_pane(landscape ? 1 : 0).LayoutLine();
       
   277 
       
   278 	TRect rect = Rect();	
       
   279     
       
   280 	if ( landscape )
       
   281 	    {
       
   282         if ( Layout_Meta_Data::IsMirrored() )
       
   283             {
       
   284             iLayout = ELandscapeMirrored;
       
   285             }
       
   286         else
       
   287             {
       
   288             iLayout = ELandscape;
       
   289             }
       
   290 	    }
       
   291 	else
       
   292 	    {
       
   293         iLayout = EPortrait;
       
   294 	    }
       
   295 	
       
   296     // layout Ovi button
       
   297     AknLayoutUtils::LayoutControl( iOviPortal, rect, btnPane );
       
   298     
       
   299     if( iFindbox && iFindPaneIsVisible )
       
   300         {
       
   301 		TAknLayoutRect layoutRect;
       
   302         layoutRect.LayoutRect( rect, listPane );
       
   303 		iWidgetsList->SetRect( layoutRect.Rect() );
       
   304         HandleFindSizeChanged();
       
   305         }
       
   306     else
       
   307         {
       
   308         AknLayoutUtils::LayoutControl( iWidgetsList, rect, listPane );
       
   309         }
       
   310 
       
   311     DrawDeferred();
       
   312 	}
       
   313 
       
   314 // ---------------------------------------------------------
       
   315 // CWmMainContainer::OfferKeyEventL
       
   316 // ---------------------------------------------------------
       
   317 //
       
   318 TKeyResponse CWmMainContainer::OfferKeyEventL( 
       
   319 		const TKeyEvent& aKeyEvent, 
       
   320 		TEventCode aType )
       
   321 	{
       
   322     TKeyResponse keyResponse( EKeyWasNotConsumed );
       
   323     
       
   324     if ( iFindbox )
       
   325         {
       
   326         // open search field with alpha digit numbers
       
   327         if ( aType == EEventKeyDown && !iFindPaneIsVisible && 
       
   328         aKeyEvent.iScanCode < EStdKeyF1 &&
       
   329             TChar(aKeyEvent.iScanCode).IsAlphaDigit() )
       
   330             {
       
   331             ActivateFindPaneL();
       
   332             
       
   333             if ( iFindPaneIsVisible )
       
   334                 {
       
   335                 return EKeyWasConsumed;
       
   336                 }
       
   337             }
       
   338         
       
   339         if ( iFindPaneIsVisible )
       
   340             {
       
   341             // deactive the FindPane when Back has been pressed
       
   342             if ( aType == EEventKeyDown && 
       
   343                 aKeyEvent.iScanCode == EStdKeyBackspace )
       
   344                 {
       
   345                 TBuf<KTextLimit> searchText;
       
   346                 iFindbox->GetSearchText( searchText );
       
   347                 if ( searchText == KNullDesC )
       
   348                     {
       
   349                     DeactivateFindPaneL();
       
   350                     return EKeyWasConsumed;
       
   351                     }
       
   352                 }
       
   353             
       
   354             // Cancel-selected need to unfocus findbox 
       
   355             // to receive event in ProcessCommand
       
   356             if ( aType == EEventKeyDown 
       
   357             && aKeyEvent.iScanCode == EStdKeyDevice1 )
       
   358                 {
       
   359                 iFindbox->SetFocus( EFalse );
       
   360                 UpdateFocusMode();
       
   361                 return EKeyWasConsumed;
       
   362                 }
       
   363 
       
   364             if ( aKeyEvent.iScanCode == EStdKeyNo ||
       
   365                 aKeyEvent.iCode == EKeyNo )
       
   366                 {
       
   367                 DeactivateFindPaneL();
       
   368                 return EKeyWasConsumed;
       
   369                 }
       
   370 
       
   371             // find items with all event codes (that's the reason why there is EEventKey instead of aType)
       
   372             TBool needsRefresh( EFalse );
       
   373             keyResponse = AknFind::HandleFindOfferKeyEventL( 
       
   374                                                 aKeyEvent, EEventKey, this, 
       
   375                                 iWidgetsList, iFindbox, ETrue, needsRefresh );            
       
   376             if ( needsRefresh )
       
   377                 {
       
   378                 DrawNow();
       
   379                 }
       
   380             }
       
   381         }
       
   382 
       
   383     // check special cases for movement between controls
       
   384     if ( keyResponse == EKeyWasNotConsumed && !iFindPaneIsVisible )
       
   385          {
       
   386          keyResponse = MoveFocusByKeys( aKeyEvent, aType );
       
   387          }
       
   388 
       
   389     // pass key event except backpace or delete key event to widgets list if focused
       
   390     if ( keyResponse == EKeyWasNotConsumed && iWidgetsList->IsFocused() )
       
   391         {
       
   392         if ( (aType == EEventKey) && (aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete))
       
   393             {
       
   394             if( CanDoUninstall() )
       
   395                 {
       
   396                 UninstallWidgetL();
       
   397                 }
       
   398             else
       
   399                 {
       
   400                 CWmWidgetData* data = iWidgetsList->WidgetData();
       
   401                 if( data != NULL )
       
   402                     iWmPlugin.ResourceLoader().InfoPopupL(
       
   403                          R_QTN_WM_UNINST_NOT_ALLOWED, data->Name() );
       
   404                 }
       
   405             }
       
   406         else 
       
   407             {
       
   408 			//passing to listbox handler
       
   409             keyResponse = iWidgetsList->OfferKeyEventL( 
       
   410                     aKeyEvent, aType );
       
   411             }
       
   412         }
       
   413 
       
   414     // pass key event to OVI portal if focused
       
   415     if ( keyResponse == EKeyWasNotConsumed && iOviPortal->IsFocused() )
       
   416         {
       
   417         keyResponse = iOviPortal->OfferKeyEventL( 
       
   418                             aKeyEvent, aType );
       
   419         }
       
   420 
       
   421     if ( keyResponse == EKeyWasConsumed )
       
   422         DrawDeferred();
       
   423 
       
   424 	// Do not let UI framework forward the keys to child controls as
       
   425 	// we have already done that.
       
   426     return EKeyWasConsumed;
       
   427 	}
       
   428 
       
   429 
       
   430 // ---------------------------------------------------------
       
   431 // CWmMainContainer::MoveFocusByKeys
       
   432 // ---------------------------------------------------------
       
   433 //
       
   434 TKeyResponse CWmMainContainer::MoveFocusByKeys(
       
   435                         const TKeyEvent& aKeyEvent, 
       
   436                         TEventCode aType )
       
   437     {
       
   438     TKeyResponse keyResponse( EKeyWasNotConsumed );
       
   439 
       
   440     if ( iWidgetsList->IsFocused() )
       
   441         {
       
   442         // ------------------------------------
       
   443         // focus is in the WIDGETS LIST
       
   444         // ------------------------------------
       
   445         if ( iLayout == EPortrait &&
       
   446                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
       
   447                 iWidgetsList->CurrentItemIndex() == 0 )
       
   448             {
       
   449             // widget list top -> up -> ovi button (portrait)
       
   450             if ( aType == EEventKey )
       
   451                 SetFocusToOviButton();
       
   452             keyResponse = EKeyWasConsumed;
       
   453             }
       
   454         else if ( iLayout == EPortrait &&
       
   455                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
       
   456                 iWidgetsList->CurrentItemIndex() ==
       
   457                    iWidgetsList->Model()->NumberOfItems() - 1 )
       
   458             {
       
   459             // widget list bottom -> down -> ovi button (portrait)
       
   460             if ( aType == EEventKey )
       
   461                 SetFocusToOviButton();
       
   462             keyResponse = EKeyWasConsumed;
       
   463             }
       
   464         else if ( iLayout == ELandscape &&
       
   465                 aKeyEvent.iScanCode == EStdKeyRightArrow )
       
   466             {
       
   467             // widget list -> right -> ovi button (landscape)
       
   468             if ( aType == EEventKey )
       
   469                 SetFocusToOviButton();
       
   470             keyResponse = EKeyWasConsumed;
       
   471             }
       
   472         else if ( iLayout == ELandscapeMirrored &&
       
   473                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
   474             {
       
   475             // widget list -> left -> ovi button (landscape mirrored)
       
   476             if ( aType == EEventKey )
       
   477                 SetFocusToOviButton();
       
   478             keyResponse = EKeyWasConsumed;
       
   479             }
       
   480         }
       
   481     else if ( iOviPortal->IsFocused() )
       
   482         {
       
   483         // ------------------------------------
       
   484         // focus is in the OVI PORTAL BUTTON
       
   485         // ------------------------------------
       
   486         if ( iLayout == EPortrait &&
       
   487                 aKeyEvent.iScanCode == EStdKeyDownArrow )
       
   488             {
       
   489             // ovi button -> down -> widget list top (portrait)
       
   490             if ( aType == EEventKey )
       
   491                 SetFocusToWidgetList( 0 );
       
   492             keyResponse = EKeyWasConsumed;
       
   493             }
       
   494         else if ( iLayout == EPortrait &&
       
   495                 aKeyEvent.iScanCode == EStdKeyUpArrow )
       
   496             {
       
   497             // obi button -> up -> widget list bottom (portrait)
       
   498             if ( aType == EEventKey )
       
   499                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
       
   500             keyResponse = EKeyWasConsumed;
       
   501             }
       
   502         else if ( iLayout == ELandscape &&
       
   503                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
   504             {
       
   505             // ovi button -> left -> widget list (landscape)
       
   506             if ( aType == EEventKey )
       
   507                 SetFocusToWidgetList();
       
   508             keyResponse = EKeyWasConsumed;
       
   509             }
       
   510         else if ( iLayout == ELandscapeMirrored &&
       
   511                 aKeyEvent.iScanCode == EStdKeyRightArrow )
       
   512             {
       
   513             // ovi button -> right -> widget list (landscape mirrored)
       
   514             if ( aType == EEventKey )
       
   515                 SetFocusToWidgetList();
       
   516             keyResponse = EKeyWasConsumed;
       
   517             }
       
   518         }
       
   519     else
       
   520         {
       
   521         // ------------------------------------
       
   522         // focus is NOWHERE
       
   523         // ------------------------------------
       
   524         if ( aKeyEvent.iScanCode == EStdKeyUpArrow ||
       
   525                 aKeyEvent.iScanCode == EStdKeyDownArrow ||
       
   526                 aKeyEvent.iScanCode == EStdKeyLeftArrow ||
       
   527                 aKeyEvent.iScanCode == EStdKeyRightArrow )
       
   528             {
       
   529             // no focus -> key hit -> focus list
       
   530             if ( aType == EEventKey )
       
   531                 SetFocusToWidgetList();
       
   532             keyResponse = EKeyWasConsumed;
       
   533             }
       
   534         }
       
   535 
       
   536     return keyResponse;
       
   537     }
       
   538 
       
   539 // ---------------------------------------------------------
       
   540 // CWmMainContainer::SetFocusToOviButton
       
   541 // ---------------------------------------------------------
       
   542 //
       
   543 void CWmMainContainer::SetFocusToOviButton()
       
   544     {
       
   545     iWidgetsList->SetFocus(EFalse);
       
   546     iOviPortal->SetFocus(ETrue);
       
   547     DrawDeferred();
       
   548     UpdateFocusMode();
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------
       
   552 // CWmMainContainer::SetFocusToWidgetList
       
   553 // ---------------------------------------------------------
       
   554 //
       
   555 void CWmMainContainer::SetFocusToWidgetList( TInt aIndex )
       
   556     {
       
   557     iOviPortal->SetFocus(EFalse);
       
   558     iWidgetsList->SetFocus(ETrue);
       
   559     if ( aIndex >= 0 && aIndex < iWidgetsList->Model()->NumberOfItems() )
       
   560         {
       
   561         iWidgetsList->SetCurrentItemIndex( aIndex );
       
   562         }
       
   563     DrawDeferred();
       
   564     UpdateFocusMode();
       
   565     }
       
   566 
       
   567 // ---------------------------------------------------------
       
   568 // CWmMainContainer::UpdateFocusMode
       
   569 // ---------------------------------------------------------
       
   570 //
       
   571 void CWmMainContainer::UpdateFocusMode()
       
   572     {
       
   573     if ( iOviPortal->IsFocused() )
       
   574         {
       
   575         // OVI BUTTON is focused 
       
   576         iFocusMode = EOvi;
       
   577         }
       
   578     else if( ( iFindPaneIsVisible ) && 
       
   579         ( iFindbox->IsFocused() || iWidgetsList->IsFocused() ) )
       
   580         {
       
   581         // FIND MODE
       
   582         iFocusMode = EFind;
       
   583         }
       
   584     else if ( iWidgetsList->IsFocused() )
       
   585         {
       
   586         // WIDGETS LIST is focused 
       
   587         iFocusMode = EList;
       
   588         }
       
   589     else
       
   590         {
       
   591         // NO focus
       
   592         iFocusMode = ENowhere;
       
   593         }
       
   594     }
       
   595 
       
   596 // ---------------------------------------------------------
       
   597 // CWmMainContainer::FindChildControlByPoint
       
   598 // ---------------------------------------------------------
       
   599 //
       
   600 CCoeControl* CWmMainContainer::FindChildControlByPoint(
       
   601         const TPoint& aPoint )
       
   602     {
       
   603     CCoeControl* theControl = NULL;
       
   604     CCoeControlArray::TCursor cursor = Components().Begin();
       
   605     CCoeControl* c;
       
   606     while((c=cursor.Control<CCoeControl>()) != NULL )
       
   607         {
       
   608         if(c->IsVisible())
       
   609             {
       
   610             if ( c->Rect().Contains( aPoint ) ) theControl = c;
       
   611             }
       
   612         cursor.Next();
       
   613         }
       
   614     return theControl;
       
   615     }
       
   616 
       
   617 // ---------------------------------------------------------
       
   618 // CWmMainContainer::HandlePointerEventL
       
   619 // ---------------------------------------------------------
       
   620 //
       
   621 void CWmMainContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   622     {
       
   623     if ( !iClosingDown  )
       
   624         {
       
   625 		
       
   626 		if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
   627 			{
       
   628 	        // Check if user clicked a child control
       
   629 	        CCoeControl* control = FindChildControlByPoint( aPointerEvent.iPosition );
       
   630 	        if ( control && !control->IsFocused() )
       
   631 	            {
       
   632 	            // set focus to selected list box item.           
       
   633                 if ( control == iWidgetsList )
       
   634                     {
       
   635                     TInt itemIndex = iWidgetsList->CurrentListBoxItemIndex();
       
   636                     TBool itemPointed = iWidgetsList->View()->XYPosToItemIndex(
       
   637                             aPointerEvent.iParentPosition,
       
   638                             itemIndex );
       
   639                     if ( itemIndex >= 1 && itemPointed )
       
   640                         {
       
   641                         iWidgetsList->SetCurrentItemIndex( itemIndex - 1 );
       
   642                         }
       
   643                     }
       
   644 
       
   645 	            // Set focus to the control that was clicked
       
   646 	            control->SetFocus( ETrue );
       
   647 	            // remove focus from ALL other child controls.
       
   648 	            CCoeControlArray::TCursor cursor = Components().Begin();
       
   649 	            CCoeControl* c;
       
   650 	            while ((c=cursor.Control<CCoeControl>()) != NULL )
       
   651 	                {
       
   652 	                if ( c != control && c->IsFocused() ) c->SetFocus( EFalse );
       
   653 	                cursor.Next();
       
   654 	                }
       
   655 	            // update focus mode accordingly
       
   656 	            UpdateFocusMode();
       
   657 	            // repaint
       
   658 	            DrawDeferred();
       
   659 	            }
       
   660 			}
       
   661         
       
   662         CCoeControl::HandlePointerEventL( aPointerEvent );
       
   663         }
       
   664     }
       
   665 
       
   666 // ---------------------------------------------------------
       
   667 // CWmMainContainer::InitializeControlsL
       
   668 // ---------------------------------------------------------
       
   669 //
       
   670 void CWmMainContainer::InitializeControlsL( const TRect& /*aRect*/ )
       
   671 	{
       
   672 	// Create OVI STORE button
       
   673     HBufC* oviText = StringLoader::LoadLC( R_QTN_WM_GO_TO_OVI_STORE );    
       
   674     iOviPortal = CWmPortalButton::NewL( this, *oviText );
       
   675     CleanupStack::PopAndDestroy( oviText );
       
   676     
       
   677     iOviPortal->SetMopParent( this );    
       
   678     AddControlL( iOviPortal, EOviPortal );
       
   679     
       
   680     // Create widget list box
       
   681     iWidgetsList = CWmListBox::NewL(
       
   682             iWmPlugin,
       
   683             TRect(),
       
   684             this );
       
   685     iWidgetsList->SetMopParent( this );
       
   686     AddControlL( iWidgetsList, EWidgetsList );
       
   687 	iWidgetsList->ActivateL();
       
   688     iWidgetsList->SetListBoxObserver( this );
       
   689     
       
   690     // Create scroll bar.
       
   691     iWidgetsList->CreateScrollBarFrameL( ETrue );
       
   692     iWidgetsList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   693         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   694     iWidgetsList->UpdateScrollBarsL(); 
       
   695     
       
   696     // search field
       
   697     iFindbox = CAknSearchField::NewL( *this,
       
   698                         CAknSearchField::EAdaptiveSearch,
       
   699                         0, KTextLimit );
       
   700     AddControlL( iFindbox, EFindBox );
       
   701 
       
   702     UpdateFocusMode();
       
   703     StartLoadingWidgetsL();
       
   704     }
       
   705 
       
   706 // ---------------------------------------------------------
       
   707 // CWmMainContainer::HandleWidgetListChanged
       
   708 // ---------------------------------------------------------
       
   709 //
       
   710 void CWmMainContainer::HandleWidgetListChanged()
       
   711     {
       
   712     TRAP_IGNORE( StartLoadingWidgetsL(); );
       
   713     }
       
   714 
       
   715 // ---------------------------------------------------------
       
   716 // CWmMainContainer::StartLoadingWidgetsL
       
   717 // ---------------------------------------------------------
       
   718 //
       
   719 void CWmMainContainer::StartLoadingWidgetsL()
       
   720     {
       
   721     if ( !iWidgetLoader )
       
   722         {
       
   723         // create the widget loader AO
       
   724         iWidgetLoader = CWmWidgetLoaderAo::NewL( iWmPlugin, *iWidgetsList );
       
   725         }
       
   726     iWidgetLoader->StartLoading();
       
   727     }
       
   728 
       
   729 // ---------------------------------------------------------
       
   730 // CWmMainContainer::HandleResourceChange
       
   731 // ---------------------------------------------------------
       
   732 //
       
   733 void CWmMainContainer::HandleResourceChange( TInt aType )
       
   734 	{
       
   735     CCoeControl::HandleResourceChange( aType );
       
   736 	
       
   737     if ( KEikDynamicLayoutVariantSwitch == aType )
       
   738         {
       
   739         TRect rect;
       
   740         AknLayoutUtils::LayoutMetricsRect( 
       
   741                             AknLayoutUtils::EMainPane, rect );
       
   742         SetRect( rect );
       
   743         
       
   744         // notify widgetlist
       
   745         iWidgetsList->HandleLayoutChanged();
       
   746         }
       
   747     else if ( KAknsMessageSkinChange == aType )
       
   748         {
       
   749         // notify widgetlist , colored add icon need to be updated 
       
   750         iWidgetsList->HandleSkinChanged();
       
   751         }
       
   752 	}
       
   753 
       
   754 
       
   755 // ---------------------------------------------------------
       
   756 // CWmMainContainer::MopSupplyObject
       
   757 // ---------------------------------------------------------
       
   758 //
       
   759 TTypeUid::Ptr CWmMainContainer::MopSupplyObject( TTypeUid aId )
       
   760     {
       
   761     if ( aId.iUid == MAknsControlContext::ETypeId )
       
   762         {
       
   763         return MAknsControlContext::SupplyMopObject( 
       
   764                                             aId, iBgContext );
       
   765         }
       
   766     return CCoeControl::MopSupplyObject( aId );
       
   767     }
       
   768 
       
   769 // ---------------------------------------------------------
       
   770 // CWmMainContainer::Draw
       
   771 // ---------------------------------------------------------
       
   772 //
       
   773 void CWmMainContainer::Draw( const TRect& /*aRect*/ ) const
       
   774 	{
       
   775 	CWindowGc& gc = SystemGc();	
       
   776     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   777     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   778     AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
   779 	}
       
   780 
       
   781 // ---------------------------------------------------------
       
   782 // CWmMainContainer::AddControlL
       
   783 // ---------------------------------------------------------
       
   784 //
       
   785 void CWmMainContainer::AddControlL( 
       
   786                                 CCoeControl* aControl, 
       
   787                                 TInt aControlId )
       
   788     {
       
   789     Components().AppendLC( aControl, aControlId ); // Ownership transfered 
       
   790     CleanupStack::Pop(aControl);    
       
   791     iWmPlugin.ViewAppUi().AddToStackL( aControl );
       
   792     aControl->MakeVisible( ETrue );
       
   793     }
       
   794 
       
   795 // ---------------------------------------------------------
       
   796 // CWmMainContainer::WmPlugin
       
   797 // ---------------------------------------------------------
       
   798 //
       
   799 CWmPlugin& CWmMainContainer::WmPlugin()
       
   800     {    
       
   801     return iWmPlugin;
       
   802     }
       
   803 
       
   804 // ---------------------------------------------------------
       
   805 // CWmMainContainer::PortalSelected
       
   806 // ---------------------------------------------------------
       
   807 //
       
   808 TBool CWmMainContainer::PortalSelected()
       
   809     {    
       
   810     return ( iFocusMode == EOvi );
       
   811     }
       
   812 
       
   813 // ---------------------------------------------------------
       
   814 // CWmMainContainer::WidgetSelected
       
   815 // ---------------------------------------------------------
       
   816 //
       
   817 TBool CWmMainContainer::WidgetSelected() 
       
   818     {
       
   819     return ( iFocusMode == EList ) || ( iFocusMode == EFind );
       
   820     }
       
   821 
       
   822 // ---------------------------------------------------------
       
   823 // CWmMainContainer::CanDoAdd
       
   824 // ---------------------------------------------------------
       
   825 //
       
   826 TBool CWmMainContainer::CanDoAdd()
       
   827     {
       
   828     TBool retVal = EFalse;
       
   829     CWmWidgetData* data = iWidgetsList->WidgetData();
       
   830     if ( WidgetSelected() && data )
       
   831         {
       
   832         if ( data->HsContentInfo().CanBeAdded() )
       
   833             retVal = ETrue;
       
   834         }
       
   835     return retVal;
       
   836     }
       
   837 
       
   838 // ---------------------------------------------------------
       
   839 // CWmMainContainer::CanDoUninstall
       
   840 // ---------------------------------------------------------
       
   841 //
       
   842 TBool CWmMainContainer::CanDoUninstall() 
       
   843     {
       
   844     TBool retVal( EFalse );
       
   845     CWmWidgetData* data = iWidgetsList->WidgetData();
       
   846     if ( WidgetSelected() && data )
       
   847         {
       
   848         if ( data->WidgetType() == CWmWidgetData::ECps &&
       
   849                 data->PublisherUid() != KNullUid )
       
   850             {
       
   851             retVal = ETrue;
       
   852             }
       
   853         }
       
   854     return retVal;
       
   855     }
       
   856 
       
   857 // ---------------------------------------------------------
       
   858 // CWmMainContainer::CanDoLaunch
       
   859 // ---------------------------------------------------------
       
   860 //
       
   861 TBool CWmMainContainer::CanDoLaunch() 
       
   862     {
       
   863     TBool retVal(EFalse);
       
   864     if ( WidgetSelected() )
       
   865         {
       
   866         CWmWidgetData* data = iWidgetsList->WidgetData();        
       
   867         if ( data->WidgetType() == CWmWidgetData::ECps &&
       
   868             data->PublisherUid() != KNullUid )
       
   869             {
       
   870             retVal = ETrue;
       
   871             }
       
   872         }
       
   873     return retVal;
       
   874     }
       
   875 
       
   876 // ---------------------------------------------------------
       
   877 // CWmMainContainer::CanDoFind
       
   878 // ---------------------------------------------------------
       
   879 //
       
   880 TBool CWmMainContainer::CanDoFind()
       
   881     {
       
   882     TBool canDo( !iFindPaneIsVisible );
       
   883     if ( canDo )
       
   884         {
       
   885         canDo = ( iFocusMode == EList || iFocusMode == ENowhere );
       
   886         }
       
   887     return canDo;
       
   888     }
       
   889 
       
   890 // ---------------------------------------------------------
       
   891 // CWmMainContainer::CanDoSort
       
   892 // ---------------------------------------------------------
       
   893 //
       
   894 TBool CWmMainContainer::CanDoSort()
       
   895     {
       
   896     return !iFindPaneIsVisible;
       
   897     }
       
   898 
       
   899 // ---------------------------------------------------------
       
   900 // CWmMainContainer::CanDoDetails
       
   901 // ---------------------------------------------------------
       
   902 //
       
   903 TBool CWmMainContainer::CanDoDetails()
       
   904     {
       
   905     return WidgetSelected();
       
   906     }
       
   907 
       
   908 // ---------------------------------------------------------
       
   909 // CWmMainContainer::CanDoHelp
       
   910 // ---------------------------------------------------------
       
   911 //
       
   912 TBool CWmMainContainer::CanDoHelp()
       
   913     {
       
   914     return FeatureManager::FeatureSupported( KFeatureIdHelp );
       
   915     }
       
   916 
       
   917 // ---------------------------------------------------------------------------
       
   918 // CWmMainContainer::AddWidgetToHomeScreenL
       
   919 // ---------------------------------------------------------------------------
       
   920 //
       
   921 void CWmMainContainer::AddWidgetToHomeScreenL()
       
   922     {
       
   923     CWmWidgetData* data = iWidgetsList->WidgetData();
       
   924     if ( !iClosingDown && data )
       
   925         {
       
   926         if ( iFindbox && iFindPaneIsVisible )
       
   927             {
       
   928             DeactivateFindPaneL();
       
   929             }
       
   930 
       
   931         // set add to homescreen to be executed later
       
   932         iWmPlugin.SetPostponedCommandL(
       
   933                 CWmPlugin::EAddToHomescreen, data->HsContentInfo() );
       
   934 
       
   935         iWmPlugin.Deactivate();
       
   936         }
       
   937     }
       
   938 	
       
   939 // ---------------------------------------------------------------------------
       
   940 // CWmMainContainer::LaunchWidgetL
       
   941 // ---------------------------------------------------------------------------
       
   942 //
       
   943 void CWmMainContainer::LaunchWidgetL()
       
   944     {
       
   945     if ( CanDoLaunch() )
       
   946         {
       
   947         CWmWidgetData* data = iWidgetsList->WidgetData();
       
   948         
       
   949         HBufC* param = KNullDesC().AllocLC(); // launch params
       
   950         
       
   951         RApaLsSession appArc;
       
   952         User::LeaveIfError( appArc.Connect() ); // connect to AppArc server
       
   953         CleanupClosePushL( appArc );
       
   954         TThreadId id;
       
   955         User::LeaveIfError( appArc.StartDocument(
       
   956             *param, data->PublisherUid(), id ) );
       
   957     
       
   958         CleanupStack::PopAndDestroy( &appArc );      
       
   959         CleanupStack::PopAndDestroy( param );
       
   960         }
       
   961     }
       
   962 
       
   963 // ---------------------------------------------------------------------------
       
   964 // CWmMainContainer::ActivateFindPaneL
       
   965 // ---------------------------------------------------------------------------
       
   966 //
       
   967 void CWmMainContainer::ActivateFindPaneL()
       
   968     {
       
   969     if ( iFindbox && !iFindPaneIsVisible &&
       
   970             iWidgetsList->Model()->NumberOfItems() > KMinWidgets )
       
   971         {
       
   972 		// enable filtering
       
   973         CAknFilteredTextListBoxModel* m = 
       
   974                 static_cast <CAknFilteredTextListBoxModel*> ( iWidgetsList->Model() );
       
   975         if ( m )
       
   976             {
       
   977             m->CreateFilterL( iWidgetsList, iFindbox );
       
   978             if ( m->Filter() )
       
   979                 {
       
   980                 m->Filter()->SetParentControl( this );
       
   981                 }
       
   982             }
       
   983 
       
   984         iFindbox->ActivateL();
       
   985         iFindbox->ResetL();
       
   986         iFindbox->SetSearchTextL( KNullDesC );
       
   987         iFindbox->SetSkinEnabledL( ETrue );
       
   988 
       
   989         iFindPaneIsVisible = ETrue;
       
   990         iFindbox->MakeVisible( ETrue );
       
   991         
       
   992         // layout listbox and findbox
       
   993         LayoutControls();        
       
   994         
       
   995         iFindbox->SetFocus( ETrue );
       
   996         iWidgetsList->SetFindPaneIsVisible( ETrue );
       
   997 
       
   998         // set soft key set
       
   999         CEikButtonGroupContainer* cbaGroup =
       
  1000             CEikButtonGroupContainer::Current();
       
  1001         cbaGroup->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_CANCEL__SELECT );
       
  1002         cbaGroup->DrawNow();
       
  1003 
       
  1004         UpdateFocusMode();
       
  1005         }
       
  1006     }
       
  1007 
       
  1008 // ---------------------------------------------------------------------------
       
  1009 // CWmMainContainer::DeactivateFindPaneL
       
  1010 // ---------------------------------------------------------------------------
       
  1011 //
       
  1012 void CWmMainContainer::DeactivateFindPaneL()
       
  1013     {
       
  1014     if( iFindbox && iFindPaneIsVisible )
       
  1015 	    {
       
  1016         // notify search field we're shutting down
       
  1017         TKeyEvent keyEvent = { EKeyNo, EStdKeyNo, 0, 0  };
       
  1018         iFindbox->OfferKeyEventL( keyEvent, EEventKey );
       
  1019         
       
  1020         // reset findbox
       
  1021         iFindbox->ResetL();
       
  1022 
       
  1023         // reset filter
       
  1024         CAknFilteredTextListBoxModel* m = 
       
  1025                 static_cast <CAknFilteredTextListBoxModel*> ( iWidgetsList->Model() );
       
  1026         if ( m && m->Filter() )
       
  1027             {
       
  1028             m->Filter()->ResetFilteringL();
       
  1029             m->RemoveFilter();
       
  1030             }
       
  1031 
       
  1032         iFindbox->MakeVisible( EFalse );
       
  1033         iFindbox->SetFocus( EFalse );
       
  1034         iFindPaneIsVisible = EFalse;
       
  1035         iWidgetsList->SetFindPaneIsVisible( EFalse );
       
  1036         
       
  1037         LayoutControls();
       
  1038         iWidgetsList->SetFocus( ETrue );
       
  1039 
       
  1040         // set soft key set
       
  1041         CEikButtonGroupContainer* cbaGroup =
       
  1042             CEikButtonGroupContainer::Current();
       
  1043         cbaGroup->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT );
       
  1044         cbaGroup->DrawNow();
       
  1045 
       
  1046         UpdateFocusMode();
       
  1047         DrawNow();
       
  1048         }
       
  1049     }
       
  1050 
       
  1051 // ---------------------------------------------------------------------------
       
  1052 // CWmMainContainer::SortListAlphabeticallyL
       
  1053 // ---------------------------------------------------------------------------
       
  1054 //
       
  1055 void CWmMainContainer::SortListAlphabeticallyL()
       
  1056     {
       
  1057     if ( iWidgetsList )
       
  1058         {
       
  1059         iWidgetsList->SetSortOrderL( CWmListBox::EAlphabetical );
       
  1060        
       
  1061         //store changed list order
       
  1062         CWmPersistentWidgetOrder* widgetOrder =
       
  1063             CWmPersistentWidgetOrder::NewL( iWmPlugin.FileServer() );
       
  1064         CleanupStack::PushL( widgetOrder );
       
  1065         widgetOrder->StoreL( iWidgetsList->WidgetDataArray() );
       
  1066         CleanupStack::PopAndDestroy( widgetOrder );
       
  1067 
       
  1068         }
       
  1069     }
       
  1070 
       
  1071 // ---------------------------------------------------------------------------
       
  1072 // CWmMainContainer::UninstallWidgetL
       
  1073 // ---------------------------------------------------------------------------
       
  1074 //
       
  1075 void CWmMainContainer::UninstallWidgetL()
       
  1076     {
       
  1077     if ( CanDoUninstall() )
       
  1078         {
       
  1079         CWmWidgetData* data = iWidgetsList->WidgetData();
       
  1080         
       
  1081         SwiUI::RSWInstLauncher installer;
       
  1082         User::LeaveIfError( installer.Connect() );
       
  1083         
       
  1084         installer.Uninstall( data->PublisherUid(), KWrtMime );
       
  1085         installer.Close();
       
  1086         }
       
  1087     }
       
  1088 
       
  1089 // ---------------------------------------------------------------------------
       
  1090 // CWmMainContainer::OpenOviPortalL
       
  1091 // ---------------------------------------------------------------------------
       
  1092 //
       
  1093 void CWmMainContainer::OpenOviPortalL()
       
  1094     {
       
  1095     if ( !iClosingDown )
       
  1096         {
       
  1097         RApaLsSession session;
       
  1098         User::LeaveIfError( session.Connect() );
       
  1099         CleanupClosePushL( session );
       
  1100         TApaAppInfo appInfo;
       
  1101         TUid launchUid;
       
  1102 
       
  1103         // Get ovi store uid    
       
  1104         RWidgetRegistryClientSession widgetSession;
       
  1105         User::LeaveIfError( widgetSession.Connect() );    
       
  1106         CleanupClosePushL( widgetSession );
       
  1107         
       
  1108         launchUid.iUid = widgetSession.GetWidgetUidL( *iOviStoreClientBundleId );    
       
  1109         CleanupStack::PopAndDestroy( &widgetSession );
       
  1110 
       
  1111         TInt err = session.GetAppInfo( appInfo, launchUid );
       
  1112         if ( err == KErrNone )
       
  1113             {
       
  1114             CApaCommandLine* commandLine = CApaCommandLine::NewLC();
       
  1115             commandLine->SetExecutableNameL(appInfo.iFullName); 
       
  1116             HBufC8* buf8 = HBufC8::NewLC( iOviStoreClientParam->Des().Length() );
       
  1117             buf8->Des().Copy( *iOviStoreClientParam );
       
  1118                     
       
  1119             //cmdLine->SetOpaqueDataL( *buf8 );
       
  1120             commandLine->SetTailEndL( *buf8 );
       
  1121             err = session.StartApp( *commandLine );
       
  1122             CleanupStack::PopAndDestroy( buf8 );
       
  1123             CleanupStack::PopAndDestroy( commandLine );
       
  1124             }
       
  1125         else
       
  1126             {
       
  1127             if( iOviStoreUrl )
       
  1128                 {
       
  1129                 // Ovi store not found start browser
       
  1130                 const TUid KOSSBrowserUidValue = { 0x10008D39 };
       
  1131                 HBufC* param = HBufC::NewLC( iOviStoreUrl->Length() + 
       
  1132                         KBrowserPrefix().Length() );
       
  1133                 
       
  1134                 param->Des().Copy( KBrowserPrefix );
       
  1135                 param->Des().Append( *iOviStoreUrl );
       
  1136                 
       
  1137                 TUid id( KOSSBrowserUidValue );
       
  1138                 
       
  1139                 TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  1140                 TApaTask task = taskList.FindApp(id);
       
  1141                 if( task.Exists() )
       
  1142                     {
       
  1143                     task.BringToForeground();
       
  1144                     HBufC8* param8 = HBufC8::NewLC(param->Length());
       
  1145                     param8->Des().Append(*param);
       
  1146                     task.SendMessage(TUid::Uid(0), *param8); // UID not used
       
  1147                     CleanupStack::PopAndDestroy(param8);
       
  1148                     }
       
  1149                 else
       
  1150                     {
       
  1151                     if( !session.Handle() )
       
  1152                         {
       
  1153                         User::LeaveIfError( session.Connect() );
       
  1154                         }
       
  1155                     TThreadId thread;
       
  1156                     User::LeaveIfError(session.StartDocument(*param, KOSSBrowserUidValue, thread));
       
  1157                       
       
  1158                     }
       
  1159                 CleanupStack::PopAndDestroy( param );
       
  1160                 }
       
  1161             }
       
  1162         CleanupStack::PopAndDestroy( &session );
       
  1163         }
       
  1164     }
       
  1165 
       
  1166 // ---------------------------------------------------------------------------
       
  1167 // CWmMainContainer::SelectL
       
  1168 // ---------------------------------------------------------------------------
       
  1169 //
       
  1170 void CWmMainContainer::SelectL()
       
  1171     {
       
  1172     if ( WidgetSelected() )
       
  1173         AddWidgetToHomeScreenL();
       
  1174     else if ( PortalSelected() )
       
  1175         OpenOviPortalL();
       
  1176     else
       
  1177         SetFocusToWidgetList();
       
  1178     }
       
  1179 
       
  1180 // ---------------------------------------------------------------------------
       
  1181 // CWmMainContainer::ShowHelpL
       
  1182 // ---------------------------------------------------------------------------
       
  1183 //
       
  1184 void CWmMainContainer::ShowHelpL()
       
  1185     {
       
  1186     TUid fwUid = TUid::Uid( AI_UID3_AIFW_COMMON );
       
  1187     // retrieve resolve host application help context
       
  1188     CArrayFix<TCoeHelpContext>* helpContext =
       
  1189         iEikonEnv->EikAppUi()->AppHelpContextL();
       
  1190 
       
  1191     // add the widget manager entry into the help context
       
  1192     CleanupStack::PushL( helpContext );
       
  1193     helpContext->InsertL( 0, TCoeHelpContext(
       
  1194             fwUid, KWM_HLP_WIDGET_COLLECTION ) );
       
  1195     CleanupStack::Pop( helpContext );
       
  1196 
       
  1197     // launch help
       
  1198     HlpLauncher::LaunchHelpApplicationL(
       
  1199           iEikonEnv->WsSession(),
       
  1200           helpContext );
       
  1201     helpContext = 0; // HlpLauncher takes ownership of helpContext
       
  1202     }
       
  1203 
       
  1204 // ---------------------------------------------------------------------------
       
  1205 // CWmMainContainer::RemoveCtrlsFromStack
       
  1206 // ---------------------------------------------------------------------------
       
  1207 //
       
  1208 void CWmMainContainer::RemoveCtrlsFromStack()
       
  1209     {    
       
  1210     for ( TInt i=0; i < CountComponentControls(); i++ ) 
       
  1211         {
       
  1212         CCoeControl* ctl = ComponentControl( i ) ;
       
  1213         if ( ctl )
       
  1214             {
       
  1215             iWmPlugin.ViewAppUi().RemoveFromStack( ctl );
       
  1216             }
       
  1217         }
       
  1218     }
       
  1219 
       
  1220 // ---------------------------------------------------------------------------
       
  1221 // CWmMainContainer::HandleListBoxEventL
       
  1222 // ---------------------------------------------------------------------------
       
  1223 //
       
  1224 void CWmMainContainer::HandleListBoxEventL(
       
  1225         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
  1226     {
       
  1227     if ( !iClosingDown && ( aEventType == EEventEnterKeyPressed ||
       
  1228             aEventType == EEventItemSingleClicked ) )
       
  1229         {
       
  1230         AddWidgetToHomeScreenL();
       
  1231         }
       
  1232     }
       
  1233 
       
  1234 // ----------------------------------------------------
       
  1235 // CWmMainContainer::LaunchDetailsDialogL
       
  1236 // ----------------------------------------------------
       
  1237 //
       
  1238 void CWmMainContainer::LaunchDetailsDialogL()
       
  1239     {
       
  1240     CWmWidgetData* data = iWidgetsList->WidgetData();
       
  1241     if ( data )
       
  1242         {
       
  1243         const CFbsBitmap* logo = ( data->LogoImage() ) ? 
       
  1244                     data->LogoImage() : iWidgetsList->DefaultLogo();
       
  1245         const CFbsBitmap* mask = ( data->LogoImageMask() ) ? 
       
  1246                     data->LogoImageMask() : iWidgetsList->DefaultMask();
       
  1247         
       
  1248         TPtrC description = ( data->Description().Length() > 0 ) ? 
       
  1249             data->Description() : iWmPlugin.ResourceLoader().NoDescriptionText();
       
  1250         CWmDetailsDlg* dlg = CWmDetailsDlg::NewL(
       
  1251                 data->Name(), description, 
       
  1252                 data->HsContentInfo().CanBeAdded(),
       
  1253                 logo, mask, iBgContext );
       
  1254 
       
  1255         if ( dlg && dlg->ExecuteLD() == ECbaAddToHs )
       
  1256             {
       
  1257             AddWidgetToHomeScreenL();
       
  1258             }
       
  1259         }
       
  1260     }
       
  1261 
       
  1262 // ----------------------------------------------------
       
  1263 // CWmMainContainer::SetClosingDown
       
  1264 // ----------------------------------------------------
       
  1265 //
       
  1266 void CWmMainContainer::SetClosingDown( TBool aClosingDown )
       
  1267     {
       
  1268     iClosingDown = aClosingDown;
       
  1269     }
       
  1270 
       
  1271 // ----------------------------------------------------
       
  1272 // CWmMainContainer::ClosingDown
       
  1273 // ----------------------------------------------------
       
  1274 //
       
  1275 TBool CWmMainContainer::ClosingDown()
       
  1276     {
       
  1277     return iClosingDown;
       
  1278     }
       
  1279 
       
  1280 // ----------------------------------------------------
       
  1281 // CWmMainContainer::HandleFindSizeChanged
       
  1282 // ----------------------------------------------------
       
  1283 //
       
  1284 void CWmMainContainer::HandleFindSizeChanged()
       
  1285     {    
       
  1286     TAknWindowLineLayout findPane = 
       
  1287             AknLayoutScalable_Avkon::find_pane().LayoutLine();
       
  1288 
       
  1289     TAknWindowLineLayout listPane;
       
  1290 
       
  1291     TRect listRect = iWidgetsList->Rect();
       
  1292     listPane.il = listRect.iTl.iX;
       
  1293     listPane.it = listRect.iTl.iY;
       
  1294     listPane.ib = 0;
       
  1295     listPane.iH = TUint16( listRect.Height() - ( findPane.iH - 1 ) );
       
  1296     listPane.iW = listRect.Width();
       
  1297     listPane.ir = ELayoutEmpty;
       
  1298     
       
  1299     // set findpane width equal to listwidth
       
  1300     findPane.iW = listPane.iW;
       
  1301 
       
  1302     TRect rect = Rect();
       
  1303     AknLayoutUtils::LayoutControl( iFindbox, rect, findPane );
       
  1304     AknLayoutUtils::LayoutControl( iWidgetsList, rect, listPane );
       
  1305     
       
  1306     iWidgetsList->DrawNow();
       
  1307     }
       
  1308 
       
  1309 
       
  1310 // End of File
       
  1311