[telepathy-mission-control/master] _mcd_account_online_request: deny the request if the account is invalid or disabled
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Jun 25 08:02:29 PDT 2009
---
src/mcd-account.c | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 5e08dfb..36ff8a5 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -2724,29 +2724,51 @@ _mcd_account_online_request (McdAccount *account,
gpointer userdata)
{
McdAccountPrivate *priv = account->priv;
+ McdOnlineRequestData *data;
DEBUG ("connection status for %s is %d",
priv->unique_name, priv->conn_status);
if (priv->conn_status == TP_CONNECTION_STATUS_CONNECTED)
{
/* invoke the callback now */
+ DEBUG ("%s is already connected", priv->unique_name);
callback (account, userdata, NULL);
+ return;
}
- else
+
+ if (!priv->valid)
{
- McdOnlineRequestData *data;
- /* listen to the StatusChanged signal */
- if (priv->conn_status == TP_CONNECTION_STATUS_DISCONNECTED)
- _mcd_account_request_connection (account);
+ /* FIXME: pick a better error and put it in telepathy-spec? */
+ GError e = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "account isn't Valid (not enough information to put it online)" };
- /* now the connection should be in connecting state; insert the
- * callback in the online_requests hash table, which will be processed
- * in the connection-status-changed callback */
- data = g_slice_new (McdOnlineRequestData);
- data->callback = callback;
- data->user_data = userdata;
- priv->online_requests = g_list_append (priv->online_requests, data);
+ DEBUG ("%s: %s", priv->unique_name, e.message);
+ callback (account, userdata, &e);
+ return;
}
+
+ if (!priv->enabled)
+ {
+ /* FIXME: pick a better error and put it in telepathy-spec? */
+ GError e = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "account isn't Enabled" };
+
+ DEBUG ("%s: %s", priv->unique_name, e.message);
+ callback (account, userdata, &e);
+ return;
+ }
+
+ /* listen to the StatusChanged signal */
+ if (priv->conn_status == TP_CONNECTION_STATUS_DISCONNECTED)
+ _mcd_account_request_connection (account);
+
+ /* now the connection should be in connecting state; insert the
+ * callback in the online_requests hash table, which will be processed
+ * in the connection-status-changed callback */
+ data = g_slice_new (McdOnlineRequestData);
+ data->callback = callback;
+ data->user_data = userdata;
+ priv->online_requests = g_list_append (priv->online_requests, data);
}
GKeyFile *
--
1.5.6.5
More information about the telepathy-commits
mailing list