tracker r1884 - in branches/indexer-split: . data/dbus src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1884 - in branches/indexer-split: . data/dbus src/trackerd
- Date: Thu, 17 Jul 2008 15:06:29 +0000 (UTC)
Author: pvanhoof
Date: Thu Jul 17 15:06:29 2008
New Revision: 1884
URL: http://svn.gnome.org/viewvc/tracker?rev=1884&view=rev
Log:
2008-07-17 Philip Van Hoof <pvanhoof gnome org>
* src/trackerd/tracker-search.c:
* data/dbus/tracker-search.xml:
Async search API.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-search.xml
branches/indexer-split/src/trackerd/tracker-search.c
branches/indexer-split/src/trackerd/tracker-search.h
Modified: branches/indexer-split/data/dbus/tracker-search.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-search.xml (original)
+++ branches/indexer-split/data/dbus/tracker-search.xml Thu Jul 17 15:06:29 2008
@@ -7,6 +7,7 @@
<interface name="org.freedesktop.Tracker.Search">
<!-- Returns no of hits for the search_text on the servce. -->
<method name="GetHitCount">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="service" direction="in" />
<arg type="s" name="search_text" direction="in" />
<arg type="i" name="result" direction="out" />
@@ -14,6 +15,7 @@
<!-- returns [service name, no. of hits] for the search_text -->
<method name="GetHitCountAll">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="search_text" direction="in" />
<arg type="aas" name="result" direction="out" />
</method>
@@ -22,6 +24,7 @@
specified search_text. Returns uri of all hits.
-->
<method name="Text">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="i" name="live_query_id" direction="in" />
<arg type="s" name="service" direction="in" />
<arg type="s" name="search_text" direction="in" />
@@ -35,6 +38,7 @@
hits in array format [uri, service, mime].
-->
<method name="TextDetailed">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="i" name="live_query_id" direction="in" />
<arg type="s" name="service" direction="in" />
<arg type="s" name="search_text" direction="in" />
@@ -47,6 +51,7 @@
in bold tags.
-->
<method name="GetSnippet">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="service" direction="in" />
<arg type="s" name="id" direction="in" />
<arg type="s" name="search_text" direction="in" />
@@ -57,6 +62,7 @@
search term (search_text). The result is an array of uri/id's.
-->
<method name="Metadata">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<arg type="s" name="service" direction="in" />
<arg type="s" name="field" direction="in" />
@@ -91,6 +97,7 @@
specified field in the fields paramter and so on.
-->
<method name="Query">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="i" name="live_query_id" direction="in" />
<arg type="s" name="service" direction="in" />
<arg type="as" name="fields" direction="in" />
@@ -105,6 +112,7 @@
<!-- Suggests an alternate spelling based on the word index. -->
<method name="Suggest">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="search_text" direction="in" />
<arg type="i" name="maxdist" direction="in" />
<arg type="s" name="result" direction="out" />
Modified: branches/indexer-split/src/trackerd/tracker-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-search.c Thu Jul 17 15:06:29 2008
@@ -432,47 +432,53 @@
}
}
-gboolean
-tracker_search_get_hit_count (TrackerSearch *object,
- const gchar *service,
- const gchar *search_text,
- gint *value,
- GError **error)
+void
+tracker_search_get_hit_count (TrackerSearch *object,
+ const gchar *service,
+ const gchar *search_text,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerSearchPriv *priv;
TrackerQueryTree *tree;
GArray *array;
guint request_id;
gint services[12];
- gint count = 0;
+ gint count = 0;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (value != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
tracker_dbus_request_new (request_id,
- "DBus request to get hit count, "
+ "DBus request to get hit count, "
"service:'%s', search text:'%s'",
- service,
- search_text);
+ service,
+ search_text);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ if (tracker_is_empty_string (search_text)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "No search term was specified");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- if (tracker_is_empty_string (search_text)) {
- tracker_dbus_request_failed (request_id,
- error,
- "No search term was specified");
- return FALSE;
- }
-
priv = GET_PRIV (object);
services[count++] = tracker_ontology_get_id_for_service_type (service);
@@ -503,59 +509,66 @@
priv->config,
priv->language,
array);
- *value = tracker_query_tree_get_hit_count (tree);
+
+ dbus_g_method_return (context, tracker_query_tree_get_hit_count (tree));
+
g_object_unref (tree);
- g_array_free (array, TRUE);
+ g_array_free (array, TRUE);
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_get_hit_count_all (TrackerSearch *object,
- const gchar *search_text,
- GPtrArray **values,
- GError **error)
+void
+tracker_search_get_hit_count_all (TrackerSearch *object,
+ const gchar *search_text,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerSearchPriv *priv;
TrackerDBResultSet *result_set = NULL;
- TrackerQueryTree *tree;
- GArray *hit_counts;
+ TrackerQueryTree *tree;
+ GArray *hit_counts;
GArray *mail_hit_counts;
guint request_id;
guint i;
+ GPtrArray *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
tracker_dbus_request_new (request_id,
- "DBus request to get search hit count for all, "
- "search text:'%s'",
- search_text);
-
- if (tracker_is_empty_string (search_text)) {
- tracker_dbus_request_failed (request_id,
- error,
- "No search term was specified");
- return FALSE;
- }
+ "DBus request to get search hit count for all, "
+ "search text:'%s'",
+ search_text);
+
+ if (tracker_is_empty_string (search_text)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "No search term was specified");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
priv = GET_PRIV (object);
- tree = tracker_query_tree_new (search_text,
+ tree = tracker_query_tree_new (search_text,
priv->file_index,
priv->config,
priv->language,
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);
+ 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);
for (i = 0; i < hit_counts->len; i++) {
TrackerHitCount count;
@@ -580,67 +593,77 @@
g_value_unset (&value);
}
- *values = tracker_dbus_query_result_to_ptr_array (result_set);
+ values = tracker_dbus_query_result_to_ptr_array (result_set);
+
+ dbus_g_method_return (context, values);
+
+ tracker_dbus_results_ptr_array_free (&values);
if (result_set) {
tracker_db_result_set_rewind (result_set);
g_object_unref (result_set);
}
- g_array_free (hit_counts, TRUE);
- g_object_unref (tree);
+ g_array_free (hit_counts, TRUE);
+ g_object_unref (tree);
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_text (TrackerSearch *object,
- gint live_query_id,
- const gchar *service,
- const gchar *search_text,
- gint offset,
- gint max_hits,
- gchar ***values,
- GError **error)
+void
+tracker_search_text (TrackerSearch *object,
+ gint live_query_id,
+ const gchar *service,
+ const gchar *search_text,
+ gint offset,
+ gint max_hits,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
- guint request_id;
- gchar **strv = NULL;
+ guint request_id;
+ gchar **strv = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
tracker_dbus_request_new (request_id,
- "DBus request to search text, "
+ "DBus request to search text, "
"query id:%d, service:'%s', search text:'%s', "
"offset:%d, max hits:%d",
live_query_id,
- service,
- search_text,
- offset,
- max_hits);
+ service,
+ search_text,
+ offset,
+ max_hits);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ if (tracker_is_empty_string (search_text)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "No search term was specified");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- if (tracker_is_empty_string (search_text)) {
- tracker_dbus_request_failed (request_id,
- error,
- "No search term was specified");
- return FALSE;
- }
-
iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
@@ -679,66 +702,75 @@
g_object_unref (result_set);
}
- if (!strv) {
- strv = g_new (gchar*, 1);
+ if (!strv) {
+ strv = g_new (gchar*, 1);
strv[0] = NULL;
-
- tracker_dbus_request_comment (request_id,
+ tracker_dbus_request_comment (request_id,
"Search found no results");
}
- *values = strv;
+ dbus_g_method_return (context, strv);
+
+ g_strfreev (strv);
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_text_detailed (TrackerSearch *object,
- gint live_query_id,
- const gchar *service,
- const gchar *search_text,
- gint offset,
- gint max_hits,
- GPtrArray **values,
- GError **error)
+void
+tracker_search_text_detailed (TrackerSearch *object,
+ gint live_query_id,
+ const gchar *service,
+ const gchar *search_text,
+ gint offset,
+ gint max_hits,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
+ GPtrArray *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
- tracker_dbus_request_new (request_id,
- "DBus request to search text detailed, "
+ tracker_dbus_request_new (request_id,
+ "DBus request to search text detailed, "
"query id:%d, service:'%s', search text:'%s', "
"offset:%d, max hits:%d",
live_query_id,
- service,
- search_text,
- offset,
- max_hits);
+ service,
+ search_text,
+ offset,
+ max_hits);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ if (tracker_is_empty_string (search_text)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "No search term was specified");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- if (tracker_is_empty_string (search_text)) {
- tracker_dbus_request_failed (request_id,
- error,
- "No search term was specified");
- return FALSE;
- }
-
iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
@@ -749,7 +781,11 @@
FALSE,
TRUE);
- *values = tracker_dbus_query_result_to_ptr_array (result_set);
+ values = tracker_dbus_query_result_to_ptr_array (result_set);
+
+ dbus_g_method_return (context, values);
+
+ tracker_dbus_results_ptr_array_free (&values);
if (result_set) {
g_object_unref (result_set);
@@ -757,70 +793,79 @@
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_get_snippet (TrackerSearch *object,
- const gchar *service,
- const gchar *id,
- const gchar *search_text,
- gchar **values,
- GError **error)
+void
+tracker_search_get_snippet (TrackerSearch *object,
+ const gchar *service,
+ const gchar *id,
+ const gchar *search_text,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
- gchar *snippet = NULL;
- gchar *service_id;
+ gchar *snippet = NULL;
+ gchar *service_id;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (id != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (id != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
- tracker_dbus_request_new (request_id,
- "DBus request to get snippet, "
+ tracker_dbus_request_new (request_id,
+ "DBus request to get snippet, "
"service:'%s', search text:'%s', id:'%s'",
- service,
- search_text,
- id);
+ service,
+ search_text,
+ id);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ if (tracker_is_empty_string (search_text)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "No search term was specified");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- if (tracker_is_empty_string (search_text)) {
- tracker_dbus_request_failed (request_id,
- error,
- "No search term was specified");
- return FALSE;
- }
-
iface = tracker_db_manager_get_db_interface_by_service (service);
service_id = tracker_db_file_get_id_as_string (iface, service, id);
- if (!service_id) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service URI '%s' not found",
- id);
- return FALSE;
- }
+ if (!service_id) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service URI '%s' not found",
+ id);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
iface = tracker_db_manager_get_db_interface_by_service (service);
-
+
result_set = tracker_db_exec_proc (iface,
"GetAllContents",
service_id,
NULL);
- g_free (service_id);
+ g_free (service_id);
if (result_set) {
TrackerSearchPriv *priv;
@@ -849,41 +894,44 @@
snippet = g_strdup (" ");
}
- *values = snippet;
+ dbus_g_method_return (context, snippet);
+
+ g_free (snippet);
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_files_by_text (TrackerSearch *object,
- gint live_query_id,
- const gchar *search_text,
- gint offset,
- gint max_hits,
- gboolean group_results,
- GHashTable **values,
- GError **error)
+void
+tracker_search_files_by_text (TrackerSearch *object,
+ gint live_query_id,
+ const gchar *search_text,
+ gint offset,
+ gint max_hits,
+ gboolean group_results,
+ DBusGMethodInvocation *context,
+ GError **error)
{
/* TrackerDBInterface *iface; */
TrackerDBResultSet *result_set;
guint request_id;
+ GHashTable *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
- tracker_dbus_request_new (request_id,
- "DBus request to search files by text, "
+ tracker_dbus_request_new (request_id,
+ "DBus request to search files by text, "
"query id:%d, search text:'%s', offset:%d"
- "max hits:%d, group results:'%s'",
+ "max hits:%d, group results:'%s'",
live_query_id,
- search_text,
- offset,
- max_hits,
- group_results ? "yes" : "no");
+ search_text,
+ offset,
+ max_hits,
+ group_results ? "yes" : "no");
/* iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE); */
@@ -899,7 +947,11 @@
/* search_sanity_check_max_hits (max_hits), */
/* group_results); */
- *values = tracker_dbus_query_result_to_hash_table (result_set);
+ values = tracker_dbus_query_result_to_hash_table (result_set);
+
+ dbus_g_method_return (context, values);
+
+ g_hash_table_destroy (values);
if (result_set) {
g_object_unref (result_set);
@@ -907,48 +959,53 @@
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_metadata (TrackerSearch *object,
- const gchar *service,
- const gchar *field,
- const gchar *search_text,
- gint offset,
- gint max_hits,
- gchar ***values,
- GError **error)
+void
+tracker_search_metadata (TrackerSearch *object,
+ const gchar *service,
+ const gchar *field,
+ const gchar *search_text,
+ gint offset,
+ gint max_hits,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
+ gchar **values;
- /* FIXME: This function is completely redundant */
+ /* FIXME: This function is completely redundant */
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (field != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (field != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
- tracker_dbus_request_new (request_id,
- "DBus request to search metadata, "
+ tracker_dbus_request_new (request_id,
+ "DBus request to search metadata, "
"service:'%s', search text:'%s', field:'%s', "
"offset:%d, max hits:%d",
- service,
- search_text,
- field,
- offset,
- max_hits);
+ service,
+ search_text,
+ field,
+ offset,
+ max_hits);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
iface = tracker_db_manager_get_db_interface_by_service (service);
@@ -957,7 +1014,7 @@
* NULL in every case, this DBus function needs rewriting or
* to be removed.
*/
- result_set = NULL;
+ result_set = NULL;
/* result_set = tracker_db_search_metadata (iface, */
/* service, */
@@ -965,7 +1022,12 @@
/* text, */
/* offset, */
/* search_sanity_check_max_hits (max_hits)); */
- *values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
+
+ values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
+
+ dbus_g_method_return (context, values);
+
+ g_strfreev (values);
if (result_set) {
g_object_unref (result_set);
@@ -973,63 +1035,76 @@
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
-tracker_search_matching_fields (TrackerSearch *object,
- const gchar *service,
- const gchar *id,
- const gchar *search_text,
- GHashTable **values,
- GError **error)
+void
+tracker_search_matching_fields (TrackerSearch *object,
+ const gchar *service,
+ const gchar *id,
+ const gchar *search_text,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
+ GHashTable *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (id != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
-
- tracker_dbus_request_new (request_id,
- "DBus request to search matching fields, "
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (id != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to search matching fields, "
"service:'%s', search text:'%s', id:'%s'",
- service,
- search_text,
- id);
+ service,
+ search_text,
+ id);
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
+
+ if (tracker_is_empty_string (id)) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "ID field must have a value");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- if (tracker_is_empty_string (id)) {
- tracker_dbus_request_failed (request_id,
- error,
- "ID field must have a value");
- return FALSE;
- }
-
iface = tracker_db_manager_get_db_interface_by_service (service);
/* FIXME: This function no longer exists, it was returning
* NULL in every case, this DBus function needs rewriting or
* to be removed.
*/
- result_set = NULL;
+ result_set = NULL;
/* result_set = tracker_db_search_matching_metadata (iface, */
/* service, */
/* id, */
/* search_text); */
- *values = tracker_dbus_query_result_to_hash_table (result_set);
+
+ values = tracker_dbus_query_result_to_hash_table (result_set);
+
+ dbus_g_method_return (context, values);
+
+ g_hash_table_destroy (values);
if (result_set) {
g_object_unref (result_set);
@@ -1037,10 +1112,10 @@
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
+void
tracker_search_query (TrackerSearch *object,
gint live_query_id,
const gchar *service,
@@ -1051,42 +1126,47 @@
gboolean sort_by_service,
gint offset,
gint max_hits,
- GPtrArray **values,
+ DBusGMethodInvocation *context,
GError **error)
{
+ GError *actual_error = NULL;
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
guint request_id;
+ GPtrArray *values = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (fields != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (keyword != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (query_condition != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service != NULL, context);
+ tracker_dbus_async_return_if_fail (fields != NULL, context);
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (keyword != NULL, context);
+ tracker_dbus_async_return_if_fail (query_condition != NULL, context);
+ tracker_dbus_async_return_if_fail (values != NULL, context);
- tracker_dbus_request_new (request_id,
- "DBus request to search query, "
+ tracker_dbus_request_new (request_id,
+ "DBus request to search query, "
"query id:%d, service:'%s', search text '%s', "
"keyword:'%s', query condition:'%s', offset:%d, "
"max hits:%d, sort by service:'%s'",
live_query_id,
- service,
- search_text,
- keyword,
- query_condition,
- offset,
- max_hits,
- sort_by_service ? "yes" : "no");
-
+ service,
+ search_text,
+ keyword,
+ query_condition,
+ offset,
+ max_hits,
+ sort_by_service ? "yes" : "no");
+
if (!tracker_ontology_is_valid_service_type (service)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Service '%s' is invalid or has not been implemented yet",
+ service);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
result_set = NULL;
@@ -1097,52 +1177,56 @@
GError *query_error = NULL;
gchar *query_translated;
- tracker_dbus_request_comment (request_id,
+ tracker_dbus_request_comment (request_id,
"Executing RDF query:'%s' with search "
"term:'%s' and keyword:'%s'",
query_condition,
search_text,
keyword);
-
+
query_translated = tracker_rdf_query_to_sql (iface,
- query_condition,
- service,
- fields,
- g_strv_length (fields),
- search_text,
- keyword,
- sort_by_service,
- offset,
- search_sanity_check_max_hits (max_hits),
- query_error);
-
+ query_condition,
+ service,
+ fields,
+ g_strv_length (fields),
+ search_text,
+ keyword,
+ sort_by_service,
+ offset,
+ search_sanity_check_max_hits (max_hits),
+ query_error);
+
if (query_error) {
- tracker_dbus_request_failed (request_id,
- error,
- "Invalid rdf query produced following error: %s",
- query_error->message);
- g_error_free (query_error);
-
- return FALSE;
- } else if (!query_translated) {
- tracker_dbus_request_failed (request_id,
- error,
- "Invalid rdf query, no error given");
- return FALSE;
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ query_error->message);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ g_error_free (query_error);
+ return;
+ } else if (!query_translated) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Invalid rdf query, no error given");
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- tracker_dbus_request_comment (request_id,
+ tracker_dbus_request_comment (request_id,
"Translated RDF query:'%s'",
query_translated);
if (!tracker_is_empty_string (search_text)) {
tracker_db_search_text (iface,
- service,
- search_text,
- 0,
- 999999,
- TRUE,
- FALSE);
+ service,
+ search_text,
+ 0,
+ 999999,
+ TRUE,
+ FALSE);
}
result_set = tracker_db_interface_execute_query (iface,
@@ -1151,7 +1235,11 @@
g_free (query_translated);
}
- *values = tracker_dbus_query_result_to_ptr_array (result_set);
+ values = tracker_dbus_query_result_to_ptr_array (result_set);
+
+ dbus_g_method_return (context, values);
+
+ tracker_dbus_results_ptr_array_free (&values);
if (result_set) {
g_object_unref (result_set);
@@ -1159,46 +1247,52 @@
tracker_dbus_request_success (request_id);
- return TRUE;
+ return;
}
-gboolean
+void
tracker_search_suggest (TrackerSearch *object,
const gchar *search_text,
gint max_dist,
- gchar **value,
+ DBusGMethodInvocation *context,
GError **error)
{
- TrackerSearchPriv *priv;
+ GError *actual_error = NULL;
+ TrackerSearchPriv *priv;
guint request_id;
+ gchar *value;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (search_text != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (value != NULL, FALSE, error);
-
- tracker_dbus_request_new (request_id,
- "DBus request to for suggested words, "
+ tracker_dbus_async_return_if_fail (search_text != NULL, context);
+ tracker_dbus_async_return_if_fail (value != NULL, context);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to for suggested words, "
"term:'%s', max dist:%d",
search_text,
max_dist);
priv = GET_PRIV (object);
- *value = tracker_indexer_get_suggestion (priv->file_index, search_text, max_dist);
+ value = tracker_indexer_get_suggestion (priv->file_index, search_text, max_dist);
- if (!(*value)) {
- tracker_dbus_request_failed (request_id,
- error,
- "Possible data error in index, no suggestions given for '%s'",
- search_text);
- return FALSE;
- }
-
- tracker_dbus_request_comment (request_id,
+ if (!value) {
+ g_set_error (&actual_error,
+ TRACKER_DBUS_ERROR,
+ 0,
+ "Possible data error in index, no suggestions given for '%s'",
+ search_text);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ } else {
+ dbus_g_method_return (context, value);
+ tracker_dbus_request_comment (request_id,
"Suggested spelling for '%s' is '%s'",
- search_text, *value);
-
+ search_text, value);
+ g_free (value);
+ }
- return TRUE;
+ return;
}
Modified: branches/indexer-split/src/trackerd/tracker-search.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.h (original)
+++ branches/indexer-split/src/trackerd/tracker-search.h Thu Jul 17 15:06:29 2008
@@ -57,60 +57,60 @@
TrackerLanguage *language,
TrackerIndexer *file_index,
TrackerIndexer *email_index);
-gboolean tracker_search_get_hit_count (TrackerSearch *object,
+void tracker_search_get_hit_count (TrackerSearch *object,
const gchar *service,
const gchar *search_text,
- gint *result,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_get_hit_count_all (TrackerSearch *object,
+void tracker_search_get_hit_count_all (TrackerSearch *object,
const gchar *search_text,
- GPtrArray **values,
- GError **error);
-gboolean tracker_search_text (TrackerSearch *object,
+ DBusGMethodInvocation *context,
+ GError **error_in);
+void tracker_search_text (TrackerSearch *object,
gint live_query_id,
const gchar *service,
const gchar *search_text,
gint offset,
gint max_hits,
- gchar ***values,
- GError **error);
-gboolean tracker_search_text_detailed (TrackerSearch *object,
+ DBusGMethodInvocation *context,
+ GError **error_in);
+void tracker_search_text_detailed (TrackerSearch *object,
gint live_query_id,
const gchar *service,
const gchar *search_text,
gint offset,
gint max_hits,
- GPtrArray **values,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_get_snippet (TrackerSearch *object,
+void tracker_search_get_snippet (TrackerSearch *object,
const gchar *service,
const gchar *id,
const gchar *search_text,
- gchar **result,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_files_by_text (TrackerSearch *object,
+void tracker_search_files_by_text (TrackerSearch *object,
gint live_query_id,
const gchar *search_text,
gint offset,
gint max_hits,
gboolean group_results,
- GHashTable **values,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_metadata (TrackerSearch *object,
+void tracker_search_metadata (TrackerSearch *object,
const gchar *service,
const gchar *field,
const gchar *search_text,
gint offset,
gint max_hits,
- gchar ***values,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_matching_fields (TrackerSearch *object,
+void tracker_search_matching_fields (TrackerSearch *object,
const gchar *service,
const gchar *id,
const gchar *search_text,
- GHashTable **values,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_query (TrackerSearch *object,
+void tracker_search_query (TrackerSearch *object,
gint live_query_id,
const gchar *service,
gchar **fields,
@@ -120,12 +120,12 @@
gboolean sort_by_service,
gint offset,
gint max_hits,
- GPtrArray **values,
+ DBusGMethodInvocation *context,
GError **error);
-gboolean tracker_search_suggest (TrackerSearch *object,
+void tracker_search_suggest (TrackerSearch *object,
const gchar *search_text,
gint max_dist,
- gchar **value,
+ DBusGMethodInvocation *context,
GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]