Commit ddf3fe65 authored by Benjamin REIS's avatar Benjamin REIS

fix build & coding style

parent 9d7d6083
...@@ -28,22 +28,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -28,22 +28,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 *system_context);
virtual void setDnsServers(); virtual void setDnsServers ();
virtual void acquireWifiLock(); virtual void acquireWifiLock ();
virtual void releaseWifiLock(); virtual void releaseWifiLock ();
virtual void acquireMcastLock(); virtual void acquireMcastLock ();
virtual void releaseMcastLock(); virtual void releaseMcastLock ();
virtual void acquireCpuLock(); virtual void acquireCpuLock ();
virtual void releaseCpuLock(); virtual void releaseCpuLock ();
virtual std::string getDataPath(); virtual std::string getDataPath ();
virtual std::string getConfigPath(); virtual std::string getConfigPath ();
~AndroidPlatformHelpers(); ~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);
jobject mJavaHelper; jobject mJavaHelper;
jmethodID mWifiLockAcquireId; jmethodID mWifiLockAcquireId;
jmethodID mWifiLockReleaseId; jmethodID mWifiLockReleaseId;
...@@ -58,33 +58,33 @@ private: ...@@ -58,33 +58,33 @@ private:
}; };
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, NULL) : NULL;
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); ms_fatal("Could not find java method '%s %s'", method, signature);
} }
return id; return id;
} }
AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_context) : PlatformHelpers(lc) { AndroidPlatformHelpers::AndroidPlatformHelpers (LinphoneCore *lc, void *system_context) : 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"); ms_fatal("Could not find java AndroidPlatformHelper class");
return; 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)system_context); mJavaHelper = env->NewObject(klass, ctor, (jobject)system_context);
if (!mJavaHelper){ if (!mJavaHelper) {
ms_error("Could not instanciate AndroidPlatformHelper object."); ms_error("Could not instanciate AndroidPlatformHelper object.");
return; return;
} }
...@@ -107,8 +107,8 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co ...@@ -107,8 +107,8 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co
ms_message("AndroidPlatformHelpers is fully initialised"); ms_message("AndroidPlatformHelpers is fully initialised");
} }
AndroidPlatformHelpers::~AndroidPlatformHelpers(){ AndroidPlatformHelpers::~AndroidPlatformHelpers () {
if (mJavaHelper){ if (mJavaHelper) {
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);
...@@ -117,7 +117,7 @@ AndroidPlatformHelpers::~AndroidPlatformHelpers(){ ...@@ -117,7 +117,7 @@ AndroidPlatformHelpers::~AndroidPlatformHelpers(){
} }
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) {
...@@ -128,13 +128,13 @@ void AndroidPlatformHelpers::setDnsServers(){ ...@@ -128,13 +128,13 @@ void AndroidPlatformHelpers::setDnsServers(){
ms_error("AndroidPlatformHelpers::setDnsServers() exception"); ms_error("AndroidPlatformHelpers::setDnsServers() exception");
return; return;
} }
if (jservers != NULL){ if (jservers != NULL) {
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, NULL);
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);
} }
...@@ -145,31 +145,31 @@ void AndroidPlatformHelpers::setDnsServers(){ ...@@ -145,31 +145,31 @@ void AndroidPlatformHelpers::setDnsServers(){
} }
} }
void AndroidPlatformHelpers::acquireWifiLock(){ void AndroidPlatformHelpers::acquireWifiLock () {
callVoidMethod(mWifiLockAcquireId); callVoidMethod(mWifiLockAcquireId);
} }
void AndroidPlatformHelpers::releaseWifiLock(){ void AndroidPlatformHelpers::releaseWifiLock () {
callVoidMethod(mWifiLockReleaseId); callVoidMethod(mWifiLockReleaseId);
} }
void AndroidPlatformHelpers::acquireMcastLock(){ void AndroidPlatformHelpers::acquireMcastLock () {
callVoidMethod(mMcastLockAcquireId); callVoidMethod(mMcastLockAcquireId);
} }
void AndroidPlatformHelpers::releaseMcastLock(){ void AndroidPlatformHelpers::releaseMcastLock () {
callVoidMethod(mMcastLockReleaseId); callVoidMethod(mMcastLockReleaseId);
} }
void AndroidPlatformHelpers::acquireCpuLock(){ void AndroidPlatformHelpers::acquireCpuLock () {
callVoidMethod(mCpuLockAcquireId); callVoidMethod(mCpuLockAcquireId);
} }
void AndroidPlatformHelpers::releaseCpuLock(){ void AndroidPlatformHelpers::releaseCpuLock () {
callVoidMethod(mCpuLockReleaseId); callVoidMethod(mCpuLockReleaseId);
} }
std::string AndroidPlatformHelpers::getDataPath(){ std::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);
...@@ -178,7 +178,7 @@ std::string AndroidPlatformHelpers::getDataPath(){ ...@@ -178,7 +178,7 @@ std::string AndroidPlatformHelpers::getDataPath(){
return dataPath; return dataPath;
} }
std::string AndroidPlatformHelpers::getConfigPath(){ std::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);
...@@ -187,7 +187,7 @@ std::string AndroidPlatformHelpers::getConfigPath(){ ...@@ -187,7 +187,7 @@ std::string AndroidPlatformHelpers::getConfigPath(){
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);
...@@ -200,7 +200,7 @@ int AndroidPlatformHelpers::callVoidMethod(jmethodID id) { ...@@ -200,7 +200,7 @@ int AndroidPlatformHelpers::callVoidMethod(jmethodID id) {
return -1; return -1;
} }
PlatformHelpers *createAndroidPlatformHelpers(LinphoneCore *lc, void *system_context){ PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *system_context) {
return new AndroidPlatformHelpers(lc, system_context); return new AndroidPlatformHelpers(lc, system_context);
} }
......
...@@ -23,33 +23,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -23,33 +23,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
PlatformHelpers::~PlatformHelpers(){ 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 Utils::getEmptyConstRefObject<std::string>();
} }
std::string StubbedPlatformHelpers::getConfigPath(){ std::string StubbedPlatformHelpers::getConfigPath () {
return Utils::getEmptyConstRefObject<std::string>(); return Utils::getEmptyConstRefObject<std::string>();
} }
StubbedPlatformHelpers::~StubbedPlatformHelpers(){ StubbedPlatformHelpers::~StubbedPlatformHelpers () {
} }
LINPHONE_END_NAMESPACE LINPHONE_END_NAMESPACE
...@@ -20,49 +20,50 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -20,49 +20,50 @@ 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 "linphone/utils/general.h"
namespace LinphonePrivate{ 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. //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;
virtual void acquireMcastLock() = 0; virtual void acquireMcastLock () = 0;
virtual void releaseMcastLock() = 0; virtual void releaseMcastLock () = 0;
virtual void acquireCpuLock() = 0; virtual void acquireCpuLock () = 0;
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(); virtual ~PlatformHelpers ();
protected:
PlatformHelpers(LinphoneCore *lc) : mCore(lc){ protected:
} 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);
void setDnsServers() override; void setDnsServers () override;
void acquireWifiLock() override; void acquireWifiLock () override;
void releaseWifiLock() override; void releaseWifiLock () override;
void acquireMcastLock() override; void acquireMcastLock () override;
void releaseMcastLock() override; void releaseMcastLock () override;
void acquireCpuLock() override; void acquireCpuLock () override;
void releaseCpuLock() override; void releaseCpuLock () override;
std::string getDataPath() override; std::string getDataPath () override;
std::string getConfigPath() override; std::string getConfigPath () override;
virtual ~StubbedPlatformHelpers(); virtual ~StubbedPlatformHelpers ();
}; };
PlatformHelpers *createAndroidPlatformHelpers(LinphoneCore *lc, void *system_context); PlatformHelpers *createAndroidPlatformHelpers (LinphoneCore *lc, void *system_context);
}//end of namespace LINPHONE_END_NAMESPACE
#endif #endif
...@@ -212,19 +212,16 @@ set(LINPHONE_OBJC_SOURCE_FILES) ...@@ -212,19 +212,16 @@ set(LINPHONE_OBJC_SOURCE_FILES)
if (APPLE) if (APPLE)
list(APPEND LINPHONE_OBJC_SOURCE_FILES utils/paths/paths-apple.mm) list(APPEND LINPHONE_OBJC_SOURCE_FILES utils/paths/paths-apple.mm)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-apple.h) list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-apple.h)
endif()
if (ANDROID) elseif(ANDROID)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-android.cpp) list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-android.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-android.h) list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-android.h)
endif()
if (WIN32) elseif(WIN32)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-windows.cpp) list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-windows.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-windows.h) list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-windows.h)
endif()
if (UNIX AND NOT APPLE) elseif(UNIX)
list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-linux.cpp) list(APPEND LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/paths/paths-linux.cpp)
list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-linux.h) list(APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-linux.h)
endif() endif()
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#else #else
#error "Unsupported system" #error "Unsupported system"
#endif #endif
// ============================================================================= // =============================================================================
using namespace std; using namespace std;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment