diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index 1f1dce9f2..af3c7c187 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -23,11 +23,13 @@ import org.linphone.core.LinphoneCall; 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.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreListener; +import org.linphone.core.LinphoneEvent; import org.linphone.core.LinphoneFriend; import org.linphone.core.LinphoneInfoMessage; import org.linphone.core.LinphoneProxyConfig; @@ -36,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.SubscriptionState; /** * @@ -255,5 +258,19 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { } + @Override + public void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, + SubscriptionState state) { + // TODO Auto-generated method stub + + } + + @Override + public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, + String eventName, LinphoneContent content) { + // TODO Auto-generated method stub + + } + } diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java index ecd5846d6..276d291e5 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java @@ -24,6 +24,7 @@ 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; @@ -31,9 +32,11 @@ import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreListener; +import org.linphone.core.LinphoneEvent; import org.linphone.core.LinphoneFriend; import org.linphone.core.LinphoneInfoMessage; import org.linphone.core.LinphoneProxyConfig; +import org.linphone.core.SubscriptionState; /** @@ -177,5 +180,19 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa } + @Override + public void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, + SubscriptionState state) { + // TODO Auto-generated method stub + + } + + @Override + public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, + String eventName, LinphoneContent content) { + // TODO Auto-generated method stub + + } + } diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java index 10d3a2ce5..c624a9e83 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java @@ -23,17 +23,20 @@ import org.linphone.core.LinphoneCall; 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.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreListener; +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.SubscriptionState; /** @@ -181,5 +184,19 @@ public class TutorialHelloWorld implements LinphoneCoreListener { } + @Override + public void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, + SubscriptionState state) { + // TODO Auto-generated method stub + + } + + @Override + public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, + String eventName, LinphoneContent content) { + // TODO Auto-generated method stub + + } + } diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index e8373b0d4..685997f11 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -23,17 +23,20 @@ import org.linphone.core.LinphoneCall; 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.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreListener; +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.SubscriptionState; /** @@ -212,6 +215,20 @@ public class TutorialRegistration implements LinphoneCoreListener { } + @Override + public void subscriptionStateChanged(LinphoneCore lc, LinphoneEvent ev, + SubscriptionState state) { + // TODO Auto-generated method stub + + } + + @Override + public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, + String eventName, LinphoneContent content) { + // TODO Auto-generated method stub + + } + } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 0424a797c..c8a6d7b6f 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1267,5 +1267,27 @@ public interface LinphoneCore { */ public LinphoneInfoMessage createInfoMessage(); - + /** + * Sends an outgoing subscription for a resource with given event, expiration period, and content. + * The state changes of the new subscriptions can be followed thanks to { @link LinphoneCoreListener.subscriptionStateChanged() } and + * { @link LinphoneCoreListener.notifyReceived }. + * @param resource the address of the resource for which the event needs to be monitored. + * @param event the event name, as specified in the event package RFC. + * @param expires the expiration period in seconds. + * @param content optional content of the subscription. + * @return a LinphoneEvent representing the subscription context. + */ + public LinphoneEvent subscribe(LinphoneAddress resource, String event, int expires, LinphoneContent content ); + + /** + * Publish an event. + * After the initial publication, updates can be done with { @link LinphoneEvent.updatePublish() } + * @param resource the resource to which the event belongs. + * @param event the event name as specified in the event package RFC. + * @param expires valid time for the event. + * @param content content of the publish. + * @return a LinphoneEvent representing the publish context. + */ + public LinphoneEvent publish(LinphoneAddress resource, String event, int expires, LinphoneContent content); + } diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index b3ff9bbfc..af5b07b84 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -132,6 +132,23 @@ public interface LinphoneCoreListener { */ 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); + /**< @Deprecated Notifies the application that it should show up * @return */ void show(LinphoneCore lc); diff --git a/java/common/org/linphone/core/LinphoneEvent.java b/java/common/org/linphone/core/LinphoneEvent.java new file mode 100644 index 000000000..26f55c9f1 --- /dev/null +++ b/java/common/org/linphone/core/LinphoneEvent.java @@ -0,0 +1,59 @@ +package org.linphone.core; + +public interface LinphoneEvent { + /** + * Get the event name as standardized by the event package RFC. + * @return the event name. + */ + String getEventName(); + /** + * Accept an incoming subscription. After it is accepted the application can immediately start to send notifications with + * {@link LinphoneEvent.notify() }. + */ + void acceptSubscription(); + + /** + * Reject an incoming subscription. + * @param reason reason code for rejection. + */ + void denySubscription(Reason reason); + + /** + * Sends a NOTIFY request in the context of a LinphoneEvent created by an incoming subscription. + * @param content the data to be put in the notification. + */ + void notify(LinphoneContent content); + + /** + * Update a subscription initiated previously with {@link LinphoneCore.subscribe() } + * @param content the data to be put in the subscribe request. + */ + void updateSubscribe(LinphoneContent content); + + /** + * Update a Publish previously started with {@link LinphoneCore.publish() }. + * @param content the data to be put in the publish request. + */ + void updatePublish(LinphoneContent content); + + /** + * Terminate an outgoing or incoming subscription, depending on the way the LinphoneEvent was created. + */ + void terminate(); + /** + * In the event where an error would be returned or notified relatively to this LinphoneEvent, returns a reason error code. + * @return + */ + Reason getReason(); + + /** + * Assign an application context to the LinphoneEvent, for later use. + * @param obj + */ + void setUserContext(Object obj); + /** + * Retrieve application context previously set by setUserContext(). + * @return + */ + Object getUserContext(); +} diff --git a/java/common/org/linphone/core/SubscriptionDir.java b/java/common/org/linphone/core/SubscriptionDir.java new file mode 100644 index 000000000..e18639efc --- /dev/null +++ b/java/common/org/linphone/core/SubscriptionDir.java @@ -0,0 +1,7 @@ +package org.linphone.core; + +public enum SubscriptionDir { + Incoming, + Outgoing, + Invalid +} diff --git a/java/common/org/linphone/core/SubscriptionState.java b/java/common/org/linphone/core/SubscriptionState.java new file mode 100644 index 000000000..4ab9f7ca6 --- /dev/null +++ b/java/common/org/linphone/core/SubscriptionState.java @@ -0,0 +1,32 @@ +package org.linphone.core; + +public enum SubscriptionState { + /** + * Initial state, should not be used. + */ + LinphoneSubscriptionNone, + /** + * An outgoing subcription was created. + */ + LinphoneSubscriptionOutoingInit, + /** + * An incoming subcription is received. + */ + LinphoneSubscriptionIncomingReceived, + /** + * Subscription is pending, waiting for user approval + */ + LinphoneSubscriptionPending, + /** + * Subscription is accepted and now active. + */ + LinphoneSubscriptionActive, + /** + * Subscription is terminated normally + */ + LinphoneSubscriptionTerminated, + /** + * Subscription encountered an error, indicated by { @link LinphoneEvent.getReason() } + */ + LinphoneSubscriptionError +} diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 4b0232113..bcf128f08 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -954,4 +954,16 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneInfoMessage createInfoMessage() { return new LinphoneInfoMessageImpl(createInfoMessage(nativePtr)); } + @Override + public LinphoneEvent subscribe(LinphoneAddress resource, String event, + int expires, LinphoneContent content) { + // TODO Auto-generated method stub + return null; + } + @Override + public LinphoneEvent publish(LinphoneAddress resource, String event, + int expires, LinphoneContent content) { + // TODO Auto-generated method stub + return null; + } }