browserplugin/cpixnpplugin/inc/cobjectinterface.h
changeset 0 ccd0fd43f247
equal deleted inserted replaced
-1:000000000000 0:ccd0fd43f247
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 #ifndef OBJECTINTERFACE_H
       
    18 #define OBJECTINTERFACE_H
       
    19 
       
    20 #include <e32base.h>
       
    21 
       
    22 #ifdef __S60_50__
       
    23 #include <npscript.h>
       
    24 #include <npapi.h>
       
    25 #else
       
    26 #include <stdint.h>
       
    27 #include <JavaScriptCore/npruntime.h>
       
    28 #endif
       
    29 
       
    30 /**
       
    31  * Provides utility functionality to make the commmunication between 
       
    32  * NP Runtime interface and S60 functionality more convinient. 
       
    33  */
       
    34 class CObjectInterface : public CBase
       
    35 {
       
    36 	// FIXME: This is an antipattern! Move required methods into 
       
    37     // 
       
    38 
       
    39 public:
       
    40 	virtual ~CObjectInterface();
       
    41 
       
    42 public:
       
    43 	void SetInstance( NPP instance, NPObject* aNpObject ) { iInstanceHandle = instance; iNpObject = aNpObject; }
       
    44 	virtual void Deallocate();
       
    45 	
       
    46 	bool HasMethod( NPIdentifier name );
       
    47 	virtual bool HasProperty( NPIdentifier name );
       
    48 	virtual bool InvokeL( NPIdentifier name, NPVariant *args, uint32_t argCount, NPVariant *result ) = 0;
       
    49 	virtual bool GetProperty( NPIdentifier name, NPVariant *variant ) = 0;
       
    50 	virtual bool SetPropertyL( NPIdentifier name, NPVariant *variant ) = 0;
       
    51 	
       
    52 protected:
       
    53 	CObjectInterface();
       
    54 	void SetIdentifiersL( const NPUTF8** aPropertyNames, TInt aPropertyCount, const NPUTF8** aMethodNames, TInt aMethodCount );
       
    55 	
       
    56 protected:
       
    57 	NPP iInstanceHandle;
       
    58 	NPObject* iNpObject; // For raising exceptions and reference counting
       
    59 	
       
    60     NPIdentifier* iPropertyIdentifiers;
       
    61     NPIdentifier* iMethodIdentifiers;
       
    62     
       
    63     TInt          iPropertyCount;
       
    64     TInt          iMethodCount;
       
    65 };
       
    66 
       
    67 #endif /*OBJECTINTERFACE_H*/