diff -r 3ab5c078b490 -r c63ee96dbe5f taskswitcher/utils/src/tsentry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskswitcher/utils/src/tsentry.cpp Thu Sep 16 12:11:40 2010 +0100 @@ -0,0 +1,250 @@ +/* + * 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 +#include +#include "tsentry.h" +#include "tsdataobserver.h" + +// -------------------------------------------------------------------------- +// CTsFswEntry::NewL +// -------------------------------------------------------------------------- +// +CTsEntry* CTsEntry::NewL(const TTsEntryKey &key, MTsDataObserver &observer) +{ + CTsEntry* self = NewLC(key, observer); + CleanupStack::Pop(self); + return self; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::NewLC +// -------------------------------------------------------------------------- +// +CTsEntry* CTsEntry::NewLC(const TTsEntryKey &key, MTsDataObserver &observer) +{ + CTsEntry* self = new (ELeave) CTsEntry(key, observer); + CleanupStack::PushL(self); + return self; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::~CTsFswEntry +// -------------------------------------------------------------------------- +// +CTsEntry::~CTsEntry() +{ + delete mAppName; + delete mAppIconBitmap; + delete mScreenshot; + delete mImgTool; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::CTsFswEntry +// -------------------------------------------------------------------------- +// +CTsEntry::CTsEntry(const TTsEntryKey &key, MTsDataObserver &observer) +: + mVisibility(Visible), + mKey(key), + mPriority(Low), + mObserver(observer) +{ +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppUid +// -------------------------------------------------------------------------- +// +void CTsEntry::SetAppUid(const TUid &uid) +{ + mAppUid = uid; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppNameL +// -------------------------------------------------------------------------- +// +void CTsEntry::SetAppNameL(const TDesC &appName) +{ + delete mAppName; + mAppName = 0; + mAppName = appName.AllocL(); +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetSystemApp +// -------------------------------------------------------------------------- +// +void CTsEntry::SetCloseableApp(TBool value) +{ + mCloseableApp = value; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetAppIconHandles +// -------------------------------------------------------------------------- +// +void CTsEntry::SetAppIcon(CFbsBitmap * bitmap) +{ + mAppIconBitmap = bitmap; +} + +// -------------------------------------------------------------------------- +/** + * Application uid. + */ +TUid CTsEntry::AppUid() const +{ + return mAppUid; +} + +// -------------------------------------------------------------------------- +/** + * Application name. + */ +const TDesC& CTsEntry::AppName() const +{ + return mAppName ? *mAppName : KNullDesC(); +} + +// -------------------------------------------------------------------------- +/** + * Retrieve entry visibilit status + */ +Visibility CTsEntry::GetVisibility() const +{ + return mVisibility; +} + +// -------------------------------------------------------------------------- +/** + * Change entry visibility status + * @param visibility - new visibility status + */ +void CTsEntry::SetVisibility(Visibility visibility) +{ + mVisibility = visibility; +} + +// -------------------------------------------------------------------------- +/** + * ETrue if the application is closeable + */ +TBool CTsEntry::CloseableApp() const +{ + return mCloseableApp; +} + +// -------------------------------------------------------------------------- +/** + * Application icon bitmap + */ +CFbsBitmap *CTsEntry::AppIconBitmap() const +{ + return mAppIconBitmap; +} + +// -------------------------------------------------------------------------- +/** + * Entry's key + */ +const TTsEntryKey &CTsEntry::Key() const +{ + return mKey; +} + +TTime CTsEntry::Timestamp() const +{ + return mTimestamp; +} + +void CTsEntry::SetTimestamp(const TTime ×tamp) +{ + mTimestamp = timestamp; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::SetScreenshot +// -------------------------------------------------------------------------- +// +void CTsEntry::SetScreenshotL(const CFbsBitmap &bitmapArg, UpdatePriority priority) +{ + TInt currentPriority = static_cast (mPriority); + TInt newPriority = static_cast (priority); + if(newPriority 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); +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::RemoveScreenshot +// -------------------------------------------------------------------------- +// +void CTsEntry::RemoveScreenshotL() +{ + if (!mScreenshot) { + User::Leave(KErrNotFound); + } + delete mScreenshot; + mScreenshot = NULL; + mPriority = Low; + + mObserver.DataChanged(); +} + +// -------------------------------------------------------------------------- +/** + * Application screenshot. + */ +CFbsBitmap* CTsEntry::Screenshot() const +{ + return mScreenshot; +} + +// -------------------------------------------------------------------------- +// CTsFswEntry::Priority +// -------------------------------------------------------------------------- +// +void CTsEntry::ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap) +{ + if (KErrNone == error && 0 != bitmap) { + mScreenshot->Reset(); + mScreenshot->Duplicate(bitmap->Handle()); + + mObserver.DataChanged(); + } +} + +// end of file