]> sjero.net Git - linphone/commitdiff
implement chat notification on Linux
authorMargaux Clerc <margaux.clerc@belledonne-communications>
Mon, 10 Sep 2012 09:12:53 +0000 (11:12 +0200)
committerMargaux Clerc <margaux.clerc@belledonne-communications>
Mon, 10 Sep 2012 09:13:20 +0000 (11:13 +0200)
gtk/chat.c
gtk/linphone.h
gtk/main.c

index cb866a92f38219f3577a8482e141143fa7990e87..aa1e7dff677ab3d9c10741614a9d466111d8f9cf 100644 (file)
@@ -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")),
index f817969f7bfc63dfca552e0343755fba6638a332..97a4400c75dbd180fbe019651a4b294f01256190 100644 (file)
@@ -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();
index 2085e3d20b6c89c2ada209e217a62911caa9f048..1938032563aad51cb1ca011251802f40ac2b285c 100644 (file)
@@ -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();