Added ClearException in jni layer to prevent crash when listener doesn't implement all callbacks + reworked linphonecorelistener

This commit is contained in:
Sylvain Berfini 2014-12-01 12:36:24 +01:00
parent 6045f50dc5
commit de2e98bd96
8 changed files with 291 additions and 219 deletions

View file

@ -34,7 +34,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneFriend.SubscribePolicy;
@ -60,7 +60,7 @@ import org.linphone.core.SubscriptionState;
* @author Guillaume Beraudo
*
*/
public class TutorialBuddyStatus implements LinphoneCoreListener {
public class TutorialBuddyStatus implements LinphoneListener {
private boolean running;
private TutorialNotifier TutorialNotifier;

View file

@ -34,7 +34,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneInfoMessage;
@ -58,7 +58,7 @@ import org.linphone.core.SubscriptionState;
* @author Guillaume Beraudo
*
*/
public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessage.StateListener {
public class TutorialChatRoom implements LinphoneListener, LinphoneChatMessage.StateListener {
private boolean running;
private TutorialNotifier TutorialNotifier;

View file

@ -22,23 +22,23 @@ import java.nio.ByteBuffer;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallStats;
import org.linphone.core.LinphoneChatMessage;
import org.linphone.core.LinphoneChatRoom;
import org.linphone.core.LinphoneContent;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneInfoMessage;
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;
@ -52,7 +52,7 @@ import org.linphone.core.SubscriptionState;
* @author Guillaume Beraudo
*
*/
public class TutorialHelloWorld implements LinphoneCoreListener {
public class TutorialHelloWorld implements LinphoneListener {
private boolean running;
private TutorialNotifier TutorialNotifier;

View file

@ -34,7 +34,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneInfoMessage;
@ -57,7 +57,7 @@ import org.linphone.core.SubscriptionState;
* @author Guillaume Beraudo
*
*/
public class TutorialRegistration implements LinphoneCoreListener {
public class TutorialRegistration implements LinphoneListener {
private boolean running;
private TutorialNotifier TutorialNotifier;

View file

@ -264,151 +264,178 @@ public:
/*displayStatus(LinphoneCore lc,String message);*/
displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
env->ExceptionClear();
if (displayStatusId) {
vTable->display_status = displayStatusCb;
}
/*void generalState(LinphoneCore lc,int state); */
globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
env->ExceptionClear();
if (globalStateId) {
vTable->global_state_changed = globalStateChange;
}
/*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
env->ExceptionClear();
if (registrationStateId) {
vTable->registration_state_changed = registrationStateChange;
}
/*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
env->ExceptionClear();
if (callStateId) {
vTable->call_state_changed = callStateChange;
}
transferStateId = env->GetMethodID(listenerClass,"transferState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;)V");
env->ExceptionClear();
if (transferStateId) {
vTable->transfer_state_changed = transferStateChanged;
}
/*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
env->ExceptionClear();
if (callStatsUpdatedId) {
vTable->call_stats_updated = callStatsUpdated;
}
chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
/*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
callEncryptionChangedId = env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
env->ExceptionClear();
if (callEncryptionChangedId) {
vTable->call_encryption_changed = callEncryptionChange;
}
/*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
env->ExceptionClear();
/*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
env->ExceptionClear();
if (newSubscriptionRequestId) {
vTable->new_subscription_requested = new_subscription_requested;
}
authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
env->ExceptionClear();
if (authInfoRequestedId) {
vTable->auth_info_requested = authInfoRequested;
}
/*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
env->ExceptionClear();
if (notifyPresenceReceivedId) {
vTable->notify_presence_received = notify_presence_received;
}
/*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
env->ExceptionClear();
if (textReceivedId) {
vTable->text_received = text_received;
}
messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
env->ExceptionClear();
if (messageReceivedId) {
vTable->message_received = message_received;
}
isComposingReceivedId = env->GetMethodID(listenerClass,"isComposingReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;)V");
env->ExceptionClear();
if (isComposingReceivedId) {
vTable->is_composing_received = is_composing_received;
}
dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
env->ExceptionClear();
if (dtmfReceivedId) {
vTable->dtmf_received = dtmf_received;
}
infoReceivedId = env->GetMethodID(listenerClass,"infoReceived", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneInfoMessage;)V");
env->ExceptionClear();
if (infoReceivedId) {
vTable->info_received = infoReceived;
}
subscriptionStateId = env->GetMethodID(listenerClass,"subscriptionStateChanged", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/SubscriptionState;)V");
subscriptionStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/SubscriptionState"));
subscriptionStateFromIntId = env->GetStaticMethodID(subscriptionStateClass,"fromInt","(I)Lorg/linphone/core/SubscriptionState;");
subscriptionStateId = env->GetMethodID(listenerClass,"subscriptionStateChanged", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/SubscriptionState;)V");
env->ExceptionClear();
if (subscriptionStateId) {
vTable->subscription_state_changed = subscriptionStateChanged;
}
publishStateId = env->GetMethodID(listenerClass,"publishStateChanged", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/PublishState;)V");
publishStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/PublishState"));
publishStateFromIntId = env->GetStaticMethodID(publishStateClass,"fromInt","(I)Lorg/linphone/core/PublishState;");
publishStateId = env->GetMethodID(listenerClass,"publishStateChanged", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Lorg/linphone/core/PublishState;)V");
env->ExceptionClear();
if (publishStateId) {
vTable->publish_state_changed = publishStateChanged;
}
notifyRecvId = env->GetMethodID(listenerClass,"notifyReceived", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneEvent;Ljava/lang/String;Lorg/linphone/core/LinphoneContent;)V");
env->ExceptionClear();
if (notifyRecvId) {
vTable->notify_received = notifyReceived;
}
configuringStateId = env->GetMethodID(listenerClass,"configuringStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$RemoteProvisioningState;Ljava/lang/String;)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");
env->ExceptionClear();
if (configuringStateId) {
vTable->configuring_status = configuringStatus;
}
fileTransferProgressIndicationId = env->GetMethodID(listenerClass, "fileTransferProgressIndication", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;I)V");
env->ExceptionClear();
if (fileTransferProgressIndicationId) {
vTable->file_transfer_progress_indication = fileTransferProgressIndication;
}
fileTransferSendId = env->GetMethodID(listenerClass, "fileTransferSend", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;Ljava/nio/ByteBuffer;I)I");
env->ExceptionClear();
if (fileTransferSendId) {
vTable->file_transfer_send = fileTransferSend;
}
fileTransferRecvId = env->GetMethodID(listenerClass, "fileTransferRecv", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;[BI)V");
env->ExceptionClear();
if (fileTransferRecvId) {
vTable->file_transfer_recv = fileTransferRecv;
}
chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(Lorg/linphone/core/LinphoneCoreImpl;J)V");
callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
if (chatMessageClass) {
chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
}
chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
@ -421,8 +448,6 @@ public:
callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
infoMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneInfoMessageImpl"));
infoMessageCtor = env->GetMethodID(infoMessageClass,"<init>", "(J)V");
@ -999,14 +1024,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env, jobj
}
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_AddListener(JNIEnv* env, jobject thiz, jlong lc, jobject jlistener) {
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addListener(JNIEnv* env, jobject thiz, jlong lc, jobject jlistener) {
LinphoneCoreVTable *vTable = linphone_core_v_table_new();
LinphoneCoreData* ldata = new LinphoneCoreData(env, thiz, vTable, jlistener);
linphone_core_v_table_set_user_data(vTable, ldata);
linphone_core_add_listener((LinphoneCore*)lc, vTable);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_RemoveListener(JNIEnv* env, jobject thiz, jlong lc) {
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeListener(JNIEnv* env, jobject thiz, jlong lc, jobject jlistener) {
//TODO
}

View file

@ -1787,4 +1787,16 @@ public interface LinphoneCore {
* @return An object that implement LinphonePlayer
*/
public LinphonePlayer createLocalPlayer(AndroidVideoWindowImpl window);
/**
* Adds a new listener to be called by the core
* @param listener to add
*/
public void addListener(LinphoneCoreListener listener);
/**
* Removes a listener previously added with addListener
* @param listener to remove
*/
public void removeListener(LinphoneCoreListener listener);
}

View file

@ -22,203 +22,226 @@ import java.nio.ByteBuffer;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
/**
*
*This interface holds all callbacks that the application should implement. None is mandatory.
*/
public interface LinphoneCoreListener {
/**< Ask the application some authentication information
* @return */
void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain);
/** General State notification
* @param state LinphoneCore.State
* @return
* */
void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message);
/** Call State notification
* @param state LinphoneCall.State
* @return
* */
void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);
/**
* Call stats notification
*/
void callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);
/**
* Callback to display change in encryption state.
* @param encrypted true if all streams of the call are encrypted
* @param authenticationToken token like ZRTP SAS that may be displayed to user
*/
void callEncryptionChanged(LinphoneCore lc, LinphoneCall call, boolean encrypted, String authenticationToken);
/**
* Registration state notification
* */
void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);
/**
* Reports that a new subscription request has been received and wait for a decision.
*Status on this subscription request is notified by changing policy for this friend
*@param lc LinphoneCore
*@param lf LinphoneFriend corresponding to the subscriber
*@param url of the subscriber
*
*/
void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url);
/**
* Report status change for a friend previously added to LinphoneCore.
* @param lc LinphoneCore
* @param lf updated LinphoneFriend
*/
void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);
/**
* invoked when a new text message is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
* @param from LinphoneAddress from
* @param message incoming message
*/
void textReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneAddress from, String message);
/**
* invoked when a new linphone chat message is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
* @param message incoming linphone chat message message
*/
void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message);
public interface LinphoneListener extends LinphoneCoreListener,
LinphoneRemoteProvisioningListener, LinphoneMessageListener, LinphoneCallStateListener,
LinphoneCallEncryptionStateListener, LinphoneNotifyListener, LinphoneComposingListener,
LinphoneGlobalStateListener, LinphoneRegistrationStateListener {
/**< Ask the application some authentication information
* @return */
void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain);
/**
* invoked when a composing notification is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in the conversation.
*/
void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr);
/**
* Call stats notification
*/
void callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);
/**
* invoked when a new dtmf is received
* @param lc LinphoneCore
* @param call LinphoneCall involved in the dtmf sending
* @param dtmf value of the dtmf sent
*/
void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf);
/**
* Invoked when echo cancalation calibration is completed
* @param lc LinphoneCore
* @param status
* @param delay_ms echo delay
* @param data
*/
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
/**
* Report Notified message received for this identity.
* @param lc LinphoneCore
* @param call LinphoneCall in case the notify is part of a dialog, may be null
* @param from LinphoneAddress the message comes from
* @param event String the raw body of the notify event.
*
*/
void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event);
/**
* Reports that a new subscription request has been received and wait for a decision.
*Status on this subscription request is notified by changing policy for this friend
*@param lc LinphoneCore
*@param lf LinphoneFriend corresponding to the subscriber
*@param url of the subscriber
*
*/
void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url);
/**
* Notifies progress of a call transfer.
* @param lc the LinphoneCore
* @param call the call through which the transfer was sent.
* @param new_call_state the state of the call resulting of the transfer, at the other party.
**/
void transferState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State new_call_state);
/**
* Notifies an incoming INFO message.
* @param lc the LinphoneCore.
* @param info the info message
*/
void infoReceived(LinphoneCore lc, LinphoneCall call, LinphoneInfoMessage info);
/**
* Notifies of subscription requests state changes, including new incoming subscriptions.
* @param lc the LinphoneCore
* @param ev LinphoneEvent object representing the subscription context.
* @param state actual state of the subscription.
*/
void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, SubscriptionState state);
/**
* Notifies of an incoming NOTIFY received.
* @param lc the linphoneCore
* @param ev a LinphoneEvent representing the subscription context for which this notify belongs, or null if it is a NOTIFY out of of any subscription.
* @param eventName the event name
* @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);
/**
* Notifies the changes about the remote provisioning step
* @param lc the LinphoneCore
* @param state the RemoteProvisioningState
* @param message the error message if state == Failed
*/
void configuringStatus(LinphoneCore lc, RemoteProvisioningState state,
String message);
/**< @Deprecated Notifies the application that it should show up
* @return */
void show(LinphoneCore lc);
/**< @Deprecated Callback that notifies various events with human readable text.
* @return */
void displayStatus(LinphoneCore lc,String message);
/**
* Report status change for a friend previously added to LinphoneCore.
* @param lc LinphoneCore
* @param lf updated LinphoneFriend
*/
void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);
/**< @Deprecated Callback to display a message to the user
* @return */
void displayMessage(LinphoneCore lc,String message);
/**
* invoked when a new text message is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
* @param from LinphoneAddress from
* @param message incoming message
*/
void textReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneAddress from, String message);
/**
* invoked when a new dtmf is received
* @param lc LinphoneCore
* @param call LinphoneCall involved in the dtmf sending
* @param dtmf value of the dtmf sent
*/
void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf);
/**
* Invoked when echo cancalation calibration is completed
* @param lc LinphoneCore
* @param status
* @param delay_ms echo delay
* @param data
*/
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
/**
* Report Notified message received for this identity.
* @param lc LinphoneCore
* @param call LinphoneCall in case the notify is part of a dialog, may be null
* @param from LinphoneAddress the message comes from
* @param event String the raw body of the notify event.
*
*/
void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event);
/** @Deprecated Callback to display a warning to the user
* @return */
void displayWarning(LinphoneCore lc,String message);
/**
* Notifies progress of a call transfer.
* @param lc the LinphoneCore
* @param call the call through which the transfer was sent.
* @param new_call_state the state of the call resulting of the transfer, at the other party.
**/
void transferState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State new_call_state);
/**
* Notifies an incoming INFO message.
* @param lc the LinphoneCore.
* @param info the info message
*/
void infoReceived(LinphoneCore lc, LinphoneCall call, LinphoneInfoMessage info);
/**
* Notifies of subscription requests state changes, including new incoming subscriptions.
* @param lc the LinphoneCore
* @param ev LinphoneEvent object representing the subscription context.
* @param state actual state of the subscription.
*/
void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, SubscriptionState state);
/**
* 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 */
void show(LinphoneCore lc);
/**< @Deprecated Callback that notifies various events with human readable text.
* @return */
void displayStatus(LinphoneCore lc,String message);
/**< @Deprecated Callback to display a message to the user
* @return */
void displayMessage(LinphoneCore lc,String message);
/** @Deprecated Callback to display a warning to the user
* @return */
void displayWarning(LinphoneCore lc,String message);
/**
* Callback to be notified about the transfer progress.
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param progress percentage of the transfer done
*/
void fileTransferProgressIndication(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, int progress);
/**
* Callback to be notified when new data has been received
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param buffer
* @param size
*/
void fileTransferRecv(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, byte[] buffer, int size);
/**
* Callback to be notified when new data needs to be sent
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param buffer
* @param size
* @return the number of bytes written into buffer
*/
int fileTransferSend(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, ByteBuffer buffer, int size);
}
/**
* Callback to be notified about the transfer progress.
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param progress percentage of the transfer done
*/
void fileTransferProgressIndication(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, int progress);
public interface LinphoneGlobalStateListener extends LinphoneCoreListener {
/** General State notification
* @param state LinphoneCore.State
* @return
* */
void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message);
}
/**
* Callback to be notified when new data has been received
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param buffer
* @param size
*/
void fileTransferRecv(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, byte[] buffer, int size);
public interface LinphoneRegistrationStateListener extends LinphoneCoreListener {
/**
* Registration state notification
* */
void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage);
}
/**
* Callback to be notified when new data needs to be sent
* @param lc the LinphoneCore
* @param message the LinphoneChatMessage
* @param content the LinphoneContent
* @param buffer
* @param size
* @return the number of bytes written into buffer
*/
int fileTransferSend(LinphoneCore lc, LinphoneChatMessage message, LinphoneContent content, ByteBuffer buffer, int size);
public interface LinphoneRemoteProvisioningListener extends LinphoneCoreListener {
/**
* Notifies the changes about the remote provisioning step
* @param lc the LinphoneCore
* @param state the RemoteProvisioningState
* @param message the error message if state == Failed
*/
void configuringStatus(LinphoneCore lc, RemoteProvisioningState state, String message);
}
public interface LinphoneMessageListener extends LinphoneCoreListener {
/**
* invoked when a new linphone chat message is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
* @param message incoming linphone chat message message
*/
void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message);
}
public interface LinphoneCallStateListener extends LinphoneCoreListener {
/** Call State notification
* @param state LinphoneCall.State
* @return
* */
void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message);
}
public interface LinphoneCallEncryptionStateListener extends LinphoneCoreListener {
/**
* Callback to display change in encryption state.
* @param encrypted true if all streams of the call are encrypted
* @param authenticationToken token like ZRTP SAS that may be displayed to user
*/
void callEncryptionChanged(LinphoneCore lc, LinphoneCall call, boolean encrypted, String authenticationToken);
}
public interface LinphoneNotifyListener extends LinphoneCoreListener {
/**
* Notifies of an incoming NOTIFY received.
* @param lc the linphoneCore
* @param ev a LinphoneEvent representing the subscription context for which this notify belongs, or null if it is a NOTIFY out of of any subscription.
* @param eventName the event name
* @param content content of the NOTIFY request.
*/
void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content);
}
public interface LinphoneComposingListener extends LinphoneCoreListener {
/**
* invoked when a composing notification is received
* @param lc LinphoneCore
* @param room LinphoneChatRoom involved in the conversation.
*/
void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr);
}
}

View file

@ -1291,4 +1291,16 @@ class LinphoneCoreImpl implements LinphoneCore {
return null;
}
}
private native void addListener(long nativePtr, LinphoneCoreListener listener);
@Override
public void addListener(LinphoneCoreListener listener) {
addListener(nativePtr, listener);
}
private native void removeListener(long nativePtr, LinphoneCoreListener listener);
@Override
public void removeListener(LinphoneCoreListener listener) {
removeListener(nativePtr, listener);
}
}