[tracker/threaded-extractor] tracker-extract: Use TrackerExtractInfo from libtracker-extract
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/threaded-extractor] tracker-extract: Use TrackerExtractInfo from libtracker-extract
- Date: Thu, 7 Jul 2011 11:54:38 +0000 (UTC)
commit fbafdb55e9db13d5bc8aef2d2f3f3a6ce053e3ae
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Jul 7 13:51:26 2011 +0200
tracker-extract: Use TrackerExtractInfo from libtracker-extract
Asynchronous tasks in both tracker-extract internals and tracker-extract-client
actually hold the same information, but each being at one side of D-Bus, so
make both use the same TrackerExtractInfo data type.
src/libtracker-extract/tracker-extract-client.c | 4 +-
src/libtracker-extract/tracker-extract-client.h | 6 +++
src/tracker-extract/tracker-controller.c | 35 ++++++++++-----------
src/tracker-extract/tracker-extract.c | 38 ++++++++++------------
src/tracker-extract/tracker-extract.h | 7 ----
5 files changed, 42 insertions(+), 48 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-extract-client.c b/src/libtracker-extract/tracker-extract-client.c
index 9acdfbc..ccb754d 100644
--- a/src/libtracker-extract/tracker-extract-client.c
+++ b/src/libtracker-extract/tracker-extract-client.c
@@ -56,7 +56,7 @@ typedef struct {
GError *error;
} SendAndSpliceData;
-static TrackerExtractInfo *
+TrackerExtractInfo *
tracker_extract_info_new (const gchar *preupdate,
const gchar *update,
const gchar *where)
@@ -71,7 +71,7 @@ tracker_extract_info_new (const gchar *preupdate,
return info;
}
-static void
+void
tracker_extract_info_free (TrackerExtractInfo *info)
{
g_free (info->preupdate);
diff --git a/src/libtracker-extract/tracker-extract-client.h b/src/libtracker-extract/tracker-extract-client.h
index f3637eb..6d08487 100644
--- a/src/libtracker-extract/tracker-extract-client.h
+++ b/src/libtracker-extract/tracker-extract-client.h
@@ -42,6 +42,12 @@ TrackerExtractInfo * tracker_extract_client_get_metadata_finish (GFile
void tracker_extract_client_cancel_for_prefix (GFile *uri);
+TrackerExtractInfo * tracker_extract_info_new (const gchar *preupdate,
+ const gchar *statements,
+ const gchar *where_clause);
+void tracker_extract_info_free (TrackerExtractInfo *info);
+
+
const gchar * tracker_extract_info_get_preupdate (TrackerExtractInfo *info);
const gchar * tracker_extract_info_get_update (TrackerExtractInfo *info);
const gchar * tracker_extract_info_get_where_clause (TrackerExtractInfo *info);
diff --git a/src/tracker-extract/tracker-controller.c b/src/tracker-extract/tracker-controller.c
index 5ec1a7a..f0674aa 100644
--- a/src/tracker-extract/tracker-controller.c
+++ b/src/tracker-extract/tracker-controller.c
@@ -442,18 +442,18 @@ get_metadata_cb (GObject *object,
info = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
if (info) {
- if (tracker_sparql_builder_get_length (info->statements) > 0) {
- const gchar *preupdate_str = NULL;
+ const gchar *preupdate, *statements, *where;
- if (tracker_sparql_builder_get_length (info->preupdate) > 0) {
- preupdate_str = tracker_sparql_builder_get_result (info->preupdate);
- }
+ preupdate = tracker_extract_info_get_preupdate (info);
+ statements = tracker_extract_info_get_update (info);
+ where = tracker_extract_info_get_where_clause (info);
+ if (statements && *statements) {
g_dbus_method_invocation_return_value (data->invocation,
g_variant_new ("(sss)",
- preupdate_str ? preupdate_str : "",
- tracker_sparql_builder_get_result (info->statements),
- info->where ? info->where : ""));
+ preupdate ? preupdate : "",
+ statements,
+ where ? where : ""));
} else {
g_dbus_method_invocation_return_value (data->invocation,
g_variant_new ("(sss)", "", "", ""));
@@ -550,6 +550,7 @@ get_metadata_fast_cb (GObject *object,
GOutputStream *unix_output_stream;
GOutputStream *buffered_output_stream;
GDataOutputStream *data_output_stream;
+ const gchar *preupdate, *statements, *where;
GError *error = NULL;
#ifdef THREAD_ENABLE_TRACE
@@ -564,15 +565,13 @@ get_metadata_fast_cb (GObject *object,
g_data_output_stream_set_byte_order (G_DATA_OUTPUT_STREAM (data_output_stream),
G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN);
- if (tracker_sparql_builder_get_length (info->statements) > 0) {
- const gchar *preupdate_str = NULL;
-
- if (tracker_sparql_builder_get_length (info->preupdate) > 0) {
- preupdate_str = tracker_sparql_builder_get_result (info->preupdate);
- }
+ preupdate = tracker_extract_info_get_preupdate (info);
+ statements = tracker_extract_info_get_update (info);
+ where = tracker_extract_info_get_where_clause (info);
+ if (statements && *statements) {
g_data_output_stream_put_string (data_output_stream,
- preupdate_str ? preupdate_str : "",
+ preupdate ? preupdate : "",
NULL,
&error);
@@ -585,7 +584,7 @@ get_metadata_fast_cb (GObject *object,
if (!error) {
g_data_output_stream_put_string (data_output_stream,
- tracker_sparql_builder_get_result (info->statements),
+ statements,
NULL,
&error);
}
@@ -597,9 +596,9 @@ get_metadata_fast_cb (GObject *object,
&error);
}
- if (!error && info->where) {
+ if (!error && where) {
g_data_output_stream_put_string (data_output_stream,
- info->where,
+ where,
NULL,
&error);
}
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index c23f8d4..d45893d 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -390,21 +390,6 @@ get_file_metadata (TrackerExtractTask *task,
return (items > 0);
}
-static void
-tracker_extract_info_free (TrackerExtractInfo *info)
-{
- if (info->statements) {
- g_object_unref (info->statements);
- }
-
- if (info->preupdate) {
- g_object_unref (info->preupdate);
- }
-
- g_free (info->where);
- g_slice_free (TrackerExtractInfo, info);
-}
-
/* This function is called on the thread calling g_cancellable_cancel() */
static void
task_cancellable_cancelled_cb (GCancellable *cancellable,
@@ -501,6 +486,10 @@ static gboolean
get_metadata (TrackerExtractTask *task)
{
TrackerExtractInfo *info;
+ TrackerSparqlBuilder *preupdate, *statements;
+ gchar *where = NULL;
+
+ preupdate = statements = NULL;
#ifdef THREAD_ENABLE_TRACE
g_debug ("Thread:%p --> File:'%s' - Extracted",
@@ -519,12 +508,11 @@ get_metadata (TrackerExtractTask *task)
return FALSE;
}
- info = g_slice_new (TrackerExtractInfo);
+ if (get_file_metadata (task, &preupdate, &statements, &where)) {
+ info = tracker_extract_info_new ((preupdate) ? tracker_sparql_builder_get_result (preupdate) : NULL,
+ (statements) ? tracker_sparql_builder_get_result (statements) : NULL,
+ where);
- if (get_file_metadata (task,
- &info->preupdate,
- &info->statements,
- &info->where)) {
g_simple_async_result_set_op_res_gpointer ((GSimpleAsyncResult *) task->res,
info,
(GDestroyNotify) tracker_extract_info_free);
@@ -532,7 +520,15 @@ get_metadata (TrackerExtractTask *task)
g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res);
extract_task_free (task);
} else {
- tracker_extract_info_free (info);
+ if (preupdate) {
+ g_object_unref (preupdate);
+ }
+
+ if (statements) {
+ g_object_unref (statements);
+ }
+
+ g_free (where);
/* Reinject the task into the main thread
* queue, so the next module kicks in.
diff --git a/src/tracker-extract/tracker-extract.h b/src/tracker-extract/tracker-extract.h
index 5d5af2d..700702a 100644
--- a/src/tracker-extract/tracker-extract.h
+++ b/src/tracker-extract/tracker-extract.h
@@ -39,7 +39,6 @@ G_BEGIN_DECLS
typedef struct TrackerExtract TrackerExtract;
typedef struct TrackerExtractClass TrackerExtractClass;
-typedef struct TrackerExtractInfo TrackerExtractInfo;
struct TrackerExtract {
GObject parent;
@@ -49,12 +48,6 @@ struct TrackerExtractClass {
GObjectClass parent;
};
-struct TrackerExtractInfo {
- TrackerSparqlBuilder *preupdate;
- TrackerSparqlBuilder *statements;
- gchar *where;
-};
-
GType tracker_extract_get_type (void);
TrackerExtract *tracker_extract_new (gboolean disable_shutdown,
gboolean force_internal_extractors,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]