taskswitcher/contextengine/tsfswpreviewprovider/wsplugin/inc/previewprovidercrp.h
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 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Preview provider ECOM plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef PREVIEWPROVIDERCRP_H
       
    20 #define PREVIEWPROVIDERCRP_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <w32std.h>
       
    24 #include <graphics/wsgraphicdrawerinterface.h>
       
    25 #include <graphics/wsgraphicdrawer.h>
       
    26 
       
    27 // Number of screenshots used at the same time,
       
    28 // each window group change will cause a screenshot
       
    29 // to one of these, the index for the current one is
       
    30 // switched after each screenshot capture. (this is needed
       
    31 // to prevent overwriting screenshots before the client could
       
    32 // make a copy of them)
       
    33 const TInt KMaxShots = 4;
       
    34 
       
    35 /**
       
    36  * Preview provider window server ECOM plugin class.
       
    37  */
       
    38 NONSHARABLE_CLASS( CPreviewProviderCRP ) : public CWsGraphicDrawer, 
       
    39                                            public MWsEventHandler 
       
    40     {
       
    41 public:
       
    42 
       
    43     /**
       
    44      * Creates a new instance of the plguin.
       
    45      *
       
    46      * @return Created instance.
       
    47      */ 
       
    48     static CWsGraphicDrawer* CreateL();
       
    49     
       
    50     /**
       
    51      * Destructor
       
    52      */ 
       
    53     ~CPreviewProviderCRP();
       
    54     
       
    55 private:
       
    56 
       
    57     /**
       
    58      * From CWsGraphicDrawer.
       
    59      *
       
    60      * @param aGc
       
    61      * @param aRect
       
    62      * @param aData
       
    63      */ 
       
    64     void DoDraw( MWsGc& aGc, const TRect& aRect, const TDesC8& aData ) const;
       
    65     
       
    66     /**
       
    67      * Handles message from PreviewProviderClient.
       
    68      *
       
    69      * @param aData Message data.
       
    70      */ 
       
    71     void HandleMessage( const TDesC8& aData );
       
    72 
       
    73     /**
       
    74      * 2nd phase constructor.
       
    75      *
       
    76      * @param aEnv
       
    77      * @param aId
       
    78      * @param aOwner
       
    79      * @param aData
       
    80      */     
       
    81     void ConstructL( MWsGraphicDrawerEnvironment& aEnv, 
       
    82                      const TGraphicDrawerId& aId, 
       
    83                      MWsClient& aOwner, 
       
    84                      const TDesC8& aData );
       
    85     
       
    86     /**
       
    87      * From MWsEventHandler.
       
    88      * 
       
    89      * Observer for TWservCrEvent::EWindowGroupChanged to take the screenshot
       
    90      * when application changes.
       
    91      *
       
    92      * @param aEvent
       
    93      */     
       
    94     void DoHandleEvent( const TWservCrEvent& aEvent );
       
    95     
       
    96 private:
       
    97 
       
    98     /**
       
    99      * 2nd phase constructor.
       
   100      */ 
       
   101     void ConstructL();
       
   102     
       
   103     /**
       
   104      * Handles application registration.
       
   105      *
       
   106      * @param aWgId Window group id.
       
   107      */ 
       
   108     void Register( TInt aWgId );
       
   109     
       
   110     /**
       
   111      * Handler application unregistration.
       
   112      *
       
   113      * @param aWgId Window group id.
       
   114      */     
       
   115     void Unregister( TInt aWgId );
       
   116     
       
   117     /*
       
   118      * Allocate resources and take screenshot
       
   119      */
       
   120     void ScreenshotL();
       
   121     
       
   122     /**
       
   123      * Takes the screenshot.
       
   124      */     
       
   125     void ScreenshotL( CFbsBitmap& aBitmap );
       
   126     
       
   127     /**
       
   128      * Remove bitmap reference fom list
       
   129      */
       
   130     void RemoveScreenshot( TInt aBitmapHandle );
       
   131     
       
   132     /**
       
   133      * Remove all bitmaps overflow
       
   134      */
       
   135     void CheckOverflow();
       
   136     
       
   137     /**
       
   138      * Handles message from PreviewProviderClient.
       
   139      *
       
   140      * @param aData Message data.
       
   141      */     
       
   142     void DoHandleMessageL( const TDesC8& aData );
       
   143     
       
   144     /**
       
   145      * Notifies the PreviewProviderClient when screenshot is ready for copying.
       
   146      */     
       
   147     void ScaleCompleteL(const CFbsBitmap& aBitmap);
       
   148     
       
   149     /**
       
   150      * Notifies the PreviewProviderClient when an application has been exited.
       
   151      */
       
   152     void UnregisterComplete( TInt aWgId );
       
   153     
       
   154     /**
       
   155      * Uses window server front buffer to create a screenshot.
       
   156      * @param aFront preallocated destination bitmap
       
   157      * @param aFront Front buffer. 
       
   158      * @param aSrcSize Size of the source front buffer in pixels.
       
   159      * @param aSrcStride Source stride.
       
   160      */
       
   161     void FrontBufferScreenShot(
       
   162         CFbsBitmap& aBitmap,
       
   163         MWsFrontBuffer& aFront, const TSize& aSrcSize, TInt aSrcStride );  
       
   164     
       
   165 private:
       
   166     TInt iScreen;
       
   167     TInt iPrevId;
       
   168     TInt iPrevReg; // to work around the problem with wgid not set when app brought 
       
   169                    // to foreground first time
       
   170     RPointerArray<CFbsBitmap> iScreenshots;
       
   171     TSize iScreenshotSize;
       
   172     TDisplayMode iScreenshotMode;
       
   173     RArray<TInt> iWgIds;
       
   174     };
       
   175 
       
   176 #endif // PREVIEWPROVIDERCRP_H
       
   177 
       
   178 // End of file