taskswitcher/server/src/tsscreenshotprovider.cpp
changeset 117 c63ee96dbe5f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/server/src/tsscreenshotprovider.cpp	Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* 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
+}