javauis/lcdui_akn/javalcdui/src/CMIDEvent.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 1999-2002 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 "CJavaEventServer.h"
       
    19 #include "CMIDEvent.h"
       
    20 #include <stdio.h>
       
    21 #include <e32def.h>
       
    22 #include "lcdui.h"
       
    23 
       
    24 CMIDEvent::CMIDEvent
       
    25 (
       
    26     jmethodID   aMethod,
       
    27     jobject     aSource,
       
    28     TEventType  aType,
       
    29     TInt        aParam0,
       
    30     TInt        aParam1,
       
    31     TInt        aParam2
       
    32 )
       
    33         : iMethod(aMethod)
       
    34         , iSource(aSource)
       
    35         , iType(aType)
       
    36         , iParam0(aParam0)
       
    37         , iParam1(aParam1)
       
    38         , iParam2(aParam2)
       
    39 {
       
    40 }
       
    41 
       
    42 void CMIDEvent::Dispatch(JNIEnv& aJni)
       
    43 {
       
    44     CMIDToolkit& toolkit = Object();
       
    45     jobject sourceObject = aJni.NewLocalRef(iSource);
       
    46     if (sourceObject)
       
    47     {
       
    48         jobject peerObject = aJni.NewLocalRef(toolkit.Peer());
       
    49         if (peerObject)
       
    50         {
       
    51             aJni.CallVoidMethod(
       
    52                 peerObject,
       
    53                 iMethod,
       
    54                 sourceObject,
       
    55                 iType,
       
    56                 iParam0,
       
    57                 iParam1,
       
    58                 iParam2
       
    59             );
       
    60             aJni.DeleteLocalRef(peerObject);
       
    61         }
       
    62         aJni.DeleteLocalRef(sourceObject);
       
    63     }
       
    64 }