browserplugin/cpixnpplugin/src/cnpdocumentfieldinterface.cpp
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 
       
    18 #include "CNPDocumentFieldInterface.h"
       
    19 
       
    20 #include <utf.h>
       
    21 #include "CNPDocumentFieldInterface.h"
       
    22 
       
    23 #include "NPUtils.h"
       
    24 using namespace nputils; 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 CNPDocumentFieldInterface::~CNPDocumentFieldInterface()
       
    29     {
       
    30     }
       
    31 
       
    32 
       
    33 void CNPDocumentFieldInterface::InitInterfaceL()
       
    34     {
       
    35     const NPUTF8 *NPDocumentFieldMethodNames[] =
       
    36     	{ 
       
    37         "getName",
       
    38         "getValue"
       
    39     	};
       
    40 
       
    41     SetIdentifiersL( NULL, 0,
       
    42     				 NPDocumentFieldMethodNames, sizeof(NPDocumentFieldMethodNames)/sizeof(NPDocumentFieldMethodNames[0]));
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 
       
    47 bool CNPDocumentFieldInterface::InvokeL(NPIdentifier name, NPVariant* args, uint32_t argCount, NPVariant *result)
       
    48     {
       
    49     VOID_TO_NPVARIANT(*result);
       
    50     if ( name == iMethodIdentifiers[0] ) // getName
       
    51     	{
       
    52     	TRAP_IGNORE(
       
    53     		DescriptorToVariantL( Name(), *result);
       
    54     		);
       
    55     	// TODO: Report error
       
    56     	return true;
       
    57     	}
       
    58     else if ( name == iMethodIdentifiers[1] ) // getValue
       
    59     	{
       
    60     	TRAP_IGNORE(
       
    61     		DescriptorToVariantL( Value(), *result);
       
    62     		); 
       
    63     	// TODO: Report error
       
    64     	return true;
       
    65     	}
       
    66     return false;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 
       
    71 bool CNPDocumentFieldInterface::GetProperty (NPIdentifier name, NPVariant *variant)
       
    72     {
       
    73     // default variant value maps to javascript undefined
       
    74     VOID_TO_NPVARIANT(*variant);
       
    75     return false;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 
       
    80 bool CNPDocumentFieldInterface::SetPropertyL( NPIdentifier name, NPVariant *variant )
       
    81     {
       
    82     return false;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // NPClass Function
       
    87 
       
    88 NPObject *NPDocumentFieldAllocate ()
       
    89     {
       
    90     NPDocumentFieldObject *newInstance = (NPDocumentFieldObject *)User::Alloc (sizeof(NPDocumentFieldObject));       
       
    91     return (NPObject *)newInstance;
       
    92     }
       
    93 
       
    94 void NPDocumentFieldInvalidate ()
       
    95     {
       
    96     }
       
    97 
       
    98 void NPDocumentFieldDeallocate (NPDocumentFieldObject* obj) 
       
    99     {
       
   100     obj->plugin->Deallocate();
       
   101     User::Free ((void *)obj);
       
   102     }    
       
   103  
       
   104 bool NPDocumentFieldHasMethod(NPDocumentFieldObject* obj, NPIdentifier name)
       
   105     {
       
   106     return obj->plugin->HasMethod(name);
       
   107     }
       
   108 
       
   109 bool NPDocumentFieldInvokeFunctionL(NPDocumentFieldObject* obj, NPIdentifier name, NPVariant *args, uint32_t argCount, NPVariant *result)
       
   110     {
       
   111     return obj->plugin->InvokeL(name, args, argCount, result);
       
   112     }    
       
   113 
       
   114 bool NPDocumentFieldHasProperty(NPDocumentFieldObject* obj, NPIdentifier name)
       
   115     {
       
   116     return obj->plugin->HasProperty(name);
       
   117     }    
       
   118     
       
   119 bool NPDocumentFieldGetProperty (NPDocumentFieldObject* obj, NPIdentifier name, NPVariant *variant)
       
   120     {
       
   121     return obj->plugin->GetProperty(name,variant);
       
   122     }
       
   123 
       
   124 void NPDocumentFieldSetProperty (NPDocumentFieldObject* obj, NPIdentifier name, NPVariant *variant)
       
   125     {
       
   126     TRAP_IGNORE(obj->plugin->SetPropertyL(name,variant));
       
   127     }
       
   128 
       
   129 //  End of File