tracker r1287 - in branches/xesam-support: . data src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1287 - in branches/xesam-support: . data src/trackerd
- Date: Tue, 22 Apr 2008 16:16:59 +0100 (BST)
Author: pvanhoof
Date: Tue Apr 22 15:16:59 2008
New Revision: 1287
URL: http://svn.gnome.org/viewvc/tracker?rev=1287&view=rev
Log:
2008-04-22 Philip Van Hoof <pvanhoof gnome org>
* Branched as xesam-support
* Added Xesam skeleton
* Introduced TrackerXesamSearch
* Introduced TrackerXesamLiveSearch
* Introduced TrackerXesamSession
Added:
branches/xesam-support/
- copied from r1286, /branches/indexer-split/
branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
branches/xesam-support/src/trackerd/tracker-xesam-search.c
branches/xesam-support/src/trackerd/tracker-xesam-search.h
branches/xesam-support/src/trackerd/tracker-xesam-session.c
branches/xesam-support/src/trackerd/tracker-xesam-session.h
branches/xesam-support/src/trackerd/tracker-xesam.c
branches/xesam-support/src/trackerd/tracker-xesam.h
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/data/Makefile.am
branches/xesam-support/src/trackerd/Makefile.am
branches/xesam-support/src/trackerd/tracker-dbus.c
branches/xesam-support/src/trackerd/tracker-marshal.list
branches/xesam-support/src/trackerd/tracker-utils.c
branches/xesam-support/src/trackerd/tracker-utils.h
branches/xesam-support/src/trackerd/trackerd.c
Modified: branches/xesam-support/data/Makefile.am
==============================================================================
--- /branches/indexer-split/data/Makefile.am (original)
+++ branches/xesam-support/data/Makefile.am Tue Apr 22 15:16:59 2008
@@ -8,6 +8,7 @@
tracker-dbus-keywords.xml \
tracker-dbus-metadata.xml \
tracker-dbus-search.xml \
+ tracker-xesam-search.xml \
sqlite-tracker.sql \
sqlite-cache.sql \
sqlite-email.sql \
Modified: branches/xesam-support/src/trackerd/Makefile.am
==============================================================================
--- /branches/indexer-split/src/trackerd/Makefile.am (original)
+++ branches/xesam-support/src/trackerd/Makefile.am Tue Apr 22 15:16:59 2008
@@ -111,6 +111,8 @@
tracker-dbus-metadata.h \
tracker-dbus-search.c \
tracker-dbus-search.h \
+ tracker-xesam-search.c \
+ tracker-xesam-search.h \
tracker-email.c \
tracker-email.h \
tracker-email-utils.c \
@@ -135,7 +137,13 @@
tracker-os-dependant.h \
tracker-watch.h \
tracker-status.c \
- tracker-status.h
+ tracker-status.h \
+ tracker-xesam.h \
+ tracker-xesam.c \
+ tracker-xesam-session.c \
+ tracker-xesam-session.h \
+ tracker-xesam-live-search.c \
+ tracker-xesam-live-search.h
if OS_WIN32
trackerd_win_libs = -lws2_32 -lkernel32
@@ -181,7 +189,8 @@
tracker-dbus-files-glue.h \
tracker-dbus-keywords-glue.h \
tracker-dbus-metadata-glue.h \
- tracker-dbus-search-glue.h
+ tracker-dbus-search-glue.h \
+ tracker-xesam-search-glue.h
%-glue.h: $(top_builddir)/data/%.xml
$(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^
Modified: branches/xesam-support/src/trackerd/tracker-dbus.c
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/xesam-support/src/trackerd/tracker-dbus.c Tue Apr 22 15:16:59 2008
@@ -38,6 +38,9 @@
#include "tracker-dbus-metadata-glue.h"
#include "tracker-dbus-search.h"
#include "tracker-dbus-search-glue.h"
+#include "tracker-xesam-search.h"
+#include "tracker-xesam-search-glue.h"
+
#include "tracker-utils.h"
#include "tracker-watch.h"
@@ -218,6 +221,22 @@
g_object_set (object, "email-index", tracker->email_index, NULL);
objects = g_slist_prepend (objects, object);
+
+ /* Add org.freedesktop.xesam.Search */
+ if (!(object = dbus_register_object (connection,
+ proxy,
+ TRACKER_TYPE_XESAM_SEARCH,
+ &dbus_glib_tracker_xesam_search_object_info,
+ TRACKER_XESAM_SEARCH_PATH))) {
+ return FALSE;
+ }
+
+ g_object_set (object, "db-connection", tracker->index_db, NULL);
+ g_object_set (object, "file-index", tracker->file_index, NULL);
+ g_object_set (object, "email-index", tracker->email_index, NULL);
+ objects = g_slist_prepend (objects, object);
+
+
/* Reverse list since we added objects at the top each time */
objects = g_slist_reverse (objects);
Modified: branches/xesam-support/src/trackerd/tracker-marshal.list
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-marshal.list (original)
+++ branches/xesam-support/src/trackerd/tracker-marshal.list Tue Apr 22 15:16:59 2008
@@ -1,3 +1,5 @@
VOID:STRING,STRING,INT,INT,INT
VOID:STRING,STRING,STRING
VOID:STRING,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN
+VOID:STRING,INT
+VOID:STRING,POINTER
Modified: branches/xesam-support/src/trackerd/tracker-utils.c
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-utils.c (original)
+++ branches/xesam-support/src/trackerd/tracker-utils.c Tue Apr 22 15:16:59 2008
@@ -2569,3 +2569,63 @@
{
return tracker->pause_manual || tracker_pause_on_battery () || tracker_low_diskspace () || tracker_index_too_big ();
}
+
+
+gchar*
+tracker_unique_key (void)
+{
+ /* This function is hardly cryptographically random but should be
+ "good enough" */
+ static guint serial = 0;
+ gchar* key;
+ guint t, ut, p, u, r;
+ GTimeVal tv;
+
+ g_get_current_time(&tv);
+
+ t = tv.tv_sec;
+ ut = tv.tv_usec;
+
+ p = getpid();
+
+ #ifdef HAVE_GETUID
+ u = getuid();
+ #else
+ u = 0;
+ #endif
+
+ /* don't bother to seed; if it's based on the time or any other
+ changing info we can get, we may as well just use that changing
+ info. since we don't seed we'll at least get a different number
+ on every call to this function in the same executable. */
+ r = rand();
+
+ /* The letters may increase uniqueness by preventing "melds"
+ i.e. 01t01k01 and 0101t0k1 are not the same */
+ key = g_strdup_printf("%ut%uut%uu%up%ur%uk%u",
+ /* Duplicate keys must be generated
+ by two different program instances */
+ serial,
+ /* Duplicate keys must be generated
+ in the same microsecond */
+ t,
+ ut,
+ /* Duplicate keys must be generated by
+ the same user */
+ u,
+ /* Duplicate keys must be generated by
+ two programs that got the same PID */
+ p,
+ /* Duplicate keys must be generated with the
+ same random seed and the same index into
+ the series of pseudorandom values */
+ r,
+ /* Duplicate keys must result from running
+ this function at the same stack location */
+ GPOINTER_TO_UINT(&key));
+
+ ++serial;
+
+ return key;
+}
+
Modified: branches/xesam-support/src/trackerd/tracker-utils.h
==============================================================================
--- /branches/indexer-split/src/trackerd/tracker-utils.h (original)
+++ branches/xesam-support/src/trackerd/tracker-utils.h Tue Apr 22 15:16:59 2008
@@ -299,6 +299,8 @@
GMutex *metadata_signal_mutex;
GCond *metadata_signal_cond;
+ GHashTable *xesam_sessions;
+
} Tracker;
@@ -509,5 +511,7 @@
gboolean tracker_pause_on_battery (void);
gboolean tracker_low_diskspace (void);
gboolean tracker_pause (void);
+gchar* tracker_unique_key (void);
+
#endif
Added: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c Tue Apr 22 15:16:59 2008
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#include "tracker-xesam-live-search.h"
+
+
+struct _TrackerXesamLiveSearchPriv {
+ gchar *search_id;
+};
+
+G_DEFINE_TYPE(TrackerXesamLiveSearch, tracker_xesam_live_search, G_TYPE_OBJECT)
+
+static void
+tracker_xesam_live_search_finalize (GObject *object)
+{
+ TrackerXesamLiveSearch *self = (TrackerXesamLiveSearch *) object;
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ g_free (priv->search_id);
+}
+
+static void
+tracker_xesam_live_search_class_init (TrackerXesamLiveSearchClass * klass)
+{
+ GObjectClass *object_class;
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = tracker_xesam_live_search_finalize;
+}
+
+
+static void
+tracker_xesam_live_search_init (TrackerXesamLiveSearch * self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ priv->search_id = NULL;
+}
+
+
+
+const gchar*
+tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self)
+{
+ // todo
+ return "WHERE 1=1";
+}
+
+void
+tracker_xesam_live_search_set_id (TrackerXesamLiveSearch *self, const gchar *search_id)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ if (priv->search_id)
+ g_free (priv->search_id);
+ priv->search_id = g_strdup (search_id);
+}
+
+const gchar*
+tracker_xesam_live_search_get_id (TrackerXesamLiveSearch *self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ return (const gchar*) priv->search_id;
+}
+
+TrackerXesamLiveSearch*
+tracker_xesam_live_search_new (const gchar *query_xml)
+{
+ TrackerXesamLiveSearch * self;
+ self = g_object_newv (TRACKER_TYPE_SEARCH, 0, NULL);
+ return self;
+}
+
+
+
+
Added: branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.h Tue Apr 22 15:16:59 2008
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef _TRACKER_XESAM_LIVE_SEARCH_H_
+#define _TRACKER_XESAM_LIVE_SEARCH_H_
+
+/*
+ * 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.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+
+#define TRACKER_TYPE_SEARCH (tracker_xesam_live_search_get_type ())
+#define TRACKER_XESAM_LIVE_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_SEARCH, TrackerXesamLiveSearch))
+#define TRACKER_XESAM_LIVE_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_SEARCH, TrackerXesamLiveSearchClass))
+#define TRACKER_IS_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_SEARCH))
+#define TRACKER_IS_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_SEARCH))
+#define TRACKER_XESAM_LIVE_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_SEARCH, TrackerXesamLiveSearchClass))
+
+typedef struct _TrackerXesamLiveSearch TrackerXesamLiveSearch;
+typedef struct _TrackerXesamLiveSearchClass TrackerXesamLiveSearchClass;
+typedef struct _TrackerXesamLiveSearchPriv TrackerXesamLiveSearchPriv;
+
+struct _TrackerXesamLiveSearch {
+ GObject parent_instance;
+ TrackerXesamLiveSearchPriv * priv;
+};
+struct _TrackerXesamLiveSearchClass {
+ GObjectClass parent_class;
+};
+
+TrackerXesamLiveSearch* tracker_xesam_live_search_new (const gchar *query_xml);
+GType tracker_xesam_live_search_get_type (void);
+
+void tracker_xesam_live_search_set_id (TrackerXesamLiveSearch *self, const gchar *search_id);
+const gchar* tracker_xesam_live_search_get_id (TrackerXesamLiveSearch *self);
+const gchar* tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self);
+
+
+G_END_DECLS
+
+#endif
Added: branches/xesam-support/src/trackerd/tracker-xesam-search.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-search.c Tue Apr 22 15:16:59 2008
@@ -0,0 +1,457 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#include <string.h>
+
+#include <libtracker-common/tracker-log.h>
+
+#include <libtracker-common/tracker-log.h>
+#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-utils.h>
+
+#include "tracker-dbus.h"
+
+#define TRACKER_XESAM_SEARCH_C
+#include "tracker-xesam-search.h"
+#include "tracker-xesam.h"
+#undef TRACER_XESAM_SEARCH_C
+
+#include "tracker-rdf-query.h"
+#include "tracker-query-tree.h"
+#include "tracker-indexer.h"
+#include "tracker-service-manager.h"
+#include "tracker-marshal.h"
+
+guint xesam_signals[XESAM_LAST_SIGNAL] = {0};
+extern Tracker *tracker;
+
+#define DEFAULT_SEARCH_MAX_HITS 1024
+
+#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_XESAM_SEARCH, TrackerXesamSearchPriv))
+
+typedef struct {
+ DBusGProxy *fd_proxy;
+ DBConnection *db_con;
+ Indexer *file_index;
+ Indexer *email_index;
+} TrackerXesamSearchPriv;
+
+enum {
+ PROP_0,
+ PROP_DB_CONNECTION,
+ PROP_FILE_INDEX,
+ PROP_EMAIL_INDEX
+};
+
+
+static void dbus_search_finalize (GObject *object);
+static void dbus_search_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+G_DEFINE_TYPE(TrackerXesamSearch, tracker_xesam_search, G_TYPE_OBJECT)
+
+static void
+tracker_xesam_search_class_init (TrackerXesamSearchClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = dbus_search_finalize;
+ object_class->set_property = dbus_search_set_property;
+
+ g_object_class_install_property (object_class,
+ PROP_DB_CONNECTION,
+ g_param_spec_pointer ("db-connection",
+ "DB connection",
+ "Database connection to use in transactions",
+ G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
+ PROP_FILE_INDEX,
+ g_param_spec_pointer ("file-index",
+ "File index",
+ "File index",
+ G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
+ PROP_EMAIL_INDEX,
+ g_param_spec_pointer ("email-index",
+ "Email index",
+ "Email index",
+ G_PARAM_WRITABLE));
+
+ xesam_signals[XESAM_HITS_ADDED] =
+ g_signal_new ("hits-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_INT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_INT);
+
+ xesam_signals[XESAM_HITS_REMOVED] =
+ g_signal_new ("hits-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_POINTER,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+
+ xesam_signals[XESAM_HITS_MODIFIED] =
+ g_signal_new ("hits-modified",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_POINTER,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+
+ xesam_signals[XESAM_SEARCH_DONE] =
+ g_signal_new ("search-done",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
+
+
+ xesam_signals[XESAM_STATE_CHANGED] =
+ g_signal_new ("state-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
+ g_type_class_add_private (object_class, sizeof (TrackerXesamSearchPriv));
+}
+
+static void
+tracker_xesam_search_init (TrackerXesamSearch *object)
+{
+}
+
+static void
+dbus_search_finalize (GObject *object)
+{
+ TrackerXesamSearchPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ if (priv->fd_proxy) {
+ g_object_unref (priv->fd_proxy);
+ }
+
+ G_OBJECT_CLASS (tracker_xesam_search_parent_class)->finalize (object);
+}
+
+static void
+dbus_search_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerXesamSearchPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_DB_CONNECTION:
+ tracker_xesam_search_set_db_connection (TRACKER_XESAM_SEARCH (object),
+ g_value_get_pointer (value));
+ break;
+ case PROP_FILE_INDEX:
+ tracker_xesam_search_set_file_index (TRACKER_XESAM_SEARCH (object),
+ g_value_get_pointer (value));
+ break;
+ case PROP_EMAIL_INDEX:
+ tracker_xesam_search_set_email_index (TRACKER_XESAM_SEARCH (object),
+ g_value_get_pointer (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+TrackerXesamSearch *
+tracker_xesam_search_new (DBConnection *db_con)
+{
+ TrackerXesamSearch *object;
+
+ object = g_object_new (TRACKER_TYPE_XESAM_SEARCH,
+ "db-connection", db_con,
+ NULL);
+
+ return object;
+}
+
+void
+tracker_xesam_search_set_db_connection (TrackerXesamSearch *object,
+ DBConnection *db_con)
+{
+ TrackerXesamSearchPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_XESAM_SEARCH (object));
+ g_return_if_fail (db_con != NULL);
+
+ priv = GET_PRIV (object);
+
+ priv->db_con = db_con;
+
+ g_object_notify (G_OBJECT (object), "db-connection");
+}
+
+void
+tracker_xesam_search_set_file_index (TrackerXesamSearch *object,
+ Indexer *file_index)
+{
+ TrackerXesamSearchPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_XESAM_SEARCH (object));
+ g_return_if_fail (file_index != NULL);
+
+ priv = GET_PRIV (object);
+
+ priv->file_index = file_index;
+
+ g_object_notify (G_OBJECT (object), "file-index");
+}
+
+void
+tracker_xesam_search_set_email_index (TrackerXesamSearch *object,
+ Indexer *email_index)
+{
+ TrackerXesamSearchPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_XESAM_SEARCH (object));
+ g_return_if_fail (email_index != NULL);
+
+ priv = GET_PRIV (object);
+
+ priv->email_index = email_index;
+
+ g_object_notify (G_OBJECT (object), "email-index");
+}
+
+/*
+ * Functions
+ */
+
+gboolean
+tracker_xesam_search_new_session (TrackerXesamSearch *object,
+ const gchar **session_id,
+ GError **error)
+{
+ gchar *sid = NULL;
+
+ tracker_xesam_create_session (object, &sid);
+
+ if (sid) {
+ guint request_id = tracker_dbus_get_next_request_id ();
+ *session_id = g_strdup (sid);
+ g_free (sid);
+ tracker_dbus_request_success (request_id);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+gboolean
+tracker_xesam_search_close_session (TrackerXesamSearch *object,
+ const gchar *session_id,
+ GError **error)
+{
+ guint request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_xesam_close_session (session_id);
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
+}
+
+
+gboolean
+tracker_xesam_search_set_property (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *prop,
+ gpointer val, /* not sure */
+ gpointer *new_val, /* not sure */
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_get_property (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *prop,
+ gpointer *value, /* not sure */
+ GError **error)
+{
+ return FALSE;
+}
+
+
+gboolean
+tracker_xesam_search_new_search (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *query_xml,
+ gchar **search_id,
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_start_search (TrackerXesamSearch *object,
+ const gchar *search_id,
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_get_hit_count (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint *count,
+ GError **error)
+{
+ TrackerXesamSearchPriv *priv;
+ TrackerQueryTree *tree;
+ GArray *hit_counts;
+ GArray *mail_hit_counts;
+ guint request_id;
+ DBConnection *db_con;
+ guint i, counter = 0;
+ const gchar *search_text;
+ TrackerXesamLiveSearch *search_i;
+
+ tracker_dbus_return_val_if_fail (search_id != NULL, FALSE, error);
+ tracker_dbus_return_val_if_fail (count != NULL, FALSE, error);
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ search_i = tracker_xesam_get_live_search (search_id);
+ search_text = tracker_xesam_live_search_get_query (search_i);
+
+ priv = GET_PRIV (object);
+
+ db_con = priv->db_con;
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to get search hit count for all, "
+ "search text:'%s'",
+ tracker_xesam_live_search_get_query (search_i));
+
+ if (tracker_is_empty_string (search_text)) {
+ tracker_dbus_request_failed (request_id,
+ error,
+ "No search term was specified");
+ g_object_unref (search_i);
+ return FALSE;
+ }
+
+ tree = tracker_query_tree_new (search_text, db_con->word_index, NULL);
+
+ hit_counts = tracker_query_tree_get_hit_counts (tree);
+ tracker_query_tree_set_indexer (tree, priv->email_index);
+ mail_hit_counts = tracker_query_tree_get_hit_counts (tree);
+ g_array_append_vals (hit_counts, mail_hit_counts->data, mail_hit_counts->len);
+ g_array_free (mail_hit_counts, TRUE);
+
+ counter = 0;
+
+ for (i = 0; i < hit_counts->len; i++) {
+ TrackerHitCount mcount;
+ mcount = g_array_index (hit_counts, TrackerHitCount, i);
+ counter += mcount.count;
+ }
+
+ *count = counter;
+
+
+ g_array_free (hit_counts, TRUE);
+ g_object_unref (tree);
+
+ g_object_unref (search_i);
+
+ tracker_dbus_request_success (request_id);
+
+ return TRUE;
+}
+
+gboolean
+tracker_xesam_search_get_hits (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint num,
+ gpointer **hits, /* not sure */
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_get_hit_data (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint *hit_ids, /* not sure */
+ const gchar **fields,
+ gpointer **hit_data, /* not sure */
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_close_search (TrackerXesamSearch *object,
+ const gchar *search_id,
+ GError **error)
+{
+ return FALSE;
+}
+
+gboolean
+tracker_xesam_search_get_state (TrackerXesamSearch *object,
+ gchar **state_info,
+ GError **error)
+{
+ return FALSE;
+}
+
Added: branches/xesam-support/src/trackerd/tracker-xesam-search.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-search.h Tue Apr 22 15:16:59 2008
@@ -0,0 +1,130 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#ifndef __TRACKER_XESAM_SEARCH_H__
+#define __TRACKER_XESAM_SEARCH_H__
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "tracker-db-sqlite.h"
+#include "tracker-indexer.h"
+
+#define TRACKER_XESAM_SEARCH_SERVICE "org.freedesktop.xesam"
+#define TRACKER_XESAM_SEARCH_PATH "/org/freedesktop/xesam/Search"
+#define TRACKER_XESAM_SEARCH_INTERFACE "org.freedesktop.xesam.Search"
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_XESAM_SEARCH (tracker_xesam_search_get_type ())
+#define TRACKER_XESAM_SEARCH(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TRACKER_TYPE_XESAM_SEARCH, TrackerXesamSearch))
+#define TRACKER_XESAM_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_XESAM_SEARCH, TrackerXesamSearchClass))
+#define TRACKER_IS_XESAM_SEARCH(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TRACKER_TYPE_XESAM_SEARCH))
+#define TRACKER_IS_XESAM_SEARCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_XESAM_SEARCH))
+#define TRACKER_XESAM_SEARCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_XESAM_SEARCH, TrackerXesamSearchClass))
+
+typedef struct TrackerXesamSearch TrackerXesamSearch;
+typedef struct TrackerXesamSearchClass TrackerXesamSearchClass;
+
+struct TrackerXesamSearch {
+ GObject parent;
+};
+
+struct TrackerXesamSearchClass {
+ GObjectClass parent;
+};
+
+enum {
+ XESAM_HITS_ADDED,
+ XESAM_HITS_REMOVED,
+ XESAM_HITS_MODIFIED,
+ XESAM_SEARCH_DONE,
+ XESAM_STATE_CHANGED,
+ XESAM_LAST_SIGNAL
+};
+
+#ifndef TRACKER_XESAM_SEARCH_C
+extern guint *xesam_signals;
+#endif
+
+GType tracker_xesam_search_get_type (void);
+
+TrackerXesamSearch *
+ tracker_xesam_search_new (DBConnection *db_con);
+void tracker_xesam_search_set_db_connection (TrackerXesamSearch *object,
+ DBConnection *db_con);
+void tracker_xesam_search_set_file_index (TrackerXesamSearch *object,
+ Indexer *file_index);
+void tracker_xesam_search_set_email_index (TrackerXesamSearch *object,
+ Indexer *email_index);
+
+
+gboolean tracker_xesam_search_new_session (TrackerXesamSearch *object,
+ const gchar **session,
+ GError **error);
+gboolean tracker_xesam_search_set_property (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *prop,
+ gpointer val, /* not sure */
+ gpointer *new_val, /* not sure */
+ GError **error);
+gboolean tracker_xesam_search_get_property (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *prop,
+ gpointer *value, /* not sure */
+ GError **error);
+gboolean tracker_xesam_search_close_session (TrackerXesamSearch *object,
+ const gchar *session_id,
+ GError **error);
+gboolean tracker_xesam_search_new_search (TrackerXesamSearch *object,
+ const gchar *session_id,
+ const gchar *query_xml,
+ gchar **search_id,
+ GError **error);
+gboolean tracker_xesam_search_start_search (TrackerXesamSearch *object,
+ const gchar *search_id,
+ GError **error);
+gboolean tracker_xesam_search_get_hit_count (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint *count,
+ GError **error);
+gboolean tracker_xesam_search_get_hits (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint num,
+ gpointer **hits, /* not sure */
+ GError **error);
+gboolean tracker_xesam_search_get_hit_data (TrackerXesamSearch *object,
+ const gchar *search_id,
+ guint *hit_ids, /* not sure */
+ const gchar **fields,
+ gpointer **hit_data, /* not sure */
+ GError **error);
+gboolean tracker_xesam_search_close_search (TrackerXesamSearch *object,
+ const gchar *search_id,
+ GError **error);
+gboolean tracker_xesam_search_get_state (TrackerXesamSearch *object,
+ gchar **state_info,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __TRACKER_XESAM_SEARCH_H__ */
Added: branches/xesam-support/src/trackerd/tracker-xesam-session.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-session.c Tue Apr 22 15:16:59 2008
@@ -0,0 +1,220 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#include "tracker-xesam.h"
+
+struct _TrackerXesamSessionPriv {
+ GHashTable *searches;
+ TrackerXesamSearch *dbus_proxy;
+ gchar *session_id;
+};
+
+
+G_DEFINE_TYPE(TrackerXesamSession, tracker_xesam_session, G_TYPE_OBJECT)
+
+static void
+tracker_xesam_session_init (TrackerXesamSession *self)
+{
+ TrackerXesamSessionPriv *priv = self->priv;
+
+ priv->dbus_proxy = NULL;
+ priv->session_id = NULL;
+
+ priv->searches = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+}
+
+
+static void
+tracker_xesam_session_finalize (GObject *object)
+{
+ TrackerXesamSession *self = (TrackerXesamSession *) object;
+ TrackerXesamSessionPriv *priv = self->priv;
+ g_free (priv->session_id);
+ g_hash_table_destroy (priv->searches);
+}
+
+static void
+tracker_xesam_session_class_init (TrackerXesamSessionClass * klass)
+{
+ GObjectClass *object_class;
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = tracker_xesam_session_finalize;
+}
+
+void
+tracker_xesam_session_set_id (TrackerXesamSession *self, const gchar *session_id)
+{
+ TrackerXesamSessionPriv *priv = self->priv;
+ if (priv->session_id)
+ g_free (priv->session_id);
+ priv->session_id = g_strdup (session_id);
+}
+
+const gchar*
+tracker_xesam_session_get_id (TrackerXesamSession *self)
+{
+ TrackerXesamSessionPriv *priv = self->priv;
+ return (const gchar*) priv->session_id;
+}
+
+GList *
+tracker_xesam_session_get_searches (TrackerXesamSession *self)
+{
+ TrackerXesamSessionPriv *priv = self->priv;
+ return g_hash_table_get_values (priv->searches);
+}
+
+void
+tracker_xesam_session_hits_added (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint count)
+{
+ TrackerXesamSessionPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+ g_return_if_fail (search == NULL || TRACKER_IS_SEARCH (search));
+
+ priv = self->priv;
+
+ g_signal_emit (priv->dbus_proxy, xesam_signals[XESAM_HITS_ADDED], 0,
+ tracker_xesam_live_search_get_id (search), count);
+}
+
+
+void
+tracker_xesam_session_hits_removed (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint *hit_ids, gint hit_ids_length)
+{
+ TrackerXesamSessionPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+ g_return_if_fail (search == NULL || TRACKER_IS_SEARCH (search));
+
+ priv = self->priv;
+
+ g_signal_emit (priv->dbus_proxy, xesam_signals[XESAM_HITS_REMOVED], 0,
+ tracker_xesam_live_search_get_id (search), 0); // todo
+}
+
+
+void
+tracker_xesam_session_hits_modified (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint *hit_ids, gint hit_ids_length)
+{
+ TrackerXesamSessionPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+ g_return_if_fail (search == NULL || TRACKER_IS_SEARCH (search));
+
+ priv = self->priv;
+
+ g_signal_emit (priv->dbus_proxy, xesam_signals[XESAM_HITS_MODIFIED], 0,
+ tracker_xesam_live_search_get_id (search), 0); // todo
+}
+
+
+void
+tracker_xesam_session_search_done (TrackerXesamSession *self, TrackerXesamLiveSearch *search)
+{
+ TrackerXesamSessionPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+ g_return_if_fail (search == NULL || TRACKER_IS_SEARCH (search));
+
+ priv = self->priv;
+
+ g_signal_emit (priv->dbus_proxy, xesam_signals[XESAM_SEARCH_DONE], 0,
+ tracker_xesam_live_search_get_id (search));
+}
+
+
+void
+tracker_xesam_session_state_changed (TrackerXesamSession *self, gchar **state_info, gint state_info_length)
+{
+ TrackerXesamSessionPriv *priv;
+
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+
+ priv = self->priv;
+
+ g_signal_emit (priv->dbus_proxy, xesam_signals[XESAM_STATE_CHANGED], 0,
+ 0); // todo
+}
+
+
+void
+tracker_xesam_session_set_property (TrackerXesamSession *self, const gchar *prop, const gchar *val)
+{
+ g_return_if_fail (TRACKER_IS_SESSION (self));
+}
+
+
+gchar*
+tracker_xesam_session_get_property (TrackerXesamSession *self, const gchar *prop)
+{
+ g_return_val_if_fail (TRACKER_IS_SESSION (self), NULL);
+ return g_strdup ("");
+}
+
+
+TrackerXesamLiveSearch*
+tracker_xesam_session_create_search (TrackerXesamSession *self, const gchar *query_xml)
+{
+ TrackerXesamLiveSearch *search;
+ TrackerXesamSessionPriv *priv = self->priv;
+
+ g_return_val_if_fail (TRACKER_IS_SESSION (self), NULL);
+
+ search = tracker_xesam_live_search_new (query_xml);
+ tracker_xesam_live_search_set_id (search, tracker_unique_key ());
+
+ g_hash_table_insert (priv->searches,
+ g_strdup (tracker_xesam_live_search_get_id (search)),
+ g_object_ref (search));
+
+ return search;
+}
+
+TrackerXesamLiveSearch*
+tracker_xesam_session_get_search (TrackerXesamSession *self, const gchar *search_id)
+{
+ TrackerXesamSessionPriv *priv = self->priv;
+ TrackerXesamLiveSearch *search = g_hash_table_lookup (priv->searches, search_id);
+ if (search)
+ g_object_ref (search);
+ return search;
+}
+
+TrackerXesamSession*
+tracker_xesam_session_new (TrackerXesamSearch *dbus_proxy)
+{
+ TrackerXesamSession * self;
+ TrackerXesamSessionPriv *priv;
+ self = g_object_newv (TRACKER_TYPE_SESSION, 0, NULL);
+
+ priv = self->priv;
+ priv->dbus_proxy = dbus_proxy;
+
+ return self;
+}
+
+
+
+
Added: branches/xesam-support/src/trackerd/tracker-xesam-session.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam-session.h Tue Apr 22 15:16:59 2008
@@ -0,0 +1,75 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+#ifndef _TRACKER_XESAM_SESSION_H_
+#define _TRACKER_XESAM_SESSION_H_
+
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tracker-xesam-live-search.h"
+#include "tracker-xesam-search.h"
+
+G_BEGIN_DECLS
+
+
+#define TRACKER_TYPE_SESSION (tracker_xesam_session_get_type ())
+#define TRACKER_XESAM_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_SESSION, TrackerXesamSession))
+#define TRACKER_XESAM_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_SESSION, TrackerXesamSessionClass))
+#define TRACKER_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_SESSION))
+#define TRACKER_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_SESSION))
+#define TRACKER_XESAM_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_SESSION, TrackerXesamSessionClass))
+
+typedef struct _TrackerXesamSession TrackerXesamSession;
+typedef struct _TrackerXesamSessionClass TrackerXesamSessionClass;
+typedef struct _TrackerXesamSessionPriv TrackerXesamSessionPriv;
+
+struct _TrackerXesamSession {
+ GObject parent_instance;
+ TrackerXesamSessionPriv *priv;
+};
+
+struct _TrackerXesamSessionClass {
+ GObjectClass parent_class;
+};
+
+void tracker_xesam_session_hits_added (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint count);
+void tracker_xesam_session_hits_removed (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint *hit_ids, gint hit_ids_length);
+void tracker_xesam_session_hits_modified (TrackerXesamSession *self, TrackerXesamLiveSearch *search, guint *hit_ids, gint hit_ids_length);
+void tracker_xesam_session_search_done (TrackerXesamSession *self, TrackerXesamLiveSearch *search);
+void tracker_xesam_session_state_changed (TrackerXesamSession *self, gchar **state_info, gint state_info_length);
+void tracker_xesam_session_set_property (TrackerXesamSession *self, const gchar *prop, const gchar* val);
+char* tracker_xesam_session_get_property (TrackerXesamSession *self, const gchar *prop);
+TrackerXesamLiveSearch* tracker_xesam_session_create_search (TrackerXesamSession *self, const gchar *query_xml);
+TrackerXesamLiveSearch* tracker_xesam_session_get_search (TrackerXesamSession *self, const gchar *search_id);
+GList *tracker_xesam_session_get_searches (TrackerXesamSession *self);
+void tracker_xesam_session_set_id (TrackerXesamSession *self, const gchar *session_id);
+const gchar* tracker_xesam_session_get_id (TrackerXesamSession *self);
+
+TrackerXesamSession* tracker_xesam_session_new (TrackerXesamSearch *dbus_proxy);
+GType tracker_xesam_session_get_type (void);
+
+
+G_END_DECLS
+
+#endif
Added: branches/xesam-support/src/trackerd/tracker-xesam.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam.c Tue Apr 22 15:16:59 2008
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+#include "tracker-xesam.h"
+
+extern Tracker *tracker;
+
+void
+tracker_xesam_init (void)
+{
+ tracker->xesam_sessions = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify ) g_object_unref);
+}
+
+TrackerXesamSession *
+tracker_xesam_create_session (TrackerXesamSearch *dbus_proxy, gchar **session_id)
+{
+ TrackerXesamSession *session;
+
+ session = tracker_xesam_session_new (dbus_proxy);
+ tracker_xesam_session_set_id (session, tracker_unique_key ());
+
+ g_hash_table_insert (tracker->xesam_sessions,
+ g_strdup (tracker_xesam_session_get_id (session)),
+ g_object_ref (session));
+
+ if (session_id)
+ *session_id = g_strdup (tracker_xesam_session_get_id (session));
+
+ return session;
+}
+
+void
+tracker_xesam_close_session (const gchar *session_id)
+{
+ g_hash_table_remove (tracker->xesam_sessions, session_id);
+}
+
+
+TrackerXesamSession *
+tracker_xesam_get_session (const gchar *session_id)
+{
+ TrackerXesamSession *retval = g_hash_table_lookup (tracker->xesam_sessions, session_id);
+ if (retval)
+ g_object_ref (retval);
+ return retval;
+}
+
+TrackerXesamSession *
+tracker_xesam_get_session_for_search (const gchar *search_id)
+{
+ TrackerXesamSession *retval = NULL;
+ GList * sessions = g_hash_table_get_values (tracker->xesam_sessions);
+
+ while (sessions) {
+ TrackerXesamLiveSearch *search = tracker_xesam_session_get_search (sessions->data, search_id);
+ if (search) {
+ retval = g_object_ref (sessions->data);
+ break;
+ }
+ sessions = g_list_next (sessions);
+ }
+
+ return retval;
+}
+
+
+TrackerXesamLiveSearch *
+tracker_xesam_get_live_search (const gchar *search_id)
+{
+ TrackerXesamLiveSearch *retval = NULL;
+ GList * sessions = g_hash_table_get_values (tracker->xesam_sessions);
+
+ while (sessions) {
+ TrackerXesamLiveSearch *search = tracker_xesam_session_get_search (sessions->data, search_id);
+ if (search) {
+ retval = g_object_ref (search);
+ break;
+ }
+ sessions = g_list_next (sessions);
+ }
+
+ return retval;
+}
+
+
Added: branches/xesam-support/src/trackerd/tracker-xesam.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/src/trackerd/tracker-xesam.h Tue Apr 22 15:16:59 2008
@@ -0,0 +1,37 @@
+#ifndef _TRACKER_XESAM_H_
+#define _TRACKER_XESAM_H_
+
+#include "tracker-utils.h"
+#include "tracker-xesam-session.h"
+#include "tracker-xesam-live-search.h"
+
+/*
+ * Copyright (C) 2008, Nokia
+ * Authors: Philip Van Hoof (pvanhoof gnome org)
+ *
+ * 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.
+ */
+
+TrackerXesamSession* tracker_xesam_get_session (const gchar *session_id);
+TrackerXesamSession* tracker_xesam_get_session_for_search (const gchar *search_id);
+TrackerXesamLiveSearch* tracker_xesam_get_live_search (const gchar *search_id);
+TrackerXesamSession* tracker_xesam_create_session (TrackerXesamSearch *dbus_proxy, gchar **session_id);
+void tracker_xesam_close_session (const gchar *session_id);
+
+
+void tracker_xesam_init (void);
+
+#endif
Modified: branches/xesam-support/src/trackerd/trackerd.c
==============================================================================
--- /branches/indexer-split/src/trackerd/trackerd.c (original)
+++ branches/xesam-support/src/trackerd/trackerd.c Tue Apr 22 15:16:59 2008
@@ -54,7 +54,8 @@
#include "tracker-hal.h"
#include "tracker-service-manager.h"
#include "tracker-status.h"
-
+#include "tracker-xesam.h"
+
#ifdef OS_WIN32
#include <windows.h>
#include <pthread.h>
@@ -654,6 +655,8 @@
tracker = g_new0 (Tracker, 1);
+ tracker_xesam_init ();
+
/* Set up directories */
tracker->pid = (int) getpid ();
tmp_dir = g_strdup_printf ("Tracker-%s.%d", g_get_user_name (), tracker->pid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]