Commit 20dfd43a authored by Ghislain MARY's avatar Ghislain MARY

More coherent friend API.

parent 43186ab4
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
/**
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment