implement chat notification on Linux

This commit is contained in:
Margaux Clerc 2012-09-10 11:12:53 +02:00
parent f815b0d5aa
commit 2c7cc3a261
3 changed files with 16 additions and 3 deletions

View 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")),

View 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();

View 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();