From c3e3178942f92d98d06d05a7c5e0e88095019dc4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 10 Nov 2015 15:13:36 +0100 Subject: [PATCH] Fix bug 0002636: Don't know who sent a chat message from a notification. --- gtk/chat.c | 2 +- gtk/linphone.h | 2 +- gtk/main.c | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gtk/chat.c b/gtk/chat.c index e1533b117..d098d52b9 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -620,7 +620,7 @@ void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room, #else if ( !gtk_window_is_active ( GTK_WINDOW ( main_window ) ) ) { if ( !GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( w ),"is_notified" ) ) ) { - linphone_gtk_notify ( NULL,linphone_chat_message_get_text ( msg ) ); + linphone_gtk_notify ( NULL, msg, NULL ); g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( TRUE ) ); } else { g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( FALSE ) ); diff --git a/gtk/linphone.h b/gtk/linphone.h index fd7dd074f..6bb1382b3 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -146,7 +146,7 @@ LINPHONE_PUBLIC void linphone_gtk_terminate_call(GtkWidget *button); LINPHONE_PUBLIC void linphone_gtk_call_update_tab_header(LinphoneCall *call, gboolean pause); LINPHONE_PUBLIC void linphone_gtk_show_directory_search(void); LINPHONE_PUBLIC void linphone_gtk_status_icon_set_blinking(gboolean val); -LINPHONE_PUBLIC void linphone_gtk_notify(LinphoneCall *call, const char *msg); +LINPHONE_PUBLIC void linphone_gtk_notify(LinphoneCall *call, LinphoneChatMessage *chat_message, const char *msg); LINPHONE_PUBLIC void linphone_gtk_load_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *uri, GtkWidget *chat_view); LINPHONE_PUBLIC void linphone_gtk_send_text(); diff --git a/gtk/main.c b/gtk/main.c index 7bc36b416..94ac81928 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1220,21 +1220,26 @@ static void make_notification(const char *title, const char *body){ #endif -void linphone_gtk_notify(LinphoneCall *call, const char *msg){ +void linphone_gtk_notify(LinphoneCall *call, LinphoneChatMessage *chat_message, const char *msg){ #ifdef HAVE_NOTIFY if (!notify_is_initted()) if (!notify_init ("Linphone")) ms_error("Libnotify failed to init."); #endif if (!call) { - + if (chat_message) { + const LinphoneAddress *address = linphone_chat_message_get_peer_address(chat_message); + char *remote = linphone_address_as_string(address); + make_notification(remote, linphone_chat_message_get_text(chat_message)); + } else { #ifdef HAVE_NOTIFY - if (!notify_notification_show(notify_notification_new("Linphone",msg,NULL + if (!notify_notification_show(notify_notification_new("Linphone",msg,NULL #ifdef HAVE_NOTIFY1 - ,NULL + ,NULL #endif -),NULL)) - + ),NULL)) { ms_error("Failed to send notification."); + } + } #else linphone_gtk_show_main_window(); #endif @@ -1389,7 +1394,7 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call default: break; } - linphone_gtk_notify(call, msg); + linphone_gtk_notify(call, NULL, msg); linphone_gtk_update_call_buttons (call); } @@ -1952,7 +1957,7 @@ void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to){ GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget( linphone_gtk_get_main_window(), "uribar")); char *text; - linphone_gtk_notify(NULL,(text=ms_strdup_printf(_("We are transferred to %s"),refer_to))); + linphone_gtk_notify(NULL,NULL,(text=ms_strdup_printf(_("We are transferred to %s"),refer_to))); g_free(text); gtk_entry_set_text(uri_bar, refer_to); linphone_gtk_start_call(linphone_gtk_get_main_window());