Commit 1cb1d7c5 authored by Ghislain MARY's avatar Ghislain MARY

Allow friends to be added to a friend list even if they do not have a SIP address.

parent 3be8c6bd
......@@ -1829,13 +1829,13 @@ linphonec_proxy_use(LinphoneCore *lc, int index)
static void
linphonec_friend_display(LinphoneFriend *fr)
{
LinphoneAddress *uri=linphone_friend_get_address(fr);
char *str;
LinphoneAddress *addr = linphone_friend_get_address(fr);
char *str = NULL;
linphonec_out("name: %s\n", linphone_address_get_display_name(uri));
linphone_address_set_display_name(uri,NULL);
str=linphone_address_as_string(uri);
linphonec_out("name: %s\n", linphone_friend_get_name(fr));
if (addr) str = linphone_address_as_string_uri_only(addr);
linphonec_out("address: %s\n", str);
if (str) ms_free(str);
}
static int
......@@ -1853,15 +1853,8 @@ linphonec_friend_list(LinphoneCore *lc, char *pat)
for(n=0; friend!=NULL; friend=bctbx_list_next(friend), ++n )
{
if ( pat ) {
LinphoneAddress *addr = linphone_friend_get_address((LinphoneFriend*)friend->data);
if (addr) {
const char *name = linphone_address_get_display_name(addr);
if (name && ! strstr(name, pat) ) {
linphone_address_unref(addr);
continue;
}
linphone_address_unref(addr);
}
const char *name = linphone_friend_get_name((LinphoneFriend *)friend->data);
if (name && !strstr(name, pat)) continue;
}
linphonec_out("****** Friend %i *******\n",n);
linphonec_friend_display((LinphoneFriend*)friend->data);
......@@ -1883,11 +1876,15 @@ linphonec_friend_call(LinphoneCore *lc, unsigned int num)
{
int ret;
LinphoneAddress *addr = linphone_friend_get_address((LinphoneFriend*)friend->data);
addr_str = linphone_address_as_string(addr);
ret=lpc_cmd_call(lc, addr_str);
ms_free(addr_str);
linphone_address_unref(addr);
return ret;
if (addr) {
addr_str = linphone_address_as_string(addr);
ret=lpc_cmd_call(lc, addr_str);
ms_free(addr_str);
linphone_address_unref(addr);
return ret;
} else {
linphonec_out("Friend %u does not have an address\n", num);
}
}
}
linphonec_out("No such friend %u\n", num);
......
......@@ -158,22 +158,24 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
LinphoneCore *lc=fr->lc;
LinphoneAddress *addr = linphone_friend_get_address(fr);
if (fr->outsub==NULL){
/* people for which we don't have yet an answer should appear as offline */
fr->presence_models = bctbx_list_free_with_data(fr->presence_models, (bctbx_list_free_func)free_friend_presence);
/*
if (fr->lc->vtable.notify_recv)
fr->lc->vtable.notify_recv(fr->lc,(LinphoneFriend*)fr);
*/
}else{
sal_op_release(fr->outsub);
fr->outsub=NULL;
}
fr->outsub=sal_op_new(lc->sal);
linphone_configure_op(lc,fr->outsub,addr,NULL,TRUE);
sal_subscribe_presence(fr->outsub,NULL,NULL,lp_config_get_int(lc->config,"sip","subscribe_expires",600));
fr->subscribe_active=TRUE;
linphone_address_unref(addr);
if (addr != NULL) {
if (fr->outsub==NULL){
/* people for which we don't have yet an answer should appear as offline */
fr->presence_models = bctbx_list_free_with_data(fr->presence_models, (bctbx_list_free_func)free_friend_presence);
/*
if (fr->lc->vtable.notify_recv)
fr->lc->vtable.notify_recv(fr->lc,(LinphoneFriend*)fr);
*/
}else{
sal_op_release(fr->outsub);
fr->outsub=NULL;
}
fr->outsub=sal_op_new(lc->sal);
linphone_configure_op(lc,fr->outsub,addr,NULL,TRUE);
sal_subscribe_presence(fr->outsub,NULL,NULL,lp_config_get_int(lc->config,"sip","subscribe_expires",600));
fr->subscribe_active=TRUE;
linphone_address_unref(addr);
}
}
LinphoneFriend * linphone_friend_new(void){
......@@ -671,16 +673,18 @@ void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *
if (only_when_registered && (fr->subscribe || fr->subscribe_active)){
LinphoneAddress *addr = linphone_friend_get_address(fr);
LinphoneProxyConfig *cfg=linphone_core_lookup_known_proxy(fr->lc, addr);
if (proxy && proxy!=cfg) return;
if (cfg && cfg->state!=LinphoneRegistrationOk){
char *tmp=linphone_address_as_string(addr);
ms_message("Friend [%s] belongs to proxy config with identity [%s], but this one isn't registered. Subscription is suspended.",
tmp,linphone_proxy_config_get_identity(cfg));
ms_free(tmp);
can_subscribe=0;
if (addr != NULL) {
LinphoneProxyConfig *cfg=linphone_core_lookup_known_proxy(fr->lc, addr);
if (proxy && proxy!=cfg) return;
if (cfg && cfg->state!=LinphoneRegistrationOk){
char *tmp=linphone_address_as_string(addr);
ms_message("Friend [%s] belongs to proxy config with identity [%s], but this one isn't registered. Subscription is suspended.",
tmp,linphone_proxy_config_get_identity(cfg));
ms_free(tmp);
can_subscribe=0;
}
linphone_address_unref(addr);
}
linphone_address_unref(addr);
}
if (can_subscribe && fr->subscribe && fr->subscribe_active==FALSE){
ms_message("Sending a new SUBSCRIBE");
......@@ -1166,7 +1170,7 @@ static void linphone_create_table(sqlite3* db) {
ret = sqlite3_exec(db,"CREATE TABLE IF NOT EXISTS friends ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"friend_list_id INTEGER,"
"sip_uri TEXT NOT NULL,"
"sip_uri TEXT,"
"subscribe_policy INTEGER,"
"send_subscribe INTEGER,"
"ref_key TEXT,"
......@@ -1196,7 +1200,26 @@ static void linphone_create_table(sqlite3* db) {
}
static void linphone_update_table(sqlite3* db) {
char *errmsg = NULL;
int ret = sqlite3_exec(db,
"PRAGMA writable_schema = 1;\n"
"UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE friends ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
"friend_list_id INTEGER,"
"sip_uri TEXT,"
"subscribe_policy INTEGER,"
"send_subscribe INTEGER,"
"ref_key TEXT,"
"vCard TEXT,"
"vCard_etag TEXT,"
"vCard_url TEXT,"
"presence_received INTEGER"
")' WHERE NAME = 'friends';\n"
"PRAGMA writable_schema = 0;", 0, 0, &errmsg);
if (ret != SQLITE_OK) {
ms_error("Error altering table friends: %s.\n", errmsg);
sqlite3_free(errmsg);
}
}
void linphone_core_friends_storage_init(LinphoneCore *lc) {
......@@ -1372,7 +1395,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) {
if (linphone_core_vcard_supported()) vcard = linphone_friend_get_vcard(lf);
addr = linphone_friend_get_address(lf);
addr_str = linphone_address_as_string(addr);
if (addr != NULL) addr_str = linphone_address_as_string(addr);
if (lf->storage_id > 0) {
buf = sqlite3_mprintf("UPDATE friends SET friend_list_id=%u,sip_uri=%Q,subscribe_policy=%i,send_subscribe=%i,ref_key=%Q,vCard=%Q,vCard_etag=%Q,vCard_url=%Q,presence_received=%i WHERE (id = %u);",
lf->friend_list->storage_id,
......@@ -1399,8 +1422,8 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) {
lf->presence_received
);
}
ms_free(addr_str);
linphone_address_unref(addr);
if (addr_str != NULL) ms_free(addr_str);
if (addr != NULL) linphone_address_unref(addr);
linphone_sql_request_generic(lc->friends_db, buf);
sqlite3_free(buf);
......
......@@ -444,18 +444,16 @@ void linphone_friend_list_set_rls_uri(LinphoneFriendList *list, const char *rls_
static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
LinphoneFriendListStatus status = LinphoneFriendListInvalidFriend;
LinphoneAddress *addr = linphone_friend_get_address(lf);
LinphoneAddress *addr;
if (!list || !addr || lf->friend_list) {
if (!list || lf->friend_list) {
if (!list)
ms_error("linphone_friend_list_add_friend(): invalid list, null");
if (!addr)
ms_error("linphone_friend_list_add_friend(): invalid friend, no sip uri");
if (lf->friend_list)
ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
if (addr) linphone_address_unref(addr);
return status;
}
addr = linphone_friend_get_address(lf);
if (bctbx_list_find(list->friends, lf) != NULL) {
char *tmp = NULL;
if (addr) tmp = linphone_address_as_string(addr);
......@@ -482,16 +480,11 @@ LinphoneFriendListStatus linphone_friend_list_add_local_friend(LinphoneFriendLis
}
LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize) {
LinphoneAddress *addr = linphone_friend_get_address(lf);
if (!addr || lf->friend_list) {
if (!addr)
ms_error("linphone_friend_list_add_friend(): invalid friend, no sip uri");
if (lf->friend_list) {
if (lf->friend_list)
ms_error("linphone_friend_list_add_friend(): invalid friend, already in list");
if (addr) linphone_address_unref(addr);
return LinphoneFriendListInvalidFriend;
}
linphone_address_unref(addr);
lf->friend_list = list;
lf->lc = list->lc;
list->friends = bctbx_list_append(list->friends, linphone_friend_ref(lf));
......@@ -952,8 +945,6 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list
if (vcard) {
const char *vcard_text = linphone_vcard_as_vcard4_string(vcard);
fprintf(file, "%s", vcard_text);
} else {
ms_warning("Couldn't export friend %s because it doesn't have a vCard attached", linphone_address_as_string(linphone_friend_get_address(lf)));
}
friends = bctbx_list_next(friends);
}
......
......@@ -51,20 +51,24 @@ static void stop(int signum){
* presence state change notification callback
*/
static void notify_presence_recv_updated (LinphoneCore *lc, LinphoneFriend *friend) {
const LinphonePresenceModel* model = linphone_friend_get_presence_model(friend);
LinphoneAddress* friend_address = linphone_friend_get_address(friend);
LinphonePresenceActivity *activity = linphone_presence_model_get_activity(model);
char *activity_str = linphone_presence_activity_to_string(activity);
printf("New state state [%s] for user id [%s] \n"
,activity_str
,linphone_address_as_string (friend_address));
linphone_address_unref(friend_address);
if (friend_address != NULL) {
const LinphonePresenceModel* model = linphone_friend_get_presence_model(friend);
LinphonePresenceActivity *activity = linphone_presence_model_get_activity(model);
char *activity_str = linphone_presence_activity_to_string(activity);
printf("New state state [%s] for user id [%s] \n"
,activity_str
,linphone_address_as_string (friend_address));
linphone_address_unref(friend_address);
}
}
static void new_subscription_requested (LinphoneCore *lc, LinphoneFriend *friend, const char* url) {
LinphoneAddress* friend_address = linphone_friend_get_address(friend);
printf(" [%s] wants to see your status, accepting\n"
,linphone_address_as_string (friend_address));
linphone_address_unref(friend_address);
if (friend_address != NULL) {
printf(" [%s] wants to see your status, accepting\n"
,linphone_address_as_string (friend_address));
linphone_address_unref(friend_address);
}
linphone_friend_edit(friend); /* start editing friend */
linphone_friend_set_inc_subscribe_policy(friend,LinphoneSPAccept); /* Accept incoming subscription request for this friend*/
linphone_friend_done(friend); /*commit change*/
......
......@@ -1483,10 +1483,12 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO
lc->subscribers=bctbx_list_append(lc->subscribers,fl);
addr = linphone_friend_get_address(fl);
tmp = linphone_address_as_string(addr);
linphone_core_notify_new_subscription_requested(lc,fl,tmp);
ms_free(tmp);
linphone_address_unref(addr);
if (addr != NULL) {
tmp = linphone_address_as_string(addr);
linphone_core_notify_new_subscription_requested(lc,fl,tmp);
ms_free(tmp);
linphone_address_unref(addr);
}
}
void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf){
......@@ -1907,19 +1909,21 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa
if (lf!=NULL){
LinphonePresenceActivity *activity = NULL;
char *activity_str;
friend=linphone_friend_get_address(lf);
tmp=linphone_address_as_string(friend);
activity = linphone_presence_model_get_activity(presence);
activity_str = linphone_presence_activity_to_string(activity);
ms_message("We are notified that [%s] has presence [%s]", tmp, activity_str);
if (activity_str != NULL) ms_free(activity_str);
friend=linphone_friend_get_address(lf);
if (friend != NULL) {
tmp=linphone_address_as_string(friend);
activity_str = linphone_presence_activity_to_string(activity);
ms_message("We are notified that [%s] has presence [%s]", tmp, activity_str);
if (activity_str != NULL) ms_free(activity_str);
ms_free(tmp);
linphone_address_unref(friend);
}
linphone_friend_set_presence_model(lf, presence);
lf->subscribe_active=TRUE;
lf->presence_received = TRUE;
lf->out_sub_state = linphone_subscription_state_from_sal(ss);
linphone_core_notify_notify_presence_received(lc,(LinphoneFriend*)lf);
linphone_address_unref(friend);
ms_free(tmp);
if (op != lf->outsub){
/*case of a NOTIFY received out of any dialog*/
sal_op_release(op);
......
......@@ -316,12 +316,9 @@ void linphone_gtk_call_log_update(GtkWidget *w){
#endif
lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr);
if(lf != NULL){
LinphoneAddress *address = linphone_friend_get_address(lf);
if ((display=linphone_address_get_display_name(address))) {
/*update display name from friend*/
linphone_address_set_display_name(la,display);
}
linphone_address_unref(address);
/*update display name from friend*/
const char *name = linphone_friend_get_name(lf);
if (name != NULL) linphone_address_set_display_name(la, name);
} else {
display=linphone_address_get_display_name(la);
}
......
......@@ -93,9 +93,11 @@ static void linphone_gtk_set_selection_to_uri_bar(GtkTreeView *treeview){
LinphoneAddress *addr;
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
addr = linphone_friend_get_address(lf);
friend=linphone_address_as_string(addr);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),friend);
linphone_address_unref(addr);
if (addr) {
friend=linphone_address_as_string(addr);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),friend);
linphone_address_unref(addr);
}
ms_free(friend);
}
}
......@@ -180,9 +182,13 @@ gboolean linphone_gtk_on_key_press(GtkWidget *widget, GdkEvent *event, gpointer
LinphoneAddress *addr;
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
addr = linphone_friend_get_address(lf);
if (lf != NULL) linphone_gtk_friend_list_set_chat_conversation(addr);
linphone_address_unref(addr);
if (lf != NULL) {
addr = linphone_friend_get_address(lf);
if (addr != NULL) {
linphone_gtk_friend_list_set_chat_conversation(addr);
linphone_address_unref(addr);
}
}
if (cr != NULL){
linphone_gtk_mark_chat_read(cr);
linphone_gtk_friend_list_update_button_display(GTK_TREE_VIEW(friendlist));
......@@ -218,18 +224,20 @@ void linphone_gtk_delete_history(GtkWidget *button){
if(chat_view!=NULL){
const LinphoneAddress *from=linphone_gtk_friend_list_get_active_address();
LinphoneAddress *addr=linphone_friend_get_address(lf);
if(linphone_address_weak_equal(from,addr)){
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *text_buffer;
text_buffer=gtk_text_view_get_buffer(text_view);
gtk_text_buffer_get_bounds(text_buffer, &start, &end);
gtk_text_buffer_delete (text_buffer, &start, &end);
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
if (addr != NULL) {
if(linphone_address_weak_equal(from,addr)){
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *text_buffer;
text_buffer=gtk_text_view_get_buffer(text_view);
gtk_text_buffer_get_bounds(text_buffer, &start, &end);
gtk_text_buffer_delete (text_buffer, &start, &end);
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
}
linphone_address_unref(addr);
}
linphone_address_unref(addr);
}
linphone_gtk_show_friends();
}
......@@ -334,17 +342,19 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
LinphoneAddress *addr;
gtk_tree_model_get(model, &iter,FRIEND_ID , &lf, -1);
addr=linphone_friend_get_address(lf);
if (linphone_address_weak_equal(addr,la)){
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
if(cr==NULL){
cr=linphone_gtk_create_chatroom(addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
if (addr != NULL) {
if (linphone_address_weak_equal(addr,la)){
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
if(cr==NULL){
cr=linphone_gtk_create_chatroom(addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
}
linphone_gtk_friend_list_set_active_address(addr);
gtk_tree_selection_select_iter(selection, &iter);
break;
}
linphone_gtk_friend_list_set_active_address(addr);
gtk_tree_selection_select_iter(selection, &iter);
break;
linphone_address_unref(addr);
}
linphone_address_unref(addr);
}while(gtk_tree_model_iter_next(model,&iter));
}
}
......@@ -397,22 +407,24 @@ void linphone_gtk_chat_selected(GtkWidget *item){
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
addr=linphone_friend_get_address(lf);
if(cr==NULL){
cr=linphone_gtk_create_chatroom(addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
}
page=GTK_WIDGET(g_object_get_data(G_OBJECT(friendlist),"chatview"));
linphone_gtk_friend_list_set_active_address(addr);
if(page==NULL){
page=linphone_gtk_init_chatroom(cr,addr);
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)page);
} else {
linphone_gtk_load_chatroom(cr,addr,page);
if (addr != NULL) {
if(cr==NULL){
cr=linphone_gtk_create_chatroom(addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
}
page=GTK_WIDGET(g_object_get_data(G_OBJECT(friendlist),"chatview"));
linphone_gtk_friend_list_set_active_address(addr);
if(page==NULL){
page=linphone_gtk_init_chatroom(cr,addr);
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)page);
} else {
linphone_gtk_load_chatroom(cr,addr,page);
}
linphone_address_unref(addr);
linphone_gtk_mark_chat_read(cr);
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
}
linphone_address_unref(addr);
linphone_gtk_mark_chat_read(cr);
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
}
}
......@@ -596,9 +608,12 @@ static int get_friend_weight(const LinphoneFriend *lf){
int w=0;
LinphoneCore *lc=linphone_gtk_get_core();
LinphoneAddress *addr = linphone_friend_get_address(lf);
LinphoneChatRoom *cr=linphone_core_get_chat_room(lc, addr);
LinphoneChatRoom *cr;
linphone_address_unref(addr);
if (addr != NULL) {
cr = linphone_core_get_chat_room(lc, addr);
linphone_address_unref(addr);
}
if (cr && linphone_chat_room_get_unread_messages_count(cr)>0){
w+=2000;
}
......@@ -627,6 +642,9 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend *
LinphoneAddress *addr1,*addr2;
addr1=linphone_friend_get_address(lf1);
addr2=linphone_friend_get_address(lf2);
if ((addr1 == NULL) && (addr2 == NULL)) return 0;
if ((addr1 == NULL) && (addr2 != NULL)) return -1;
if ((addr1 != NULL) && (addr2 == NULL)) return 1;
u1=linphone_address_get_display_name(addr1) ? linphone_address_get_display_name(addr1) : linphone_address_get_username(addr1);
u2=linphone_address_get_display_name(addr2) ? linphone_address_get_display_name(addr2) : linphone_address_get_username(addr2);
if (u1 && u2) {
......@@ -760,15 +778,16 @@ void linphone_gtk_show_friends(void){
for(itf=sorted;itf!=NULL;itf=bctbx_list_next(itf)){
LinphoneFriend *lf=(LinphoneFriend*)itf->data;
LinphoneAddress *f_addr=linphone_friend_get_address(lf);
char *uri=linphone_address_as_string(f_addr);
const char *name=linphone_friend_get_name(lf);
char *uri = NULL;
const char *display=name;
char *escaped=NULL;
int nbmsg=0;
//BuddyInfo *bi;
gboolean send_subscribe=linphone_friend_get_send_subscribe(lf);
if (display==NULL || display[0]=='\0') {
if (f_addr != NULL) uri = linphone_address_as_string(f_addr);
if ((display==NULL || display[0]=='\0') && (f_addr != NULL)) {
display=linphone_address_get_username(f_addr);
}
gtk_list_store_append(store,&iter);
......@@ -776,18 +795,20 @@ void linphone_gtk_show_friends(void){
FRIEND_PRESENCE_IMG, send_subscribe ? status_to_icon_name(linphone_friend_get_status(lf)) : NULL,
FRIEND_CHAT,"linphone-chat-nothing", -1);
cr=linphone_gtk_create_chatroom(f_addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
nbmsg=linphone_chat_room_get_unread_messages_count(cr);
if(nbmsg != 0){
gtk_list_store_set(store,&iter,FRIEND_CHAT,"linphone-chat-new-message",
FRIEND_CHAT_BUTTON_VISIBLE, TRUE, -1);
if (f_addr != NULL) {
cr=linphone_gtk_create_chatroom(f_addr);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
nbmsg=linphone_chat_room_get_unread_messages_count(cr);
if(nbmsg != 0){
gtk_list_store_set(store,&iter,FRIEND_CHAT,"linphone-chat-new-message",
FRIEND_CHAT_BUTTON_VISIBLE, TRUE, -1);
}
escaped=g_markup_escape_text(uri,-1);
gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1);
g_free(escaped);
linphone_address_unref(f_addr);
ms_free(uri);
}
escaped=g_markup_escape_text(uri,-1);
gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1);
g_free(escaped);
linphone_address_unref(f_addr);
ms_free(uri);
}
bctbx_list_free(sorted);
}
......@@ -798,12 +819,14 @@ void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){
const char *name = linphone_friend_get_name(lf);
LinphoneAddress *f_addr = linphone_friend_get_address(lf);
uri=linphone_address_as_string_uri_only(f_addr);
if (uri) {
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address")),uri);
ms_free(uri);
if (f_addr != NULL) {
uri=linphone_address_as_string_uri_only(f_addr);
if (uri) {
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address")),uri);
ms_free(uri);
}
linphone_address_unref(f_addr);
}
linphone_address_unref(f_addr);
if (name){
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"name")),name);
......
......@@ -37,12 +37,14 @@ static LinphoneCoreManager* presence_linphone_core_manager_new(char* username) {
void new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url){
LinphoneAddress *addr = linphone_friend_get_address(lf);
char* from=linphone_address_as_string(addr);
stats* counters;
ms_message("New subscription request from [%s] url [%s]",from,url);
linphone_address_unref(addr);
ms_free(from);
LinphoneAddress *addr = linphone_friend_get_address(lf);
if (addr != NULL) {
char* from=linphone_address_as_string(addr);
ms_message("New subscription request from [%s] url [%s]",from,url);
linphone_address_unref(addr);
ms_free(from);
}
counters = get_stats(lc);
counters->number_of_NewSubscriptionRequest++;
linphone_core_add_friend(lc,lf); /*accept subscription*/
......@@ -52,10 +54,12 @@ void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) {
stats* counters;
unsigned int i;
LinphoneAddress *addr = linphone_friend_get_address(lf);
char* from=linphone_address_as_string(addr);
ms_message("New Notify request from [%s] ",from);
linphone_address_unref(addr);
ms_free(from);
if (addr != NULL) {
char* from=linphone_address_as_string(addr);
ms_message("New Notify request from [%s] ",from);
linphone_address_unref(addr);
ms_free(from);
}
counters = get_stats(lc);
counters->number_of_NotifyPresenceReceived++;
counters->last_received_presence = linphone_friend_get_presence_model(lf);
......
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