taskswitcher/server/src/tsdatalist.cpp
changeset 127 7b66bc3c6dc9
parent 125 26079c1bb561
equal deleted inserted replaced
126:efda7c0771b9 127:7b66bc3c6dc9
    14  * Description:  File containing application list classes
    14  * Description:  File containing application list classes
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 //INCLUDES:
    18 //INCLUDES:
    19 #include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
       
    20 #include <e32debug.h>
       
    21 #include <apgwgnam.h>
       
    22 #include <bitstd.h>
       
    23 #include <AknIconUtils.h> // avkon
       
    24 #include <apgicnfl.h> // fbsbitmap
       
    25 #include <AknIconSrvClient.h> 
       
    26 #include <fbs.h>
    19 #include <fbs.h>
    27 #include <apgwgnam.h>
       
    28 #include <QSizeF>
       
    29 #include <camenuiconutility.h>
       
    30 #include <apgcli.h>
    20 #include <apgcli.h>
    31 
    21 
       
    22 #include "tsutils.h"
    32 #include "tsdatalist.h"
    23 #include "tsdatalist.h"
    33 #include "tsentrykeygenerator.h"
       
    34 #include "tsscreenshotmsg.h"
    24 #include "tsscreenshotmsg.h"
    35 #include "tsunregscreenshotmsg.h"
    25 #include "tsunregscreenshotmsg.h"
    36 #include "tsvisibilitymsg.h"
       
    37 #include "tsresourcemanager.h"
    26 #include "tsresourcemanager.h"
    38 #include "tsrunningapp.h"
    27 #include "tsrunningapp.h"
    39 #include "tsrunningappstorage.h"
    28 #include "tsrunningappstorage.h"
    40 
    29 #include "tsiconprovider.h"
    41 // size for the created app icons
    30 #include "tsidlist.h"
    42 const TInt KAppIconWidth = 128;
       
    43 const TInt KAppIconHeight = 128;
       
    44 
       
    45 //uids to be hidden
       
    46 const TUid KHsApplicationUid = { 0x20022F35 };
       
    47 
    31 
    48 // ================= MEMBER FUNCTIONS =======================
    32 // ================= MEMBER FUNCTIONS =======================
    49 
    33 
    50 // --------------------------------------------------------------------------
    34 // --------------------------------------------------------------------------
    51 /**
    35 /**
    85  */
    69  */
    86 CTsDataList::~CTsDataList()
    70 CTsDataList::~CTsDataList()
    87     {
    71     {
    88     iData.ResetAndDestroy();
    72     iData.ResetAndDestroy();
    89     iVisibleData.Close();
    73     iVisibleData.Close();
    90     iHiddenUids.Close();
       
    91     RFbsSession::Disconnect();
       
    92     RAknIconSrvClient::Disconnect();
       
    93     delete iDefaultIcon;
       
    94     }
    74     }
    95 
    75 
    96 // --------------------------------------------------------------------------
    76 // --------------------------------------------------------------------------
    97 /**
    77 /**
    98  * Performs 2nd phase construction.
    78  * Performs 2nd phase construction.
    99  */
    79  */
   100 void CTsDataList::ConstructL()
    80 void CTsDataList::ConstructL()
   101     {
    81     {
   102     BaseConstructL();
    82     BaseConstructL();
   103     iHiddenUids.AppendL( KHsApplicationUid );
       
   104     User::LeaveIfError(RFbsSession::Connect());
       
   105     RAknIconSrvClient::Connect();
       
   106     QT_TRYCATCH_LEAVING(
       
   107         iDefaultIcon = HbIcon2CFbsBitmap( HbIcon("qtg_large_application") );)
       
   108     }
    83     }
   109 
    84 
   110 // --------------------------------------------------------------------------
    85 // --------------------------------------------------------------------------
   111 /**
    86 /**
   112  * Returns a reference to the current content.
    87  * Returns a reference to the current content.
   128                       MTsResourceManager &/*aResources*/, 
   103                       MTsResourceManager &/*aResources*/, 
   129                       const MTsRunningApplicationStorage& aStorage)
   104                       const MTsRunningApplicationStorage& aStorage)
   130     {
   105     {
   131     TRAP_IGNORE(RDebug::Print(_L("[TaskSwitcher] processing started"));
   106     TRAP_IGNORE(RDebug::Print(_L("[TaskSwitcher] processing started"));
   132                 RTsFswArray newAppsList;
   107                 RTsFswArray newAppsList;
   133                 CleanupResetAndDestroyPushL(newAppsList);
   108                 TaskSwitcher::CleanupResetAndDestroyPushL(newAppsList);
   134                 CollectAppsL(newAppsList, aStorage);
   109                 CollectAppsL(newAppsList, aStorage);
   135                 RDebug::Print(_L("[TaskSwitcher] gathered app info"));
   110                 RDebug::Print(_L("[TaskSwitcher] gathered app info"));
   136                 FitDataToListL(newAppsList);
   111                 FitDataToListL(newAppsList);
   137                 CleanupStack::PopAndDestroy(&newAppsList);
   112                 CleanupStack::PopAndDestroy(&newAppsList);
   138                 RDebug::Print(_L("[TaskSwitcher] processing finished"));
   113                 RDebug::Print(_L("[TaskSwitcher] processing finished"));
   148                                const MTsRunningApplicationStorage& aStorage)
   123                                const MTsRunningApplicationStorage& aStorage)
   149     {
   124     {
   150     for( TInt i(0); i < aStorage.Count(); ++i )
   125     for( TInt i(0); i < aStorage.Count(); ++i )
   151         {
   126         {
   152         TTsEntryKey key;
   127         TTsEntryKey key;
   153         TInt err = TsEntryKeyGeneraror::Generate( key, 
   128         TInt err = aStorage.GenerateKey(key, aStorage[i].WindowGroupId());
   154                                                   aStorage[i].WindowGroupId(), 
       
   155                                                   aStorage );
       
   156         //skip this entry if it is already on list or generate key failed
   129         //skip this entry if it is already on list or generate key failed
   157         if( err!=KErrNone || FindEntry( aAppsList, key ) >= 0 ) 
   130         if( err!=KErrNone || FindEntry( aAppsList, key ) >= 0 ) 
   158             {
   131             {
   159             continue;
   132             continue;
   160             }
   133             }
   161 
   134 
   162         // get screen number (-1=console, 0=main screen, 1=cover ui)
   135         // get screen number (-1=console, 0=main screen, 1=cover ui)
   163         TInt appScreen = 0;
   136         TInt appScreen = 0;
   164         TInt scrNumErr = 
   137         TInt scrNumErr = 
   165             iResources.ApaSession().GetDefaultScreenNumber( appScreen, 
   138             iResources.ApaSession().GetDefaultScreenNumber( appScreen, 
   166                                                             aStorage[i].UidL() );
   139                                                             aStorage[i].Uid() );
   167         
   140         
   168         if( aStorage[i].UidL().iUid && 
   141         if( aStorage[i].Uid().iUid && 
   169             !aStorage[i].IsHiddenL() && 
   142             MTsRunningApplication::None == aStorage[i].HideMode()&& 
   170             (appScreen == 0 || appScreen == -1) && 
   143             (appScreen == 0 || appScreen == -1) && 
   171             scrNumErr == KErrNone )
   144             scrNumErr == KErrNone )
   172             {
   145             {
   173             AddEntryL( key, aStorage[i], aAppsList );
   146             AddEntryL(key, aStorage[i], aAppsList );
   174             }
   147             }
   175         }
   148         }
   176     }
   149     }
   177 
   150 
   178 // --------------------------------------------------------------------------
   151 // --------------------------------------------------------------------------
   179 /**
   152 /**
   180  * Called from CollectTasksL for each entry in the task list.
   153  * Called from CollectTasksL for each entry in the task list.
   181  * @param   aKey       entry key
       
   182  * @param   aRunningApp  running application entry
   154  * @param   aRunningApp  running application entry
   183  * @param   aNewList   list to add to
   155  * @param   aNewList   list to add to
   184  */
   156  */
   185 void CTsDataList::AddEntryL( const TTsEntryKey& aKey, 
   157 void CTsDataList::AddEntryL( const TTsEntryKey aKey, 
   186                              const MTsRunningApplication& aRunningApp, 
   158                              const MTsRunningApplication& aRunningApp, 
   187                              RTsFswArray& aNewList )
   159                              RTsFswArray& aNewList )
   188     {
   160     {
   189     CTsEntry* entry = CTsEntry::NewLC( aKey, iObserver, &iEnv );
   161     CTsRunningAppEntry* entry = CTsRunningAppEntry::NewLC(aKey,
   190     // check if present in old list and if yes then take some of the old data
   162                                                           aRunningApp,
   191     TBool found = ConsiderOldDataL( aKey );
   163                                                           iResources,
   192     // if not present previously then find out app name
   164                                                           iObserver, 
   193     // and check if screenshot is already available
   165                                                           &iEnv );
   194     if( !found )
       
   195         {
       
   196         entry->SetAppUid(aRunningApp.UidL());
       
   197         HBufC* name = FindAppNameLC( aRunningApp );
       
   198         entry->SetAppNameL(*name);
       
   199         CleanupStack::PopAndDestroy( name );
       
   200         //transfer ownership to entry
       
   201         entry->SetAppIcon( GetAppIconL( aRunningApp.UidL() ) );
       
   202         }
       
   203     entry->SetCloseableApp( !aRunningApp.IsSystemL());
       
   204     // add to new list, ownership is transferred
   166     // add to new list, ownership is transferred
   205     aNewList.AppendL( entry );
   167     aNewList.AppendL( entry );
   206     CleanupStack::Pop( entry );
   168     CleanupStack::Pop( entry );
   207     }
   169     }
   208 
   170 
   212  * If yes then it takes some of the data for the entry that
   174  * If yes then it takes some of the data for the entry that
   213  * will correspond to the same app in the refreshed content list.
   175  * will correspond to the same app in the refreshed content list.
   214  * @param   aKey      new key in content list
   176  * @param   aKey      new key in content list
   215  * @return  ETrue if app was found
   177  * @return  ETrue if app was found
   216  */
   178  */
   217 TBool CTsDataList::ConsiderOldDataL( const TTsEntryKey& aKey )
   179 TBool CTsDataList::ConsiderOldData( const TTsEntryKey& aKey )
   218     {
   180     {
   219     for(TInt entryIdx = 0, oldCount = iData.Count(); entryIdx < oldCount; ++entryIdx) 
   181     for(TInt entryIdx = 0, oldCount = iData.Count(); entryIdx < oldCount; ++entryIdx) 
   220         {
   182         {
   221         if (iData[entryIdx]->Key() == aKey) 
   183         if (iData[entryIdx]->Key().Key() == aKey.Key()) 
   222             {
   184             {
   223             return ETrue;
   185             return ETrue;
   224             }
   186             }
   225         }
   187         }
   226     return EFalse;
   188     return EFalse;
   227     }
       
   228 
       
   229 // --------------------------------------------------------------------------
       
   230 /**
       
   231  * Finds out the application name.
       
   232  * @param   aWindowName window group name or NULL
       
   233  * @param   aAppUId     application uid
       
   234  * @param   aWgId       window group id
       
   235  * @return  application name, ownership transferred to caller
       
   236  */
       
   237 HBufC* CTsDataList::FindAppNameLC( const MTsRunningApplication& aRunningApp )
       
   238     {
       
   239     //Retrieve the app name
       
   240     TApaAppInfo info;
       
   241     iResources.ApaSession().GetAppInfo( info, aRunningApp.UidL() );
       
   242     TPtrC caption = info.iShortCaption;
       
   243 
       
   244     HBufC* tempName( 0 );
       
   245     if (!caption.Length() ) // if not set - use thread name instead
       
   246         {
       
   247         if( aRunningApp.CaptionL().Length() )
       
   248             {
       
   249             tempName = aRunningApp.CaptionL().AllocLC();
       
   250             }
       
   251         else
       
   252             {
       
   253             TThreadId threadId;
       
   254             if(KErrNone == iResources.WsSession().GetWindowGroupClientThreadId( aRunningApp.WindowGroupId(), threadId ) ) 
       
   255                 {
       
   256                 RThread thread;
       
   257                 CleanupClosePushL( thread );
       
   258                 if( KErrNone == thread.Open( threadId ) )
       
   259                     {
       
   260                     tempName = thread.Name().AllocL(); // codescanner::forgottoputptroncleanupstack
       
   261                     }
       
   262                 // tempName put on cleanupstack after the if
       
   263                 CleanupStack::PopAndDestroy( &thread );
       
   264                 if(tempName)
       
   265                     {
       
   266                     CleanupStack::PushL(tempName);
       
   267                     }
       
   268                 }
       
   269             }
       
   270         }
       
   271     else
       
   272         {
       
   273         tempName = caption.AllocLC();
       
   274         }
       
   275     if( 0 == tempName )
       
   276         {
       
   277         tempName = KNullDesC16().AllocLC();
       
   278         }
       
   279     return tempName;
       
   280     }
   189     }
   281 
   190 
   282 // --------------------------------------------------------------------------
   191 // --------------------------------------------------------------------------
   283 /**
   192 /**
   284  * Fit existing class contained data list into give one.
   193  * Fit existing class contained data list into give one.
   293     TInt dataCount = iData.Count();
   202     TInt dataCount = iData.Count();
   294     
   203     
   295     //remove items that dont't exists in newly collected list
   204     //remove items that dont't exists in newly collected list
   296     for (TInt i = dataCount - 1; i >= 0; --i) 
   205     for (TInt i = dataCount - 1; i >= 0; --i) 
   297         {
   206         {
   298         if( !CheckIfExists( *iData[i], aListToFit ) )
   207         if( !CheckIfExistsL( *iData[i], aListToFit ) )
   299             {
   208             {
   300             delete iData[i];
   209             delete iData[i];
   301             iData.Remove( i );
   210             iData.Remove( i );
   302             changed = ETrue;
   211             changed = ETrue;
   303             }
   212             }
   306     
   215     
   307     //add new items at start
   216     //add new items at start
   308     for(TInt i = aListToFit.Count() - 1; i >= 0; --i)
   217     for(TInt i = aListToFit.Count() - 1; i >= 0; --i)
   309         {        
   218         {        
   310         User::LeaveIfError( allKeys.Insert(aListToFit[i]->Key(), 0) );
   219         User::LeaveIfError( allKeys.Insert(aListToFit[i]->Key(), 0) );
   311         if( !CheckIfExists( *aListToFit[i], iData ) ) 
   220         if( !CheckIfExistsL( *aListToFit[i], iData ) ) 
   312             {
   221             {
   313             HideEntryIfNotAllowed( aListToFit[i] );
   222             HideEntryIfNotAllowed( aListToFit[i] );
   314             User::LeaveIfError( iData.Insert( aListToFit[i], 0 ) );
   223             User::LeaveIfError( iData.Insert( aListToFit[i], 0 ) );
   315             TTime currentTimestamp;
   224             iData[0]->RefreshTimestamp();
   316             currentTimestamp.UniversalTime();
       
   317             iData[0]->SetTimestamp( currentTimestamp );
       
   318             aListToFit[i] = 0;
   225             aListToFit[i] = 0;
   319             changed = ETrue;
   226             changed = ETrue;
   320             }
   227             }
   321         }
   228         }
   322     //establish order
   229     //establish order
   323     TBool orderChanged = EstablishOrder( allKeys );
   230     TBool orderChanged = EstablishOrderL( allKeys );
   324     //update entries data
   231     //update entries data
   325     TBool dataChanged = UpdateEntryData( aListToFit );
   232     TBool dataChanged = UpdateEntryData( aListToFit );
   326     RebuildVisibleDataListL();
   233     RebuildVisibleDataListL();
   327     if( changed || orderChanged || dataChanged )
   234     if( changed || orderChanged || dataChanged )
   328         {
   235         {
   337  * @param   aEntry      entry
   244  * @param   aEntry      entry
   338  * @param   aList    ref to list
   245  * @param   aList    ref to list
   339  * @return  ETrue if app was found
   246  * @return  ETrue if app was found
   340  */
   247  */
   341 
   248 
   342 TBool CTsDataList::CheckIfExists( const CTsEntry& aEntry, 
   249 TBool CTsDataList::CheckIfExistsL( const MTsEntry& aEntry, 
   343                                   const RTsFswArray& aList ) const
   250                                   const RTsFswArray& aList ) const
   344     {
   251     {
   345     return 0 <= FindEntry( aList, aEntry.Key() );
   252     return 0 <= FindEntry( aList, aEntry.Key() );
   346     }
   253     }
   347 
   254 
   348 // --------------------------------------------------------------------------
       
   349 /**
       
   350  * Retrieves the bitmap for the icon of the given app.
       
   351  * @param   aAppUid application uid
       
   352  * @return  app CFbsBitmap
       
   353  */
       
   354 CFbsBitmap* CTsDataList::GetAppIconL( const TUid& aAppUid )
       
   355     {
       
   356     
       
   357     CFbsBitmap* iconBitmap(0);
       
   358     TRAPD(errNo, 
       
   359           QT_TRYCATCH_LEAVING(
       
   360           const QSize size(KAppIconWidth, KAppIconHeight);
       
   361           HbIcon icon = CaMenuIconUtility::getApplicationIcon( aAppUid.iUid, size);
       
   362           iconBitmap = HbIcon2CFbsBitmap( icon );)
       
   363           User::LeaveIfNull(iconBitmap); )
       
   364     if( KErrNone != errNo )
       
   365         {
       
   366         iconBitmap = new(ELeave) CFbsBitmap;
       
   367         CleanupStack::PushL(iconBitmap);
       
   368         User::LeaveIfError( iconBitmap->Duplicate( iDefaultIcon->Handle() ) );
       
   369         CleanupStack::Pop(iconBitmap);
       
   370         }
       
   371     return iconBitmap; 
       
   372     }
       
   373 
       
   374 // --------------------------------------------------------------------------
       
   375 /**
       
   376  * Converts HbIcon to CFbsBitmap
       
   377  * @param   aIcon icon to be coverted
       
   378  * @return  CFbsBitmap
       
   379  */
       
   380 CFbsBitmap* CTsDataList::HbIcon2CFbsBitmap( const HbIcon& aIcon )
       
   381     {
       
   382     CFbsBitmap* retValue(0);
       
   383     QIcon qicon = aIcon.qicon();
       
   384     QPixmap pixmap = qicon.pixmap(QSize(KAppIconWidth, KAppIconHeight));
       
   385     if( !pixmap.isNull() )
       
   386         {
       
   387         retValue = pixmap.toSymbianCFbsBitmap();
       
   388         }
       
   389     return retValue; 
       
   390     }
       
   391 // --------------------------------------------------------------------------
   255 // --------------------------------------------------------------------------
   392 TBool CTsDataList::IsSupported( TInt aFunction ) const
   256 TBool CTsDataList::IsSupported( TInt aFunction ) const
   393     {
   257     {
   394     return ( RegisterScreenshotMessage == aFunction ||
   258     return ( RegisterScreenshotMessage == aFunction ||
   395              UnregisterScreenshotMessage == aFunction ||
   259              UnregisterScreenshotMessage == aFunction ||
   396              VisibilityChange == aFunction || 
       
   397              WindowGroupToBackgroundMessage == aFunction );
   260              WindowGroupToBackgroundMessage == aFunction );
   398     }
   261     }
   399 
   262 
   400 // --------------------------------------------------------------------------
   263 // --------------------------------------------------------------------------
   401 void CTsDataList::HandleDataL( TInt aFunction, RReadStream& aDataStream )
   264 void CTsDataList::HandleDataL( TInt aFunction, RReadStream& aDataStream )
   406             RegisterScreenshotL( aDataStream );
   269             RegisterScreenshotL( aDataStream );
   407             break;
   270             break;
   408         case UnregisterScreenshotMessage:
   271         case UnregisterScreenshotMessage:
   409             UnregisterScreenshotL( aDataStream );
   272             UnregisterScreenshotL( aDataStream );
   410             break;
   273             break;
   411         case VisibilityChange:
       
   412             ChangeVisibilityL( aDataStream );
       
   413             break;        
       
   414         case WindowGroupToBackgroundMessage:
   274         case WindowGroupToBackgroundMessage:
   415             UpdateTaskTimestampL( aDataStream );
   275             UpdateTaskTimestampL( aDataStream );
   416             break;
   276             break;
   417         }
   277         }
   418     }
   278     }
   419 
   279 
   420 // --------------------------------------------------------------------------
   280 // --------------------------------------------------------------------------
       
   281 MTsEntry& CTsDataList::FindL(TTsEntryKey& aKey)
       
   282     {
       
   283     MTsEntry* entry(0);
       
   284     for(TInt offset(0); 0 == entry && offset < iData.Count(); ++offset)
       
   285         {
       
   286         if(iData[offset]->Key().Key() == aKey.Key())
       
   287             {
       
   288             entry = iData[offset];
       
   289             }
       
   290         }
       
   291     User::LeaveIfNull(entry);
       
   292     return *entry;
       
   293     }
       
   294 
       
   295 // --------------------------------------------------------------------------
   421 void CTsDataList::RegisterScreenshotL( RReadStream& aDataStream )
   296 void CTsDataList::RegisterScreenshotL( RReadStream& aDataStream )
   422     {
   297     {
   423     CTsScreenshotMsg* msg = CTsScreenshotMsg::NewLC( aDataStream );
   298     CTsScreenshotMsg* msg = CTsScreenshotMsg::NewLC( aDataStream );
   424     const TInt pos = FindEntry( iData, GenerateKeyL(msg->WindowGroupId() ) );
   299     const TInt pos = FindEntry(iData, GenerateKeyL(msg->WindowGroupId() ) );
   425     User::LeaveIfError(pos);
   300     User::LeaveIfError(pos);
   426     iData[pos]->SetScreenshotL( msg->Screenshot(), msg->Priority(), msg->Rotation() );
   301     iData[pos]->SetScreenshotL( msg->Screenshot(), msg->Priority(), msg->Rotation() );
   427     CleanupStack::PopAndDestroy(msg);
   302     CleanupStack::PopAndDestroy(msg);
   428     }
   303     }
   429 // --------------------------------------------------------------------------
   304 // --------------------------------------------------------------------------
   434     const TInt pos = FindEntry( iData, GenerateKeyL(msg->windowGroupId() ) );
   309     const TInt pos = FindEntry( iData, GenerateKeyL(msg->windowGroupId() ) );
   435     User::LeaveIfError(pos);
   310     User::LeaveIfError(pos);
   436     iData[pos]->RemoveScreenshotL();
   311     iData[pos]->RemoveScreenshotL();
   437     CleanupStack::PopAndDestroy(msg);
   312     CleanupStack::PopAndDestroy(msg);
   438 }
   313 }
   439 // --------------------------------------------------------------------------
   314 
   440 void CTsDataList::ChangeVisibilityL( RReadStream& aDataStream )
       
   441     {
       
   442     CTsVisibilitMsg* msg = CTsVisibilitMsg::NewLC(aDataStream);
       
   443     const TInt pos = FindEntry( iData, GenerateKeyL( msg->windowGroupId() ) );
       
   444     User::LeaveIfError(pos);
       
   445     
       
   446     msg->visibility() == iData[pos]->GetVisibility() ? 
       
   447     User::Leave( KErrInUse ) : 
       
   448     iData[pos]->SetVisibility( msg->visibility() );
       
   449     
       
   450     CleanupStack::PopAndDestroy(msg);
       
   451     RebuildVisibleDataListL();
       
   452     iObserver.DataChanged();
       
   453     }
       
   454 // --------------------------------------------------------------------------
   315 // --------------------------------------------------------------------------
   455 void CTsDataList::UpdateTaskTimestampL( RReadStream& aDataStream )
   316 void CTsDataList::UpdateTaskTimestampL( RReadStream& aDataStream )
   456     {
   317     {
   457     const TInt wgId = aDataStream.ReadInt32L();
   318     const TInt wgId = aDataStream.ReadInt32L();
   458     const TInt pos = FindEntry( iData, GenerateKeyL( wgId ) );
   319     const TInt pos = FindEntry( iData, GenerateKeyL( wgId ) );
   459     User::LeaveIfError( pos );
   320     User::LeaveIfError( pos );
   460 
   321 
   461     TTime currentTimestamp;
   322     iData[pos]->RefreshTimestamp();
   462     currentTimestamp.UniversalTime();
       
   463     iData[pos]->SetTimestamp( currentTimestamp );
       
   464 
   323 
   465     iObserver.DataChanged();
   324     iObserver.DataChanged();
   466     }
       
   467 
       
   468 // --------------------------------------------------------------------------
       
   469 /**
       
   470  * Checks if given uid is on hidden list
       
   471  * @param   aUid uid to be checked
       
   472  * @return  ETrue if uid is on hidden list
       
   473  */
       
   474 TBool CTsDataList::IsHiddenUid( TUid aUid )
       
   475     {
       
   476     return 0 < iHiddenUids.Find( aUid );
       
   477     }
   325     }
   478 
   326 
   479 // --------------------------------------------------------------------------
   327 // --------------------------------------------------------------------------
   480 /**
   328 /**
   481  * Finds entry in array
   329  * Finds entry in array
   489     TInt pos(KErrNotFound);
   337     TInt pos(KErrNotFound);
   490     for(TInt entryIdx = 0; 
   338     for(TInt entryIdx = 0; 
   491         entryIdx < aList.Count() && KErrNotFound == pos; 
   339         entryIdx < aList.Count() && KErrNotFound == pos; 
   492         ++entryIdx)
   340         ++entryIdx)
   493         {
   341         {
   494         if (aList[entryIdx]->Key() == aKey)
   342         if (aList[entryIdx]->Key().Key() == aKey.Key())
   495             {
   343             {
   496             pos = entryIdx;
   344             pos = entryIdx;
   497             }
   345             }
   498         }
   346         }
   499     return pos;
   347     return pos;
   503 /**
   351 /**
   504  * Establish entry order accridung to aKeyList, all keys MUST be in iData
   352  * Establish entry order accridung to aKeyList, all keys MUST be in iData
   505  * @param   aKeyList reference key list
   353  * @param   aKeyList reference key list
   506  * @return   ETrue if changes occured
   354  * @return   ETrue if changes occured
   507  */
   355  */
   508 TBool CTsDataList::EstablishOrder( const RArray<TTsEntryKey>& aKeyList )
   356 TBool CTsDataList::EstablishOrderL( const RArray<TTsEntryKey>& aKeyList )
   509     {
   357     {
   510     TBool changed( EFalse );
   358     TBool changed( EFalse );
   511     TInt lastChangedItem( KErrNotFound );
   359     TInt lastChangedItem( KErrNotFound );
   512     __ASSERT_ALWAYS( iData.Count() == aKeyList.Count(), User::Panic(_L("EstablishOrder 1"), KErrBadHandle) );
   360     __ASSERT_ALWAYS( iData.Count() == aKeyList.Count(), User::Panic(_L("EstablishOrder 1"), KErrBadHandle) );
   513     for (TInt i = 0; i < aKeyList.Count(); i++)
   361     for (TInt i = 0; i < aKeyList.Count(); i++)
   516         const TTsEntryKey& referenceKey = aKeyList[i];
   364         const TTsEntryKey& referenceKey = aKeyList[i];
   517         if( !(currentdataKey == referenceKey) )
   365         if( !(currentdataKey == referenceKey) )
   518             {
   366             {
   519             TInt foundPos = FindEntry( iData, referenceKey );
   367             TInt foundPos = FindEntry( iData, referenceKey );
   520             __ASSERT_ALWAYS(foundPos>=0,  User::Panic(_L("EstablishOrder 2"), KErrBadHandle));
   368             __ASSERT_ALWAYS(foundPos>=0,  User::Panic(_L("EstablishOrder 2"), KErrBadHandle));
   521             CTsEntry* entry = iData[foundPos];
   369             CTsRunningAppEntry* entry = iData[foundPos];
   522             iData.Remove( foundPos );
   370             iData.Remove( foundPos );
   523             iData.Insert( entry, i );
   371             iData.Insert( entry, i );
   524             changed = ETrue;
   372             changed = ETrue;
   525             lastChangedItem = i;
   373             lastChangedItem = i;
   526             }
   374             }
   527         }
   375         }
   528     TTime currentTimestamp;
       
   529     currentTimestamp.UniversalTime();
       
   530     for (TInt i = lastChangedItem; i >= 0; --i)
   376     for (TInt i = lastChangedItem; i >= 0; --i)
   531         {
   377         {
   532         iData[i]->SetTimestamp(currentTimestamp);
   378         iData[i]->RefreshTimestamp();
   533         }
   379         }
   534     return changed;
   380     return changed;
   535     }
   381     }
   536 
   382 
   537 // --------------------------------------------------------------------------
   383 // --------------------------------------------------------------------------
   549         {
   395         {
   550         if(aList[i]) 
   396         if(aList[i]) 
   551             {
   397             {
   552             __ASSERT_ALWAYS(iData[i]->Key() == aList[i]->Key(), 
   398             __ASSERT_ALWAYS(iData[i]->Key() == aList[i]->Key(), 
   553                             User::Panic(_L("UpdateEntryData 2"), KErrBadHandle));
   399                             User::Panic(_L("UpdateEntryData 2"), KErrBadHandle));
   554             if( iData[i]->CloseableApp() != aList[i]->CloseableApp() )
   400             if( iData[i]->IsClosable() != aList[i]->IsClosable() )
   555                 {
   401                 {
   556                 iData[i]->SetCloseableApp(aList[i]->CloseableApp());
   402                 iData[i]->SetCloseableApp(aList[i]->IsClosable());
   557                 changed = ETrue;
   403                 changed = ETrue;
   558                 }
   404                 }
   559             }
   405             }
   560         }
   406         }
   561     return changed;
   407     return changed;
   567  * @param wgId - window group id of running application
   413  * @param wgId - window group id of running application
   568  * @param entry key 
   414  * @param entry key 
   569  */
   415  */
   570 TTsEntryKey CTsDataList::GenerateKeyL( TInt aWgId )
   416 TTsEntryKey CTsDataList::GenerateKeyL( TInt aWgId )
   571     {
   417     {
   572     RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
   418     TTsEntryKey retVal;
       
   419     iResources.WsMonitor().Storage().GenerateKey(retVal, aWgId);
       
   420     return retVal;
       
   421     /*RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
   573     CleanupClosePushL( allWgIds );
   422     CleanupClosePushL( allWgIds );
   574     User::LeaveIfError( iResources.WsSession().WindowGroupList( 0, &allWgIds ) );
   423     User::LeaveIfError( iResources.WsSession().WindowGroupList( 0, &allWgIds ) );
   575     TTsEntryKey key;
   424     TTsEntryKey key;
   576     User::LeaveIfError(TsEntryKeyGeneraror::Generate(key, aWgId, allWgIds.Array()));
   425     User::LeaveIfError(TsEntryKeyGeneraror::Generate(key, aWgId, allWgIds.Array()));
   577     CleanupStack::PopAndDestroy( &allWgIds );
   426     CleanupStack::PopAndDestroy( &allWgIds );
   578     return key;
   427     return key;*/
   579     }
   428     }
   580 
   429 
   581 // --------------------------------------------------------------------------
   430 // --------------------------------------------------------------------------
   582 /**
   431 /**
   583  * Hides entrie if exist on mHiddenUids
   432  * Hides entrie if exist on mHiddenUids
   584  * @param   entry
   433  * @param   entry
   585  */
   434  */
   586 void CTsDataList::HideEntryIfNotAllowed( CTsEntry* aEntry )
   435 void CTsDataList::HideEntryIfNotAllowed( CTsRunningAppEntry* aEntry )
   587     {
   436     {
   588     if( iHiddenUids.Find( aEntry->AppUid() ) >= 0 )
   437     if( iResources.ApplicationsBlackList().IsPresent(aEntry->Uid().iUid) )
   589         {
   438         {
   590         aEntry->SetVisibility(Invisible);
   439         aEntry->SetHidden(ETrue);
   591         }
   440         }
   592     }
   441     }
   593 
   442 
       
   443 // --------------------------------------------------------------------------
   594 void CTsDataList::RebuildVisibleDataListL()
   444 void CTsDataList::RebuildVisibleDataListL()
   595     {
   445     {
   596     iVisibleData.Reset();
   446     iVisibleData.Reset();
   597     RArray<TInt> visibleItems(iData.Count() ? iData.Count() : 1);
   447     RArray<TInt> visibleItems(iData.Count() ? iData.Count() : 1);
   598     CleanupClosePushL(visibleItems);
   448     CleanupClosePushL(visibleItems);
   599     for( TInt iter = 0; iter < iData.Count(); ++iter )
   449     for( TInt iter = 0; iter < iData.Count(); ++iter )
   600         {
   450         {
   601         if( Visible == iData[iter]->GetVisibility() )
   451         if( MTsRunningApplication::None == iData[iter]->HideMode() )
   602             {
   452             {
   603             visibleItems.AppendL(iter);
   453             visibleItems.AppendL(iter);
   604             }
   454             }
   605         }
   455         }
   606     for( TInt iter = 0; iter < visibleItems.Count(); ++iter ) 
   456     for( TInt iter = 0; iter < visibleItems.Count(); ++iter )