[empathy] remove empathy_account_settings_set_* functions
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] remove empathy_account_settings_set_* functions
- Date: Thu, 7 Jun 2012 10:51:36 +0000 (UTC)
commit 9d8d7a2e4f9cd772fe69dae15c4c21728e974df3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Jun 7 09:59:52 2012 +0200
remove empathy_account_settings_set_* functions
They don't buy us much so let's just pass the GVariant directly.
Fix some string leaks in empathy-account-widget-irc.c as well.
https://bugzilla.gnome.org/show_bug.cgi?id=677545
libempathy-gtk/empathy-account-widget-irc.c | 29 +++---
libempathy-gtk/empathy-account-widget.c | 36 ++++----
libempathy-gtk/empathy-irc-network-chooser.c | 12 ++-
.../empathy-local-xmpp-assistant-widget.c | 16 ++--
libempathy-gtk/empathy-protocol-chooser.c | 29 +++---
libempathy/empathy-account-settings.c | 104 ++------------------
libempathy/empathy-account-settings.h | 18 +---
7 files changed, 74 insertions(+), 170 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c
index a4343e1..b4d5673 100644
--- a/libempathy-gtk/empathy-account-widget-irc.c
+++ b/libempathy-gtk/empathy-account-widget-irc.c
@@ -67,22 +67,23 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
fullname = empathy_account_settings_get_string (ac_settings,
"fullname");
- if (!nick)
+ if (nick == NULL)
{
- nick = g_strdup (g_get_user_name ());
- empathy_account_settings_set_string (ac_settings,
- "account", nick);
+ nick = g_get_user_name ();
+
+ empathy_account_settings_set (ac_settings,
+ "account", g_variant_new_string (nick));
}
- if (!fullname)
+ if (fullname == NULL)
{
- fullname = g_strdup (g_get_real_name ());
- if (!fullname)
- {
- fullname = g_strdup (nick);
- }
- empathy_account_settings_set_string (ac_settings,
- "fullname", fullname);
+ fullname = g_get_real_name ();
+
+ if (fullname == NULL)
+ fullname = nick;
+
+ empathy_account_settings_set (ac_settings,
+ "fullname", g_variant_new_string (fullname));
}
}
@@ -114,8 +115,8 @@ set_password_prompt_if_needed (EmpathyAccountSettings *ac_settings,
"password-prompt"))
return FALSE;
- empathy_account_settings_set_boolean (ac_settings, "password-prompt",
- prompt);
+ empathy_account_settings_set (ac_settings, "password-prompt",
+ g_variant_new_boolean (prompt));
return TRUE;
}
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index cfa8f32..df56816 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -304,8 +304,8 @@ account_widget_entry_changed_common (EmpathyAccountWidget *self,
{
DEBUG ("Setting %s to %s", param_name,
tp_strdiff (param_name, "password") ? str : "***");
- empathy_account_settings_set_string (self->priv->settings, param_name,
- str);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_string (str));
}
curr_status = empathy_account_settings_parameter_is_valid (
@@ -361,21 +361,21 @@ account_widget_int_changed_cb (GtkWidget *widget,
{
case DBUS_TYPE_INT16:
case DBUS_TYPE_INT32:
- empathy_account_settings_set_int32 (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_int32 (value));
break;
case DBUS_TYPE_INT64:
- empathy_account_settings_set_int64 (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_int64 (value));
break;
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- empathy_account_settings_set_uint32 (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_uint32 (value));
break;
case DBUS_TYPE_UINT64:
- empathy_account_settings_set_uint64 (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_uint64 (value));
break;
default:
g_return_if_reached ();
@@ -409,8 +409,8 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
else
{
DEBUG ("Setting %s to %d", param_name, value);
- empathy_account_settings_set_boolean (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_boolean (value));
}
empathy_account_widget_changed (self);
@@ -475,8 +475,8 @@ account_widget_combobox_changed_cb (GtkWidget *widget,
else
{
DEBUG ("Setting %s to %s", param_name, value);
- empathy_account_settings_set_string (self->priv->settings, param_name,
- value);
+ empathy_account_settings_set (self->priv->settings, param_name,
+ g_variant_new_string (value));
}
empathy_account_widget_changed (self);
@@ -1006,8 +1006,8 @@ account_widget_apply_and_log_in (EmpathyAccountWidget *self)
self->priv->radiobutton_reuse));
DEBUG ("Set register param: %d", !reuse);
- empathy_account_settings_set_boolean (self->priv->settings, "register",
- !reuse);
+ empathy_account_settings_set (self->priv->settings, "register",
+ g_variant_new_boolean (!reuse));
}
g_object_get (self->priv->settings,
@@ -1242,8 +1242,8 @@ suffix_id_widget_changed_cb (GtkWidget *entry,
DEBUG ("Change account from '%s' to '%s'", account, tmp);
- empathy_account_settings_set_string (self->priv->settings, "account",
- tmp);
+ empathy_account_settings_set (self->priv->settings, "account",
+ g_variant_new_string (tmp));
g_free (tmp);
}
diff --git a/libempathy-gtk/empathy-irc-network-chooser.c b/libempathy-gtk/empathy-irc-network-chooser.c
index 74c9685..ac814e6 100644
--- a/libempathy-gtk/empathy-irc-network-chooser.c
+++ b/libempathy-gtk/empathy-irc-network-chooser.c
@@ -163,7 +163,8 @@ update_server_params (EmpathyIrcNetworkChooser *self)
charset = empathy_irc_network_get_charset (priv->network);
DEBUG ("Setting charset to %s", charset);
- empathy_account_settings_set_string (priv->settings, "charset", charset);
+ empathy_account_settings_set (priv->settings, "charset",
+ g_variant_new_string (charset));
servers = empathy_irc_network_get_servers (priv->network);
if (g_slist_length (servers) > 0)
@@ -182,11 +183,14 @@ update_server_params (EmpathyIrcNetworkChooser *self)
NULL);
DEBUG ("Setting server to %s", address);
- empathy_account_settings_set_string (priv->settings, "server", address);
+ empathy_account_settings_set (priv->settings, "server",
+ g_variant_new_string (address));
DEBUG ("Setting port to %u", port);
- empathy_account_settings_set_uint32 (priv->settings, "port", port);
+ empathy_account_settings_set (priv->settings, "port",
+ g_variant_new_uint32 (port));
DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
- empathy_account_settings_set_boolean (priv->settings, "use-ssl", ssl);
+ empathy_account_settings_set (priv->settings, "use-ssl",
+ g_variant_new_boolean (ssl));
/* Set Account.Service */
service = dup_network_service (priv->network);
diff --git a/libempathy-gtk/empathy-local-xmpp-assistant-widget.c b/libempathy-gtk/empathy-local-xmpp-assistant-widget.c
index cf38039..1ac8fff 100644
--- a/libempathy-gtk/empathy-local-xmpp-assistant-widget.c
+++ b/libempathy-gtk/empathy-local-xmpp-assistant-widget.c
@@ -102,13 +102,15 @@ create_salut_account_settings (void)
nickname, first_name, last_name, email, jid);
empathy_account_settings_set_string (settings,
- "nickname", nickname ? nickname : "");
- empathy_account_settings_set_string (settings,
- "first-name", first_name ? first_name : "");
- empathy_account_settings_set_string (settings,
- "last-name", last_name ? last_name : "");
- empathy_account_settings_set_string (settings, "email", email ? email : "");
- empathy_account_settings_set_string (settings, "jid", jid ? jid : "");
+ "nickname", g_variant_new_string (nickname ? nickname : ""));
+ empathy_account_settings_set_ (settings,
+ "first-name", g_variant_new_string (first_name ? first_name : ""));
+ empathy_account_settings_set (settings,
+ "last-name", g_variant_new_string (last_name ? last_name : ""));
+ empathy_account_settings_set (settings, "email",
+ g_variant_new_string (email ? email : ""));
+ empathy_account_settings_set (settings, "jid",
+ g_variant_new_string (jid ? jid : ""));
g_free (nickname);
g_free (first_name);
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c
index 6751e79..0396f78 100644
--- a/libempathy-gtk/empathy-protocol-chooser.c
+++ b/libempathy-gtk/empathy-protocol-chooser.c
@@ -615,18 +615,19 @@ empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self)
empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
NULL, NULL);
- empathy_account_settings_set_string (settings, "server",
- extra_certificate_identities[0]);
- empathy_account_settings_set_boolean (settings, "require-encryption",
- TRUE);
- empathy_account_settings_set_strv (settings, "fallback-servers",
- fallback_servers);
+ empathy_account_settings_set (settings, "server",
+ g_variant_new_string (extra_certificate_identities[0]));
+ empathy_account_settings_set (settings, "require-encryption",
+ g_variant_new_boolean (TRUE));
+ empathy_account_settings_set (settings, "fallback-servers",
+ g_variant_new_strv (fallback_servers, -1));
if (empathy_account_settings_have_tp_param (settings,
"extra-certificate-identities"))
{
- empathy_account_settings_set_strv (settings,
- "extra-certificate-identities", extra_certificate_identities);
+ empathy_account_settings_set (settings,
+ "extra-certificate-identities",
+ g_variant_new_strv (extra_certificate_identities, -1));
}
}
else if (!tp_strdiff (service, "facebook"))
@@ -637,12 +638,12 @@ empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self)
empathy_account_settings_set_icon_name_async (settings, "im-facebook",
NULL, NULL);
- empathy_account_settings_set_boolean (settings, "require-encryption",
- TRUE);
- empathy_account_settings_set_string (settings, "server",
- "chat.facebook.com");
- empathy_account_settings_set_strv (settings, "fallback-servers",
- fallback_servers);
+ empathy_account_settings_set (settings, "require-encryption",
+ g_variant_new_boolean (TRUE));
+ empathy_account_settings_set (settings, "server",
+ g_variant_new_string ("chat.facebook.com"));
+ empathy_account_settings_set (settings, "fallback-servers",
+ g_variant_new_strv (fallback_servers, -1));
}
out:
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 9f7297b..8a0e61f 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -1137,121 +1137,31 @@ empathy_account_settings_get_boolean (EmpathyAccountSettings *settings,
}
void
-empathy_account_settings_set_string (EmpathyAccountSettings *settings,
+empathy_account_settings_set (EmpathyAccountSettings *settings,
const gchar *param,
- const gchar *value)
+ GVariant *v)
{
EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
g_return_if_fail (param != NULL);
- g_return_if_fail (value != NULL);
+ g_return_if_fail (v != NULL);
- if (!tp_strdiff (param, "password") && priv->supports_sasl)
+ if (!tp_strdiff (param, "password") && priv->supports_sasl &&
+ g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
{
g_free (priv->password);
- priv->password = g_strdup (value);
+ priv->password = g_variant_dup_string (v, NULL);
priv->password_changed = TRUE;
}
else
{
g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_string (value)));
+ g_variant_ref_sink (v));
}
account_settings_remove_from_unset (settings, param);
}
-void
-empathy_account_settings_set_strv (EmpathyAccountSettings *settings,
- const gchar *param,
- const gchar * const *value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
- g_return_if_fail (value != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_strv (value, -1)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
-void
-empathy_account_settings_set_int32 (EmpathyAccountSettings *settings,
- const gchar *param,
- gint32 value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_int32 (value)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
-void
-empathy_account_settings_set_int64 (EmpathyAccountSettings *settings,
- const gchar *param,
- gint64 value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_int64 (value)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
-void
-empathy_account_settings_set_uint32 (EmpathyAccountSettings *settings,
- const gchar *param,
- guint32 value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_uint32 (value)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
-void
-empathy_account_settings_set_uint64 (EmpathyAccountSettings *settings,
- const gchar *param,
- guint64 value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_uint64 (value)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
-void
-empathy_account_settings_set_boolean (EmpathyAccountSettings *settings,
- const gchar *param,
- gboolean value)
-{
- EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
-
- g_return_if_fail (param != NULL);
-
- g_hash_table_insert (priv->parameters, g_strdup (param),
- g_variant_ref_sink (g_variant_new_boolean (value)));
-
- account_settings_remove_from_unset (settings, param);
-}
-
static void
account_settings_display_name_set_cb (GObject *src,
GAsyncResult *res,
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index a467275..fef3282 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -126,23 +126,9 @@ guint64 empathy_account_settings_get_uint64 (EmpathyAccountSettings *settings,
gboolean empathy_account_settings_get_boolean (EmpathyAccountSettings *settings,
const gchar *param);
-void empathy_account_settings_set_string (EmpathyAccountSettings *settings,
- const gchar *param, const gchar *value);
-void empathy_account_settings_set_strv (EmpathyAccountSettings *settings,
+void empathy_account_settings_set (EmpathyAccountSettings *settings,
const gchar *param,
- const gchar * const *value);
-
-void empathy_account_settings_set_int32 (EmpathyAccountSettings *settings,
- const gchar *param, gint32 value);
-void empathy_account_settings_set_int64 (EmpathyAccountSettings *settings,
- const gchar *param, gint64 value);
-void empathy_account_settings_set_uint32 (EmpathyAccountSettings *settings,
- const gchar *param, guint32 value);
-void empathy_account_settings_set_uint64 (EmpathyAccountSettings *settings,
- const gchar *param, guint64 value);
-
-void empathy_account_settings_set_boolean (EmpathyAccountSettings *settings,
- const gchar *param, gboolean value);
+ GVariant *v);
gchar *empathy_account_settings_get_icon_name (
EmpathyAccountSettings *settings);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]