uifw/AknGlobalUI/AknCapServer/src/AknFastswapWindowControl.cpp
changeset 47 2f0c06423c72
parent 14 3320e4e6e8bb
equal deleted inserted replaced
46:0e1e0022bd03 47:2f0c06423c72
    37 #include <skinlayout.cdl.h>
    37 #include <skinlayout.cdl.h>
    38 
    38 
    39 #include <akntransitionutils.h>
    39 #include <akntransitionutils.h>
    40 #include <akntranseffect.h>
    40 #include <akntranseffect.h>
    41 #include <gfxtranseffect/gfxtranseffect.h>
    41 #include <gfxtranseffect/gfxtranseffect.h>
    42 #include <WidgetRegistryConstants.h>
       
    43 #include <WidgetRegistryData.h>
       
    44 #include <featmgr.h>
    42 #include <featmgr.h>
    45 #include <aknglobalpopupprioritycontroller.h>
    43 #include <aknglobalpopupprioritycontroller.h>
    46 #include <centralrepository.h>
    44 #include <centralrepository.h>
    47 #include <AknTasHook.h>
    45 #include <AknTasHook.h>
    48 #include <touchfeedback.h>
    46 #include <touchfeedback.h>
   155     CAknTransitionUtils::RemoveObserver( this, aEvent );
   153     CAknTransitionUtils::RemoveObserver( this, aEvent );
   156     _AKNTRACE_FUNC_EXIT; 
   154     _AKNTRACE_FUNC_EXIT; 
   157     return KErrNone;
   155     return KErrNone;
   158     }
   156     }
   159 
   157 
   160 NONSHARABLE_CLASS(CAknWidgetList) : public CBase
       
   161     {
       
   162     public:
       
   163         static CAknWidgetList* NewL( CAknFastSwapWindowControl& aParent );
       
   164         /** Destructor */
       
   165         ~CAknWidgetList();
       
   166 
       
   167         /**
       
   168          * Initializes the list that stores widgets.
       
   169          * @return   -
       
   170          */        
       
   171         void InitializeWidgetListL();
       
   172 
       
   173         /**
       
   174          * Check if a uid is the uid of the widget application.
       
   175          * @param    aAppUid The application uid to be checked.
       
   176          * @return   ETrue application uid belongs to widget application - EFalse otherwise.
       
   177          */
       
   178         TBool IsWidgetAppUI( TUid aAppUid );
       
   179 
       
   180         /**
       
   181          * Check if the window group id value refers to widget.
       
   182          * @param aWgId window group id.
       
   183          * @return ETrue if window group id has value that refers to widget.
       
   184          */
       
   185         TBool IsWidget( TInt aWgId );
       
   186 
       
   187         /**
       
   188          * Map tasklist application index to application Uid.
       
   189          *  
       
   190          * @param    aIndex index of tasklist item array.
       
   191          * @param    aAlwaysShownCount number of applications that are always shown on
       
   192                      the active applications list.
       
   193          * @return   application Uid
       
   194          */
       
   195         TUid IndexToAppUid( TInt aIndex, TInt aAlwaysShownCount );
       
   196         
       
   197     private:
       
   198         /** Constructor */
       
   199         CAknWidgetList( CAknFastSwapWindowControl& aParent );
       
   200         void ConstructL();
       
   201         void ResetArrayOfWidgetInfo( RWidgetInfoArray& aWidgetInfoArr );
       
   202         
       
   203         static void CleanupConnect( TAny* aThis );
       
   204 
       
   205     public:
       
   206         /** Contains list of widgets that are currently running */
       
   207         RWidgetInfoArray iRunningWidgets;
       
   208     private:
       
   209         CAknFastSwapWindowControl& iParent;
       
   210         RWidgetRegistryClientSession iWidgetRegistryClientSession;
       
   211     };
       
   212 
       
   213 
       
   214 CAknWidgetList* CAknWidgetList::NewL( CAknFastSwapWindowControl& aParent )
       
   215     {
       
   216     _AKNTRACE_FUNC_ENTER;
       
   217     CAknWidgetList* self = new (ELeave) CAknWidgetList( aParent );
       
   218     CleanupStack::PushL(self);
       
   219     self->ConstructL();
       
   220     CleanupStack::Pop(); //self
       
   221     _AKNTRACE_FUNC_EXIT;
       
   222     return self;
       
   223     }
       
   224     
       
   225 CAknWidgetList::CAknWidgetList( CAknFastSwapWindowControl& aParent ): iParent( aParent )
       
   226     {
       
   227     }
       
   228 
       
   229 CAknWidgetList::~CAknWidgetList()
       
   230     {
       
   231     _AKNTRACE_FUNC_ENTER;    
       
   232     ResetArrayOfWidgetInfo( iRunningWidgets );        
       
   233     iRunningWidgets.Reset();
       
   234     _AKNTRACE_FUNC_EXIT;
       
   235     }
       
   236 
       
   237 void CAknWidgetList::ConstructL()
       
   238     {
       
   239     }
       
   240     
       
   241 void CAknWidgetList::CleanupConnect( TAny* aThis )
       
   242     {
       
   243     _AKNTRACE_FUNC_ENTER;
       
   244      (( CAknWidgetList*)aThis)->iWidgetRegistryClientSession.Disconnect();   
       
   245     _AKNTRACE_FUNC_EXIT;
       
   246     }
       
   247 
       
   248 void CAknWidgetList::InitializeWidgetListL()
       
   249     {
       
   250     _AKNTRACE_FUNC_ENTER;
       
   251     ResetArrayOfWidgetInfo( iRunningWidgets );
       
   252     iRunningWidgets.Reset();
       
   253     User::LeaveIfError( iWidgetRegistryClientSession.Connect() );
       
   254     CleanupStack::PushL( TCleanupItem( CleanupConnect, this) );
       
   255     iWidgetRegistryClientSession.RunningWidgetsL(iRunningWidgets);
       
   256     for ( TInt i = iRunningWidgets.Count() - 1; i > -1; i-- )
       
   257         {
       
   258         if ( !iWidgetRegistryClientSession.IsWidgetInFullView(iRunningWidgets[i]->iUid) )
       
   259             {
       
   260             delete iRunningWidgets[i];
       
   261             iRunningWidgets.Remove(i);
       
   262             }
       
   263         }
       
   264     CleanupStack::Pop(); // clean WidgetRegistryClientSession item
       
   265     iWidgetRegistryClientSession.Disconnect();
       
   266     _AKNTRACE_FUNC_EXIT;
       
   267     }
       
   268     
       
   269 TBool CAknWidgetList::IsWidgetAppUI( TUid aAppUid )
       
   270     {
       
   271     _AKNTRACE( "[%s] aAppUid = %d", 
       
   272 	           __FUNCTION__, aAppUid.iUid );
       
   273     return (aAppUid == KWidgetAppUid);
       
   274     }
       
   275 
       
   276 TBool CAknWidgetList::IsWidget( TInt aWgId )
       
   277     {
       
   278     _AKNTRACE( "[%s] aWgId = %d", 
       
   279 	           __FUNCTION__, aWgId );
       
   280     return (aWgId == KWidgetWithoutWG);
       
   281     }
       
   282 
       
   283 TUid CAknWidgetList::IndexToAppUid( TInt aIndex, TInt aAlwaysShownCount )
       
   284     {
       
   285     _AKNTRACE( "[%s] aIndex = %d aAlwaysShownCount = %d",
       
   286     		   __FUNCTION__, aIndex, aAlwaysShownCount );
       
   287     return iRunningWidgets[aIndex + iRunningWidgets.Count() + 
       
   288         aAlwaysShownCount - iParent.iNumberOfWGs]->iUid;
       
   289     }
       
   290 
       
   291 void CAknWidgetList::ResetArrayOfWidgetInfo( 
       
   292     RWidgetInfoArray& aWidgetInfoArr )
       
   293     {
       
   294     _AKNTRACE_FUNC_ENTER;
       
   295     for ( TInt i = 0; i < aWidgetInfoArr.Count(); i++ )
       
   296         {
       
   297         CWidgetInfo *item = aWidgetInfoArr[i];
       
   298         delete item ; 
       
   299         }
       
   300     _AKNTRACE_FUNC_EXIT;
       
   301     }
       
   302 
       
   303 
       
   304 NONSHARABLE_CLASS(CAknAlwaysShownAppList) : public CBase
   158 NONSHARABLE_CLASS(CAknAlwaysShownAppList) : public CBase
   305     {
   159     {
   306     public:
   160     public:
   307        // always shown application info  
   161        // always shown application info  
   308        // used in the always shown application list
   162        // used in the always shown application list
   526 // ================= MEMBER FUNCTIONS =======================
   380 // ================= MEMBER FUNCTIONS =======================
   527 // C++ default constructor can NOT contain any code, that
   381 // C++ default constructor can NOT contain any code, that
   528 // might leave.
   382 // might leave.
   529 //
   383 //
   530 CAknFastSwapWindowControl::CAknFastSwapWindowControl(CAknCapAppServerAppUi& aAppUi)
   384 CAknFastSwapWindowControl::CAknFastSwapWindowControl(CAknCapAppServerAppUi& aAppUi)
   531 : iAppUi( aAppUi ),iLowMemory( EFalse ), iLowMemIcons( EFalse ), iAppArcSessionInitiated( EFalse ),
   385 : iAppUi( aAppUi ), iLowMemory( EFalse ), iLowMemIcons( EFalse ), iAppArcSessionInitiated( EFalse ),
   532   iWidgetAppUiWgId(-1), iWidgetsSupported( EFalse ),
   386   iTooltipModeTouch( EFalse ), iTransparencyEnabled( CAknEnv::Static()->TransparencyEnabled() ), 
   533   iTooltipModeTouch( EFalse ),iTransparencyEnabled( CAknEnv::Static()->TransparencyEnabled() ), 
       
   534   iIsStylusPopupShow(EFalse), iState( EWaiting )
   387   iIsStylusPopupShow(EFalse), iState( EWaiting )
   535     { 
   388     { 
   536     AKNTASHOOK_ADD( this, "CAknFastSwapWindowControl" );
   389     AKNTASHOOK_ADD( this, "CAknFastSwapWindowControl" );
   537     }
   390     }
   538 
   391 
   557             {
   410             {
   558             Window().SetBackgroundColor(~0);
   411             Window().SetBackgroundColor(~0);
   559             }
   412             }
   560         }
   413         }
   561 
   414 
   562     if (FeatureManager::FeatureSupported(KFeatureIdWebWidgets))
       
   563         {   
       
   564         iWidgetsSupported = ETrue;     
       
   565         }
       
   566     CreateCbaL();
   415     CreateCbaL();
   567     CreateGridL();
   416     CreateGridL();
   568     CreateItemArraysL();
   417     CreateItemArraysL();
   569     CreateTooltipL();
   418     CreateTooltipL();
   570     CreateLabelL();
   419     CreateLabelL();
   585         KAknsIIDQsnFrPopup, nullRect, nullRect, EFalse);
   434         KAknsIIDQsnFrPopup, nullRect, nullRect, EFalse);
   586 
   435 
   587     // the list for always shown applications in the fast swap
   436     // the list for always shown applications in the fast swap
   588     iAlwaysShownList = CAknAlwaysShownAppList::NewL( *this );
   437     iAlwaysShownList = CAknAlwaysShownAppList::NewL( *this );
   589 
   438 
   590     if (iWidgetsSupported)
       
   591         {        
       
   592         iWidgetList = CAknWidgetList::NewL( *this );
       
   593         }
       
   594     MakeVisible( EFalse );
   439     MakeVisible( EFalse );
   595     _AKNTRACE_FUNC_EXIT; 
   440     _AKNTRACE_FUNC_EXIT; 
   596     }
   441     }
   597     
   442     
   598 // Destructor
   443 // Destructor
   608     if ( iGrid )
   453     if ( iGrid )
   609         {
   454         {
   610         AknsUtils::DeregisterControlPosition( iGrid );
   455         AknsUtils::DeregisterControlPosition( iGrid );
   611         }
   456         }
   612     delete iAlwaysShownList;
   457     delete iAlwaysShownList;
   613     delete iWidgetList;
   458     
   614     FadeBackground( EFalse );
   459     FadeBackground( EFalse );
   615     delete iFrameContext;
   460     delete iFrameContext;
   616     delete iGrid; // destroys also iIconArray and scrollbar frame
   461     delete iGrid; // destroys also iIconArray and scrollbar frame
   617     delete iShownWgIds;
   462     delete iShownWgIds;
   618     if ( iAllWgIds )
   463     if ( iAllWgIds )
   884         iAppArcSessionInitiated = ETrue;
   729         iAppArcSessionInitiated = ETrue;
   885         }
   730         }
   886     iAppArcSession.GetAllApps();
   731     iAppArcSession.GetAllApps();
   887     // create list for always shown applications    
   732     // create list for always shown applications    
   888     iAlwaysShownList->InitializeAlwaysShownListL();         
   733     iAlwaysShownList->InitializeAlwaysShownListL();         
   889     if (iWidgetsSupported)
   734     
   890         {        
       
   891         iWidgetList->InitializeWidgetListL();
       
   892         }
       
   893     //Initializes CAknFastSwapWindowControl private data ( iWgIds, iNumberOfWGs )
   735     //Initializes CAknFastSwapWindowControl private data ( iWgIds, iNumberOfWGs )
   894     RWsSession& wsSession=iEikonEnv->WsSession();
   736     RWsSession& wsSession=iEikonEnv->WsSession();
   895     TInt count=wsSession.NumWindowGroups( 0 );
   737     TInt count=wsSession.NumWindowGroups( 0 );
   896 
   738 
   897     RArray<RWsSession::TWindowGroupChainInfo>* allWgIds = new (ELeave)
   739     RArray<RWsSession::TWindowGroupChainInfo>* allWgIds = new (ELeave)
   938             // always shown applications are appended to the end of window group list 
   780             // always shown applications are appended to the end of window group list 
   939             if ( iAlwaysShownList->IsAlwaysShownApp( applicationUid ) )
   781             if ( iAlwaysShownList->IsAlwaysShownApp( applicationUid ) )
   940                 {
   782                 {
   941                 iAlwaysShownList->AddWgGroupToAlwaysShownList( applicationUid, wgId );
   783                 iAlwaysShownList->AddWgGroupToAlwaysShownList( applicationUid, wgId );
   942                 }
   784                 }
   943             else if (iWidgetsSupported && iWidgetList->IsWidgetAppUI(applicationUid))
   785             
   944                 {
       
   945                 iWidgetAppUiWgId = wgId;
       
   946                 }
       
   947             // could't use windowName->IsAppReady(), because then java and console application
   786             // could't use windowName->IsAppReady(), because then java and console application
   948             // wouldn't be seen in FSW. Now it is possible that some system apps are seen at the
   787             // wouldn't be seen in FSW. Now it is possible that some system apps are seen at the
   949             // beginning of their start for a while in FSW (even they should be hidden all the time)
   788             // beginning of their start for a while in FSW (even they should be hidden all the time)
   950             // temporary solution since application shell is normally hidden from tasklist
   789             // temporary solution since application shell is normally hidden from tasklist
   951             // and in the new solution it should be shown
   790             // and in the new solution it should be shown
   954                 {
   793                 {
   955                 SWindowGroupInfo wgInfo = { wgId, windowName->IsSystem() };
   794                 SWindowGroupInfo wgInfo = { wgId, windowName->IsSystem() };
   956                 shownWgIds->AppendL(wgInfo);
   795                 shownWgIds->AppendL(wgInfo);
   957                 }
   796                 }
   958             CleanupStack::PopAndDestroy();  //windowName
   797             CleanupStack::PopAndDestroy();  //windowName
   959             }
       
   960         }
       
   961 
       
   962     if (iWidgetsSupported)
       
   963         {        
       
   964         for ( TInt index = 0; index < iWidgetList->iRunningWidgets.Count(); index++)
       
   965             {
       
   966             SWindowGroupInfo wgInfo = { KWidgetWithoutWG, EFalse };
       
   967             shownWgIds->AppendL( wgInfo );
       
   968             }
   798             }
   969         }
   799         }
   970 
   800 
   971     // always shown applications are appended to the end of window group list 
   801     // always shown applications are appended to the end of window group list 
   972     for ( TInt index = 0; index < iAlwaysShownList->iAppList->Count(); index++)
   802     for ( TInt index = 0; index < iAlwaysShownList->iAppList->Count(); index++)
  2041             name.AppendNum( index ); 
  1871             name.AppendNum( index ); 
  2042             
  1872             
  2043             name.Append( KTab );
  1873             name.Append( KTab );
  2044             name.Append( caption );
  1874             name.Append( caption );
  2045             }
  1875             }
  2046         else if (iWidgetsSupported && iWidgetList->IsWidget( wgId ))
       
  2047             {
       
  2048             appUid = iWidgetList->IndexToAppUid( index, iAlwaysShownList->iAppList->Count() );
       
  2049             iAppArcSession.GetAppInfo( info, appUid );
       
  2050 
       
  2051             // retrieve the app name
       
  2052             TPtrC caption = info.iShortCaption;
       
  2053             name.Zero();
       
  2054             
       
  2055             // conversion from TInt to TReal, might be a problem in the future
       
  2056             name.AppendNum( index ); 
       
  2057             
       
  2058             name.Append( KTab );
       
  2059             name.Append( caption );            
       
  2060             }            
       
  2061         //
  1876         //
  2062         // Running Applications
  1877         // Running Applications
  2063         //
  1878         //
  2064         else 
  1879         else 
  2065             {
  1880             {
  2229     // launches application and closes fastswap
  2044     // launches application and closes fastswap
  2230     if ( wgId == KApplicationWithoutWG )
  2045     if ( wgId == KApplicationWithoutWG )
  2231         {
  2046         {
  2232         LaunchAppL( iAlwaysShownList->IndexToAppUid( aIndex ) );
  2047         LaunchAppL( iAlwaysShownList->IndexToAppUid( aIndex ) );
  2233         }
  2048         }
  2234     else if ( iWidgetsSupported && wgId == KWidgetWithoutWG )
       
  2235         {
       
  2236         LaunchAppL( iWidgetList->IndexToAppUid( aIndex, iAlwaysShownList->iAppList->Count() ) );
       
  2237         }
       
  2238     // brings existing application to foreground and closes fastswap    
  2049     // brings existing application to foreground and closes fastswap    
  2239     else 
  2050     else 
  2240         {
  2051         {
  2241         if ( iAlwaysShownList->IsAlwaysShownApp( wgId ) &&
  2052         if ( iAlwaysShownList->IsAlwaysShownApp( wgId ) &&
  2242              iAlwaysShownList->IndexToAppUid( aIndex ) == KMenuAppUid )
  2053              iAlwaysShownList->IndexToAppUid( aIndex ) == KMenuAppUid )
  3031     // if this leaves, okToClose will be left as ETrue
  2842     // if this leaves, okToClose will be left as ETrue
  3032     iTooltip->HideInfoPopupNote();
  2843     iTooltip->HideInfoPopupNote();
  3033 
  2844 
  3034     iIsClosing = ETrue;
  2845     iIsClosing = ETrue;
  3035     
  2846     
  3036     if (iWidgetsSupported && iWidgetList->IsWidget( iConfirmCloseWgId ))
  2847     if ( aIsShift )
  3037         {
       
  3038         TWsEvent event;
       
  3039         event.SetType(EEventUser);
       
  3040             
       
  3041         TUid widgetUid = iWidgetList->IndexToAppUid(aIndex, iAlwaysShownList->iAppList->Count());
       
  3042 
       
  3043         TInt32 widgetAppUiUidInt = KWidgetAppUid.iUid;
       
  3044         TInt32 widgetUidInt = widgetUid.iUid;
       
  3045         TUint8* eventData = event.EventData();
       
  3046         // Fill bits 0-31 with widget application Uid.
       
  3047         (TUint32&)*eventData = widgetAppUiUidInt;
       
  3048         eventData+=sizeof(TUint32);
       
  3049         // Fill bits 32-63 with uid of the widget that should be closed.
       
  3050         (TUint32&)*eventData = widgetUidInt;
       
  3051         // Send the event to Widget AppUi.
       
  3052         iEikonEnv->WsSession().SendEventToWindowGroup(iWidgetAppUiWgId, event);
       
  3053         }
       
  3054     else if ( aIsShift )
       
  3055         {
  2848         {
  3056         TApaTask task( iEikonEnv->WsSession() );
  2849         TApaTask task( iEikonEnv->WsSession() );
  3057         task.SetWgId( iConfirmCloseWgId );
  2850         task.SetWgId( iConfirmCloseWgId );
  3058         task.SendSystemEvent( EApaSystemEventShutdown);
  2851         task.SendSystemEvent( EApaSystemEventShutdown);
  3059         }
  2852         }