[Telepathy-commits] [telepathy-mission-control/master] Make the McdChannel error API public

Alberto Mardegan alberto.mardegan at nokia.com
Thu Feb 12 04:58:20 PST 2009


Also, rename _mcd_channel_set_error() to mcd_channel_take_error().
---
 src/mcd-account-compat.c   |    2 +-
 src/mcd-account-requests.c |    8 ++++----
 src/mcd-channel.c          |   24 ++++++++++++------------
 src/mcd-channel.h          |    9 ++++-----
 src/mcd-connection.c       |   10 +++++-----
 src/mcd-dispatcher.c       |   14 +++++++-------
 6 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/src/mcd-account-compat.c b/src/mcd-account-compat.c
index 7e7f9d8..fb214a2 100644
--- a/src/mcd-account-compat.c
+++ b/src/mcd-account-compat.c
@@ -276,7 +276,7 @@ on_channel_status_changed (McdChannel *channel, McdChannelStatus status,
         master = mcd_master_get_default ();
         g_return_if_fail (MCD_IS_SERVICE (master));
 
-        error = _mcd_channel_get_error (channel);
+        error = mcd_channel_get_error (channel);
         g_signal_emit_by_name (master, "mcd-error",
                                req_data->requestor_serial,
                                req_data->requestor_client_id, error->code);
diff --git a/src/mcd-account-requests.c b/src/mcd-account-requests.c
index ae40765..70d67d6 100644
--- a/src/mcd-account-requests.c
+++ b/src/mcd-account-requests.c
@@ -50,7 +50,7 @@ online_request_cb (McdAccount *account, gpointer userdata, const GError *error)
     if (error)
     {
         g_warning ("%s: got error: %s", G_STRFUNC, error->message);
-        _mcd_channel_set_error (channel, g_error_copy (error));
+        mcd_channel_take_error (channel, g_error_copy (error));
         g_object_unref (channel);
         return;
     }
@@ -123,7 +123,7 @@ on_channel_status_changed (McdChannel *channel, McdChannelStatus status,
     if (status == MCD_CHANNEL_STATUS_FAILED)
     {
         const gchar *err_string;
-        error = _mcd_channel_get_error (channel);
+        error = mcd_channel_get_error (channel);
         g_warning ("Channel request %s failed, error: %s",
                    _mcd_channel_get_request_path (channel), error->message);
 
@@ -178,7 +178,7 @@ create_request (McdAccount *account, GHashTable *properties,
     {
         g_warning ("%s: _mcd_account_online_request: %s", G_STRFUNC,
                    (*error)->message);
-        _mcd_channel_set_error (channel, g_error_copy (*error));
+        mcd_channel_take_error (channel, g_error_copy (*error));
         /* no unref here, as this will invoke our handler which will
          * unreference the channel */
         channel = NULL;
@@ -277,7 +277,7 @@ account_request_cancel (McSvcAccountInterfaceChannelRequests *self,
     {
         g_object_ref (channel);
         error = g_error_new (TP_ERRORS, TP_ERROR_CANCELLED, "Cancelled");
-        _mcd_channel_set_error (channel, error);
+        mcd_channel_take_error (channel, error);
 
         /* REQUESTED is a special case: the channel must not be aborted now,
          * because we need to explicitly close the channel object when it will
diff --git a/src/mcd-channel.c b/src/mcd-channel.c
index 2327037..13123ef 100644
--- a/src/mcd-channel.c
+++ b/src/mcd-channel.c
@@ -382,7 +382,7 @@ mcd_channel_abort (McdMission *mission)
          * we use the DISCONNECTED error code */
         GError *error = g_error_new (TP_ERRORS, TP_ERROR_DISCONNECTED,
                                      "Channel aborted");
-        _mcd_channel_set_error (channel, error);
+        mcd_channel_take_error (channel, error);
     }
     /* Don't release the TpChannel, because we might still be asked to retrieve
      * its properties or object path; instead, just close the channel */
@@ -925,17 +925,17 @@ _mcd_channel_get_target_id (McdChannel *channel)
     return tp_asv_get_string (crd->properties, TP_IFACE_CHANNEL ".TargetID");
 }
 
-/*
- * _mcd_channel_set_error:
+/**
+ * mcd_channel_take_error:
  * @channel: the #McdChannel.
  * @error: a #GError.
  *
- * Sets @error on channel, and takes ownership of it. As a side effect, if
- * @error is not %NULL this method causes the channel status be set to
- * %MCD_CHANNEL_STATUS_FAILED.
+ * Sets @error on channel, and takes ownership of it (the error will eventually
+ * be freed with g_error_free()). As a side effect, if @error is not %NULL this
+ * method causes the channel status be set to %MCD_CHANNEL_STATUS_FAILED.
  */
 void
-_mcd_channel_set_error (McdChannel *channel, GError *error)
+mcd_channel_take_error (McdChannel *channel, GError *error)
 {
     g_return_if_fail (MCD_IS_CHANNEL (channel));
     g_object_set_data_full ((GObject *)channel, CD_ERROR,
@@ -944,14 +944,14 @@ _mcd_channel_set_error (McdChannel *channel, GError *error)
         mcd_channel_set_status (channel, MCD_CHANNEL_STATUS_FAILED);
 }
 
-/*
- * _mcd_channel_get_error:
+/**
+ * mcd_channel_get_error:
  * @channel: the #McdChannel.
  *
  * Returns: the #GError, or %NULL if no error is set.
  */
 const GError *
-_mcd_channel_get_error (McdChannel *channel)
+mcd_channel_get_error (McdChannel *channel)
 {
     g_return_val_if_fail (MCD_IS_CHANNEL (channel), NULL);
     return g_object_get_data ((GObject *)channel, CD_ERROR);
@@ -1167,9 +1167,9 @@ copy_status (McdChannel *source, McdChannel *dest)
         {
             const GError *error;
 
-            error = _mcd_channel_get_error (source);
+            error = mcd_channel_get_error (source);
             /* this also takes care of setting the status */
-            _mcd_channel_set_error (dest, g_error_copy (error));
+            mcd_channel_take_error (dest, g_error_copy (error));
         }
         else
             mcd_channel_set_status (dest, src_priv->status);
diff --git a/src/mcd-channel.h b/src/mcd-channel.h
index 5a3cd24..f0742ce 100644
--- a/src/mcd-channel.h
+++ b/src/mcd-channel.h
@@ -123,6 +123,10 @@ gboolean mcd_channel_is_requested (McdChannel *channel);
 McdAccount *mcd_channel_get_account (McdChannel *channel);
 TpChannel *mcd_channel_get_tp_channel (McdChannel *channel);
 
+void mcd_channel_take_error (McdChannel *channel, GError *error);
+const GError *mcd_channel_get_error (McdChannel *channel);
+
+
 /* not exported: */
 G_GNUC_INTERNAL
 gboolean _mcd_channel_create_proxy_old (McdChannel *channel,
@@ -161,10 +165,5 @@ void _mcd_channel_copy_details (McdChannel *channel, McdChannel *source);
 G_GNUC_INTERNAL
 void _mcd_channel_set_request_proxy (McdChannel *channel, McdChannel *source);
 
-G_GNUC_INTERNAL
-void _mcd_channel_set_error (McdChannel *channel, GError *error);
-G_GNUC_INTERNAL
-const GError *_mcd_channel_get_error (McdChannel *channel);
-
 G_END_DECLS
 #endif /* MCD_CHANNEL_H */
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 031b2c4..544a501 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -579,7 +579,7 @@ on_channel_capabilities_timeout (McdChannel *channel,
     g_debug ("%s: channel %p timed out, returning error!", G_STRFUNC, channel);
 
     mc_error = map_tp_error_to_mc_error (channel, cwd->error);
-    _mcd_channel_set_error (channel, mc_error);
+    mcd_channel_take_error (channel, mc_error);
     g_object_set_data (G_OBJECT (channel), "error_on_creation", NULL);
 
     /* No abort on channel, because we are the only one holding the only
@@ -2129,7 +2129,7 @@ request_channel_cb (TpConnection *proxy, const gchar *channel_path,
 	{
 	    /* Faild dispatch */
 	    GError *mc_error = map_tp_error_to_mc_error (channel, tp_error);
-            _mcd_channel_set_error (channel, mc_error);
+            mcd_channel_take_error (channel, mc_error);
             mcd_mission_abort ((McdMission *)channel);
 	}
 	else
@@ -2162,7 +2162,7 @@ request_channel_cb (TpConnection *proxy, const gchar *channel_path,
 	mc_error = g_error_new (MC_ERROR,
 				MC_CHANNEL_REQUEST_GENERIC_ERROR,
 				"Returned channel_path from telepathy is NULL");
-        _mcd_channel_set_error (channel, mc_error);
+        mcd_channel_take_error (channel, mc_error);
         mcd_mission_abort ((McdMission *)channel);
 	return;
     }
@@ -2209,7 +2209,7 @@ request_handles_cb (TpConnection *proxy, const GArray *handles,
 	mc_error = g_error_new (MC_ERROR, MC_INVALID_HANDLE_ERROR,
 		     "Could not map string handle to a valid handle!: %s",
 		     msg);
-        _mcd_channel_set_error (channel, mc_error);
+        mcd_channel_take_error (channel, mc_error);
 	
 	/* No abort, because we are the only one holding the only reference
 	 * to this temporary channel
@@ -2282,7 +2282,7 @@ common_request_channel_cb (TpConnection *proxy, gboolean yours,
          * soon :-) */
         g_debug ("%s: Got error: %s", G_STRFUNC, error->message);
         mc_error = map_tp_error_to_mc_error (channel, error);
-        _mcd_channel_set_error (channel, mc_error);
+        mcd_channel_take_error (channel, mc_error);
         mcd_mission_abort ((McdMission *)channel);
         return;
     }
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index b3a044a..c011715 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -738,7 +738,7 @@ _mcd_dispatcher_handle_channel_async_cb (DBusGProxy * proxy, GError * error,
 	mc_error = g_error_new (MC_ERROR, MC_CHANNEL_REQUEST_GENERIC_ERROR,
 				"Handle channel failed: %s", error->message);
 
-        _mcd_channel_set_error (channel, mc_error);
+        mcd_channel_take_error (channel, mc_error);
 	g_signal_emit_by_name (context->dispatcher, "dispatch-failed",
 			       channel, mc_error);
 	
@@ -822,7 +822,7 @@ start_old_channel_handler (McdDispatcherContext *context)
 	mc_error = g_error_new (MC_ERROR, MC_CHANNEL_REQUEST_GENERIC_ERROR,
 				"No handler for channel type %s",
 				mcd_channel_get_channel_type (channel));
-        _mcd_channel_set_error (channel, mc_error);
+        mcd_channel_take_error (channel, mc_error);
 	g_signal_emit_by_name (context->dispatcher, "dispatch-failed", channel,
 			       mc_error);
         mcd_mission_abort (MCD_MISSION (channel));
@@ -1104,7 +1104,7 @@ handle_channels_cb (TpProxy *proxy, const GError *error, gpointer user_data,
         {
             McdChannel *channel = MCD_CHANNEL (list->data);
 
-            _mcd_channel_set_error (channel, g_error_copy (mc_error));
+            mcd_channel_take_error (channel, g_error_copy (mc_error));
             g_signal_emit_by_name (context->dispatcher, "dispatch-failed",
                                    channel, mc_error);
 
@@ -1559,8 +1559,8 @@ _mcd_dispatcher_context_abort (McdDispatcherContext *context,
     {
         McdChannel *channel = MCD_CHANNEL (list->data);
 
-        if (_mcd_channel_get_error (channel) == NULL)
-            _mcd_channel_set_error (channel, g_error_copy (error));
+        if (mcd_channel_get_error (channel) == NULL)
+            mcd_channel_take_error (channel, g_error_copy (error));
 
         /* FIXME: try to dispatch the channels to another handler, instead
          * of just aborting them */
@@ -1582,7 +1582,7 @@ on_channel_abort_context (McdChannel *channel, McdDispatcherContext *context)
 
     /* but if it was a channel request, and it was cancelled, then the whole
      * context should be aborted */
-    error = _mcd_channel_get_error (channel);
+    error = mcd_channel_get_error (channel);
     if (error && error->code == TP_ERROR_CANCELLED)
         context->cancelled = TRUE;
 }
@@ -2892,7 +2892,7 @@ on_request_status_changed (McdChannel *channel, McdChannelStatus status,
     {
         const GError *error;
         const gchar *err_string;
-        error = _mcd_channel_get_error (channel);
+        error = mcd_channel_get_error (channel);
         err_string = _mcd_get_error_string (error);
         /* no callback, as we don't really care */
         mc_cli_client_handler_call_remove_failed_request
-- 
1.5.6.5




More information about the telepathy-commits mailing list