[tracker/architecture-sparql-up-in-daemon] Applied several ontology fixes to the KMail and Evolution push modules
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/architecture-sparql-up-in-daemon] Applied several ontology fixes to the KMail and Evolution push modules
- Date: Mon, 27 Apr 2009 08:24:55 -0400 (EDT)
commit a68247e28947d5d258a6fd3aae3b68099d473476
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Apr 27 14:24:09 2009 +0200
Applied several ontology fixes to the KMail and Evolution push modules
---
.../evolution/tracker-evolution-registrar.c | 130 +++++++++++++-------
src/plugins/kmail/tracker-kmail-registrar.c | 130 +++++++++++++-------
2 files changed, 173 insertions(+), 87 deletions(-)
diff --git a/src/plugins/evolution/tracker-evolution-registrar.c b/src/plugins/evolution/tracker-evolution-registrar.c
index 12925a4..5cf013c 100644
--- a/src/plugins/evolution/tracker-evolution-registrar.c
+++ b/src/plugins/evolution/tracker-evolution-registrar.c
@@ -31,6 +31,7 @@
#include <libtracker-data/tracker-data-update.h>
#include <libtracker-data/tracker-data-manager.h>
#include <libtracker-data/tracker-data-query.h>
+#include <libtracker-common/tracker-ontology.h>
#include <trackerd/tracker-push-registrar.h>
@@ -45,27 +46,13 @@
#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 RDF_PREFIX TRACKER_RDF_PREFIX
+#define NMO_PREFIX TRACKER_NMO_PREFIX
+#define NCO_PREFIX TRACKER_NCO_PREFIX
+#define NAO_PREFIX TRACKER_NAO_PREFIX
#define DATASOURCE_URN "urn:nepomuk:datasource:1cb1eb90-1241-11de-8c30-0800200c9a66"
@@ -255,6 +242,33 @@ get_object_encoding (GMimeObject *object)
}
#endif
+
+static void
+get_email_and_fullname (const gchar *line, gchar **email, gchar **fullname)
+{
+ gchar *ptr = g_utf8_strchr (line, -1, '<');
+
+ if (ptr) {
+ gchar *holder;
+
+ holder = g_strdup (line);
+ ptr = g_utf8_strchr (holder, -1, '<');
+ *ptr = '\0';
+ ptr++;
+ *fullname = holder;
+ holder = ptr;
+ ptr = g_utf8_strchr (ptr, -1, '>');
+ if (ptr) {
+ *ptr = '\0';
+ }
+ *email = g_strdup (holder);
+
+ } else {
+ *email = g_strdup (line);
+ *fullname = NULL;
+ }
+}
+
static void
perform_set (TrackerEvolutionRegistrar *object,
const gchar *subject,
@@ -264,15 +278,15 @@ perform_set (TrackerEvolutionRegistrar *object,
guint i = 0;
if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
- tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
+ tracker_data_insert_statement (DATASOURCE_URN, RDF_PREFIX "type",
NIE_DATASOURCE);
}
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_EMAIL);
+ tracker_data_insert_statement (subject, RDF_PREFIX "type",
+ NMO_PREFIX "Email");
- tracker_data_insert_statement (subject, RDF_TYPE,
- METADATA_MAILBOXDATA_OBJECT);
+ tracker_data_insert_statement (subject, RDF_PREFIX "type",
+ NMO_PREFIX "MailboxDataObject");
tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
DATASOURCE_URN);
@@ -381,8 +395,7 @@ perform_set (TrackerEvolutionRegistrar *object,
if (!values[i] || strlen (values[i]) < 1)
goto cont;
- key = g_strdup_printf ("X-Evolution-UserTag-%s", (values[i]));
-
+ key = g_strdup (values[i]);
value = strchr (key, '=');
if (value) {
@@ -390,52 +403,85 @@ perform_set (TrackerEvolutionRegistrar *object,
value++;
}
- tracker_data_insert_statement (":1", RDF_TYPE,
- METADATA_EMAIL_MESSAGE_HEADER);
+ tracker_data_insert_statement (":1", RDF_PREFIX "type",
+ NAO_PREFIX "Property");
tracker_data_insert_statement (":1",
- METADATA_EMAIL_MESSAGE_HEADER_NAME,
+ NAO_PREFIX "propertyName",
key);
tracker_data_insert_statement (":1",
- METADATA_EMAIL_MESSAGE_HEADER_VALUE,
+ NAO_PREFIX "propertyValue",
value);
tracker_data_insert_statement (subject,
- METADATA_EMAIL_MESSAGE_HEADER,
- ":1");
+ NAO_PREFIX "hasProperty",
+ ":1");
g_free (key);
}
if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SUBJECT) == 0) {
tracker_data_insert_statement (subject,
- METADATA_EMAIL_SUBJECT,
+ TRACKER_NMO_PREFIX "messageSubject",
values[i]);
}
if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_SENT) == 0) {
tracker_data_insert_statement (subject,
- METADATA_EMAIL_DATE,
+ TRACKER_NMO_PREFIX "receivedDate",
values[i]);
}
if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_FROM) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENDER,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "from", ":1");
+ g_free (email_uri);
+ g_free (email);
}
if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_TO) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENT_TO,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "to", ":1");
+ g_free (email_uri);
+ g_free (email);
}
if (g_strcmp0 (predicates[i], TRACKER_EVOLUTION_PREDICATE_CC) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_CC,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "cc", ":1");
+ g_free (email_uri);
+ g_free (email);
}
cont:
diff --git a/src/plugins/kmail/tracker-kmail-registrar.c b/src/plugins/kmail/tracker-kmail-registrar.c
index 664ae1c..abe1de7 100644
--- a/src/plugins/kmail/tracker-kmail-registrar.c
+++ b/src/plugins/kmail/tracker-kmail-registrar.c
@@ -44,34 +44,14 @@
#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 RDF_PREFIX TRACKER_RDF_PREFIX
+#define NMO_PREFIX TRACKER_NMO_PREFIX
+#define NCO_PREFIX TRACKER_NCO_PREFIX
+#define NAO_PREFIX TRACKER_NAO_PREFIX
#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;
@@ -147,6 +127,31 @@ tracker_kmail_registrar_init (TrackerKMailRegistrar *object)
}
+static void
+get_email_and_fullname (const gchar *line, gchar **email, gchar **fullname)
+{
+ gchar *ptr = g_utf8_strchr (line, -1, '<');
+
+ if (ptr) {
+ gchar *holder;
+
+ holder = g_strdup (line);
+ ptr = g_utf8_strchr (holder, -1, '<');
+ *ptr = '\0';
+ ptr++;
+ *fullname = holder;
+ holder = ptr;
+ ptr = g_utf8_strchr (ptr, -1, '>');
+ if (ptr) {
+ *ptr = '\0';
+ }
+ *email = g_strdup (holder);
+
+ } else {
+ *email = g_strdup (line);
+ *fullname = NULL;
+ }
+}
static void
@@ -158,15 +163,16 @@ perform_set (TrackerKMailRegistrar *object,
guint i = 0;
if (!tracker_data_query_resource_exists (DATASOURCE_URN, NULL, NULL)) {
- tracker_data_insert_statement (DATASOURCE_URN, RDF_TYPE,
+ tracker_data_insert_statement (DATASOURCE_URN, RDF_PREFIX "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, RDF_PREFIX "type",
+ NMO_PREFIX "Email");
+
+ tracker_data_insert_statement (subject, RDF_PREFIX "type",
+ NMO_PREFIX "MailboxDataObject");
tracker_data_insert_statement (subject, NIE_DATASOURCE_P,
DATASOURCE_URN);
@@ -186,48 +192,82 @@ perform_set (TrackerKMailRegistrar *object,
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TAG) == 0) {
- tracker_data_insert_statement (":1", RDF_TYPE,
- NAO_TAG);
+ tracker_data_insert_statement (":1", RDF_PREFIX "type",
+ NAO_PREFIX "Tag");
tracker_data_insert_statement (":1",
- NAO_PREFLABEL,
+ NAO_PREFIX "prefLabel",
values[i]);
tracker_data_insert_statement (subject,
- NAO_HASTAG,
+ NAO_PREFIX "hasTag",
":1");
}
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SUBJECT) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SUBJECT,
+ tracker_data_insert_statement (subject,
+ TRACKER_NMO_PREFIX "messageSubject",
values[i]);
}
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_SENT) == 0) {
tracker_data_insert_statement (subject,
- METADATA_EMAIL_DATE,
+ TRACKER_NMO_PREFIX "receivedDate",
values[i]);
}
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_FROM) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENDER,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "from", ":1");
+ g_free (email_uri);
+ g_free (email);
}
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_TO) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_SENT_TO,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "to", ":1");
+ g_free (email_uri);
+ g_free (email);
}
if (g_strcmp0 (predicates[i], TRACKER_KMAIL_PREDICATE_CC) == 0) {
- tracker_data_insert_statement (subject,
- METADATA_EMAIL_CC,
- values[i]);
+ gchar *email_uri, *email = NULL, *fullname = NULL;
+ tracker_data_insert_statement (":1", RDF_PREFIX "type", NCO_PREFIX "Contact");
+ get_email_and_fullname (values[i], &email, &fullname);
+ if (fullname) {
+ tracker_data_insert_statement (":1", NCO_PREFIX "fullname", fullname);
+ g_free (fullname);
+ }
+ email_uri = tracker_uri_printf_escaped ("mailto:%s", email);
+ tracker_data_insert_statement (email_uri, RDF_PREFIX "type", NCO_PREFIX "EmailAddress");
+ tracker_data_insert_statement (email_uri, NCO_PREFIX "emailAddress", email);
+ tracker_data_insert_statement (":1", NCO_PREFIX "hasEmailAddress", email_uri);
+ tracker_data_insert_statement (subject, NMO_PREFIX "cc", ":1");
+ g_free (email_uri);
+ g_free (email);
}
+
i++;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]