[tracker/tracker-store] tracker-indexer: Simplify evolution_common_get_wrapper_metadata
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store] tracker-indexer: Simplify evolution_common_get_wrapper_metadata
- Date: Tue, 23 Jun 2009 11:05:58 -0400 (EDT)
commit fdd27878854e31a36054446327e27811ed846490
Author: Jürg Billeter <j bitron ch>
Date: Tue Jun 23 17:03:26 2009 +0200
tracker-indexer: Simplify evolution_common_get_wrapper_metadata
Avoids using tracker_module_metadata_foreach, which will be removed.
src/tracker-indexer/modules/evolution-common.c | 31 +-------------------
src/tracker-indexer/modules/files.c | 11 ++++++-
.../tracker-module-metadata-utils.c | 12 +++----
.../tracker-module-metadata-utils.h | 3 +-
4 files changed, 18 insertions(+), 39 deletions(-)
---
diff --git a/src/tracker-indexer/modules/evolution-common.c b/src/tracker-indexer/modules/evolution-common.c
index ca43af1..6e6ae24 100644
--- a/src/tracker-indexer/modules/evolution-common.c
+++ b/src/tracker-indexer/modules/evolution-common.c
@@ -58,24 +58,6 @@ evolution_common_get_stream (const gchar *path,
return stream;
}
-typedef struct {
- const gchar *subject;
- TrackerModuleMetadata *metadata;
-} WrapInfo;
-
-static void
-foreach_wrap_metadata (const gchar *subject,
- const gchar *predicate,
- const gchar *object,
- gpointer user_data)
-{
- WrapInfo *info = user_data;
-
- tracker_module_metadata_add_string (info->metadata,
- info->subject,
- predicate, object);
-}
-
void
evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper,
TrackerModuleMetadata *metadata,
@@ -87,28 +69,17 @@ evolution_common_get_wrapper_metadata (GMimeDataWrapper *wrapper,
path = g_build_filename (g_get_tmp_dir (), "tracker-evolution-module-XXXXXX", NULL);
fd = g_mkstemp (path);
- metadata = NULL;
stream = g_mime_stream_fs_new (fd);
if (g_mime_data_wrapper_write_to_stream (wrapper, stream) != -1) {
GFile *file;
- TrackerModuleMetadata *f_metadata;
- WrapInfo info;
-
- info.subject = subject;
- info.metadata = metadata;
file = g_file_new_for_path (path);
g_mime_stream_flush (stream);
- f_metadata = tracker_module_metadata_utils_get_data (file);
-
- tracker_module_metadata_foreach (f_metadata,
- foreach_wrap_metadata,
- &info);
+ tracker_module_metadata_utils_get_data (file, metadata);
- g_object_unref (f_metadata);
g_object_unref (file);
g_unlink (path);
}
diff --git a/src/tracker-indexer/modules/files.c b/src/tracker-indexer/modules/files.c
index 2f3de65..47d348a 100644
--- a/src/tracker-indexer/modules/files.c
+++ b/src/tracker-indexer/modules/files.c
@@ -159,13 +159,22 @@ check_exclude_file (const gchar *path)
static TrackerModuleMetadata *
tracker_regular_file_get_metadata (TrackerModuleFile *file)
{
+ TrackerModuleMetadata *metadata;
+
#ifdef ENABLE_FILE_EXCLUDE_CHECKING
if (check_exclude_file (file->path)) {
return NULL;
}
#endif
- return tracker_module_metadata_utils_get_data (tracker_module_file_get_file (file));
+ metadata = tracker_module_metadata_new ();
+
+ if (!tracker_module_metadata_utils_get_data (tracker_module_file_get_file (file), metadata)) {
+ g_object_unref (metadata);
+ metadata = NULL;
+ }
+
+ return metadata;
}
static gchar *
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.c b/src/tracker-indexer/tracker-module-metadata-utils.c
index 5c62b89..1b76f40 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.c
+++ b/src/tracker-indexer/tracker-module-metadata-utils.c
@@ -820,10 +820,10 @@ tracker_module_metadata_utils_get_text (GFile *file)
*
* Returns: A newly created #TrackerModuleMetadata, or %NULL if the file is not found.
**/
-TrackerModuleMetadata *
-tracker_module_metadata_utils_get_data (GFile *file)
+
+gboolean
+tracker_module_metadata_utils_get_data (GFile *file, TrackerModuleMetadata *metadata)
{
- TrackerModuleMetadata *metadata;
gchar *mime_type, *uri;
GFileInfo *file_info;
guint64 time_;
@@ -832,11 +832,9 @@ tracker_module_metadata_utils_get_data (GFile *file)
file_info = g_file_query_info (file, "standard::*,time::*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, NULL);
if (!file_info) {
- return NULL;
+ return FALSE;
}
- metadata = tracker_module_metadata_new ();
-
uri = g_file_get_uri (file);
mime_type = tracker_file_get_mime_type (file);
@@ -868,7 +866,7 @@ tracker_module_metadata_utils_get_data (GFile *file)
g_free (mime_type);
g_free (uri);
- return metadata;
+ return TRUE;
}
void
diff --git a/src/tracker-indexer/tracker-module-metadata-utils.h b/src/tracker-indexer/tracker-module-metadata-utils.h
index ab1f2f1..8375948 100644
--- a/src/tracker-indexer/tracker-module-metadata-utils.h
+++ b/src/tracker-indexer/tracker-module-metadata-utils.h
@@ -32,7 +32,8 @@ G_BEGIN_DECLS
#endif
-TrackerModuleMetadata *tracker_module_metadata_utils_get_data (GFile *file);
+gboolean tracker_module_metadata_utils_get_data (GFile *file,
+ TrackerModuleMetadata *metadata);
gchar * tracker_module_metadata_utils_get_text (GFile *file);
void tracker_module_metadata_utils_cancel (GFile *file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]