[telepathy-glib/master] account*: remove _set_features
Jonny Lamb
jonny.lamb at collabora.co.uk
Tue Sep 22 05:30:44 PDT 2009
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
docs/reference/telepathy-glib-sections.txt | 1 -
telepathy-glib/account-manager.c | 67 +++++++---------------------
telepathy-glib/account-manager.h | 3 -
telepathy-glib/account.c | 67 +++++++---------------------
telepathy-glib/account.h | 2 -
5 files changed, 32 insertions(+), 108 deletions(-)
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index ec0dbe2..3fe9469 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -3039,7 +3039,6 @@ tp_account_is_ready
tp_account_prepare_async
tp_account_prepare_finish
tp_account_get_features
-tp_account_set_features
<SUBSECTION>
tp_cli_account_callback_for_reconnect
tp_cli_account_call_reconnect
diff --git a/telepathy-glib/account-manager.c b/telepathy-glib/account-manager.c
index ecd6fe9..915c110 100644
--- a/telepathy-glib/account-manager.c
+++ b/telepathy-glib/account-manager.c
@@ -150,11 +150,12 @@ _tp_account_manager_get_feature (TpAccountManager *self,
if (feat == NULL && add)
{
- GQuark fs[] = { feature, 0 };
- tp_account_manager_set_features (self, fs);
+ feat = g_slice_new0 (TpAccountManagerFeature);
+ feat->name = feature;
+ feat->ready = FALSE;
+ priv->features = g_list_prepend (priv->features, feat);
- /* New feature will be the first element as we use g_list_prepend */
- feat = priv->features->data;
+ g_array_append_val (priv->features_array, feature);
}
return feat;
@@ -1277,6 +1278,10 @@ tp_account_manager_is_ready (TpAccountManager *manager,
* can then call tp_account_manager_prepare_finish() to get the result of the
* operation.
*
+ * If %NULL is given to @callback, then no callback will be called when the
+ * operation is finished. Instead, it will simply set @features on @manager.
+ * Note that if @callback is %NULL, then @user_data must also be %NULL.
+ *
* Since: 0.7.UNRELEASED
*/
void
@@ -1290,9 +1295,6 @@ tp_account_manager_prepare_async (TpAccountManager *manager,
guint i;
gboolean already_ready = TRUE;
- result = g_simple_async_result_new (G_OBJECT (manager),
- callback, user_data, tp_account_manager_prepare_finish);
-
for (i = 0; features[i] != 0; i++)
{
TpAccountManagerFeature *f;
@@ -1300,12 +1302,15 @@ tp_account_manager_prepare_async (TpAccountManager *manager,
f = _tp_account_manager_get_feature (manager, features[i], TRUE);
if (!f->ready)
- {
- already_ready = FALSE;
- break;
- }
+ already_ready = FALSE;
}
+ if (callback == NULL)
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (manager),
+ callback, user_data, tp_account_manager_prepare_finish);
+
if (already_ready)
{
g_simple_async_result_complete (result);
@@ -1349,46 +1354,6 @@ tp_account_manager_prepare_finish (TpAccountManager *manager,
}
/**
- * tp_account_manager_set_features:
- * @manager: a #TpAccountManager
- * @features: a 0-terminated list of features
- *
- * Sets additional features on @manager. Features cannot be removed from
- * an object. Features which are already set on @manager will be ignored.
- *
- * Returns: %TRUE if the set was successful, otherwise %FALSE
- *
- * Since: 0.7.UNRELEASED
- */
-gboolean
-tp_account_manager_set_features (TpAccountManager *manager,
- const GQuark* features)
-{
- TpAccountManagerPrivate *priv = manager->priv;
- guint i;
-
- for (i = 0; features[i] != 0; i++)
- {
- TpAccountManagerFeature *feature;
- GQuark f = features[i];
-
- if (_tp_account_manager_get_feature (manager, f, FALSE) != NULL)
- continue;
-
- feature = g_slice_new0 (TpAccountManagerFeature);
- feature->name = f;
- feature->ready = FALSE;
- /* If _prepend is changed, _get_feature must also be changed.
- * (see comment there) */
- priv->features = g_list_prepend (priv->features, feature);
-
- g_array_append_val (priv->features_array, f);
- }
-
- return TRUE;
-}
-
-/**
* tp_account_manager_get_features:
* @manager: a #TpAccountManager
*
diff --git a/telepathy-glib/account-manager.h b/telepathy-glib/account-manager.h
index 105d5ac..c57d00d 100644
--- a/telepathy-glib/account-manager.h
+++ b/telepathy-glib/account-manager.h
@@ -103,9 +103,6 @@ void tp_account_manager_prepare_async (TpAccountManager *manager,
gboolean tp_account_manager_prepare_finish (TpAccountManager *manager,
GAsyncResult *result, GError **error);
-gboolean tp_account_manager_set_features (TpAccountManager *manager,
- const GQuark* features);
-
const GQuark * tp_account_manager_get_features (TpAccountManager *manager);
G_END_DECLS
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 551e75c..58b7569 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -212,11 +212,12 @@ _tp_account_get_feature (TpAccount *self,
if (feat == NULL && add)
{
- GQuark fs[] = { feature, 0 };
- tp_account_set_features (self, fs);
+ feat = g_slice_new0 (TpAccountFeature);
+ feat->name = feature;
+ feat->ready = FALSE;
+ priv->features = g_list_prepend (priv->features, feat);
- /* New feature will be the first element as we use g_list_prepend */
- feat = priv->features->data;
+ g_array_append_val (priv->features_array, feature);
}
return feat;
@@ -2532,6 +2533,10 @@ tp_account_is_ready (TpAccount *account,
* can then call tp_account_prepare_finish() to get the result of the
* operation.
*
+ * If %NULL is given to @callback, then no callback will be called when the
+ * operation is finished. Instead, it will simply set @features on @manager.
+ * Note that if @callback is %NULL, then @user_data must also be %NULL.
+ *
* Since: 0.7.UNRELEASED
*/
void
@@ -2545,9 +2550,6 @@ tp_account_prepare_async (TpAccount *account,
guint i;
gboolean already_ready = TRUE;
- result = g_simple_async_result_new (G_OBJECT (account),
- callback, user_data, tp_account_prepare_finish);
-
for (i = 0; features[i] != 0; i++)
{
TpAccountFeature *f;
@@ -2555,12 +2557,15 @@ tp_account_prepare_async (TpAccount *account,
f = _tp_account_get_feature (account, features[i], TRUE);
if (!f->ready)
- {
- already_ready = FALSE;
- break;
- }
+ already_ready = FALSE;
}
+ if (callback == NULL)
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (account),
+ callback, user_data, tp_account_prepare_finish);
+
if (already_ready)
{
g_simple_async_result_complete (result);
@@ -2604,46 +2609,6 @@ tp_account_prepare_finish (TpAccount *account,
}
/**
- * tp_account_set_features:
- * @account: a #TpAccount
- * @features: a 0-terminated list of features
- *
- * Sets additional features on @account. Features cannot be removed from
- * an object. Features which are already set on @account will be ignored.
- *
- * Returns: %TRUE if the set was successful, otherwise %FALSE
- *
- * Since: 0.7.UNRELEASED
- */
-gboolean
-tp_account_set_features (TpAccount *account,
- const GQuark* features)
-{
- TpAccountPrivate *priv = account->priv;
- guint i;
-
- for (i = 0; features[i] != 0; i++)
- {
- TpAccountFeature *feature;
- GQuark f = features[i];
-
- if (_tp_account_get_feature (account, f, FALSE) != NULL)
- continue;
-
- feature = g_slice_new0 (TpAccountFeature);
- feature->name = f;
- feature->ready = FALSE;
- /* If _prepend is changed, _get_feature must also be changed.
- * (see comment there) */
- priv->features = g_list_prepend (priv->features, feature);
-
- g_array_append_val (priv->features_array, f);
- }
-
- return TRUE;
-}
-
-/**
* tp_account_get_features:
* @account: a #TpAccount
*
diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h
index 7ddb4b2..962d8b7 100644
--- a/telepathy-glib/account.h
+++ b/telepathy-glib/account.h
@@ -201,8 +201,6 @@ void tp_account_prepare_async (TpAccount *account, GQuark* features,
gboolean tp_account_prepare_finish (TpAccount *account, GAsyncResult *result,
GError **error);
-gboolean tp_account_set_features (TpAccount *account, const GQuark* features);
-
const GQuark * tp_account_get_features (TpAccount *account);
G_END_DECLS
--
1.5.6.5
More information about the telepathy-commits
mailing list