mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 21:58:08 +00:00
imlement java synchronization of LinphoneFriend with LinphoneCore
This commit is contained in:
parent
bc078d65d2
commit
87d4f5f895
4 changed files with 44 additions and 5 deletions
|
|
@ -656,3 +656,7 @@ void linphone_core_write_friends_config(LinphoneCore* lc)
|
|||
linphone_friend_write_to_config_file(lc->config,NULL,i); /* set the end */
|
||||
}
|
||||
|
||||
LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr){
|
||||
return fr->lc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2222,6 +2222,16 @@ extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
|
|||
,jlong ptr) {
|
||||
return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
|
||||
}
|
||||
extern "C" jobject Java_org_linphone_core_LinphoneFriendImpl_getCore(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
LinphoneCore *lc=linphone_friend_get_core((LinphoneFriend*)ptr);
|
||||
if (lc!=NULL){
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
|
||||
return lcData->core;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_LinphoneFriendImpl
|
||||
|
|
|
|||
|
|
@ -392,6 +392,11 @@ LINPHONE_PUBLIC LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc
|
|||
*/
|
||||
LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the LinphoneCore object managing this friend, if any.
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
|
|||
private native void setPresenceModel(long nativePtr, long presencePtr);
|
||||
private native void edit(long nativePtr);
|
||||
private native void done(long nativePtr);
|
||||
|
||||
private native void delete(long ptr);
|
||||
private native Object getCore(long ptr);
|
||||
|
||||
boolean ownPtr = false;
|
||||
protected LinphoneFriendImpl() {
|
||||
nativePtr = newLinphoneFriend(null);
|
||||
|
|
@ -57,13 +58,17 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
|
|||
return new LinphoneAddressImpl(getAddress(nativePtr),LinphoneAddressImpl.WrapMode.FromConst);
|
||||
}
|
||||
public void setIncSubscribePolicy(SubscribePolicy policy) {
|
||||
setIncSubscribePolicy(nativePtr,policy.mValue);
|
||||
synchronized(getSyncObject()){
|
||||
setIncSubscribePolicy(nativePtr,policy.mValue);
|
||||
}
|
||||
}
|
||||
public SubscribePolicy getIncSubscribePolicy() {
|
||||
return SubscribePolicy.fromInt(getIncSubscribePolicy(nativePtr)) ;
|
||||
}
|
||||
public void enableSubscribes(boolean enable) {
|
||||
enableSubscribes(nativePtr, enable);
|
||||
synchronized(getSyncObject()){
|
||||
enableSubscribes(nativePtr, enable);
|
||||
}
|
||||
}
|
||||
public boolean isSubscribesEnabled() {
|
||||
return isSubscribesEnabled(nativePtr);
|
||||
|
|
@ -75,12 +80,27 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
|
|||
return (PresenceModel)getPresenceModel(nativePtr);
|
||||
}
|
||||
public void edit() {
|
||||
edit(nativePtr);
|
||||
synchronized(getSyncObject()){
|
||||
edit(nativePtr);
|
||||
}
|
||||
}
|
||||
public void done() {
|
||||
done(nativePtr);
|
||||
synchronized(getSyncObject()){
|
||||
done(nativePtr);
|
||||
}
|
||||
}
|
||||
public long getNativePtr() {
|
||||
return nativePtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a java object to synchronize this friend with.
|
||||
* Indeed some operation must be synchronized with the LinphoneCore object.
|
||||
* If the friend is not associated with a LinphoneCore object, it returns itself in order to avoid writing code for case where no synchronization is necessary.
|
||||
*/
|
||||
private Object getSyncObject(){
|
||||
Object core=getCore(nativePtr);
|
||||
if (core!=null) return core;
|
||||
else return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue