taskswitcher/screenshotplugin/src/tsscreenshotnotifier.cpp
changeset 124 e36b2f4799c0
equal deleted inserted replaced
121:0b3699f6c654 124:e36b2f4799c0
       
     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: 
       
    15 *
       
    16 */
       
    17 #include <fbs.h>
       
    18 #include <s32mem.h>
       
    19 
       
    20 #include "tsscreenshotnotifier.h"
       
    21 #include "tsscreenshotmsg.h"
       
    22 
       
    23 //------------------------------------------------------------------------------
       
    24 CTsScreenshotNotifier* CTsScreenshotNotifier::NewL( MTsNotifier& aNotifier, 
       
    25                                                     TInt aId,
       
    26                                                     CFbsBitmap* aBitmap,
       
    27                                                     TInt aAngle )
       
    28     {
       
    29     User::LeaveIfNull(aBitmap);
       
    30     CTsScreenshotNotifier* self = 
       
    31         new(ELeave)CTsScreenshotNotifier( aNotifier, aId, aBitmap, aAngle );
       
    32     return self;
       
    33     }
       
    34 
       
    35 //------------------------------------------------------------------------------
       
    36 CTsScreenshotNotifier::CTsScreenshotNotifier( MTsNotifier& aNotifier, 
       
    37                                               TInt aId,
       
    38                                               CFbsBitmap* aBitmap,
       
    39                                               TInt aAngle )
       
    40 :
       
    41     CActive( EPriorityIdle ),
       
    42     iNotifier( aNotifier ),
       
    43     iId( aId ),
       
    44     iBitmap( aBitmap ),
       
    45     iAngle( aAngle )
       
    46     {
       
    47     CActiveScheduler::Add(this);
       
    48     SetActive();
       
    49     TRequestStatus *status( &iStatus );
       
    50     User::RequestComplete( status, KErrNone );
       
    51     }
       
    52 
       
    53 //------------------------------------------------------------------------------
       
    54 CTsScreenshotNotifier::~CTsScreenshotNotifier()
       
    55     {
       
    56     Cancel();
       
    57     delete iBitmap;
       
    58     }
       
    59 
       
    60 //------------------------------------------------------------------------------
       
    61 TInt CTsScreenshotNotifier::Handle() const
       
    62     {
       
    63     return iBitmap->Handle();
       
    64     }
       
    65 
       
    66 //------------------------------------------------------------------------------
       
    67 void CTsScreenshotNotifier::DoCancel()
       
    68     {
       
    69     //No implementation required
       
    70     }
       
    71 
       
    72 //------------------------------------------------------------------------------
       
    73 void CTsScreenshotNotifier::RunL()
       
    74     {
       
    75     RBuf8 message;
       
    76     CleanupClosePushL(message);
       
    77     message.CreateL(CTsScreenshotMsg::Size() + sizeof(TInt));
       
    78     RDesWriteStream stream(message);
       
    79     CleanupClosePushL(stream);
       
    80     stream.WriteInt32L(RegisterScreenshotMessage);
       
    81     CTsScreenshotMsg * screenshotMsg = 
       
    82         CTsScreenshotMsg::NewLC(iId, 
       
    83                                 *iBitmap, 
       
    84                                 Low, 
       
    85                                 iAngle);
       
    86     stream << (*screenshotMsg);
       
    87     CleanupStack::PopAndDestroy(screenshotMsg);
       
    88     CleanupStack::PopAndDestroy(&stream);
       
    89     iNotifier.SendMessageL(message);
       
    90     CleanupStack::PopAndDestroy(&message);
       
    91     }
       
    92 
       
    93 //------------------------------------------------------------------------------
       
    94 TInt CTsScreenshotNotifier::RunError(TInt /*aError*/)
       
    95     {
       
    96     delete iBitmap;
       
    97     iBitmap = 0;
       
    98     return KErrNone;
       
    99     }