Commit 439a157d authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Add libnotify notification on incoming call

parent 4744c466
......@@ -3,6 +3,7 @@ bin_PROGRAMS = sflphone-gtk
sflphone_gtk_SOURCES = \
main.c \
dbus.c \
SFLnotify.c \
mainwindow.c \
calllist.c \
dialpad.c \
......@@ -20,11 +21,11 @@ sflphone_gtk_SOURCES = \
glwidget.c \
MemManager.c
noinst_HEADERS = actions.h dbus.h mainwindow.h calllist.h dialpad.h codeclist.h\
noinst_HEADERS = actions.h dbus.h SFLnotify.h mainwindow.h calllist.h dialpad.h codeclist.h\
callmanager-glue.h configurationmanager-glue.h instance-glue.h menus.h calltree.h screen.h configwindow.h \
accountlist.h accountwindow.h marshaller.h sliders.h statusicon.h
EXTRA_DIST = marshaller.list
sflphone_gtk_LDADD = $(DEPS_LIBS)
sflphone_gtk_LDADD = $(DEPS_LIBS) -lnotify
AM_CPPFLAGS = $(DEPS_CFLAGS) \
-DICONS_DIR=\""$(datadir)/sflphone"\" \
......
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <SFLnotify.h>
static NotifyNotification *notification;
void
notify_incoming_call( call_t* c )
{
GdkPixbuf *pixbuf;
gchar* callerid;
gchar* title;
notify_init("sflphone");
title = g_markup_printf_escaped(_("%s account: %s") ,
g_hash_table_lookup(account_list_get_by_id(c->accountID)->properties , ACCOUNT_TYPE) ,
g_hash_table_lookup(account_list_get_by_id(c->accountID)->properties , ACCOUNT_ALIAS) ) ;
callerid = g_markup_printf_escaped(_("<i>From:</i> %s") , c->from);
//pixbuf = gdk_pixbuf_new_from_file(ICON_DIR "/sflphone.png", NULL);
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
notification = notify_notification_new( title,
callerid,
NULL,
NULL);
notify_notification_set_urgency( notification , NOTIFY_URGENCY_NORMAL );
notify_notification_set_icon_from_pixbuf (notification, pixbuf);
notify_notification_attach_to_status_icon( notification , get_status_icon() );
notify_notification_set_timeout( notification , (( g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER ));
g_object_set_data( G_OBJECT( notification ) , "call" , c );
notify_notification_add_action( notification , "accept" , _("Accept") , (NotifyActionCallback) answer_call_cb , NULL, NULL );
notify_notification_add_action( notification , "refuse" , _("Refuse") , (NotifyActionCallback) refuse_call_cb , NULL , NULL );
notify_notification_add_action( notification , "ignore" , _("Ignore") , (NotifyActionCallback) ignore_call_cb , NULL , NULL );
if (!notify_notification_show (notification, NULL)) {
g_print("notify(), failed to send notification\n");
}
}
void
answer_call_cb( NotifyNotification *notification, gchar *action, gpointer data )
{
call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" );
dbus_accept(c);
#ifdef __POPUP_WINDOW
status_icon_unminimize();
#endif
g_object_unref( notification );
}
void
refuse_call_cb( NotifyNotification *notification, gchar *action, gpointer data )
{
call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" );
dbus_refuse(c);
g_object_unref( notification );
}
void
ignore_call_cb( NotifyNotification *notification, gchar *action, gpointer data )
{
call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" );
g_object_unref( notification );
}
/*
* Copyright (C) 2008 Savoir-Faire Linux inc.
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFL_NOTIFY_H__
#define __SFL_NOTIFY_H__
#include <libnotify/notify.h>
#include <accountlist.h>
#include <calllist.h>
#include <dbus.h>
#include <actions.h>
#include <statusicon.h>
#define __TIMEOUT_MODE "default"
#define __TIMEOUT_TIME 30000 // 30 secondes
#define __POPUP_WINDOW true
/*
* Notify an incoming call with the libnotify notification library
* A dialog box appears near the status icon
* @param c The incoming call
*/
void notify_incoming_call( call_t* c);
/*
* Callback when answer button is pressed.
* Action: Pick up the incoming call
* @param notification The pointer on the notification structure
* @param data The data associated. Here: call_t*
*/
void answer_call_cb( NotifyNotification *notification, gchar *action, gpointer data );
/*
* Callback when refuse button is pressed
* Action: hang up the incoming call
* @param notification The pointer on the notification structure
* @param data The data associated. Here: call_t*
*/
void refuse_call_cb( NotifyNotification *notification, gchar *action, gpointer data );
/*
* Callback when ignore button is pressed
* Action: nothing - The call continues ringing
* @param notification The pointer on the notification structure
* @param data The data associated. Here: call_t*
*/
void ignore_call_cb( NotifyNotification *notification, gchar *action, gpointer data );
#endif
......@@ -49,9 +49,9 @@ sflphone_notify_voice_mail (guint count)
{
gchar * message = g_new0(gchar, 50);
if( count > 1)
g_sprintf(message, _("%d new voice mails"), count);
g_sprintf(message, _("%d voice mails"), count);
else
g_sprintf(message, _("%d new voice mail"), count);
g_sprintf(message, _("%d voice mail"), count);
status_bar_message_add(message, __MSG_VOICE_MAILS);
g_free(message);
}
......@@ -60,13 +60,15 @@ sflphone_notify_voice_mail (guint count)
void
status_bar_display_account( call_t* c)
{
gchar* msg = malloc(100);
gchar* msg;
account_t* acc;
if(c->accountID != NULL)
acc = account_list_get_by_id(c->accountID);
else
acc = account_list_get_by_id( account_list_get_default());
sprintf( msg , "%s account: %s" , g_hash_table_lookup( acc->properties , ACCOUNT_TYPE) , g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS));
msg = g_markup_printf_escaped("%s account: %s" ,
g_hash_table_lookup( acc->properties , ACCOUNT_TYPE),
g_hash_table_lookup( acc->properties , ACCOUNT_ALIAS));
status_bar_message_add( msg , __MSG_ACCOUNT_DEFAULT);
g_free(msg);
}
......@@ -117,6 +119,7 @@ sflphone_hung_up( call_t * c)
call_list_remove( c->callID);
update_call_tree_remove(c);
update_menus();
status_tray_icon_blink( FALSE );
}
/** Internal to actions: Fill account list */
......@@ -208,7 +211,6 @@ sflphone_hang_up()
dbus_hang_up (selectedCall);
break;
case CALL_STATE_INCOMING:
status_tray_icon_blink( FALSE );
dbus_refuse (selectedCall);
break;
case CALL_STATE_TRANSFERT:
......@@ -234,7 +236,6 @@ sflphone_pick_up()
sflphone_place_call (selectedCall);
break;
case CALL_STATE_INCOMING:
status_tray_icon_blink( FALSE );
dbus_accept (selectedCall);
break;
case CALL_STATE_HOLD:
......@@ -348,7 +349,7 @@ sflphone_unset_transfert()
sflphone_incoming_call (call_t * c)
{
call_list_add ( c );
status_icon_unminimize();
//status_icon_unminimize();
update_call_tree_add(c);
update_menus();
}
......@@ -475,12 +476,10 @@ sflphone_keypad( guint keyval, gchar * key)
{
case 65293: /* ENTER */
case 65421: /* ENTER numpad */
status_tray_icon_blink( FALSE );
status_bar_display_account(c);
dbus_accept(c);
break;
case 65307: /* ESCAPE */
status_tray_icon_blink( FALSE );
dbus_refuse(c);
break;
}
......
......@@ -988,7 +988,7 @@ create_audio_tab ()
outputAudioPluginStore = gtk_list_store_new(1, G_TYPE_STRING);
config_window_fill_output_audio_plugin_list();
pluginComboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputAudioPluginStore));
//select_active_output_audio_plugin();
select_active_output_audio_plugin();
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), pluginComboBox);
g_signal_connect(G_OBJECT(pluginComboBox), "changed", G_CALLBACK(select_output_audio_plugin), pluginComboBox);
......@@ -1048,7 +1048,7 @@ create_audio_tab ()
// Set event on selection
g_signal_connect(G_OBJECT(refreshButton), "clicked", G_CALLBACK(detect_all_audio_settings), NULL);
select_active_output_audio_plugin();
//select_active_output_audio_plugin();
// Codec section label
codecFrame = gtk_frame_new(_("Codecs"));
gtk_misc_set_alignment(GTK_MISC(codecFrame), 0, 0.5);
......
......@@ -55,6 +55,7 @@ incoming_call_cb (DBusGProxy *proxy,
c->state = CALL_STATE_INCOMING;
status_tray_icon_blink( TRUE );
notify_incoming_call( c );
sflphone_incoming_call (c);
}
......@@ -346,6 +347,7 @@ dbus_transfert (const call_t * c)
void
dbus_accept (const call_t * c)
{
status_tray_icon_blink( FALSE );
GError *error = NULL;
org_sflphone_SFLphone_CallManager_accept ( callManagerProxy, c->callID, &error);
if (error)
......@@ -366,6 +368,7 @@ dbus_refuse (const call_t * c)
{
// Remove the account message from the status bar stack
status_bar_message_remove( __MSG_ACCOUNT_DEFAULT );
status_tray_icon_blink( FALSE );
GError *error = NULL;
org_sflphone_SFLphone_CallManager_refuse ( callManagerProxy, c->callID, &error);
if (error)
......
......@@ -25,6 +25,7 @@
#include <accountlist.h>
#include <calllist.h>
#include <SFLnotify.h>
/** @file dbus.h
* @brief General DBus functions wrappers.
......
......@@ -110,8 +110,7 @@ show_status_icon()
create_menu());
// Add a tooltip to the system tray icon
gchar* tip = malloc(500);
sprintf( tip , _("SFLphone - %i accounts registered") , account_list_get_size());
gchar *tip = g_markup_printf_escaped (_("SFLphone - %i accounts registered") , account_list_get_size());
gtk_status_icon_set_tooltip( status , tip );
g_free(tip);
}
......@@ -121,3 +120,9 @@ status_tray_icon_blink( gboolean active )
{
gtk_status_icon_set_blinking( status , active );
}
GtkStatusIcon*
get_status_icon( void )
{
return status;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment