1 //******************************************************************
3 // Copyright 2014 MediaTek All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "ocstack-jni.h"
23 static const char* TAG = "PLATFORMCFG-JNI";
25 OC::ServiceType getServiceType(int type)
29 return OC::ServiceType::InProc;
32 return OC::ServiceType::OutOfProc;
36 OC::ModeType getModeType(int type)
40 return OC::ModeType::Server;
42 return OC::ModeType::Client;
45 return OC::ModeType::Both;
49 OC::QualityOfService getQOS(int type)
53 return OC::QualityOfService::LowQos;
55 return OC::QualityOfService::MidQos;
57 return OC::QualityOfService::HighQos;
60 return OC::QualityOfService::NaQos;
64 OC::PlatformConfig *g_cfg;
66 JNIEXPORT jlong JNICALL createNativeInstance
67 (JNIEnv *env, jobject obj, jint jServiceType, jint jModeType, jstring jIpAddress, jint port, jint jQOS)
70 g_cfg = new OC::PlatformConfig{getServiceType(jServiceType),
71 getModeType(jModeType),
72 env->GetStringUTFChars(jIpAddress, 0),
78 jlong instptr = reinterpret_cast<jlong>(g_cfg);