From 50f145ed7791cee65750ed6c84c380c370dea8da Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 25 Jun 2013 11:59:27 +0200 Subject: [PATCH] Add missing functions to presence JNI. --- coreapi/linphonecore_jni.cc | 37 ++++++++++++++++++- .../org/linphone/core/PresenceModel.java | 18 +++++++++ .../org/linphone/core/PresenceModelImpl.java | 18 +++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index e80a2c587..316e28c11 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2007,7 +2007,7 @@ extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env */ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneFriendImpl_getPresenceModel(JNIEnv *env, jobject jobj, jlong ptr) { LinphoneFriend *lf = (LinphoneFriend *)ptr; - const LinphonePresenceModel *model = linphone_friend_get_presence_model(lf); + LinphonePresenceModel *model = (LinphonePresenceModel *)linphone_friend_get_presence_model(lf); if (model == NULL) return NULL; RETURN_USER_DATA_OBJECT("PresenceModelImpl", linphone_presence_model, model); } @@ -3120,6 +3120,41 @@ 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: getTimestamp + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_getTimestamp(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jlong)linphone_presence_model_get_timestamp(model); +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: getContact + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceModelImpl_getContact(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + char *ccontact = linphone_presence_model_get_contact(model); + jstring jcontact = ccontact ? env->NewStringUTF(ccontact) : NULL; + if (ccontact) ms_free(ccontact); + return jcontact; +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: setContact + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_PresenceModelImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + linphone_presence_model_set_contact(model, ccontact); + if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); +} + /* * Class: org_linphone_core_PresenceModelImpl * Method: nbActivities diff --git a/java/common/org/linphone/core/PresenceModel.java b/java/common/org/linphone/core/PresenceModel.java index 9644e04cb..08cb2ad4b 100644 --- a/java/common/org/linphone/core/PresenceModel.java +++ b/java/common/org/linphone/core/PresenceModel.java @@ -56,6 +56,24 @@ public interface PresenceModel { */ BasicStatus getBasicStatus(); + /** + * @brief Gets the timestamp of a presence model. + * @return The timestamp of the #LinphonePresenceModel object or -1 on error. + */ + long getTimestamp(); + + /** + * @brief Gets the contact of a presence model. + * @return A string containing the contact, or null if no contact is found. + */ + String getContact(); + + /** + * @brief Sets the contact of a presence model. + * @param contact The contact string to set. + */ + void setContact(String contact); + /** * @brief Gets the number of activities included in the presence model. * @return The number of activities included in the #PresenceModel object. diff --git a/java/impl/org/linphone/core/PresenceModelImpl.java b/java/impl/org/linphone/core/PresenceModelImpl.java index c7720fa2e..839961ee9 100644 --- a/java/impl/org/linphone/core/PresenceModelImpl.java +++ b/java/impl/org/linphone/core/PresenceModelImpl.java @@ -41,6 +41,24 @@ public class PresenceModelImpl implements PresenceModel { return BasicStatus.fromInt(getBasicStatus(mNativePtr)); } + private native long getTimestamp(long nativePtr); + @Override + public long getTimestamp() { + return getTimestamp(mNativePtr); + } + + private native String getContact(long nativePtr); + @Override + public String getContact() { + return getContact(mNativePtr); + } + + private native void setContact(long nativePtr, String contact); + @Override + public void setContact(String contact) { + setContact(mNativePtr, contact); + } + private native long nbActivities(long nativePtr); @Override public long nbActivities() {