summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2009-04-29 15:32:43 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2009-05-15 18:24:23 +0100
commit63434b7998fd87de0536b1bdf661727e336e7531 (patch)
treeb79121979381e36d8d891636a68efd43c61a4421
parent6fc6582b4ec056045b692df514a23311f4293f3f (diff)
UNFINISHED: Assume all connections support Requests until otherwise discoveredwip-assume-requests
-rw-r--r--src/mcd-connection.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index b00dd4d8..1bf584c8 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -1214,6 +1214,8 @@ mcd_connection_found_channel (McdConnection *self,
}
}
+static void mcd_connection_setup_pre_requests (McdConnection *connection);
+
static void get_all_requests_cb (TpProxy *proxy, GHashTable *properties,
const GError *error, gpointer user_data,
GObject *weak_object)
@@ -1227,6 +1229,8 @@ static void get_all_requests_cb (TpProxy *proxy, GHashTable *properties,
if (error)
{
g_warning ("%s got error: %s", G_STRFUNC, error->message);
+ /* fall back to the legacy API */
+ mcd_connection_setup_pre_requests (connection);
return;
}
@@ -1745,23 +1749,16 @@ _mcd_connection_request_channel (McdConnection *connection,
if (!tp_connection_is_ready (priv->tp_conn))
{
- /* don't request any channel until the connection is ready (because we
- * don't know if the CM implements the Requests interface). The channel
- * will be processed once the connection is ready */
+ /* don't request any channel until the connection is ready (because
+ * all requests will fail until it's connected). */
return TRUE;
}
- if (priv->has_requests_if)
- ret = request_channel_new_iface (connection, channel);
- else
- {
- mcd_channel_take_error (channel,
- g_error_new (TP_ERRORS,
- TP_ERROR_NOT_IMPLEMENTED,
- "No Requests interface"));
- mcd_mission_abort ((McdMission *) channel);
- return TRUE;
- }
+ /* we now only support requesting channels via CreateChannel/EnsureChannel
+ * and assume Requests is supported - if this assumption fails, the CM
+ * will eventually send us an error reply, so optimize for the ideal
+ * case. */
+ ret = request_channel_new_iface (connection, channel);
if (ret)
_mcd_channel_set_status (channel, MCD_CHANNEL_STATUS_REQUESTED);
@@ -2161,6 +2158,14 @@ _mcd_connection_set_tp_connection (McdConnection *connection,
TP_CONNECTION_STATUS_REASON_NETWORK_ERROR);
return;
}
+
+ /* Assume that the TpConnection does support Requests - since
+ * telepathy-spec 0.17.23 it's mandatory. If it doesn't, we'll fall back.
+ */
+ tp_proxy_add_interface_by_id ((TpProxy *) priv->tp_conn,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS);
+ mcd_connection_setup_requests (connection);
+
_mcd_account_tp_connection_changed (priv->account);
/* Setup signals */
@@ -2169,6 +2174,7 @@ _mcd_connection_set_tp_connection (McdConnection *connection,
g_signal_connect (priv->tp_conn, "notify::status",
G_CALLBACK (on_connection_status_changed),
connection);
+
/* HACK for cancelling the _call_when_ready() callback when our object gets
* destroyed */
connection_ptr = g_slice_alloc (sizeof (McdConnection *));