taskswitcher/contextengine/tsfswpreviewprovider/src/tspreviewproviderclient.cpp
changeset 4 4d54b72983ae
child 15 ff572dfe6d86
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
       
     1 /*
       
     2 * Copyright (c) 2008 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 */
       
    10 
       
    11 #include "tspreviewproviderclient.h"
       
    12 #include "previewproviderlogging.h"
       
    13 #include "tspropertylistener.h"
       
    14 #include "previewmsg.h"
       
    15 
       
    16 #include <s32mem.h>
       
    17 
       
    18 #define SZ( x ) ( sizeof( x ) / sizeof( TInt ) )
       
    19 
       
    20 
       
    21 // --------------------------------------------------------------------------
       
    22 // CTsFastSwapPreviewProviderClient::CTsFastSwapPreviewProviderClient
       
    23 // --------------------------------------------------------------------------
       
    24 //
       
    25 CTsFastSwapPreviewProviderClient::CTsFastSwapPreviewProviderClient(
       
    26         MTsFastSwapPreviewObserver& aObs ) : iObs( aObs )
       
    27     {
       
    28     }
       
    29 
       
    30 // --------------------------------------------------------------------------
       
    31 // CTsFastSwapPreviewProviderClient::~CTsFastSwapPreviewProviderClient
       
    32 // --------------------------------------------------------------------------
       
    33 //
       
    34 CTsFastSwapPreviewProviderClient::~CTsFastSwapPreviewProviderClient()
       
    35     {
       
    36     delete iListener;
       
    37     }
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // CTsFastSwapPreviewProviderClient::ConstructL
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 void CTsFastSwapPreviewProviderClient::ConstructL()
       
    44     {
       
    45     TSLOG_CONTEXT( ConstructL, TSLOG_LOCAL );
       
    46     TSLOG_IN();
       
    47 
       
    48     const TUid id = { 0x20016BEC };
       
    49     BaseConstructL( id, KNullDesC8 );
       
    50     iListener = CTsPropertyListener::NewL( iObs );
       
    51     
       
    52     TSLOG_OUT();        
       
    53     }    
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CTsFastSwapPreviewProviderClient::Register
       
    57 // --------------------------------------------------------------------------
       
    58 //    
       
    59 void CTsFastSwapPreviewProviderClient::Register( TInt aWgId )
       
    60     {
       
    61     TSLOG_CONTEXT( Register, TSLOG_LOCAL );
       
    62     TSLOG_IN();
       
    63     
       
    64     const TInt msg[] = {
       
    65         NPreviewMsg::ERegister,
       
    66         aWgId
       
    67         };
       
    68     TPckgC<TInt[SZ(msg)]> buf(msg);
       
    69     SendMessage(buf);
       
    70     Flush();
       
    71 
       
    72     TSLOG_OUT();
       
    73     }
       
    74 
       
    75 // --------------------------------------------------------------------------
       
    76 // CTsFastSwapPreviewProviderClient::Unregister
       
    77 // --------------------------------------------------------------------------
       
    78 //    
       
    79 void CTsFastSwapPreviewProviderClient::Unregister( TInt aWgId )
       
    80     {
       
    81     TSLOG_CONTEXT( Unregister, TSLOG_LOCAL );
       
    82     TSLOG_IN();
       
    83 
       
    84     const TInt msg[] = {
       
    85         NPreviewMsg::EUnregister,
       
    86         aWgId
       
    87         };
       
    88     TPckgC<TInt[SZ(msg)]> buf(msg);
       
    89     SendMessage(buf);
       
    90     Flush();
       
    91     
       
    92     TSLOG_OUT();
       
    93     }
       
    94 
       
    95 // --------------------------------------------------------------------------
       
    96 // CTsFastSwapPreviewProviderClient::ChangeScreen
       
    97 // --------------------------------------------------------------------------
       
    98 //    
       
    99 void CTsFastSwapPreviewProviderClient::ChangeScreen( TInt aScreenNo )
       
   100     {
       
   101     TSLOG_CONTEXT( ChangeScreen, TSLOG_LOCAL );
       
   102     TSLOG_IN();
       
   103     
       
   104     const TInt msg[] = {
       
   105         NPreviewMsg::EChangeScreen,
       
   106         aScreenNo
       
   107         };
       
   108     TPckgC<TInt[SZ(msg)]> buf(msg);
       
   109     SendMessage(buf);
       
   110     Flush();
       
   111     
       
   112     TSLOG_OUT();     
       
   113     }
       
   114 
       
   115 // --------------------------------------------------------------------------
       
   116 // CTsFastSwapPreviewProviderClient::SetPreviewParam
       
   117 // --------------------------------------------------------------------------
       
   118 //    
       
   119 void CTsFastSwapPreviewProviderClient::SetPreviewParam(const TSize& aSize,
       
   120         TDisplayMode aMode)
       
   121     {
       
   122     TSLOG_CONTEXT( SetPreviewParam, TSLOG_LOCAL );
       
   123     TSLOG_IN();
       
   124     
       
   125     const TInt msg[] = {
       
   126         NPreviewMsg::ESetPreviewParam,
       
   127         aSize.iWidth,
       
   128         aSize.iHeight,
       
   129         static_cast<TInt>(aMode)
       
   130         };
       
   131     TPckgC<TInt[SZ(msg)]> buf(msg);
       
   132     SendMessage(buf);
       
   133     Flush();
       
   134 
       
   135     TSLOG_OUT();
       
   136     }
       
   137 
       
   138 // --------------------------------------------------------------------------
       
   139 // CTsFastSwapPreviewProviderClient::TakePreview 
       
   140 // --------------------------------------------------------------------------
       
   141 //    
       
   142 void CTsFastSwapPreviewProviderClient::TakePreview()
       
   143     {
       
   144     TSLOG_CONTEXT( TakePreview, TSLOG_LOCAL );
       
   145     TSLOG_IN();
       
   146     
       
   147     TPckgC<TInt> buf(NPreviewMsg::ETakePreview);
       
   148     SendMessage(buf);
       
   149     Flush();
       
   150     
       
   151     TSLOG_OUT();      
       
   152     }
       
   153 
       
   154 // --------------------------------------------------------------------------
       
   155 // CTsFastSwapPreviewProviderClient::AckPreview 
       
   156 // --------------------------------------------------------------------------
       
   157 //
       
   158 void CTsFastSwapPreviewProviderClient::AckPreview( TInt aPreviwId )
       
   159     {
       
   160     TSLOG_CONTEXT( TakePreview, TSLOG_LOCAL );
       
   161     TSLOG_IN();
       
   162     
       
   163     const TInt msg[] = { NPreviewMsg::EAckPreviewReady,
       
   164                          aPreviwId };
       
   165     TPckgC<TInt[SZ(msg)]> buf(msg);
       
   166     SendMessage(buf);
       
   167     Flush();
       
   168     
       
   169     TSLOG_OUT();
       
   170     }
       
   171 
       
   172 // --------------------------------------------------------------------------
       
   173 // CTsFastSwapPreviewProviderClient::HandleMessage
       
   174 // --------------------------------------------------------------------------
       
   175 //    
       
   176 void CTsFastSwapPreviewProviderClient::HandleMessage( const TDesC8& aData )
       
   177     {
       
   178     TRAP_IGNORE(DoHandleMessageL(aData));
       
   179     }
       
   180 
       
   181 // --------------------------------------------------------------------------
       
   182 // CTsFastSwapPreviewProviderClient::DoHandleMessageL
       
   183 // --------------------------------------------------------------------------
       
   184 //
       
   185 void CTsFastSwapPreviewProviderClient::DoHandleMessageL( const TDesC8& aData )
       
   186     {
       
   187     TSLOG_CONTEXT( DoHandleMessageL, TSLOG_LOCAL );
       
   188     TSLOG_IN();
       
   189     
       
   190     RDesReadStream in( aData );
       
   191     TInt message = in.ReadInt32L();
       
   192     switch ( message )
       
   193         {
       
   194         case NPreviewMsg::EPreviewReady:
       
   195             {
       
   196             const TInt id = in.ReadInt32L();
       
   197             const TInt handle = in.ReadInt32L();    
       
   198             SetProperties( handle, id, EOperationBitmapUpdated );
       
   199             }
       
   200             break;
       
   201         case NPreviewMsg::EUnregisterReady:
       
   202             {
       
   203             const TInt id = in.ReadInt32L();
       
   204             const TInt handle = in.ReadInt32L();
       
   205             SetProperties( handle, id, EOperationUnregister );
       
   206             }
       
   207             break;
       
   208         }
       
   209 
       
   210     TSLOG_OUT();
       
   211     }
       
   212 
       
   213 // --------------------------------------------------------------------------
       
   214 // CTsFastSwapPreviewProviderClient::SetProperties
       
   215 // --------------------------------------------------------------------------
       
   216 //
       
   217 void CTsFastSwapPreviewProviderClient::SetProperties(TInt aHandle, TInt aWgId,
       
   218         TInt aOp)
       
   219     {
       
   220     // Notify CPropertyListener via P&S
       
   221     RProperty::Set( KPSUidPreviewProvider, KPSKeyFbsBitmapId, aHandle );
       
   222     RProperty::Set( KPSUidPreviewProvider, KPSKeyOperation, aOp );
       
   223     // KPSKeyWgId should be notified first since that is being listened 
       
   224     // by CPropertyListener 
       
   225     RProperty::Set( KPSUidPreviewProvider, KPSKeyWgId, aWgId );    
       
   226     }
       
   227 
       
   228 // --------------------------------------------------------------------------
       
   229 // CTsFastSwapPreviewProviderClient::OnReplace
       
   230 // --------------------------------------------------------------------------
       
   231 //
       
   232 void CTsFastSwapPreviewProviderClient::OnReplace()
       
   233     {
       
   234     }
       
   235 
       
   236 // End of file