Commit cd66e363 authored by Emmanuel Milou's avatar Emmanuel Milou

Settings window: Popup mode done

parent 25829fa8
......@@ -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");
}
}
}
......@@ -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
......
......@@ -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
......@@ -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;
}
......
......@@ -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);
}
}
......@@ -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);
......
......@@ -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;
}
};
} } }
......
......@@ -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"/>
......
......@@ -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( );
}
......@@ -80,6 +80,8 @@ public:
void setDialpad( void );
::DBus::Int32 isStartHidden( void );
void startHidden( void );
::DBus::Int32 popupMode( void );
void switchPopupMode( void );
};
......
......@@ -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
......
......@@ -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 )
{
......
......@@ -351,6 +351,8 @@ public:
void setDialpad( void );
int isStartHidden( void );
void startHidden( void );
int popupMode( void );
void switchPopupMode( void );
/**
......
......@@ -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 ""
......
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