tracker r2509 - in branches/uri: . src/tracker-indexer src/tracker-indexer/modules
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2509 - in branches/uri: . src/tracker-indexer src/tracker-indexer/modules
- Date: Mon, 17 Nov 2008 15:25:51 +0000 (UTC)
Author: juergbi
Date: Mon Nov 17 15:25:51 2008
New Revision: 2509
URL: http://svn.gnome.org/viewvc/tracker?rev=2509&view=rev
Log:
2008-11-17 JÃrg Billeter <j bitron ch>
* src/tracker-indexer/modules/dummy.c:
* src/tracker-indexer/modules/evolution.c:
* src/tracker-indexer/tracker-indexer-module.c:
* src/tracker-indexer/tracker-indexer-module.h:
* src/tracker-indexer/tracker-indexer.c:
* src/tracker-indexer/tracker-module.h:
Convert tracker_module_file_get_uri
from dirname and basename to URI
Modified:
branches/uri/ChangeLog
branches/uri/src/tracker-indexer/modules/dummy.c
branches/uri/src/tracker-indexer/modules/evolution.c
branches/uri/src/tracker-indexer/tracker-indexer-module.c
branches/uri/src/tracker-indexer/tracker-indexer-module.h
branches/uri/src/tracker-indexer/tracker-indexer.c
branches/uri/src/tracker-indexer/tracker-module.h
Modified: branches/uri/src/tracker-indexer/modules/dummy.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/dummy.c (original)
+++ branches/uri/src/tracker-indexer/modules/dummy.c Mon Nov 17 15:25:51 2008
@@ -86,18 +86,16 @@
void
tracker_module_file_get_uri (TrackerFile *file,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
/* Implementing this function is optional
*
- * Return dirname/basename for the current item, with this
+ * Return URI for the current item, with this
* method modules can specify different URIs for different
* elements contained in the file. Also see
* tracker_module_file_iter_contents()
*/
- *dirname = g_path_get_dirname (file->path);
- *basename = g_path_get_basename (file->path);
+ *uri = g_strdup (file->path);
}
TrackerMetadata *
Modified: branches/uri/src/tracker-indexer/modules/evolution.c
==============================================================================
--- branches/uri/src/tracker-indexer/modules/evolution.c (original)
+++ branches/uri/src/tracker-indexer/modules/evolution.c Mon Nov 17 15:25:51 2008
@@ -643,27 +643,22 @@
static void
get_mbox_uri (TrackerFile *file,
GMimeMessage *message,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
- gchar *dir, *name;
+ gchar *dir;
gint message_id;
message_id = get_mbox_message_id (message);
if (message_id < 0) {
- *dirname = NULL;
- *basename = NULL;
+ *uri = NULL;
return;
}
dir = tracker_string_replace (file->path, local_dir, NULL);
dir = tracker_string_remove (dir, ".sbd");
- name = g_strdup_printf ("%s;uid=%d", dir, message_id);
-
- *dirname = g_strdup ("email://local local");
- *basename = name;
+ *uri = g_strdup_printf ("email://local local/%s;uid=%d", dir, message_id);
g_free (dir);
}
@@ -672,8 +667,7 @@
get_mbox_attachment_uri (TrackerFile *file,
GMimeMessage *message,
GMimePart *part,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
gint message_id;
gchar *dir;
@@ -681,17 +675,16 @@
message_id = get_mbox_message_id (message);
if (message_id < 0) {
- *dirname = NULL;
- *basename = NULL;
+ *uri = NULL;
return;
}
dir = tracker_string_replace (file->path, local_dir, NULL);
dir = tracker_string_remove (dir, ".sbd");
- *dirname = g_strdup_printf ("email://local local/%s;uid=%d",
- dir, message_id);
- *basename = g_strdup (g_mime_part_get_filename (part));
+ *uri = g_strdup_printf ("email://local local/%s;uid=%d/%s",
+ dir, message_id,
+ g_mime_part_get_filename (part));
g_free (dir);
}
@@ -776,16 +769,14 @@
metadata = get_metadata_for_data_wrapper (content);
if (metadata) {
- gchar *dirname, *basename, *uri;
+ gchar *basename, *uri;
get_mbox_attachment_uri (file, message, part,
- &dirname, &basename);
- uri = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
+ &uri);
+ basename = g_path_get_basename (uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_URI, uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
-
- g_free (dirname);
}
g_object_unref (content);
@@ -799,7 +790,7 @@
EvolutionLocalData *data;
GMimeMessage *message;
TrackerDataMetadata *metadata;
- gchar *dirname, *basename, *uri;
+ gchar *basename, *uri;
time_t date;
GList *list;
guint flags;
@@ -825,8 +816,8 @@
metadata = tracker_data_metadata_new ();
- get_mbox_uri (file, message, &dirname, &basename);
- uri = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
+ get_mbox_uri (file, message, &uri);
+ basename = g_path_get_basename (uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_URI, uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
@@ -845,8 +836,6 @@
list = get_mbox_recipient_list (message, GMIME_RECIPIENT_TYPE_CC);
tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
- g_free (dirname);
-
return metadata;
}
@@ -995,15 +984,14 @@
static void
get_imap_uri (TrackerFile *file,
const gchar *uid,
- gchar **uri_base,
- gchar **basename)
+ gchar **uri)
{
GList *keys, *k;
- gchar *path, *uri, *dir, *subdirs;
+ gchar *path, *dir, *subdirs;
path = file->path;
keys = g_hash_table_get_keys (accounts);
- *uri_base = *basename = NULL;
+ *uri = NULL;
for (k = keys; k; k = k->next) {
if (strstr (path, k->data)) {
@@ -1016,15 +1004,12 @@
subdirs = tracker_string_remove (subdirs, "/subfolders");
subdirs = tracker_string_remove (subdirs, "/summary");
- uri = g_strdup_printf ("email://%s/%s;uid=%s",
+ *uri = g_strdup_printf ("email://%s/%s;uid=%s",
(gchar *) g_hash_table_lookup (accounts, k->data),
subdirs, uid);
- tracker_file_get_path_and_name (uri, uri_base, basename);
-
g_free (subdirs);
g_free (dir);
- g_free (uri);
break;
}
@@ -1037,11 +1022,10 @@
static void
get_imap_attachment_uri (TrackerFile *file,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
EvolutionImapData *data;
- gchar *message_dirname, *message_basename, *name;
+ gchar *message_uri, *name;
data = file->data;
@@ -1049,12 +1033,10 @@
return;
}
- get_imap_uri (file, data->cur_message_uid, &message_dirname, &message_basename);
- *dirname = g_strdup_printf ("%s/%s", message_dirname, message_basename);
- *basename = name;
+ get_imap_uri (file, data->cur_message_uid, &message_uri);
+ *uri = g_strdup_printf ("%s/%s", message_uri, name);
- g_free (message_dirname);
- g_free (message_basename);
+ g_free (message_uri);
}
static GList *
@@ -1127,20 +1109,19 @@
if (metadata) {
EvolutionImapData *data;
- gchar *dirname, *basename;
+ gchar *uri;
data = file->data;
get_imap_uri (file,
data->cur_message_uid,
- &dirname, &basename);
+ &uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, g_strdup (name));
tracker_data_metadata_insert (metadata, METADATA_FILE_URI,
- g_strdup_printf ("%s/%s/%s", dirname, basename, name));
+ g_strdup_printf ("%s/%s", uri, name));
- g_free (dirname);
- g_free (basename);
+ g_free (uri);
}
g_object_unref (wrapper);
@@ -1156,7 +1137,7 @@
{
EvolutionImapData *data;
TrackerDataMetadata *metadata = NULL;
- gchar *dirname, *basename, *uri;
+ gchar *basename, *uri;
gchar *subject, *from, *to, *cc;
gint32 i, count, flags;
time_t date;
@@ -1206,8 +1187,8 @@
if (!deleted) {
metadata = tracker_data_metadata_new ();
- get_imap_uri (file, data->cur_message_uid, &dirname, &basename);
- uri = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
+ get_imap_uri (file, data->cur_message_uid, &uri);
+ basename = g_path_get_basename (uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_URI, uri);
tracker_data_metadata_insert (metadata, METADATA_FILE_NAME, basename);
@@ -1223,8 +1204,6 @@
list = get_imap_recipient_list (cc);
tracker_data_metadata_insert_values (metadata, METADATA_EMAIL_CC, list);
-
- g_free (dirname);
}
g_free (to);
@@ -1301,8 +1280,7 @@
void
tracker_module_file_get_uri (TrackerFile *file,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
EvolutionFileData *file_data;
@@ -1326,9 +1304,9 @@
/* We're currently on an attachment */
get_mbox_attachment_uri (file, data->message,
data->current_mime_part->data,
- dirname, basename);
+ uri);
} else {
- get_mbox_uri (file, data->message, dirname, basename);
+ get_mbox_uri (file, data->message, uri);
}
break;
@@ -1338,9 +1316,9 @@
if (data->current_mime_part) {
/* We're currently on an attachment */
- get_imap_attachment_uri (file, dirname, basename);
+ get_imap_attachment_uri (file, uri);
} else {
- get_imap_uri (file, data->cur_message_uid, dirname, basename);
+ get_imap_uri (file, data->cur_message_uid, uri);
}
break;
Modified: branches/uri/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer-module.c (original)
+++ branches/uri/src/tracker-indexer/tracker-indexer-module.c Mon Nov 17 15:25:51 2008
@@ -115,46 +115,32 @@
gboolean
tracker_indexer_module_file_get_uri (GModule *module,
TrackerFile *file,
- gchar **dirname,
- gchar **basename)
+ gchar **uri)
{
TrackerModuleFileGetUriFunc func;
- gchar *tmp_dirname;
- gchar *tmp_basename;
+ gchar *tmp_uri;
- tmp_dirname = tmp_basename = NULL;
+ tmp_uri = NULL;
if (g_module_symbol (module, "tracker_module_file_get_uri", (gpointer *) &func)) {
- (func) (file, &tmp_dirname, &tmp_basename);
+ (func) (file, &tmp_uri);
} else {
- tmp_dirname = g_path_get_dirname (file->path);
- tmp_basename = g_path_get_basename (file->path);
+ tmp_uri = g_strdup (file->path);
}
- if (tmp_dirname && tmp_basename) {
- if (dirname) {
- *dirname = tmp_dirname;
+ if (tmp_uri) {
+ if (uri) {
+ *uri = tmp_uri;
} else {
- g_free (tmp_dirname);
- }
-
- if (basename) {
- *basename = tmp_basename;
- } else {
- g_free (tmp_basename);
+ g_free (tmp_uri);
}
return TRUE;
} else {
- g_free (tmp_dirname);
- g_free (tmp_basename);
-
- if (dirname) {
- *dirname = NULL;
- }
+ g_free (tmp_uri);
- if (basename) {
- *basename = NULL;
+ if (uri) {
+ *uri = NULL;
}
return FALSE;
Modified: branches/uri/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer-module.h (original)
+++ branches/uri/src/tracker-indexer/tracker-indexer-module.h Mon Nov 17 15:25:51 2008
@@ -42,8 +42,7 @@
gboolean tracker_indexer_module_file_get_uri (GModule *module,
TrackerFile *file,
- gchar **dirname,
- gchar **basename);
+ gchar **uri);
gchar * tracker_indexer_module_file_get_service_type (GModule *module,
TrackerFile *file);
TrackerDataMetadata * tracker_indexer_module_file_get_metadata (GModule *module,
Modified: branches/uri/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/uri/src/tracker-indexer/tracker-indexer.c Mon Nov 17 15:25:51 2008
@@ -1943,8 +1943,6 @@
PathInfo *info)
{
TrackerDataMetadata *metadata;
- gchar *dirname;
- gchar *basename;
gchar *uri;
/* Note: If info->other_file is set, the PathInfo is for a
@@ -1956,13 +1954,10 @@
if (!tracker_indexer_module_file_get_uri (info->module,
info->file,
- &dirname,
- &basename)) {
+ &uri)) {
return !tracker_indexer_module_file_iter_contents (info->module, info->file);
}
- uri = g_build_path (G_DIR_SEPARATOR_S, dirname, basename, NULL);
-
/*
* FIRST:
* ======
@@ -1986,12 +1981,11 @@
* We simply check the dirname[0] to make sure it isn't an
* email based dirname.
*/
- if (G_LIKELY (!info->other_file) && dirname[0] == G_DIR_SEPARATOR) {
+ if (G_LIKELY (!info->other_file) && uri[0] == G_DIR_SEPARATOR) {
if (!should_index_file (indexer, info, uri)) {
g_debug ("File is already up to date: '%s'", info->file->path);
- g_free (dirname);
- g_free (basename);
+ g_free (uri);
return TRUE;
}
@@ -2019,8 +2013,6 @@
indexer->private->items_processed++;
- g_free (dirname);
- g_free (basename);
g_free (uri);
return !tracker_indexer_module_file_iter_contents (info->module, info->file);
Modified: branches/uri/src/tracker-indexer/tracker-module.h
==============================================================================
--- branches/uri/src/tracker-indexer/tracker-module.h (original)
+++ branches/uri/src/tracker-indexer/tracker-module.h Mon Nov 17 15:25:51 2008
@@ -45,8 +45,7 @@
typedef gchar * (* TrackerModuleFileGetServiceTypeFunc) (TrackerFile *file);
typedef void (* TrackerModuleFileGetUriFunc) (TrackerFile *file,
- gchar **dirname,
- gchar **basename);
+ gchar **uri);
typedef TrackerDataMetadata * (* TrackerModuleFileGetMetadataFunc) (TrackerFile *file);
typedef gchar * (* TrackerModuleFileGetText) (TrackerFile *path);
@@ -60,8 +59,7 @@
void tracker_module_file_free_data (gpointer file_data);
gchar * tracker_module_file_get_service_type (TrackerFile *file);
void tracker_module_file_get_uri (TrackerFile *file,
- gchar **dirname,
- gchar **basename);
+ gchar **uri);
TrackerDataMetadata * tracker_module_file_get_metadata (TrackerFile *file);
gchar * tracker_module_file_get_text (TrackerFile *file);
gboolean tracker_module_file_iter_contents (TrackerFile *file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]