From 2d862f98ba3baea697e7c1a54f35c1c966417a98 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 25 Jun 2013 10:45:14 +0200 Subject: [PATCH] Remove useless minutes_away and contact parameters to the linphone_core_set_presence_model() function. --- coreapi/help/buddy_status.c | 4 ++-- coreapi/linphonecore.c | 20 +++++++++---------- coreapi/linphonecore_jni.cc | 6 ++---- coreapi/linphonefriend.h | 4 +--- .../org/linphone/core/LinphoneCore.java | 6 ++---- .../org/linphone/core/LinphoneCoreImpl.java | 6 +++--- tester/presence_tester.c | 8 ++++---- 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/coreapi/help/buddy_status.c b/coreapi/help/buddy_status.c index 4f1f64906..5e073d75a 100644 --- a/coreapi/help/buddy_status.c +++ b/coreapi/help/buddy_status.c @@ -168,7 +168,7 @@ int main(int argc, char *argv[]){ } /*set my status to online*/ - linphone_core_set_presence_model(lc, 0, NULL, linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline, NULL)); + linphone_core_set_presence_model(lc, linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline, NULL)); /* main loop for receiving notifications and doing background linphone core work: */ while(running){ @@ -177,7 +177,7 @@ int main(int argc, char *argv[]){ } /* change my presence status to offline*/ - linphone_core_set_presence_model(lc, 0, NULL, linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline, NULL)); + linphone_core_set_presence_model(lc, linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline, NULL)); linphone_core_iterate(lc); /* just to make sure new status is initiate message is issued */ linphone_friend_edit(my_friend); /* start editing friend */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8c79e75d4..5e1820ce4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3646,6 +3646,14 @@ void linphone_core_set_presence_info(LinphoneCore *lc, int minutes_away, const c LinphonePresenceModel *presence = NULL; char *description = NULL; LinphonePresenceActivityType acttype = LinphonePresenceActivityUnknown; + + if (minutes_away>0) lc->minutes_away=minutes_away; + if (lc->alt_contact!=NULL) { + ms_free(lc->alt_contact); + lc->alt_contact=NULL; + } + if (contact) lc->alt_contact=ms_strdup(contact); + switch (os) { case LinphoneStatusOffline: acttype = LinphonePresenceActivityOffline; @@ -3691,18 +3699,10 @@ void linphone_core_set_presence_info(LinphoneCore *lc, int minutes_away, const c return; } presence = linphone_presence_model_new_with_activity(acttype, description); - linphone_core_set_presence_model(lc, minutes_away, contact, presence); + linphone_core_set_presence_model(lc, presence); } -void linphone_core_set_presence_model(LinphoneCore *lc, int minutes_away, const char *contact, LinphonePresenceModel *presence) { - if (minutes_away>0) lc->minutes_away=minutes_away; - - if (lc->alt_contact!=NULL) { - ms_free(lc->alt_contact); - lc->alt_contact=NULL; - } - if (contact) lc->alt_contact=ms_strdup(contact); - +void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence) { // TODO: Check that the presence timestamp is newer than the last sent presence. linphone_core_notify_all_friends(lc,presence); /* diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 4278ca466..e80a2c587 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -1099,12 +1099,10 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getPresenceInfo(JNIEnv * * Method: setPresenceModel * Signature: (JILjava/lang/String;J)V */ -JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setPresenceModel(JNIEnv *env, jobject jobj, jlong ptr, jint minutes_away, jstring jalternative_contact, jlong modelPtr) { +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setPresenceModel(JNIEnv *env, jobject jobj, jlong ptr, jlong modelPtr) { LinphoneCore *lc = (LinphoneCore *)ptr; - const char *calternative_contact = jalternative_contact ? env->GetStringUTFChars(jalternative_contact, NULL) : NULL; LinphonePresenceModel *model = (LinphonePresenceModel *)modelPtr; - linphone_core_set_presence_model(lc, minutes_away, calternative_contact, model); - if (calternative_contact) env->ReleaseStringUTFChars(jalternative_contact, calternative_contact); + linphone_core_set_presence_model(lc, model); } /* diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index d7c7cd8d8..312efec6a 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -249,11 +249,9 @@ LINPHONE_PUBLIC void linphone_core_set_presence_info(LinphoneCore *lc,int minute /** * @brief Set my presence status * @param[in] lc #LinphoneCore object - * @param[in] minutes_away how long in away - * @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved * @param[in] presence #LinphonePresenceModel */ -LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, int minutes_away, const char *alternative_contact, LinphonePresenceModel *presence); +LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence); /** * @brief Get my presence status diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 66db71526..76ced4133 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -671,7 +671,7 @@ public interface LinphoneCore { /** * @brief Set my presence status * @param minutes_away how long in away - * @param status sip uri used to redirect call in state LinphoneStatusMoved + * @param alternative_contact sip uri used to redirect call in state LinphoneStatusMoved * @param status OnlineStatus * @deprecated Use setPresenceModel() instead */ @@ -684,11 +684,9 @@ public interface LinphoneCore { OnlineStatus getPresenceInfo(); /** * @brief Set my presence status - * @param minutess_away how long in away - * @param alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved * @param presence #LinphonePresenceModel */ - void setPresenceModel(int minutes_away, String alternative_contact, PresenceModel presence); + void setPresenceModel(PresenceModel presence); /** * @brief Get my presence status * @return A #PresenceModel object, or null if no presence model has been set. diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 7884fb011..a61bd1cc5 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -82,7 +82,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void addFriend(long nativePtr,long friend); private native void setPresenceInfo(long nativePtr, int minutes_away, String alternative_contact, int status); private native int getPresenceInfo(long nativePtr); - private native void setPresenceModel(long nativePtr, int minutes_away, String alternative_contact, long presencePtr); + private native void setPresenceModel(long nativePtr, long presencePtr); private native Object getPresenceModel(long nativePtr); private native long createChatRoom(long nativePtr,String to); private native void enableVideo(long nativePtr,boolean vcap_enabled,boolean display_enabled); @@ -378,8 +378,8 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized OnlineStatus getPresenceInfo() { return OnlineStatus.fromInt(getPresenceInfo(nativePtr)); } - public synchronized void setPresenceModel(int minutes_away, String alternative_contact, PresenceModel presence) { - setPresenceModel(nativePtr, minutes_away, alternative_contact, ((PresenceModelImpl)presence).getNativePtr()); + public synchronized void setPresenceModel(PresenceModel presence) { + setPresenceModel(nativePtr, ((PresenceModelImpl)presence).getNativePtr()); } public synchronized PresenceModel getPresenceModel() { return (PresenceModel)getPresenceModel(nativePtr); diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 1363c4045..029d2e01a 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -134,7 +134,7 @@ static void simple_publish(void) { linphone_proxy_config_done(proxy); wait_core(marie->lc); presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,NULL); - linphone_core_set_presence_model(marie->lc,0,NULL,presence); + linphone_core_set_presence_model(marie->lc,presence); wait_core(marie->lc); linphone_core_manager_destroy(marie); } @@ -222,7 +222,7 @@ static void presence_information(void) { /* Presence activity without description. */ presence = linphone_presence_model_new_with_activity(LinphonePresenceActivityDinner, NULL); - linphone_core_set_presence_model(pauline->lc, 0, NULL, presence); + linphone_core_set_presence_model(pauline->lc, presence); wait_core(marie->lc); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityDinner, 1); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence); @@ -233,7 +233,7 @@ static void presence_information(void) { /* Presence activity with description. */ presence = linphone_presence_model_new_with_activity(LinphonePresenceActivitySteering, bike_description); - linphone_core_set_presence_model(pauline->lc, 0, NULL, presence); + linphone_core_set_presence_model(pauline->lc, presence); wait_core(marie->lc); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivitySteering, 1); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence); @@ -245,7 +245,7 @@ static void presence_information(void) { /* Presence activity with description and note. */ presence = linphone_presence_model_new_with_activity_and_note(LinphonePresenceActivityVacation, NULL, vacation_note, vacation_lang); - linphone_core_set_presence_model(pauline->lc, 0, NULL, presence); + linphone_core_set_presence_model(pauline->lc, presence); wait_core(marie->lc); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePresenceActivityVacation, 1); activity = linphone_presence_model_get_activity(marie->stat.last_received_presence);