Add network reachable callback in JNI

This commit is contained in:
Erwan Croze 2017-02-28 16:23:53 +01:00
parent b18702cf9e
commit 583b0ed767
7 changed files with 54 additions and 2 deletions

View file

@ -361,4 +361,9 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
}
@Override
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
}
}

View file

@ -272,4 +272,9 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
}
@Override
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
}
}

View file

@ -278,4 +278,9 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
}
@Override
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
}
}

View file

@ -308,4 +308,9 @@ public class TutorialRegistration implements LinphoneCoreListener {
}
@Override
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
}
}

View file

@ -318,6 +318,8 @@ public:
notifyRecvId = env->GetMethodID(listenerClass,"notifyReceived", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Ljava/lang/String;Lorg/linphone/core/LinphoneContent;)V");
networkReachableId = env->GetMethodID(listenerClass,"networkReachableChanged", "(Lorg/linphone/core/LinphoneCore;Z)V");
configuringStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RemoteProvisioningState"));
configuringStateFromIntId = env->GetStaticMethodID(configuringStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RemoteProvisioningState;");
configuringStateId = env->GetMethodID(listenerClass,"configuringStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$RemoteProvisioningState;Ljava/lang/String;)V");
@ -445,6 +447,7 @@ public:
jmethodID authenticationRequestedId;
jmethodID publishStateId;
jmethodID notifyRecvId;
jmethodID networkReachableId;
jclass authMethodClass;
jmethodID authMethodFromIntId;
@ -874,6 +877,10 @@ public:
vTable->notify_received = notifyReceived;
}
if (ljb->networkReachableId) {
vTable->network_reachable = networkReachableCb;
}
if (ljb->configuringStateId) {
vTable->configuring_status = configuringStatus;
}
@ -1397,6 +1404,21 @@ public:
handle_possible_java_exception(env, lcData->listener);
}
static void networkReachableCb(LinphoneCore *lc, bool_t enable){
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
if (result != 0) {
ms_error("cannot attach VM");
return;
}
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc);
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table);
env->CallVoidMethod(lcData->listener, ljb->networkReachableId, lcData->core, (jboolean)enable);
handle_possible_java_exception(env, lcData->listener);
}
static void configuringStatus(LinphoneCore *lc, LinphoneConfiguringState status, const char *message) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
@ -7877,8 +7899,6 @@ extern "C" jboolean Java_org_linphone_core_LinphoneConferenceParamsImpl_isVideoR
return linphone_conference_params_video_requested((LinphoneConferenceParams *)paramsPtr);
}
extern "C" jobjectArray Java_org_linphone_core_LinphoneConferenceImpl_getParticipants(JNIEnv *env, jobject thiz, jlong pconference) {
bctbx_list_t *participants, *it;
jclass addr_class = env->FindClass("org/linphone/core/LinphoneAddressImpl");

View file

@ -269,5 +269,12 @@ public interface LinphoneCoreListener {
* @param list LinphoneFriendList object
*/
void friendListRemoved(LinphoneCore lc, LinphoneFriendList list);
/**
* Callback prototype for reporting network is reachable
* @param lc LinphoneCore object
* @param enable status of network
*/
void networkReachableChanged(LinphoneCore lc, boolean enable);
}

View file

@ -220,4 +220,9 @@ public class LinphoneCoreListenerBase implements LinphoneCoreListener {
// TODO Auto-generated method stub
}
@Override
public void networkReachableChanged(LinphoneCore lc, boolean enable) {
// TODO Auto-generated method stub
}
}