webengine/osswebengine/WebKit/s60/plugins/PluginLoader.h
changeset 0 dd21522fd290
child 13 10e98eab6f85
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:  Loads the plugin content
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __PLUGINLOADER_H__
       
    19 #define __PLUGINLOADER_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "ContentListener.h"
       
    24 #include "PluginWin.h"
       
    25 
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CPluginLoadData;
       
    29 class CUrlResponseInfo;
       
    30 class CUrlResponseHeaderInfo;
       
    31 class CPluginSkin;
       
    32 class CWebKitFrame;
       
    33 class MContentLoaderInterface;
       
    34 
       
    35 /**
       
    36 *  This is a plugin content loader class. It handles loading plugin content
       
    37 *  @lib plugin.dll
       
    38 *  @since 3.1
       
    39 */
       
    40 class CPluginLoader: public CBase, 
       
    41                      public MContentListener                     
       
    42     {
       
    43 
       
    44     public:
       
    45         /**
       
    46         * NewL
       
    47         * Two phase constructor
       
    48         * @param aPluginSkin The plugin skin object that creates the loader
       
    49         * @param aWebKitBridge The webkitbridge
       
    50         * @param aBaseUrl base url from which the plugin is loaded
       
    51         * @return A newly created CPluginLoader object pointer
       
    52         *
       
    53         */
       
    54         static CPluginLoader* NewL( CPluginSkin& aPluginSkin,
       
    55                                     CWebKitFrame& aWebKitFrame,
       
    56                                     const TDesC8& aBaseUrl  );
       
    57         /**
       
    58         * ~CPluginLoader
       
    59         * Destructor
       
    60         *
       
    61         */
       
    62         virtual ~CPluginLoader();
       
    63 
       
    64         /**
       
    65         * LoadPluginContentL
       
    66         * Load the plugin content from the given URL
       
    67         * @since 3.1
       
    68         * @param aUrl url to load the plugin content from
       
    69         * @return void
       
    70         */
       
    71         void LoadPluginContentL( const TDesC8& aUrl, TPluginLoadMode aLoadMode );
       
    72 
       
    73         /**
       
    74         * LoadPluginContentL
       
    75         * Load the plugin content from the given URL
       
    76         * @since 3.1
       
    77         * @param aUrl url to load the plugin content from
       
    78         * @param aMethod url to load the plugin content from
       
    79         * @param aLoadMode url to load the plugin content from
       
    80         * @param aBody url to load the plugin content from
       
    81         * @param aTrId url to load the plugin content from
       
    82         * @return void
       
    83         */
       
    84         void LoadPluginContentL( const TDesC8& aUrl,
       
    85                                  TUrlLoadMethod aMethod,
       
    86                                  TPluginLoadMode aLoadMode,
       
    87                                  const TPtr8& aBody, TInt &aTrId);
       
    88 
       
    89         /**
       
    90         * CancelAllTransactions
       
    91         * Cancels all plugin transactions
       
    92         * @since 3.1
       
    93         * @return void
       
    94         */
       
    95         void CancelAllTransactions();
       
    96 
       
    97     public: // Methods From CUrlLoadListener
       
    98 
       
    99         /**
       
   100         * HeadersL
       
   101         * Invoked when headers arrive
       
   102         * @since 3.1
       
   103         * @param
       
   104         * @return KErrNotSupported if it is not a native browser content
       
   105         */
       
   106         TInt HeadersL( TInt aTransactionId, CUrlResponseInfo& aResponse );
       
   107 
       
   108         /**
       
   109         * ResponseL
       
   110         * Creates a PluginInst in response to first chunk and creates and writes to a stream
       
   111         * to the plugin. On subsequent chunks it just writes to the stream
       
   112         * @since 3.1
       
   113         * @param
       
   114         * @return void
       
   115         */
       
   116         void ResponseL( TInt aTransactionId, CUrlResponseInfo& aResponse );
       
   117 
       
   118         /**
       
   119         * Complete
       
   120         * Closes the stream to the plugin since response is complete
       
   121         * @since 3.1
       
   122         * @param aTransactionId Transaction ID for the load request
       
   123         * @param aError Error code for the transaction
       
   124         * @return void
       
   125         */
       
   126         void Complete( TInt aTransactionId, CUrlResponseInfo& aResponse, TInt aError );
       
   127 
       
   128         /**
       
   129         * HandleError
       
   130         * Handles any error
       
   131         * @since 3.1
       
   132         * @param aTransactionId Transaction ID for the load request
       
   133         * @param aError Error ID for the load request
       
   134         * @return void
       
   135         */
       
   136         void HandleError( TInt aTransactionId, TInt aError );
       
   137 
       
   138         /**
       
   139         * GetTransactionId
       
   140         * Return transaction Id, using the request url
       
   141         * @param aRequestUrl the request url
       
   142         * @return TInt the transaction Id
       
   143         */
       
   144         TInt GetTransactionId( const TDesC8& aRequestUrl );
       
   145 
       
   146         /**
       
   147         * GetCompleteError
       
   148         * Return the complete error using TrId as the index into the
       
   149         * PluginLoadDataArray
       
   150         * @param aTrId the transaction Id
       
   151         * @return TInt the completion error
       
   152         */
       
   153         TInt GetCompleteError( TInt aTrId );
       
   154 
       
   155     protected:
       
   156 
       
   157         /**
       
   158         * CPluginLoader
       
   159         * Constructor
       
   160         *
       
   161         */
       
   162         CPluginLoader( CPluginSkin& aPluginSkin, CWebKitFrame& aWebKitFrame );
       
   163 
       
   164         /**
       
   165         * ConstructL
       
   166         * Constructor
       
   167         *
       
   168         */
       
   169         void ConstructL(const TDesC8& aBaseUrl);
       
   170 
       
   171         /**
       
   172         * GetLoadData
       
   173         * Gets the load mode corresponding to load requests transId
       
   174         * @param aTrId the transaction Id
       
   175         * @return load data for a given transaction ID
       
   176         */
       
   177         CPluginLoadData* GetPluginLoadData(TInt aTrId);
       
   178 
       
   179         /**
       
   180         * GetLoadMode
       
   181         * Gets the load mode corresponding to load requests transId
       
   182         * @param aTrId the transaction Id
       
   183         * @return load mode for a given transaction ID
       
   184         */
       
   185         TPluginLoadMode CPluginLoader::GetLoadMode(TInt aTrId);
       
   186 
       
   187         /**
       
   188         * SaveCompleteError
       
   189         * Save the complete error using TrId as the index into the
       
   190         * PluginLoadDataArray
       
   191         * @param aTrId the transaction Id
       
   192         * @param aError the completion error
       
   193         * @return true if successfully saved
       
   194         */
       
   195         TBool SaveCompleteError( TInt aTrId, TInt aError );
       
   196 
       
   197         /**
       
   198         * SaveResponseHeader
       
   199         * Save the response header using TrId as the index into the
       
   200         * PluginLoadDataArray
       
   201         * @param aTrId the transaction Id
       
   202         * @param aResponseHeader the response header structure
       
   203         * @return true if successfully saved
       
   204         */
       
   205         TBool SaveResponseHeader( TInt aTrId, CUrlResponseHeaderInfo& aResponseHeader );
       
   206 
       
   207         /**
       
   208         * RemovePluginLoadData
       
   209         *
       
   210         * @return
       
   211         */
       
   212         void RemovePluginLoadData( TInt aTransactionId );
       
   213 
       
   214     private:
       
   215 
       
   216         //Pointer to the Webkitbridge; not owned
       
   217         CWebKitFrame*   iWebKitFrame;
       
   218         //Pointer to the plugin skin; not owned
       
   219         CPluginSkin*   iPluginSkin;
       
   220         //Base url of the plugin object; owned
       
   221         HBufC8*         iBaseUrl;
       
   222         //Array of Plugin load data
       
   223         CArrayFixFlat<CPluginLoadData>* iPluginLoadDataArray;
       
   224     };
       
   225 
       
   226 /**
       
   227 *  This is a plugin data holder class.
       
   228 *  It maps the transaction to the load mode of the load request
       
   229 *  An array of this datastructure is maintained by CPluginLoader
       
   230 *  It is used for tracking load requests from plugin engines
       
   231 *  @lib plugin.dll
       
   232 *  @since 3.1
       
   233 */
       
   234 class CPluginLoadData : public CBase
       
   235     {
       
   236     public:  // Constructors and destructor
       
   237 
       
   238         /**
       
   239         * Two-phased constructor.
       
   240         */
       
   241         static CPluginLoadData* NewL(TInt aTrId);
       
   242 
       
   243         /**
       
   244         * Destructor.
       
   245         */
       
   246         ~CPluginLoadData();
       
   247 
       
   248     private:  // Constructors
       
   249 
       
   250         /**
       
   251         * C++ default constructor.
       
   252         */
       
   253         CPluginLoadData(TInt aTrId);
       
   254 
       
   255         /**
       
   256         * By default Symbian 2nd phase constructor is private.
       
   257         */
       
   258         void ConstructL();
       
   259 
       
   260     public:  // New functions
       
   261 
       
   262         /**
       
   263         * TransactionId
       
   264         * Get Transaction Id
       
   265         * @since 3.1
       
   266         * @return TInt TransactionId
       
   267         */
       
   268         TInt TransactionId() { return iTransId; }
       
   269 
       
   270         /**
       
   271         * GetHttpStatus
       
   272         * Get HTTP status
       
   273         * @since 3.1
       
   274         * @return TInt iHttpStatus
       
   275         */
       
   276         TInt HttpStatus() { return iHttpStatus; }
       
   277 
       
   278         /**
       
   279         * SetHttpStatus
       
   280         * Set HTTP status
       
   281         * @since 3.1
       
   282         * @param aHttpStatus
       
   283         * @return void
       
   284         */
       
   285         void SetHttpStatus(TInt aHttpStatus);
       
   286 
       
   287         /**
       
   288         * SetLoadMode
       
   289         * Save the load mode.
       
   290         * @since 3.1
       
   291         * @param aLoadMode the enum TPluginLoadMode load mode
       
   292         * @return void
       
   293         */
       
   294         void SetLoadMode(TPluginLoadMode aLoadMode);
       
   295 
       
   296         /**
       
   297         * LoadMode
       
   298         * Return the load mode
       
   299         * @since 3.1
       
   300         * @param aTrId the transaction Id
       
   301         * @return TPluginLoadMode
       
   302         */
       
   303         TPluginLoadMode LoadMode() { return iLoadMode; }
       
   304 
       
   305         /**
       
   306         * SetCompleteError
       
   307         * Save completion "error/reason" code from response complete
       
   308         * @since 3.1
       
   309         * @param aCompleteError the completion error code
       
   310         * @return void
       
   311         */
       
   312         void SetCompleteError(TInt aCompleteError);
       
   313 
       
   314         /**
       
   315         * CompleteError
       
   316         * Get completion "error/reason" code from response complete
       
   317         * @since 3.1
       
   318         * @return TInt completion error code
       
   319         */
       
   320         TInt CompleteError() { return iCompleteError; }
       
   321 
       
   322         /**
       
   323         * SetRequestUrlL
       
   324         * Save request url. We take ownership of the url.
       
   325         * @since 3.1
       
   326         * @param aRequestUrl the request url
       
   327         * @return void
       
   328         */
       
   329         void SetRequestUrlL(const TDesC8& aRequestUrl);
       
   330 
       
   331         /**
       
   332         * RequestUrlL
       
   333         * Return the request url
       
   334         * @since 3.1
       
   335         * @return void
       
   336         */
       
   337         HBufC8* RequestUrlL() { return iRequestUrl; }
       
   338 
       
   339         /**
       
   340         * SetURLLoader
       
   341         * Save request url. We take ownership of the url.
       
   342         * @since 3.1
       
   343         * @param aRequestUrl the request url
       
   344         * @return void
       
   345         */
       
   346         void SetUrlLoader(MContentLoaderInterface* aUrlLoader);
       
   347 
       
   348         /**
       
   349         * UrlLoader
       
   350         * Return the request url
       
   351         * @since 3.1
       
   352         * @return void
       
   353         */
       
   354         MContentLoaderInterface* UrlLoader() { return iUrlLoader; }
       
   355 
       
   356   private: // members
       
   357         TInt iTransId;
       
   358         TPluginLoadMode iLoadMode;
       
   359         TInt iCompleteError;
       
   360         TInt iHttpStatus;
       
   361         HBufC8* iRequestUrl;
       
   362         MContentLoaderInterface* iUrlLoader;
       
   363     };
       
   364 
       
   365 #endif