taskswitcher/utils/src/tsscreenshotmsg.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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 #include <s32mem.h>
       
    18 #include <fbs.h>
       
    19 
       
    20 #include "tsscreenshotmsg.h"
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 CTsScreenshotMsg* CTsScreenshotMsg::NewLC(RReadStream& stream)
       
    24 {
       
    25     CTsScreenshotMsg *self = new(ELeave)CTsScreenshotMsg();
       
    26     CleanupStack::PushL(self);
       
    27     self->ConstructL(stream);
       
    28     return self;
       
    29 }
       
    30 // -----------------------------------------------------------------------------
       
    31 CTsScreenshotMsg* CTsScreenshotMsg::NewLC(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior)
       
    32 {
       
    33     CTsScreenshotMsg *self = new(ELeave)CTsScreenshotMsg();
       
    34     CleanupStack::PushL(self);
       
    35     self->ConstructL(windowGroupId, bitmap, prior);
       
    36     return self;
       
    37 }
       
    38 // -----------------------------------------------------------------------------
       
    39 TInt CTsScreenshotMsg::CTsScreenshotMsg::size()
       
    40 {
       
    41     return sizeof(TInt) * 3;
       
    42 }
       
    43 // -----------------------------------------------------------------------------
       
    44 CTsScreenshotMsg::~CTsScreenshotMsg()
       
    45 {
       
    46     delete mBitmap;
       
    47 }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 TInt CTsScreenshotMsg::windowGroupId() const
       
    51 {
       
    52     return mWindowGroupId;
       
    53 }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 const CFbsBitmap& CTsScreenshotMsg::screenshot() const
       
    57 {
       
    58     return *mBitmap;
       
    59 }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 UpdatePriority CTsScreenshotMsg::priority() const
       
    63 {
       
    64     return mPriority;
       
    65 }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 HBufC8* CTsScreenshotMsg::ExternalizeLC() const
       
    69 {
       
    70     HBufC8* retVal = HBufC8::NewLC(size());
       
    71     TPtr8 des(retVal->Des());
       
    72     RDesWriteStream stream(des);
       
    73     CleanupClosePushL(stream);
       
    74     stream << (*this);
       
    75     CleanupStack::PopAndDestroy(&stream);
       
    76     return retVal;
       
    77 }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 void CTsScreenshotMsg::ExternalizeL(RWriteStream &stream) const
       
    81 {
       
    82     stream.WriteInt32L(mWindowGroupId);
       
    83     stream.WriteInt32L(mBitmap->Handle());
       
    84     stream.WriteInt32L(mPriority);
       
    85 }
       
    86 // -----------------------------------------------------------------------------
       
    87 void CTsScreenshotMsg::InternalizeL(RReadStream &stream)
       
    88 {
       
    89     mWindowGroupId = stream.ReadInt32L();
       
    90     User::LeaveIfError(mBitmap->Duplicate(stream.ReadInt32L()));
       
    91     mPriority = static_cast<UpdatePriority>(stream.ReadInt32L());
       
    92 }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 CTsScreenshotMsg::CTsScreenshotMsg()
       
    96 {}
       
    97 // -----------------------------------------------------------------------------
       
    98 void CTsScreenshotMsg::ConstructL(RReadStream &stream)
       
    99 {
       
   100     mBitmap = new(ELeave)CFbsBitmap();
       
   101     stream >> (*this);
       
   102 }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 void CTsScreenshotMsg::ConstructL(TInt windowGroupId, const CFbsBitmap& bitmap, UpdatePriority prior)
       
   106 {
       
   107     mBitmap = new(ELeave)CFbsBitmap();
       
   108     User::LeaveIfError(mBitmap->Duplicate(bitmap.Handle()));
       
   109     mWindowGroupId = windowGroupId;
       
   110     mPriority = prior;
       
   111 }