diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index b12eacaa6..a3acc1ec2 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3307,6 +3307,17 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_getBasicStatus(J return (jint)linphone_presence_model_get_basic_status(model); } +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: setBasicStatus + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_setBasicStatus(JNIEnv *env, jobject jobj, jlong ptr, jint basic_status) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jint)linphone_presence_model_set_basic_status(model, (LinphonePresenceBasicStatus)basic_status); +} + + /* * Class: org_linphone_core_PresenceModelImpl * Method: getTimestamp @@ -3389,6 +3400,29 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_setActivity(JNIE return res; } +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: addActivity + * Signature: (JILjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addActivity(JNIEnv *env, jobject jobj, jlong ptr, jint acttype, jstring description) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + jint res = (jint)linphone_presence_model_add_activity(model, (LinphonePresenceActivityType)acttype, cdescription); + if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + return res; +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: clearActivities + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearActivities(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jint)linphone_presence_model_clear_activities(model); +} + /* * Class: org_linphone_core_PresenceModelImpl * Method: getNote diff --git a/java/common/org/linphone/core/PresenceModel.java b/java/common/org/linphone/core/PresenceModel.java index 5a6a9bf93..8f4d3716d 100644 --- a/java/common/org/linphone/core/PresenceModel.java +++ b/java/common/org/linphone/core/PresenceModel.java @@ -27,6 +27,13 @@ public interface PresenceModel { */ PresenceBasicStatus getBasicStatus(); + /** + * @brief Sets the basic status of a presence model. + * @param[in] basic_status The #BasicStatus to set for the #PresenceModel object. + * @return 0 if successful, a value < 0 in case of error. + */ + int setBasicStatus(PresenceBasicStatus basic_status); + /** * @brief Gets the timestamp of a presence model. * @return The timestamp of the #LinphonePresenceModel object or -1 on error. @@ -69,9 +76,26 @@ public interface PresenceModel { * @param[in] activity The #PresenceActivityType to set for the model. * @param[in] description An additional description of the activity to set for the model. Can be null if no additional description is to be added. * @return 0 if successful, a value < 0 in case of error. + * + * WARNING: This method will modify the basic status of the model according to the activity being set. + * If you don't want the basic status to be modified automatically, you can use the combination of setBasicStatus(), clearActivities() and addActivity(). */ int setActivity(PresenceActivityType activity, String description); + /** + * @brief Adds an activity to a presence model. + * @param[in] activity The #PresenceActivityType to add to the model. + * @param[in] description An additional description of the activity to add to the model. Can be null if no additional description is to be added. + * @return 0 if successful, a value < 0 in case of error. + */ + int addActivity(PresenceActivityType activity, String description); + + /** + * @brief Clears the activities of a presence model. + * @return 0 if successful, a value < 0 in case of error. + */ + int clearActivities(); + /** * @brief Gets the first note of a presence model (there is usually only one). * @param[in] lang The language of the note to get. Can be null to get a note that has no language specified or to get the first note whatever language it is written into. diff --git a/java/impl/org/linphone/core/PresenceModelImpl.java b/java/impl/org/linphone/core/PresenceModelImpl.java index 0a7173036..3cafe3cd7 100644 --- a/java/impl/org/linphone/core/PresenceModelImpl.java +++ b/java/impl/org/linphone/core/PresenceModelImpl.java @@ -41,6 +41,12 @@ public class PresenceModelImpl implements PresenceModel { return PresenceBasicStatus.fromInt(getBasicStatus(mNativePtr)); } + private native int setBasicStatus(long nativePtr, int basic_status); + @Override + public int setBasicStatus(PresenceBasicStatus basic_status) { + return setBasicStatus(mNativePtr, basic_status.toInt()); + } + private native long getTimestamp(long nativePtr); @Override public long getTimestamp() { @@ -83,6 +89,18 @@ public class PresenceModelImpl implements PresenceModel { return setActivity(mNativePtr, activity.toInt(), description); } + private native int addActivity(long nativePtr, int activity, String description); + @Override + public int addActivity(PresenceActivityType activity, String description) { + return addActivity(mNativePtr, activity.toInt(), description); + } + + private native int clearActivities(long nativePtr); + @Override + public int clearActivities() { + return clearActivities(mNativePtr); + } + private native Object getNote(long nativePtr, String lang); @Override public PresenceNote getNote(String lang) {