javaextensions/comm/src/commconnectionimpljni.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 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:  ?Description
       
    15  *
       
    16 */
       
    17 
       
    18 #include "com_nokia_mj_impl_comm_CommConnectionImpl.h"
       
    19 #include "nativecommconnection.h"
       
    20 #include "javacommconnection.h"
       
    21 #include "fs_methodcall.h"
       
    22 
       
    23 using namespace java::comm;
       
    24 
       
    25 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1createNativePeer
       
    26 (JNIEnv *, jobject)
       
    27 {
       
    28     JavaCommConnection *nativeObj = new JavaCommConnection();
       
    29     //NativeCommConnection *obj = new NativeCommConnection();
       
    30     NativeCommConnection *obj = nativeObj->getNativeObject();
       
    31     return reinterpret_cast<jint>(obj);
       
    32 }
       
    33 
       
    34 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1openCommportConnection
       
    35 (JNIEnv *aJni, jobject, jint aNativePeerHandle, jstring aPort, jint aPortNumber, jintArray aIntegerOptions)
       
    36 {
       
    37     NativeCommConnection *nativeConn = reinterpret_cast<NativeCommConnection*>(aNativePeerHandle);
       
    38     std::string port = (aJni)->GetStringUTFChars(aPort, 0);
       
    39     int *optionsList = new int[3];
       
    40     jint* jNativeBufferPtr = reinterpret_cast<jint*>(optionsList);
       
    41     aJni->GetIntArrayRegion(aIntegerOptions, 0, 3, jNativeBufferPtr);
       
    42     int ret = nativeConn->openPortConnection(port,aPortNumber,optionsList);
       
    43     delete[] optionsList;
       
    44     return ret;
       
    45 }
       
    46 
       
    47 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1setBaudRate
       
    48 (JNIEnv *, jobject, jint aNativePeerHandle, jint aBaudRate)
       
    49 {
       
    50     NativeCommConnection *nativeConn = reinterpret_cast<NativeCommConnection*>(aNativePeerHandle);
       
    51     int ret = nativeConn->setBaudRate(aBaudRate);
       
    52     return ret;
       
    53 
       
    54 }
       
    55 
       
    56 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1getBaudRate
       
    57 (JNIEnv *, jobject, jint aNativePeerHandle)
       
    58 {
       
    59     NativeCommConnection *nativeConn = reinterpret_cast<NativeCommConnection*>(aNativePeerHandle);
       
    60     int ret = nativeConn->getBaudRate();
       
    61     return ret;
       
    62 
       
    63 }
       
    64 
       
    65 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1close
       
    66 (JNIEnv *, jobject, jint aNativePeerHandle)
       
    67 {
       
    68     NativeCommConnection *nativeConn = reinterpret_cast<NativeCommConnection*>(aNativePeerHandle);
       
    69     nativeConn->close();
       
    70 
       
    71 }
       
    72 
       
    73 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_comm_CommConnectionImpl__1dispose
       
    74 (JNIEnv *, jobject, jint aNativePeerHandle)
       
    75 {
       
    76     NativeCommConnection* nativeConn = reinterpret_cast<NativeCommConnection*>(aNativePeerHandle);
       
    77     delete nativeConn;
       
    78 }