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
ef7677a8
Commit
ef7677a8
authored
Apr 13, 2015
by
Margaux Clerc
Browse files
Fix friend in JNI
parent
a2561ca8
Changes
4
Hide whitespace changes
Inline
Side-by-side
coreapi/linphonecore.c
View file @
ef7677a8
...
...
@@ -6333,7 +6333,7 @@ void ui_config_uninit(LinphoneCore* lc)
{
ms_message
(
"Destroying friends."
);
if
(
lc
->
friends
){
ms_list_for_each
(
lc
->
friends
,(
void
(
*
)(
void
*
))
linphone_friend_
destroy
);
ms_list_for_each
(
lc
->
friends
,(
void
(
*
)(
void
*
))
linphone_friend_
unref
);
ms_list_free
(
lc
->
friends
);
lc
->
friends
=
NULL
;
}
...
...
coreapi/linphonecore_jni.cc
View file @
ef7677a8
...
...
@@ -250,20 +250,21 @@ jobject getChatMessage(JNIEnv *env, LinphoneChatMessage *msg){
return
jobj
;
}
jobject
getFriend
(
JNIEnv
*
env
,
LinphoneFriend
*
lfriend
,
jobject
core
){
jobject
getFriend
(
JNIEnv
*
env
,
LinphoneFriend
*
lfriend
){
jobject
jobj
=
0
;
if
(
lfriend
!=
NULL
){
if
(
lfriend
!=
NULL
){
jclass
friendClass
=
(
jclass
)
env
->
FindClass
(
"org/linphone/core/LinphoneFriendImpl"
);
jmethodID
friendCtrId
=
env
->
GetMethodID
(
friendClass
,
"<init>"
,
"(J)V"
);
void
*
up
=
linphone_friend_get_user_data
(
lfriend
);
if
(
up
==
NULL
){
if
(
up
==
NULL
){
jobj
=
env
->
NewObject
(
friendClass
,
friendCtrId
,(
jlong
)
lfriend
);
linphone_friend_set_user_data
(
lfriend
,(
void
*
)
env
->
NewWeakGlobalRef
(
jobj
));
linphone_friend_ref
(
lfriend
);
}
else
{
jobj
=
env
->
NewLocalRef
((
jobject
)
up
);
if
(
jobj
==
NULL
){
jobj
=
env
->
NewObject
(
friendClass
,
friendCtrId
,(
jlong
)
lfriend
);
...
...
@@ -754,7 +755,7 @@ public:
env
->
CallVoidMethod
(
lcData
->
listener
,
lcData
->
notifyPresenceReceivedId
,
lcData
->
core
,
env
->
NewObject
(
lcData
->
friendClass
,
lcData
->
friendCtrId
,(
jlong
)
my_friend
));
,
getFriend
(
env
,
my_friend
));
if
(
env
->
ExceptionCheck
())
{
ms_error
(
"Listener %p raised an exception"
,
lcData
->
listener
);
env
->
ExceptionClear
();
...
...
@@ -772,7 +773,7 @@ public:
env
->
CallVoidMethod
(
lcData
->
listener
,
lcData
->
newSubscriptionRequestId
,
lcData
->
core
,
env
->
NewObject
(
lcData
->
friendClass
,
lcData
->
friendCtrId
,(
jlong
)
my_friend
)
,
getFriend
(
env
,
my_friend
)
,
url
?
env
->
NewStringUTF
(
url
)
:
NULL
);
if
(
env
->
ExceptionCheck
())
{
ms_error
(
"Listener %p raised an exception"
,
lcData
->
listener
);
...
...
@@ -1845,10 +1846,11 @@ extern "C" jobjectArray Java_org_linphone_core_LinphoneCoreImpl_getFriendList(JN
for
(
int
i
=
0
;
i
<
friendsSize
;
i
++
)
{
LinphoneFriend
*
lfriend
=
(
LinphoneFriend
*
)
friends
->
data
;
jobject
jfriend
=
getFriend
(
env
,
lfriend
,
thiz
);
jobject
jfriend
=
getFriend
(
env
,
lfriend
);
if
(
jfriend
!=
NULL
){
env
->
SetObjectArrayElement
(
jFriends
,
i
,
jfriend
);
}
friends
=
friends
->
next
;
}
env
->
DeleteGlobalRef
(
cls
);
...
...
@@ -2881,7 +2883,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNI
if
(
jFriendUri
)
{
const
char
*
friendUri
=
env
->
GetStringUTFChars
(
jFriendUri
,
NULL
);
lResult
=
linphone_friend_new_with_address
(
friendUri
);
lResult
=
linphone_friend_new_with_address
(
friendUri
);
linphone_friend_set_user_data
(
lResult
,
env
->
NewWeakGlobalRef
(
thiz
));
env
->
ReleaseStringUTFChars
(
jFriendUri
,
friendUri
);
}
else
{
...
...
@@ -2957,9 +2959,9 @@ extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getRefKey(JNIEnv*
extern
"C"
void
Java_org_linphone_core_LinphoneFriendImpl_finalize
(
JNIEnv
*
env
,
jobject
thiz
,
jlong
ptr
)
{
LinphoneFriend
*
friend
=
(
LinphoneFriend
*
)
ptr
;
linphone_friend_set_user_data
(
friend
,
NULL
);
linphone_friend_unref
(
friend
);
LinphoneFriend
*
l
friend
=
(
LinphoneFriend
*
)
ptr
;
linphone_friend_set_user_data
(
l
friend
,
NULL
);
linphone_friend_unref
(
l
friend
);
}
/*
...
...
@@ -2990,14 +2992,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* en
,
jlong
lf
)
{
linphone_core_remove_friend
((
LinphoneCore
*
)
ptr
,
(
LinphoneFriend
*
)
lf
);
}
extern
"C"
j
long
Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress
(
JNIEnv
*
env
extern
"C"
j
object
Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress
(
JNIEnv
*
env
,
jobject
thiz
,
jlong
ptr
,
jstring
jaddress
)
{
const
char
*
address
=
env
->
GetStringUTFChars
(
jaddress
,
NULL
);
LinphoneFriend
*
lf
=
linphone_core_get_friend_by_address
((
LinphoneCore
*
)
ptr
,
address
);
env
->
ReleaseStringUTFChars
(
jaddress
,
address
);
return
(
jlong
)
lf
;
if
(
lf
!=
NULL
)
{
jobject
jfriend
=
getFriend
(
env
,
lf
);
return
jfriend
;
}
else
{
return
NULL
;
}
}
extern
"C"
jlongArray
_LinphoneChatRoomImpl_getHistory
(
JNIEnv
*
env
...
...
java/impl/org/linphone/core/LinphoneCoreImpl.java
View file @
ef7677a8
...
...
@@ -960,14 +960,10 @@ class LinphoneCoreImpl implements LinphoneCore {
removeFriend
(
nativePtr
,
lf
.
getNativePtr
());
}
private
native
long
getFriendByAddress
(
long
ptr
,
String
sipUri
);
private
native
LinphoneFriend
getFriendByAddress
(
long
ptr
,
String
sipUri
);
@Override
public
synchronized
LinphoneFriend
findFriendByAddress
(
String
sipUri
)
{
long
ptr
=
getFriendByAddress
(
nativePtr
,
sipUri
);
if
(
ptr
==
0
)
{
return
null
;
}
return
new
LinphoneFriendImpl
(
ptr
);
return
getFriendByAddress
(
nativePtr
,
sipUri
);
}
public
synchronized
void
setAudioPort
(
int
port
)
{
...
...
java/impl/org/linphone/core/LinphoneFriendImpl.java
View file @
ef7677a8
...
...
@@ -46,12 +46,15 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
nativePtr
=
newLinphoneFriend
(
friendUri
);
}
/*reserved for JNI */
protected
LinphoneFriendImpl
(
long
aNativePtr
)
{
nativePtr
=
aNativePtr
;
}
protected
void
finalize
()
throws
Throwable
{
finalize
(
nativePtr
);
if
(
nativePtr
!=
0
)
{
finalize
(
nativePtr
);
}
super
.
finalize
();
}
public
void
setAddress
(
LinphoneAddress
anAddress
)
{
this
.
setAddress
(
nativePtr
,
((
LinphoneAddressImpl
)
anAddress
).
nativePtr
);
...
...
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