[grilo-plugins/tracker-notification: 7/10] tracker: make requests more robust



commit a7e61b69373e2831c6b58e2a2e01766b549dbf11
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Fri Feb 18 17:30:06 2011 +0000

    tracker: make requests more robust
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 src/tracker/grl-tracker-notif.c |   45 +++++++++++++++++---------------------
 src/tracker/grl-tracker.c       |   19 +++++++++++-----
 2 files changed, 33 insertions(+), 31 deletions(-)
---
diff --git a/src/tracker/grl-tracker-notif.c b/src/tracker/grl-tracker-notif.c
index 9194eac..8a8d0db 100644
--- a/src/tracker/grl-tracker-notif.c
+++ b/src/tracker/grl-tracker-notif.c
@@ -181,16 +181,14 @@ tracker_evt_update_orphan_item_cb (GObject              *object,
   guint id;
   const gchar *type, *datasource;
   GrlTrackerSource *source;
-  GError *tracker_error = NULL;
+  GError *error = NULL;
 
   GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
 
-  if (!tracker_sparql_cursor_next_finish (evt->cursor,
-                                          result,
-                                          &tracker_error)) {
-    if (tracker_error != NULL) {
-      GRL_DEBUG ("\terror in parsing : %s", tracker_error->message);
-      g_error_free (tracker_error);
+  if (!tracker_sparql_cursor_next_finish (evt->cursor, result, &error)) {
+    if (error != NULL) {
+      GRL_DEBUG ("\terror in parsing : %s", error->message);
+      g_error_free (error);
     } else {
       GRL_DEBUG ("\tend of parsing...");
     }
@@ -250,19 +248,19 @@ tracker_evt_update_orphans_cb (GObject              *object,
                                GAsyncResult         *result,
                                tracker_evt_update_t *evt)
 {
-  GError *tracker_error = NULL;
+  GError *error = NULL;
 
   GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
 
   if (evt->cursor != NULL)
     g_object_unref (evt->cursor);
   evt->cursor = tracker_sparql_connection_query_finish (grl_tracker_connection,
-                                                        result, NULL);
+                                                        result, &error);
 
-  if (tracker_error != NULL) {
-    GRL_WARNING ("Could not execute sparql query: %s", tracker_error->message);
+  if (error != NULL) {
+    GRL_WARNING ("Could not execute sparql query: %s", error->message);
 
-    g_error_free (tracker_error);
+    g_error_free (error);
     tracker_evt_postupdate_sources (evt);
     return;
   }
@@ -432,16 +430,14 @@ tracker_evt_preupdate_sources_item_cb (GObject              *object,
   const gchar *type, *datasource, *uri, *datasource_name;
   gboolean volume_mounted, upnp_available, source_available;
   GrlTrackerSource *source;
-  GError *tracker_error = NULL;
+  GError *error = NULL;
 
   GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
 
-  if (!tracker_sparql_cursor_next_finish (evt->cursor,
-                                          result,
-                                          &tracker_error)) {
-    if (tracker_error != NULL) {
-      GRL_DEBUG ("\terror in parsing : %s", tracker_error->message);
-      g_error_free (tracker_error);
+  if (!tracker_sparql_cursor_next_finish (evt->cursor, result, &error)) {
+    if (error != NULL) {
+      GRL_DEBUG ("\terror in parsing : %s", error->message);
+      g_error_free (error);
     } else {
       GRL_DEBUG ("\tend of parsing... start notifying sources");
     }
@@ -493,20 +489,19 @@ tracker_evt_preupdate_sources_cb (GObject              *object,
                                   GAsyncResult         *result,
                                   tracker_evt_update_t *evt)
 {
-  GError *tracker_error = NULL;
+  GError *error = NULL;
 
   GRL_DEBUG ("%s: evt=%p", __FUNCTION__, evt);
 
   if (evt->cursor != NULL)
     g_object_unref (evt->cursor);
   evt->cursor = tracker_sparql_connection_query_finish (grl_tracker_connection,
-                                                        result, NULL);
+                                                        result, &error);
 
-  if (tracker_error != NULL) {
-    GRL_WARNING ("\tCould not execute sparql query: %s",
-                 tracker_error->message);
+  if (error != NULL) {
+    GRL_WARNING ("\tCannot handle datasource request : %s", error->message);
 
-    g_error_free (tracker_error);
+    g_error_free (error);
     tracker_evt_update_free (evt);
     return;
   }
diff --git a/src/tracker/grl-tracker.c b/src/tracker/grl-tracker.c
index 9c52d05..2ce6505 100644
--- a/src/tracker/grl-tracker.c
+++ b/src/tracker/grl-tracker.c
@@ -163,17 +163,17 @@ tracker_get_datasource_cb (GObject             *object,
 {
   const gchar *type, *datasource, *datasource_name, *uri;
   gboolean volume_mounted, upnp_available, source_available;
-  GError *tracker_error = NULL;
+  GError *error = NULL;
   GrlTrackerSource *source;
 
   GRL_DEBUG ("%s", __FUNCTION__);
 
-  if (!tracker_sparql_cursor_next_finish (cursor, result, &tracker_error)) {
-    if (tracker_error == NULL) {
+  if (!tracker_sparql_cursor_next_finish (cursor, result, &error)) {
+    if (error == NULL) {
       GRL_DEBUG ("\tEnd of parsing of devices");
     } else {
-      GRL_DEBUG ("\tError while parsing devices: %s", tracker_error->message);
-      g_error_free (tracker_error);
+      GRL_WARNING ("\tError while parsing devices: %s", error->message);
+      g_error_free (error);
     }
     g_object_unref (G_OBJECT (cursor));
     return;
@@ -215,12 +215,19 @@ tracker_get_datasources_cb (GObject      *object,
                             GAsyncResult *result,
                             gpointer      data)
 {
+  GError *error = NULL;
   TrackerSparqlCursor *cursor;
 
   GRL_DEBUG ("%s", __FUNCTION__);
 
   cursor = tracker_sparql_connection_query_finish (grl_tracker_connection,
-                                                   result, NULL);
+                                                   result, &error);
+
+  if (error) {
+    GRL_WARNING ("Cannot handle datasource request : %s", error->message);
+    g_error_free (error);
+    return;
+  }
 
   tracker_sparql_cursor_next_async (cursor, NULL,
                                     (GAsyncReadyCallback) tracker_get_datasource_cb,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]