mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-29 06:36:22 +00:00
fix(PlatformHelpers): clean code, fix coding style, use cpp logger...
This commit is contained in:
parent
2941e64e3e
commit
4e3c5d9548
6 changed files with 152 additions and 148 deletions
|
|
@ -221,47 +221,47 @@ if (APPLE)
|
||||||
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/paths/paths-apple.mm)
|
list(APPEND LINPHONE_OBJC_SOURCE_FILES core/paths/paths-apple.mm)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-apple.h)
|
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-apple.h)
|
||||||
|
|
||||||
elseif(ANDROID)
|
elseif (ANDROID)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-android.cpp core/platform-helpers/android-helpers.cpp)
|
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-android.cpp core/platform-helpers/android-platform-helpers.cpp)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-android.h)
|
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-android.h)
|
||||||
|
|
||||||
elseif(WIN32)
|
elseif (WIN32)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-windows.cpp)
|
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-windows.cpp)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-windows.h)
|
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-windows.h)
|
||||||
|
|
||||||
elseif(UNIX)
|
elseif (UNIX)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-linux.cpp)
|
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES core/paths/paths-linux.cpp)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-linux.h)
|
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES core/paths/paths-linux.h)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS} ${LIBXSD_INCLUDE_DIRS})
|
set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS} ${LIBXSD_INCLUDE_DIRS})
|
||||||
set(LINPHONE_CXX_OBJECTS_DEFINITIONS "-DLIBLINPHONE_EXPORTS")
|
set(LINPHONE_CXX_OBJECTS_DEFINITIONS "-DLIBLINPHONE_EXPORTS")
|
||||||
set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
|
set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS})
|
||||||
|
|
||||||
if(SOCI_FOUND)
|
if (SOCI_FOUND)
|
||||||
list(APPEND LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${SOCI_INCLUDE_DIRS} ${SOCI_MYSQL_INCLUDES})
|
list(APPEND LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${SOCI_INCLUDE_DIRS} ${SOCI_MYSQL_INCLUDES})
|
||||||
add_definitions(-DSOCI_ENABLED)
|
add_definitions(-DSOCI_ENABLED)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
set(LINPHONE_PRIVATE_HEADER_FILES)
|
set(LINPHONE_PRIVATE_HEADER_FILES)
|
||||||
foreach(header ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES})
|
foreach (header ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES})
|
||||||
list(APPEND LINPHONE_PRIVATE_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
|
list(APPEND LINPHONE_PRIVATE_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
|
||||||
endforeach()
|
endforeach ()
|
||||||
set(LINPHONE_PRIVATE_HEADER_FILES ${LINPHONE_PRIVATE_HEADER_FILES} PARENT_SCOPE)
|
set(LINPHONE_PRIVATE_HEADER_FILES ${LINPHONE_PRIVATE_HEADER_FILES} PARENT_SCOPE)
|
||||||
|
|
||||||
bc_apply_compile_flags(LINPHONE_CXX_OBJECTS_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
|
bc_apply_compile_flags(LINPHONE_CXX_OBJECTS_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
|
||||||
bc_apply_compile_flags(LINPHONE_OBJC_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX STRICT_OPTIONS_OBJC)
|
bc_apply_compile_flags(LINPHONE_OBJC_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX STRICT_OPTIONS_OBJC)
|
||||||
|
|
||||||
if(ENABLE_STATIC)
|
if (ENABLE_STATIC)
|
||||||
add_library(
|
add_library(
|
||||||
linphone-cxx-objects-static OBJECT
|
linphone-cxx-objects-static OBJECT
|
||||||
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
|
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
|
||||||
)
|
)
|
||||||
target_compile_definitions(linphone-cxx-objects-static PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS})
|
target_compile_definitions(linphone-cxx-objects-static PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS})
|
||||||
target_include_directories(linphone-cxx-objects-static SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS})
|
target_include_directories(linphone-cxx-objects-static SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS})
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
if(ENABLE_SHARED)
|
if (ENABLE_SHARED)
|
||||||
add_library(
|
add_library(
|
||||||
linphone-cxx-objects OBJECT
|
linphone-cxx-objects OBJECT
|
||||||
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
|
${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES}
|
||||||
|
|
@ -269,4 +269,4 @@ if(ENABLE_SHARED)
|
||||||
target_compile_definitions(linphone-cxx-objects PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS})
|
target_compile_definitions(linphone-cxx-objects PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS})
|
||||||
target_include_directories(linphone-cxx-objects SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS})
|
target_include_directories(linphone-cxx-objects SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS})
|
||||||
target_compile_options(linphone-cxx-objects PRIVATE "-fPIC")
|
target_compile_options(linphone-cxx-objects PRIVATE "-fPIC")
|
||||||
endif()
|
endif ()
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,13 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "address/address.h"
|
|
||||||
#include "chat/chat-room/basic-chat-room.h"
|
#include "chat/chat-room/basic-chat-room.h"
|
||||||
#include "core-p.h"
|
#include "core-p.h"
|
||||||
#include "db/main-db.h"
|
#include "db/main-db.h"
|
||||||
#include "linphone/core.h"
|
|
||||||
#include "object/object-p.h"
|
#include "object/object-p.h"
|
||||||
#include "paths/paths.h"
|
#include "paths/paths.h"
|
||||||
|
|
||||||
|
// TODO: Remove me later.
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,12 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "chat/chat-room/chat-room.h"
|
#include "object/object.h"
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
|
L_DECL_C_STRUCT(LinphoneCore);
|
||||||
|
|
||||||
LINPHONE_BEGIN_NAMESPACE
|
LINPHONE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class ChatRoom;
|
class ChatRoom;
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,41 @@
|
||||||
/*
|
/*
|
||||||
linphone
|
* android-platform-helpers.h
|
||||||
Copyright (C) 2017 Belledonne Communications SARL
|
* Copyright (C) 2010-2017 Belledonne Communications SARL
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "linphone/utils/utils.h"
|
|
||||||
|
|
||||||
#include "private.h"
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "platform-helpers.h"
|
||||||
|
#include "logger/logger.h"
|
||||||
|
|
||||||
|
// TODO: Remove me later.
|
||||||
|
#include "private.h"
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
LINPHONE_BEGIN_NAMESPACE
|
LINPHONE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class AndroidPlatformHelpers : public PlatformHelpers {
|
class AndroidPlatformHelpers : public PlatformHelpers {
|
||||||
public:
|
public:
|
||||||
AndroidPlatformHelpers (LinphoneCore *lc, void *system_context);
|
AndroidPlatformHelpers (LinphoneCore *lc, void *systemContext);
|
||||||
|
~AndroidPlatformHelpers ();
|
||||||
|
|
||||||
void setDnsServers () override;
|
void setDnsServers () override;
|
||||||
void acquireWifiLock () override;
|
void acquireWifiLock () override;
|
||||||
void releaseWifiLock () override;
|
void releaseWifiLock () override;
|
||||||
|
|
@ -37,9 +43,9 @@ public:
|
||||||
void releaseMcastLock () override;
|
void releaseMcastLock () override;
|
||||||
void acquireCpuLock () override;
|
void acquireCpuLock () override;
|
||||||
void releaseCpuLock () override;
|
void releaseCpuLock () override;
|
||||||
std::string getDataPath () override;
|
string getDataPath () override;
|
||||||
std::string getConfigPath () override;
|
string getConfigPath () override;
|
||||||
~AndroidPlatformHelpers ();
|
|
||||||
private:
|
private:
|
||||||
int callVoidMethod (jmethodID id);
|
int callVoidMethod (jmethodID id);
|
||||||
static jmethodID getMethodId (JNIEnv *env, jclass klass, const char *method, const char *signature);
|
static jmethodID getMethodId (JNIEnv *env, jclass klass, const char *method, const char *signature);
|
||||||
|
|
@ -54,40 +60,37 @@ private:
|
||||||
jmethodID mGetPowerManagerId;
|
jmethodID mGetPowerManagerId;
|
||||||
jmethodID mGetDataPathId;
|
jmethodID mGetDataPathId;
|
||||||
jmethodID mGetConfigPathId;
|
jmethodID mGetConfigPathId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* GetStringUTFChars (JNIEnv* env, jstring string) {
|
static const char *GetStringUTFChars (JNIEnv *env, jstring string) {
|
||||||
const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL;
|
const char *cstring = string ? env->GetStringUTFChars(string, nullptr) : nullptr;
|
||||||
return cstring;
|
return cstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReleaseStringUTFChars (JNIEnv* env, jstring string, const char *cstring) {
|
static void ReleaseStringUTFChars (JNIEnv *env, jstring string, const char *cstring) {
|
||||||
if (string) env->ReleaseStringUTFChars(string, cstring);
|
if (string) env->ReleaseStringUTFChars(string, cstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID AndroidPlatformHelpers::getMethodId (JNIEnv *env, jclass klass, const char *method, const char *signature) {
|
jmethodID AndroidPlatformHelpers::getMethodId (JNIEnv *env, jclass klass, const char *method, const char *signature) {
|
||||||
jmethodID id = env->GetMethodID(klass, method, signature);
|
jmethodID id = env->GetMethodID(klass, method, signature);
|
||||||
if (id == 0) {
|
if (id == 0)
|
||||||
ms_fatal("Could not find java method '%s %s'", method, signature);
|
lFatal() << "Could not find java method: `" << method << ", " << signature << "`.";
|
||||||
}
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidPlatformHelpers::AndroidPlatformHelpers (LinphoneCore *lc, void *system_context) : PlatformHelpers(lc) {
|
AndroidPlatformHelpers::AndroidPlatformHelpers (LinphoneCore *lc, void *systemContext) : PlatformHelpers(lc) {
|
||||||
JNIEnv *env=ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
jclass klass = env->FindClass("org/linphone/core/tools/AndroidPlatformHelper");
|
jclass klass = env->FindClass("org/linphone/core/tools/AndroidPlatformHelper");
|
||||||
if (!klass) {
|
if (!klass)
|
||||||
ms_fatal("Could not find java AndroidPlatformHelper class");
|
lFatal() << "Could not find java AndroidPlatformHelper class.";
|
||||||
return;
|
|
||||||
}
|
jmethodID ctor = env->GetMethodID(klass, "<init>", "(Ljava/lang/Object;)V");
|
||||||
jmethodID ctor = env->GetMethodID(klass,"<init>", "(Ljava/lang/Object;)V");
|
mJavaHelper = env->NewObject(klass, ctor, (jobject)systemContext);
|
||||||
mJavaHelper = env->NewObject(klass, ctor, (jobject)system_context);
|
|
||||||
if (!mJavaHelper) {
|
if (!mJavaHelper) {
|
||||||
ms_error("Could not instanciate AndroidPlatformHelper object.");
|
lError() << "Could not instanciate AndroidPlatformHelper object.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mJavaHelper = (jobject) env->NewGlobalRef(mJavaHelper);
|
mJavaHelper = (jobject)env->NewGlobalRef(mJavaHelper);
|
||||||
|
|
||||||
mWifiLockAcquireId = getMethodId(env, klass, "acquireWifiLock", "()V");
|
mWifiLockAcquireId = getMethodId(env, klass, "acquireWifiLock", "()V");
|
||||||
mWifiLockReleaseId = getMethodId(env, klass, "releaseWifiLock", "()V");
|
mWifiLockReleaseId = getMethodId(env, klass, "releaseWifiLock", "()V");
|
||||||
|
|
@ -100,10 +103,10 @@ AndroidPlatformHelpers::AndroidPlatformHelpers (LinphoneCore *lc, void *system_c
|
||||||
mGetDataPathId = getMethodId(env, klass, "getDataPath", "()Ljava/lang/String;");
|
mGetDataPathId = getMethodId(env, klass, "getDataPath", "()Ljava/lang/String;");
|
||||||
mGetConfigPathId = getMethodId(env, klass, "getConfigPath", "()Ljava/lang/String;");
|
mGetConfigPathId = getMethodId(env, klass, "getConfigPath", "()Ljava/lang/String;");
|
||||||
|
|
||||||
jobject pm = env->CallObjectMethod(mJavaHelper,mGetPowerManagerId);
|
jobject pm = env->CallObjectMethod(mJavaHelper, mGetPowerManagerId);
|
||||||
belle_sip_wake_lock_init(env, pm);
|
belle_sip_wake_lock_init(env, pm);
|
||||||
|
|
||||||
ms_message("AndroidPlatformHelpers is fully initialised");
|
lInfo() << "AndroidPlatformHelpers is fully initialised.";
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidPlatformHelpers::~AndroidPlatformHelpers () {
|
AndroidPlatformHelpers::~AndroidPlatformHelpers () {
|
||||||
|
|
@ -111,28 +114,27 @@ AndroidPlatformHelpers::~AndroidPlatformHelpers () {
|
||||||
JNIEnv *env = ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
belle_sip_wake_lock_uninit(env);
|
belle_sip_wake_lock_uninit(env);
|
||||||
env->DeleteGlobalRef(mJavaHelper);
|
env->DeleteGlobalRef(mJavaHelper);
|
||||||
mJavaHelper = NULL;
|
mJavaHelper = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AndroidPlatformHelpers::setDnsServers () {
|
void AndroidPlatformHelpers::setDnsServers () {
|
||||||
if (!mJavaHelper) return;
|
if (!mJavaHelper) return;
|
||||||
JNIEnv *env=ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
if (env && mJavaHelper) {
|
if (env && mJavaHelper) {
|
||||||
jobjectArray jservers = (jobjectArray)env->CallObjectMethod(mJavaHelper,mGetDnsServersId);
|
jobjectArray jservers = (jobjectArray)env->CallObjectMethod(mJavaHelper, mGetDnsServersId);
|
||||||
bctbx_list_t *l = NULL;
|
bctbx_list_t *l = nullptr;
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
ms_error("AndroidPlatformHelpers::setDnsServers() exception");
|
lError() << "AndroidPlatformHelpers::setDnsServers() exception.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (jservers != NULL) {
|
if (jservers != nullptr) {
|
||||||
int count = env->GetArrayLength(jservers);
|
int count = env->GetArrayLength(jservers);
|
||||||
|
|
||||||
for (int i=0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
jstring jserver = (jstring) env->GetObjectArrayElement(jservers, i);
|
jstring jserver = (jstring)env->GetObjectArrayElement(jservers, i);
|
||||||
const char *str = env->GetStringUTFChars(jserver, NULL);
|
const char *str = env->GetStringUTFChars(jserver, nullptr);
|
||||||
if (str) {
|
if (str) {
|
||||||
l = bctbx_list_append(l, ms_strdup(str));
|
l = bctbx_list_append(l, ms_strdup(str));
|
||||||
env->ReleaseStringUTFChars(jserver, str);
|
env->ReleaseStringUTFChars(jserver, str);
|
||||||
|
|
@ -168,28 +170,28 @@ void AndroidPlatformHelpers::releaseCpuLock () {
|
||||||
callVoidMethod(mCpuLockReleaseId);
|
callVoidMethod(mCpuLockReleaseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AndroidPlatformHelpers::getDataPath () {
|
string AndroidPlatformHelpers::getDataPath () {
|
||||||
JNIEnv *env = ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
jstring jdata_path = (jstring)env->CallObjectMethod(mJavaHelper,mGetDataPathId);
|
jstring jdata_path = (jstring)env->CallObjectMethod(mJavaHelper, mGetDataPathId);
|
||||||
const char *data_path = GetStringUTFChars(env, jdata_path);
|
const char *data_path = GetStringUTFChars(env, jdata_path);
|
||||||
std::string dataPath = data_path;
|
string dataPath = data_path;
|
||||||
ReleaseStringUTFChars(env, jdata_path, data_path);
|
ReleaseStringUTFChars(env, jdata_path, data_path);
|
||||||
return dataPath;
|
return dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AndroidPlatformHelpers::getConfigPath () {
|
string AndroidPlatformHelpers::getConfigPath () {
|
||||||
JNIEnv *env = ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
jstring jconfig_path = (jstring)env->CallObjectMethod(mJavaHelper,mGetConfigPathId);
|
jstring jconfig_path = (jstring)env->CallObjectMethod(mJavaHelper, mGetConfigPathId);
|
||||||
const char *config_path = GetStringUTFChars(env, jconfig_path);
|
const char *config_path = GetStringUTFChars(env, jconfig_path);
|
||||||
std::string configPath = config_path;
|
string configPath = config_path;
|
||||||
ReleaseStringUTFChars(env, jconfig_path, config_path);
|
ReleaseStringUTFChars(env, jconfig_path, config_path);
|
||||||
return configPath;
|
return configPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AndroidPlatformHelpers::callVoidMethod (jmethodID id) {
|
int AndroidPlatformHelpers::callVoidMethod (jmethodID id) {
|
||||||
JNIEnv *env=ms_get_jni_env();
|
JNIEnv *env = ms_get_jni_env();
|
||||||
if (env && mJavaHelper) {
|
if (env && mJavaHelper) {
|
||||||
env->CallVoidMethod(mJavaHelper,id);
|
env->CallVoidMethod(mJavaHelper, id);
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -199,10 +201,8 @@ int AndroidPlatformHelpers::callVoidMethod (jmethodID id) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *system_context) {
|
PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *systemContext) {
|
||||||
return new AndroidPlatformHelpers(lc, system_context);
|
return new AndroidPlatformHelpers(lc, systemContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
LINPHONE_END_NAMESPACE
|
LINPHONE_END_NAMESPACE
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,53 +1,50 @@
|
||||||
/*
|
/*
|
||||||
linphone
|
* platform-helpers.cpp
|
||||||
Copyright (C) 2017 Belledonne Communications SARL
|
* Copyright (C) 2010-2017 Belledonne Communications SARL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
#include "platform-helpers.h"
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
// =============================================================================
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "linphone/utils/utils.h"
|
|
||||||
|
|
||||||
#include "private.h"
|
|
||||||
|
|
||||||
LINPHONE_BEGIN_NAMESPACE
|
LINPHONE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
PlatformHelpers::~PlatformHelpers () {}
|
|
||||||
|
|
||||||
StubbedPlatformHelpers::StubbedPlatformHelpers (LinphoneCore *lc) : PlatformHelpers(lc) {}
|
StubbedPlatformHelpers::StubbedPlatformHelpers (LinphoneCore *lc) : PlatformHelpers(lc) {}
|
||||||
|
|
||||||
void StubbedPlatformHelpers::setDnsServers () {
|
void StubbedPlatformHelpers::setDnsServers () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::acquireWifiLock () {
|
void StubbedPlatformHelpers::acquireWifiLock () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::releaseWifiLock () {
|
void StubbedPlatformHelpers::releaseWifiLock () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::acquireMcastLock () {
|
void StubbedPlatformHelpers::acquireMcastLock () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::releaseMcastLock () {
|
void StubbedPlatformHelpers::releaseMcastLock () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::acquireCpuLock () {
|
void StubbedPlatformHelpers::acquireCpuLock () {}
|
||||||
}
|
|
||||||
void StubbedPlatformHelpers::releaseCpuLock () {
|
void StubbedPlatformHelpers::releaseCpuLock () {}
|
||||||
}
|
|
||||||
std::string StubbedPlatformHelpers::getDataPath () {
|
std::string StubbedPlatformHelpers::getDataPath () {
|
||||||
return Utils::getEmptyConstRefObject<std::string>();
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StubbedPlatformHelpers::getConfigPath () {
|
std::string StubbedPlatformHelpers::getConfigPath () {
|
||||||
return Utils::getEmptyConstRefObject<std::string>();
|
return "";
|
||||||
}
|
|
||||||
StubbedPlatformHelpers::~StubbedPlatformHelpers () {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LINPHONE_END_NAMESPACE
|
LINPHONE_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,44 @@
|
||||||
/*
|
/*
|
||||||
linphone
|
* platform-helpers.h
|
||||||
Copyright (C) 2017 Belledonne Communications SARL
|
* Copyright (C) 2010-2017 Belledonne Communications SARL
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM_HELPERS_H_
|
#ifndef _PLATFORM_HELPERS_H_
|
||||||
#define _PLATFORM_HELPERS_H_
|
#define _PLATFORM_HELPERS_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "linphone/core.h"
|
|
||||||
#include "linphone/utils/general.h"
|
#include "linphone/utils/general.h"
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
L_DECL_C_STRUCT(LinphoneCore);
|
||||||
|
|
||||||
LINPHONE_BEGIN_NAMESPACE
|
LINPHONE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface aims at abstracting some features offered by the platform, most often mobile platforms.
|
* This interface aims at abstracting some features offered by the platform, most often mobile platforms.
|
||||||
* A per platform implementation is to be made to implement these features, if available on the platform
|
* A per platform implementation is to be made to implement these features, if available on the platform.
|
||||||
*/
|
*/
|
||||||
class PlatformHelpers {
|
class PlatformHelpers {
|
||||||
public:
|
public:
|
||||||
//This method shall retrieve DNS server list from the platform and assign it to the core.
|
virtual ~PlatformHelpers () = default;
|
||||||
|
|
||||||
|
// This method shall retrieve DNS server list from the platform and assign it to the core.
|
||||||
virtual void setDnsServers () = 0;
|
virtual void setDnsServers () = 0;
|
||||||
virtual void acquireWifiLock () = 0;
|
virtual void acquireWifiLock () = 0;
|
||||||
virtual void releaseWifiLock () = 0;
|
virtual void releaseWifiLock () = 0;
|
||||||
|
|
@ -43,16 +48,18 @@ public:
|
||||||
virtual void releaseCpuLock () = 0;
|
virtual void releaseCpuLock () = 0;
|
||||||
virtual std::string getDataPath () = 0;
|
virtual std::string getDataPath () = 0;
|
||||||
virtual std::string getConfigPath () = 0;
|
virtual std::string getConfigPath () = 0;
|
||||||
virtual ~PlatformHelpers ();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline PlatformHelpers (LinphoneCore *lc) : mCore(lc) {}
|
inline PlatformHelpers (LinphoneCore *lc) : mCore(lc) {}
|
||||||
|
|
||||||
LinphoneCore *mCore;
|
LinphoneCore *mCore;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StubbedPlatformHelpers : public PlatformHelpers {
|
class StubbedPlatformHelpers : public PlatformHelpers {
|
||||||
public:
|
public:
|
||||||
StubbedPlatformHelpers (LinphoneCore *lc);
|
StubbedPlatformHelpers (LinphoneCore *lc);
|
||||||
|
virtual ~StubbedPlatformHelpers () = default;
|
||||||
|
|
||||||
void setDnsServers () override;
|
void setDnsServers () override;
|
||||||
void acquireWifiLock () override;
|
void acquireWifiLock () override;
|
||||||
void releaseWifiLock () override;
|
void releaseWifiLock () override;
|
||||||
|
|
@ -62,10 +69,9 @@ public:
|
||||||
void releaseCpuLock () override;
|
void releaseCpuLock () override;
|
||||||
std::string getDataPath () override;
|
std::string getDataPath () override;
|
||||||
std::string getConfigPath () override;
|
std::string getConfigPath () override;
|
||||||
virtual ~StubbedPlatformHelpers ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *system_context);
|
PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *systemContext);
|
||||||
|
|
||||||
LINPHONE_END_NAMESPACE
|
LINPHONE_END_NAMESPACE
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue