[telepathy-mission-control/master] McdAccount: Requests: expose internal methods to create a ChannelRequest, and Proceed with it

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Apr 3 11:31:09 PDT 2009


---
 src/mcd-account-requests.c |   45 +++++++++++++++++++++++++++----------------
 src/mcd-account-requests.h |    9 ++++++++
 2 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/src/mcd-account-requests.c b/src/mcd-account-requests.c
index cdf5564..c21bde4 100644
--- a/src/mcd-account-requests.c
+++ b/src/mcd-account-requests.c
@@ -152,10 +152,11 @@ on_channel_status_changed (McdChannel *channel, McdChannelStatus status,
     }
 }
 
-static McdChannel *
-create_request (McdAccount *account, GHashTable *properties,
-                gint64 user_time, const gchar *preferred_handler,
-                gboolean use_existing, GError **error)
+McdChannel *
+_mcd_account_create_request (McdAccount *account, GHashTable *properties,
+                             gint64 user_time, const gchar *preferred_handler,
+                             gboolean use_existing, gboolean proceeding,
+                             GError **error)
 {
     McdChannel *channel;
     GHashTable *props;
@@ -163,8 +164,6 @@ create_request (McdAccount *account, GHashTable *properties,
         mcd_account_get_account_manager (account));
     DBusGConnection *dgc = tp_proxy_get_dbus_connection (dbus_daemon);
 
-    g_return_val_if_fail (error != NULL, NULL);
-
     if (mcd_mission_get_flags (MCD_MISSION (mcd_master_get_default ())) &
         MCD_SYSTEM_MEMORY_CONSERVED)
     {
@@ -180,6 +179,10 @@ create_request (McdAccount *account, GHashTable *properties,
                                        proceeding);
     g_hash_table_unref (props);
 
+    /* FIXME: this isn't ideal - if the account is deleted, Proceed will fail,
+     * whereas what we want to happen is that Proceed will succeed but
+     * immediately cause a failure to be signalled. It'll do for now though. */
+
     /* we use connect_after, to make sure that other signals (such as
      * RemoveFailedRequest) are emitted before the Failed signal */
     /* WARNING: on_channel_status_changed unrefs the McdChannel (!), so we
@@ -195,6 +198,19 @@ const McdDBusProp account_channelrequests_properties[] = {
     { 0 },
 };
 
+void
+_mcd_account_proceed_with_request (McdAccount *account,
+                                   McdChannel *channel)
+{
+    /* Put the account online if necessary, and when that's finished,
+     * make the actual request. This is the equivalent of Proceed() in the
+     * new API.
+     *
+     * (The callback releases this reference.) */
+    _mcd_account_online_request (account, online_request_cb,
+                                 g_object_ref (channel));
+}
+
 static void
 account_request_common (McdAccount *account, GHashTable *properties,
                         gint64 user_time, const gchar *preferred_handler,
@@ -205,8 +221,9 @@ account_request_common (McdAccount *account, GHashTable *properties,
     McdChannel *channel;
     McdDispatcher *dispatcher;
 
-    channel = create_request (account, properties, user_time,
-                              preferred_handler, use_existing, &error);
+    channel = _mcd_account_create_request (account, properties, user_time,
+                                           preferred_handler, use_existing,
+                                           TRUE /* proceeding */, &error);
 
     if (error)
     {
@@ -216,13 +233,7 @@ account_request_common (McdAccount *account, GHashTable *properties,
         return;
     }
 
-    /* Put the account online if necessary, and when that's finished,
-     * make the actual request. This is the equivalent of Proceed() in the
-     * new API.
-     *
-     * (The callback releases this reference.) */
-    _mcd_account_online_request (account, online_request_cb,
-                                 g_object_ref (channel));
+    _mcd_account_proceed_with_request (account, channel);
 
     request_id = _mcd_channel_get_request_path (channel);
     DEBUG ("returning %s", request_id);
@@ -236,8 +247,8 @@ account_request_common (McdAccount *account, GHashTable *properties,
     dispatcher = mcd_master_get_dispatcher (mcd_master_get_default ());
     _mcd_dispatcher_add_request (dispatcher, account, channel);
 
-    /* we still have a ref returned by create_request(), which is no longer
-     * necessary at this point */
+    /* we still have a ref returned by _mcd_account_create_request(), which
+     * is no longer necessary at this point */
     g_object_unref (channel);
 }
 
diff --git a/src/mcd-account-requests.h b/src/mcd-account-requests.h
index e6b0cdb..2440ca0 100644
--- a/src/mcd-account-requests.h
+++ b/src/mcd-account-requests.h
@@ -28,12 +28,21 @@
 /* auto-generated stubs */
 #include "_gen/svc-Account_Interface_ChannelRequests.h"
 
+#include "mcd-channel.h"
 #include "mcd-dbusprop.h"
 
 G_BEGIN_DECLS
 
 extern const McdDBusProp account_channelrequests_properties[];
 
+G_GNUC_INTERNAL McdChannel *_mcd_account_create_request (McdAccount *account,
+    GHashTable *properties, gint64 user_action_time,
+    const gchar *preferred_handler, gboolean use_existing,
+    gboolean proceeding, GError **error);
+
+G_GNUC_INTERNAL void _mcd_account_proceed_with_request (McdAccount *account,
+                                                        McdChannel *channel);
+
 void account_channelrequests_iface_init
     (McSvcAccountInterfaceChannelRequestsClass *iface, gpointer iface_data);
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list