From 9e6b47328461d2eb307023d3d3b133bc3bc0c40f Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Tue, 4 Sep 2012 16:17:47 +0200 Subject: [PATCH] implement incoming chat notification on Mac --- gtk/chat.c | 14 +++++++++++++- gtk/linphone.h | 2 ++ gtk/main.c | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gtk/chat.c b/gtk/chat.c index 0dafbdb9..4138f672 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -19,6 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" + +#ifdef HAVE_GTK_OSX +#include +#endif + GtkWidget * linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const char *with){ GtkWidget *w; GtkTextBuffer *b; @@ -37,6 +42,7 @@ GtkWidget * linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const char *with){ } void linphone_gtk_create_chatroom(const char *with){ + LinphoneChatRoom *cr=linphone_core_create_chat_room(linphone_gtk_get_core(),with); if (!cr) return; linphone_gtk_init_chatroom(cr,with); @@ -101,9 +107,15 @@ 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); - if (w==NULL){ + if (w==NULL){ w=linphone_gtk_init_chatroom(room,linphone_address_as_string_uri_only(from)); } + + #ifdef HAVE_GTK_OSX + /* Notify when a new message is send */ + linphone_gtk_status_icon_set_blinking(TRUE); + #endif + linphone_gtk_push_text(GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textlog")), linphone_address_as_string_uri_only(from), message,FALSE); diff --git a/gtk/linphone.h b/gtk/linphone.h index d4cafe28..f817969f 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -97,6 +97,8 @@ 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); + /*functions controlling the different views*/ gboolean linphone_gtk_use_in_call_view(); LinphoneCall *linphone_gtk_get_currently_displayed_call(gboolean *is_conf); diff --git a/gtk/main.c b/gtk/main.c index 2955b3ec..2085e3d2 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -65,10 +65,11 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call static void linphone_gtk_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t enabled, const char *token); static void linphone_gtk_transfer_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate); static gboolean linphone_gtk_auto_answer(LinphoneCall *call); -static void linphone_gtk_status_icon_set_blinking(gboolean val); +void linphone_gtk_status_icon_set_blinking(gboolean val); void _linphone_gtk_enable_video(gboolean val); + static gboolean verbose=0; static gboolean auto_answer = 0; static gchar * addr_to_call = NULL; @@ -1347,7 +1348,7 @@ static gboolean do_icon_blink(GtkStatusIcon *gi){ #endif -static void linphone_gtk_status_icon_set_blinking(gboolean val){ +void linphone_gtk_status_icon_set_blinking(gboolean val){ #ifdef HAVE_GTK_OSX static gint attention_id; GtkOSXApplication *theMacApp=(GtkOSXApplication*)g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); -- 2.39.2