Skip to content
Snippets Groups Projects
Commit 0cb4976c authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Little check button on audio settings GTk to enable ringtones

Does not much for now
parent 2de5c139
No related branches found
No related tags found
No related merge requests found
......@@ -466,6 +466,81 @@ static
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled (DBusGProxy *proxy, gint* OUT_bool, GError **error)
{
return dbus_g_proxy_call (proxy, "isRingtoneEnabled", error, G_TYPE_INVALID, G_TYPE_INT, OUT_bool, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_reply) (DBusGProxy *proxy, gint OUT_bool, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
gint OUT_bool;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_bool, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_reply)data->cb) (proxy, OUT_bool, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_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, "isRingtoneEnabled", org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled (DBusGProxy *proxy, GError **error)
{
return dbus_g_proxy_call (proxy, "ringtoneEnabled", error, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled_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_ringtone_enabled_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled_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, "ringtoneEnabled", org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_codec_list (DBusGProxy *proxy, char *** OUT_list, GError **error)
{
......
......@@ -35,6 +35,7 @@
* Local variables
*/
gboolean dialogOpen = FALSE;
gboolean ringtoneEnabled = TRUE;
GtkListStore *accountStore;
GtkWidget *codecTreeView; // View used instead of store to get access to selection
......@@ -482,6 +483,18 @@ default_account(GtkWidget *widget, gpointer data)
}
}
int
is_ringtone_enabled( void )
{
int res = dbus_is_ringtone_enabled();
return res;
}
void
ringtone_enabled( void )
{
dbus_ringtone_enabled();
}
/**
* Call back when the user click on an account in the list
*/
......@@ -938,6 +951,7 @@ create_audio_tab ()
GtkWidget *deviceTable;
GtkWidget *codecLabel;
GtkWidget *codecBox;
GtkWidget *enableTone;
GtkWidget *titleLabel;
GtkWidget *comboBox;
......@@ -1081,6 +1095,14 @@ create_audio_tab ()
gtk_box_pack_start(GTK_BOX(codecBox), codecTable, TRUE, TRUE, 0);
gtk_widget_show(codecTable);
// check button to enable ringtones
GtkWidget* box = gtk_hbox_new( TRUE , 1);
gtk_box_pack_start( GTK_BOX(ret) , box , TRUE , TRUE , 1);
enableTone = gtk_check_button_new_with_mnemonic( "_Enable ringtones");
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enableTone), dbus_is_ringtone_enabled() );
gtk_box_pack_start( GTK_BOX(box) , enableTone , TRUE , TRUE , 1);
g_signal_connect(G_OBJECT( enableTone) , "clicked" , G_CALLBACK( ringtone_enabled ) , NULL);
// Show all
gtk_widget_show_all(ret);
......
......@@ -1027,6 +1027,41 @@ dbus_get_current_audio_output_plugin()
return plugin;
}
int
dbus_is_ringtone_enabled()
{
int res;
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled(
configurationManagerProxy,
&res,
&error);
g_print("After");
if(error)
{
g_error_free(error);
}
else
g_print("DBus called is_ringtone_enabled() on ConfigurationManager\n");
return res;
}
void
dbus_ringtone_enabled()
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled(
configurationManagerProxy,
&error);
g_print("After");
if(error)
{
g_error_free(error);
}
else
g_print("DBus called ringtone_enabled() on ConfigurationManager\n");
}
int
dbus_is_iax2_enabled()
{
......
......@@ -74,6 +74,7 @@ gchar** dbus_get_current_audio_devices_index();
int dbus_get_audio_device_index(const gchar* name);
gchar* dbus_get_current_audio_output_plugin();
int dbus_is_iax2_enabled( void );
int dbus_is_ringtone_enabled( void );
/* Instance */
void dbus_register( int pid, gchar * name);
......
......@@ -32,6 +32,8 @@ public:
register_method(ConfigurationManager, getRingtoneList, _getRingtoneList_stub);
register_method(ConfigurationManager, getPlaybackDeviceList, _getPlaybackDeviceList_stub);
register_method(ConfigurationManager, getRecordDeviceList, _getRecordDeviceList_stub);
register_method(ConfigurationManager, isRingtoneEnabled, _isRingtoneEnabled_stub);
register_method(ConfigurationManager, ringtoneEnabled, _ringtoneEnabled_stub);
register_method(ConfigurationManager, getCodecList, _getCodecList_stub);
register_method(ConfigurationManager, getCodecDetails, _getCodecDetails_stub);
register_method(ConfigurationManager, getActiveCodecList, _getActiveCodecList_stub);
......@@ -114,6 +116,15 @@ public:
{ "list", "as", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument isRingtoneEnabled_args[] =
{
{ "bool", "i", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument ringtoneEnabled_args[] =
{
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getCodecList_args[] =
{
{ "list", "as", false },
......@@ -219,6 +230,8 @@ public:
{ "getRingtoneList", getRingtoneList_args },
{ "getPlaybackDeviceList", getPlaybackDeviceList_args },
{ "getRecordDeviceList", getRecordDeviceList_args },
{ "isRingtoneEnabled", isRingtoneEnabled_args },
{ "ringtoneEnabled", ringtoneEnabled_args },
{ "getCodecList", getCodecList_args },
{ "getCodecDetails", getCodecDetails_args },
{ "getActiveCodecList", getActiveCodecList_args },
......@@ -280,6 +293,8 @@ public:
virtual std::vector< ::DBus::String > getRingtoneList( ) = 0;
virtual std::vector< ::DBus::String > getPlaybackDeviceList( ) = 0;
virtual std::vector< ::DBus::String > getRecordDeviceList( ) = 0;
virtual ::DBus::Int32 isRingtoneEnabled( ) = 0;
virtual void ringtoneEnabled( ) = 0;
virtual std::vector< ::DBus::String > getCodecList( ) = 0;
virtual std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload ) = 0;
virtual std::vector< ::DBus::String > getActiveCodecList( ) = 0;
......@@ -436,6 +451,24 @@ private:
wi << argout1;
return reply;
}
::DBus::Message _isRingtoneEnabled_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
::DBus::Int32 argout1 = isRingtoneEnabled();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
::DBus::Message _ringtoneEnabled_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
ringtoneEnabled();
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _getCodecList_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
......
......@@ -57,6 +57,12 @@
<arg type="as" name="list" direction="out"/>
</method>
<method name="isRingtoneEnabled">
<arg type="i" name="bool" direction="out"/>
</method>
<method name="ringtoneEnabled">
</method>
<!-- /////////////////////// -->
<!-- Codecs-related methods -->
......
......@@ -236,3 +236,15 @@ ConfigurationManager::isIax2Enabled( void )
{
return Manager::instance().isIax2Enabled( );
}
void
ConfigurationManager::ringtoneEnabled( void )
{
Manager::instance().ringtoneEnabled( );
}
::DBus::Int32
ConfigurationManager::isRingtoneEnabled( void )
{
return Manager::instance().isRingtoneEnabled( );
}
......@@ -72,6 +72,8 @@ public:
std::vector< ::DBus::String > getRingtoneList( );
::DBus::Int32 isIax2Enabled( void );
::DBus::Int32 isRingtoneEnabled( void );
void ringtoneEnabled( void );
};
......
......@@ -102,5 +102,6 @@ typedef short int16;
#define GSM_STRING_DESCRIPTION "gsm"
#define SPEEX_STRING_DESCRIPTION "speex"
#define RINGTONE_ENABLED "1"
#endif // __GLOBAL_H__
......@@ -1082,6 +1082,7 @@ ManagerImpl::initConfigFile (void)
fill_config_int(CHECKED_TRAY, NO_STR);
fill_config_str(VOICEMAIL_NUM, DFT_VOICEMAIL);
fill_config_int(CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT_STR);
fill_config_int(CONFIG_RINGTONE, CONFIG_RINGTONE_DEFAULT);
// Loads config from ~/.sflphone/sflphonedrc or so..
if (createSettingsPath() == 1) {
......@@ -1360,6 +1361,18 @@ ManagerImpl::isIax2Enabled( void )
#endif
}
int
ManagerImpl::isRingtoneEnabled( void )
{
return std::atoi( getConfigString( PREFERENCES , CONFIG_RINGTONE ).c_str());
}
void
ManagerImpl::ringtoneEnabled( void )
{
( getConfigString( PREFERENCES , CONFIG_RINGTONE ) == RINGTONE_ENABLED )? setConfig(PREFERENCES , CONFIG_RINGTONE , "0") : setConfig( PREFERENCES , CONFIG_RINGTONE , "1");
}
int
ManagerImpl::getAudioDeviceIndex(const std::string name)
{
......
......@@ -342,6 +342,8 @@ public:
std::string serialize(std::vector<std::string> v);
int isIax2Enabled( void );
int isRingtoneEnabled( void );
void ringtoneEnabled( void );
/**
* Inverse of serialize
*/
......
......@@ -77,12 +77,13 @@
#define CHECKED_TRAY "Options.checkedTray"
#define VOICEMAIL_NUM "Options.voicemailNumber"
// zeroconfig module
#define CONFIG_ZEROCONF "Zeroconf.enable"
#define CONFIG_ZEROCONF "Zeroconf.enable"
#define CONFIG_RINGTONE "Ringtones.enable"
// Default values
#define EMPTY_FIELD ""
#define DFT_STUN_SERVER "stun.fwdnet.net:3478"
#define CONFIG_RINGTONE_DEFAULT "1"
#define YES_STR "1"
#define NO_STR "0"
#define DFT_PULSE_LENGTH_STR "250"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment