Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
ddf3fe65
Commit
ddf3fe65
authored
Oct 19, 2017
by
Benjamin REIS
Browse files
fix build & coding style
parent
9d7d6083
Changes
5
Hide whitespace changes
Inline
Side-by-side
coreapi/android-helpers.cpp
View file @
ddf3fe65
...
...
@@ -28,22 +28,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
LINPHONE_BEGIN_NAMESPACE
class
AndroidPlatformHelpers
:
public
PlatformHelpers
{
class
AndroidPlatformHelpers
:
public
PlatformHelpers
{
public:
AndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
);
virtual
void
setDnsServers
();
virtual
void
acquireWifiLock
();
virtual
void
releaseWifiLock
();
virtual
void
acquireMcastLock
();
virtual
void
releaseMcastLock
();
virtual
void
acquireCpuLock
();
virtual
void
releaseCpuLock
();
virtual
std
::
string
getDataPath
();
virtual
std
::
string
getConfigPath
();
~
AndroidPlatformHelpers
();
AndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
);
virtual
void
setDnsServers
();
virtual
void
acquireWifiLock
();
virtual
void
releaseWifiLock
();
virtual
void
acquireMcastLock
();
virtual
void
releaseMcastLock
();
virtual
void
acquireCpuLock
();
virtual
void
releaseCpuLock
();
virtual
std
::
string
getDataPath
();
virtual
std
::
string
getConfigPath
();
~
AndroidPlatformHelpers
();
private:
int
callVoidMethod
(
jmethodID
id
);
static
jmethodID
getMethodId
(
JNIEnv
*
env
,
jclass
klass
,
const
char
*
method
,
const
char
*
signature
);
int
callVoidMethod
(
jmethodID
id
);
static
jmethodID
getMethodId
(
JNIEnv
*
env
,
jclass
klass
,
const
char
*
method
,
const
char
*
signature
);
jobject
mJavaHelper
;
jmethodID
mWifiLockAcquireId
;
jmethodID
mWifiLockReleaseId
;
...
...
@@ -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
;
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
);
}
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
);
if
(
id
==
0
){
if
(
id
==
0
)
{
ms_fatal
(
"Could not find java method '%s %s'"
,
method
,
signature
);
}
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
();
jclass
klass
=
env
->
FindClass
(
"org/linphone/core/tools/AndroidPlatformHelper"
);
if
(
!
klass
){
if
(
!
klass
)
{
ms_fatal
(
"Could not find java AndroidPlatformHelper class"
);
return
;
}
jmethodID
ctor
=
env
->
GetMethodID
(
klass
,
"<init>"
,
"(Ljava/lang/Object;)V"
);
mJavaHelper
=
env
->
NewObject
(
klass
,
ctor
,
(
jobject
)
system_context
);
if
(
!
mJavaHelper
){
if
(
!
mJavaHelper
)
{
ms_error
(
"Could not instanciate AndroidPlatformHelper object."
);
return
;
}
...
...
@@ -107,8 +107,8 @@ AndroidPlatformHelpers::AndroidPlatformHelpers(LinphoneCore *lc, void *system_co
ms_message
(
"AndroidPlatformHelpers is fully initialised"
);
}
AndroidPlatformHelpers
::~
AndroidPlatformHelpers
(){
if
(
mJavaHelper
){
AndroidPlatformHelpers
::~
AndroidPlatformHelpers
()
{
if
(
mJavaHelper
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
belle_sip_wake_lock_uninit
(
env
);
env
->
DeleteGlobalRef
(
mJavaHelper
);
...
...
@@ -117,7 +117,7 @@ AndroidPlatformHelpers::~AndroidPlatformHelpers(){
}
void
AndroidPlatformHelpers
::
setDnsServers
(){
void
AndroidPlatformHelpers
::
setDnsServers
()
{
if
(
!
mJavaHelper
)
return
;
JNIEnv
*
env
=
ms_get_jni_env
();
if
(
env
&&
mJavaHelper
)
{
...
...
@@ -128,13 +128,13 @@ void AndroidPlatformHelpers::setDnsServers(){
ms_error
(
"AndroidPlatformHelpers::setDnsServers() exception"
);
return
;
}
if
(
jservers
!=
NULL
){
if
(
jservers
!=
NULL
)
{
int
count
=
env
->
GetArrayLength
(
jservers
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
jstring
jserver
=
(
jstring
)
env
->
GetObjectArrayElement
(
jservers
,
i
);
const
char
*
str
=
env
->
GetStringUTFChars
(
jserver
,
NULL
);
if
(
str
){
if
(
str
)
{
l
=
bctbx_list_append
(
l
,
ms_strdup
(
str
));
env
->
ReleaseStringUTFChars
(
jserver
,
str
);
}
...
...
@@ -145,31 +145,31 @@ void AndroidPlatformHelpers::setDnsServers(){
}
}
void
AndroidPlatformHelpers
::
acquireWifiLock
(){
void
AndroidPlatformHelpers
::
acquireWifiLock
()
{
callVoidMethod
(
mWifiLockAcquireId
);
}
void
AndroidPlatformHelpers
::
releaseWifiLock
(){
void
AndroidPlatformHelpers
::
releaseWifiLock
()
{
callVoidMethod
(
mWifiLockReleaseId
);
}
void
AndroidPlatformHelpers
::
acquireMcastLock
(){
void
AndroidPlatformHelpers
::
acquireMcastLock
()
{
callVoidMethod
(
mMcastLockAcquireId
);
}
void
AndroidPlatformHelpers
::
releaseMcastLock
(){
void
AndroidPlatformHelpers
::
releaseMcastLock
()
{
callVoidMethod
(
mMcastLockReleaseId
);
}
void
AndroidPlatformHelpers
::
acquireCpuLock
(){
void
AndroidPlatformHelpers
::
acquireCpuLock
()
{
callVoidMethod
(
mCpuLockAcquireId
);
}
void
AndroidPlatformHelpers
::
releaseCpuLock
(){
void
AndroidPlatformHelpers
::
releaseCpuLock
()
{
callVoidMethod
(
mCpuLockReleaseId
);
}
std
::
string
AndroidPlatformHelpers
::
getDataPath
(){
std
::
string
AndroidPlatformHelpers
::
getDataPath
()
{
JNIEnv
*
env
=
ms_get_jni_env
();
jstring
jdata_path
=
(
jstring
)
env
->
CallObjectMethod
(
mJavaHelper
,
mGetDataPathId
);
const
char
*
data_path
=
GetStringUTFChars
(
env
,
jdata_path
);
...
...
@@ -178,7 +178,7 @@ std::string AndroidPlatformHelpers::getDataPath(){
return
dataPath
;
}
std
::
string
AndroidPlatformHelpers
::
getConfigPath
(){
std
::
string
AndroidPlatformHelpers
::
getConfigPath
()
{
JNIEnv
*
env
=
ms_get_jni_env
();
jstring
jconfig_path
=
(
jstring
)
env
->
CallObjectMethod
(
mJavaHelper
,
mGetConfigPathId
);
const
char
*
config_path
=
GetStringUTFChars
(
env
,
jconfig_path
);
...
...
@@ -187,7 +187,7 @@ std::string AndroidPlatformHelpers::getConfigPath(){
return
configPath
;
}
int
AndroidPlatformHelpers
::
callVoidMethod
(
jmethodID
id
)
{
int
AndroidPlatformHelpers
::
callVoidMethod
(
jmethodID
id
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
if
(
env
&&
mJavaHelper
)
{
env
->
CallVoidMethod
(
mJavaHelper
,
id
);
...
...
@@ -200,7 +200,7 @@ int AndroidPlatformHelpers::callVoidMethod(jmethodID id) {
return
-
1
;
}
PlatformHelpers
*
createAndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
){
PlatformHelpers
*
createAndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
)
{
return
new
AndroidPlatformHelpers
(
lc
,
system_context
);
}
...
...
coreapi/platform-helpers.cpp
View file @
ddf3fe65
...
...
@@ -23,33 +23,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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
>
();
}
std
::
string
StubbedPlatformHelpers
::
getConfigPath
(){
std
::
string
StubbedPlatformHelpers
::
getConfigPath
()
{
return
Utils
::
getEmptyConstRefObject
<
std
::
string
>
();
}
StubbedPlatformHelpers
::~
StubbedPlatformHelpers
(){
StubbedPlatformHelpers
::~
StubbedPlatformHelpers
()
{
}
LINPHONE_END_NAMESPACE
coreapi/platform-helpers.h
View file @
ddf3fe65
...
...
@@ -20,49 +20,50 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef 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.
* A per platform implementation is to be made to implement these features, if available on the platform
*/
class
PlatformHelpers
{
public:
//This method shall retrieve DNS server list from the platform and assign it to the core.
virtual
void
setDnsServers
()
=
0
;
virtual
void
acquireWifiLock
()
=
0
;
virtual
void
releaseWifiLock
()
=
0
;
virtual
void
acquireMcastLock
()
=
0
;
virtual
void
releaseMcastLock
()
=
0
;
virtual
void
acquireCpuLock
()
=
0
;
virtual
void
releaseCpuLock
()
=
0
;
virtual
std
::
string
getDataPath
()
=
0
;
virtual
std
::
string
getConfigPath
()
=
0
;
virtual
~
PlatformHelpers
();
protected:
PlatformHelpers
(
LinphoneCore
*
lc
)
:
mCore
(
lc
){
}
LinphoneCore
*
mCore
;
class
PlatformHelpers
{
public:
//This method shall retrieve DNS server list from the platform and assign it to the core.
virtual
void
setDnsServers
()
=
0
;
virtual
void
acquireWifiLock
()
=
0
;
virtual
void
releaseWifiLock
()
=
0
;
virtual
void
acquireMcastLock
()
=
0
;
virtual
void
releaseMcastLock
()
=
0
;
virtual
void
acquireCpuLock
()
=
0
;
virtual
void
releaseCpuLock
()
=
0
;
virtual
std
::
string
getDataPath
()
=
0
;
virtual
std
::
string
getConfigPath
()
=
0
;
virtual
~
PlatformHelpers
();
protected:
inline
PlatformHelpers
(
LinphoneCore
*
lc
)
:
mCore
(
lc
)
{
}
LinphoneCore
*
mCore
;
};
class
StubbedPlatformHelpers
:
public
PlatformHelpers
{
class
StubbedPlatformHelpers
:
public
PlatformHelpers
{
public:
StubbedPlatformHelpers
(
LinphoneCore
*
lc
);
void
setDnsServers
()
override
;
void
acquireWifiLock
()
override
;
void
releaseWifiLock
()
override
;
void
acquireMcastLock
()
override
;
void
releaseMcastLock
()
override
;
void
acquireCpuLock
()
override
;
void
releaseCpuLock
()
override
;
std
::
string
getDataPath
()
override
;
std
::
string
getConfigPath
()
override
;
virtual
~
StubbedPlatformHelpers
();
StubbedPlatformHelpers
(
LinphoneCore
*
lc
);
void
setDnsServers
()
override
;
void
acquireWifiLock
()
override
;
void
releaseWifiLock
()
override
;
void
acquireMcastLock
()
override
;
void
releaseMcastLock
()
override
;
void
acquireCpuLock
()
override
;
void
releaseCpuLock
()
override
;
std
::
string
getDataPath
()
override
;
std
::
string
getConfigPath
()
override
;
virtual
~
StubbedPlatformHelpers
();
};
PlatformHelpers
*
createAndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
);
PlatformHelpers
*
createAndroidPlatformHelpers
(
LinphoneCore
*
lc
,
void
*
system_context
);
}
//end of namespace
LINPHONE_END_NAMESPACE
#endif
src/CMakeLists.txt
View file @
ddf3fe65
...
...
@@ -212,19 +212,16 @@ set(LINPHONE_OBJC_SOURCE_FILES)
if
(
APPLE
)
list
(
APPEND LINPHONE_OBJC_SOURCE_FILES utils/paths/paths-apple.mm
)
list
(
APPEND LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/paths/paths-apple.h
)
endif
()
if
(
ANDROID
)
else
if
(
ANDROID
)
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
)
endif
()
if
(
WIN32
)
else
if
(
WIN32
)
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
)
endif
()
if
(
UNIX
AND NOT APPLE
)
else
if
(
UNIX
)
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
)
endif
()
...
...
src/utils/paths/paths.cpp
View file @
ddf3fe65
...
...
@@ -30,6 +30,7 @@
#else
#error "Unsupported system"
#endif
// =============================================================================
using
namespace
std
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment