taskswitcher/server/src/tsscreenshotprovider.cpp
changeset 124 e36b2f4799c0
parent 121 0b3699f6c654
child 125 26079c1bb561
equal deleted inserted replaced
121:0b3699f6c654 124:e36b2f4799c0
    17 #include <s32mem.h>
    17 #include <s32mem.h>
    18 
    18 
    19 #include "tsscreenshotprovider.h"
    19 #include "tsscreenshotprovider.h"
    20 #include "tstaskmonitorglobals.h"
    20 #include "tstaskmonitorglobals.h"
    21 #include "tsscreenshotmsg.h"
    21 #include "tsscreenshotmsg.h"
       
    22 #include "tsidlist.h"
    22 
    23 
    23 
    24 
    24 const TUid KPluginUID = {0x200267AE};
    25 const TUid KPluginUID = {0x200267AE};
       
    26 const TInt KSkippedApp [] = {0x20022F35 /* <-- hsapplication */};
    25 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
    26 //
    28 //
    27 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    28 //
    30 //
    29 CTsScreenshotProvider* CTsScreenshotProvider::NewL( MTsDataStorage& aStorage )
    31 CTsScreenshotProvider* CTsScreenshotProvider::NewL( MTsDataStorage& aStorage,
       
    32                                                     MTsWindowGroupsMonitor& aMonitor)
    30     {
    33     {
    31     CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider( aStorage );
    34     CTsScreenshotProvider *self = new (ELeave)CTsScreenshotProvider(aStorage, aMonitor);
    32     CleanupStack::PushL( self );
    35     CleanupStack::PushL( self );
    33     self->BaseConstructL(KPluginUID, KNullDesC8);
    36     self->BaseConstructL(KPluginUID, KNullDesC8);
       
    37     aMonitor.SubscribeL(*self);
    34     CleanupStack::Pop( self );
    38     CleanupStack::Pop( self );
    35     return self;
    39     return self;
    36     }
    40     }
    37 
    41 
    38 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    39 //
    43 CTsScreenshotProvider::CTsScreenshotProvider( MTsDataStorage& aStorage,
    40 // -----------------------------------------------------------------------------
    44                                               MTsWindowGroupsMonitor& aMonitor)
    41 //
       
    42 CTsScreenshotProvider::CTsScreenshotProvider( MTsDataStorage& aStorage )
       
    43 :
    45 :
    44     iStorage(aStorage)
    46     iStorage(aStorage),
       
    47     iMonitor(aMonitor)
    45     {
    48     {
    46     //No implementation required
    49     //No implementation required
    47     }
    50     }
    48 
    51 
       
    52 CTsScreenshotProvider::~CTsScreenshotProvider()
       
    53     {
       
    54     iMonitor.Cancel(*this);
       
    55     }
       
    56 
    49 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    50 //
    58 void CTsScreenshotProvider::HandleWindowGroupChanged(
       
    59                                   MTsResourceManager &aResources, 
       
    60                                   const MTsRunningApplicationStorage& aStorage)
       
    61     {
       
    62     TRAP_IGNORE(HandleWindowGroupChangedL(aResources, aStorage);)
       
    63     }
       
    64 
    51 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    52 //
    66 /**
       
    67  * Retrieve list of applications that shouldn't be displayed in taskswitcher 
       
    68  * and send it to module responsible for screenshot taking.  
       
    69  * Interface implementation.
       
    70  * @see MTsWindowGroupsObserver::HandleWindowGroupChangedL
       
    71  */
       
    72 void CTsScreenshotProvider::HandleWindowGroupChangedL(
       
    73                                    MTsResourceManager& /*aResources*/, 
       
    74                                    const MTsRunningApplicationStorage& aStorage)
       
    75     {
       
    76     const TInt count(sizeof( KSkippedApp ) / sizeof(TInt));
       
    77     CTsIdList* list = CTsIdList::NewLC();
       
    78     list->AppendL(aStorage.BlockedWindowGroups());//filtered servers
       
    79     for( TInt iter(0); iter < aStorage.Count(); ++iter )
       
    80         {
       
    81         if(aStorage[iter].IsHiddenL())
       
    82             {
       
    83             list->AppendL(aStorage[iter].WindowGroupId());
       
    84             }
       
    85         else
       
    86             {
       
    87             for(TInt blocked(0); blocked < count; ++blocked)
       
    88                 {
       
    89                 if(aStorage[iter].UidL().iUid == KSkippedApp[blocked])
       
    90                     {
       
    91                     list->AppendL(aStorage[iter].WindowGroupId());
       
    92                     }
       
    93                 }
       
    94             }
       
    95         }
       
    96     
       
    97     RBuf8 message;
       
    98     CleanupClosePushL(message);
       
    99     message.CreateL(list->Size() + sizeof(TInt));
       
   100     
       
   101     RDesWriteStream stream;
       
   102     CleanupClosePushL(stream);
       
   103     stream.Open(message);
       
   104     stream.WriteInt32L(IgnoreWindowGroups);
       
   105     stream << (*list);
       
   106     CleanupStack::PopAndDestroy(&stream);
       
   107     
       
   108     SendMessage(message);
       
   109     CleanupStack::PopAndDestroy(&message);
       
   110     CleanupStack::PopAndDestroy(list);
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
    53 void CTsScreenshotProvider::HandleMessage( const TDesC8& aMsg )
   114 void CTsScreenshotProvider::HandleMessage( const TDesC8& aMsg )
    54     {
   115     {
    55     TRAP_IGNORE( HandleMessageL( aMsg ) );
   116     TRAP_IGNORE( HandleMessageL( aMsg ) );
    56     }
   117     }
    57 
   118 
    58 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
    59 //
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CTsScreenshotProvider::HandleMessageL( const TDesC8& aMsg )
   120 void CTsScreenshotProvider::HandleMessageL( const TDesC8& aMsg )
    63     {
   121     {
    64     RDesReadStream msgStream( aMsg );
   122     RDesReadStream msgStream( aMsg );
    65     CleanupClosePushL( msgStream );
   123     CleanupClosePushL( msgStream );
    66     switch ( msgStream.ReadInt32L() ) 
   124     switch ( msgStream.ReadInt32L() ) 
    76             msgStream.Open(aMsg);
   134             msgStream.Open(aMsg);
    77             
   135             
    78             //forward stream to storage
   136             //forward stream to storage
    79             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
   137             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
    80             
   138             
    81             CleanupStack::PopAndDestroy(screenshotMsg);            
   139             CleanupStack::PopAndDestroy(screenshotMsg);
    82             break;
   140             break;
    83             }
   141             }
    84             
   142             
    85         case WindowGroupToBackgroundMessage:
   143         case WindowGroupToBackgroundMessage:
    86             {
   144             {
    91             //forward stream to storage
   149             //forward stream to storage
    92             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
   150             iStorage.HandleDataL(msgStream.ReadInt32L(), msgStream);
    93             break;
   151             break;
    94             }
   152             }
    95             
   153             
    96         default: User::Leave(KErrNotSupported);        
   154         default: User::Leave(KErrNotSupported);
    97         }
   155         }
    98 
       
    99     CleanupStack::PopAndDestroy(&msgStream);
   156     CleanupStack::PopAndDestroy(&msgStream);
   100     }
   157     }
   101 
   158 
   102 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   103 //
   160 //