javauis/javalegacyutils/src/eventserver/MIDEventServer.cpp
changeset 76 4ad59aaee882
parent 69 773449708c84
child 79 2f468c1958d0
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
     1 /*
       
     2 * Copyright (c) 1999-2001 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 
       
    19 #include <mevents.h>
       
    20 #include "eventserverglobals.h"
       
    21 #include "com_nokia_mj_impl_rt_legacy_MIDEventServer.h"
       
    22 #include "JniEnvWrapper.h"
       
    23 
       
    24 /*
       
    25  * Class:     com_symbian_epoc_midp_events_MIDEventServer
       
    26  * Method:    _createServer
       
    27  * Signature: (Ljava/lang/String;)I
       
    28  */
       
    29 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_rt_legacy_MIDEventServer__1createServer(JNIEnv* aJni, jobject, jstring aName)
       
    30 {
       
    31     RJString name(*aJni,aName);
       
    32 
       
    33     JniEnvWrapper::InitJavaVmRef(aJni);
       
    34 
       
    35     TRAPD(h,h=TJavaEventServer::NewL(name).Handle());
       
    36     return h;
       
    37 }
       
    38 
       
    39 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_rt_legacy_MIDEventServer__1shutdown(JNIEnv*, jobject, jint aHandle)
       
    40 {
       
    41     TJavaEventServer(aHandle).Shutdown();
       
    42 }
       
    43 
       
    44 // In polling builds we maintain a global record of all the event
       
    45 // servers running in the system, held in a static RArray of integer
       
    46 // handles. Event servers are added to the handle array by their
       
    47 // Java side thread's run() method, which goes native below.
       
    48 //
       
    49 // Note that it is necessary for the RArray to be initialized
       
    50 // by a function-scoped static in order for its constructor to
       
    51 // get run reliably.
       
    52 
       
    53 RArray<TInt>& EventServerHandles()
       
    54 {
       
    55     return getEsStaticData()->mHandles;
       
    56 }
       
    57