taskswitcher/server/src/tsscreenshotprovider.cpp
changeset 121 0b3699f6c654
child 119 50e220be30d1
equal deleted inserted replaced
115:3ab5c078b490 121:0b3699f6c654
       
     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& aStorage )
       
    30     {
       
    31     CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider( aStorage );
       
    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& aStorage )
       
    43 :
       
    44     iStorage(aStorage)
       
    45     {
       
    46     //No implementation required
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CTsScreenshotProvider::HandleMessage( const TDesC8& aMsg )
       
    54     {
       
    55     TRAP_IGNORE( HandleMessageL( aMsg ) );
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CTsScreenshotProvider::HandleMessageL( const TDesC8& aMsg )
       
    63     {
       
    64     RDesReadStream msgStream( aMsg );
       
    65     CleanupClosePushL( msgStream );
       
    66     switch ( msgStream.ReadInt32L() ) 
       
    67         {
       
    68         case RegisterScreenshotMessage:
       
    69             {
       
    70             //parse msg to ACK provider ASAP and be sure that bitmap still exists
       
    71             CTsScreenshotMsg* screenshotMsg = CTsScreenshotMsg::NewLC(msgStream); 
       
    72             SendMessage(aMsg);
       
    73             
       
    74             //reset stream
       
    75             msgStream.Close();
       
    76             msgStream.Open(aMsg);
       
    77             
       
    78             //forward stream to storage
       
    79             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
       
    80             
       
    81             CleanupStack::PopAndDestroy(screenshotMsg);            
       
    82             break;
       
    83             }
       
    84             
       
    85         case WindowGroupToBackgroundMessage:
       
    86             {
       
    87             //reset stream
       
    88             msgStream.Close();
       
    89             msgStream.Open(aMsg);
       
    90             
       
    91             //forward stream to storage
       
    92             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
       
    93             break;
       
    94             }
       
    95             
       
    96         default: User::Leave(KErrNotSupported);        
       
    97         }
       
    98 
       
    99     CleanupStack::PopAndDestroy(&msgStream);
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CTsScreenshotProvider::OnReplace()
       
   107     {
       
   108     //No implementation required
       
   109     }