taskswitcher/server/src/tsscreenshotprovider.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     1 /*
       
     2 * Copyright (c) 2009 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 <s32mem.h>
       
    18 
       
    19 #include "tsscreenshotprovider.h"
       
    20 #include "tstaskmonitorglobals.h"
       
    21 #include "tsscreenshotmsg.h"
       
    22 
       
    23 
       
    24 const TUid KPluginUID = {0x200267AE};
       
    25 // -----------------------------------------------------------------------------
       
    26 //
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CTsScreenshotProvider* CTsScreenshotProvider::NewL(MTsDataStorage& storage)
       
    30 {
       
    31     CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider(storage);
       
    32     CleanupStack::PushL(self);
       
    33     self->BaseConstructL(KPluginUID, KNullDesC8);
       
    34     CleanupStack::Pop(self);
       
    35     return self;
       
    36 }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CTsScreenshotProvider::CTsScreenshotProvider(MTsDataStorage& storage)
       
    43 :
       
    44 mStorage(storage)
       
    45 {}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CTsScreenshotProvider::HandleMessage(const TDesC8& msg)
       
    52 {
       
    53     TRAP_IGNORE(HandleMessageL(msg));
       
    54 }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 void CTsScreenshotProvider::HandleMessageL(const TDesC8& msg)
       
    61 {
       
    62     RDesReadStream msgStream(msg);
       
    63     CleanupClosePushL(msgStream);
       
    64     if(RegisterScreenshotMessage != msgStream.ReadInt32L()) {
       
    65         User::Leave(KErrNotSupported);
       
    66     }
       
    67     
       
    68     //parse msg to ACK provider ASAP and be sure that bitmap still exists
       
    69     CTsScreenshotMsg* screenshotMsg = CTsScreenshotMsg::NewLC(msgStream); 
       
    70     SendMessage(msg);
       
    71     
       
    72     //reset stream
       
    73     msgStream.Close();
       
    74     msgStream.Open(msg);
       
    75     
       
    76     //forward stream to storage
       
    77     mStorage.handleDataL(msgStream.ReadInt32L(), msgStream);
       
    78     
       
    79     CleanupStack::PopAndDestroy(screenshotMsg);//
       
    80     CleanupStack::PopAndDestroy(&msgStream);
       
    81 }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CTsScreenshotProvider::OnReplace()
       
    88 {
       
    89     //no implementation required
       
    90 }