tstaskmonitor/server/src/tsscreenshotprovider.cpp
changeset 102 8b8b34fa9751
parent 100 0920c6a9b6c8
child 106 e78d6e055a5b
equal deleted inserted replaced
100:0920c6a9b6c8 102:8b8b34fa9751
     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 "tsscreenshotprovider.h"
       
    18 #include "tstaskmonitorglobals.h"
       
    19 #include <s32mem.h>
       
    20 
       
    21 const TUid KPluginUID = {0x200267AE};
       
    22 // -----------------------------------------------------------------------------
       
    23 //
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 CTsScreenshotProvider* CTsScreenshotProvider::NewL(MTsDataStorage& storage)
       
    27 {
       
    28     CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider(storage);
       
    29     CleanupStack::PushL(self);
       
    30     self->BaseConstructL(KPluginUID, KNullDesC8);
       
    31     CleanupStack::Pop(self);
       
    32     return self;
       
    33 }
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CTsScreenshotProvider::CTsScreenshotProvider(MTsDataStorage& storage)
       
    40 :
       
    41 mStorage(storage)
       
    42 {}
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CTsScreenshotProvider::HandleMessage(const TDesC8& msg)
       
    49 {
       
    50     TRAP_IGNORE(HandleMessageL(msg));
       
    51 }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CTsScreenshotProvider::HandleMessageL(const TDesC8& msg)
       
    58 {
       
    59     const TInt KMsgSize(5); 
       
    60     TInt parsedMsg[KMsgSize];
       
    61     
       
    62     RDesReadStream msgStream(msg);
       
    63     for (TInt iter(0); iter < KMsgSize; ++iter) {
       
    64         parsedMsg[iter] = msgStream.ReadInt32L();
       
    65     }
       
    66     
       
    67     if (RegisterScreenshotMessage == parsedMsg[0]) {
       
    68         CFbsBitmap *bitmap = new CFbsBitmap;
       
    69         TInt errNo(KErrNoMemory);
       
    70         if (0 != bitmap) {
       
    71             CleanupStack::PushL(bitmap);
       
    72             errNo = bitmap->Duplicate(parsedMsg[ScreenshotHandle + 1]);
       
    73         }
       
    74         const TPckgC<TInt[sizeof(parsedMsg) / sizeof(TInt)]> buf(parsedMsg);//ACK bitmap duplication
       
    75         SendMessage(msg);
       
    76         User::LeaveIfError(errNo);
       
    77         
       
    78         mStorage.UpdateL(parsedMsg[WindowsGroup +1 ], 
       
    79                          *bitmap, 
       
    80                          parsedMsg[AdditionalParameters + 1], 
       
    81                          parsedMsg[Priority + 1]);
       
    82        
       
    83         CleanupStack::PopAndDestroy(bitmap);
       
    84     }
       
    85 }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CTsScreenshotProvider::OnReplace()
       
    92 {
       
    93     //no implementation required
       
    94 }