[tracker/external-crawler: 23/31] libtracker-miner: Rename TrackerEnumerator members 'start' to 'get-children'



commit 9affed385f5c74c8b040570d8de42ca85041c4ee
Author: Martyn Russell <martyn lanedo com>
Date:   Wed May 21 10:49:48 2014 +0100

    libtracker-miner: Rename TrackerEnumerator members 'start' to 'get-children'
    
    API was a bit weird calling _start_finish().

 src/libtracker-miner/tracker-crawler.c             |   18 ++--
 src/libtracker-miner/tracker-enumerator.c          |   44 +++++-----
 src/libtracker-miner/tracker-enumerator.h          |   70 ++++++++--------
 src/libtracker-miner/tracker-file-enumerator.c     |   88 ++++++++++----------
 .../tracker-file-enumerator-test.c                 |   14 ++--
 5 files changed, 117 insertions(+), 117 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
index 1d418a0..ecc477a 100644
--- a/src/libtracker-miner/tracker-crawler.c
+++ b/src/libtracker-miner/tracker-crawler.c
@@ -725,7 +725,7 @@ file_enumerate_children_cb (GObject      *object,
        parent = ed->dir_info->node->data;
        enumerator = TRACKER_ENUMERATOR (object);
 
-       files = tracker_enumerator_start_finish (enumerator, result, &error);
+       files = tracker_enumerator_get_children_finish (enumerator, result, &error);
 
        if (!files) {
                if (error && !cancelled) {
@@ -798,14 +798,14 @@ file_enumerate_children (TrackerCrawler          *crawler,
                attrs = g_strdup (FILE_ATTRIBUTES);
        }
 
-       tracker_enumerator_start_async (crawler->priv->enumerator,
-                                       ed->dir_file,
-                                       attrs,
-                                       G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                       G_PRIORITY_LOW,
-                                       ed->cancellable,
-                                       file_enumerate_children_cb,
-                                       ed);
+       tracker_enumerator_get_children_async (crawler->priv->enumerator,
+                                              ed->dir_file,
+                                              attrs,
+                                              G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                              G_PRIORITY_LOW,
+                                              ed->cancellable,
+                                              file_enumerate_children_cb,
+                                              ed);
        g_free (attrs);
 }
 
diff --git a/src/libtracker-miner/tracker-enumerator.c b/src/libtracker-miner/tracker-enumerator.c
index b3cb8ef..5cda32f 100644
--- a/src/libtracker-miner/tracker-enumerator.c
+++ b/src/libtracker-miner/tracker-enumerator.c
@@ -34,12 +34,12 @@ tracker_enumerator_default_init (TrackerEnumeratorInterface *iface)
 }
 
 GSList *
-tracker_enumerator_start (TrackerEnumerator    *enumerator,
-                          GFile                *dir,
-                          const gchar          *attributes,
-                          GFileQueryInfoFlags   flags,
-                          GCancellable         *cancellable,
-                          GError              **error)
+tracker_enumerator_get_children (TrackerEnumerator    *enumerator,
+                                 GFile                *dir,
+                                 const gchar          *attributes,
+                                 GFileQueryInfoFlags   flags,
+                                 GCancellable         *cancellable,
+                                 GError              **error)
 {
        TrackerEnumeratorIface *iface;
 
@@ -51,7 +51,7 @@ tracker_enumerator_start (TrackerEnumerator    *enumerator,
 
        iface = TRACKER_ENUMERATOR_GET_IFACE (enumerator);
 
-       if (iface->start == NULL) {
+       if (iface->get_children == NULL) {
                g_set_error_literal (error,
                                     G_IO_ERROR,
                                     G_IO_ERROR_NOT_SUPPORTED,
@@ -59,18 +59,18 @@ tracker_enumerator_start (TrackerEnumerator    *enumerator,
                return NULL;
        }
 
-       return (* iface->start) (enumerator, dir, attributes, flags, cancellable, error);
+       return (* iface->get_children) (enumerator, dir, attributes, flags, cancellable, error);
 }
 
 void
-tracker_enumerator_start_async (TrackerEnumerator    *enumerator,
-                                GFile                *dir,
-                                const gchar          *attributes,
-                                GFileQueryInfoFlags   flags,
-                                int                   io_priority,
-                                GCancellable         *cancellable,
-                                GAsyncReadyCallback   callback,
-                                gpointer              user_data)
+tracker_enumerator_get_children_async (TrackerEnumerator    *enumerator,
+                                       GFile                *dir,
+                                       const gchar          *attributes,
+                                       GFileQueryInfoFlags   flags,
+                                       int                   io_priority,
+                                       GCancellable         *cancellable,
+                                       GAsyncReadyCallback   callback,
+                                       gpointer              user_data)
 {
        TrackerEnumeratorIface *iface;
 
@@ -78,18 +78,18 @@ tracker_enumerator_start_async (TrackerEnumerator    *enumerator,
 
        iface = TRACKER_ENUMERATOR_GET_IFACE (enumerator);
 
-       if (iface->start_async == NULL) {
+       if (iface->get_children_async == NULL) {
                g_critical (_("Operation not supported"));
                return;
        }
 
-       (* iface->start_async) (enumerator, dir, attributes, flags, io_priority, cancellable, callback, 
user_data);
+       (* iface->get_children_async) (enumerator, dir, attributes, flags, io_priority, cancellable, 
callback, user_data);
 }
 
 GSList *
-tracker_enumerator_start_finish (TrackerEnumerator  *enumerator,
-                                 GAsyncResult       *result,
-                                 GError            **error)
+tracker_enumerator_get_children_finish (TrackerEnumerator  *enumerator,
+                                        GAsyncResult       *result,
+                                        GError            **error)
 {
        TrackerEnumeratorIface *iface;
 
@@ -102,5 +102,5 @@ tracker_enumerator_start_finish (TrackerEnumerator  *enumerator,
                return NULL;
        }
 
-       return (* iface->start_finish) (enumerator, result, error);
+       return (* iface->get_children_finish) (enumerator, result, error);
 }
diff --git a/src/libtracker-miner/tracker-enumerator.h b/src/libtracker-miner/tracker-enumerator.h
index 9525bcf..22f728a 100644
--- a/src/libtracker-miner/tracker-enumerator.h
+++ b/src/libtracker-miner/tracker-enumerator.h
@@ -42,44 +42,44 @@ struct _TrackerEnumeratorIface {
        GTypeInterface g_iface;
 
        /* Virtual Table */
-       GSList * (* start)        (TrackerEnumerator    *enumerator,
-                                  GFile                *dir,
-                                  const gchar          *attributes,
-                                  GFileQueryInfoFlags   flags,
-                                  GCancellable         *cancellable,
-                                  GError              **error);
-       void     (* start_async)  (TrackerEnumerator    *enumerator,
-                                  GFile                *dir,
-                                  const gchar          *attributes,
-                                  GFileQueryInfoFlags   flags,
-                                  int                   io_priority,
-                                  GCancellable         *cancellable,
-                                  GAsyncReadyCallback   callback,
-                                  gpointer              user_data);
-       GSList * (* start_finish) (TrackerEnumerator    *enumerator,
-                                  GAsyncResult         *result,
-                                  GError              **error);
+       GSList * (* get_children)        (TrackerEnumerator    *enumerator,
+                                         GFile                *dir,
+                                         const gchar          *attributes,
+                                         GFileQueryInfoFlags   flags,
+                                         GCancellable         *cancellable,
+                                         GError              **error);
+       void     (* get_children_async)  (TrackerEnumerator    *enumerator,
+                                         GFile                *dir,
+                                         const gchar          *attributes,
+                                         GFileQueryInfoFlags   flags,
+                                         int                   io_priority,
+                                         GCancellable         *cancellable,
+                                         GAsyncReadyCallback   callback,
+                                         gpointer              user_data);
+       GSList * (* get_children_finish) (TrackerEnumerator    *enumerator,
+                                         GAsyncResult         *result,
+                                         GError              **error);
 
 };
 
-GType   tracker_enumerator_get_type      (void) G_GNUC_CONST;
-GSList *tracker_enumerator_start         (TrackerEnumerator    *enumerator,
-                                          GFile                *dir,
-                                          const gchar          *attributes,
-                                          GFileQueryInfoFlags   flags,
-                                          GCancellable         *cancellable,
-                                          GError              **error);
-void    tracker_enumerator_start_async   (TrackerEnumerator    *enumerator,
-                                          GFile                *dir,
-                                          const gchar          *attributes,
-                                          GFileQueryInfoFlags   flags,
-                                          int                   io_priority,
-                                          GCancellable         *cancellable,
-                                          GAsyncReadyCallback   callback,
-                                          gpointer              user_data);
-GSList *tracker_enumerator_start_finish  (TrackerEnumerator    *enumerator,
-                                          GAsyncResult         *result,
-                                          GError              **error);
+GType   tracker_enumerator_get_type             (void) G_GNUC_CONST;
+GSList *tracker_enumerator_get_children         (TrackerEnumerator    *enumerator,
+                                                 GFile                *dir,
+                                                 const gchar          *attributes,
+                                                 GFileQueryInfoFlags   flags,
+                                                 GCancellable         *cancellable,
+                                                 GError              **error);
+void    tracker_enumerator_get_children_async   (TrackerEnumerator    *enumerator,
+                                                 GFile                *dir,
+                                                 const gchar          *attributes,
+                                                 GFileQueryInfoFlags   flags,
+                                                 int                   io_priority,
+                                                 GCancellable         *cancellable,
+                                                 GAsyncReadyCallback   callback,
+                                                 gpointer              user_data);
+GSList *tracker_enumerator_get_children_finish  (TrackerEnumerator    *enumerator,
+                                                 GAsyncResult         *result,
+                                                 GError              **error);
 
 G_END_DECLS
 
diff --git a/src/libtracker-miner/tracker-file-enumerator.c b/src/libtracker-miner/tracker-file-enumerator.c
index 97d5736..8251d78 100644
--- a/src/libtracker-miner/tracker-file-enumerator.c
+++ b/src/libtracker-miner/tracker-file-enumerator.c
@@ -33,7 +33,7 @@ typedef struct {
        GFile *dir;
        gchar *attributes;
        GFileQueryInfoFlags flags;
-} StartData;
+} GetChildrenData;
 
 G_DEFINE_TYPE_WITH_CODE (TrackerFileEnumerator, tracker_file_enumerator, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (TRACKER_TYPE_ENUMERATOR,
@@ -58,14 +58,14 @@ tracker_file_enumerator_init (TrackerFileEnumerator *fe)
 {
 }
 
-static StartData *
-start_data_new (GFile               *dir,
-                const gchar         *attributes,
-                GFileQueryInfoFlags  flags)
+static GetChildrenData *
+get_children_data_new (GFile               *dir,
+                       const gchar         *attributes,
+                       GFileQueryInfoFlags  flags)
 {
-       StartData *data;
+       GetChildrenData *data;
 
-       data = g_slice_new0 (StartData);
+       data = g_slice_new0 (GetChildrenData);
        data->dir = g_object_ref (dir);
        /* FIXME: inefficient */
        data->attributes = g_strdup (attributes);
@@ -75,7 +75,7 @@ start_data_new (GFile               *dir,
 }
 
 static void
-start_data_free (StartData *data)
+get_children_data_free (GetChildrenData *data)
 {
        if (!data) {
                return;
@@ -83,16 +83,16 @@ start_data_free (StartData *data)
 
        g_object_unref (data->dir);
        g_free (data->attributes);
-       g_slice_free (StartData, data);
+       g_slice_free (GetChildrenData, data);
 }
 
 static GSList *
-file_enumerator_start (TrackerEnumerator    *enumerator,
-                       GFile                *dir,
-                       const gchar          *attributes,
-                       GFileQueryInfoFlags   flags,
-                       GCancellable         *cancellable,
-                       GError              **error)
+file_enumerator_get_children (TrackerEnumerator    *enumerator,
+                              GFile                *dir,
+                              const gchar          *attributes,
+                              GFileQueryInfoFlags   flags,
+                              GCancellable         *cancellable,
+                              GError              **error)
 {
        GFileEnumerator *fe;
        GSList *files;
@@ -170,64 +170,64 @@ file_enumerator_start (TrackerEnumerator    *enumerator,
 }
 
 static void
-start_async_thread_op_free (GSList *files)
+get_children_async_thread_op_free (GSList *files)
 {
        g_slist_free_full (files, g_object_unref);
 }
 
 static void
-start_async_thread (GTask        *task,
-                    gpointer      source_object,
-                    gpointer      task_data,
-                    GCancellable *cancellable)
+get_children_async_thread (GTask        *task,
+                           gpointer      source_object,
+                           gpointer      task_data,
+                           GCancellable *cancellable)
 {
        TrackerEnumerator *enumerator = source_object;
-       StartData *data = task_data;
+       GetChildrenData *data = task_data;
        GSList *files = NULL;
        GError *error = NULL;
 
        if (g_cancellable_set_error_if_cancelled (cancellable, &error)) {
                files = NULL;
        } else {
-               files = file_enumerator_start (enumerator,
-                                              data->dir,
-                                              data->attributes,
-                                              data->flags,
-                                              cancellable,
-                                              &error);
+               files = file_enumerator_get_children (enumerator,
+                                                     data->dir,
+                                                     data->attributes,
+                                                     data->flags,
+                                                     cancellable,
+                                                     &error);
        }
 
        if (error) {
                g_task_return_error (task, error);
        } else {
-               g_task_return_pointer (task, files, (GDestroyNotify) start_async_thread_op_free);
+               g_task_return_pointer (task, files, (GDestroyNotify) get_children_async_thread_op_free);
        }
 }
 
 static void
-file_enumerator_start_async (TrackerEnumerator    *enumerator,
-                             GFile                *dir,
-                             const gchar          *attributes,
-                             GFileQueryInfoFlags   flags,
-                             int                   io_priority,
-                             GCancellable         *cancellable,
-                             GAsyncReadyCallback   callback,
-                             gpointer              user_data)
+file_enumerator_get_children_async (TrackerEnumerator    *enumerator,
+                                    GFile                *dir,
+                                    const gchar          *attributes,
+                                    GFileQueryInfoFlags   flags,
+                                    int                   io_priority,
+                                    GCancellable         *cancellable,
+                                    GAsyncReadyCallback   callback,
+                                    gpointer              user_data)
 {
        GTask *task;
 
        task = g_task_new (enumerator, cancellable, callback, user_data);
-       g_task_set_task_data (task, start_data_new (dir, attributes, flags), (GDestroyNotify) 
start_data_free);
+       g_task_set_task_data (task, get_children_data_new (dir, attributes, flags), (GDestroyNotify) 
get_children_data_free);
        g_task_set_priority (task, io_priority);
 
-       g_task_run_in_thread (task, start_async_thread);
+       g_task_run_in_thread (task, get_children_async_thread);
        g_object_unref (task);
 }
 
 static GSList *
-file_enumerator_start_finish (TrackerEnumerator  *enumerator,
-                              GAsyncResult       *result,
-                              GError            **error)
+file_enumerator_get_children_finish (TrackerEnumerator  *enumerator,
+                                     GAsyncResult       *result,
+                                     GError            **error)
 {
        g_return_val_if_fail (g_task_is_valid (result, enumerator), NULL);
 
@@ -238,9 +238,9 @@ file_enumerator_start_finish (TrackerEnumerator  *enumerator,
 static void
 tracker_file_enumerator_file_iface_init (TrackerEnumeratorIface *iface)
 {
-       iface->start = file_enumerator_start;
-       iface->start_async = file_enumerator_start_async;
-       iface->start_finish = file_enumerator_start_finish;
+       iface->get_children = file_enumerator_get_children;
+       iface->get_children_async = file_enumerator_get_children_async;
+       iface->get_children_finish = file_enumerator_get_children_finish;
 }
 
 TrackerEnumerator *
diff --git a/tests/libtracker-miner/tracker-file-enumerator-test.c 
b/tests/libtracker-miner/tracker-file-enumerator-test.c
index 2665064..99e68de 100644
--- a/tests/libtracker-miner/tracker-file-enumerator-test.c
+++ b/tests/libtracker-miner/tracker-file-enumerator-test.c
@@ -42,13 +42,13 @@ test_enumerator_crawl (void)
        dir = g_file_new_for_path (path);
        g_print ("'%s'\n", path);
 
-       files = tracker_enumerator_start (enumerator,
-                                         dir,
-                                         G_FILE_ATTRIBUTE_STANDARD_NAME "," \
-                                         G_FILE_ATTRIBUTE_STANDARD_TYPE,
-                                         G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
-                                         NULL,
-                                         &error);
+       files = tracker_enumerator_get_children (enumerator,
+                                                dir,
+                                                G_FILE_ATTRIBUTE_STANDARD_NAME "," \
+                                                G_FILE_ATTRIBUTE_STANDARD_TYPE,
+                                                G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+                                                NULL,
+                                                &error);
        g_assert_no_error (error);
        g_assert (files != NULL);
        g_assert (g_slist_length (files) > 0);


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