tracker r1321 - in trunk: . data src/libtracker src/trackerd
- From: jamiemcc svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1321 - in trunk: . data src/libtracker src/trackerd
- Date: Mon, 28 Apr 2008 14:55:15 +0100 (BST)
Author: jamiemcc
Date: Mon Apr 28 13:55:14 2008
New Revision: 1321
URL: http://svn.gnome.org/viewvc/tracker?rev=1321&view=rev
Log:
added dbus method GetUniqueValues to retrieve list of values for a metadata type
Modified:
trunk/ChangeLog
trunk/data/sqlite-stored-procs.sql
trunk/data/tracker-introspect.xml
trunk/src/libtracker/tracker.c
trunk/src/libtracker/tracker.h
trunk/src/trackerd/tracker-db-sqlite.c
trunk/src/trackerd/tracker-db-sqlite.h
trunk/src/trackerd/tracker-dbus-metadata.c
trunk/src/trackerd/tracker-dbus-metadata.h
trunk/src/trackerd/tracker-dbus.c
trunk/src/trackerd/tracker-dbus.h
trunk/src/trackerd/tracker-process-requests.c
Modified: trunk/data/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/sqlite-stored-procs.sql (original)
+++ trunk/data/sqlite-stored-procs.sql Mon Apr 28 13:55:14 2008
@@ -83,6 +83,10 @@
GetMetadata SELECT MetaDataDisplay FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ?;
GetMetadataNumeric SELECT MetaDataValue FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+GetMetadataKeywordValues SELECT DISTINCT MetaDataValue FROM ServiceKeywordMetaData WHERE MetaDataID = ? LIMIT ?,?;
+GetMetadataValues SELECT DISTINCT MetaDataDisplay FROM ServiceMetaData WHERE MetaDataID = ? LIMIT ?,?;
+GetMetadataNumericValues SELECT DISTINCT MetaDataValue FROM ServiceNumericMetaData WHERE MetaDataID = ? LIMIT ?,?;
+
SetMetadataKeyword INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
SetMetadata INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay) VALUES (?,?,?,?);
SetMetadataNumeric INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
Modified: trunk/data/tracker-introspect.xml
==============================================================================
--- trunk/data/tracker-introspect.xml (original)
+++ trunk/data/tracker-introspect.xml Mon Apr 28 13:55:14 2008
@@ -220,6 +220,14 @@
<arg type="as" name="result" direction="out" />
</method>
+ <!-- returns an array of all unique values of given metadata type -->
+ <method name="GetUniqueValues">
+ <arg type="s" name="meta_type" direction="in" />
+ <arg type="i" name="offset" direction="in" />
+ <arg type="i" name="max_hits" direction="in" />
+ <arg type="as" name="result" direction="out" />
+ </method>
+
<!-- signal emitted whenever metadata for a service entity is changed. The keys are the metadata names that have changed -->
<signal name="Changed">
<arg type="s" name="service"/>
Modified: trunk/src/libtracker/tracker.c
==============================================================================
--- trunk/src/libtracker/tracker.c (original)
+++ trunk/src/libtracker/tracker.c Mon Apr 28 13:55:14 2008
@@ -511,7 +511,17 @@
+char **
+tracker_metadata_get_unique_values (TrackerClient *client, const char *meta_type, int offset, int max_hits, GError **error)
+{
+ char **array = NULL;
+
+ if (!org_freedesktop_Tracker_Metadata_get_unique_values (client->proxy_metadata, meta_type, offset, max_hits, &array, &*error)) {
+ return NULL;
+ }
+ return array;
+}
GPtrArray *
@@ -1099,6 +1109,20 @@
+void
+tracker_metadata_get_unique_values_async (TrackerClient *client, const char *meta_type, int offset, int max_hits, TrackerArrayReply callback, gpointer user_data)
+{
+
+ ArrayCallBackStruct *callback_struct;
+
+ callback_struct = g_new (ArrayCallBackStruct, 1);
+ callback_struct->callback = callback;
+ callback_struct->data = user_data;
+
+ org_freedesktop_Tracker_Metadata_get_unique_values_async (client->proxy_search, meta_type, offset, max_hits, tracker_array_reply, callback_struct);
+
+}
+
Modified: trunk/src/libtracker/tracker.h
==============================================================================
--- trunk/src/libtracker/tracker.h (original)
+++ trunk/src/libtracker/tracker.h Mon Apr 28 13:55:14 2008
@@ -125,7 +125,7 @@
char ** tracker_metadata_get_registered_types (TrackerClient *client, const char *classname, GError **error);
char ** tracker_metadata_get_writeable_types (TrackerClient *client, const char *classname, GError **error);
char ** tracker_metadata_get_registered_classes (TrackerClient *client, GError **error);
-
+char ** tracker_metadata_get_unique_values (TrackerClient *client, const char *meta_type, int offset, int max_hits, GError **error);
GPtrArray * tracker_keywords_get_list (TrackerClient *client, ServiceType service, GError **error);
char ** tracker_keywords_get (TrackerClient *client, ServiceType service, const char *id, GError **error);
@@ -184,7 +184,7 @@
void tracker_metadata_get_registered_types_async (TrackerClient *client, const char *classname, TrackerArrayReply callback, gpointer user_data);
void tracker_metadata_get_writeable_types_async (TrackerClient *client, const char *classname, TrackerArrayReply callback, gpointer user_data);
void tracker_metadata_get_registered_classes_async (TrackerClient *client, TrackerArrayReply callback, gpointer user_data);
-
+void tracker_metadata_get_unique_values_async (TrackerClient *client, const char *meta_type, int offset, int max_hits, TrackerArrayReply callback, gpointer user_data);
void tracker_keywords_get_list_async (TrackerClient *client, ServiceType service, TrackerGPtrArrayReply callback, gpointer user_data);
void tracker_keywords_get_async (TrackerClient *client, ServiceType service, const char *id, TrackerArrayReply callback, gpointer user_data);
Modified: trunk/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- trunk/src/trackerd/tracker-db-sqlite.c (original)
+++ trunk/src/trackerd/tracker-db-sqlite.c Mon Apr 28 13:55:14 2008
@@ -2980,6 +2980,47 @@
}
+TrackerDBResultSet *
+tracker_db_get_unique_metadata_values (DBConnection *db_con, const char *meta_type, int offset, int limit)
+{
+ FieldDef *def;
+ char *str_offset, *str_limit;
+ TrackerDBResultSet *result_set;
+
+ g_return_val_if_fail ((meta_type), NULL);
+
+ def = tracker_db_get_field_def (db_con, meta_type);
+
+ if (!def) {
+ tracker_error ("ERROR: metadata not found for type %s", meta_type);
+ return NULL;
+ }
+
+ str_offset = tracker_int_to_str (offset);
+ str_limit = tracker_int_to_str (limit);
+
+ switch (def->type) {
+
+ case DATA_INDEX:
+ case DATA_STRING:
+ case DATA_DOUBLE:
+ result_set = tracker_exec_proc (db_con, "GetMetadataValues", def->id, str_offset, str_limit, NULL); break;
+
+ case DATA_INTEGER:
+ case DATA_DATE:
+ result_set = tracker_exec_proc (db_con, "GetMetadataNumericValues", def->id, str_offset, str_limit, NULL); break;
+
+ case DATA_KEYWORD:
+ result_set = tracker_exec_proc (db_con, "GetMetadataKeywordValues", def->id, str_offset, str_limit, NULL); break;
+
+ default: tracker_error ("ERROR: metadata could not be retrieved as type %d is not supported", def->type); result_set = NULL;
+ }
+
+ return result_set;
+
+}
+
+
static char *
remove_value (const char *str, const char *del_str)
{
Modified: trunk/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- trunk/src/trackerd/tracker-db-sqlite.h (original)
+++ trunk/src/trackerd/tracker-db-sqlite.h Mon Apr 28 13:55:14 2008
@@ -139,6 +139,8 @@
char * tracker_db_set_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values, int length, gboolean do_backup);
void tracker_db_set_single_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, gboolean do_backup);
+TrackerDBResultSet * tracker_db_get_unique_metadata_values (DBConnection *db_con, const char *meta_type, int offset, int limit);
+
void tracker_db_insert_embedded_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, char **values, int length, GHashTable *table);
void tracker_db_insert_single_embedded_metadata (DBConnection *db_con, const char *service, const char *id, const char *key, const char *value, GHashTable *table);
Modified: trunk/src/trackerd/tracker-dbus-metadata.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus-metadata.c (original)
+++ trunk/src/trackerd/tracker-dbus-metadata.c Mon Apr 28 13:55:14 2008
@@ -568,3 +568,62 @@
dbus_connection_send (rec->connection, reply, NULL);
dbus_message_unref (reply);
}
+
+
+void
+tracker_dbus_method_metadata_get_unique_values (DBusRec *rec)
+{
+ DBConnection *db_con;
+ DBusError dbus_error;
+ DBusMessage *reply;
+ gchar *meta_type;
+ gchar **array;
+ gint limit, offset;
+ int row_count;
+ TrackerDBResultSet *result_set;
+/*
+ <!-- returns an array of all unique values of given metadata type -->
+ <method name="GetUniqueValues">
+ <arg type="s" name="meta_type" direction="in" />
+ <arg type="i" name="offset" direction="in" />
+ <arg type="i" name="max_hits" direction="in" />
+ <arg type="as" name="result" direction="out" />
+ </method>
+*/
+
+ g_return_if_fail (rec && rec->user_data);
+
+ db_con = rec->user_data;
+
+ dbus_error_init (&dbus_error);
+ if (!dbus_message_get_args (rec->message, NULL,
+ DBUS_TYPE_STRING, &meta_type,
+ DBUS_TYPE_INT32, &offset,
+ DBUS_TYPE_INT32, &limit,
+ DBUS_TYPE_INVALID)) {
+ tracker_set_error (rec, "DBusError: %s;%s", dbus_error.name, dbus_error.message);
+ dbus_error_free (&dbus_error);
+ return;
+ }
+
+ result_set = tracker_db_get_unique_metadata_values (db_con, meta_type, offset, limit);
+
+ array = NULL;
+ row_count = 0;
+
+ if (result_set) {
+ array = tracker_get_query_result_as_array (result_set, &row_count);
+ g_object_unref (result_set);
+ }
+
+ reply = dbus_message_new_method_return (rec->message);
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &array, row_count,
+ DBUS_TYPE_INVALID);
+
+ tracker_free_array (array, row_count);
+
+ dbus_connection_send (rec->connection, reply, NULL);
+ dbus_message_unref (reply);
+}
Modified: trunk/src/trackerd/tracker-dbus-metadata.h
==============================================================================
--- trunk/src/trackerd/tracker-dbus-metadata.h (original)
+++ trunk/src/trackerd/tracker-dbus-metadata.h Mon Apr 28 13:55:14 2008
@@ -33,4 +33,6 @@
void tracker_dbus_method_metadata_get_writeable_types (DBusRec *rec);
void tracker_dbus_method_metadata_get_registered_classes (DBusRec *rec);
+void tracker_dbus_method_metadata_get_unique_values (DBusRec *rec);
+
#endif
Modified: trunk/src/trackerd/tracker-dbus.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus.c (original)
+++ trunk/src/trackerd/tracker-dbus.c Mon Apr 28 13:55:14 2008
@@ -445,6 +445,13 @@
+ } else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_METADATA, TRACKER_METHOD_METADATA_GET_UNIQUE_VALUES)) {
+
+ dbus_message_ref (message);
+ rec->action = DBUS_ACTION_METADATA_GET_UNIQUE_VALUES;
+
+
+
} else if (dbus_message_is_method_call (message, TRACKER_INTERFACE_KEYWORDS, TRACKER_METHOD_KEYWORDS_GET_LIST)) {
dbus_message_ref (message);
Modified: trunk/src/trackerd/tracker-dbus.h
==============================================================================
--- trunk/src/trackerd/tracker-dbus.h (original)
+++ trunk/src/trackerd/tracker-dbus.h Mon Apr 28 13:55:14 2008
@@ -59,6 +59,7 @@
#define TRACKER_METHOD_METADATA_GET_REGISTERED_TYPES "GetRegisteredTypes"
#define TRACKER_METHOD_METADATA_GET_WRITEABLE_TYPES "GetWriteableTypes"
#define TRACKER_METHOD_METADATA_GET_REGISTERED_CLASSES "GetRegisteredClasses"
+#define TRACKER_METHOD_METADATA_GET_UNIQUE_VALUES "GetUniqueValues"
/* keywords interface */
#define TRACKER_METHOD_KEYWORDS_GET_LIST "GetList"
@@ -130,6 +131,7 @@
DBUS_ACTION_METADATA_GET_REGISTERED_TYPES,
DBUS_ACTION_METADATA_GET_WRITEABLE_TYPES,
DBUS_ACTION_METADATA_GET_REGISTERED_CLASSES,
+ DBUS_ACTION_METADATA_GET_UNIQUE_VALUES,
DBUS_ACTION_KEYWORDS_GET_LIST,
DBUS_ACTION_KEYWORDS_GET,
Modified: trunk/src/trackerd/tracker-process-requests.c
==============================================================================
--- trunk/src/trackerd/tracker-process-requests.c (original)
+++ trunk/src/trackerd/tracker-process-requests.c Mon Apr 28 13:55:14 2008
@@ -206,7 +206,11 @@
case DBUS_ACTION_METADATA_GET_REGISTERED_CLASSES:
tracker_dbus_method_metadata_get_registered_classes (rec);
break;
-
+
+ case DBUS_ACTION_METADATA_GET_UNIQUE_VALUES:
+ tracker_dbus_method_metadata_get_unique_values (rec);
+ break;
+
case DBUS_ACTION_KEYWORDS_GET_LIST:
tracker->request_waiting = TRUE;
tracker->grace_period = 2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]