wrap new publishStateChanged callback to Java

This commit is contained in:
Simon Morlat 2013-09-17 19:26:14 +02:00
parent fed415507f
commit 90dd9fe885
6 changed files with 68 additions and 0 deletions

View file

@ -38,6 +38,7 @@ import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneFriend.SubscribePolicy;
import org.linphone.core.PublishState;
import org.linphone.core.SubscriptionState;
/**
@ -272,5 +273,12 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
}
@Override
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
PublishState state) {
// TODO Auto-generated method stub
}
}

View file

@ -36,6 +36,7 @@ import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneInfoMessage;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PublishState;
import org.linphone.core.SubscriptionState;
@ -194,5 +195,12 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
}
@Override
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
PublishState state) {
// TODO Auto-generated method stub
}
}

View file

@ -36,6 +36,7 @@ import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.PublishState;
import org.linphone.core.SubscriptionState;
@ -198,5 +199,12 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
}
@Override
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
PublishState state) {
// TODO Auto-generated method stub
}
}

View file

@ -36,6 +36,7 @@ import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.PublishState;
import org.linphone.core.SubscriptionState;
@ -229,6 +230,13 @@ public class TutorialRegistration implements LinphoneCoreListener {
}
@Override
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
PublishState state) {
// TODO Auto-generated method stub
}
}

View file

@ -175,6 +175,7 @@ public:
vTable.info_received = infoReceived;
vTable.subscription_state_changed=subscriptionStateChanged;
vTable.notify_received=notifyReceived;
vTable.publish_state_changed=publishStateChanged;
listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
@ -227,6 +228,8 @@ public:
subscriptionStateId = env->GetMethodID(listenerClass,"subscriptionStateChanged",
"(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/SubscriptionState;)V");
publishStateId = env->GetMethodID(listenerClass,"publishStateChanged",
"(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/PublishState;)V");
notifyRecvId = env->GetMethodID(listenerClass,"notifyReceived",
"(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Ljava/lang/String;Lorg/linphone/core/LinphoneContent;)V");
@ -263,6 +266,9 @@ public:
subscriptionStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/SubscriptionState"));
subscriptionStateFromIntId = env->GetStaticMethodID(subscriptionStateClass,"fromInt","(I)Lorg/linphone/core/SubscriptionState;");
publishStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/PublishState"));
publishStateFromIntId = env->GetStaticMethodID(subscriptionStateClass,"fromInt","(I)Lorg/linphone/core/PublishState;");
subscriptionDirClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/SubscriptionDir"));
subscriptionDirFromIntId = env->GetStaticMethodID(subscriptionDirClass,"fromInt","(I)Lorg/linphone/core/SubscriptionDir;");
}
@ -303,6 +309,7 @@ public:
jmethodID transferStateId;
jmethodID infoReceivedId;
jmethodID subscriptionStateId;
jmethodID publishStateId;
jmethodID notifyRecvId;
jclass globalStateClass;
@ -358,6 +365,9 @@ public:
jclass subscriptionStateClass;
jmethodID subscriptionStateFromIntId;
jclass publishStateClass;
jmethodID publishStateFromIntId;
jclass subscriptionDirClass;
jmethodID subscriptionDirFromIntId;
@ -642,6 +652,25 @@ public:
env->DeleteGlobalRef(jevent);
}
}
static void publishStateChanged(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
jobject jevent;
jobject jstate;
if (result != 0) {
ms_error("cannot attach VM");
return;
}
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
jevent=lcData->getEvent(env,ev);
jstate=env->CallStaticObjectMethod(lcData->publishStateClass,lcData->publishStateFromIntId,(jint)state);
env->CallVoidMethod(lcData->listener
,lcData->publishStateId
,lcData->core
,jevent
,jstate
);
}
static void notifyReceived(LinphoneCore *lc, LinphoneEvent *ev, const char *evname, const LinphoneContent *content){
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);

View file

@ -148,6 +148,13 @@ public interface LinphoneCoreListener {
* @param content content of the NOTIFY request.
*/
void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content);
/**
* Notifies about outgoing generic publish states.
* @param lc the LinphoneCore
* @param ev a LinphoneEvent representing the publish, typically created by {@link LinphoneCore#publish}
* @param state the publish state
*/
void publishStateChanged(LinphoneCore lc, LinphoneEvent ev, PublishState state);
/**< @Deprecated Notifies the application that it should show up
* @return */