From 2c7cc3a261764fa65a31d177cba6c31b7ae249fd Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Mon, 10 Sep 2012 11:12:53 +0200 Subject: [PATCH] implement chat notification on Linux --- gtk/chat.c | 14 ++++++++++++-- gtk/linphone.h | 1 + gtk/main.c | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gtk/chat.c b/gtk/chat.c index cb866a92..aa1e7dff 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -112,14 +112,24 @@ void linphone_gtk_send_text(GtkWidget *button){ } void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message){ - GtkWidget *w=(GtkWidget*)linphone_chat_room_get_user_data(room); + GtkWidget *w=(GtkWidget*)linphone_chat_room_get_user_data(room); if (w==NULL){ w=linphone_gtk_init_chatroom(room,linphone_address_as_string_uri_only(from)); + g_object_set_data(G_OBJECT(w),"is_notified",GINT_TO_POINTER(FALSE)); } #ifdef HAVE_GTK_OSX - /* Notify when a new message is send */ + /* Notified when a new message is sent */ linphone_gtk_status_icon_set_blinking(TRUE); + #else + if (!gtk_window_is_active((GtkWindow*)w)){ + if(!GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"is_notified"))){ + linphone_gtk_notify(NULL,message); + 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)); + } #endif linphone_gtk_push_text(GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textlog")), diff --git a/gtk/linphone.h b/gtk/linphone.h index f817969f..97a4400c 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -98,6 +98,7 @@ void * linphone_gtk_wait(LinphoneCore *lc, void *ctx, LinphoneWaitingState ws, c void linphone_gtk_show_directory_search(void); void linphone_gtk_status_icon_set_blinking(gboolean val); +void linphone_gtk_notify(LinphoneCall *call, const char *msg); /*functions controlling the different views*/ gboolean linphone_gtk_use_in_call_view(); diff --git a/gtk/main.c b/gtk/main.c index 2085e3d2..19380325 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1029,18 +1029,20 @@ static void make_notification(const char *title, const char *body){ #endif -static void linphone_gtk_notify(LinphoneCall *call, const char *msg){ +void linphone_gtk_notify(LinphoneCall *call, const char *msg){ #ifdef HAVE_NOTIFY if (!notify_is_initted()) if (!notify_init ("Linphone")) ms_error("Libnotify failed to init."); #endif if (!call) { + #ifdef HAVE_NOTIFY if (!notify_notification_show(notify_notification_new("Linphone",msg,NULL #ifdef HAVE_NOTIFY1 ,NULL #endif ),NULL)) + ms_error("Failed to send notification."); #else linphone_gtk_show_main_window(); -- 2.39.2