diff --git a/sflphone-gtk/src/SFLnotify.c b/sflphone-gtk/src/SFLnotify.c index 5a4308cd6a51468d091940beb6405ef68afc9072..d7f493887390e63afd64aa1e4851b3075b641a3d 100644 --- a/sflphone-gtk/src/SFLnotify.c +++ b/sflphone-gtk/src/SFLnotify.c @@ -21,7 +21,7 @@ static NotifyNotification *notification; -void + void notify_incoming_call( call_t* c ) { GdkPixbuf *pixbuf; @@ -30,18 +30,18 @@ notify_incoming_call( call_t* c ) 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) ) ; + 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); + 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() ); @@ -52,22 +52,21 @@ notify_incoming_call( call_t* c ) 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"); + g_print("notify(), failed to send notification\n"); } } -void + 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 + if( __POPUP_WINDOW ) + status_icon_unminimize(); g_object_unref( notification ); } -void + void refuse_call_cb( NotifyNotification *notification, gchar *action, gpointer data ) { call_t* c = (call_t*)g_object_get_data( G_OBJECT( notification ) , "call" ); @@ -75,13 +74,13 @@ refuse_call_cb( NotifyNotification *notification, gchar *action, gpointer data ) g_object_unref( notification ); } -void + void ignore_call_cb( NotifyNotification *notification, gchar *action, gpointer data ) { g_object_unref( notification ); } -void + void notify_voice_mails( guint count , account_t* acc ) { // the account is different from NULL @@ -91,16 +90,16 @@ notify_voice_mails( guint count , account_t* acc ) notify_init("sflphone"); title = g_markup_printf_escaped(_("%s account: %s") , - g_hash_table_lookup(acc->properties , ACCOUNT_TYPE) , - g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) ) ; + g_hash_table_lookup(acc->properties , ACCOUNT_TYPE) , + g_hash_table_lookup(acc->properties , ACCOUNT_ALIAS) ) ; body = g_markup_printf_escaped(_("%d voice mails"), count); pixbuf = gdk_pixbuf_new_from_file(ICON_DIR "/sflphone.png", NULL); notification = notify_notification_new( title, - body, - NULL, - NULL); + body, + 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() ); @@ -108,6 +107,48 @@ notify_voice_mails( guint count , account_t* acc ) 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"); + g_print("notify(), failed to send notification\n"); + } +} + + void +notify_registered_accounts( void ) +{ + // the account is different from NULL + GdkPixbuf *pixbuf; + gchar* title; + gchar* body=""; + notify_init("sflphone"); + + guint size = account_list_get_size(); + int i; + + if( size > 0 ){ + for( i = 0 ; i < size ; i++ ){ + + body = g_markup_printf_escaped(_("%s%s (%s) - State:<i>%s</i>") , + body, + g_hash_table_lookup( account_list_get_nth(i)->properties , ACCOUNT_ALIAS), + g_hash_table_lookup( account_list_get_nth(i)->properties , ACCOUNT_TYPE) , + account_state_name( account_list_get_nth(i)->state)) ; + } + + title = g_markup_printf_escaped(_("Accounts")); + + pixbuf = gdk_pixbuf_new_from_file(ICON_DIR "/sflphone.png", 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); + notify_notification_attach_to_status_icon( notification , get_status_icon() ); + 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)) { + g_print("notify(), failed to send notification\n"); + } } } diff --git a/sflphone-gtk/src/SFLnotify.h b/sflphone-gtk/src/SFLnotify.h index 276a62079207444498d166258056461acc9a4cab..7dfed316a6d4682345f7eb790f8b0225d065220a 100644 --- a/sflphone-gtk/src/SFLnotify.h +++ b/sflphone-gtk/src/SFLnotify.h @@ -31,8 +31,7 @@ #define __TIMEOUT_MODE "default" #define __TIMEOUT_TIME 30000 // 30 secondes -#define __POPUP_WINDOW true - +#define __POPUP_WINDOW ( dbus_popup_mode() ) /* * Notify an incoming call with the libnotify notification library @@ -43,6 +42,7 @@ void notify_incoming_call( call_t* c); void notify_voice_mails( guint count , account_t* acc ); +void notify_registered_accounts(); /* * Callback when answer button is pressed. * Action: Pick up the incoming call diff --git a/sflphone-gtk/src/configurationmanager-glue.h b/sflphone-gtk/src/configurationmanager-glue.h index 866b0eb8c01607c1f37ab3ce4d12a8563af6cd6c..4def5c8215d2310a0436f88a2d1ba8550149f012 100644 --- a/sflphone-gtk/src/configurationmanager-glue.h +++ b/sflphone-gtk/src/configurationmanager-glue.h @@ -1364,6 +1364,81 @@ org_sflphone_SFLphone_ConfigurationManager_is_start_hidden_async (DBusGProxy *pr stuff->userdata = userdata; return dbus_g_proxy_begin_call (proxy, "isStartHidden", org_sflphone_SFLphone_ConfigurationManager_is_start_hidden_async_callback, stuff, g_free, G_TYPE_INVALID); } +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_popup_mode (DBusGProxy *proxy, gint* OUT_state, GError **error) + +{ + return dbus_g_proxy_call (proxy, "popupMode", error, G_TYPE_INVALID, G_TYPE_INT, OUT_state, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_popup_mode_reply) (DBusGProxy *proxy, gint OUT_state, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_popup_mode_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + gint OUT_state; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_state, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_popup_mode_reply)data->cb) (proxy, OUT_state, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_popup_mode_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_popup_mode_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "popupMode", org_sflphone_SFLphone_ConfigurationManager_popup_mode_async_callback, stuff, g_free, G_TYPE_INVALID); +} +static +#ifdef G_HAVE_INLINE +inline +#endif +gboolean +org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode (DBusGProxy *proxy, GError **error) + +{ + return dbus_g_proxy_call (proxy, "switchPopupMode", error, G_TYPE_INVALID, G_TYPE_INVALID); +} + +typedef void (*org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_reply) (DBusGProxy *proxy, GError *error, gpointer userdata); + +static void +org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data) +{ + DBusGAsyncData *data = (DBusGAsyncData*) user_data; + GError *error = NULL; + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID); + (*(org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_reply)data->cb) (proxy, error, data->userdata); + return; +} + +static +#ifdef G_HAVE_INLINE +inline +#endif +DBusGProxyCall* +org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_reply callback, gpointer userdata) + +{ + DBusGAsyncData *stuff; + stuff = g_new (DBusGAsyncData, 1); + stuff->cb = G_CALLBACK (callback); + stuff->userdata = userdata; + return dbus_g_proxy_begin_call (proxy, "switchPopupMode", org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode_async_callback, stuff, g_free, G_TYPE_INVALID); +} #endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */ G_END_DECLS diff --git a/sflphone-gtk/src/configwindow.c b/sflphone-gtk/src/configwindow.c index c3f175e9988ab05b4d4780784c050260f1309853..c2cacca66d15e54f83e0be21132c193bf252764f 100644 --- a/sflphone-gtk/src/configwindow.c +++ b/sflphone-gtk/src/configwindow.c @@ -496,8 +496,7 @@ default_account(GtkWidget *widget, gpointer data) int is_ringtone_enabled( void ) { - int res = dbus_is_ringtone_enabled(); - return res; + return dbus_is_ringtone_enabled(); } void @@ -506,6 +505,12 @@ start_hidden( void ) dbus_start_hidden(); } +void +set_popup_mode( void ) +{ + dbus_switch_popup_mode(); +} + void ringtone_enabled( void ) { @@ -1157,20 +1162,20 @@ create_general_settings () gtk_widget_show( trayBox ); gtk_container_add( GTK_CONTAINER(trayFrame) , trayBox); - trayItem = gtk_check_button_new_with_label(_("Start Hidden")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem), dbus_is_start_hidden() ); - gtk_box_pack_start( GTK_BOX(trayBox) , trayItem , TRUE , TRUE , 1); - g_signal_connect(G_OBJECT( trayItem ) , "clicked" , G_CALLBACK( start_hidden ) , NULL); - GtkWidget* trayItem1 = gtk_radio_button_new_with_label(NULL, _("Popup Main Window On Incoming Call")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem1), TRUE ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem1), dbus_popup_mode() ); gtk_box_pack_start( GTK_BOX(trayBox) , trayItem1 , TRUE , TRUE , 1); - //TODO callback + g_signal_connect(G_OBJECT( trayItem1 ) , "clicked" , G_CALLBACK( set_popup_mode ) , NULL); + trayItem = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(trayItem1), _("Never Popup Main Window")); - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem), TRUE ); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem), !dbus_popup_mode() ); gtk_box_pack_start( GTK_BOX(trayBox) , trayItem , TRUE , TRUE , 1); - //TODO callback + trayItem = gtk_check_button_new_with_label(_("Start Hidden")); + gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(trayItem), dbus_is_start_hidden() ); + gtk_box_pack_start( GTK_BOX(trayBox) , trayItem , TRUE , TRUE , 1); + g_signal_connect(G_OBJECT( trayItem ) , "clicked" , G_CALLBACK( start_hidden ) , NULL); + gtk_widget_show_all(ret); return ret; } diff --git a/sflphone-gtk/src/dbus.c b/sflphone-gtk/src/dbus.c index 509779568e01dd02a78b4dbf9ae1c00090dceb00..45194969d274be663362dc76998c1c81f3a42772 100644 --- a/sflphone-gtk/src/dbus.c +++ b/sflphone-gtk/src/dbus.c @@ -1257,3 +1257,35 @@ dbus_is_start_hidden( void ) g_print("DBus called start_hidden on ConfigurationManager\n"); return state; } + +int +dbus_popup_mode( void ) +{ + GError* error = NULL; + int state; + org_sflphone_SFLphone_ConfigurationManager_popup_mode( + configurationManagerProxy, + &state, + &error); + g_print("After"); + if(error) + { + g_error_free(error); + } + else + g_print("DBus called popup_mode on ConfigurationManager\n"); + return state; +} + +void +dbus_switch_popup_mode( void ) +{ + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } +} diff --git a/sflphone-gtk/src/dbus.h b/sflphone-gtk/src/dbus.h index 62780762429c585f1feb17d68bf6868fa5b4d29a..5cee9d295500a79818abd51bd2466f84d1396dd5 100644 --- a/sflphone-gtk/src/dbus.h +++ b/sflphone-gtk/src/dbus.h @@ -83,6 +83,8 @@ void dbus_set_dialpad( ); int dbus_get_dialpad( void ); void dbus_start_hidden( void ); int dbus_is_start_hidden( void ); +void dbus_switch_popup_mode( void ); +int dbus_popup_mode( void ); /* Instance */ void dbus_register( int pid, gchar * name); diff --git a/src/dbus/configurationmanager-glue.h b/src/dbus/configurationmanager-glue.h index dfbb970ddc9394c08c55db031f54e6cbb6dabfef..cdb689c87fa01b483882d2a864ff07c37360af02 100644 --- a/src/dbus/configurationmanager-glue.h +++ b/src/dbus/configurationmanager-glue.h @@ -56,6 +56,8 @@ public: register_method(ConfigurationManager, setDialpad, _setDialpad_stub); register_method(ConfigurationManager, startHidden, _startHidden_stub); register_method(ConfigurationManager, isStartHidden, _isStartHidden_stub); + register_method(ConfigurationManager, popupMode, _popupMode_stub); + register_method(ConfigurationManager, switchPopupMode, _switchPopupMode_stub); } ::DBus::IntrospectedInterface* const introspect() const @@ -241,6 +243,15 @@ public: { "state", "i", false }, { 0, 0, 0 } }; + static ::DBus::IntrospectedArgument popupMode_args[] = + { + { "state", "i", false }, + { 0, 0, 0 } + }; + static ::DBus::IntrospectedArgument switchPopupMode_args[] = + { + { 0, 0, 0 } + }; static ::DBus::IntrospectedArgument parametersChanged_args[] = { { "list", "a{ss}", false }, @@ -293,6 +304,8 @@ public: { "setDialpad", setDialpad_args }, { "startHidden", startHidden_args }, { "isStartHidden", isStartHidden_args }, + { "popupMode", popupMode_args }, + { "switchPopupMode", switchPopupMode_args }, { 0, 0 } }; static ::DBus::IntrospectedMethod ConfigurationManager_signals[] = @@ -363,6 +376,8 @@ public: virtual void setDialpad( ) = 0; virtual void startHidden( ) = 0; virtual ::DBus::Int32 isStartHidden( ) = 0; + virtual ::DBus::Int32 popupMode( ) = 0; + virtual void switchPopupMode( ) = 0; public: @@ -740,6 +755,24 @@ private: wi << argout1; return reply; } + ::DBus::Message _popupMode_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + ::DBus::Int32 argout1 = popupMode(); + ::DBus::ReturnMessage reply(call); + ::DBus::MessageIter wi = reply.writer(); + wi << argout1; + return reply; + } + ::DBus::Message _switchPopupMode_stub( const ::DBus::CallMessage& call ) + { + ::DBus::MessageIter ri = call.reader(); + + switchPopupMode(); + ::DBus::ReturnMessage reply(call); + return reply; + } }; } } } diff --git a/src/dbus/configurationmanager-introspec.xml b/src/dbus/configurationmanager-introspec.xml index 55e0bdc26295dc526433df1d4dd8e264a16b1187..f3c48f275e35032e7aae8c5d8ab60cc9b7768724 100644 --- a/src/dbus/configurationmanager-introspec.xml +++ b/src/dbus/configurationmanager-introspec.xml @@ -155,6 +155,13 @@ <arg type="i" name="state" direction="out"/> </method> + <method name="popupMode"> + <arg type="i" name="state" direction="out"/> + </method> + + <method name="switchPopupMode"> + </method> + <!-- ///////////////////////////// --> <signal name="parametersChanged"> <arg type="a{ss}" name="list" direction="out"/> diff --git a/src/dbus/configurationmanager.cpp b/src/dbus/configurationmanager.cpp index 9f7e8f40396ae924347116a636a2e1897c306be3..0fb075f93041be0e7203ac865eb402a6a78038bb 100644 --- a/src/dbus/configurationmanager.cpp +++ b/src/dbus/configurationmanager.cpp @@ -285,4 +285,17 @@ ConfigurationManager::isStartHidden( void ) return Manager::instance().isStartHidden( ); } +void +ConfigurationManager::switchPopupMode( void ) +{ + Manager::instance().switchPopupMode( ); +} + +::DBus::Int32 +ConfigurationManager::popupMode( void ) +{ + return Manager::instance().popupMode( ); +} + + diff --git a/src/dbus/configurationmanager.h b/src/dbus/configurationmanager.h index dfc5e4085072ca305fb80bc660692135e007d5ec..c0f5e300bb052d4445ff37d464a6f4ad67d4f972 100644 --- a/src/dbus/configurationmanager.h +++ b/src/dbus/configurationmanager.h @@ -80,6 +80,8 @@ public: void setDialpad( void ); ::DBus::Int32 isStartHidden( void ); void startHidden( void ); + ::DBus::Int32 popupMode( void ); + void switchPopupMode( void ); }; diff --git a/src/global.h b/src/global.h index 923fb5e61d32e69d9c75dc221860d83d62491ef0..e09409da50cf14ffa85c7e263155085af1792673 100644 --- a/src/global.h +++ b/src/global.h @@ -111,6 +111,7 @@ typedef short int16; #define RINGTONE_ENABLED 1 #define DISPLAY_DIALPAD 1 #define START_HIDDEN 1 +#define WINDOW_POPUP 1 #define ERROR_ALSA_CAPTURE_DEVICE 0 #define ERROR_ALSA_PLAYBACK_DEVICE 1 diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index a570b83926f0920869f4258243c2196429365fcc..32aee5add706824ef290be5c5ae2439c9dada8c0 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -1100,6 +1100,7 @@ ManagerImpl::initConfigFile (void) fill_config_int(CONFIG_RINGTONE, YES_STR); fill_config_int(CONFIG_DIALPAD, YES_STR); fill_config_int(CONFIG_START, NO_STR); + fill_config_int(CONFIG_POPUP, YES_STR); // Loads config from ~/.sflphone/sflphonedrc or so.. if (createSettingsPath() == 1) { @@ -1457,6 +1458,19 @@ ManagerImpl::isStartHidden( void ) return getConfigInt( PREFERENCES , CONFIG_START ); } +void +ManagerImpl::switchPopupMode( void ) +{ + _debug("Switch popup mode\n"); + ( getConfigInt( PREFERENCES , CONFIG_POPUP ) == WINDOW_POPUP)? setConfig(PREFERENCES , CONFIG_POPUP , NO_STR ) : setConfig( PREFERENCES , CONFIG_POPUP , YES_STR ); +} + +int +ManagerImpl::popupMode( void ) +{ + return getConfigInt( PREFERENCES , CONFIG_POPUP ); +} + void ManagerImpl::notifyErrClient( const int& errCode ) { diff --git a/src/managerimpl.h b/src/managerimpl.h index 21522e46faa73d24aec827a3a9732725e8f68774..9902f25e1f773c3b28fbb84b2e753ab6e22ba6ff 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -351,6 +351,8 @@ public: void setDialpad( void ); int isStartHidden( void ); void startHidden( void ); + int popupMode( void ); + void switchPopupMode( void ); /** diff --git a/src/user_cfg.h b/src/user_cfg.h index f82c46fb02abcbba09a40c0257a06eef46c67938..bafce381485eb5282879e8b20d37eada4829ba7d 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -68,6 +68,7 @@ #define CONFIG_RINGTONE "Ringtones.enable" #define CONFIG_DIALPAD "Dialpad.display" #define CONFIG_START "Start.hidden" +#define CONFIG_POPUP "Window.popup" // Default values #define EMPTY_FIELD ""