1.1 --- a/gmyth-dbus/debian/changelog Fri Oct 26 23:03:22 2007 +0100
1.2 +++ b/gmyth-dbus/debian/changelog Mon Oct 29 19:56:35 2007 +0000
1.3 @@ -1,3 +1,9 @@
1.4 +gmyth-dbus (0.1.1) unstable; urgency=low
1.5 +
1.6 + * Implemented error propagation;
1.7 +
1.8 + -- Hallyson Melo <hallyson.melo@indt.org.br> Fri, 29 Oct 2006 14:00:16 -0300
1.9 +
1.10 gmyth-dbus (0.1) unstable; urgency=low
1.11
1.12 * Initial Package.
2.1 --- a/gmyth-dbus/src/gmyth-dbus-server.c Fri Oct 26 23:03:22 2007 +0100
2.2 +++ b/gmyth-dbus/src/gmyth-dbus-server.c Mon Oct 29 19:56:35 2007 +0000
2.3 @@ -26,15 +26,31 @@
2.4 #endif
2.5
2.6
2.7 +#include <glib/gi18n.h>
2.8 #include <gmyth/gmyth.h>
2.9 #include <dbus/dbus-glib-bindings.h>
2.10
2.11 -
2.12 #include "gmyth-dbus-common.h"
2.13 #include "gmyth-dbus-server.h"
2.14
2.15 #define MYTH_DEFAULT_DB "mythconverg"
2.16
2.17 +enum
2.18 +{
2.19 + GMYTH_DBUS_ERROR_MYTHTV,
2.20 + GMYTH_DBUS_ERROR_CONNECTION,
2.21 + GMYTH_DBUS_ERROR_EPG,
2.22 + GMYTH_DBUS_ERROR_SCHEDULE
2.23 +};
2.24 +
2.25 +#define GMYTH_DBUS_ERROR gmyth_dbus_error_quark ()
2.26 +
2.27 +GQuark
2.28 +gmyth_dbus_error_quark (void)
2.29 +{
2.30 + return g_quark_from_static_string ("gmyth-dbus-error-quark");
2.31 +}
2.32 +
2.33 typedef struct _GMythDbusServerPrivate GMythDbusServerPrivate;
2.34
2.35 struct _GMythDbusServerPrivate
2.36 @@ -83,10 +99,11 @@
2.37 gint channel_id,
2.38 const gchar *start_time,
2.39 const gchar *end_time,
2.40 - GPtrArray **program_list);
2.41 + GPtrArray **program_list,
2.42 + GError **error);
2.43 static gboolean gmyth_dbus_server_get_schedule_list (GObject *obj,
2.44 - GPtrArray **schedule_list);
2.45 -
2.46 + GPtrArray **schedule_list,
2.47 + GError **error);
2.48 static gboolean gmyth_dbus_server_connected (GObject *obj,
2.49 gboolean *status,
2.50 GError **error);
2.51 @@ -168,13 +185,20 @@
2.52 }
2.53
2.54 static gboolean
2.55 -gmyth_dbus_server_connect_epg (GMythDbusServer *server)
2.56 +gmyth_dbus_server_connect_epg (GMythDbusServer *server, GError **error)
2.57 {
2.58 GMythDbusServerPrivate *priv;
2.59 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (server);
2.60
2.61 if (!priv->connected)
2.62 + {
2.63 + g_set_error (error,
2.64 + GMYTH_DBUS_ERROR,
2.65 + GMYTH_DBUS_ERROR_CONNECTION,
2.66 + _("Not connected"));
2.67 +
2.68 return FALSE;
2.69 + }
2.70
2.71 if (!priv->myth_epg)
2.72 {
2.73 @@ -183,6 +207,12 @@
2.74 {
2.75 g_object_unref (priv->myth_epg);
2.76 priv->myth_epg = NULL;
2.77 +
2.78 + g_set_error (error,
2.79 + GMYTH_DBUS_ERROR,
2.80 + GMYTH_DBUS_ERROR_EPG,
2.81 + _("Fail to connect with EPG"));
2.82 +
2.83 return FALSE;
2.84 }
2.85 }
2.86 @@ -191,13 +221,21 @@
2.87 }
2.88
2.89 static gboolean
2.90 -gmyth_dbus_server_connect_scheduler (GMythDbusServer *server)
2.91 +gmyth_dbus_server_connect_scheduler (GMythDbusServer *server,
2.92 + GError **error)
2.93 {
2.94 GMythDbusServerPrivate *priv;
2.95 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (server);
2.96
2.97 if (!priv->connected)
2.98 + {
2.99 + g_set_error (error,
2.100 + GMYTH_DBUS_ERROR,
2.101 + GMYTH_DBUS_ERROR_CONNECTION,
2.102 + _("Not connected"));
2.103 +
2.104 return FALSE;
2.105 + }
2.106
2.107 if (!priv->myth_scheduler)
2.108 {
2.109 @@ -207,6 +245,12 @@
2.110 {
2.111 g_object_unref (priv->myth_scheduler);
2.112 priv->myth_scheduler = NULL;
2.113 +
2.114 + g_set_error (error,
2.115 + GMYTH_DBUS_ERROR,
2.116 + GMYTH_DBUS_ERROR_SCHEDULE,
2.117 + _("Fail to connect with Schedule"));
2.118 +
2.119 return FALSE;
2.120 }
2.121 }
2.122 @@ -230,7 +274,7 @@
2.123
2.124 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.125
2.126 - if (priv->myth_backend)
2.127 + if (priv->connected)
2.128 {
2.129 gmyth_dbus_server_disconnect (obj, NULL);
2.130 }
2.131 @@ -249,10 +293,14 @@
2.132 }
2.133 else
2.134 {
2.135 - g_debug ("FAIL TO CONNECT");
2.136 g_object_unref (priv->myth_backend);
2.137 priv->myth_backend = NULL;
2.138 *result = FALSE;
2.139 +
2.140 + g_set_error (error,
2.141 + GMYTH_DBUS_ERROR,
2.142 + GMYTH_DBUS_ERROR_CONNECTION,
2.143 + _("Fail to connect with backend"));
2.144 }
2.145
2.146 priv->connected = *result;
2.147 @@ -329,6 +377,16 @@
2.148
2.149 socket = gmyth_backend_info_get_connected_socket (priv->myth_backend);
2.150
2.151 + if (!socket)
2.152 + {
2.153 + g_set_error (error,
2.154 + GMYTH_DBUS_ERROR,
2.155 + GMYTH_DBUS_ERROR_MYTHTV,
2.156 + _("MythTv not avaliable"));
2.157 + return FALSE;
2.158 +
2.159 + }
2.160 +
2.161 details = NULL;
2.162 gmyth_util_get_backend_details (socket,
2.163 &details);
2.164 @@ -341,6 +399,13 @@
2.165
2.166 ret = TRUE;
2.167 }
2.168 + else
2.169 + {
2.170 + g_set_error (error,
2.171 + GMYTH_DBUS_ERROR,
2.172 + GMYTH_DBUS_ERROR_MYTHTV,
2.173 + _("Fail to get MythTv details"));
2.174 + }
2.175
2.176 g_object_unref (socket);
2.177
2.178 @@ -375,8 +440,10 @@
2.179
2.180 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
2.181
2.182 - if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj)))
2.183 + if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
2.184 + {
2.185 return FALSE;
2.186 + }
2.187
2.188 ch_type = GMYTH_DBUS_CHANNEL_G_TYPE;
2.189
2.190 @@ -391,6 +458,13 @@
2.191 *info = g_value_get_boxed (&v);
2.192 return TRUE;
2.193 }
2.194 + else
2.195 + {
2.196 + g_set_error (error,
2.197 + GMYTH_DBUS_ERROR,
2.198 + GMYTH_DBUS_ERROR_EPG,
2.199 + _("no channel info avaliable"));
2.200 + }
2.201
2.202 return FALSE;
2.203 }
2.204 @@ -411,7 +485,7 @@
2.205 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.206
2.207 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
2.208 - if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj)))
2.209 + if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
2.210 return FALSE;
2.211
2.212
2.213 @@ -460,7 +534,8 @@
2.214 gint channel_id,
2.215 const gchar *start_time,
2.216 const gchar *end_time,
2.217 - GPtrArray **programs)
2.218 + GPtrArray **programs,
2.219 + GError **error)
2.220 {
2.221 GList *list;
2.222 GList *walk;
2.223 @@ -474,7 +549,7 @@
2.224 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.225
2.226 g_return_val_if_fail (priv->myth_backend, FALSE);
2.227 - if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj)))
2.228 + if (!gmyth_dbus_server_connect_epg (GMYTH_DBUS_SERVER (obj), error))
2.229 return FALSE;
2.230
2.231 g_time_val_from_iso8601 (start_time, &start_time_val);
2.232 @@ -574,7 +649,7 @@
2.233
2.234 g_return_val_if_fail (priv->myth_backend, FALSE);
2.235
2.236 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.237 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.238 return FALSE;
2.239
2.240 record_type = GMYTH_DBUS_RECORD_G_TYPE;
2.241 @@ -597,6 +672,14 @@
2.242
2.243 return TRUE;
2.244 }
2.245 + else
2.246 + {
2.247 + g_set_error (error,
2.248 + GMYTH_DBUS_ERROR,
2.249 + GMYTH_DBUS_ERROR_EPG,
2.250 + _("no record info avaliable"));
2.251 +
2.252 + }
2.253
2.254 return FALSE;
2.255 }
2.256 @@ -617,7 +700,7 @@
2.257 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.258
2.259 g_return_val_if_fail (priv->myth_backend != NULL, FALSE);
2.260 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.261 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.262 return FALSE;
2.263
2.264
2.265 @@ -652,7 +735,8 @@
2.266
2.267 static gboolean
2.268 gmyth_dbus_server_get_schedule_list (GObject *obj,
2.269 - GPtrArray **schedules)
2.270 + GPtrArray **schedules,
2.271 + GError **error)
2.272 {
2.273 GList *list;
2.274 GList *walk;
2.275 @@ -664,7 +748,7 @@
2.276 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.277
2.278 g_return_val_if_fail (priv->myth_backend, FALSE);
2.279 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.280 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.281 return FALSE;
2.282
2.283
2.284 @@ -733,12 +817,25 @@
2.285 g_return_val_if_fail (priv->myth_backend, FALSE);
2.286
2.287 if (!gmyth_util_file_exists (priv->myth_backend, uri))
2.288 + {
2.289 + g_set_error (error,
2.290 + GMYTH_DBUS_ERROR,
2.291 + GMYTH_DBUS_ERROR_MYTHTV,
2.292 + _("File not exists"));
2.293 +
2.294 goto fail;
2.295 + }
2.296
2.297 file_transfer = gmyth_file_transfer_new (priv->myth_backend);
2.298
2.299 if (!gmyth_file_transfer_open (file_transfer, uri))
2.300 + {
2.301 + g_set_error (error,
2.302 + GMYTH_DBUS_ERROR,
2.303 + GMYTH_DBUS_ERROR_MYTHTV,
2.304 + _("Fail to open file"));
2.305 goto fail;
2.306 + }
2.307
2.308 filesize = gmyth_file_transfer_get_filesize (file_transfer);
2.309 if (filesize <= 0)
2.310 @@ -747,13 +844,27 @@
2.311 *image = g_byte_array_new ();
2.312 result = gmyth_file_transfer_read (file_transfer, *image, filesize, FALSE);
2.313 if (result == GMYTH_FILE_READ_ERROR)
2.314 + {
2.315 + g_set_error (error,
2.316 + GMYTH_DBUS_ERROR,
2.317 + GMYTH_DBUS_ERROR_MYTHTV,
2.318 + _("Fail to read file"));
2.319 +
2.320 goto fail;
2.321 + }
2.322
2.323 gmyth_file_transfer_close (file_transfer);
2.324 g_object_unref (file_transfer);
2.325
2.326 if (filesize > (*image)->len)
2.327 + {
2.328 + g_set_error (error,
2.329 + GMYTH_DBUS_ERROR,
2.330 + GMYTH_DBUS_ERROR_MYTHTV,
2.331 + _("Empty file"));
2.332 +
2.333 goto fail;
2.334 + }
2.335
2.336 return TRUE;
2.337
2.338 @@ -785,12 +896,23 @@
2.339 *icon = NULL;
2.340
2.341 if (channel == NULL)
2.342 + {
2.343 + g_set_error (error,
2.344 + GMYTH_DBUS_ERROR,
2.345 + GMYTH_DBUS_ERROR_MYTHTV,
2.346 + _("Invalid channel"));
2.347 +
2.348 return FALSE;
2.349 + }
2.350
2.351 if (!gmyth_epg_channel_has_icon(priv->myth_epg, channel))
2.352 {
2.353 gmyth_channel_info_free (channel);
2.354 - g_debug("Channel does not have icon available");
2.355 + g_set_error (error,
2.356 + GMYTH_DBUS_ERROR,
2.357 + GMYTH_DBUS_ERROR_MYTHTV,
2.358 + _("Channel does not have icon available"));
2.359 +
2.360 return FALSE;
2.361 }
2.362
2.363 @@ -802,7 +924,11 @@
2.364 &icon_length))
2.365 {
2.366 gmyth_channel_info_free (channel);
2.367 - g_warning("Could not get channel icon for channel id = %u", channel_id);
2.368 + g_set_error (error,
2.369 + GMYTH_DBUS_ERROR,
2.370 + GMYTH_DBUS_ERROR_MYTHTV,
2.371 + _("Could not get channel icon for channel id = %u"),
2.372 + channel_id);
2.373 return FALSE;
2.374 }
2.375
2.376 @@ -828,7 +954,7 @@
2.377 priv = GMYTH_DBUS_SERVER_GET_PRIVATE (obj);
2.378
2.379 g_return_val_if_fail (priv->myth_backend, FALSE);
2.380 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.381 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.382 return FALSE;
2.383
2.384 ret = gmyth_scheduler_stop_recording (priv->myth_scheduler,
2.385 @@ -893,7 +1019,7 @@
2.386
2.387 g_return_val_if_fail (priv->myth_backend, FALSE);
2.388
2.389 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.390 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.391 return FALSE;
2.392
2.393
2.394 @@ -980,7 +1106,7 @@
2.395
2.396 g_return_val_if_fail (priv->myth_backend, FALSE);
2.397
2.398 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.399 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.400 return FALSE;
2.401
2.402 g_time_val_from_iso8601 (start_time, &start_vtime);
2.403 @@ -1020,7 +1146,7 @@
2.404
2.405 g_return_val_if_fail (priv->myth_backend, FALSE);
2.406
2.407 - if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj)))
2.408 + if (!gmyth_dbus_server_connect_scheduler (GMYTH_DBUS_SERVER (obj), error))
2.409 return FALSE;
2.410
2.411 return gmyth_scheduler_delete_schedule (priv->myth_scheduler, schedule_id);