taskswitcher/server/src/tsscreenshotprovider.cpp
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include <s32mem.h>

#include "tsscreenshotprovider.h"
#include "tstaskmonitorglobals.h"
#include "tsscreenshotmsg.h"


const TUid KPluginUID = {0x200267AE};
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
CTsScreenshotProvider* CTsScreenshotProvider::NewL(MTsDataStorage& storage)
{
    CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider(storage);
    CleanupStack::PushL(self);
    self->BaseConstructL(KPluginUID, KNullDesC8);
    CleanupStack::Pop(self);
    return self;
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
CTsScreenshotProvider::CTsScreenshotProvider(MTsDataStorage& storage)
:
mStorage(storage)
{}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void CTsScreenshotProvider::HandleMessage(const TDesC8& msg)
{
    TRAP_IGNORE(HandleMessageL(msg));
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void CTsScreenshotProvider::HandleMessageL(const TDesC8& msg)
{
    RDesReadStream msgStream(msg);
    CleanupClosePushL(msgStream);
    if(RegisterScreenshotMessage != msgStream.ReadInt32L()) {
        User::Leave(KErrNotSupported);
    }
    
    //parse msg to ACK provider ASAP and be sure that bitmap still exists
    CTsScreenshotMsg* screenshotMsg = CTsScreenshotMsg::NewLC(msgStream); 
    SendMessage(msg);
    
    //reset stream
    msgStream.Close();
    msgStream.Open(msg);
    
    //forward stream to storage
    mStorage.handleDataL(msgStream.ReadInt32L(), msgStream);
    
    CleanupStack::PopAndDestroy(screenshotMsg);//
    CleanupStack::PopAndDestroy(&msgStream);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void CTsScreenshotProvider::OnReplace()
{
    //no implementation required
}