]> sjero.net Git - linphone/blobdiff - coreapi/friend.c
Update ms2
[linphone] / coreapi / friend.c
index ee70139460ae9810b7297a8b9d27ec21f2fc3b95..c6dee2440a8d28019c003893123cc2dfde218b0a 100644 (file)
@@ -186,6 +186,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
                        /*try adding domain part from default current proxy*/
                        LinphoneAddress * id=linphone_address_new(linphone_core_get_identity(lc));
                        if (id!=NULL){
+                               linphone_address_set_display_name(id,NULL);
                                linphone_address_set_username(id,uri);
                                *result=linphone_address_as_string(id);
                                linphone_address_destroy(id);
@@ -203,10 +204,6 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
 
 int linphone_friend_set_addr(LinphoneFriend *lf, const LinphoneAddress *addr){
        LinphoneAddress *fr=linphone_address_clone(addr);
-       if (fr==NULL) {
-               ms_warning("Invalid friend sip uri: %s",addr);
-               return -1;
-       }
        linphone_address_clean(fr);
        if (lf->uri!=NULL) linphone_address_destroy(lf->uri);   
        lf->uri=fr;
@@ -277,7 +274,9 @@ SalPresenceStatus linphone_online_status_to_sal(LinphoneOnlineStatus os){
 }
 
 void linphone_friend_notify(LinphoneFriend *lf, LinphoneOnlineStatus os){
-       //printf("Wish to notify %p, lf->nid=%i\n",lf,lf->nid);
+       char *addr=linphone_address_as_string(linphone_friend_get_address(lf));
+       ms_message("Want to notify %s, insub=%p",addr,lf->insub);
+       ms_free(addr);
        if (lf->insub!=NULL){
                sal_notify_presence(lf->insub,linphone_online_status_to_sal(os),NULL);
        }
@@ -286,8 +285,6 @@ void linphone_friend_notify(LinphoneFriend *lf, LinphoneOnlineStatus os){
 static void linphone_friend_unsubscribe(LinphoneFriend *lf){
        if (lf->outsub!=NULL) {
                sal_unsubscribe(lf->outsub);
-               sal_op_release(lf->outsub);
-               lf->outsub=NULL;
                lf->subscribe_active=FALSE;
        }
 }
@@ -296,13 +293,19 @@ void linphone_friend_close_subscriptions(LinphoneFriend *lf){
        linphone_friend_unsubscribe(lf);
        if (lf->insub){
                sal_notify_close(lf->insub);
-               sal_op_release(lf->insub);
-               lf->insub=NULL;
+               
        }
 }
 
 void linphone_friend_destroy(LinphoneFriend *lf){
-       
+       if (lf->insub) {
+               sal_op_release(lf->insub);
+               lf->insub=NULL;
+       }
+       if (lf->outsub){
+               sal_op_release(lf->outsub);
+               lf->outsub=NULL;
+       }
        if (lf->uri!=NULL) linphone_address_destroy(lf->uri);
        if (lf->info!=NULL) buddy_info_free(lf->info);
        ms_free(lf);
@@ -393,8 +396,8 @@ void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf)
 void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend* fl){
        MSList *el=ms_list_find(lc->friends,(void *)fl);
        if (el!=NULL){
-               lc->friends=ms_list_remove_link(lc->friends,el);
                linphone_friend_destroy((LinphoneFriend*)el->data);
+               lc->friends=ms_list_remove_link(lc->friends,el);
                linphone_core_write_friends_config(lc);
        }
 }
@@ -432,13 +435,19 @@ static bool_t username_match(const char *u1, const char *u2){
 LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *uri){
        LinphoneAddress *puri=linphone_address_new(uri);
        const MSList *elem;
-       const char *username=linphone_address_get_username(puri);
-       const char *domain=linphone_address_get_domain(puri);
+       const char *username;
+       const char *domain;
        LinphoneFriend *lf=NULL;
                
        if (puri==NULL){
                return NULL;
        }
+       username=linphone_address_get_username(puri);
+       domain=linphone_address_get_domain(puri);
+       if (domain==NULL) {
+               linphone_address_destroy(puri);
+               return NULL;
+       }
        for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){
                lf=(LinphoneFriend*)elem->data;
                const char *it_username=linphone_address_get_username(lf->uri);