taskswitcher/utils/src/tsentry.cpp
changeset 127 7b66bc3c6dc9
parent 126 efda7c0771b9
equal deleted inserted replaced
126:efda7c0771b9 127:7b66bc3c6dc9
     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 
       
    20 #include <s32strm.h>
       
    21 #include <fbs.h>
       
    22 
       
    23 #include "tsentry.h"
       
    24 #include "tsdataobserver.h"
       
    25 #include "tsthumbnailprovider.h"
       
    26 
       
    27 // --------------------------------------------------------------------------
       
    28 // CTsFswEntry::NewL
       
    29 // --------------------------------------------------------------------------
       
    30 //
       
    31 CTsEntry* CTsEntry::NewL(const TTsEntryKey &key, MTsDataObserver &observer, QObject* obj)
       
    32 {
       
    33     CTsEntry* self = NewLC(key, observer, obj);
       
    34     CleanupStack::Pop(self);
       
    35     return self;
       
    36 }
       
    37 
       
    38 // --------------------------------------------------------------------------
       
    39 // CTsFswEntry::NewLC
       
    40 // --------------------------------------------------------------------------
       
    41 //
       
    42 CTsEntry* CTsEntry::NewLC(const TTsEntryKey &key, MTsDataObserver &observer, QObject* obj)
       
    43 {
       
    44     CTsEntry* self = new (ELeave) CTsEntry(key, observer);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL(obj);
       
    47     return self;
       
    48 }
       
    49 
       
    50 // --------------------------------------------------------------------------
       
    51 // CTsFswEntry::~CTsFswEntry
       
    52 // --------------------------------------------------------------------------
       
    53 //
       
    54 CTsEntry::~CTsEntry()
       
    55 {
       
    56     delete mAppName;
       
    57     delete mAppIconBitmap;
       
    58     delete mScreenshot;
       
    59     delete iProvider;
       
    60 }
       
    61 
       
    62 // --------------------------------------------------------------------------
       
    63 // CTsFswEntry::CTsFswEntry
       
    64 // --------------------------------------------------------------------------
       
    65 //
       
    66 CTsEntry::CTsEntry(const TTsEntryKey &key, MTsDataObserver &observer) 
       
    67 :
       
    68     mVisibility(Visible),
       
    69     mKey(key), 
       
    70     mPriority(Low), 
       
    71     mObserver(observer)
       
    72 {
       
    73     RefreshUpdateTimestamp();
       
    74 }
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 void CTsEntry::ConstructL(QObject* object)
       
    78 {
       
    79     QT_TRYCATCH_LEAVING(
       
    80        iProvider = new TsThumbnailProvider(*this, object);
       
    81     )
       
    82     
       
    83 }
       
    84 
       
    85 // --------------------------------------------------------------------------
       
    86 // CTsFswEntry::SetAppUid
       
    87 // --------------------------------------------------------------------------
       
    88 //
       
    89 void CTsEntry::SetAppUid(const TUid &uid)
       
    90 {
       
    91     mAppUid = uid;
       
    92 }
       
    93 
       
    94 // --------------------------------------------------------------------------
       
    95 // CTsFswEntry::SetAppNameL
       
    96 // --------------------------------------------------------------------------
       
    97 //
       
    98 void CTsEntry::SetAppNameL(const TDesC &appName)
       
    99 {
       
   100     delete mAppName;
       
   101     mAppName = 0;
       
   102     mAppName = appName.AllocL();
       
   103 }
       
   104 
       
   105 // --------------------------------------------------------------------------
       
   106 // CTsFswEntry::SetSystemApp
       
   107 // --------------------------------------------------------------------------
       
   108 //
       
   109 void CTsEntry::SetCloseableApp(TBool value)
       
   110 {
       
   111     mCloseableApp = value;
       
   112 }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // CTsFswEntry::SetAppIconHandles
       
   116 // --------------------------------------------------------------------------
       
   117 //
       
   118 void CTsEntry::SetAppIcon(CFbsBitmap * bitmap)
       
   119 {
       
   120     mAppIconBitmap = bitmap;
       
   121 }
       
   122 
       
   123 // --------------------------------------------------------------------------
       
   124 /**
       
   125  * Application uid.
       
   126  */
       
   127 TUid CTsEntry::AppUid() const
       
   128 {
       
   129     return mAppUid;
       
   130 }
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 /**
       
   134  * Application name.
       
   135  */
       
   136 const TDesC& CTsEntry::AppName() const
       
   137 {
       
   138     return mAppName ? *mAppName : KNullDesC();
       
   139 }
       
   140 
       
   141 // --------------------------------------------------------------------------
       
   142 /**
       
   143  * Retrieve entry visibilit status
       
   144  */
       
   145 Visibility CTsEntry::GetVisibility() const
       
   146 {
       
   147     return mVisibility;
       
   148 }
       
   149 
       
   150 // --------------------------------------------------------------------------
       
   151 /**
       
   152  * Change entry visibility status
       
   153  * @param visibility - new visibility status
       
   154  */
       
   155 void CTsEntry::SetVisibility(Visibility visibility)
       
   156 {
       
   157     mVisibility = visibility;
       
   158 }
       
   159 
       
   160 // --------------------------------------------------------------------------
       
   161 /**
       
   162  * ETrue if the application is closeable
       
   163  */
       
   164 TBool CTsEntry::CloseableApp() const
       
   165 {
       
   166     return mCloseableApp;
       
   167 }
       
   168 
       
   169 // --------------------------------------------------------------------------
       
   170 /**
       
   171  * Application icon bitmap
       
   172  */
       
   173 CFbsBitmap *CTsEntry::AppIconBitmap() const
       
   174 {
       
   175     return mAppIconBitmap;
       
   176 }
       
   177 
       
   178 // --------------------------------------------------------------------------
       
   179 /**
       
   180  * Entry's key
       
   181  */
       
   182 const TTsEntryKey &CTsEntry::Key() const
       
   183 {
       
   184     return mKey;
       
   185 }
       
   186 
       
   187 TTime CTsEntry::Timestamp() const
       
   188 {
       
   189     return mTimestamp;
       
   190 }
       
   191     
       
   192 // --------------------------------------------------------------------------
       
   193 /**
       
   194  * Timestamp of last entry change 
       
   195  */
       
   196 TTime CTsEntry::LastUpdateTimestamp() const
       
   197 {
       
   198     return mUpdateTimestamp;
       
   199 }
       
   200 
       
   201 void CTsEntry::SetTimestamp(const TTime &timestamp)
       
   202 {
       
   203     mTimestamp = timestamp;
       
   204     RefreshUpdateTimestamp();
       
   205 }
       
   206 
       
   207 // --------------------------------------------------------------------------
       
   208 /**
       
   209  * Set new value of updates timestamp
       
   210  */
       
   211 void CTsEntry::RefreshUpdateTimestamp()
       
   212 {
       
   213     mUpdateTimestamp.UniversalTime();
       
   214 }
       
   215 
       
   216 // --------------------------------------------------------------------------
       
   217 // CTsFswEntry::SetScreenshot
       
   218 // --------------------------------------------------------------------------
       
   219 //
       
   220 void CTsEntry::SetScreenshotL(const CFbsBitmap &bitmapArg, UpdatePriority priority, TInt angle)
       
   221 {
       
   222     TInt currentPriority = static_cast<TInt> (mPriority);
       
   223     TInt newPriority = static_cast<TInt> (priority);
       
   224     if(newPriority <currentPriority) {
       
   225         User::Leave(KErrAccessDenied);
       
   226     }
       
   227     
       
   228     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
   229     CleanupStack::PushL(bitmap);
       
   230     User::LeaveIfError(bitmap->Duplicate(bitmapArg.Handle()));
       
   231     CleanupStack::Pop(bitmap);
       
   232 
       
   233     mPriority = priority;
       
   234     delete mScreenshot;
       
   235     mScreenshot = bitmap;
       
   236     RefreshUpdateTimestamp();
       
   237 
       
   238     iProvider->createThumbnail( *mScreenshot, angle);
       
   239 }
       
   240 
       
   241 // --------------------------------------------------------------------------
       
   242 // CTsFswEntry::RemoveScreenshot
       
   243 // --------------------------------------------------------------------------
       
   244 //
       
   245 void CTsEntry::RemoveScreenshotL()
       
   246 {
       
   247     if (!mScreenshot) {
       
   248         User::Leave(KErrNotFound);
       
   249     }
       
   250     delete mScreenshot;
       
   251     mScreenshot = NULL;
       
   252     mPriority = Low;
       
   253     
       
   254     mObserver.DataChanged();
       
   255     RefreshUpdateTimestamp();
       
   256 }
       
   257 
       
   258 // --------------------------------------------------------------------------
       
   259 /**
       
   260  * Application screenshot.
       
   261  */
       
   262 CFbsBitmap* CTsEntry::Screenshot() const
       
   263 {
       
   264     return mScreenshot;
       
   265 }
       
   266 
       
   267 // --------------------------------------------------------------------------
       
   268 /**
       
   269  * Interface implementation
       
   270  * @see MTsThumbnailObserver::ThumbnailCreated( const CFbsBitmap& )
       
   271  */
       
   272 void CTsEntry::ThumbnailCreated(const CFbsBitmap& aThumbnail)
       
   273     {
       
   274     mScreenshot->Reset();
       
   275     mScreenshot->Duplicate(aThumbnail.Handle());
       
   276     RefreshUpdateTimestamp();
       
   277     mObserver.DataChanged();
       
   278     }
       
   279 
       
   280 // end of file