tstaskmonitor/server/src/tsfswengine.cpp
changeset 83 156f692b1687
parent 80 397d00875918
--- a/tstaskmonitor/server/src/tsfswengine.cpp	Thu May 27 13:11:12 2010 +0300
+++ b/tstaskmonitor/server/src/tsfswengine.cpp	Fri Jun 11 13:58:37 2010 +0300
@@ -17,205 +17,114 @@
 
 
 #include "tsfswengine.h"
-
 #include "tsfswdatalist.h"
 
 
-
-
-#include <apgtask.h>
-#include <AknDef.h>
-#include <apgwgnam.h>
-#include <mmf/common/mmfcontrollerpluginresolver.h> // for CleanupResetAndDestroyPushL
-#include <featmgr.h>
-#include <swi/swispubsubdefs.h>
-#include <s32mem.h>
-#include <bitmaptransforms.h>
-
-// time to wait before refreshing content
-const TInt KContentRefreshDelay = 50000; // 0.05 sec
-
-
 // --------------------------------------------------------------------------
 // CTsFswEngine::NewL
 // --------------------------------------------------------------------------
 //
-CTsFswEngine* CTsFswEngine::NewL( MHsDataObserver& aObserver )
-    {
-    CTsFswEngine* self = NewLC( aObserver );
-    CleanupStack::Pop( self );
+CTsFswEngine* CTsFswEngine::NewL(MHsDataObserver& observer)
+{
+    CTsFswEngine* self = NewLC(observer);
+    CleanupStack::Pop(self);
     return self;
-    }
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::NewLC
 // --------------------------------------------------------------------------
 //
-CTsFswEngine* CTsFswEngine::NewLC( MHsDataObserver& aObserver )
-    {
-    CTsFswEngine* self = new ( ELeave ) CTsFswEngine( aObserver );
-    CleanupStack::PushL( self );
+CTsFswEngine* CTsFswEngine::NewLC(MHsDataObserver& observer)
+{
+    CTsFswEngine* self = new (ELeave) CTsFswEngine(observer);
+    CleanupStack::PushL(self);
     self->ConstructL();
     return self;
-    }
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::CTsFswEngine
 // --------------------------------------------------------------------------
 //
-CTsFswEngine::CTsFswEngine( MHsDataObserver& aObserver )
-        :iObserver( aObserver )
-    {
-    }
+CTsFswEngine::CTsFswEngine(MHsDataObserver& observer) :
+    mObserver(observer)
+{
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::ConstructL
 // --------------------------------------------------------------------------
 //
 void CTsFswEngine::ConstructL()
-    {
-    User::LeaveIfError( iWsSession.Connect() );
-    User::LeaveIfError( iAppArcSession.Connect() );
-
-    iDataList = CTsFswDataList::NewL(*this);    
-
-    // get an initial list of tasks
-    iDataList->SetAppDataRefreshNeeded();
+{
+    mDataList = CTsFswDataList::NewL(mObserver);
     CollectTasksL();
-
-    iUpdateStarter = CPeriodic::NewL( CActive::EPriorityStandard );   
-    }
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::~CTsFswEngine
 // --------------------------------------------------------------------------
 //
 CTsFswEngine::~CTsFswEngine()
-    {
-
-    delete iUpdateStarter;
-
-    iWgIds.Close();
-
-    iAppArcSession.Close();
-    iWsSession.Close();
-
-    delete iDataList;
-    }
+{
+    delete mDataList;
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::FswDataL
 // --------------------------------------------------------------------------
 //
 const RTsFswArray& CTsFswEngine::FswDataL()
-    {
-    return iDataList->FswDataL();
-    }
+{
+    return mDataList->FswDataL();
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::UpdateTaskList
 // Callback from appui
 // --------------------------------------------------------------------------
 //
-void CTsFswEngine::UpdateTaskList()
-    {
-    // There can be many calls in a row, use a timer to prevent degrading
-    // device performance.
-    iDataList->SetDirty();
-    if ( !iUpdateStarter->IsActive() )
-        {
-        iUpdateStarter->Start( KContentRefreshDelay, 0,
-                TCallBack( UpdateStarterCallback, this ) );
-        }    
-    // get the foreground app uid and publish it to CFW if different than before
-    TRAP_IGNORE( PublishFgAppUidL() );
+void CTsFswEngine::DataChanged()
+{
+    TBool changed = EFalse;
+    TRAPD( err, changed = CollectTasksL() );
+    if (err == KErrNone && changed) {
+        mObserver.DataChanged();
     }
-
-// --------------------------------------------------------------------------
-// CTsFswEngine::UpdateStarterCallback
-// Callback for the timer
-// --------------------------------------------------------------------------
-//
-TInt CTsFswEngine::UpdateStarterCallback( TAny* aParam )
-    {
-    CTsFswEngine* self = static_cast<CTsFswEngine*>( aParam );
-    self->iUpdateStarter->Cancel();
-    // get list of tasks and notify observer if there is a change in the list
-    TBool changed = EFalse;
-    TRAPD( err, changed = self->CollectTasksL() );
-    if ( err == KErrNone && changed )
-        {
-        self->iObserver.DataChanged();
-        }
-    return 0;
-    }
+}
 
 // --------------------------------------------------------------------------
 // CTsFswEngine::CollectTasksL
 // --------------------------------------------------------------------------
 //
 TBool CTsFswEngine::CollectTasksL()
-    {
-    TBool changed = iDataList->CollectTasksL();
+{
+    TBool changed = mDataList->CollectTasksL();
     return changed;
-    }
+}
 
 // --------------------------------------------------------------------------
-// CTsFswEngine::ForegroundAppUidL
+// CTsFswEngine::SetScreenshotL
 // --------------------------------------------------------------------------
 //
-TUid CTsFswEngine::ForegroundAppUidL( TInt aType )
-    {
-    // Do not use GetFocusWindowGroup or others.
-    // We want to see only "real" application uids in FgApp,
-    // i.e. stuff that would also be shown in the task swapper
-    // area of Taskswitcher.
-
-    TUid result = KNullUid;
-    RArray<RWsSession::TWindowGroupChainInfo> allWgIds;
-    CleanupClosePushL( allWgIds );
-    User::LeaveIfError( iWsSession.WindowGroupList( 0, &allWgIds ) );
-    TInt count = allWgIds.Count();
-    for ( TInt i = 0; i < count; ++i )
-        {
-        // Depending on aType we may not need to bother with iParentId here.
-        // If aType == EUseEmbeddedUid => embedded apps are treated as others.
-        // If aType == EUseStandaloneUid => embedded apps must be ignored.
-        if ( allWgIds[i].iParentId > 0
-                && aType == CTsFswEngine::EUseStandaloneUid )
-            {
-            continue;
-            }
-
-        CApaWindowGroupName* wgn = CApaWindowGroupName::NewLC(
-            iWsSession, allWgIds[i].iId );
-        TUid newUid = wgn->AppUid();
-        TBool hidden = wgn->Hidden();
-        CleanupStack::PopAndDestroy( wgn );
-
-        if ( !hidden && newUid.iUid && !iDataList->IsHiddenUid(newUid) )
-            {
-            result = newUid;
-            break;
-            }
-        }
-    CleanupStack::PopAndDestroy( &allWgIds );
-    
-    return result;
+void CTsFswEngine::SetScreenshotL(const CFbsBitmap* bitmap, UpdatePriority priority, TInt wgId)
+{
+    TBool changed = mDataList->SetScreenshotL(bitmap, priority, wgId);
+    if (!changed) {
+        User::Leave(KErrAccessDenied);
     }
+}
 
 // --------------------------------------------------------------------------
-// CTsFswEngine::PublishFgAppUidL
+// CTsFswEngine::SetScreenshotL
 // --------------------------------------------------------------------------
 //
-void CTsFswEngine::PublishFgAppUidL()
-    {
-    TUid newUid = ForegroundAppUidL( CTsFswEngine::EUseEmbeddedUid );
-    if ( iFgAppUid != newUid && newUid.iUid )
-        {
-        iFgAppUid = newUid;
-        iDataList->MoveEntryAtStart(newUid.iUid, EFalse);
-        }
+void CTsFswEngine::RemoveScreenshotL(TInt wgId)
+{
+    TBool changed = mDataList->RemoveScreenshotL(wgId);
+    if (changed) {
+        mObserver.DataChanged();
     }
-
+}
 // end of file