--- a/tstaskmonitor/utils/src/tsfswentry.cpp Thu May 27 13:11:12 2010 +0300
+++ b/tstaskmonitor/utils/src/tsfswentry.cpp Fri Jun 11 13:58:37 2010 +0300
@@ -1,22 +1,23 @@
/*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Task list entry
+ * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
-*/
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Task list entry
+ *
+ */
#define __E32SVR_H__
#include "tsfswentry.h"
+#include "tsdataobserver.h"
#include <s32strm.h>
#include <fbs.h>
@@ -25,227 +26,370 @@
// --------------------------------------------------------------------------
//
CTsFswEntry* CTsFswEntry::NewL()
- {
+{
CTsFswEntry* self = NewLC();
- CleanupStack::Pop( self );
+ CleanupStack::Pop(self);
return self;
- }
+}
// --------------------------------------------------------------------------
// CTsFswEntry::NewLC
// --------------------------------------------------------------------------
//
CTsFswEntry* CTsFswEntry::NewLC()
- {
- CTsFswEntry* self = new ( ELeave ) CTsFswEntry;
- CleanupStack::PushL( self );
+{
+ CTsFswEntry* self = new (ELeave) CTsFswEntry;
+ CleanupStack::PushL(self);
return self;
- }
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::NewL
+// --------------------------------------------------------------------------
+//
+CTsFswEntry* CTsFswEntry::NewL(const TTsEntryKey& key, MHsDataObserver *observer)
+{
+ CTsFswEntry* self = NewLC(key, observer);
+ CleanupStack::Pop(self);
+ return self;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::NewLC
+// --------------------------------------------------------------------------
+//
+CTsFswEntry* CTsFswEntry::NewLC(const TTsEntryKey& key, MHsDataObserver* observer)
+{
+ CTsFswEntry* self = new (ELeave) CTsFswEntry(key, observer);
+ CleanupStack::PushL(self);
+ return self;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::~CTsFswEntry
// --------------------------------------------------------------------------
//
CTsFswEntry::~CTsFswEntry()
- {
- delete iAppName;
- delete iAppIconBitmap;
- delete iAppIconMask;
- }
+{
+ delete mAppName;
+ delete mAppIconBitmap;
+ delete mAppIconMask;
+ delete mScreenshot;
+ delete mImgTool;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::CTsFswEntry
+// --------------------------------------------------------------------------
+//
+CTsFswEntry::CTsFswEntry() :
+ mPriority(Low)
+{
+ mKey = TTsEntryKey();
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::CTsFswEntry
+// --------------------------------------------------------------------------
+//
+CTsFswEntry::CTsFswEntry(const TTsEntryKey& key, MHsDataObserver *observer) :
+ mKey(key), mPriority(Low), mObserver(observer)
+{
+ mWgId = key.mParentId;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SetWgId
// --------------------------------------------------------------------------
//
-void CTsFswEntry::SetWgId( TInt aWgId )
- {
- iWgId = aWgId;
- }
+void CTsFswEntry::SetWgId(TInt wgId)
+{
+ mWgId = wgId;
+ mKey = TTsEntryKey(mWgId);
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SetAppUid
// --------------------------------------------------------------------------
//
-void CTsFswEntry::SetAppUid( const TUid& aUid )
- {
- iAppUid = aUid;
- }
+void CTsFswEntry::SetAppUid(const TUid& uid)
+{
+ mAppUid = uid;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SetAppNameL
// --------------------------------------------------------------------------
//
-void CTsFswEntry::SetAppNameL( const TDesC& aAppName )
- {
- delete iAppName; iAppName = 0;
- iAppName = aAppName.AllocL();
- }
+void CTsFswEntry::SetAppNameL(const TDesC& appName)
+{
+ delete mAppName;
+ mAppName = 0;
+ mAppName = appName.AllocL();
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SetSystemApp
// --------------------------------------------------------------------------
//
-void CTsFswEntry::SetCloseableApp( TBool aValue )
- {
- iCloseableApp = aValue;
- }
+void CTsFswEntry::SetCloseableApp(TBool value)
+{
+ mCloseableApp = value;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SetAppIconHandles
// --------------------------------------------------------------------------
//
-void CTsFswEntry::SetAppIcon( CFbsBitmap* aBitmap, CFbsBitmap* aMask )
- {
- iAppIconBitmap = aBitmap;
- iAppIconMask = aMask;
- }
+void CTsFswEntry::SetAppIcon(CFbsBitmap* bitmap, CFbsBitmap* mask)
+{
+ mAppIconBitmap = bitmap;
+ mAppIconMask = mask;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::WgId
// --------------------------------------------------------------------------
//
TInt CTsFswEntry::WgId() const
- {
- return iWgId;
- }
+{
+ return mWgId;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::AppUid
// --------------------------------------------------------------------------
//
TUid CTsFswEntry::AppUid() const
- {
- return iAppUid;
- }
+{
+ return mAppUid;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::AppName
// --------------------------------------------------------------------------
//
const TDesC& CTsFswEntry::AppName() const
- {
- return iAppName ? *iAppName : KNullDesC();
- }
+{
+ return mAppName ? *mAppName : KNullDesC();
+}
// --------------------------------------------------------------------------
// CTsFswEntry::SystemApp
// --------------------------------------------------------------------------
//
TBool CTsFswEntry::CloseableApp() const
- {
- return iCloseableApp;
- }
+{
+ return mCloseableApp;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::AppIconBitmapHandle
// --------------------------------------------------------------------------
//
CFbsBitmap* CTsFswEntry::AppIconBitmap() const
- {
- return iAppIconBitmap;
- }
+{
+ return mAppIconBitmap;
+}
// --------------------------------------------------------------------------
// CTsFswEntry::AppIconMaskHandle
// --------------------------------------------------------------------------
//
CFbsBitmap* CTsFswEntry::AppIconMask() const
- {
- return iAppIconMask;
- }
+{
+ return mAppIconMask;
+}
// --------------------------------------------------------------------------
+// CTsFswEntry::Key
+// --------------------------------------------------------------------------
+//
+const TTsEntryKey& CTsFswEntry::Key() const
+{
+ return mKey;
+}
+// --------------------------------------------------------------------------
// CTsFswEntry::ExternalizeL
// --------------------------------------------------------------------------
//
-void CTsFswEntry::ExternalizeL( RWriteStream& aStream )
- {
- aStream.WriteInt32L( iWgId );
- aStream.WriteInt32L( iAppUid.iUid );
- aStream << AppName();
- aStream.WriteInt32L( iCloseableApp );
- if ( iAppIconBitmap )
- {
- aStream.WriteInt32L( iAppIconBitmap->Handle() );
- }
- else
- {
- aStream.WriteInt32L( KErrNotFound );
- }
-
- if ( iAppIconMask )
- {
- aStream.WriteInt32L( iAppIconMask->Handle() );
- }
- else
- {
- aStream.WriteInt32L( KErrNotFound );
- }
+void CTsFswEntry::ExternalizeL(RWriteStream& stream)
+{
+ stream.WriteInt32L(mWgId);
+ stream.WriteInt32L(mAppUid.iUid);
+ stream << AppName();
+ stream.WriteInt32L(mCloseableApp);
+ if (mAppIconBitmap) {
+ stream.WriteInt32L(mAppIconBitmap->Handle());
+ }
+ else {
+ stream.WriteInt32L(KErrNotFound);
+ }
+
+ if (mAppIconMask) {
+ stream.WriteInt32L(mAppIconMask->Handle());
}
+ else {
+ stream.WriteInt32L(KErrNotFound);
+ }
+
+ if (mScreenshot) {
+ stream.WriteInt32L(mScreenshot->Handle());
+ }
+ else {
+ stream.WriteInt32L(KErrNotFound);
+ }
+
+ mKey.ExternalizeL(stream);
+ TInt currentPriority = static_cast<TInt> (mPriority);
+ stream.WriteInt32L(currentPriority);
+}
// --------------------------------------------------------------------------
// CTsFswEntry::InternalizeL
// --------------------------------------------------------------------------
//
-void CTsFswEntry::InternalizeL( RReadStream& aStream )
- {
- iWgId = aStream.ReadInt32L();
- iAppUid = TUid::Uid( aStream.ReadInt32L() );
- delete iAppName; iAppName = NULL;
- iAppName = HBufC::NewL( aStream, KMaxTInt );
- iCloseableApp = aStream.ReadInt32L();
- TInt appIconBitmapHandle = aStream.ReadInt32L();
- TInt appIconMaskHandle = aStream.ReadInt32L();
- if ( appIconBitmapHandle != KErrNotFound )
- {
- iAppIconBitmap = new (ELeave) CFbsBitmap;
- iAppIconBitmap->Duplicate( appIconBitmapHandle );
- }
- if ( appIconMaskHandle != KErrNotFound )
- {
- iAppIconMask = new (ELeave) CFbsBitmap;
- iAppIconMask->Duplicate( appIconMaskHandle );
- }
+void CTsFswEntry::InternalizeL(RReadStream& stream)
+{
+ mWgId = stream.ReadInt32L();
+ mAppUid = TUid::Uid(stream.ReadInt32L());
+ delete mAppName;
+ mAppName = NULL;
+ mAppName = HBufC::NewL(stream, KMaxTInt);
+ mCloseableApp = stream.ReadInt32L();
+ TInt appIconBitmapHandle = stream.ReadInt32L();
+ TInt appIconMaskHandle = stream.ReadInt32L();
+ TInt screenshotHandle = stream.ReadInt32L();
+ if (appIconBitmapHandle != KErrNotFound) {
+ mAppIconBitmap = new (ELeave) CFbsBitmap;
+ mAppIconBitmap->Duplicate(appIconBitmapHandle);
}
+ if (appIconMaskHandle != KErrNotFound) {
+ mAppIconMask = new (ELeave) CFbsBitmap;
+ mAppIconMask->Duplicate(appIconMaskHandle);
+ }
+ if (screenshotHandle != KErrNotFound) {
+ mScreenshot = new (ELeave) CFbsBitmap;
+ mScreenshot->Duplicate(screenshotHandle);
+ }
+ mKey.InternalizeL(stream);
+ TInt currentPriority = stream.ReadInt32L();
+ mPriority = static_cast<UpdatePriority> (currentPriority);
+}
// --------------------------------------------------------------------------
// CTsFswEntry::ExternalizeArrayL
// --------------------------------------------------------------------------
//
-void CTsFswEntry::ExternalizeArrayL( RWriteStream& aStream,
- const RTsFswArray& aArray )
- {
+void CTsFswEntry::ExternalizeArrayL(RWriteStream& stream, const RTsFswArray& aArray)
+{
TInt count = aArray.Count();
- aStream.WriteInt32L( count );
- for ( TInt i = 0; i < count; ++i )
- {
- aArray[i]->ExternalizeL( aStream );
- }
+ stream.WriteInt32L(count);
+ for (TInt i = 0; i < count; ++i) {
+ aArray[i]->ExternalizeL(stream);
}
+}
// --------------------------------------------------------------------------
// CTsFswEntry::InternalizeArrayL
// --------------------------------------------------------------------------
//
-void CTsFswEntry::InternalizeArrayL( RReadStream& aStream,
- RTsFswArray& aArray )
- {
+void CTsFswEntry::InternalizeArrayL(RReadStream& stream, RTsFswArray& aArray)
+{
aArray.ResetAndDestroy();
- TInt count = aStream.ReadInt32L(); for ( TInt i = 0; i < count; ++i )
- {
+ TInt count = stream.ReadInt32L();
+ for (TInt i = 0; i < count; ++i) {
CTsFswEntry* entry = CTsFswEntry::NewLC();
- entry->InternalizeL( aStream );
- aArray.AppendL( entry );
- CleanupStack::Pop( entry );
- }
+ entry->InternalizeL(stream);
+ aArray.AppendL(entry);
+ CleanupStack::Pop(entry);
}
+}
// --------------------------------------------------------------------------
// CTsFswEntry::Type
// --------------------------------------------------------------------------
//
TAppType CTsFswEntry::Type() const
- {
+{
return EApp;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::SetScreenshot
+// --------------------------------------------------------------------------
+//
+TBool CTsFswEntry::SetScreenshotL(const CFbsBitmap* bitmapArg, UpdatePriority priority)
+{
+ TInt currentPriority = static_cast<TInt> (mPriority);
+ TInt newPriority = static_cast<TInt> (priority);
+ if (newPriority >= currentPriority) {
+ CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
+ CleanupStack::PushL(bitmap);
+ User::LeaveIfError(bitmap->Duplicate(bitmapArg->Handle()));
+ CleanupStack::Pop(bitmap);
+
+ mPriority = priority;
+ delete mScreenshot;
+ mScreenshot = bitmap;
+
+ delete mImgTool;
+ mImgTool = 0;
+
+ mImgTool = CTsGraphicFileScalingHandler::NewL(*this, *mScreenshot, TSize(128, 128),
+ CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding);
+ return ETrue;
}
+ return EFalse;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::RemoveScreenshot
+// --------------------------------------------------------------------------
+//
+TBool CTsFswEntry::RemoveScreenshot()
+{
+ if (mScreenshot) {
+ delete mScreenshot;
+ mScreenshot = NULL;
+ mPriority = Low;
+ return ETrue;
+ }
+ return EFalse;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::Screenshot
+// --------------------------------------------------------------------------
+//
+CFbsBitmap* CTsFswEntry::Screenshot() const
+{
+ return mScreenshot;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::Priority
+// --------------------------------------------------------------------------
+//
+UpdatePriority CTsFswEntry::Priority() const
+{
+ return mPriority;
+}
+
+// --------------------------------------------------------------------------
+// CTsFswEntry::Priority
+// --------------------------------------------------------------------------
+//
+void CTsFswEntry::ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap)
+{
+ if (KErrNone == error && 0 != bitmap) {
+ mScreenshot->Reset();
+ mScreenshot->Duplicate(bitmap->Handle());
+
+ if (mObserver) {
+ mObserver->DataChanged();
+ }
+ }
+}
+
// end of file