diff --git a/sflphone-client-gnome/pixmaps/Makefile.am b/sflphone-client-gnome/pixmaps/Makefile.am index 47973af90bd9c2128f0fd0beddfb02d868b4246d..15fc5055572ecdb0ed65c9c7feeb871384650fd8 100644 --- a/sflphone-client-gnome/pixmaps/Makefile.am +++ b/sflphone-client-gnome/pixmaps/Makefile.am @@ -2,6 +2,6 @@ icondir = $(datadir)/pixmaps icon_DATA = sflphone.svg -buttons_DATA = accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg mic.svg mic_25.svg mic_50.svg mic_75.svg speaker.svg speaker_25.svg speaker_50.svg speaker_75.svg fail.svg incoming.svg outgoing.svg missed.svg mailbox.svg busy.svg icon_accept.svg icon_hold.svg icon_unhold.svg icon_hangup.svg icon_call.svg icon_dialpad.svg icon_volume.svg icon_dialpad_off.svg icon_volume_off.svg history2.svg sflphone.svg sflphone_notif.svg stock_person.svg icon_rec.svg rec_call.svg addressbook.svg contact_default.svg face-monkey.svg users.svg home.svg wait-on.gif +buttons_DATA = accept.svg current.svg transfert.svg hang_up.svg hold.svg unhold.svg refuse.svg call.svg ring.svg dial.svg mic.svg mic_25.svg mic_50.svg mic_75.svg speaker.svg speaker_25.svg speaker_50.svg speaker_75.svg fail.svg incoming.svg outgoing.svg missed.svg mailbox.svg busy.svg icon_accept.svg icon_hold.svg icon_unhold.svg icon_hangup.svg icon_call.svg icon_dialpad.svg icon_volume.svg icon_dialpad_off.svg icon_volume_off.svg history2.svg sflphone.svg sflphone_small.svg stock_person.svg icon_rec.svg rec_call.svg addressbook.svg contact_default.svg face-monkey.svg users.svg home.svg wait-on.gif buttonsdir = $(datadir)/sflphone EXTRA_DIST = $(buttons_DATA) $(icon_DATA) diff --git a/sflphone-client-gnome/src/sflnotify.c b/sflphone-client-gnome/src/sflnotify.c index 4021a044f0228a08943e4f1dd6778d88039a43b9..0bf66ff9130c0c04d66d61fe3349051d2e737132 100644 --- a/sflphone-client-gnome/src/sflnotify.c +++ b/sflphone-client-gnome/src/sflnotify.c @@ -19,124 +19,94 @@ #include <sflnotify.h> -static NotifyNotification *notification; +GnomeNotification *_gnome_notification; - void -notify_incoming_call( call_t* c ) +void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urgency, gint timeout, GnomeNotification **notif) { - if( dbus_get_notify()){ + GnomeNotification *_notif; - GdkPixbuf *pixbuf; - gchar* callerid; - gchar* title; - notify_init("sflphone"); + if( dbus_get_notify()){ - if (g_strcasecmp (c->accountID,"") == 0) { - title = g_markup_printf_escaped ("IP-to-IP call"); - } - else { - title = g_markup_printf_escaped(_("%s account: %s") , - (gchar*)g_hash_table_lookup(account_list_get_by_id(c->accountID)->properties , ACCOUNT_TYPE) , - (gchar*)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); + _notif = g_new0 (GnomeNotification, 1); - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); + notify_init ("SFLphone"); - notification = notify_notification_new( title, - callerid, - NULL, - NULL); - notify_notification_set_urgency( notification , NOTIFY_URGENCY_CRITICAL ); - notify_notification_set_icon_from_pixbuf (notification, pixbuf); + // Set struct fields + _notif->notification = notify_notification_new (title, body, NULL, NULL); + //_notif->icon = gdk_pixbuf_new_from_file_at_size (LOGO, 120, 120, NULL); + _notif->icon = gdk_pixbuf_new_from_file (LOGO, NULL); #if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon( notification , get_status_icon() ); + notify_notification_attach_to_status_icon (_notif->notification , get_status_icon() ); #endif - 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)) { + notify_notification_set_urgency (_notif->notification, urgency); + + if (_notif->icon != NULL) + notify_notification_set_icon_from_pixbuf (_notif->notification, _notif->icon); + else + ERROR ("notify(), cannot load notification icon"); + + notify_notification_set_timeout (_notif->notification, timeout); + + if (!notify_notification_show (_notif->notification, NULL)) { ERROR("notify(), failed to send notification"); } + + *notif = _notif; } } - void -answer_call_cb( NotifyNotification *notification, gpointer data UNUSED ) -{ - call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" ); - c->history_state = INCOMING; - calltree_update_call( history , c ); - dbus_accept(c); -#if GTK_CHECK_VERSION(2,10,0) - if( __POPUP_WINDOW ) - status_icon_unminimize(); -#endif - g_object_unref( notification ); -} - void -refuse_call_cb( NotifyNotification *notification, gpointer data UNUSED) -{ - 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, gpointer data UNUSED) +notify_incoming_call (call_t* c) { - g_object_unref( notification ); + + gchar* callerid; + gchar* title; + + if (g_strcasecmp (c->accountID,"") == 0) { + title = g_markup_printf_escaped ("IP-to-IP call"); + } + else { + title = g_markup_printf_escaped(_("%s account: %s") , + (gchar*)g_hash_table_lookup(account_list_get_by_id(c->accountID)->properties , ACCOUNT_TYPE) , + (gchar*)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); + + create_new_gnome_notification (title, + callerid, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); } void -notify_voice_mails( guint count , account_t* acc ) +notify_voice_mails (guint count, account_t* acc) { - - if( dbus_get_mail_notify()) { // the account is different from NULL - GdkPixbuf *pixbuf; gchar* title; gchar* body; - notify_init("sflphone"); title = g_markup_printf_escaped(_("%s account: %s") , (gchar*)g_hash_table_lookup(acc->properties , ACCOUNT_TYPE) , (gchar*) g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) ) ; body = g_markup_printf_escaped(_("%d voice mails"), count); - pixbuf = gdk_pixbuf_new_from_file(LOGO, NULL); - - notification = notify_notification_new( title, - body, - NULL, - NULL); - notify_notification_set_urgency( notification , NOTIFY_URGENCY_LOW ); - notify_notification_set_icon_from_pixbuf (notification, pixbuf); -#if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon( notification , get_status_icon() ); -#endif - notify_notification_set_timeout( notification , NOTIFY_EXPIRES_DEFAULT ); - notify_notification_add_action( notification , "ignore" , _("Ignore") , (NotifyActionCallback) ignore_call_cb , NULL , NULL ); - - if (!notify_notification_show (notification, NULL)) { - ERROR("notify(), failed to send notification"); - } - } + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_LOW, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } void -notify_current_account( account_t* acc ) +notify_current_account (account_t* acc) { - if( dbus_get_notify()){ // the account is different from NULL - GdkPixbuf *pixbuf; gchar* title; gchar* body=""; - notify_init("sflphone"); body = g_markup_printf_escaped(_("Calling with %s account <i>%s</i>") , (gchar*)g_hash_table_lookup( acc->properties , ACCOUNT_TYPE) , @@ -144,109 +114,70 @@ notify_current_account( account_t* acc ) title = g_markup_printf_escaped(_("Current account")); - pixbuf = gdk_pixbuf_new_from_file(LOGO, NULL); - - notification = notify_notification_new( title, - body, - NULL, - NULL); - notify_notification_set_urgency( notification , NOTIFY_URGENCY_NORMAL ); - notify_notification_set_icon_from_pixbuf (notification, pixbuf); -#if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon( notification , get_status_icon() ); -#endif - notify_notification_set_timeout( notification , NOTIFY_EXPIRES_DEFAULT ); - notify_notification_add_action( notification , "ignore" , _("Ignore") , (NotifyActionCallback) ignore_call_cb , NULL , NULL ); - - if (!notify_notification_show (notification, NULL)) { - ERROR("notify(), failed to send notification"); - } - } + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_NORMAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } + void -notify_no_accounts( ) +notify_no_accounts () { - GdkPixbuf *pixbuf; gchar* title; gchar* body=""; - notify_init("sflphone"); body = g_markup_printf_escaped(_("You haven't setup any accounts")); - title = g_markup_printf_escaped(_("Error")); - pixbuf = gdk_pixbuf_new_from_file(LOGO, NULL); - - notification = notify_notification_new( title, - body, - NULL, - NULL); - notify_notification_set_urgency( notification , NOTIFY_URGENCY_CRITICAL ); - notify_notification_set_icon_from_pixbuf (notification, pixbuf); -#if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon( notification , get_status_icon() ); -#endif - notify_notification_set_timeout( notification , NOTIFY_EXPIRES_DEFAULT ); - //notify_notification_add_action( notification , "setup" , _("Setup Accounts") , (NotifyActionCallback) setup_accounts_cb , NULL , NULL ); - - if (!notify_notification_show (notification, NULL)) { - ERROR("notify(), failed to send notification"); - } + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_CRITICAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } - void -setup_accounts_cb( NotifyNotification *notification, gpointer data UNUSED) -{ - //gtk_widget_set_parent( show_accounts_window() , GTK_WIDGET(get_main_window())); - show_accounts_window(); - g_object_unref( notification ); -} void -notify_no_registered_accounts( ) +notify_no_registered_accounts () { - GdkPixbuf *pixbuf; gchar* title; gchar* body=""; - notify_init("sflphone"); - body = g_markup_printf_escaped(_("You have no registered accounts")); - - title = g_markup_printf_escaped(_("Error")); - pixbuf = gdk_pixbuf_new_from_file(LOGO, NULL); - - notification = notify_notification_new( title, - body, - NULL, - NULL); - notify_notification_set_urgency( notification , NOTIFY_URGENCY_CRITICAL ); - notify_notification_set_icon_from_pixbuf (notification, pixbuf); -#if GTK_CHECK_VERSION(2,10,0) - notify_notification_attach_to_status_icon( notification , get_status_icon() ); -#endif - notify_notification_set_timeout( notification , NOTIFY_EXPIRES_DEFAULT ); - //notify_notification_add_action( notification , "setup" , _("Setup Accounts") , (NotifyActionCallback) setup_accounts_cb , NULL , NULL ); - - if (!notify_notification_show (notification, NULL)) { - ERROR("notify(), failed to send notification"); - } - + create_new_gnome_notification (title, + body, + NOTIFY_URGENCY_CRITICAL, + NOTIFY_EXPIRES_DEFAULT, + &_gnome_notification); } void stop_notification( void ) { - if( notification != NULL ) + if( _gnome_notification->notification != NULL ) { - if(notify_notification_show( notification , NULL)) + if(notify_notification_show (_gnome_notification->notification, NULL)) { - notify_notification_close( notification , NULL); - g_object_unref( notification ); - notification = NULL; + notify_notification_close (_gnome_notification->notification, NULL); + g_object_unref(_gnome_notification->notification ); + _gnome_notification->notification = NULL; } - notification = NULL; + _gnome_notification->notification = NULL; } + //free_notification (_gnome_notification); +} + +/** + * Freeing a notification instance + */ +void free_notification (GnomeNotification *g) +{ + g_free(g->title); + g_free(g->body); + g_free(g->notification); + g_free(g->icon); + g_free(g); } diff --git a/sflphone-client-gnome/src/sflnotify.h b/sflphone-client-gnome/src/sflnotify.h index 6131322b445326a68b60114d1c849d5a020ad208..1f0fdff962ba1c3b8028a036d79ca90a5cc3cdf9 100644 --- a/sflphone-client-gnome/src/sflnotify.h +++ b/sflphone-client-gnome/src/sflnotify.h @@ -17,9 +17,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __SFL_NOTIFY_H__ -#define __SFL_NOTIFY_H__ +#ifndef __GNOME_NOTIFICATION_H__ +#define __GNOME_NOTIFICATION_H__ /** @file sflnotify.h * @brief Implements desktop notification for incoming events. @@ -29,11 +28,22 @@ #include <accountlist.h> #include <calllist.h> #include <dbus/dbus.h> -#include <actions.h> #include <statusicon.h> -#include <configwindow.h> #include <sflphone_const.h> +G_BEGIN_DECLS + +typedef struct { + NotifyNotification *notification; + gchar *title; + gchar *body; + GdkPixbuf *icon; +} GnomeNotification; + +void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urgency, gint timeout, GnomeNotification **notif); + +void free_notification (GnomeNotification *g); + /** * Notify an incoming call * A dialog box is attached to the status icon @@ -65,41 +75,11 @@ void notify_no_accounts( ); */ void notify_no_registered_accounts( ); -/** - * Callback when answer button is pressed. - * Action associated: 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, gpointer data ); - -/** - * Callback when refuse button is pressed - * Action associated: 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, gpointer data ); - -/** - * Callback when ignore button is pressed - * Action associated: 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, gpointer data ); - -/** - * Callback when you try to make a call without accounts setup and 'setup account' button is clicked. - * Action associated: Open the account window - * @param notification The pointer on the notification structure - * @param data The data associated. Here: account_t* - */ -void setup_accounts_cb(NotifyNotification *notification, gpointer data); - /** * Stop and close the current notification if an action occured before the timeout */ void stop_notification( void ); +G_END_DECLS + #endif diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 9a86a86fa46c6bcd437d7f862d102a55f156364c..9ae9bbb696a50aa3a6b8207c7f5a8f30ab0dd8e3 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -28,8 +28,8 @@ * @brief Contains the global variables for the client code */ - -#define LOGO ICONS_DIR "/sflphone.svg" +#define LOGO ICONS_DIR "/sflphone.svg" +#define LOGO_SMALL ICONS_DIR "/sflphone_small.svg" /** Locale */ #define _(STRING) gettext( STRING )