taskswitcher/utils/src/tsentry.cpp
changeset 121 0b3699f6c654
child 119 50e220be30d1
equal deleted inserted replaced
115:3ab5c078b490 121:0b3699f6c654
       
     1 /*
       
     2  * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  Task list entry
       
    15  *
       
    16  */
       
    17 
       
    18 #define __E32SVR_H__
       
    19 #include <s32strm.h>
       
    20 #include <fbs.h>
       
    21 #include "tsentry.h"
       
    22 #include "tsdataobserver.h"
       
    23 
       
    24 // --------------------------------------------------------------------------
       
    25 // CTsFswEntry::NewL
       
    26 // --------------------------------------------------------------------------
       
    27 //
       
    28 CTsEntry* CTsEntry::NewL(const TTsEntryKey &key, MTsDataObserver &observer)
       
    29 {
       
    30     CTsEntry* self = NewLC(key, observer);
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33 }
       
    34 
       
    35 // --------------------------------------------------------------------------
       
    36 // CTsFswEntry::NewLC
       
    37 // --------------------------------------------------------------------------
       
    38 //
       
    39 CTsEntry* CTsEntry::NewLC(const TTsEntryKey &key, MTsDataObserver &observer)
       
    40 {
       
    41     CTsEntry* self = new (ELeave) CTsEntry(key, observer);
       
    42     CleanupStack::PushL(self);
       
    43     return self;
       
    44 }
       
    45 
       
    46 // --------------------------------------------------------------------------
       
    47 // CTsFswEntry::~CTsFswEntry
       
    48 // --------------------------------------------------------------------------
       
    49 //
       
    50 CTsEntry::~CTsEntry()
       
    51 {
       
    52     delete mAppName;
       
    53     delete mAppIconBitmap;
       
    54     delete mScreenshot;
       
    55     delete mImgTool;
       
    56 }
       
    57 
       
    58 // --------------------------------------------------------------------------
       
    59 // CTsFswEntry::CTsFswEntry
       
    60 // --------------------------------------------------------------------------
       
    61 //
       
    62 CTsEntry::CTsEntry(const TTsEntryKey &key, MTsDataObserver &observer) 
       
    63 :
       
    64     mVisibility(Visible),
       
    65     mKey(key), 
       
    66     mPriority(Low), 
       
    67     mObserver(observer)
       
    68 {
       
    69     RefreshUpdateTimestamp();
       
    70 }
       
    71 
       
    72 // --------------------------------------------------------------------------
       
    73 // CTsFswEntry::SetAppUid
       
    74 // --------------------------------------------------------------------------
       
    75 //
       
    76 void CTsEntry::SetAppUid(const TUid &uid)
       
    77 {
       
    78     mAppUid = uid;
       
    79 }
       
    80 
       
    81 // --------------------------------------------------------------------------
       
    82 // CTsFswEntry::SetAppNameL
       
    83 // --------------------------------------------------------------------------
       
    84 //
       
    85 void CTsEntry::SetAppNameL(const TDesC &appName)
       
    86 {
       
    87     delete mAppName;
       
    88     mAppName = 0;
       
    89     mAppName = appName.AllocL();
       
    90 }
       
    91 
       
    92 // --------------------------------------------------------------------------
       
    93 // CTsFswEntry::SetSystemApp
       
    94 // --------------------------------------------------------------------------
       
    95 //
       
    96 void CTsEntry::SetCloseableApp(TBool value)
       
    97 {
       
    98     mCloseableApp = value;
       
    99 }
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CTsFswEntry::SetAppIconHandles
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 void CTsEntry::SetAppIcon(CFbsBitmap * bitmap)
       
   106 {
       
   107     mAppIconBitmap = bitmap;
       
   108 }
       
   109 
       
   110 // --------------------------------------------------------------------------
       
   111 /**
       
   112  * Application uid.
       
   113  */
       
   114 TUid CTsEntry::AppUid() const
       
   115 {
       
   116     return mAppUid;
       
   117 }
       
   118 
       
   119 // --------------------------------------------------------------------------
       
   120 /**
       
   121  * Application name.
       
   122  */
       
   123 const TDesC& CTsEntry::AppName() const
       
   124 {
       
   125     return mAppName ? *mAppName : KNullDesC();
       
   126 }
       
   127 
       
   128 // --------------------------------------------------------------------------
       
   129 /**
       
   130  * Retrieve entry visibilit status
       
   131  */
       
   132 Visibility CTsEntry::GetVisibility() const
       
   133 {
       
   134     return mVisibility;
       
   135 }
       
   136 
       
   137 // --------------------------------------------------------------------------
       
   138 /**
       
   139  * Change entry visibility status
       
   140  * @param visibility - new visibility status
       
   141  */
       
   142 void CTsEntry::SetVisibility(Visibility visibility)
       
   143 {
       
   144     mVisibility = visibility;
       
   145 }
       
   146 
       
   147 // --------------------------------------------------------------------------
       
   148 /**
       
   149  * ETrue if the application is closeable
       
   150  */
       
   151 TBool CTsEntry::CloseableApp() const
       
   152 {
       
   153     return mCloseableApp;
       
   154 }
       
   155 
       
   156 // --------------------------------------------------------------------------
       
   157 /**
       
   158  * Application icon bitmap
       
   159  */
       
   160 CFbsBitmap *CTsEntry::AppIconBitmap() const
       
   161 {
       
   162     return mAppIconBitmap;
       
   163 }
       
   164 
       
   165 // --------------------------------------------------------------------------
       
   166 /**
       
   167  * Entry's key
       
   168  */
       
   169 const TTsEntryKey &CTsEntry::Key() const
       
   170 {
       
   171     return mKey;
       
   172 }
       
   173 
       
   174 TTime CTsEntry::Timestamp() const
       
   175 {
       
   176     return mTimestamp;
       
   177 }
       
   178     
       
   179 // --------------------------------------------------------------------------
       
   180 /**
       
   181  * Timestamp of last entry change 
       
   182  */
       
   183 TTime CTsEntry::LastUpdateTimestamp() const
       
   184 {
       
   185     return mUpdateTimestamp;
       
   186 }
       
   187 
       
   188 void CTsEntry::SetTimestamp(const TTime &timestamp)
       
   189 {
       
   190     mTimestamp = timestamp;
       
   191     RefreshUpdateTimestamp();
       
   192 }
       
   193 
       
   194 // --------------------------------------------------------------------------
       
   195 /**
       
   196  * Set new value of updates timestamp
       
   197  */
       
   198 void CTsEntry::RefreshUpdateTimestamp()
       
   199 {
       
   200     mUpdateTimestamp.UniversalTime();
       
   201 }
       
   202 
       
   203 // --------------------------------------------------------------------------
       
   204 // CTsFswEntry::SetScreenshot
       
   205 // --------------------------------------------------------------------------
       
   206 //
       
   207 void CTsEntry::SetScreenshotL(const CFbsBitmap &bitmapArg, UpdatePriority priority, TInt angle)
       
   208 {
       
   209     TInt currentPriority = static_cast<TInt> (mPriority);
       
   210     TInt newPriority = static_cast<TInt> (priority);
       
   211     if(newPriority <currentPriority) {
       
   212         User::Leave(KErrAccessDenied);
       
   213     }
       
   214     
       
   215     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
   216     CleanupStack::PushL(bitmap);
       
   217     User::LeaveIfError(bitmap->Duplicate(bitmapArg.Handle()));
       
   218     CleanupStack::Pop(bitmap);
       
   219 
       
   220     mPriority = priority;
       
   221     delete mScreenshot;
       
   222     mScreenshot = bitmap;
       
   223     RefreshUpdateTimestamp();
       
   224 
       
   225     delete mImgTool;
       
   226     mImgTool = 0;
       
   227 
       
   228     mImgTool = CTsGraphicFileScalingHandler::NewL(*this, *mScreenshot, TSize(128, 128),
       
   229     CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding, angle);
       
   230 }
       
   231 
       
   232 // --------------------------------------------------------------------------
       
   233 // CTsFswEntry::RemoveScreenshot
       
   234 // --------------------------------------------------------------------------
       
   235 //
       
   236 void CTsEntry::RemoveScreenshotL()
       
   237 {
       
   238     if (!mScreenshot) {
       
   239         User::Leave(KErrNotFound);
       
   240     }
       
   241     delete mScreenshot;
       
   242     mScreenshot = NULL;
       
   243     mPriority = Low;
       
   244     
       
   245     mObserver.DataChanged();
       
   246     RefreshUpdateTimestamp();
       
   247 }
       
   248 
       
   249 // --------------------------------------------------------------------------
       
   250 /**
       
   251  * Application screenshot.
       
   252  */
       
   253 CFbsBitmap* CTsEntry::Screenshot() const
       
   254 {
       
   255     return mScreenshot;
       
   256 }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 // CTsFswEntry::Priority
       
   260 // --------------------------------------------------------------------------
       
   261 //
       
   262 void CTsEntry::ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap)
       
   263 {
       
   264     if (KErrNone == error && 0 != bitmap) {
       
   265         mScreenshot->Reset();
       
   266         mScreenshot->Duplicate(bitmap->Handle());
       
   267         RefreshUpdateTimestamp();
       
   268         mObserver.DataChanged();
       
   269     }
       
   270 }
       
   271 
       
   272 // end of file