[tracker/architecture-sparql-up-in-daemon] Removed the indexer part of the push modules
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/architecture-sparql-up-in-daemon] Removed the indexer part of the push modules
- Date: Mon, 27 Apr 2009 06:44:46 -0400 (EDT)
commit 29113df65241b787c8c42157a39b690d2c5b175d
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Apr 27 12:42:46 2009 +0200
Removed the indexer part of the push modules
After the reachitecture the indexer wont do the writes, the daemon wil.
This means that we must not proxy the request to the indexer anymore,
instead will the daemon perform the write immediately itself.
---
src/plugins/evolution/Makefile.am | 23 -
src/plugins/evolution/tracker-evolution-indexer.c | 607 --------------------
src/plugins/evolution/tracker-evolution-indexer.h | 101 ----
.../evolution/tracker-evolution-registrar.c | 470 +++++++++++++---
src/plugins/kmail/Makefile.am | 23 -
src/plugins/kmail/tracker-kmail-indexer.c | 403 -------------
src/plugins/kmail/tracker-kmail-indexer.h | 101 ----
src/plugins/kmail/tracker-kmail-registrar.c | 257 ++++++---
src/plugins/rss/Makefile.am | 23 -
src/plugins/rss/tracker-rss-indexer.c | 344 -----------
src/plugins/rss/tracker-rss-indexer.h | 101 ----
src/plugins/rss/tracker-rss-registrar.c | 203 ++++---
12 files changed, 678 insertions(+), 1978 deletions(-)
diff --git a/src/plugins/evolution/Makefile.am b/src/plugins/evolution/Makefile.am
index dbc9209..69f3bb8 100644
--- a/src/plugins/evolution/Makefile.am
+++ b/src/plugins/evolution/Makefile.am
@@ -29,16 +29,8 @@ eplugin_LTLIBRARIES = liborg-freedesktop-Tracker-evolution-plugin.la
module_flags = -module -avoid-version -no-undefined
pushd_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/daemon
-pushi_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/indexer
pushd_modules_LTLIBRARIES = libtracker-module-evolution-daemon-module.la
-pushi_modules_LTLIBRARIES = libtracker-module-evolution-indexer-module.la
-
-libtracker_module_evolution_indexer_module_la_SOURCES = \
- tracker-evolution-indexer.c \
- tracker-evolution-indexer.h \
- tracker-evolution-registrar-glue.h \
- tracker-evolution-common.h
libtracker_module_evolution_daemon_module_la_SOURCES = \
tracker-evolution-registrar.c \
@@ -60,21 +52,6 @@ libtracker_module_evolution_daemon_module_la_LIBADD = \
$(RAPTOR_LIBS) \
$(GCOV_LIBS)
-libtracker_module_evolution_indexer_module_la_LDFLAGS = $(module_flags)
-
-libtracker_module_evolution_indexer_module_la_LIBADD = \
- $(top_builddir)/src/libtracker-data/libtracker-data.la \
- $(top_builddir)/src/libtracker-db/libtracker-db.la \
- $(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(GMODULE_LIBS) \
- $(DBUS_LIBS) \
- $(GTHREAD_LIBS) \
- $(GIO_LIBS) \
- $(GLIB2_LIBS) \
- $(RAPTOR_LIBS) \
- $(GMIME_LIBS) \
- $(GCOV_LIBS)
-
liborg_freedesktop_Tracker_evolution_plugin_la_SOURCES = \
tracker-evolution-plugin.c \
tracker-evolution-plugin.h \
diff --git a/src/plugins/evolution/tracker-evolution-indexer.c b/src/plugins/evolution/tracker-evolution-indexer.c
deleted file mode 100644
index 4f32a5e..0000000
--- a/src/plugins/evolution/tracker-evolution-indexer.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <gio/gio.h>
-#include <glib/gstdio.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gmime/gmime.h>
-
-#include <libtracker-common/tracker-ontology.h>
-
-#include <libtracker-data/tracker-data-manager.h>
-#include <libtracker-data/tracker-data-query.h>
-#include <libtracker-data/tracker-data-update.h>
-
-#include "tracker-evolution-indexer.h"
-
-/* These defines/renames are necessary for -glue.h */
-#define tracker_evolution_registrar_set tracker_evolution_indexer_set
-#define tracker_evolution_registrar_set_many tracker_evolution_indexer_set_many
-#define tracker_evolution_registrar_unset_many tracker_evolution_indexer_unset_many
-#define tracker_evolution_registrar_unset tracker_evolution_indexer_unset
-#define tracker_evolution_registrar_cleanup tracker_evolution_indexer_cleanup
-#define dbus_glib_tracker_evolution_indexer_object_info dbus_glib_tracker_evolution_registrar_object_info
-
-#include "tracker-evolution-registrar-glue.h"
-
-/* Based on data/services/email.metadata */
-
-#define METADATA_EMAIL TRACKER_NMO_PREFIX "Email"
-#define METADATA_MAILBOXDATA_OBJECT TRACKER_NMO_PREFIX "MailboxDataObject"
-
-#define METADATA_EMAIL_RECIPIENT TRACKER_NMO_PREFIX "to"
-#define METADATA_EMAIL_DATE TRACKER_NMO_PREFIX "receivedDate"
-#define METADATA_EMAIL_SENDER TRACKER_NMO_PREFIX "sender"
-#define METADATA_EMAIL_SUBJECT TRACKER_NMO_PREFIX "subject"
-#define METADATA_EMAIL_SENT_TO TRACKER_NMO_PREFIX "recipient"
-#define METADATA_EMAIL_CC TRACKER_NMO_PREFIX "cc"
-#if 0
-#define METADATA_EMAIL_TEXT TRACKER_NMO_PREFIX "Body"
-#endif
-
-#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
-#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
-
-#define RDF_TYPE TRACKER_RDF_PREFIX "type"
-
-#define METADATA_EMAIL_MESSAGE_HEADER TRACKER_NMO_PREFIX "messageHeader"
-#define METADATA_EMAIL_MESSAGE_HEADER_NAME TRACKER_NMO_PREFIX "headerName"
-#define METADATA_EMAIL_MESSAGE_HEADER_VALUE TRACKER_NMO_PREFIX "headerValue"
-
-#define DATASOURCE_URN "urn:nepomuk:datasource:1cb1eb90-1241-11de-8c30-0800200c9a66"
-
-G_DEFINE_TYPE (TrackerEvolutionIndexer, tracker_evolution_indexer, G_TYPE_OBJECT)
-
-/* This runs in-process of tracker-indexer */
-
-static GObject *idx_indexer = NULL;
-
-enum {
- PROP_0,
-};
-
-void tracker_push_module_init (TrackerConfig *config);
-void tracker_push_module_shutdown (void);
-
-static void
-tracker_evolution_indexer_finalize (GObject *object)
-{
- G_OBJECT_CLASS (tracker_evolution_indexer_parent_class)->finalize (object);
-}
-
-static void
-tracker_evolution_indexer_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_evolution_indexer_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_evolution_indexer_class_init (TrackerEvolutionIndexerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tracker_evolution_indexer_finalize;
- object_class->set_property = tracker_evolution_indexer_set_property;
- object_class->get_property = tracker_evolution_indexer_get_property;
-}
-
-static void
-tracker_evolution_indexer_init (TrackerEvolutionIndexer *object)
-{
-}
-
-
-#if 0
-static void
-extract_mime_parts (GMimeObject *object,
- gpointer user_data)
-{
- const gchar *message_subject = user_data;
- gchar *subject = NULL;
- const gchar *disposition, *filename;
- GMimePart *part;
-
- if (GMIME_IS_MESSAGE_PART (object)) {
- GMimeMessage *message;
-
- message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (object));
-
- if (message) {
- g_mime_message_foreach_part (message, extract_mime_parts, user_data);
- g_object_unref (message);
- }
-
- return;
- } else if (GMIME_IS_MULTIPART (object)) {
- g_mime_multipart_foreach (GMIME_MULTIPART (object), extract_mime_parts, user_data);
- return;
- }
-
- part = GMIME_PART (object);
- disposition = g_mime_part_get_content_disposition (part);
-
- if (!disposition ||
- (g_strcmp0 (disposition, GMIME_DISPOSITION_ATTACHMENT) != 0 &&
- g_strcmp0 (disposition, GMIME_DISPOSITION_INLINE) != 0)) {
- return;
- }
-
- filename = g_mime_part_get_filename (GMIME_PART (object));
-
- if (!filename ||
- g_strcmp0 (filename, "signature.asc") == 0 ||
- g_strcmp0 (filename, "signature.pgp") == 0) {
- return;
- }
-
- if (filename) {
- GHashTable *data;
- TrackerModuleMetadata *metadata;
- gchar *subject;
-
- /* This is not a path but a URI: don't use the OS's dir separator
- * here, use the '/'. Another option is to use '#' instead of '/'
- * here. This depends on how we want to format the URI and what
- * Evolution can cope with as URI for an attachment (I don't
- * think it can cope with any attachment URI, btw). */
-
- subject = g_strdup_printf ("%s/%s", message_subject,
- filename);
-
- tracker_data_insert_statement (subject,
- "File:Path",
- filename);
-
- tracker_data_insert_statement (subject,
- "File:Name",
- filename);
-
- g_free (subject);
- }
-}
-
-static gchar *
-get_object_encoding (GMimeObject *object)
-{
- const gchar *start_encoding, *end_encoding;
- const gchar *content_type = NULL;
-
- if (GMIME_IS_MESSAGE (object)) {
- content_type = g_mime_message_get_header (GMIME_MESSAGE (object), "Content-Type");
- } else if (GMIME_IS_PART (object)) {
- content_type = g_mime_part_get_content_header (GMIME_PART (object), "Content-Type");
- }
-
- if (!content_type) {
- return NULL;
- }
-
- start_encoding = strstr (content_type, "charset=");
-
- if (!start_encoding) {
- return NULL;
- }
-
- start_encoding += strlen ("charset=");
-
- if (start_encoding[0] == '"') {
- /* encoding is quoted */
- start_encoding++;
- end_encoding = strstr (start_encoding, "\"");
- } else {
- end_encoding = strstr (start_encoding, ";");
- }
-
- if (end_encoding) {
- return g_strndup (start_encoding, end_encoding - start_encoding);
- } else {
- return g_strdup (start_encoding);
- }
-}
-#endif
-
-static void
-perform_set (TrackerEvolutionIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values)
-{
- guint i = 0;
-
- if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
- tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
- NIE_DATASOURCE);
- }
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_EMAIL);
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_MAILBOXDATA_OBJECT);
-
- tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
- DATASOURCE_URN);
-
- while (predicates [i] != NULL && values[i] != NULL) {
-
- /* TODO: TRACKER_EVOLUTION_PREDICATE_JUNK (!)
- * TRACKER_EVOLUTION_PREDICATE_ANSWERED
- * TRACKER_EVOLUTION_PREDICATE_FLAGGED
- * TRACKER_EVOLUTION_PREDICATE_FORWARDED
- * TRACKER_EVOLUTION_PREDICATE_DELETED (!)
- * TRACKER_EVOLUTION_PREDICATE_SIZE (!) :
- *
- * I don't have predicates in Tracker's ontology for these. In
- * Jürg's vstore branch we are working with Nepomuk as ontology-
- * set. Perhaps when we merge this to that branch that we can
- * improve this situation. */
-
-
-#if 0
-
- /* Disabling this as I can't find any version of GMime-2.0 that
- * wont crash on any of my test E-mails. Going to ask Garnacho
- * to migrate to GMime-2.4 with his old Evolution support. */
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_FILE) == 0) {
- GMimeStream *stream;
- GMimeParser *parser;
- GMimeMessage *message;
- gint fd;
- gchar *text, *orig_text, *ptr, *encoding;
- gchar *path = g_strdup (values[i]);
- off_t offset = 0;
- gboolean is_html;
-
- ptr = strstr (path, "/!");
- if (ptr) {
- offset = (off_t) atol (ptr+2);
- *ptr = '\0';
- }
-
- fd = tracker_file_open (path, FALSE);
-
- g_free (path);
-
- if (fd == -1)
- goto cont;
-
- stream = g_mime_stream_fs_new_with_bounds (fd, offset, -1);
-
- if (!stream) {
- close (fd);
- goto cont;
- }
-
- parser = g_mime_parser_new_with_stream (stream);
-
- if (!parser) {
- g_object_unref (stream);
- goto cont;
- }
-
- g_mime_parser_set_scan_from (parser, FALSE);
-
- message = g_mime_parser_construct_message (parser);
-
- if (!message) {
- g_object_unref (parser);
- g_object_unref (stream);
- goto cont;
- }
-
- g_mime_message_foreach_part (message,
- extract_mime_parts,
- subject);
-
- orig_text = g_mime_message_get_body (message, TRUE, &is_html);
-
- if (orig_text) {
-
- encoding = get_object_encoding (GMIME_OBJECT (message));
-
- if (encoding) {
- text = g_convert (text, -1, "utf8", encoding, NULL, NULL, NULL);
- g_free (orig_text);
- } else
- text = orig_text;
-
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_TEXT,
- text);
-
- g_free (text);
- g_free (encoding);
- }
-
- g_object_unref (message);
- g_object_unref (parser);
- g_object_unref (stream);
- }
-#endif
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TAG) == 0) {
- gchar *key, *value;
-
- if (!values[i] || strlen (values[i]) < 1)
- goto cont;
-
- key = g_strdup_printf ("X-Evolution-UserTag-%s", (values[i]));
-
- value = strchr (key, '=');
-
- if (value) {
- *value = '\0';
- value++;
- }
-
- tracker_data_insert_statement (":1", RDF_TYPE,
- METADATA_EMAIL_MESSAGE_HEADER);
-
- tracker_data_insert_statement (":1",
- METADATA_EMAIL_MESSAGE_HEADER_NAME,
- key);
-
- tracker_data_insert_statement (":1",
- METADATA_EMAIL_MESSAGE_HEADER_VALUE,
- value);
-
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_MESSAGE_HEADER,
- ":1");
-
- g_free (key);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SUBJECT) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SUBJECT,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SENT) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_DATE,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_FROM) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENDER,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TO) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENT_TO,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_CC) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_CC,
- values[i]);
- }
-
- cont:
-
- i++;
- }
-
-}
-
-static void
-perform_unset (TrackerEvolutionIndexer *object,
- const gchar *subject)
-{
- tracker_data_delete_resource (subject);
-}
-
-static void
-perform_cleanup (TrackerEvolutionIndexer *object)
-{
- GError *error = NULL;
-
- tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-set_stored_last_modseq (guint last_modseq)
-{
- tracker_data_manager_set_db_option_int ("EvolutionLastModseq", (gint) last_modseq);
-}
-
-void
-tracker_evolution_indexer_set (TrackerEvolutionIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- if (predicates && values) {
-
- dbus_async_return_if_fail (g_strv_length (predicates) ==
- g_strv_length (values), context);
-
- perform_set (object, subject, predicates, values);
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_evolution_indexer_set_many (TrackerEvolutionIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint len;
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
- dbus_async_return_if_fail (predicates != NULL, context);
- dbus_async_return_if_fail (values != NULL, context);
-
- len = g_strv_length (subjects);
-
- dbus_async_return_if_fail (len == predicates->len, context);
- dbus_async_return_if_fail (len == values->len, context);
-
- while (subjects[i] != NULL) {
- GStrv preds = g_ptr_array_index (predicates, i);
- GStrv vals = g_ptr_array_index (values, i);
-
- perform_set (object, subjects[i], preds, vals);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_evolution_indexer_unset_many (TrackerEvolutionIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
-
- while (subjects[i] != NULL) {
-
- perform_unset (object, subjects[i]);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_evolution_indexer_unset (TrackerEvolutionIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- perform_unset (object, subject);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_evolution_indexer_cleanup (TrackerEvolutionIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- perform_cleanup (object);
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_push_module_init (TrackerConfig *config)
-{
- GError *error = NULL;
- DBusGConnection *connection;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
- if (!error) {
- idx_indexer = g_object_new (TRACKER_TYPE_EVOLUTION_INDEXER, NULL);
-
- dbus_g_object_type_install_info (G_OBJECT_TYPE (idx_indexer),
- &dbus_glib_tracker_evolution_indexer_object_info);
-
- dbus_g_connection_register_g_object (connection,
- TRACKER_EVOLUTION_INDEXER_PATH,
- idx_indexer);
- }
-
- if (error) {
- g_critical ("Can't init DBus for Evolution support: %s", error->message);
- g_error_free (error);
- }
-}
-
-void
-tracker_push_module_shutdown (void)
-{
- if (idx_indexer)
- g_object_unref (idx_indexer);
-}
diff --git a/src/plugins/evolution/tracker-evolution-indexer.h b/src/plugins/evolution/tracker-evolution-indexer.h
deleted file mode 100644
index 7e5d03f..0000000
--- a/src/plugins/evolution/tracker-evolution-indexer.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#ifndef __LIBTRACKER_EVOLUTION_H__
-#define __LIBTRACKER_EVOLUTION_H__
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-
-#include <libtracker-common/tracker-common.h>
-
-G_BEGIN_DECLS
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-#include <dbus/dbus-glib-bindings.h>
-
-#include <tracker-indexer/tracker-indexer.h>
-
-#include "tracker-evolution-common.h"
-
-G_BEGIN_DECLS
-
-#define TRACKER_TYPE_EVOLUTION_INDEXER (tracker_evolution_indexer_get_type())
-#define TRACKER_EVOLUTION_INDEXER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_EVOLUTION_INDEXER, TrackerEvolutionIndexer))
-#define TRACKER_EVOLUTION_INDEXER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_EVOLUTION_INDEXER, TrackerEvolutionIndexerClass))
-#define TRACKER_EVOLUTION_INDEXER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_EVOLUTION_INDEXER, TrackerEvolutionIndexerClass))
-
-G_BEGIN_DECLS
-
-typedef struct TrackerEvolutionIndexer TrackerEvolutionIndexer;
-typedef struct TrackerEvolutionIndexerClass TrackerEvolutionIndexerClass;
-
-struct TrackerEvolutionIndexer {
- GObject parent;
-};
-
-struct TrackerEvolutionIndexerClass {
- GObjectClass parent;
-};
-
-GType tracker_evolution_indexer_get_type (void);
-
-void tracker_evolution_indexer_set (TrackerEvolutionIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_evolution_indexer_set_many (TrackerEvolutionIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_evolution_indexer_unset_many (TrackerEvolutionIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_evolution_indexer_unset (TrackerEvolutionIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_evolution_indexer_cleanup (TrackerEvolutionIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-
-G_END_DECLS
-
-#endif /* __LIBTRACKER_EVOLUTION_H__ */
diff --git a/src/plugins/evolution/tracker-evolution-registrar.c b/src/plugins/evolution/tracker-evolution-registrar.c
index 4d36b55..12925a4 100644
--- a/src/plugins/evolution/tracker-evolution-registrar.c
+++ b/src/plugins/evolution/tracker-evolution-registrar.c
@@ -23,11 +23,14 @@
#include "config.h"
+#include <string.h>
+
#include <glib-object.h>
#include <dbus/dbus-glib-bindings.h>
#include <libtracker-data/tracker-data-update.h>
#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
#include <trackerd/tracker-push-registrar.h>
@@ -41,6 +44,31 @@
#define TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR (tracker_evolution_push_registrar_get_type ())
#define TRACKER_EVOLUTION_PUSH_REGISTRAR(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR, TrackerEvolutionPushRegistrar))
+
+#define METADATA_EMAIL TRACKER_NMO_PREFIX "Email"
+#define METADATA_MAILBOXDATA_OBJECT TRACKER_NMO_PREFIX "MailboxDataObject"
+
+#define METADATA_EMAIL_RECIPIENT TRACKER_NMO_PREFIX "to"
+#define METADATA_EMAIL_DATE TRACKER_NMO_PREFIX "receivedDate"
+#define METADATA_EMAIL_SENDER TRACKER_NMO_PREFIX "sender"
+#define METADATA_EMAIL_SUBJECT TRACKER_NMO_PREFIX "subject"
+#define METADATA_EMAIL_SENT_TO TRACKER_NMO_PREFIX "recipient"
+#define METADATA_EMAIL_CC TRACKER_NMO_PREFIX "cc"
+#if 0
+#define METADATA_EMAIL_TEXT TRACKER_NMO_PREFIX "Body"
+#endif
+
+#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
+#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
+
+#define RDF_TYPE TRACKER_RDF_PREFIX "type"
+
+#define METADATA_EMAIL_MESSAGE_HEADER TRACKER_NMO_PREFIX "messageHeader"
+#define METADATA_EMAIL_MESSAGE_HEADER_NAME TRACKER_NMO_PREFIX "headerName"
+#define METADATA_EMAIL_MESSAGE_HEADER_VALUE TRACKER_NMO_PREFIX "headerValue"
+
+#define DATASOURCE_URN "urn:nepomuk:datasource:1cb1eb90-1241-11de-8c30-0800200c9a66"
+
typedef struct TrackerEvolutionPushRegistrar TrackerEvolutionPushRegistrar;
typedef struct TrackerEvolutionPushRegistrarClass TrackerEvolutionPushRegistrarClass;
@@ -54,13 +82,11 @@ struct TrackerEvolutionPushRegistrarClass {
typedef struct {
- DBusGProxy *idx_proxy;
- DBusGConnection *connection;
+ gpointer dummy;
} TrackerEvolutionRegistrarPrivate;
enum {
PROP_0,
- PROP_CONNECTION
};
static GType tracker_evolution_push_registrar_get_type (void) G_GNUC_CONST;
@@ -68,34 +94,12 @@ static GType tracker_evolution_push_registrar_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (TrackerEvolutionRegistrar, tracker_evolution_registrar, G_TYPE_OBJECT)
G_DEFINE_TYPE (TrackerEvolutionPushRegistrar, tracker_evolution_push_registrar, TRACKER_TYPE_PUSH_REGISTRAR);
-/* This runs in-process of trackerd. It simply proxies everything to the indexer
- * who wont always be running. Which is why this is needed (trackerd is always
- * running, so it's more suitable to respond to Evolution's requests). */
-
static void
tracker_evolution_registrar_finalize (GObject *object)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
- if (priv->idx_proxy)
- g_object_unref (priv->idx_proxy);
-
G_OBJECT_CLASS (tracker_evolution_registrar_parent_class)->finalize (object);
}
-static void
-tracker_evolution_registrar_set_connection (TrackerEvolutionRegistrar *object,
- DBusGConnection *connection)
-{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
- priv->connection = connection; /* weak */
-
- priv->idx_proxy = dbus_g_proxy_new_for_name (priv->connection,
- "org.freedesktop.Tracker.Indexer",
- TRACKER_EVOLUTION_INDEXER_PATH,
- TRACKER_EVOLUTION_REGISTRAR_INTERFACE);
-}
static void
tracker_evolution_registrar_set_property (GObject *object,
@@ -104,10 +108,6 @@ tracker_evolution_registrar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (prop_id) {
- case PROP_CONNECTION:
- tracker_evolution_registrar_set_connection (TRACKER_EVOLUTION_REGISTRAR (object),
- g_value_get_pointer (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -119,12 +119,7 @@ tracker_evolution_registrar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
switch (prop_id) {
- case PROP_CONNECTION:
- g_value_set_pointer (value, priv->connection);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -139,14 +134,6 @@ tracker_evolution_registrar_class_init (TrackerEvolutionRegistrarClass *klass)
object_class->set_property = tracker_evolution_registrar_set_property;
object_class->get_property = tracker_evolution_registrar_get_property;
- g_object_class_install_property (object_class,
- PROP_CONNECTION,
- g_param_spec_pointer ("connection",
- "DBus connection",
- "DBus connection",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
g_type_class_add_private (object_class, sizeof (TrackerEvolutionRegistrarPrivate));
}
@@ -155,6 +142,336 @@ tracker_evolution_registrar_init (TrackerEvolutionRegistrar *object)
{
}
+
+
+
+
+#if 0
+static void
+extract_mime_parts (GMimeObject *object,
+ gpointer user_data)
+{
+ const gchar *message_subject = user_data;
+ gchar *subject = NULL;
+ const gchar *disposition, *filename;
+ GMimePart *part;
+
+ if (GMIME_IS_MESSAGE_PART (object)) {
+ GMimeMessage *message;
+
+ message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (object));
+
+ if (message) {
+ g_mime_message_foreach_part (message, extract_mime_parts, user_data);
+ g_object_unref (message);
+ }
+
+ return;
+ } else if (GMIME_IS_MULTIPART (object)) {
+ g_mime_multipart_foreach (GMIME_MULTIPART (object), extract_mime_parts, user_data);
+ return;
+ }
+
+ part = GMIME_PART (object);
+ disposition = g_mime_part_get_content_disposition (part);
+
+ if (!disposition ||
+ (g_strcmp0 (disposition, GMIME_DISPOSITION_ATTACHMENT) != 0 &&
+ g_strcmp0 (disposition, GMIME_DISPOSITION_INLINE) != 0)) {
+ return;
+ }
+
+ filename = g_mime_part_get_filename (GMIME_PART (object));
+
+ if (!filename ||
+ g_strcmp0 (filename, "signature.asc") == 0 ||
+ g_strcmp0 (filename, "signature.pgp") == 0) {
+ return;
+ }
+
+ if (filename) {
+ GHashTable *data;
+ TrackerModuleMetadata *metadata;
+ gchar *subject;
+
+ /* This is not a path but a URI: don't use the OS's dir separator
+ * here, use the '/'. Another option is to use '#' instead of '/'
+ * here. This depends on how we want to format the URI and what
+ * Evolution can cope with as URI for an attachment (I don't
+ * think it can cope with any attachment URI, btw). */
+
+ subject = g_strdup_printf ("%s/%s", message_subject,
+ filename);
+
+ tracker_data_insert_statement (subject,
+ "File:Path",
+ filename);
+
+ tracker_data_insert_statement (subject,
+ "File:Name",
+ filename);
+
+ g_free (subject);
+ }
+}
+
+static gchar *
+get_object_encoding (GMimeObject *object)
+{
+ const gchar *start_encoding, *end_encoding;
+ const gchar *content_type = NULL;
+
+ if (GMIME_IS_MESSAGE (object)) {
+ content_type = g_mime_message_get_header (GMIME_MESSAGE (object), "Content-Type");
+ } else if (GMIME_IS_PART (object)) {
+ content_type = g_mime_part_get_content_header (GMIME_PART (object), "Content-Type");
+ }
+
+ if (!content_type) {
+ return NULL;
+ }
+
+ start_encoding = strstr (content_type, "charset=");
+
+ if (!start_encoding) {
+ return NULL;
+ }
+
+ start_encoding += strlen ("charset=");
+
+ if (start_encoding[0] == '"') {
+ /* encoding is quoted */
+ start_encoding++;
+ end_encoding = strstr (start_encoding, "\"");
+ } else {
+ end_encoding = strstr (start_encoding, ";");
+ }
+
+ if (end_encoding) {
+ return g_strndup (start_encoding, end_encoding - start_encoding);
+ } else {
+ return g_strdup (start_encoding);
+ }
+}
+#endif
+
+static void
+perform_set (TrackerEvolutionRegistrar *object,
+ const gchar *subject,
+ const GStrv predicates,
+ const GStrv values)
+{
+ guint i = 0;
+
+ if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
+ tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
+ NIE_DATASOURCE);
+ }
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_EMAIL);
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_MAILBOXDATA_OBJECT);
+
+ tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
+ DATASOURCE_URN);
+
+ while (predicates [i] != NULL && values[i] != NULL) {
+
+ /* TODO: TRACKER_EVOLUTION_PREDICATE_JUNK (!)
+ * TRACKER_EVOLUTION_PREDICATE_ANSWERED
+ * TRACKER_EVOLUTION_PREDICATE_FLAGGED
+ * TRACKER_EVOLUTION_PREDICATE_FORWARDED
+ * TRACKER_EVOLUTION_PREDICATE_DELETED (!)
+ * TRACKER_EVOLUTION_PREDICATE_SIZE (!) :
+ *
+ * I don't have predicates in Tracker's ontology for these. In
+ * Jürg's vstore branch we are working with Nepomuk as ontology-
+ * set. Perhaps when we merge this to that branch that we can
+ * improve this situation. */
+
+
+#if 0
+
+ /* Disabling this as I can't find any version of GMime-2.0 that
+ * wont crash on any of my test E-mails. Going to ask Garnacho
+ * to migrate to GMime-2.4 with his old Evolution support. */
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_FILE) == 0) {
+ GMimeStream *stream;
+ GMimeParser *parser;
+ GMimeMessage *message;
+ gint fd;
+ gchar *text, *orig_text, *ptr, *encoding;
+ gchar *path = g_strdup (values[i]);
+ off_t offset = 0;
+ gboolean is_html;
+
+ ptr = strstr (path, "/!");
+ if (ptr) {
+ offset = (off_t) atol (ptr+2);
+ *ptr = '\0';
+ }
+
+ fd = tracker_file_open (path, FALSE);
+
+ g_free (path);
+
+ if (fd == -1)
+ goto cont;
+
+ stream = g_mime_stream_fs_new_with_bounds (fd, offset, -1);
+
+ if (!stream) {
+ close (fd);
+ goto cont;
+ }
+
+ parser = g_mime_parser_new_with_stream (stream);
+
+ if (!parser) {
+ g_object_unref (stream);
+ goto cont;
+ }
+
+ g_mime_parser_set_scan_from (parser, FALSE);
+
+ message = g_mime_parser_construct_message (parser);
+
+ if (!message) {
+ g_object_unref (parser);
+ g_object_unref (stream);
+ goto cont;
+ }
+
+ g_mime_message_foreach_part (message,
+ extract_mime_parts,
+ subject);
+
+ orig_text = g_mime_message_get_body (message, TRUE, &is_html);
+
+ if (orig_text) {
+
+ encoding = get_object_encoding (GMIME_OBJECT (message));
+
+ if (encoding) {
+ text = g_convert (text, -1, "utf8", encoding, NULL, NULL, NULL);
+ g_free (orig_text);
+ } else
+ text = orig_text;
+
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_TEXT,
+ text);
+
+ g_free (text);
+ g_free (encoding);
+ }
+
+ g_object_unref (message);
+ g_object_unref (parser);
+ g_object_unref (stream);
+ }
+#endif
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TAG) == 0) {
+ gchar *key, *value;
+
+ if (!values[i] || strlen (values[i]) < 1)
+ goto cont;
+
+ key = g_strdup_printf ("X-Evolution-UserTag-%s", (values[i]));
+
+ value = strchr (key, '=');
+
+ if (value) {
+ *value = '\0';
+ value++;
+ }
+
+ tracker_data_insert_statement (":1", RDF_TYPE,
+ METADATA_EMAIL_MESSAGE_HEADER);
+
+ tracker_data_insert_statement (":1",
+ METADATA_EMAIL_MESSAGE_HEADER_NAME,
+ key);
+
+ tracker_data_insert_statement (":1",
+ METADATA_EMAIL_MESSAGE_HEADER_VALUE,
+ value);
+
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_MESSAGE_HEADER,
+ ":1");
+
+ g_free (key);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SUBJECT) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SUBJECT,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SENT) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_DATE,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_FROM) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SENDER,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TO) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SENT_TO,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_CC) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_CC,
+ values[i]);
+ }
+
+ cont:
+
+ i++;
+ }
+
+}
+
+static void
+perform_unset (TrackerEvolutionRegistrar *object,
+ const gchar *subject)
+{
+ tracker_data_delete_resource (subject);
+}
+
+static void
+perform_cleanup (TrackerEvolutionRegistrar *object)
+{
+ GError *error = NULL;
+
+ tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+set_stored_last_modseq (guint last_modseq)
+{
+ tracker_data_manager_set_db_option_int ("EvolutionLastModseq", (gint) last_modseq);
+}
+
+
void
tracker_evolution_registrar_set (TrackerEvolutionRegistrar *object,
const gchar *subject,
@@ -164,8 +481,6 @@ tracker_evolution_registrar_set (TrackerEvolutionRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
if (predicates && values) {
@@ -173,16 +488,11 @@ tracker_evolution_registrar_set (TrackerEvolutionRegistrar *object,
dbus_async_return_if_fail (g_strv_length (predicates) ==
g_strv_length (values), context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Set",
- G_TYPE_STRING, subject,
- G_TYPE_STRV, predicates,
- G_TYPE_STRV, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_set (object, subject, predicates, values);
}
+ set_stored_last_modseq (modseq);
+
dbus_g_method_return (context);
}
@@ -195,8 +505,8 @@ tracker_evolution_registrar_set_many (TrackerEvolutionRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
guint len;
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
dbus_async_return_if_fail (predicates != NULL, context);
@@ -207,14 +517,16 @@ tracker_evolution_registrar_set_many (TrackerEvolutionRegistrar *object,
dbus_async_return_if_fail (len == predicates->len, context);
dbus_async_return_if_fail (len == values->len, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "SetMany",
- G_TYPE_STRV, subjects,
- TRACKER_TYPE_G_STRV_ARRAY, predicates,
- TRACKER_TYPE_G_STRV_ARRAY, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+ GStrv preds = g_ptr_array_index (predicates, i);
+ GStrv vals = g_ptr_array_index (values, i);
+
+ perform_set (object, subjects[i], preds, vals);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -226,16 +538,18 @@ tracker_evolution_registrar_unset_many (TrackerEvolutionRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "UnsetMany",
- G_TYPE_STRV, subjects,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+
+ perform_unset (object, subjects[i]);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -247,16 +561,9 @@ tracker_evolution_registrar_unset (TrackerEvolutionRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Unset",
- G_TYPE_STRING, subject,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_unset (object, subject);
dbus_g_method_return (context);
}
@@ -267,13 +574,9 @@ tracker_evolution_registrar_cleanup (TrackerEvolutionRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerEvolutionRegistrarPrivate *priv = TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE (object);
+ perform_cleanup (object);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Cleanup",
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -324,8 +627,7 @@ tracker_evolution_push_registrar_enable (TrackerPushRegistrar *registrar,
return;
}
- object = g_object_new (TRACKER_TYPE_EVOLUTION_REGISTRAR,
- "connection", connection, NULL);
+ object = g_object_new (TRACKER_TYPE_EVOLUTION_REGISTRAR, NULL);
dbus_g_object_type_install_info (G_OBJECT_TYPE (object),
&dbus_glib_tracker_evolution_registrar_object_info);
diff --git a/src/plugins/kmail/Makefile.am b/src/plugins/kmail/Makefile.am
index 5a3e5e9..acd2a8e 100644
--- a/src/plugins/kmail/Makefile.am
+++ b/src/plugins/kmail/Makefile.am
@@ -12,16 +12,8 @@ INCLUDES = -I$(top_srcdir)/src \
module_flags = -module -avoid-version -no-undefined
pushd_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/daemon
-pushi_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/indexer
pushd_modules_LTLIBRARIES = libtracker-module_kmail-daemon-module.la
-pushi_modules_LTLIBRARIES = libtracker-module_kmail-indexer-module.la
-
-libtracker_module_kmail_indexer_module_la_SOURCES = \
- tracker-kmail-indexer.c \
- tracker-kmail-indexer.h \
- tracker-kmail-registrar-glue.h \
- tracker-kmail-common.h
libtracker_module_kmail_daemon_module_la_SOURCES = \
tracker-kmail-registrar.c \
@@ -43,21 +35,6 @@ libtracker_module_kmail_daemon_module_la_LIBADD = \
$(RAPTOR_LIBS) \
$(GCOV_LIBS)
-libtracker_module_kmail_indexer_module_la_LDFLAGS = $(module_flags)
-
-libtracker_module_kmail_indexer_module_la_LIBADD = \
- $(top_builddir)/src/libtracker-data/libtracker-data.la \
- $(top_builddir)/src/libtracker-db/libtracker-db.la \
- $(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(GMODULE_LIBS) \
- $(DBUS_LIBS) \
- $(GTHREAD_LIBS) \
- $(GIO_LIBS) \
- $(GLIB2_LIBS) \
- $(RAPTOR_LIBS) \
- $(GMIME_LIBS) \
- $(GCOV_LIBS)
-
dbus_sources = tracker-kmail-registrar-glue.h
%-glue.h: %.xml
diff --git a/src/plugins/kmail/tracker-kmail-indexer.c b/src/plugins/kmail/tracker-kmail-indexer.c
deleted file mode 100644
index cad2266..0000000
--- a/src/plugins/kmail/tracker-kmail-indexer.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <gio/gio.h>
-#include <glib/gstdio.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gmime/gmime.h>
-
-#include <libtracker-common/tracker-ontology.h>
-
-#include <libtracker-data/tracker-data-manager.h>
-#include <libtracker-data/tracker-data-query.h>
-#include <libtracker-data/tracker-data-update.h>
-
-/* This is okay, we run in-process of the indexer: we can access its symbols */
-#include <tracker-indexer/tracker-module.h>
-#include <tracker-indexer/tracker-push.h>
-#include <tracker-indexer/tracker-module-metadata-private.h>
-
-#include "tracker-kmail-indexer.h"
-
-/* These defines/renames are necessary for -glue.h */
-#define tracker_kmail_registrar_set tracker_kmail_indexer_set
-#define tracker_kmail_registrar_set_many tracker_kmail_indexer_set_many
-#define tracker_kmail_registrar_unset_many tracker_kmail_indexer_unset_many
-#define tracker_kmail_registrar_unset tracker_kmail_indexer_unset
-#define tracker_kmail_registrar_cleanup tracker_kmail_indexer_cleanup
-#define dbus_glib_tracker_kmail_indexer_object_info dbus_glib_tracker_kmail_registrar_object_info
-
-#include "tracker-kmail-registrar-glue.h"
-
-/* Based on data/services/email.metadata */
-
-
-#define METADATA_EMAIL TRACKER_NMO_PREFIX "Email"
-#define METADATA_MAILBOXDATA_OBJECT TRACKER_NMO_PREFIX "MailboxDataObject"
-
-#define METADATA_EMAIL_RECIPIENT TRACKER_NMO_PREFIX "to"
-#define METADATA_EMAIL_DATE TRACKER_NMO_PREFIX "receivedDate"
-#define METADATA_EMAIL_SENDER TRACKER_NMO_PREFIX "sender"
-#define METADATA_EMAIL_SUBJECT TRACKER_NMO_PREFIX "subject"
-#define METADATA_EMAIL_SENT_TO TRACKER_NMO_PREFIX "recipient"
-#define METADATA_EMAIL_CC TRACKER_NMO_PREFIX "cc"
-#if 0
-#define METADATA_EMAIL_TEXT TRACKER_NMO_PREFIX "Body"
-#endif
-
-#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
-#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
-
-#define RDF_TYPE TRACKER_RDF_PREFIX "type"
-
-#define METADATA_EMAIL_MESSAGE_HEADER TRACKER_NMO_PREFIX "messageHeader"
-#define METADATA_EMAIL_MESSAGE_HEADER_NAME TRACKER_NMO_PREFIX "headerName"
-#define METADATA_EMAIL_MESSAGE_HEADER_VALUE TRACKER_NMO_PREFIX "headerValue"
-
-#define NAO_TAG TRACKER_NAO_PREFIX "Tag"
-#define NAO_HASTAG TRACKER_NAO_PREFIX "hasTag"
-#define NAO_PREFLABEL TRACKER_NAO_PREFIX "prefLabel"
-
-#define DATASOURCE_URN "urn:nepomuk:datasource:4a157cf0-1241-11de-8c30-0800200c9a66"
-
-G_DEFINE_TYPE (TrackerKMailIndexer, tracker_kmail_indexer, G_TYPE_OBJECT)
-
-/* This runs in-process of tracker-indexer */
-
-static GObject *idx_indexer = NULL;
-
-
-enum {
- PROP_0,
-};
-
-void tracker_push_module_init (TrackerConfig *config);
-void tracker_push_module_shutdown (void);
-
-static void
-tracker_kmail_indexer_finalize (GObject *object)
-{
- G_OBJECT_CLASS (tracker_kmail_indexer_parent_class)->finalize (object);
-}
-
-static void
-tracker_kmail_indexer_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_kmail_indexer_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_kmail_indexer_class_init (TrackerKMailIndexerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tracker_kmail_indexer_finalize;
- object_class->set_property = tracker_kmail_indexer_set_property;
- object_class->get_property = tracker_kmail_indexer_get_property;
-}
-
-static void
-tracker_kmail_indexer_init (TrackerKMailIndexer *object)
-{
-}
-
-
-static void
-perform_set (TrackerKMailIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values)
-{
- guint i = 0;
-
- if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
- tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
- NIE_DATASOURCE);
- }
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_EMAIL);
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_MAILBOXDATA_OBJECT);
-
- tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
- DATASOURCE_URN);
-
- while (predicates [i] != NULL && values[i] != NULL) {
-
- /* TODO: TRACKER_KMAIL_PREDICATE_IDMD5
- * TRACKER_KMAIL_PREDICATE_UID
- * TRACKER_KMAIL_PREDICATE_SERNUM
- * TRACKER_KMAIL_PREDICATE_SPAM
- * TRACKER_KMAIL_PREDICATE_HAM
- *
- * I don't have predicates in Tracker's ontology for these. In
- * Jürg's vstore branch we are working with Nepomuk as ontology-
- * set. Perhaps when we merge this to that branch that we can
- * improve this situation. */
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TAG) == 0) {
-
- tracker_data_insert_statement (":1", RDF_TYPE,
- NAO_TAG);
-
- tracker_data_insert_statement (":1",
- NAO_PREFLABEL,
- values[i]);
-
- tracker_data_insert_statement (subject,
- NAO_HASTAG,
- ":1");
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SUBJECT) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SUBJECT,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SENT) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_DATE,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_FROM) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENDER,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TO) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENT_TO,
- values[i]);
- }
-
- if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_CC) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_CC,
- values[i]);
- }
-
- i++;
- }
-
-}
-
-static void
-perform_unset (TrackerKMailIndexer *object,
- const gchar *subject)
-{
- tracker_data_delete_resource (subject);
-}
-
-static void
-perform_cleanup (TrackerKMailIndexer *object)
-{
- GError *error = NULL;
-
- tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-set_stored_last_modseq (guint last_modseq)
-{
- tracker_data_manager_set_db_option_int ("KMailLastModseq", (gint) last_modseq);
-}
-
-void
-tracker_kmail_indexer_set (TrackerKMailIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- if (predicates && values) {
-
- dbus_async_return_if_fail (g_strv_length (predicates) ==
- g_strv_length (values), context);
-
- perform_set (object, subject, predicates, values);
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_kmail_indexer_set_many (TrackerKMailIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint len;
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
- dbus_async_return_if_fail (predicates != NULL, context);
- dbus_async_return_if_fail (values != NULL, context);
-
- len = g_strv_length (subjects);
-
- dbus_async_return_if_fail (len == predicates->len, context);
- dbus_async_return_if_fail (len == values->len, context);
-
- while (subjects[i] != NULL) {
- GStrv preds = g_ptr_array_index (predicates, i);
- GStrv vals = g_ptr_array_index (values, i);
-
- perform_set (object, subjects[i], preds, vals);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_kmail_indexer_unset_many (TrackerKMailIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
-
- while (subjects[i] != NULL) {
-
- perform_unset (object, subjects[i]);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_kmail_indexer_unset (TrackerKMailIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- perform_unset (object, subject);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_kmail_indexer_cleanup (TrackerKMailIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- perform_cleanup (object);
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_push_module_init (TrackerConfig *config)
-{
- GError *error = NULL;
- DBusGConnection *connection;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
- if (!error) {
- idx_indexer = g_object_new (TRACKER_TYPE_KMAIL_INDEXER, NULL);
-
- dbus_g_object_type_install_info (G_OBJECT_TYPE (idx_indexer),
- &dbus_glib_tracker_kmail_indexer_object_info);
-
- dbus_g_connection_register_g_object (connection,
- TRACKER_KMAIL_INDEXER_PATH,
- idx_indexer);
- }
-
- if (error) {
- g_critical ("Can't init DBus for KMail support: %s", error->message);
- g_error_free (error);
- }
-}
-
-void
-tracker_push_module_shutdown (void)
-{
- if (idx_indexer)
- g_object_unref (idx_indexer);
-}
diff --git a/src/plugins/kmail/tracker-kmail-indexer.h b/src/plugins/kmail/tracker-kmail-indexer.h
deleted file mode 100644
index 17a6d52..0000000
--- a/src/plugins/kmail/tracker-kmail-indexer.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#ifndef __LIBTRACKER_KMAIL_H__
-#define __LIBTRACKER_KMAIL_H__
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-
-#include <libtracker-common/tracker-common.h>
-
-G_BEGIN_DECLS
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-#include <dbus/dbus-glib-bindings.h>
-
-#include <tracker-indexer/tracker-indexer.h>
-
-#include "tracker-kmail-common.h"
-
-G_BEGIN_DECLS
-
-#define TRACKER_TYPE_KMAIL_INDEXER (tracker_kmail_indexer_get_type())
-#define TRACKER_KMAIL_INDEXER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_KMAIL_INDEXER, TrackerKMailIndexer))
-#define TRACKER_KMAIL_INDEXER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_KMAIL_INDEXER, TrackerKMailIndexerClass))
-#define TRACKER_KMAIL_INDEXER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_KMAIL_INDEXER, TrackerKMailIndexerClass))
-
-G_BEGIN_DECLS
-
-typedef struct TrackerKMailIndexer TrackerKMailIndexer;
-typedef struct TrackerKMailIndexerClass TrackerKMailIndexerClass;
-
-struct TrackerKMailIndexer {
- GObject parent;
-};
-
-struct TrackerKMailIndexerClass {
- GObjectClass parent;
-};
-
-GType tracker_kmail_indexer_get_type (void);
-
-void tracker_kmail_indexer_set (TrackerKMailIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_kmail_indexer_set_many (TrackerKMailIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_kmail_indexer_unset_many (TrackerKMailIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_kmail_indexer_unset (TrackerKMailIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_kmail_indexer_cleanup (TrackerKMailIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-
-G_END_DECLS
-
-#endif /* __LIBTRACKER_KMAIL_H__ */
diff --git a/src/plugins/kmail/tracker-kmail-registrar.c b/src/plugins/kmail/tracker-kmail-registrar.c
index 093f237..664ae1c 100644
--- a/src/plugins/kmail/tracker-kmail-registrar.c
+++ b/src/plugins/kmail/tracker-kmail-registrar.c
@@ -23,11 +23,14 @@
#include "config.h"
+#include <string.h>
+
#include <glib-object.h>
#include <dbus/dbus-glib-bindings.h>
#include <libtracker-data/tracker-data-update.h>
#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
#include <trackerd/tracker-push-registrar.h>
@@ -41,6 +44,36 @@
#define TRACKER_TYPE_KMAIL_PUSH_REGISTRAR (tracker_kmail_push_registrar_get_type ())
#define TRACKER_KMAIL_PUSH_REGISTRAR(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_KMAIL_PUSH_REGISTRAR, TrackerKMailPushRegistrar))
+
+
+#define METADATA_EMAIL TRACKER_NMO_PREFIX "Email"
+#define METADATA_MAILBOXDATA_OBJECT TRACKER_NMO_PREFIX "MailboxDataObject"
+
+#define METADATA_EMAIL_RECIPIENT TRACKER_NMO_PREFIX "to"
+#define METADATA_EMAIL_DATE TRACKER_NMO_PREFIX "receivedDate"
+#define METADATA_EMAIL_SENDER TRACKER_NMO_PREFIX "sender"
+#define METADATA_EMAIL_SUBJECT TRACKER_NMO_PREFIX "subject"
+#define METADATA_EMAIL_SENT_TO TRACKER_NMO_PREFIX "recipient"
+#define METADATA_EMAIL_CC TRACKER_NMO_PREFIX "cc"
+#if 0
+#define METADATA_EMAIL_TEXT TRACKER_NMO_PREFIX "Body"
+#endif
+
+#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
+#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
+
+#define RDF_TYPE TRACKER_RDF_PREFIX "type"
+
+#define METADATA_EMAIL_MESSAGE_HEADER TRACKER_NMO_PREFIX "messageHeader"
+#define METADATA_EMAIL_MESSAGE_HEADER_NAME TRACKER_NMO_PREFIX "headerName"
+#define METADATA_EMAIL_MESSAGE_HEADER_VALUE TRACKER_NMO_PREFIX "headerValue"
+
+#define NAO_TAG TRACKER_NAO_PREFIX "Tag"
+#define NAO_HASTAG TRACKER_NAO_PREFIX "hasTag"
+#define NAO_PREFLABEL TRACKER_NAO_PREFIX "prefLabel"
+
+#define DATASOURCE_URN "urn:nepomuk:datasource:4a157cf0-1241-11de-8c30-0800200c9a66"
+
typedef struct TrackerKMailPushRegistrar TrackerKMailPushRegistrar;
typedef struct TrackerKMailPushRegistrarClass TrackerKMailPushRegistrarClass;
@@ -54,13 +87,11 @@ struct TrackerKMailPushRegistrarClass {
typedef struct {
- DBusGProxy *idx_proxy;
- DBusGConnection *connection;
+ gpointer dummy;
} TrackerKMailRegistrarPrivate;
enum {
PROP_0,
- PROP_CONNECTION
};
static GType tracker_kmail_push_registrar_get_type (void) G_GNUC_CONST;
@@ -68,35 +99,12 @@ static GType tracker_kmail_push_registrar_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (TrackerKMailRegistrar, tracker_kmail_registrar, G_TYPE_OBJECT)
G_DEFINE_TYPE (TrackerKMailPushRegistrar, tracker_kmail_push_registrar, TRACKER_TYPE_PUSH_REGISTRAR);
-/* This runs in-process of trackerd. It simply proxies everything to the indexer
- * who wont always be running. Which is why this is needed (trackerd is always
- * running, so it's more suitable to respond to KMail's requests). */
-
static void
tracker_kmail_registrar_finalize (GObject *object)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
- if (priv->idx_proxy)
- g_object_unref (priv->idx_proxy);
-
G_OBJECT_CLASS (tracker_kmail_registrar_parent_class)->finalize (object);
}
-static void
-tracker_kmail_registrar_set_connection (TrackerKMailRegistrar *object,
- DBusGConnection *connection)
-{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
- priv->connection = connection; /* weak */
-
- priv->idx_proxy = dbus_g_proxy_new_for_name (priv->connection,
- "org.freedesktop.Tracker.Indexer",
- TRACKER_KMAIL_INDEXER_PATH,
- TRACKER_KMAIL_REGISTRAR_INTERFACE);
-}
-
static void
tracker_kmail_registrar_set_property (GObject *object,
guint prop_id,
@@ -104,10 +112,6 @@ tracker_kmail_registrar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (prop_id) {
- case PROP_CONNECTION:
- tracker_kmail_registrar_set_connection (TRACKER_KMAIL_REGISTRAR (object),
- g_value_get_pointer (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -119,12 +123,7 @@ tracker_kmail_registrar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
switch (prop_id) {
- case PROP_CONNECTION:
- g_value_set_pointer (value, priv->connection);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -139,14 +138,6 @@ tracker_kmail_registrar_class_init (TrackerKMailRegistrarClass *klass)
object_class->set_property = tracker_kmail_registrar_set_property;
object_class->get_property = tracker_kmail_registrar_get_property;
- g_object_class_install_property (object_class,
- PROP_CONNECTION,
- g_param_spec_pointer ("connection",
- "DBus connection",
- "DBus connection",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
g_type_class_add_private (object_class, sizeof (TrackerKMailRegistrarPrivate));
}
@@ -155,6 +146,120 @@ tracker_kmail_registrar_init (TrackerKMailRegistrar *object)
{
}
+
+
+
+static void
+perform_set (TrackerKMailRegistrar *object,
+ const gchar *subject,
+ const GStrv predicates,
+ const GStrv values)
+{
+ guint i = 0;
+
+ if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
+ tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
+ NIE_DATASOURCE);
+ }
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_EMAIL);
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_MAILBOXDATA_OBJECT);
+
+ tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
+ DATASOURCE_URN);
+
+ while (predicates [i] != NULL && values[i] != NULL) {
+
+ /* TODO: TRACKER_KMAIL_PREDICATE_IDMD5
+ * TRACKER_KMAIL_PREDICATE_UID
+ * TRACKER_KMAIL_PREDICATE_SERNUM
+ * TRACKER_KMAIL_PREDICATE_SPAM
+ * TRACKER_KMAIL_PREDICATE_HAM
+ *
+ * I don't have predicates in Tracker's ontology for these. In
+ * Jürg's vstore branch we are working with Nepomuk as ontology-
+ * set. Perhaps when we merge this to that branch that we can
+ * improve this situation. */
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TAG) == 0) {
+
+ tracker_data_insert_statement (":1", RDF_TYPE,
+ NAO_TAG);
+
+ tracker_data_insert_statement (":1",
+ NAO_PREFLABEL,
+ values[i]);
+
+ tracker_data_insert_statement (subject,
+ NAO_HASTAG,
+ ":1");
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SUBJECT) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SUBJECT,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SENT) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_DATE,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_FROM) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SENDER,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TO) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_SENT_TO,
+ values[i]);
+ }
+
+ if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_CC) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_EMAIL_CC,
+ values[i]);
+ }
+
+ i++;
+ }
+
+}
+
+static void
+perform_unset (TrackerKMailRegistrar *object,
+ const gchar *subject)
+{
+ tracker_data_delete_resource (subject);
+}
+
+static void
+perform_cleanup (TrackerKMailRegistrar *object)
+{
+ GError *error = NULL;
+
+ tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+set_stored_last_modseq (guint last_modseq)
+{
+ tracker_data_manager_set_db_option_int ("KMailLastModseq", (gint) last_modseq);
+}
+
+
void
tracker_kmail_registrar_set (TrackerKMailRegistrar *object,
const gchar *subject,
@@ -164,8 +269,6 @@ tracker_kmail_registrar_set (TrackerKMailRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
if (predicates && values) {
@@ -173,16 +276,11 @@ tracker_kmail_registrar_set (TrackerKMailRegistrar *object,
dbus_async_return_if_fail (g_strv_length (predicates) ==
g_strv_length (values), context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Set",
- G_TYPE_STRING, subject,
- G_TYPE_STRV, predicates,
- G_TYPE_STRV, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_set (object, subject, predicates, values);
}
+ set_stored_last_modseq (modseq);
+
dbus_g_method_return (context);
}
@@ -195,8 +293,8 @@ tracker_kmail_registrar_set_many (TrackerKMailRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
guint len;
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
dbus_async_return_if_fail (predicates != NULL, context);
@@ -207,14 +305,16 @@ tracker_kmail_registrar_set_many (TrackerKMailRegistrar *object,
dbus_async_return_if_fail (len == predicates->len, context);
dbus_async_return_if_fail (len == values->len, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "SetMany",
- G_TYPE_STRV, subjects,
- TRACKER_TYPE_G_STRV_ARRAY, predicates,
- TRACKER_TYPE_G_STRV_ARRAY, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+ GStrv preds = g_ptr_array_index (predicates, i);
+ GStrv vals = g_ptr_array_index (values, i);
+
+ perform_set (object, subjects[i], preds, vals);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -226,16 +326,18 @@ tracker_kmail_registrar_unset_many (TrackerKMailRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "UnsetMany",
- G_TYPE_STRV, subjects,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+
+ perform_unset (object, subjects[i]);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -247,16 +349,9 @@ tracker_kmail_registrar_unset (TrackerKMailRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Unset",
- G_TYPE_STRING, subject,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_unset (object, subject);
dbus_g_method_return (context);
}
@@ -267,13 +362,9 @@ tracker_kmail_registrar_cleanup (TrackerKMailRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerKMailRegistrarPrivate *priv = TRACKER_KMAIL_REGISTRAR_GET_PRIVATE (object);
+ perform_cleanup (object);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Cleanup",
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
diff --git a/src/plugins/rss/Makefile.am b/src/plugins/rss/Makefile.am
index 712040d..9e85939 100644
--- a/src/plugins/rss/Makefile.am
+++ b/src/plugins/rss/Makefile.am
@@ -12,16 +12,8 @@ INCLUDES = -I$(top_srcdir)/src \
module_flags = -module -avoid-version -no-undefined
pushd_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/daemon
-pushi_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)/push-modules/indexer
pushd_modules_LTLIBRARIES = libtracker-module-rss-daemon-module.la
-pushi_modules_LTLIBRARIES = libtracker-module-rss-indexer-module.la
-
-libtracker_module_rss_indexer_module_la_SOURCES = \
- tracker-rss-indexer.c \
- tracker-rss-indexer.h \
- tracker-rss-registrar-glue.h \
- tracker-rss-common.h
libtracker_module_rss_daemon_module_la_SOURCES = \
tracker-rss-registrar.c \
@@ -43,21 +35,6 @@ libtracker_module_rss_daemon_module_la_LIBADD = \
$(RAPTOR_LIBS) \
$(GCOV_LIBS)
-libtracker_module_rss_indexer_module_la_LDFLAGS = $(module_flags)
-
-libtracker_module_rss_indexer_module_la_LIBADD = \
- $(top_builddir)/src/libtracker-data/libtracker-data.la \
- $(top_builddir)/src/libtracker-db/libtracker-db.la \
- $(top_builddir)/src/libtracker-common/libtracker-common.la \
- $(GMODULE_LIBS) \
- $(DBUS_LIBS) \
- $(GTHREAD_LIBS) \
- $(GIO_LIBS) \
- $(GLIB2_LIBS) \
- $(RAPTOR_LIBS) \
- $(GMIME_LIBS) \
- $(GCOV_LIBS)
-
dbus_sources = tracker-rss-registrar-glue.h
%-glue.h: %.xml
diff --git a/src/plugins/rss/tracker-rss-indexer.c b/src/plugins/rss/tracker-rss-indexer.c
deleted file mode 100644
index 1578f29..0000000
--- a/src/plugins/rss/tracker-rss-indexer.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <glib.h>
-#include <gio/gio.h>
-#include <glib/gstdio.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <gmime/gmime.h>
-
-#include <libtracker-common/tracker-ontology.h>
-
-#include <libtracker-data/tracker-data-update.h>
-#include <libtracker-data/tracker-data-manager.h>
-
-/* This is okay, we run in-process of the indexer: we can access its symbols */
-#include <tracker-indexer/tracker-module.h>
-#include <tracker-indexer/tracker-push.h>
-#include <tracker-indexer/tracker-module-metadata-private.h>
-
-#include "tracker-rss-indexer.h"
-
-/* These defines/renames are necessary for -glue.h */
-#define tracker_rss_registrar_set tracker_rss_indexer_set
-#define tracker_rss_registrar_set_many tracker_rss_indexer_set_many
-#define tracker_rss_registrar_unset_many tracker_rss_indexer_unset_many
-#define tracker_rss_registrar_unset tracker_rss_indexer_unset
-#define tracker_rss_registrar_cleanup tracker_rss_indexer_cleanup
-#define dbus_glib_tracker_rss_indexer_object_info dbus_glib_tracker_rss_registrar_object_info
-
-#include "tracker-rss-registrar-glue.h"
-
-/* This is of course TODO (and to move to libtracker-common/tracker-ontology.h): */
-#define TRACKER_RSS_PREFIX "http://www.tracker-project.org/temp/rss#"
-
-#define METADATA_RSS TRACKER_RSS_PREFIX "RSS"
-#define METADATA_RSSDATA_OBJECT TRACKER_RSS_PREFIX "RSSDataObject"
-
-#define METADATA_RSS_SOMETHING TRACKER_RSS_PREFIX "something"
-
-#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
-#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
-
-#define RDF_TYPE TRACKER_RDF_PREFIX "type"
-
-#define NAO_TAG TRACKER_NAO_PREFIX "Tag"
-#define NAO_PREFLABEL TRACKER_NAO_PREFIX "prefLabel"
-
-#define DATASOURCE_URN "urn:nepomuk:datasource:670e2cd0-1241-11de-8c30-0800200c9a66"
-
-G_DEFINE_TYPE (TrackerRssIndexer, tracker_rss_indexer, G_TYPE_OBJECT)
-
-/* This runs in-process of tracker-indexer */
-
-static GObject *idx_indexer = NULL;
-
-enum {
- PROP_0,
-};
-
-static void
-tracker_rss_indexer_finalize (GObject *object)
-{
- G_OBJECT_CLASS (tracker_rss_indexer_parent_class)->finalize (object);
-}
-
-static void
-tracker_rss_indexer_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_rss_indexer_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-tracker_rss_indexer_class_init (TrackerRssIndexerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = tracker_rss_indexer_finalize;
- object_class->set_property = tracker_rss_indexer_set_property;
- object_class->get_property = tracker_rss_indexer_get_property;
-}
-
-static void
-tracker_rss_indexer_init (TrackerRssIndexer *object)
-{
-}
-
-
-static void
-perform_set (TrackerRssIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values)
-{
- guint i = 0;
-
- /* TODO */
- return;
-
- if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
- tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
- NIE_DATASOURCE);
- }
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_RSS);
-
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_RSSDATA_OBJECT);
-
- tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
- DATASOURCE_URN);
-
- while (predicates [i] != NULL && values[i] != NULL) {
-
- if (g_strcmp0 (predicates[i], TRACKER_RSS_PREDICATE_THING) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_RSS_SOMETHING,
- values[i]);
- }
-
- i++;
- }
-}
-
-static void
-perform_unset (TrackerRssIndexer *object,
- const gchar *subject)
-{
- /* TODO */
- return;
-
- tracker_data_delete_resource (subject);
-}
-
-static void
-perform_cleanup (TrackerRssIndexer *object)
-{
- GError *error = NULL;
-
- /* TODO */
- return;
-
- tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-}
-
-static void
-set_stored_last_modseq (guint last_modseq)
-{
- tracker_data_manager_set_db_option_int ("RssLastModseq", (gint) last_modseq);
-}
-
-void
-tracker_rss_indexer_set (TrackerRssIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- if (predicates && values) {
-
- dbus_async_return_if_fail (g_strv_length (predicates) ==
- g_strv_length (values), context);
-
- perform_set (object, subject, predicates, values);
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_rss_indexer_set_many (TrackerRssIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint len;
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
- dbus_async_return_if_fail (predicates != NULL, context);
- dbus_async_return_if_fail (values != NULL, context);
-
- len = g_strv_length (subjects);
-
- dbus_async_return_if_fail (len == predicates->len, context);
- dbus_async_return_if_fail (len == values->len, context);
-
- while (subjects[i] != NULL) {
- GStrv preds = g_ptr_array_index (predicates, i);
- GStrv vals = g_ptr_array_index (values, i);
-
- perform_set (object, subjects[i], preds, vals);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_rss_indexer_unset_many (TrackerRssIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- guint i = 0;
-
- dbus_async_return_if_fail (subjects != NULL, context);
-
- while (subjects[i] != NULL) {
-
- perform_unset (object, subjects[i]);
-
- i++;
- }
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_rss_indexer_unset (TrackerRssIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- dbus_async_return_if_fail (subject != NULL, context);
-
- perform_unset (object, subject);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_rss_indexer_cleanup (TrackerRssIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror)
-{
- perform_cleanup (object);
-
- set_stored_last_modseq (modseq);
-
- dbus_g_method_return (context);
-}
-
-void
-tracker_push_module_init (TrackerConfig *config)
-{
- GError *error = NULL;
- DBusGConnection *connection;
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
- if (!error) {
- idx_indexer = g_object_new (TRACKER_TYPE_RSS_INDEXER, NULL);
-
- dbus_g_object_type_install_info (G_OBJECT_TYPE (idx_indexer),
- &dbus_glib_tracker_rss_indexer_object_info);
-
- dbus_g_connection_register_g_object (connection,
- TRACKER_RSS_INDEXER_PATH,
- idx_indexer);
- }
-
- if (error) {
- g_critical ("Can't init DBus for Rss support: %s", error->message);
- g_error_free (error);
- }
-}
-
-void
-tracker_push_module_shutdown (void)
-{
- if (idx_indexer)
- g_object_unref (idx_indexer);
-}
diff --git a/src/plugins/rss/tracker-rss-indexer.h b/src/plugins/rss/tracker-rss-indexer.h
deleted file mode 100644
index a886264..0000000
--- a/src/plugins/rss/tracker-rss-indexer.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2008, Nokia
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Philip Van Hoof <philip codeminded be>
- */
-
-#ifndef __LIBTRACKER_RSS_H__
-#define __LIBTRACKER_RSS_H__
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-
-#include <libtracker-common/tracker-common.h>
-
-G_BEGIN_DECLS
-
-#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION)
-#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions"
-#endif
-
-#include <glib.h>
-#include <dbus/dbus-glib-bindings.h>
-
-#include <tracker-indexer/tracker-indexer.h>
-
-#include "tracker-rss-common.h"
-
-G_BEGIN_DECLS
-
-#define TRACKER_TYPE_RSS_INDEXER (tracker_rss_indexer_get_type())
-#define TRACKER_RSS_INDEXER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_RSS_INDEXER, TrackerRssIndexer))
-#define TRACKER_RSS_INDEXER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_RSS_INDEXER, TrackerRssIndexerClass))
-#define TRACKER_RSS_INDEXER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_RSS_INDEXER, TrackerRssIndexerClass))
-
-G_BEGIN_DECLS
-
-typedef struct TrackerRssIndexer TrackerRssIndexer;
-typedef struct TrackerRssIndexerClass TrackerRssIndexerClass;
-
-struct TrackerRssIndexer {
- GObject parent;
-};
-
-struct TrackerRssIndexerClass {
- GObjectClass parent;
-};
-
-GType tracker_rss_indexer_get_type (void);
-
-void tracker_rss_indexer_set (TrackerRssIndexer *object,
- const gchar *subject,
- const GStrv predicates,
- const GStrv values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_rss_indexer_set_many (TrackerRssIndexer *object,
- const GStrv subjects,
- const GPtrArray *predicates,
- const GPtrArray *values,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_rss_indexer_unset_many (TrackerRssIndexer *object,
- const GStrv subjects,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_rss_indexer_unset (TrackerRssIndexer *object,
- const gchar *subject,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-void tracker_rss_indexer_cleanup (TrackerRssIndexer *object,
- const guint modseq,
- DBusGMethodInvocation *context,
- GError *derror);
-
-G_END_DECLS
-
-#endif /* __LIBTRACKER_RSS_H__ */
diff --git a/src/plugins/rss/tracker-rss-registrar.c b/src/plugins/rss/tracker-rss-registrar.c
index 7f4c206..0e3984a 100644
--- a/src/plugins/rss/tracker-rss-registrar.c
+++ b/src/plugins/rss/tracker-rss-registrar.c
@@ -28,6 +28,7 @@
#include <libtracker-data/tracker-data-update.h>
#include <libtracker-data/tracker-data-manager.h>
+#include <libtracker-data/tracker-data-query.h>
#include <trackerd/tracker-push-registrar.h>
@@ -41,6 +42,24 @@
#define TRACKER_TYPE_RSS_PUSH_REGISTRAR (tracker_rss_push_registrar_get_type ())
#define TRACKER_RSS_PUSH_REGISTRAR(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_RSS_PUSH_REGISTRAR, TrackerRssPushRegistrar))
+/* This is of course TODO (and to move to libtracker-common/tracker-ontology.h): */
+#define TRACKER_RSS_PREFIX "http://www.tracker-project.org/temp/rss#"
+
+#define METADATA_RSS TRACKER_RSS_PREFIX "RSS"
+#define METADATA_RSSDATA_OBJECT TRACKER_RSS_PREFIX "RSSDataObject"
+
+#define METADATA_RSS_SOMETHING TRACKER_RSS_PREFIX "something"
+
+#define NIE_DATASOURCE TRACKER_NIE_PREFIX "DataSource"
+#define NIE_DATASOURCE_P TRACKER_NIE_PREFIX "dataSource"
+
+#define RDF_TYPE TRACKER_RDF_PREFIX "type"
+
+#define NAO_TAG TRACKER_NAO_PREFIX "Tag"
+#define NAO_PREFLABEL TRACKER_NAO_PREFIX "prefLabel"
+
+#define DATASOURCE_URN "urn:nepomuk:datasource:670e2cd0-1241-11de-8c30-0800200c9a66"
+
typedef struct TrackerRssPushRegistrar TrackerRssPushRegistrar;
typedef struct TrackerRssPushRegistrarClass TrackerRssPushRegistrarClass;
@@ -54,13 +73,11 @@ struct TrackerRssPushRegistrarClass {
typedef struct {
- DBusGProxy *idx_proxy;
- DBusGConnection *connection;
+ gpointer dummy;
} TrackerRssRegistrarPrivate;
enum {
PROP_0,
- PROP_CONNECTION
};
static GType tracker_rss_push_registrar_get_type (void) G_GNUC_CONST;
@@ -68,35 +85,12 @@ static GType tracker_rss_push_registrar_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (TrackerRssRegistrar, tracker_rss_registrar, G_TYPE_OBJECT)
G_DEFINE_TYPE (TrackerRssPushRegistrar, tracker_rss_push_registrar, TRACKER_TYPE_PUSH_REGISTRAR);
-/* This runs in-process of trackerd. It simply proxies everything to the indexer
- * who wont always be running. Which is why this is needed (trackerd is always
- * running, so it's more suitable to respond to Rss's requests). */
-
static void
tracker_rss_registrar_finalize (GObject *object)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
-
- if (priv->idx_proxy)
- g_object_unref (priv->idx_proxy);
-
G_OBJECT_CLASS (tracker_rss_registrar_parent_class)->finalize (object);
}
-static void
-tracker_rss_registrar_set_connection (TrackerRssRegistrar *object,
- DBusGConnection *connection)
-{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
-
- priv->connection = connection; /* weak */
-
- priv->idx_proxy = dbus_g_proxy_new_for_name (priv->connection,
- "org.freedesktop.Tracker.Indexer",
- TRACKER_RSS_INDEXER_PATH,
- TRACKER_RSS_REGISTRAR_INTERFACE);
-}
-
static void
tracker_rss_registrar_set_property (GObject *object,
guint prop_id,
@@ -104,10 +98,6 @@ tracker_rss_registrar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (prop_id) {
- case PROP_CONNECTION:
- tracker_rss_registrar_set_connection (TRACKER_RSS_REGISTRAR (object),
- g_value_get_pointer (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -119,12 +109,7 @@ tracker_rss_registrar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
-
switch (prop_id) {
- case PROP_CONNECTION:
- g_value_set_pointer (value, priv->connection);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -139,14 +124,6 @@ tracker_rss_registrar_class_init (TrackerRssRegistrarClass *klass)
object_class->set_property = tracker_rss_registrar_set_property;
object_class->get_property = tracker_rss_registrar_get_property;
- g_object_class_install_property (object_class,
- PROP_CONNECTION,
- g_param_spec_pointer ("connection",
- "DBus connection",
- "DBus connection",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
g_type_class_add_private (object_class, sizeof (TrackerRssRegistrarPrivate));
}
@@ -155,6 +132,77 @@ tracker_rss_registrar_init (TrackerRssRegistrar *object)
{
}
+
+static void
+perform_set (TrackerRssRegistrar *object,
+ const gchar *subject,
+ const GStrv predicates,
+ const GStrv values)
+{
+ guint i = 0;
+
+ /* TODO */
+ return;
+
+ if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
+ tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
+ NIE_DATASOURCE);
+ }
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_RSS);
+
+ tracker_data_insert_statement (subject, RDF_TYPE,
+ METADATA_RSSDATA_OBJECT);
+
+ tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
+ DATASOURCE_URN);
+
+ while (predicates [i] != NULL && values[i] != NULL) {
+
+ if (g_strcmp0 (predicates[i], TRACKER_RSS_PREDICATE_THING) == 0) {
+ tracker_data_insert_statement (subject,
+ METADATA_RSS_SOMETHING,
+ values[i]);
+ }
+
+ i++;
+ }
+}
+
+static void
+perform_unset (TrackerRssRegistrar *object,
+ const gchar *subject)
+{
+ /* TODO */
+ return;
+
+ tracker_data_delete_resource (subject);
+}
+
+static void
+perform_cleanup (TrackerRssRegistrar *object)
+{
+ GError *error = NULL;
+
+ /* TODO */
+ return;
+
+ tracker_data_update_sparql ("DELETE { ?s ?p ?o } WHERE { ?s nie:dataSource <" DATASOURCE_URN "> }", &error);
+
+ if (error) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+set_stored_last_modseq (guint last_modseq)
+{
+ tracker_data_manager_set_db_option_int ("RssLastModseq", (gint) last_modseq);
+}
+
+
void
tracker_rss_registrar_set (TrackerRssRegistrar *object,
const gchar *subject,
@@ -164,8 +212,6 @@ tracker_rss_registrar_set (TrackerRssRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
if (predicates && values) {
@@ -173,16 +219,11 @@ tracker_rss_registrar_set (TrackerRssRegistrar *object,
dbus_async_return_if_fail (g_strv_length (predicates) ==
g_strv_length (values), context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Set",
- G_TYPE_STRING, subject,
- G_TYPE_STRV, predicates,
- G_TYPE_STRV, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_set (object, subject, predicates, values);
}
+ set_stored_last_modseq (modseq);
+
dbus_g_method_return (context);
}
@@ -195,8 +236,8 @@ tracker_rss_registrar_set_many (TrackerRssRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
guint len;
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
dbus_async_return_if_fail (predicates != NULL, context);
@@ -207,14 +248,16 @@ tracker_rss_registrar_set_many (TrackerRssRegistrar *object,
dbus_async_return_if_fail (len == predicates->len, context);
dbus_async_return_if_fail (len == values->len, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "SetMany",
- G_TYPE_STRV, subjects,
- TRACKER_TYPE_G_STRV_ARRAY, predicates,
- TRACKER_TYPE_G_STRV_ARRAY, values,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+ GStrv preds = g_ptr_array_index (predicates, i);
+ GStrv vals = g_ptr_array_index (values, i);
+
+ perform_set (object, subjects[i], preds, vals);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -226,16 +269,18 @@ tracker_rss_registrar_unset_many (TrackerRssRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
+ guint i = 0;
dbus_async_return_if_fail (subjects != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "UnsetMany",
- G_TYPE_STRV, subjects,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ while (subjects[i] != NULL) {
+
+ perform_unset (object, subjects[i]);
+
+ i++;
+ }
+
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -247,16 +292,9 @@ tracker_rss_registrar_unset (TrackerRssRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
-
dbus_async_return_if_fail (subject != NULL, context);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Unset",
- G_TYPE_STRING, subject,
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ perform_unset (object, subject);
dbus_g_method_return (context);
}
@@ -267,13 +305,9 @@ tracker_rss_registrar_cleanup (TrackerRssRegistrar *object,
DBusGMethodInvocation *context,
GError *derror)
{
- TrackerRssRegistrarPrivate *priv = TRACKER_RSS_REGISTRAR_GET_PRIVATE (object);
+ perform_cleanup (object);
- dbus_g_proxy_call_no_reply (priv->idx_proxy,
- "Cleanup",
- G_TYPE_UINT, modseq,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ set_stored_last_modseq (modseq);
dbus_g_method_return (context);
}
@@ -324,8 +358,7 @@ tracker_rss_push_registrar_enable (TrackerPushRegistrar *registrar,
return;
}
- object = g_object_new (TRACKER_TYPE_RSS_REGISTRAR,
- "connection", connection, NULL);
+ object = g_object_new (TRACKER_TYPE_RSS_REGISTRAR, NULL);
dbus_g_object_type_install_info (G_OBJECT_TYPE (object),
&dbus_glib_tracker_rss_registrar_object_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]