From 20dfd43aac43ed8a3cd966c8d0db57c3be8d2be8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 19 Sep 2013 11:15:29 +0200 Subject: [PATCH] More coherent friend API. --- console/commands.c | 4 ++-- coreapi/friend.c | 8 ++++---- coreapi/help/buddy_status.c | 2 +- coreapi/linphonecore_jni.cc | 4 ++-- coreapi/linphonefriend.h | 14 ++++++++++++-- coreapi/presence.c | 8 ++++---- coreapi/private.h | 4 +--- gtk/buddylookup.c | 2 +- gtk/calllogs.c | 2 +- gtk/chat.c | 4 ++-- gtk/friendlist.c | 4 ++-- tester/presence_tester.c | 4 ++-- 12 files changed, 34 insertions(+), 26 deletions(-) diff --git a/console/commands.c b/console/commands.c index 67b2446f4..1e893619d 100644 --- a/console/commands.c +++ b/console/commands.c @@ -1022,7 +1022,7 @@ lpc_cmd_friend(LinphoneCore *lc, char *args) linphonec_friend_add(lc, name, addr); #else LinphoneFriend *new_friend; - new_friend = linphone_friend_new_with_addr(args); + new_friend = linphone_friend_new_with_address(args); linphone_core_add_friend(lc, new_friend); #endif return 1; @@ -1852,7 +1852,7 @@ linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr) char url[PATH_MAX]; snprintf(url, PATH_MAX, "%s <%s>", name, addr); - newFriend = linphone_friend_new_with_addr(url); + newFriend = linphone_friend_new_with_address(url); linphone_core_add_friend(lc, newFriend); return 0; } diff --git a/coreapi/friend.c b/coreapi/friend.c index f5b6f626c..7626617ba 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -78,7 +78,7 @@ static int friend_compare(const void * a, const void * b){ } -MSList *linphone_find_friend_by_addr(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf){ +MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf){ MSList *res=NULL; LinphoneFriend dummy; if (lf!=NULL) *lf=NULL; @@ -145,7 +145,7 @@ LinphoneFriend * linphone_friend_new(){ return obj; } -LinphoneFriend *linphone_friend_new_with_addr(const char *addr){ +LinphoneFriend *linphone_friend_new_with_address(const char *addr){ LinphoneAddress* linphone_address = linphone_address_new(addr); LinphoneFriend *fr; @@ -154,7 +154,7 @@ LinphoneFriend *linphone_friend_new_with_addr(const char *addr){ return NULL; } fr=linphone_friend_new(); - linphone_friend_set_addr(fr,linphone_address); + linphone_friend_set_address(fr,linphone_address); linphone_address_destroy(linphone_address); return fr; } @@ -605,7 +605,7 @@ LinphoneFriend * linphone_friend_new_from_config_file(LinphoneCore *lc, int inde if (tmp==NULL) { return NULL; } - lf=linphone_friend_new_with_addr(tmp); + lf=linphone_friend_new_with_address(tmp); if (lf==NULL) { return NULL; } diff --git a/coreapi/help/buddy_status.c b/coreapi/help/buddy_status.c index 5e073d75a..bcd71b99f 100644 --- a/coreapi/help/buddy_status.c +++ b/coreapi/help/buddy_status.c @@ -155,7 +155,7 @@ int main(int argc, char *argv[]){ LinphoneFriend* my_friend=NULL; if (dest_friend) { - my_friend = linphone_friend_new_with_addr(dest_friend); /*creates friend object from dest*/ + my_friend = linphone_friend_new_with_address(dest_friend); /*creates friend object from dest*/ if (my_friend == NULL) { printf("bad destination uri for friend [%s]\n",dest_friend); goto end; diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index d1fb06674..44f94935a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2042,7 +2042,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNI if (jFriendUri) { const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL); - lResult= linphone_friend_new_with_addr(friendUri); + lResult= linphone_friend_new_with_address(friendUri); env->ReleaseStringUTFChars(jFriendUri, friendUri); } else { lResult = linphone_friend_new(); @@ -2053,7 +2053,7 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* en ,jobject thiz ,jlong ptr ,jlong linphoneAddress) { - linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress); + linphone_friend_set_address((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress); } extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env ,jobject thiz diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index cd74a10c6..fd896ac3f 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -121,12 +121,19 @@ typedef struct _LinphoneFriend LinphoneFriend; * @return a new empty #LinphoneFriend */ LINPHONE_PUBLIC LinphoneFriend * linphone_friend_new(); + /** - * Contructor same as linphone_friend_new() + linphone_friend_set_addr() + * Contructor same as linphone_friend_new() + linphone_friend_set_address() * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink */ -LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_with_addr(const char *addr); +LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_with_address(const char *addr); + +/** + * Contructor same as linphone_friend_new() + linphone_friend_set_address() + * @deprecated Use #linphone_friend_new_with_address instead + */ +#define linphone_friend_new_with_addr linphone_friend_new_with_address /** * Destructor @@ -289,6 +296,9 @@ LINPHONE_PUBLIC LinphoneOnlineStatus linphone_core_get_presence_info(const Linph */ LINPHONE_PUBLIC LinphonePresenceModel * linphone_core_get_presence_model(const LinphoneCore *lc); +/** + * @deprecated Use linphone_core_interpret_url() instead + */ LINPHONE_PUBLIC void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); /** diff --git a/coreapi/presence.c b/coreapi/presence.c index 2d23198c6..20a0ead0e 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1502,7 +1502,7 @@ static LinphonePresenceModel * process_pidf_xml_presence_notification(xmlparsing void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalOp *op){ - LinphoneFriend *fl=linphone_friend_new_with_addr(subscriber); + LinphoneFriend *fl=linphone_friend_new_with_address(subscriber); if (fl==NULL) return ; fl->insub=op; linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept); @@ -1555,14 +1555,14 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){ } /* check if we answer to this subscription */ - if (linphone_find_friend_by_addr(lc->friends,uri,&lf)!=NULL){ + if (linphone_find_friend_by_address(lc->friends,uri,&lf)!=NULL){ lf->insub=op; lf->inc_subscribe_pending=TRUE; sal_subscribe_accept(op); linphone_friend_done(lf); /*this will do all necessary actions */ }else{ /* check if this subscriber is in our black list */ - if (linphone_find_friend_by_addr(lc->subscribers,uri,&lf)){ + if (linphone_find_friend_by_address(lc->subscribers,uri,&lf)){ if (lf->pol==LinphoneSPDeny){ ms_message("Rejecting %s because we already rejected it once.",from); sal_subscribe_decline(op,SalReasonDeclined); @@ -1926,7 +1926,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa if (lf==NULL && lp_config_get_int(lc->config,"sip","allow_out_of_subscribe_presence",0)){ const SalAddress *addr=sal_op_get_from_address(op); lf=NULL; - linphone_find_friend_by_addr(lc->friends,(LinphoneAddress*)addr,&lf); + linphone_find_friend_by_address(lc->friends,(LinphoneAddress*)addr,&lf); } if (lf!=NULL){ LinphonePresenceActivity *activity = NULL; diff --git a/coreapi/private.h b/coreapi/private.h index 4cead54df..2d817f6bb 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -253,7 +253,7 @@ void linphone_friend_close_subscriptions(LinphoneFriend *lf); void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence); LinphoneFriend *linphone_find_friend_by_inc_subscribe(MSList *l, SalOp *op); LinphoneFriend *linphone_find_friend_by_out_subscribe(MSList *l, SalOp *op); -MSList *linphone_find_friend_by_addr(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf); +MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf); int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen); int set_lock_file(); @@ -303,8 +303,6 @@ void linphone_proxy_config_process_authentication_failure(LinphoneCore *lc, SalO void linphone_subscription_answered(LinphoneCore *lc, SalOp *op); void linphone_subscription_closed(LinphoneCore *lc, SalOp *op); -MSList *linphone_find_friend_by_addr(MSList *fl, const LinphoneAddress *fri, LinphoneFriend **lf); - void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc); void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt); diff --git a/gtk/buddylookup.c b/gtk/buddylookup.c index 55c3f334e..4a6cb8d7a 100644 --- a/gtk/buddylookup.c +++ b/gtk/buddylookup.c @@ -287,7 +287,7 @@ void linphone_gtk_add_buddy_from_database(GtkWidget *button){ gtk_tree_model_get (model, &iter,LOOKUP_RESULT_SIP_URI , &uri,LOOKUP_RESULT_NAME, &name, -1); addr=g_strdup_printf("%s <%s>",name,uri); - lf=linphone_friend_new_with_addr(addr); + lf=linphone_friend_new_with_address(addr); linphone_friend_set_inc_subscribe_policy(lf,presence ? LinphoneSPAccept : LinphoneSPDeny); linphone_friend_send_subscribe(lf,presence); linphone_core_add_friend(linphone_gtk_get_core(),lf); diff --git a/gtk/calllogs.c b/gtk/calllogs.c index 466541006..e9b460636 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -82,7 +82,7 @@ void linphone_gtk_call_log_add_contact(GtkWidget *w){ la=(LinphoneAddress*)pla; if (la!=NULL){ char *uri=linphone_address_as_string(la); - lf=linphone_friend_new_with_addr(uri); + lf=linphone_friend_new_with_address(uri); linphone_gtk_show_contact(lf); ms_free(uri); } diff --git a/gtk/chat.c b/gtk/chat.c index 40ad17252..25e1c0d75 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -335,7 +335,7 @@ void display_history_message(GtkWidget *chat_view,MSList *messages,const Linphon void linphone_gtk_chat_add_contact(const LinphoneAddress *addr){ LinphoneFriend *lf=NULL; char *uri=linphone_address_as_string(addr); - lf=linphone_friend_new_with_addr(uri); + lf=linphone_friend_new_with_address(uri); ms_free(uri); char *fixed_uri=NULL; gboolean show_presence=FALSE; @@ -348,7 +348,7 @@ void linphone_gtk_chat_add_contact(const LinphoneAddress *addr){ linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !")); return ; } - linphone_friend_set_addr(lf,addr); + linphone_friend_set_address(lf,addr); linphone_core_add_friend(linphone_gtk_get_core(),lf); ms_free(fixed_uri); linphone_gtk_show_friends(); diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 12da891f4..2eedd5b54 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -450,7 +450,7 @@ static void icon_press_handler(GtkEntry *entry){ } lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),uri); if (lf==NULL) - lf=linphone_friend_new_with_addr(uri); + lf=linphone_friend_new_with_address(uri); if (lf!=NULL){ linphone_gtk_show_contact(lf); } @@ -886,7 +886,7 @@ void linphone_gtk_contact_ok(GtkWidget *button){ } friend_address = linphone_address_new(fixed_uri); linphone_address_set_display_name(friend_address,name); - linphone_friend_set_addr(lf,friend_address); + linphone_friend_set_address(lf,friend_address); linphone_address_destroy(friend_address); linphone_friend_send_subscribe(lf,show_presence); diff --git a/tester/presence_tester.c b/tester/presence_tester.c index cc95d6c8a..688a8b5fc 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -146,7 +146,7 @@ static bool_t subscribe_to_callee_presence(LinphoneCoreManager* caller_mgr,Linph char* identity=linphone_address_as_string_uri_only(callee_mgr->identity); - LinphoneFriend* friend=linphone_friend_new_with_addr(identity); + LinphoneFriend* friend=linphone_friend_new_with_address(identity); linphone_friend_edit(friend); linphone_friend_enable_subscribes(friend,TRUE); linphone_friend_done(friend); @@ -211,7 +211,7 @@ static void simple_subscribe(void) { static void unsubscribe_while_subscribing(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); - LinphoneFriend* friend = linphone_friend_new_with_addr("sip:toto@git.linphone.org"); /*any unexisting address*/ + LinphoneFriend* friend = linphone_friend_new_with_address("sip:toto@git.linphone.org"); /*any unexisting address*/ linphone_friend_edit(friend); linphone_friend_enable_subscribes(friend,TRUE); linphone_friend_done(friend);