Commit 6cbd12cb authored by Carlos Garnacho's avatar Carlos Garnacho

Merge branch 'wip/carlosg/apps-in-miner-fs' into 'master'

Fold miner-apps into tracker-miner-fs

See merge request !33
parents 5df888dd 8920540b
Pipeline #40463 passed with stage
in 1 minute and 26 seconds
......@@ -104,7 +104,6 @@ libmath = cc.find_library('m', required: false)
uuid = cc.find_library('uuid')
have_tracker_extract = get_option('extract')
have_tracker_miner_apps = get_option('miner_apps')
have_tracker_miner_fs = get_option('miner_fs')
have_tracker_miner_rss = get_option('miner_rss')
have_tracker_writeback = get_option('writeback')
......@@ -409,7 +408,6 @@ summary = [
' Build with Journal support: ' + get_option('journal').to_string(),
'\nData Miners / Writebacks:',
' FS (File System): ' + have_tracker_miner_fs.to_string(),
' Applications: ' + have_tracker_miner_apps.to_string(),
' RSS: ' + have_tracker_miner_rss.to_string(),
' Extract (secondary extraction): ' + have_tracker_extract.to_string(),
' Writeback (writing changes back): ' + have_tracker_writeback.to_string(),
......
......@@ -11,8 +11,6 @@ option('guarantee_metadata', type: 'boolean', value: true,
description: 'Set nie:title and nie:contentCreated from filename and mtime if no metadata available')
option('journal', type: 'boolean', value: true,
description: 'Enable database journal backup mechanism')
option('miner_apps', type: 'boolean', value: true,
description: 'Enable the Tracker applications miner')
option('miner_fs', type: 'boolean', value: true,
description: 'Enable the Tracker filesystem miner')
option('miner_rss', type: 'boolean', value: true,
......
......@@ -2,9 +2,6 @@
# Please keep this file sorted alphabetically.
src/libtracker-miners-common/tracker-dbus.c
src/libtracker-miners-common/tracker-utils.c
src/miners/apps/org.freedesktop.Tracker1.Miner.Applications.service.in.in
src/miners/apps/tracker-main.c
src/miners/apps/tracker-miner-apps.desktop.in.in
src/miners/fs/org.freedesktop.Tracker1.Miner.Files.service.in.in
src/miners/fs/org.freedesktop.Tracker.Miner.Files.gschema.xml.in
src/miners/fs/tracker-main.c
......
......@@ -8,14 +8,10 @@ set -e
dbus_services_dir="$1"
tracker_miner_services_dir="$2"
have_tracker_miner_apps="$3"
have_tracker_miner_fs="$4"
have_tracker_miner_rss="$5"
have_tracker_miner_fs="$3"
have_tracker_miner_rss="$4"
mkdir -p ${DESTDIR}/${tracker_miner_services_dir}
if [[ "$have_tracker_miner_apps" -eq "true" ]]; then
ln -sf "${dbus_services_dir}/org.freedesktop.Tracker1.Miner.Applications.service" "${DESTDIR}/${tracker_miner_services_dir}/"
fi
ln -sf "${dbus_services_dir}/org.freedesktop.Tracker1.Miner.Extract.service" "${DESTDIR}/${tracker_miner_services_dir}/"
if [[ "$have_tracker_miner_fs" -eq "true" ]]; then
ln -sf "${dbus_services_dir}/org.freedesktop.Tracker1.Miner.Files.service" "${DESTDIR}/${tracker_miner_services_dir}/"
......
......@@ -31,4 +31,4 @@ custom_target('tracker-miners-settings-enums',
install: true,
install_dir: gsettings_schema_dir)
meson.add_install_script('create-miner-symlinks.sh', dbus_services_dir, tracker_miner_services_dir, have_tracker_miner_apps.to_string(), have_tracker_miner_fs.to_string(), have_tracker_miner_rss.to_string())
meson.add_install_script('create-miner-symlinks.sh', dbus_services_dir, tracker_miner_services_dir, have_tracker_miner_fs.to_string(), have_tracker_miner_rss.to_string())
tracker-miner-apps
*.service
sources = [
'tracker-main.c',
'tracker-miner-applications.c',
]
executable('tracker-miner-apps', sources,
dependencies: [tracker_miner, tracker_sparql, tracker_miners_common_dep],
c_args: tracker_c_args,
install: true,
install_dir: get_option('libexecdir'),
install_rpath: tracker_internal_libs_dir,
)
dbus_service_file_untranslated = configure_file(
input: 'org.freedesktop.Tracker1.Miner.Applications.service.in.in',
output: 'org.freedesktop.Tracker1.Miner.Applications.service.in',
configuration: conf)
dbus_service_file = custom_target('tracker-miner-apps-dbus-service-file',
input: dbus_service_file_untranslated,
output: 'org.freedesktop.Tracker1.Miner.Applications.service',
command: ['intltool-merge', '--quiet', '--desktop-style', '--utf8', join_paths(meson.source_root(), 'po'), '@INPUT@', '@OUTPUT@'],
install: true,
install_dir: dbus_services_dir)
desktop_file_untranslated = configure_file(
input: 'tracker-miner-apps.desktop.in.in',
output: 'tracker-miner-apps.desktop.in',
configuration: conf)
desktop_file = custom_target('tracker-miner-apps-desktop-file',
input: desktop_file_untranslated,
output: 'tracker-miner-apps.desktop',
command: ['intltool-merge', '--quiet', '--desktop-style', '--utf8', join_paths(meson.source_root(), 'po'), '@INPUT@', '@OUTPUT@'],
install: true,
install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
if install_systemd_user_services
configure_file(
input: 'tracker-miner-apps.service.in',
output: 'tracker-miner-apps.service',
configuration: conf,
install: true,
install_dir: systemd_user_services_dir)
endif
[D-BUS Service]
Name=org.freedesktop.Tracker1.Miner.Applications
Exec=@libexecdir@/tracker-miner-apps
SystemdService=tracker-miner-apps.service
# Miner details needed for tracker-control
Path=/org/freedesktop/Tracker1/Miner/Applications
NameSuffix=Miner.Applications
_DisplayName=Applications
_Comment=Applications data miner
/*
* Copyright (C) 2014, Lanedo GmbH. <martyn@lanedo.com>
* 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 "config.h"
#include <stdlib.h>
#include <locale.h>
#include <errno.h>
#include <glib.h>
#include <glib-unix.h>
#include <glib-object.h>
#include <glib/gi18n.h>
#include <libtracker-miners-common/tracker-common.h>
#include <libtracker-miner/tracker-miner.h>
#include "tracker-miner-applications.h"
#define ABOUT \
"Tracker " PACKAGE_VERSION "\n"
#define LICENSE \
"This program is free software and comes without any warranty.\n" \
"It is licensed under version 2 or later of the General Public " \
"License which can be viewed at:\n" \
"\n" \
" http://www.gnu.org/licenses/gpl.txt\n"
#define DBUS_NAME_SUFFIX "Tracker1.Miner.Applications"
#define DBUS_PATH "/org/freedesktop/Tracker1/Miner/Applications"
static GMainLoop *main_loop;
static gint verbosity = -1;
static gboolean no_daemon;
static gboolean version;
static gchar *domain_ontology_name = NULL;
static GOptionEntry entries[] = {
{ "verbosity", 'v', 0,
G_OPTION_ARG_INT, &verbosity,
N_("Logging, 0 = errors only, "
"1 = minimal, 2 = detailed and 3 = debug (default=0)"),
NULL },
{ "no-daemon", 'n', 0,
G_OPTION_ARG_NONE, &no_daemon,
N_("Runs until all applications are indexed and then exits"),
NULL },
{ "domain-ontology", 'd', 0,
G_OPTION_ARG_STRING, &domain_ontology_name,
N_("Runs for a specific domain ontology"),
NULL },
{ "version", 'V', 0,
G_OPTION_ARG_NONE, &version,
N_("Displays version information"),
NULL },
{ NULL }
};
static gboolean
signal_handler (gpointer user_data)
{
int signo = GPOINTER_TO_INT (user_data);
static gboolean in_loop = FALSE;
/* Die if we get re-entrant signals handler calls */
if (in_loop) {
_exit (EXIT_FAILURE);
}
switch (signo) {
case SIGTERM:
case SIGINT:
in_loop = TRUE;
g_main_loop_quit (main_loop);
/* Fall through */
default:
if (g_strsignal (signo)) {
g_print ("\n");
g_print ("Received signal:%d->'%s'\n",
signo,
g_strsignal (signo));
}
break;
}
return G_SOURCE_CONTINUE;
}
static void
initialize_signal_handler (void)
{
#ifndef G_OS_WIN32
g_unix_signal_add (SIGTERM, signal_handler, GINT_TO_POINTER (SIGTERM));
g_unix_signal_add (SIGINT, signal_handler, GINT_TO_POINTER (SIGINT));
#endif /* G_OS_WIN32 */
}
static void
initialize_priority_and_scheduling (TrackerSchedIdle sched_idle,
gboolean first_time_index)
{
/* Set CPU priority */
if (sched_idle == TRACKER_SCHED_IDLE_ALWAYS ||
(sched_idle == TRACKER_SCHED_IDLE_FIRST_INDEX && first_time_index)) {
tracker_sched_idle ();
}
/* Set disk IO priority and scheduling */
tracker_ioprio_init ();
/* Set process priority:
* The nice() function uses attribute "warn_unused_result" and
* so complains if we do not check its returned value. But it
* seems that since glibc 2.2.4, nice() can return -1 on a
* successful call so we have to check value of errno too.
* Stupid...
*/
g_message ("Setting priority nice level to 19");
errno = 0;
if (nice (19) == -1 && errno != 0) {
const gchar *str = g_strerror (errno);
g_message ("Couldn't set nice value to 19, %s",
str ? str : "no error given");
}
}
static void
miner_finished_cb (TrackerMinerFS *fs,
gdouble seconds_elapsed,
guint total_directories_found,
guint total_directories_ignored,
guint total_files_found,
guint total_files_ignored,
gpointer user_data)
{
g_info ("Finished mining in seconds:%f, total directories:%d, total files:%d",
seconds_elapsed,
total_directories_found,
total_files_found);
if (no_daemon && main_loop) {
g_main_loop_quit (main_loop);
}
}
static void
on_domain_vanished (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
GMainLoop *loop = user_data;
g_main_loop_quit (loop);
}
int
main (gint argc, gchar *argv[])
{
TrackerMiner *miner_applications;
GOptionContext *context;
GError *error = NULL;
gchar *log_filename = NULL;
GDBusConnection *connection;
TrackerMinerProxy *proxy;
TrackerDomainOntology *domain_ontology;
gchar *domain_name, *dbus_name;
main_loop = NULL;
setlocale (LC_ALL, "");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
/* Set timezone info */
tzset ();
/* Translators: this messagge will apper immediately after the
* usage string - Usage: COMMAND <THIS_MESSAGE>
*/
context = g_option_context_new (_("— start the application data miner"));
g_option_context_add_main_entries (context, entries, NULL);
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
if (error) {
g_printerr ("%s\n", error->message);
g_error_free (error);
return EXIT_FAILURE;
}
if (version) {
g_print ("\n" ABOUT "\n" LICENSE "\n");
return EXIT_SUCCESS;
}
tracker_sparql_connection_set_domain (domain_ontology_name);
domain_ontology = tracker_domain_ontology_new (domain_ontology_name, NULL, &error);
if (error) {
g_critical ("Could not load domain ontology '%s': %s",
domain_ontology_name, error->message);
g_error_free (error);
return EXIT_FAILURE;
}
connection = g_bus_get_sync (TRACKER_IPC_BUS, NULL, &error);
if (error) {
g_critical ("Could not create DBus connection: %s\n",
error->message);
g_error_free (error);
return EXIT_FAILURE;
}
tracker_log_init (verbosity, &log_filename);
if (log_filename) {
g_message ("Using log file:'%s'", log_filename);
g_free (log_filename);
}
/* This makes sure we don't steal all the system's resources */
initialize_priority_and_scheduling (TRACKER_SCHED_IDLE_ALWAYS, FALSE);
main_loop = g_main_loop_new (NULL, FALSE);
if (domain_ontology && domain_ontology_name) {
/* If we are running for a specific domain, we tie the lifetime of this
* process to the domain. For example, if the domain name is
* org.example.MyApp then this tracker-miner-apps process will exit as
* soon as org.example.MyApp exits.
*/
domain_name = tracker_domain_ontology_get_domain (domain_ontology, NULL);
g_bus_watch_name_on_connection (connection, domain_name,
G_BUS_NAME_WATCHER_FLAGS_NONE,
NULL, on_domain_vanished,
main_loop, NULL);
g_free (domain_name);
}
g_message ("Checking if we're running as a daemon:");
g_message (" %s %s",
no_daemon ? "No" : "Yes",
no_daemon ? "(forced by command line)" : "");
/* Create miner for applications */
miner_applications = tracker_miner_applications_new (&error);
if (!miner_applications) {
g_critical ("Couldn't create new applications miner, '%s'",
error ? error->message : "unknown error");
tracker_log_shutdown ();
return EXIT_FAILURE;
}
proxy = tracker_miner_proxy_new (miner_applications, connection, DBUS_PATH, NULL, &error);
if (!proxy) {
g_critical ("Couldn't create miner DBus proxy: %s", error->message);
g_error_free (error);
tracker_log_shutdown ();
return EXIT_FAILURE;
}
g_signal_connect (miner_applications, "finished",
G_CALLBACK (miner_finished_cb),
NULL);
/* Request DBus name */
dbus_name = tracker_domain_ontology_get_domain (domain_ontology, DBUS_NAME_SUFFIX);
if (!tracker_dbus_request_name (connection, dbus_name, &error)) {
g_critical ("Could not request DBus name '%s': %s",
dbus_name, error->message);
g_error_free (error);
g_free (dbus_name);
return EXIT_FAILURE;
}
g_free (dbus_name);
initialize_signal_handler ();
/* Go, go, go! */
tracker_miner_start (miner_applications);
g_main_loop_run (main_loop);
g_message ("Shutdown started");
g_main_loop_unref (main_loop);
g_object_unref (G_OBJECT (miner_applications));
g_object_unref (connection);
g_object_unref (proxy);
g_object_unref (domain_ontology);
tracker_log_shutdown ();
g_print ("\nOK\n\n");
return EXIT_SUCCESS;
}
This diff is collapsed.
/*
* Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
*
* 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_MINER_FS_APPLICATIONS_H__
#define __TRACKER_MINER_FS_APPLICATIONS_H__
#include <libtracker-miner/tracker-miner.h>
G_BEGIN_DECLS
#define TRACKER_TYPE_MINER_APPLICATIONS (tracker_miner_applications_get_type())
#define TRACKER_MINER_APPLICATIONS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_MINER_APPLICATIONS, TrackerMinerApplications))
#define TRACKER_MINER_APPLICATIONS_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_MINER_APPLICATIONS, TrackerMinerApplicationsClass))
#define TRACKER_IS_MINER_APPLICATIONS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_MINER_APPLICATIONS))
#define TRACKER_IS_MINER_APPLICATIONS_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_MINER_APPLICATIONS))
#define TRACKER_MINER_APPLICATIONS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_MINER_APPLICATIONS, TrackerMinerApplicationsClass))
typedef struct _TrackerMinerApplications TrackerMinerApplications;
typedef struct _TrackerMinerApplicationsClass TrackerMinerApplicationsClass;
struct _TrackerMinerApplications {
TrackerMinerFS parent_instance;
gpointer locale_notification_id;
};
struct _TrackerMinerApplicationsClass {
TrackerMinerFSClass parent_class;
};
GType tracker_miner_applications_get_type (void) G_GNUC_CONST;
TrackerMiner *tracker_miner_applications_new (GError **error);
gboolean tracker_miner_applications_detect_locale_changed (TrackerMiner *miner);
G_END_DECLS
#endif /* __TRACKER_MINER_FS_APPLICATIONS_H__ */
[Desktop Entry]
_Name=Tracker Application Miner
_Comment=Indexes information about applications installed
Icon=
Exec=@libexecdir@/tracker-miner-apps
Terminal=false
Type=Application
Categories=Utility;
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-UniqueApplet=true
NoDisplay=true
OnlyShowIn=GNOME;KDE;XFCE;X-IVI;Unity;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=tracker
X-GNOME-Bugzilla-Component=Miners
X-GNOME-Bugzilla-Version=@VERSION@
[Unit]
Description=Tracker applications data miner
[Service]
Type=dbus
BusName=org.freedesktop.Tracker1.Miner.Applications
ExecStart=@libexecdir@/tracker-miner-apps
Restart=on-failure
# Don't restart after tracker daemon -k (aka tracker-control -k)
RestartPreventExitStatus=SIGKILL
......@@ -144,7 +144,7 @@ Boston, MA 02110-1301, USA.
<key name="ignored-files" type="as">
<_summary>Ignored files</_summary>
<_description>List of file patterns to avoid</_description>
<default>[ '*~', '*.o', '*.la', '*.lo' , '*.loT', '*.in', '*.csproj', '*.m4', '*.rej', '*.gmo', '*.orig', '*.pc', '*.omf', '*.aux', '*.tmp', '*.vmdk', '*.vm*', '*.nvram', '*.part', '*.rcore', '*.lzo', 'autom4te', 'conftest', 'confstat', 'Makefile', 'SCCS', 'ltmain.sh', 'libtool', 'config.status', 'confdefs.h', 'configure', '#*#', '~$*.doc?', '~$*.dot?', '~$*.xls?', '~$*.xlt?', '~$*.xlam', '~$*.ppt?', '~$*.pot?', '~$*.ppam', '~$*.ppsm', '~$*.ppsx', '~$*.vsd?', '~$*.vss?', '~$*.vst?', '*.desktop', '*.directory' ]</default>
<default>[ '*~', '*.o', '*.la', '*.lo' , '*.loT', '*.in', '*.csproj', '*.m4', '*.rej', '*.gmo', '*.orig', '*.pc', '*.omf', '*.aux', '*.tmp', '*.vmdk', '*.vm*', '*.nvram', '*.part', '*.rcore', '*.lzo', 'autom4te', 'conftest', 'confstat', 'Makefile', 'SCCS', 'ltmain.sh', 'libtool', 'config.status', 'confdefs.h', 'configure', '#*#', '~$*.doc?', '~$*.dot?', '~$*.xls?', '~$*.xlt?', '~$*.xlam', '~$*.ppt?', '~$*.pot?', '~$*.ppam', '~$*.ppsm', '~$*.ppsx', '~$*.vsd?', '~$*.vss?', '~$*.vst?', 'mimeapps.list', 'mimeinfo.cache', '*.directory' ]</default>
</key>
<key name="ignored-directories" type="as">
......
......@@ -54,6 +54,7 @@
#define DBUS_NAME_SUFFIX "Tracker1.Miner.Files"
#define DBUS_PATH "/org/freedesktop/Tracker1/Miner/Files"
#define LOCALE_FILENAME "locale-for-miner-apps.txt"
static GMainLoop *main_loop;
......@@ -122,6 +123,112 @@ sanity_check_option_values (TrackerConfig *config)
}
}
static void
miner_reset_applications (TrackerMiner *miner)
{
const gchar *sparql;
GError *error = NULL;
sparql =
"DELETE { GRAPH <" TRACKER_OWN_GRAPH_URN "> { ?icon a rdfs:Resource } } "
"WHERE { GRAPH <" TRACKER_OWN_GRAPH_URN "> { ?app a nfo:SoftwareApplication; nfo:softwareIcon ?icon } } "
"DELETE { GRAPH <" TRACKER_OWN_GRAPH_URN "> { ?app nie:dataSource <" TRACKER_PREFIX_TRACKER "extractor-data-source> } "
"WHERE { GRAPH <" TRACKER_OWN_GRAPH_URN "> { ?app a nfo:SoftwareApplication } ";
/* Execute a sync update, we don't want the apps miner to start before
* we finish this. */
tracker_sparql_connection_update (tracker_miner_get_connection (miner),
sparql, G_PRIORITY_HIGH,
NULL, &error);
if (error) {
/* Some error happened performing the query, not good */
g_critical ("Couldn't reset indexed applications: %s",
error ? error->message : "unknown error");
g_error_free (error);
}
}
static void
save_current_locale (void)
{
GError *error = NULL;
gchar *locale = tracker_locale_get (TRACKER_LOCALE_LANGUAGE);
gchar *locale_file = g_build_filename (g_get_user_cache_dir (), "tracker", LOCALE_FILENAME, NULL);
g_message ("Saving locale used to index applications");
g_message (" Creating locale file '%s'", locale_file);
if (locale == NULL) {
locale = g_strdup ("");
}
if (!g_file_set_contents (locale_file, locale, -1, &error)) {
g_message (" Could not set file contents, %s",
error ? error->message : "no error given");
g_clear_error (&error);
}
g_free (locale);
g_free (locale_file);
}
static gboolean
detect_locale_changed (TrackerMiner *miner)
{
gchar *locale_file;
gchar *previous_locale = NULL;
gchar *current_locale;
gboolean changed;
locale_file = g_build_filename (g_get_user_cache_dir (), "tracker", LOCALE_FILENAME, NULL);
if (G_LIKELY (g_file_test (locale_file, G_FILE_TEST_EXISTS))) {
gchar *contents;
/* Check locale is correct */
if (G_LIKELY (g_file_get_contents (locale_file, &contents, NULL, NULL))) {
if (contents &&
contents[0] == '\0') {
g_critical (" Empty locale file found at '%s'", locale_file);
g_free (contents);
} else {
/* Re-use contents */
previous_locale = contents;
}
} else {
g_critical (" Could not get content of file '%s'", locale_file);
}
} else {
g_message (" Could not find locale file:'%s'", locale_file);
}
g_free (locale_file);
current_locale = tracker_locale_get (TRACKER_LOCALE_LANGUAGE);
/* Note that having both to NULL is actually valid, they would default
* to the unicode collation without locale-specific stuff. */
if (g_strcmp0 (previous_locale, current_locale) != 0) {
g_message ("Locale change detected from '%s' to '%s'...",
previous_locale, current_locale);
changed = TRUE;
} else {
g_message ("Current and previous locales match: '%s'", previous_locale);
changed = FALSE;
}
g_free (current_locale);
g_free (previous_locale);
if (changed) {
g_message ("Resetting nfo:Software due to locale change...");
miner_reset_applications (miner);
}
return changed;
}
static gboolean
signal_handler (gpointer user_data)
{
......@@ -778,6 +885,9 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
/* If the locales changed, we need to reset some things first */
detect_locale_changed (TRACKER_MINER (miner_files));
proxy = tracker_miner_proxy_new (miner_files, connection, DBUS_PATH, NULL, &error);
if (error) {
g_critical ("Couldn't create miner proxy: %s", error->message);
......@@ -875,6 +985,7 @@ main (gint argc, gchar *argv[])
if (miners_timeout_id == 0 &&
!miner_needs_check (miner_files, store_available)) {
tracker_miner_files_set_need_mtime_check (FALSE);
save_current_locale ();
}
g_main_loop_unref (main_loop);
......
......@@ -531,6 +531,29 @@ miner_files_initable_iface_init (GInitableIface *iface)
iface->init = miner_files_initable_init;
}
static void
miner_files_add_application_dir (TrackerMinerFiles *mf,
const gchar *dir)
{
TrackerIndexingTree *indexing_tree;
GFile *file;
gchar *path;
indexing_tree = tracker_miner_fs_get_indexing_tree (TRACKER_MINER_FS (mf));
/* Add $dir/applications */
path = g_build_filename (dir, "applications", NULL);
file = g_file_new_for_path (path);
g_message (" Adding:'%s'", path);
tracker_indexing_tree_add (indexing_tree, file,
TRACKER_DIRECTORY_FLAG_RECURSE |
TRACKER_DIRECTORY_FLAG_MONITOR |
TRACKER_DIRECTORY_FLAG_CHECK_MTIME);
g_object_unref (file);
g_free (path);
}
static gboolean
miner_files_initable_init (GInitable *initable,
GCancellable *cancellable,
......@@ -540,10 +563,13 @@ miner_files_initable_init (GInitable *initable,
TrackerMinerFS *fs;
TrackerIndexingTree *indexing_tree;
TrackerDirectoryFlags flags;
const gchar *user_data_dir;
const gchar * const *xdg_dirs;
GError *inner_error = NULL;
GSList *mounts = NULL;
GSList *dirs;
GSList *m;
gint i;
/* Chain up parent's initable callback before calling child's one */
if (!miner_files_initable_parent_iface->init (initable, cancellable, &inner_error)) {
......@@ -752,6 +778,19 @@ miner_files_initable_init (GInitable *initable,
NULL);
}
/* Add application directories */
g_message ("Setting up applications to iterate from XDG system directories");
xdg_dirs = g_get_system_data_dirs ();
for (i = 0; xdg_dirs[i]; i++) {
miner_files_add_application_dir (mf, xdg_dirs[i]);
}
user_data_dir = g_get_user_data_dir ();
if (user_data_dir) {
miner_files_add_application_dir (mf, user_data_dir);
}