webengine/device/src/ServiceEventHandler.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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:  Implemetation of ServiceEventHandler
       
    15 *
       
    16 */
       
    17 
       
    18 #include <config.h>
       
    19 #include "ServiceEventHandler.h"
       
    20 
       
    21 #include <object.h>
       
    22 #include <protect.h>
       
    23 #include <interpreter.h>
       
    24 #include <list.h>
       
    25 #include <e32base.h>
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 using namespace KJS;
       
    29 
       
    30 
       
    31 // ----------------------------------------------------------------------------
       
    32 // ServiceEventHandler::ServiceEventHandler
       
    33 //
       
    34 //
       
    35 //
       
    36 // ----------------------------------------------------------------------------
       
    37 //
       
    38 ServiceEventHandler::ServiceEventHandler(
       
    39     ExecState* execState, const JSObject* aInterfaceFunc, const JSValue* aCallbackFunc, const TInt aTransId )
       
    40     : iGlobalExecState( execState )
       
    41     {
       
    42     iInterfaceFunc = (JSObject*)aInterfaceFunc;
       
    43     iCallbackFunc = (JSObject*)aCallbackFunc;
       
    44     iTransId = aTransId;
       
    45     }
       
    46 
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // ServiceEventHandler::~ServiceEventHandler
       
    50 //
       
    51 //
       
    52 //
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 ServiceEventHandler::~ServiceEventHandler()
       
    56     {
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 // ServiceEventHandler::InvokeCall
       
    61 // Caller supplies a KJS::List as the param
       
    62 //
       
    63 //
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 void ServiceEventHandler::InvokeCall( const List& aParam )
       
    67     {
       
    68     if ( iInterfaceFunc && iCallbackFunc )
       
    69         {
       
    70         JSLock::lock();
       
    71 
       
    72         if ( iGlobalExecState &&
       
    73              !iCallbackFunc->isNull() && iCallbackFunc->isObject()  )
       
    74             {
       
    75             JSObject* objFunc = static_cast<JSObject*>(iCallbackFunc);
       
    76             if (objFunc->implementsCall())
       
    77             {
       
    78             objFunc->call( iGlobalExecState, iInterfaceFunc, aParam ); // note that call() creates its own execution state for the func call
       
    79             }
       
    80             if ( iGlobalExecState->hadException() )
       
    81                 {
       
    82                 iGlobalExecState->clearException();
       
    83                 }
       
    84             }
       
    85 
       
    86         JSLock::unlock();
       
    87         }
       
    88     }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // ServiceEventHandler::EventHandler
       
    92 //
       
    93 //
       
    94 //
       
    95 // ----------------------------------------------------------------------------
       
    96 //
       
    97 JSValue* ServiceEventHandler::CallbackFunc() const
       
    98     {
       
    99     return iCallbackFunc?iCallbackFunc:jsUndefined();
       
   100     }
       
   101 
       
   102 //END OF FILE