aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-07-26 23:09:06 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-07-30 06:13:20 +0800
commita84e75c56b59533a551a411ff7a2aa7d88659cd4 (patch)
treeb884cd8715271e1f16a3b456e50210bfe0bd0b8e /libempathy
parent72ae76e34c0c57b326be53f860bbc12cadf1ceb8 (diff)
downloadgsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar.gz
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar.bz2
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar.lz
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar.xz
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.tar.zst
gsoc2013-empathy-a84e75c56b59533a551a411ff7a2aa7d88659cd4.zip
Add empathy_account_settings_is_valid ()
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-account-settings.c60
-rw-r--r--libempathy/empathy-account-settings.h1
2 files changed, 61 insertions, 0 deletions
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 4e32dfcfa..59cfcc525 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -72,6 +72,7 @@ struct _EmpathyAccountSettingsPriv
GHashTable *parameters;
GArray *unset_parameters;
+ GArray *required_params;
gulong managers_ready_id;
gulong account_ready_id;
@@ -360,6 +361,23 @@ empathy_account_settings_check_readyness (EmpathyAccountSettings *self)
return;
}
+ if (priv->required_params == NULL)
+ {
+ TpConnectionManagerParam *cur;
+ char *val;
+
+ priv->required_params = g_array_new (TRUE, FALSE, sizeof (gchar *));
+
+ for (cur = priv->tp_protocol->params; cur->name != NULL; cur++)
+ {
+ if (tp_connection_manager_param_is_required (cur))
+ {
+ val = g_strdup (cur->name);
+ g_array_append_val (priv->required_params, val);
+ }
+ }
+ }
+
g_object_ref (priv->manager);
priv->ready = TRUE;
@@ -1022,3 +1040,45 @@ empathy_account_settings_owns_account (EmpathyAccountSettings *settings,
return (account == priv->account);
}
+
+gboolean
+empathy_account_settings_is_valid (EmpathyAccountSettings *settings)
+{
+ EmpathyAccountSettingsPriv *priv;
+ int idx;
+ gchar *current;
+ gboolean missed = FALSE;
+
+ g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), FALSE);
+
+ priv = GET_PRIV (settings);
+
+ for (idx = 0; idx < priv->required_params->len; idx++)
+ {
+ current = g_array_index (priv->required_params, gchar *, idx);
+
+ /* first, look if it's set in our own parameters */
+ if (tp_asv_lookup (priv->parameters, current))
+ continue;
+
+ /* if we did not unset the parameter, look if it's in the account */
+ if (priv->account != NULL &&
+ !empathy_account_settings_is_unset (settings, current))
+ {
+ const GHashTable *account_params;
+
+ account_params = empathy_account_get_parameters (priv->account);
+ if (tp_asv_lookup (account_params, current))
+ continue;
+ }
+
+ /* see if there's a default value */
+ if (empathy_account_settings_get_default (settings, current))
+ continue;
+
+ missed = TRUE;
+ break;
+ }
+
+ return !missed;
+}
diff --git a/libempathy/empathy-account-settings.h b/libempathy/empathy-account-settings.h
index 8119879cc..b660addd0 100644
--- a/libempathy/empathy-account-settings.h
+++ b/libempathy/empathy-account-settings.h
@@ -153,6 +153,7 @@ gboolean empathy_account_settings_apply_finish (
GAsyncResult *result,
GError **error);
+gboolean empathy_account_settings_is_valid (EmpathyAccountSettings *settings);
G_END_DECLS