New updated patch for application indexing.
* $XDG_DATA_DIRS and $XDG_DATA_HOME (or deafult vaules) are used to set
Service directories.
* Categories is now of keyword type. Still need's to be splited into
multiple values though.
* desktop entries with Hidden=true are ignored.
* moved to new files, tracker-apps.h/c .
best regards
/Marcus
Index: src/trackerd/tracker-apps.h
===================================================================
--- src/trackerd/tracker-apps.h (revision 0)
+++ src/trackerd/tracker-apps.h (revision 0)
@@ -0,0 +1,33 @@
+/* Tracker
+ * routines for applications
+ * Copyright (C) 2007, Marcus Rosell ([EMAIL PROTECTED])
+ *
+ * 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_APPS_H_
+#define _TRACKER_APPS_H_
+
+#include "tracker-utils.h"
+
+#include "config.h"
+
+#include "tracker-db-sqlite.h"
+
+void tracker_applications_add_service_directories(void);
+void tracker_db_index_application (DBConnection *db_con, FileInfo *info);
+
+#endif
Index: src/trackerd/tracker-metadata.c
===================================================================
--- src/trackerd/tracker-metadata.c (revision 514)
+++ src/trackerd/tracker-metadata.c (working copy)
@@ -138,9 +138,6 @@
"text/x-tcl"
};
-
-
-
static MetadataFileType
tracker_get_metadata_type (const char *mime)
{
Index: src/trackerd/trackerd.c
===================================================================
--- src/trackerd/trackerd.c (revision 514)
+++ src/trackerd/trackerd.c (working copy)
@@ -61,6 +61,7 @@
#include "tracker-dbus-files.h"
#include "tracker-email.h"
#include "tracker-indexer.h"
+#include "tracker-apps.h"
Tracker *tracker;
DBConnection *main_thread_db_con;
@@ -932,6 +933,7 @@
if (tracker->enable_indexing) {
tracker_email_add_service_directories (db_con->emails);
+ tracker_applications_add_service_directories();
tracker->status = STATUS_WATCHING;
Index: src/trackerd/tracker-db.c
===================================================================
--- src/trackerd/tracker-db.c (revision 514)
+++ src/trackerd/tracker-db.c (working copy)
@@ -22,11 +22,14 @@
#include <time.h>
#include <glib/gstdio.h>
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
#include "tracker-db.h"
#include "tracker-email.h"
#include "tracker-metadata.h"
+#include "tracker-apps.h"
-
extern Tracker *tracker;
@@ -1029,11 +1032,3 @@
}
-void
-tracker_db_index_application (DBConnection *db_con, FileInfo *info)
-{
-
-/* todo */
-}
-
-
Index: src/trackerd/Makefile.am
===================================================================
--- src/trackerd/Makefile.am (revision 514)
+++ src/trackerd/Makefile.am (working copy)
@@ -78,6 +78,8 @@
$(fam_sources) \
$(qdbm_sources) \
$(db_sources) \
+ tracker-apps.c \
+ tracker-apps.h \
tracker-db.c \
tracker-db.h \
tracker-dbus.c \
Index: src/trackerd/tracker-utils.c
===================================================================
--- src/trackerd/tracker-utils.c (revision 514)
+++ src/trackerd/tracker-utils.c (working copy)
@@ -102,7 +102,6 @@
return g_strdup (def->parent);
}
-
int
tracker_get_id_for_service (const char *service)
{
Index: src/trackerd/tracker-apps.c
===================================================================
--- src/trackerd/tracker-apps.c (revision 0)
+++ src/trackerd/tracker-apps.c (revision 0)
@@ -0,0 +1,189 @@
+/* Tracker
+ * routines for applications
+ * Copyright (C) 2007, Marcus Rosell ([EMAIL PROTECTED])
+ *
+ * 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 "tracker-apps.h"
+#include "tracker-db.h"
+
+/* Sets up service directories for application indexing
+ TODO: configuration to switch application indexing ON/OFF ?
+*/
+
+void
+tracker_applications_add_service_directories(void)
+{
+ if (1) { /* TODO: configurable.. tracker->index_applications? */
+
+ char *value;
+ gchar *dir = NULL;
+
+ value = getenv("XDG_DATA_HOME");
+ if (value != NULL) {
+ dir = g_strdup_printf("%s/applications", value);
+ }
+ else {
+ char *home;
+ home = getenv("HOME");
+ if (home != NULL) {
+ dir = g_strdup_printf("%s/.local/share/applications", home);
+ }
+ }
+
+ /* Add user defined applications path to service directory list */
+ if (dir != NULL)
+ {
+ tracker_log ("Registering path %s as belonging to service Applications", dir);
+ tracker_add_service_path("Applications", dir);
+ g_free(dir);
+ }
+
+ /* Add system defined applications path to service directory list */
+ value = getenv("XDG_DATA_DIRS");
+ if (value != NULL) {
+ gchar **dir_array;
+ dir_array = g_strsplit (value, ":", 0);
+
+ gint i;
+ for (i = 0; dir_array[i] != NULL; ++i) {
+ dir = g_strdup_printf("%s/applications", dir_array[i]);
+ tracker_log ("Registering path %s as belonging to service Applications", dir);
+ tracker_add_service_path("Applications", dir);
+ g_free(dir);
+ }
+ g_strfreev(dir_array);
+ }
+ else {
+ tracker_log ("Registering path %s as belonging to service Applications", "/usr/local/share/applications");
+ tracker_log ("Registering path %s as belonging to service Applications", "/usr/share/applications");
+ tracker_add_service_path("Applications", "/usr/local/share/applications");
+ tracker_add_service_path("Applications", "/usr/share/applications");
+ }
+ }
+}
+
+
+void
+tracker_db_index_application (DBConnection *db_con, FileInfo *info)
+{
+ /* Index application metadata from .desktop files */
+
+ GHashTable *meta_table;
+
+ GError *error = NULL;
+ GKeyFile *key_file = NULL;
+
+ gchar *type = NULL;
+ gchar *hidden = NULL;
+ gchar *tmp_str = NULL;
+ gchar desktop_entry[] = { "Desktop Entry" };
+
+ /* Check (to be sure) if this is a .desktop file */
+ if (g_str_has_suffix (info->uri, ".desktop") == FALSE)
+ return;
+
+ const gchar * const *locale_array;
+ locale_array = g_get_language_names();
+
+ key_file = g_key_file_new();
+
+ if ( g_key_file_load_from_file( key_file, info->uri, G_KEY_FILE_NONE, &error) == TRUE) {
+
+ type = g_key_file_get_string(key_file, desktop_entry, "Type", NULL);
+ hidden = g_key_file_get_string(key_file, desktop_entry, "Hidden", NULL);
+
+ /* We're only interested in (non deleted) apps */
+ gboolean do_entry = TRUE;
+ if (type == NULL)
+ do_entry = FALSE;
+ else if(strcmp(type, "Application") != 0 )
+ do_entry = FALSE;
+
+ if (hidden != NULL) {
+ if(g_ascii_strcasecmp(hidden, "true") == 0 )
+ do_entry = FALSE;
+ }
+
+ if (do_entry == TRUE) {
+
+ meta_table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
+
+ g_hash_table_insert (meta_table, "App:LocaleName", g_strdup(locale_array[0]));
+
+ if((tmp_str = g_key_file_get_locale_string(
+ key_file,
+ desktop_entry,
+ "Name",
+ locale_array[0],
+ NULL)) != NULL) {
+
+ g_hash_table_insert (meta_table, "App:Name", tmp_str);
+ }
+
+ if((tmp_str = g_key_file_get_locale_string(
+ key_file,
+ desktop_entry,
+ "GenericName",
+ locale_array[0],
+ NULL)) != NULL) {
+
+ g_hash_table_insert (meta_table, "App:GenericName", tmp_str);
+ }
+
+ if((tmp_str = g_key_file_get_locale_string(
+ key_file,
+ desktop_entry,
+ "Comment",
+ locale_array[0],
+ NULL)) != NULL) {
+
+ g_hash_table_insert (meta_table, "App:Comment", tmp_str);
+ }
+
+ if((tmp_str = g_key_file_get_locale_string(
+ key_file,
+ desktop_entry,
+ "Categories",
+ locale_array[0],
+ NULL)) != NULL) {
+
+ g_hash_table_insert (meta_table, "App:Categories", tmp_str);
+ }
+
+ if((tmp_str = g_key_file_get_locale_string(
+ key_file,
+ desktop_entry,
+ "Exec",
+ locale_array[0],
+ NULL)) != NULL) {
+
+ g_hash_table_insert (meta_table, "App:Exec", tmp_str);
+ }
+
+ tracker_db_index_service (db_con, info, "Applications", meta_table, NULL, FALSE, TRUE, FALSE, FALSE);
+
+ g_hash_table_destroy (meta_table);
+ }
+
+ g_key_file_free(key_file);
+ g_free(type);
+ }
+}
+
Index: src/tracker-extract/tracker-extract.c
===================================================================
--- src/tracker-extract/tracker-extract.c (revision 514)
+++ src/tracker-extract/tracker-extract.c (working copy)
@@ -134,6 +134,7 @@
{ "image/jpeg", tracker_extract_exif },
#endif
{ "image/*", tracker_extract_imagemagick },
+
{ "", NULL }
};
Index: data/sqlite-service-types.sql
===================================================================
--- data/sqlite-service-types.sql (revision 514)
+++ data/sqlite-service-types.sql (working copy)
@@ -56,4 +56,5 @@
insert Into ServiceTypes (TypeID, MinID, MaxID, TypeClass, TypeName, Description, MainService) values (41,41,41, 'Conversations', 'GaimConversations', 'Gaim Conversations', 0);
insert Into ServiceTypes (TypeID, MinID, MaxID, TypeClass, TypeName, Description, MainService) values (42,42,42, 'Conversations', 'XChatConversations', 'XChat Conversations', 0);
+
insert Into ServiceTypes (TypeID, MinID, MaxID, TypeClass, TypeName, Description, MainService) values (50,50,50, 'Applications', 'Applications', 'Applications', 1);
Index: data/sqlite-metadata.sql
===================================================================
--- data/sqlite-metadata.sql (revision 514)
+++ data/sqlite-metadata.sql (working copy)
@@ -202,4 +202,18 @@
insert Into MetaDataChildren (MetaDataID, ChildID) select P.ID, C.ID from MetaDataTypes P, MetaDataTypes C where P.MetaName = 'Email:Recipient' and C.MetaName = 'Email:SentTo';
insert Into MetaDataChildren (MetaDataID, ChildID) select P.ID, C.ID from MetaDataTypes P, MetaDataTypes C where P.MetaName = 'Email:Recipient' and C.MetaName = 'Email:CC';
+/* Application metadata */
+
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:Name', 0, 0, 20);
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:GenericName', 0, 0, 15);
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:Comment', 0, 0, 10);
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:Exec', 0, 0, 10);
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:Categories', 5, 0, 1);
+insert Into MetaDataTypes (MetaName, DatatypeID, MultipleValues, Weight) values ('App:LocaleName', 0, 0, 0);
+
+insert Into MetaDataChildren (MetaDataID, ChildID) select P.ID, C.ID from MetaDataTypes P, MetaDataTypes C where P.MetaName = 'DC:Title' and C.MetaName = 'App:Name';
+insert Into MetaDataChildren (MetaDataID, ChildID) select P.ID, C.ID from MetaDataTypes P, MetaDataTypes C where P.MetaName = 'DC:Description' and C.MetaName = 'App:GenericName';
+insert Into MetaDataChildren (MetaDataID, ChildID) select P.ID, C.ID from MetaDataTypes P, MetaDataTypes C where P.MetaName = 'DC:Comments' and C.MetaName = 'App:Comment';
+
+
end transaction;
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list