browserplugins/browsergpsplugin/inc/GpsPlugin.h
branchRCL_3
changeset 65 8e6fa1719340
equal deleted inserted replaced
64:6385c4c93049 65:8e6fa1719340
       
     1 /*
       
     2 * Copyright (c) 2007 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GPSPLUGIN_H
       
    20 #define GPSPLUGIN_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <cecombrowserplugininterface.h>
       
    24 #include <npscript.h>
       
    25 #include <pluginadapterinterface.h> // For base class MPluginNotifier
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CGpsObserver;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /******************************************
       
    33 This class is specific to ECom Style Plugin.  This is used for passing
       
    34 plugin specific initialization information to and from browser.
       
    35 *******************************************/
       
    36 IMPORT_C NPError InitializeFuncs( NPPluginFuncs* aPpf );
       
    37 
       
    38 // CONSTANTS
       
    39 const TInt KFirstGpsImplementationValue = 0x10282870;
       
    40 
       
    41 /**
       
    42 *  CGpsPluginEcomMain
       
    43 *  Used for passing plugin specific initialization information to and from browser.
       
    44 *  @lib npGpsPlugin.lib
       
    45 *  @since S60 v3.2
       
    46 */
       
    47 NONSHARABLE_CLASS(CGpsPluginEcomMain) : public CEcomBrowserPluginInterface
       
    48     {
       
    49  public: // Functions from base classes
       
    50 
       
    51     /**
       
    52      * Two-phased constructor.
       
    53      */
       
    54     static CGpsPluginEcomMain* NewL( TAny* aInitParam );
       
    55 
       
    56     /**
       
    57      * Destructor
       
    58      */
       
    59     virtual ~CGpsPluginEcomMain();
       
    60 
       
    61     /**
       
    62      * Passed from the browser to the plugin and delcares what
       
    63      * functions the browser makes available
       
    64      */
       
    65     NPNetscapeFuncs* Funcs() const { return iNpf; }
       
    66 
       
    67  private:
       
    68 
       
    69     // Default constructor
       
    70     CGpsPluginEcomMain( NPNetscapeFuncs* aNpf );
       
    71 
       
    72     // By default Symbian 2nd phase constructor is private.
       
    73     void ConstructL( NPPluginFuncs* aPluginFuncs );
       
    74 
       
    75     // Netscape Function Pointer
       
    76     NPNetscapeFuncs* iNpf;
       
    77     };
       
    78 
       
    79 /**
       
    80 *  CGpsPlugin class
       
    81 *  Interfaces to Browser, used to pass information between browser and plugin
       
    82 *  @lib npGpsPlugin.lib
       
    83 *  @since S60 v3.2
       
    84 */
       
    85 NONSHARABLE_CLASS(CGpsPlugin) : public CBase
       
    86     {
       
    87  public:
       
    88     static CGpsPlugin* NewL();
       
    89 
       
    90     virtual ~CGpsPlugin();
       
    91 
       
    92  public:
       
    93     void Deallocate ();
       
    94     bool HasMethod( NPIdentifier name );
       
    95     bool Invoke( NPIdentifier name,
       
    96                  NPVariant *args,
       
    97                  uint32_t argCount,
       
    98                  NPVariant *result );
       
    99     bool HasProperty( NPIdentifier name );
       
   100     bool GetProperty( NPIdentifier name, NPVariant *variant );
       
   101     bool SetPropertyL( NPIdentifier name, NPVariant *variant );
       
   102 
       
   103  public:
       
   104     void SetInstance( NPP instance ) { iInstanceHandle = instance; }
       
   105     bool InvokeCallback( TDesC8& name, const NPVariant *args, uint32_t argCount );
       
   106 
       
   107     /**
       
   108      * SetWindowL
       
   109      * @since 2.8
       
   110      * @param MPluginAdapter *pluginAdapter: Pointer to Browser adapter class
       
   111      * @param const TRect& aRect: rectangle representing current UI
       
   112      * @return void
       
   113      */
       
   114     void SetWindowL( MPluginAdapter *pluginAdapter, const TRect& aRect );
       
   115 
       
   116  private:
       
   117     CGpsPlugin();
       
   118     void ConstructL();
       
   119 
       
   120  private:
       
   121     NPP iInstanceHandle;
       
   122     NPIdentifier* iGpsPluginIdentifiers; // not owned
       
   123 
       
   124     // Interface to Browser
       
   125     MPluginAdapter* iPluginAdapter; // not owned
       
   126 
       
   127     // gpsplugin feature class instance
       
   128     CGpsObserver* iGpsObserver; // owned
       
   129     };
       
   130 
       
   131 /**
       
   132 ********************************************************************************
       
   133     Plugin API methods. Source located in CGpsApi.cpp
       
   134 *********************************************************************************
       
   135 */
       
   136 
       
   137 /**
       
   138  * Create a plugin.
       
   139  */
       
   140 
       
   141 NPError GpsNewp( NPMIMEType pluginType, NPP instance, uint16 mode,
       
   142                       CDesCArray* argn, CDesCArray* argv, NPSavedData* saved );
       
   143 
       
   144 /**
       
   145  * Wrapper the errors
       
   146  */
       
   147 void GpsConstructL( NPP aInstance, CDesCArray* argn, CDesCArray* argv );
       
   148 
       
   149 /**
       
   150  * Destroy a plugin.
       
   151  */
       
   152 NPError GpsDestroy( NPP instance, NPSavedData** save );
       
   153 
       
   154 /**
       
   155  * Generic hook to retrieve values/attributes from the plugin.
       
   156  */
       
   157 NPError GpsGetvalue( NPP instance, NPPVariable variable, void *ret_value );
       
   158 
       
   159 /**
       
   160   * This is the parent window of a plugin.
       
   161   */
       
   162 NPError GpsSetwindow(NPP instance, NPWindow* window);
       
   163 
       
   164 /**
       
   165 ********************************************************************************
       
   166     Gps Plugin API methods. Source located in CGpsApi.cpp
       
   167 *********************************************************************************
       
   168 */
       
   169 typedef struct
       
   170     {
       
   171     NPObject object;
       
   172     CGpsPlugin *plugin;
       
   173     } GpsPluginObject;
       
   174 
       
   175 /**
       
   176  * GpsPluginAllocate
       
   177  */
       
   178 NPObject* GpsPluginAllocate( NPP /*npp*/, NPClass* /*aClass*/ );
       
   179 
       
   180 /**
       
   181  * GpsPluginDeallocate
       
   182  */
       
   183 void GpsPluginDeallocate( GpsPluginObject* obj );
       
   184 
       
   185 /**
       
   186  * GpsPluginInvalidate
       
   187  */
       
   188 void GpsPluginInvalidate( NPObject* /*obj*/ );
       
   189 
       
   190 /**
       
   191  * GpsPluginHasMethod
       
   192  */
       
   193 bool GpsPluginHasMethod( GpsPluginObject* obj,
       
   194                          NPIdentifier name );
       
   195 
       
   196 /**
       
   197  * GpsPluginInvoke
       
   198  */
       
   199 bool GpsPluginInvoke( GpsPluginObject* obj,
       
   200                       NPIdentifier name,
       
   201                       NPVariant* args,
       
   202                       uint32_t argCount,
       
   203                       NPVariant* result );
       
   204 
       
   205 /**
       
   206  * GpsPluginHasProperty
       
   207  */
       
   208 bool GpsPluginHasProperty( GpsPluginObject* obj,
       
   209                            NPIdentifier name );
       
   210 
       
   211 /**
       
   212  * GpsPluginGetProperty
       
   213  */
       
   214 bool GpsPluginGetProperty( GpsPluginObject* obj,
       
   215                            NPIdentifier name,
       
   216                            NPVariant* variant );
       
   217 
       
   218 /**
       
   219  * GpsPluginSetProperty
       
   220  */
       
   221 bool GpsPluginSetProperty( GpsPluginObject* obj,
       
   222                            NPIdentifier name,
       
   223                            NPVariant* variant );
       
   224 
       
   225 /**
       
   226  * _GpsPluginClass
       
   227  */
       
   228 static NPClass _GpsPluginClass =
       
   229     {
       
   230     0, // structVersion
       
   231     (NPAllocateFunctionPtr) GpsPluginAllocate,
       
   232     (NPDeallocateFunctionPtr) GpsPluginDeallocate,
       
   233     (NPInvalidateFunctionPtr) GpsPluginInvalidate,
       
   234     (NPHasMethodFunctionPtr) GpsPluginHasMethod,
       
   235     (NPInvokeFunctionPtr) GpsPluginInvoke,
       
   236     (NPInvokeDefaultFunctionPtr) 0,
       
   237     (NPHasPropertyFunctionPtr) GpsPluginHasProperty,
       
   238     (NPGetPropertyFunctionPtr) GpsPluginGetProperty,
       
   239     (NPSetPropertyFunctionPtr) GpsPluginSetProperty,
       
   240     (NPRemovePropertyFunctionPtr) 0,
       
   241     (NPEnumerationFunctionPtr) 0
       
   242     };
       
   243 
       
   244 /**
       
   245  * static instance of the function pointer table
       
   246  */
       
   247 static NPClass* GpsPluginClass = &_GpsPluginClass;
       
   248 
       
   249 #endif      // GPSPLUGIN_H
       
   250 
       
   251 // End of File