tracker r1881 - in branches/indexer-split: . data/dbus src/trackerd
- From: ifrade svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1881 - in branches/indexer-split: . data/dbus src/trackerd
- Date: Thu, 17 Jul 2008 09:48:19 +0000 (UTC)
Author: ifrade
Date: Thu Jul 17 09:48:19 2008
New Revision: 1881
URL: http://svn.gnome.org/viewvc/tracker?rev=1881&view=rev
Log:
Metadata api async
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-metadata.xml
branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/trackerd/tracker-metadata.h
Modified: branches/indexer-split/data/dbus/tracker-metadata.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-metadata.xml (original)
+++ branches/indexer-split/data/dbus/tracker-metadata.xml Thu Jul 17 09:48:19 2008
@@ -2,47 +2,54 @@
<node name="/org/freedesktop/Tracker">
<interface name="org.freedesktop.Tracker.Metadata">
+
<!-- Retrieves an array of metadata values for the specified array
of metadata keys for a service and id pair.
-->
<method name="Get">
- <arg type="s" name="service" direction="in" />
- <arg type="s" name="id" direction="in" />
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="service_type" direction="in" />
+ <arg type="s" name="uri" direction="in" />
<arg type="as" name="keys" direction="in" />
- <arg type="as" name="values" direction="out" />
+ <arg type="as" name="metadata" direction="out" />
</method>
<!-- Sets specified metadata keys to the specified metadata values
for a service and id pair.
-->
<method name="Set">
- <arg type="s" name="service" direction="in" />
- <arg type="s" name="id" direction="in" />
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="service_type" direction="in" />
+ <arg type="s" name="uri" direction="in" />
<arg type="as" name="keys" direction="in" />
- <arg type="as" name="values" direction="in" />
+ <arg type="as" name="metadata" direction="in" />
</method>
- <!-- Gets all details of a named metadata type. -->
+ <!-- Gets all details of a named metadata type (e.g. "Video:FrameRate" or "Audio:Title").
+ data_type: keyword, index, fulltext, string, integer, dobule, date, blob, struct, link
+ -->
<method name="GetTypeDetails">
- <arg type="s" name="name" direction="in" />
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="metadata" direction="in" />
<arg type="s" name="data_type" direction="out" />
<arg type="b" name="is_embedded" direction="out" />
<arg type="b" name="is_writable" direction="out" />
</method>
<!-- Returns an array of all metadata types that are registered
- for a certain class. You can enter "*" as the class to get all
- metadat types for all classes.
+ for a certain service type. You can enter "*" as the service type to get all
+ registered metadata types .
-->
<method name="GetRegisteredTypes">
- <arg type="s" name="metadata_class" direction="in" />
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="service_type" direction="in" />
<arg type="as" name="result" direction="out" />
</method>
- <!-- Returns an array of all metadata type classes that are
- registered.
+ <!-- Returns an array of all service types that are registered.
-->
<method name="GetRegisteredClasses">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="as" name="result" direction="out" />
</method>
</interface>
Modified: branches/indexer-split/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.c (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.c Thu Jul 17 09:48:19 2008
@@ -57,13 +57,13 @@
/*
* Functions
*/
-gboolean
-tracker_metadata_get (TrackerMetadata *object,
- const gchar *service_type,
- const gchar *uri,
- gchar **keys,
- gchar ***values,
- GError **error)
+void
+tracker_metadata_get (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ gchar **keys,
+ DBusGMethodInvocation *context,
+ GError **error)
{
TrackerDBInterface *iface;
TrackerDBResultSet *result_set;
@@ -74,46 +74,57 @@
GString *sql;
GString *sql_join;
gchar *query;
+ gchar **values;
+ GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (service_type != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (keys != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (g_strv_length (keys) > 0, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service_type != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (uri != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (keys != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (g_strv_length (keys) > 0, FALSE);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to get metadata values, "
+ "service type:'%s'",
+ service_type);
if (!tracker_ontology_is_valid_service_type (service_type)) {
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Service '%s' is invalid or has not been implemented yet",
service_type);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- tracker_dbus_request_new (request_id,
- "DBus request to get metadata values, "
- "service type:'%s'",
- service_type);
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
service_id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Service URI '%s' not found",
uri);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
+ /* The parameter service_type can be "Files"
+ * and the actual service type of the uri "Video"
+ */
service_result = tracker_db_service_get_by_entity (iface, service_id);
if (!service_result) {
g_free (service_id);
tracker_dbus_request_failed (request_id,
- error,
- "Service information can not be found for entity '%s'",
+ &actual_error,
+ "Service type can not be found for entity '%s'",
uri);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
/* Build SQL select clause */
@@ -137,10 +148,12 @@
g_free (service_id);
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Invalid or non-existant metadata type '%s' specified",
keys[i]);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
if (i == 0) {
@@ -177,69 +190,77 @@
g_debug (query);
result_set = tracker_db_interface_execute_query (iface, NULL, query);
- *values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
+ values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
g_free (query);
if (result_set) {
g_object_unref (result_set);
}
- if (!*values) {
+ if (!values) {
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"No metadata information was available");
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
}
- tracker_dbus_request_success (request_id);
+ dbus_g_method_return (context, values);
+ g_strfreev (values);
- return TRUE;
+ tracker_dbus_request_success (request_id);
}
-gboolean
-tracker_metadata_set (TrackerMetadata *object,
- const gchar *service,
- const gchar *id,
- gchar **keys,
- gchar **values,
- GError **error)
+void
+tracker_metadata_set (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ gchar **keys,
+ gchar **values,
+ DBusGMethodInvocation *context,
+ GError **error)
{
TrackerDBInterface *iface;
guint request_id;
gchar *service_id;
guint i;
+ GError *actual_error = 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 (keys != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (g_strv_length (keys) > 0, FALSE, error);
- tracker_dbus_return_val_if_fail (g_strv_length (values) > 0, FALSE, error);
- tracker_dbus_return_val_if_fail (g_strv_length (keys) == g_strv_length (values), FALSE, error);
+ tracker_dbus_async_return_if_fail (service_type != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (keys != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (values != NULL, FALSE);
+ tracker_dbus_async_return_if_fail (g_strv_length (keys) > 0, FALSE);
+ tracker_dbus_async_return_if_fail (g_strv_length (values) > 0, FALSE);
+ tracker_dbus_async_return_if_fail (g_strv_length (keys) == g_strv_length (values), FALSE);
tracker_dbus_request_new (request_id,
"DBus request to set metadata keys, "
- "service:'%s'",
- service);
+ "service type:'%s' uri:'%s'",
+ service_type, uri);
- if (!tracker_ontology_is_valid_service_type (service)) {
+ if (!tracker_ontology_is_valid_service_type (service_type)) {
tracker_dbus_request_failed (request_id,
- error,
- "Service '%s' is invalid or has not been implemented yet",
- service);
- return FALSE;
+ &actual_error,
+ "Service_Type '%s' is invalid or has not been implemented yet",
+ service_type);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
- iface = tracker_db_manager_get_db_interface_by_service (service);
+ iface = tracker_db_manager_get_db_interface_by_service (service_type);
- service_id = tracker_db_file_get_id_as_string (iface, service, id);
+ service_id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!service_id) {
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Service URI '%s' not found",
- id);
- return FALSE;
+ uri);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
for (i = 0; i < g_strv_length (keys); i++) {
@@ -253,14 +274,16 @@
g_free (service_id);
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Metadata type name '%s' is invalid, all names must be registered",
key);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
tracker_db_metadata_set_single (iface,
- service,
+ service_type,
service_id,
key,
value,
@@ -271,30 +294,30 @@
/* FIXME: Check return value? */
+ dbus_g_method_return (context);
+
tracker_dbus_request_success (request_id);
- return TRUE;
}
-gboolean
-tracker_metadata_get_type_details (TrackerMetadata *object,
- const gchar *metadata,
- gchar **type,
- gboolean *is_embedded,
- gboolean *is_writable,
- GError **error)
+void
+tracker_metadata_get_type_details (TrackerMetadata *object,
+ const gchar *metadata,
+ DBusGMethodInvocation *context,
+ GError **error)
{
- guint request_id;
- TrackerField *def = NULL;
- TrackerFieldType field_type;
+ guint request_id;
+ TrackerField *def = NULL;
+ TrackerFieldType field_type;
+ gchar *type;
+ gboolean is_embedded;
+ gboolean is_writable;
+ GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (metadata != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (type != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (is_embedded != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (is_writable != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (metadata != NULL, FALSE);
tracker_dbus_request_new (request_id,
"DBus request to get metadata details, "
@@ -304,42 +327,57 @@
def = tracker_ontology_get_field_def (metadata);
if (!def) {
tracker_dbus_request_failed (request_id,
- error,
+ &actual_error,
"Metadata name '%s' is invalid or unrecognized",
metadata);
- return FALSE;
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
}
field_type = tracker_field_get_data_type (def);
- *type = g_strdup (tracker_field_type_to_string (field_type));
- *is_embedded = tracker_field_get_embedded (def);
- *is_writable = !tracker_field_get_embedded (def);
+ type = g_strdup (tracker_field_type_to_string (field_type));
+ is_embedded = tracker_field_get_embedded (def);
+ is_writable = !tracker_field_get_embedded (def);
+
+ dbus_g_method_return (context, type, is_embedded, is_writable);
+ g_free (type);
tracker_dbus_request_success (request_id);
-
- return TRUE;
}
-gboolean
-tracker_metadata_get_registered_types (TrackerMetadata *object,
- const gchar *class,
- gchar ***values,
- GError **error)
+void
+tracker_metadata_get_registered_types (TrackerMetadata *object,
+ const gchar *service_type,
+ DBusGMethodInvocation *context,
+ GError **error)
{
- TrackerDBInterface *iface;
- TrackerDBResultSet *result_set;
- guint request_id;
+ TrackerDBInterface *iface;
+ TrackerDBResultSet *result_set;
+ guint request_id;
+ gchar **values = NULL;
+ GError *actual_error = NULL;
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (class != NULL, FALSE, error);
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
+ tracker_dbus_async_return_if_fail (service_type != NULL, FALSE);
tracker_dbus_request_new (request_id,
"DBus request to get registered metadata types, "
- "class:'%s'",
- class);
+ "service_type:'%s'",
+ service_type);
+
+ if (strcmp (service_type, "*") != 0 &&
+ !tracker_ontology_is_valid_service_type (service_type)) {
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ "Service_Type '%s' is invalid or has not been implemented yet",
+ service_type);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ return;
+ }
/* Here it doesn't matter which one we ask, as long as it has common.db
* attached. The service ones are cached connections, so we can use
@@ -350,30 +388,34 @@
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
- result_set = tracker_db_metadata_get_types (iface, class, FALSE);
+ result_set = tracker_db_metadata_get_types (iface, service_type, FALSE);
if (result_set) {
- *values = tracker_dbus_query_result_to_strv (result_set, 1, NULL);
+ values = tracker_dbus_query_result_to_strv (result_set, 1, NULL);
g_object_unref (result_set);
}
+ dbus_g_method_return (context, values);
+
+ if (values) {
+ g_strfreev (values);
+ }
+
tracker_dbus_request_success (request_id);
- return TRUE;
}
-gboolean
-tracker_metadata_get_registered_classes (TrackerMetadata *object,
- gchar ***values,
- GError **error)
+void
+tracker_metadata_get_registered_classes (TrackerMetadata *object,
+ DBusGMethodInvocation *context,
+ GError **error)
{
- TrackerDBInterface *iface;
- TrackerDBResultSet *result_set;
- guint request_id;
-
+ TrackerDBInterface *iface;
+ TrackerDBResultSet *result_set;
+ guint request_id;
+ gchar **values = NULL;
+
request_id = tracker_dbus_get_next_request_id ();
- tracker_dbus_return_val_if_fail (values != NULL, FALSE, error);
-
tracker_dbus_request_new (request_id,
"DBus request to get registered classes");
@@ -391,11 +433,15 @@
NULL);
if (result_set) {
- *values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
+ values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
g_object_unref (result_set);
}
+ dbus_g_method_return (context, values);
+
+ if (values) {
+ g_strfreev (values);
+ }
+
tracker_dbus_request_success (request_id);
-
- return TRUE;
}
Modified: branches/indexer-split/src/trackerd/tracker-metadata.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.h (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.h Thu Jul 17 09:48:19 2008
@@ -52,39 +52,30 @@
GType tracker_metadata_get_type (void);
TrackerMetadata *tracker_metadata_new (void);
-gboolean tracker_metadata_get (TrackerMetadata *object,
- const gchar *service,
- const gchar *id,
- gchar **keys,
- gchar ***values,
- GError **error);
-gboolean tracker_metadata_set (TrackerMetadata *object,
- const gchar *service,
- const gchar *id,
- gchar **keys,
- gchar **values,
- GError **error);
-gboolean tracker_metadata_register_type (TrackerMetadata *object,
- const gchar *metadata,
- const gchar *type,
- GError **error);
-gboolean tracker_metadata_get_type_details (TrackerMetadata *object,
- const gchar *metadata,
- gchar **type,
- gboolean *is_embedded,
- gboolean *is_writable,
- GError **error);
-gboolean tracker_metadata_get_registered_types (TrackerMetadata *object,
- const gchar *metadata,
- gchar ***values,
- GError **error);
-gboolean tracker_metadata_get_writable_types (TrackerMetadata *object,
- const gchar *class,
- gchar ***values,
- GError **error);
-gboolean tracker_metadata_get_registered_classes (TrackerMetadata *object,
- gchar ***values,
- GError **error);
+void tracker_metadata_get (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ gchar **keys,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_metadata_set (TrackerMetadata *object,
+ const gchar *service_type,
+ const gchar *uri,
+ gchar **keys,
+ gchar **metadata,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_metadata_get_type_details (TrackerMetadata *object,
+ const gchar *metadata,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_metadata_get_registered_types (TrackerMetadata *object,
+ const gchar *service_type,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_metadata_get_registered_classes (TrackerMetadata *object,
+ DBusGMethodInvocation *context,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]