summaryrefslogtreecommitdiff
path: root/src/libtracker-common
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2019-12-30 17:52:01 +0100
committerCarlos Garnacho <carlosg@gnome.org>2020-02-17 18:57:46 +0100
commit8f7fd9765ca27e0de9e6fb214f0244a954e159a2 (patch)
treec0440cadcde9f372eb4648340504277e217f6b1f /src/libtracker-common
parentb0541d6e9b1176f7eb9cf2caf5b8043f262794e3 (diff)
downloadtracker-8f7fd9765ca27e0de9e6fb214f0244a954e159a2.tar.gz
libtracker-common: Clean up no longer used modules
With the massive shuffling happening in the tracker repo, some of these utility functions are no longer used, and even meaningless in this source tree. Clean all this up.
Diffstat (limited to 'src/libtracker-common')
-rw-r--r--src/libtracker-common/meson.build3
-rw-r--r--src/libtracker-common/tracker-common.h3
-rw-r--r--src/libtracker-common/tracker-dbus.c541
-rw-r--r--src/libtracker-common/tracker-dbus.h106
-rw-r--r--src/libtracker-common/tracker-domain-ontology.c395
-rw-r--r--src/libtracker-common/tracker-domain-ontology.h51
-rw-r--r--src/libtracker-common/tracker-ioprio.c150
-rw-r--r--src/libtracker-common/tracker-ioprio.h36
8 files changed, 0 insertions, 1285 deletions
diff --git a/src/libtracker-common/meson.build b/src/libtracker-common/meson.build
index 60941a078..d42792a57 100644
--- a/src/libtracker-common/meson.build
+++ b/src/libtracker-common/meson.build
@@ -12,10 +12,7 @@ tracker_common_enum_header = enums[1]
tracker_common_sources = [
'tracker-date-time.c',
- 'tracker-dbus.c',
- 'tracker-domain-ontology.c',
'tracker-file-utils.c',
- 'tracker-ioprio.c',
'tracker-log.c',
'tracker-type-utils.c',
'tracker-utils.c',
diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h
index 65a20c2bc..8d5df2be9 100644
--- a/src/libtracker-common/tracker-common.h
+++ b/src/libtracker-common/tracker-common.h
@@ -29,10 +29,7 @@
#define __LIBTRACKER_COMMON_INSIDE__
#include "tracker-date-time.h"
-#include "tracker-dbus.h"
-#include "tracker-domain-ontology.h"
#include "tracker-file-utils.h"
-#include "tracker-ioprio.h"
#include "tracker-language.h"
#include "tracker-log.h"
#include "tracker-parser.h"
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
deleted file mode 100644
index 5907d29fa..000000000
--- a/src/libtracker-common/tracker-dbus.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * 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 Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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 <gio/gio.h>
-#include <gio/gunixinputstream.h>
-#include <gio/gunixoutputstream.h>
-
-#ifdef __OpenBSD__
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <fcntl.h>
-#include <kvm.h>
-#endif
-
-#ifdef __sun
-#include <procfs.h>
-#endif
-
-#include "tracker-dbus.h"
-#include "tracker-log.h"
-
-/* How long clients can exist since last D-Bus call before being
- * cleaned up.
- */
-#define CLIENT_CLEAN_UP_TIME 300
-
-typedef struct {
- gchar *sender;
- gchar *binary;
- gulong pid;
- guint clean_up_id;
- gint n_active_requests;
-} ClientData;
-
-struct _TrackerDBusRequest {
- guint request_id;
- ClientData *cd;
-};
-
-static gboolean client_lookup_enabled;
-static GHashTable *clients;
-static GDBusConnection *connection;
-
-static void client_data_free (gpointer data);
-static gboolean client_clean_up_cb (gpointer data);
-
-inline GBusType
-tracker_ipc_bus (void)
-{
- const gchar *bus = g_getenv ("TRACKER_BUS_TYPE");
-
- if (G_UNLIKELY (bus != NULL &&
- g_ascii_strcasecmp (bus, "system") == 0)) {
- return G_BUS_TYPE_SYSTEM;
- }
-
- return G_BUS_TYPE_SESSION;
-}
-
-static gboolean
-clients_init (void)
-{
- GError *error = NULL;
- connection = g_bus_get_sync (TRACKER_IPC_BUS, NULL, &error);
-
- if (error) {
- g_critical ("Could not connect to the D-Bus session bus, %s",
- error ? error->message : "no error given.");
- g_clear_error (&error);
- connection = NULL;
- }
-
- clients = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- NULL,
- client_data_free);
-
- return TRUE;
-}
-
-static gboolean
-clients_shutdown (void)
-{
- if (clients) {
- g_hash_table_unref (clients);
- clients = NULL;
- }
-
- if (connection) {
- g_object_unref (connection);
- connection = NULL;
- }
-
- return TRUE;
-}
-
-static void
-client_data_free (gpointer data)
-{
- ClientData *cd = data;
-
- if (!cd) {
- return;
- }
-
- g_source_remove (cd->clean_up_id);
-
- g_free (cd->sender);
- g_free (cd->binary);
-
- g_slice_free (ClientData, cd);
-}
-
-static ClientData *
-client_data_new (gchar *sender)
-{
- ClientData *cd;
- gboolean get_binary = TRUE;
- GError *error = NULL;
-
- cd = g_slice_new0 (ClientData);
- cd->sender = sender;
-
- if (connection) {
- GVariant *v;
-
- v = g_dbus_connection_call_sync (connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "GetConnectionUnixProcessID",
- g_variant_new ("(s)", sender),
- G_VARIANT_TYPE ("(u)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
- if (!error) {
- g_variant_get (v, "(u)", &cd->pid);
- g_variant_unref (v);
- } else {
- g_error_free (error);
- }
- }
-
- if (get_binary) {
-#ifndef __OpenBSD__
- gchar *filename;
- gchar *pid_str;
- gchar *contents = NULL;
- GError *error = NULL;
- gchar **strv;
-#ifdef __sun /* Solaris */
- psinfo_t psinfo = { 0 };
-#endif
-
- pid_str = g_strdup_printf ("%ld", cd->pid);
- filename = g_build_filename (G_DIR_SEPARATOR_S,
- "proc",
- pid_str,
-#ifdef __sun /* Solaris */
- "psinfo",
-#else
- "cmdline",
-#endif
- NULL);
- g_free (pid_str);
-
- if (!g_file_get_contents (filename, &contents, NULL, &error)) {
- g_warning ("Could not get process name from id %ld, %s",
- cd->pid,
- error ? error->message : "no error given");
- g_clear_error (&error);
- g_free (filename);
- return cd;
- }
-
- g_free (filename);
-
-#ifdef __sun /* Solaris */
- memcpy (&psinfo, contents, sizeof (psinfo));
- /* won't work with paths containing spaces :( */
- strv = g_strsplit (psinfo.pr_psargs, " ", 2);
-#else
- strv = g_strsplit (contents, "^@", 2);
-#endif
- if (strv && strv[0]) {
- cd->binary = g_path_get_basename (strv[0]);
- }
-
- g_strfreev (strv);
- g_free (contents);
-#else
- gint nproc;
- struct kinfo_proc *kp;
- kvm_t *kd;
- gchar **strv;
-
- if ((kd = kvm_openfiles (NULL, NULL, NULL, KVM_NO_FILES, NULL)) == NULL)
- return cd;
-
- if ((kp = kvm_getprocs (kd, KERN_PROC_PID, cd->pid, sizeof (*kp), &nproc)) == NULL) {
- g_warning ("Could not get process name: %s", kvm_geterr (kd));
- kvm_close(kd);
- return cd;
- }
-
- if ((kp->p_flag & P_SYSTEM) != 0) {
- kvm_close(kd);
- return cd;
- }
-
- strv = kvm_getargv (kd, kp, 0);
-
- if (strv == NULL) {
- kvm_close(kd);
- return cd;
- } else {
- cd->binary = g_path_get_basename (strv[0]);
- kvm_close(kd);
- }
-#endif
- }
-
- return cd;
-}
-
-static gboolean
-client_clean_up_cb (gpointer data)
-{
- ClientData *cd;
-
- cd = data;
-
- g_debug ("Removing D-Bus client data for '%s' (pid: %lu) with id:'%s'",
- cd->binary, cd->pid, cd->sender);
- g_hash_table_remove (clients, cd->sender);
-
- if (g_hash_table_size (clients) < 1) {
- /* Clean everything up. */
- clients_shutdown ();
- }
-
- return FALSE;
-}
-
-static ClientData *
-client_get_for_sender (const gchar *sender)
-{
- ClientData *cd;
-
- if (!client_lookup_enabled) {
- return NULL;
- }
-
- /* Only really done with tracker-extract where we use
- * functions from the command line with dbus code in them.
- */
- if (!sender) {
- return NULL;
- }
-
- if (G_UNLIKELY (!clients)) {
- clients_init ();
- }
-
- cd = g_hash_table_lookup (clients, sender);
- if (!cd) {
- gchar *sender_dup;
-
- sender_dup = g_strdup (sender);
- cd = client_data_new (sender_dup);
- g_hash_table_insert (clients, sender_dup, cd);
- }
-
- if (cd->clean_up_id) {
- g_source_remove (cd->clean_up_id);
- cd->clean_up_id = 0;
- }
-
- cd->n_active_requests++;
-
- return cd;
-}
-
-GQuark
-tracker_dbus_error_quark (void)
-{
- return g_quark_from_static_string (TRACKER_DBUS_ERROR_DOMAIN);
-}
-
-gchar **
-tracker_dbus_slist_to_strv (GSList *list)
-{
- GSList *l;
- gchar **strv;
- gint i = 0;
-
- strv = g_new0 (gchar*, g_slist_length (list) + 1);
-
- for (l = list; l != NULL; l = l->next) {
- if (!g_utf8_validate (l->data, -1, NULL)) {
- g_message ("Could not add string:'%s' to GStrv, invalid UTF-8",
- (gchar*) l->data);
- continue;
- }
-
- strv[i++] = g_strdup (l->data);
- }
-
- strv[i] = NULL;
-
- return strv;
-}
-
-static guint
-get_next_request_id (void)
-{
- static guint request_id = 1;
-
- return request_id++;
-}
-
-TrackerDBusRequest *
-tracker_dbus_request_begin (const gchar *sender,
- const gchar *format,
- ...)
-{
- TrackerDBusRequest *request;
- gchar *str;
- va_list args;
-
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- request = g_slice_new (TrackerDBusRequest);
- request->request_id = get_next_request_id ();
- request->cd = client_get_for_sender (sender);
-
- g_debug ("<--- [%d%s%s|%lu] %s",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0,
- str);
-
- g_free (str);
-
- return request;
-}
-
-void
-tracker_dbus_request_end (TrackerDBusRequest *request,
- GError *error)
-{
- if (!error) {
- g_debug ("---> [%d%s%s|%lu] Success, no error given",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0);
- } else {
- g_message ("---> [%d%s%s|%lu] Failed, %s",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0,
- error->message);
- }
-
- if (request->cd) {
- request->cd->n_active_requests--;
-
- if (request->cd->n_active_requests == 0) {
- request->cd->clean_up_id = g_timeout_add_seconds (CLIENT_CLEAN_UP_TIME, client_clean_up_cb, request->cd);
- }
- }
-
- g_slice_free (TrackerDBusRequest, request);
-}
-
-void
-tracker_dbus_request_info (TrackerDBusRequest *request,
- const gchar *format,
- ...)
-{
- gchar *str;
- va_list args;
-
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_info ("---- [%d%s%s|%lu] %s",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0,
- str);
- g_free (str);
-}
-
-void
-tracker_dbus_request_comment (TrackerDBusRequest *request,
- const gchar *format,
- ...)
-{
- gchar *str;
- va_list args;
-
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_message ("---- [%d%s%s|%lu] %s",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0,
- str);
- g_free (str);
-}
-
-void
-tracker_dbus_request_debug (TrackerDBusRequest *request,
- const gchar *format,
- ...)
-{
- gchar *str;
- va_list args;
-
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_debug ("---- [%d%s%s|%lu] %s",
- request->request_id,
- request->cd ? "|" : "",
- request->cd ? request->cd->binary : "",
- request->cd ? request->cd->pid : 0,
- str);
- g_free (str);
-}
-
-void
-tracker_dbus_enable_client_lookup (gboolean enabled)
-{
- /* If this changed and we disabled everything, simply shut it
- * all down.
- */
- if (client_lookup_enabled != enabled && !enabled) {
- clients_shutdown ();
- }
-
- client_lookup_enabled = enabled;
-}
-
-TrackerDBusRequest *
-tracker_g_dbus_request_begin (GDBusMethodInvocation *invocation,
- const gchar *format,
- ...)
-{
- TrackerDBusRequest *request;
- gchar *str;
- const gchar *sender;
- va_list args;
-
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- sender = g_dbus_method_invocation_get_sender (invocation);
- request = tracker_dbus_request_begin (sender, "%s", str);
-
- g_free (str);
-
- return request;
-}
-
-gboolean
-tracker_dbus_request_name (GDBusConnection *connection,
- const gchar *name,
- GError **error)
-{
- GError *inner_error = NULL;
- GVariant *reply;
- gint rval;
-
- reply = g_dbus_connection_call_sync (connection,
- "org.freedesktop.DBus",
- "/org/freedesktop/DBus",
- "org.freedesktop.DBus",
- "RequestName",
- g_variant_new ("(su)",
- name,
- 0x4 /* DBUS_NAME_FLAG_DO_NOT_QUEUE */),
- G_VARIANT_TYPE ("(u)"),
- 0, -1, NULL, &inner_error);
- if (inner_error) {
- g_propagate_prefixed_error (error, inner_error,
- "Could not acquire name:'%s'. ",
- name);
- return FALSE;
- }
-
- g_variant_get (reply, "(u)", &rval);
- g_variant_unref (reply);
-
- if (rval != 1 /* DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER */) {
- g_set_error (error,
- G_DBUS_ERROR,
- G_DBUS_ERROR_ADDRESS_IN_USE,
- "D-Bus service name:'%s' is already taken, "
- "perhaps the application is already running?",
- name);
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
deleted file mode 100644
index bfbff9bb3..000000000
--- a/src/libtracker-common/tracker-dbus.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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 Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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 __LIBTRACKER_COMMON_DBUS_H__
-#define __LIBTRACKER_COMMON_DBUS_H__
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
-#error "only <libtracker-common/tracker-common.h> must be included directly."
-#endif
-
-/* Allow bus type override by env var TRACKER_BUS_TYPE */
-#define TRACKER_IPC_BUS tracker_ipc_bus()
-
-#define TRACKER_DBUS_ERROR_DOMAIN "TrackerDBus"
-#define TRACKER_DBUS_ERROR tracker_dbus_error_quark()
-
-#define tracker_gdbus_async_return_if_fail(expr,invocation) \
- G_STMT_START { \
- if G_LIKELY(expr) { } else { \
- GError *assert_error = NULL; \
- \
- g_set_error (&assert_error, \
- TRACKER_DBUS_ERROR, \
- TRACKER_DBUS_ERROR_ASSERTION_FAILED, \
- "Assertion `%s' failed", \
- #expr); \
- \
- g_dbus_method_invocation_return_gerror (invocation, assert_error); \
- g_clear_error (&assert_error); \
- \
- return; \
- }; \
- } G_STMT_END
-
-typedef struct _TrackerDBusRequest TrackerDBusRequest;
-
-typedef enum {
- TRACKER_DBUS_EVENTS_TYPE_ADD,
- TRACKER_DBUS_EVENTS_TYPE_UPDATE,
- TRACKER_DBUS_EVENTS_TYPE_DELETE
-} TrackerDBusEventsType;
-
-typedef enum {
- TRACKER_DBUS_ERROR_ASSERTION_FAILED,
- TRACKER_DBUS_ERROR_UNSUPPORTED,
- TRACKER_DBUS_ERROR_BROKEN_PIPE
-} TrackerDBusError;
-
-
-GBusType tracker_ipc_bus (void);
-
-GQuark tracker_dbus_error_quark (void);
-
-/* Utils */
-gchar ** tracker_dbus_slist_to_strv (GSList *list);
-
-/* Requests */
-TrackerDBusRequest *tracker_dbus_request_begin (const gchar *sender,
- const gchar *format,
- ...);
-void tracker_dbus_request_end (TrackerDBusRequest *request,
- GError *error);
-void tracker_dbus_request_comment (TrackerDBusRequest *request,
- const gchar *format,
- ...);
-void tracker_dbus_request_info (TrackerDBusRequest *request,
- const gchar *format,
- ...);
-void tracker_dbus_request_debug (TrackerDBusRequest *request,
- const gchar *format,
- ...);
-
-void tracker_dbus_enable_client_lookup (gboolean enable);
-
-gboolean tracker_dbus_request_name (GDBusConnection *connection,
- const gchar *name,
- GError **error);
-
-/* GDBus convenience API */
-TrackerDBusRequest *tracker_g_dbus_request_begin (GDBusMethodInvocation *invocation,
- const gchar *format,
- ...);
-
-G_END_DECLS
-
-#endif /* __LIBTRACKER_COMMON_DBUS_H__ */
diff --git a/src/libtracker-common/tracker-domain-ontology.c b/src/libtracker-common/tracker-domain-ontology.c
deleted file mode 100644
index f43fd926b..000000000
--- a/src/libtracker-common/tracker-domain-ontology.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (C) 2017, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Authors: Carlos Garnacho <carlosg@gnome.org>
- */
-
-#include "config.h"
-
-#include <string.h>
-#include "tracker-domain-ontology.h"
-
-struct _TrackerDomainOntology {
- gint ref_count;
- /* DomainOntologies section */
- GFile *cache_location;
- GFile *journal_location;
- GFile *ontology_location;
- gchar *name;
- gchar *domain;
- gchar *ontology_name;
- gchar **miners;
-};
-
-struct {
- const gchar *var;
- const gchar *(*func) (void);
-} lookup_dirs[] = {
- { "HOME", g_get_home_dir },
- { "XDG_CACHE_HOME", g_get_user_cache_dir },
- { "XDG_DATA_HOME", g_get_user_data_dir },
- { "XDG_RUNTIME_DIR", g_get_user_runtime_dir },
-};
-
-struct {
- const gchar *var;
- GUserDirectory user_directory;
-} lookup_special_dirs[] = {
- { "XDG_DESKTOP_DIR", G_USER_DIRECTORY_DESKTOP },
- { "XDG_DOCUMENTS_DIR", G_USER_DIRECTORY_DOCUMENTS },
- { "XDG_DOWNLOAD_DIR", G_USER_DIRECTORY_DOWNLOAD },
- { "XDG_MUSIC_DIR", G_USER_DIRECTORY_MUSIC },
- { "XDG_PICTURES_DIR", G_USER_DIRECTORY_PICTURES },
- { "XDG_PUBLICSHARE_DIR", G_USER_DIRECTORY_PUBLIC_SHARE },
- { "XDG_VIDEOS_DIR", G_USER_DIRECTORY_VIDEOS },
-};
-
-#define DOMAIN_ONTOLOGY_SECTION "DomainOntology"
-
-#define CACHE_KEY "CacheLocation"
-#define JOURNAL_KEY "JournalLocation"
-#define ONTOLOGY_KEY "OntologyLocation"
-#define ONTOLOGY_NAME_KEY "OntologyName"
-#define DOMAIN_KEY "Domain"
-#define MINERS_KEY "Miners"
-
-#define DEFAULT_RULE "default.rule"
-
-TrackerDomainOntology *
-tracker_domain_ontology_ref (TrackerDomainOntology *domain_ontology)
-{
- domain_ontology->ref_count++;
- return domain_ontology;
-}
-
-void
-tracker_domain_ontology_unref (TrackerDomainOntology *domain_ontology)
-{
- domain_ontology->ref_count--;
-
- if (domain_ontology->ref_count != 0)
- return;
-
- g_clear_object (&domain_ontology->cache_location);
- g_clear_object (&domain_ontology->journal_location);
- g_clear_object (&domain_ontology->ontology_location);
- g_free (domain_ontology->ontology_name);
- g_free (domain_ontology->name);
- g_free (domain_ontology->domain);
- g_strfreev (domain_ontology->miners);
- g_free (domain_ontology);
-}
-
-static const gchar *
-lookup_dir (const gchar *variable,
- gsize variable_len)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (lookup_dirs); i++) {
- if (strncmp (lookup_dirs[i].var, variable, variable_len) == 0) {
- return lookup_dirs[i].func ();
- }
- }
-
- for (i = 0; i < G_N_ELEMENTS (lookup_special_dirs); i++) {
- if (strncmp (lookup_special_dirs[i].var, variable, variable_len) == 0) {
- return g_get_user_special_dir (lookup_special_dirs[i].user_directory);
- }
- }
-
- return NULL;
-}
-
-static GFile *
-key_file_get_location (GKeyFile *key_file,
- const gchar *section,
- const gchar *key,
- gboolean essential,
- gboolean must_exist,
- GError **error)
-{
- GError *inner_error = NULL;
- gchar *value;
- GFile *file;
-
- value = g_key_file_get_string (key_file, section, key, &inner_error);
- if (inner_error) {
- if (essential)
- g_propagate_error (error, inner_error);
- else
- g_error_free (inner_error);
-
- return NULL;
- }
-
- if (value[0] == '$') {
- const gchar *var_end, *prefix;
- gchar *path;
-
- /* This is a path relative from a xdg dir */
- var_end = strchr (value, '/');
- if (!var_end) {
- /* We must take $VAR/subdir values */
- g_set_error (error,
- G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_INVALID_VALUE,
- "Path in key '%s' can not consist solely of a variable",
- key);
- g_free (value);
- return NULL;
- }
-
- prefix = lookup_dir (&value[1], (var_end - &value[1]));
- if (!prefix) {
- g_set_error (error,
- G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_INVALID_VALUE,
- "Unrecognized variable in '%s'", key);
- g_free (value);
- return NULL;
- }
-
- path = g_strconcat (prefix, var_end, NULL);
- file = g_file_new_for_path (path);
- g_free (path);
- } else {
- file = g_file_new_for_uri (value);
- }
-
- g_free (value);
-
- if (must_exist && file &&
- g_file_query_file_type (file, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- NULL) != G_FILE_TYPE_DIRECTORY) {
- gchar *uri = g_file_get_uri (file);
- g_set_error (error,
- G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_INVALID_VALUE,
- "Uri '%s' is not a directory or does not exist", uri);
- g_free (uri);
- return NULL;
- }
-
- return file;
-}
-
-static gchar *
-find_rule_in_data_dirs (const gchar *name)
-{
- const gchar* const *data_dirs;
- gchar *path, *rule_name;
- guint i;
-
- data_dirs = g_get_system_data_dirs ();
- rule_name = g_strconcat (name, ".rule", NULL);
-
- for (i = 0; data_dirs[i] != NULL; i++) {
- path = g_build_filename (data_dirs[i],
- "tracker", "domain-ontologies",
- rule_name, NULL);
- if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
- g_free (rule_name);
- return path;
- }
-
- g_free (path);
- }
-
- g_free (rule_name);
-
- return NULL;
-}
-
-TrackerDomainOntology *
-tracker_domain_ontology_new (const gchar *domain_name,
- GCancellable *cancellable,
- GError **error)
-{
- TrackerDomainOntology *domain_ontology;
- GError *inner_error = NULL;
- GKeyFile *key_file = NULL;
- gchar *path, *path_for_tests;
-
- domain_ontology = g_new0 (TrackerDomainOntology, 1);
- domain_ontology->name = g_strdup (domain_name);
- domain_ontology->ref_count = 1;
-
- if (domain_name && domain_name[0] == '/') {
- if (!g_file_test (domain_name, G_FILE_TEST_IS_REGULAR)) {
- inner_error = g_error_new (G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_NOT_FOUND,
- "Could not find rule at '%s'",
- domain_name);
- goto end;
- }
-
- path = g_strdup (domain_name);
- } else if (domain_name) {
- path = find_rule_in_data_dirs (domain_name);
-
- if (!path) {
- inner_error = g_error_new (G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_NOT_FOUND,
- "Could not find rule '%s' in data dirs",
- domain_name);
- goto end;
- }
- } else {
- path = g_build_filename (SHAREDIR, "tracker", "domain-ontologies",
- DEFAULT_RULE, NULL);
-
- if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
- /* This is only for uninstalled tests */
- path_for_tests = g_strdup (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE"));
-
- if (path_for_tests == NULL) {
- g_error ("Unable to find default domain ontology rule %s", path);
- }
-
- g_free (path);
- path = path_for_tests;
- }
- }
-
- key_file = g_key_file_new ();
- g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &inner_error);
- g_free (path);
-
- if (inner_error)
- goto end;
-
- domain_ontology->domain = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
- DOMAIN_KEY, &inner_error);
- if (inner_error)
- goto end;
-
- domain_ontology->cache_location =
- key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
- CACHE_KEY, TRUE, FALSE, &inner_error);
- if (inner_error)
- goto end;
-
- domain_ontology->journal_location =
- key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
- JOURNAL_KEY, FALSE, FALSE, &inner_error);
- if (inner_error)
- goto end;
-
- domain_ontology->ontology_location =
- key_file_get_location (key_file, DOMAIN_ONTOLOGY_SECTION,
- ONTOLOGY_KEY, FALSE, TRUE, &inner_error);
- if (inner_error)
- goto end;
-
- domain_ontology->ontology_name = g_key_file_get_string (key_file, DOMAIN_ONTOLOGY_SECTION,
- ONTOLOGY_NAME_KEY, NULL);
- domain_ontology->miners = g_key_file_get_string_list (key_file, DOMAIN_ONTOLOGY_SECTION,
- MINERS_KEY, NULL, NULL);
-
- /* Consistency check, we need one of OntologyLocation and OntologyName,
- * no more, no less.
- */
- if ((domain_ontology->ontology_name && domain_ontology->ontology_location) ||
- (!domain_ontology->ontology_name && !domain_ontology->ontology_location)) {
- inner_error = g_error_new (G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_INVALID_VALUE,
- "One of OntologyLocation and OntologyName must be provided");
- }
-
- /* Build ontology location from name if necessary */
- if (!domain_ontology->ontology_location) {
- gchar *ontology_path;
-
- if (g_getenv ("TRACKER_DB_ONTOLOGIES_DIR") != NULL) {
- /* Override for use only by testcases */
- domain_ontology->ontology_location = g_file_new_for_path (g_getenv ("TRACKER_DB_ONTOLOGIES_DIR"));
- } else {
- ontology_path = g_build_filename (SHAREDIR, "tracker", "ontologies",
- domain_ontology->ontology_name, NULL);
-
- if (!g_file_test (ontology_path, G_FILE_TEST_IS_DIR)) {
- g_error ("Unable to find ontologies in the configured location %s", ontology_path);
- }
-
- domain_ontology->ontology_location = g_file_new_for_path (ontology_path);
-
- g_free (ontology_path);
- }
- }
-
-end:
- if (key_file)
- g_key_file_free (key_file);
-
- if (inner_error) {
- g_propagate_error (error, inner_error);
- tracker_domain_ontology_unref (domain_ontology);
- return NULL;
- }
-
- return domain_ontology;
-}
-
-GFile *
-tracker_domain_ontology_get_cache (TrackerDomainOntology *domain_ontology)
-{
- return domain_ontology->cache_location;
-}
-
-GFile *
-tracker_domain_ontology_get_journal (TrackerDomainOntology *domain_ontology)
-{
- return domain_ontology->journal_location;
-}
-
-GFile *
-tracker_domain_ontology_get_ontology (TrackerDomainOntology *domain_ontology)
-{
- return domain_ontology->ontology_location;
-}
-
-gchar *
-tracker_domain_ontology_get_domain (TrackerDomainOntology *domain_ontology,
- const gchar *suffix)
-{
- if (suffix)
- return g_strconcat (domain_ontology->domain, ".", suffix, NULL);
- else
- return g_strconcat (domain_ontology->domain, NULL);
-}
-
-gboolean
-tracker_domain_ontology_uses_miner (TrackerDomainOntology *domain_ontology,
- const gchar *suffix)
-{
- guint i;
-
- g_return_val_if_fail (suffix != NULL, FALSE);
-
- if (!domain_ontology->miners)
- return FALSE;
-
- for (i = 0; domain_ontology->miners[i] != NULL; i++) {
- if (strcmp (domain_ontology->miners[i], suffix) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
diff --git a/src/libtracker-common/tracker-domain-ontology.h b/src/libtracker-common/tracker-domain-ontology.h
deleted file mode 100644
index 12434a212..000000000
--- a/src/libtracker-common/tracker-domain-ontology.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2017, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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.
- *
- * Authors: Carlos Garnacho <carlosg@gnome.org>
- */
-
-#ifndef __TRACKER_DOMAIN_ONTOLOGY_H__
-#define __TRACKER_DOMAIN_ONTOLOGY_H__
-
-#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
-#error "only <libtracker-common/tracker-common.h> must be included directly."
-#endif
-
-#include <glib-object.h>
-#include <gio/gio.h>
-
-typedef struct _TrackerDomainOntology TrackerDomainOntology;
-
-TrackerDomainOntology * tracker_domain_ontology_new (const gchar *name,
- GCancellable *cancellable,
- GError **error);
-TrackerDomainOntology * tracker_domain_ontology_ref (TrackerDomainOntology *domain_ontology);
-
-void tracker_domain_ontology_unref (TrackerDomainOntology *domain_ontology);
-
-GFile * tracker_domain_ontology_get_cache (TrackerDomainOntology *domain_ontology);
-GFile * tracker_domain_ontology_get_journal (TrackerDomainOntology *domain_ontology);
-GFile * tracker_domain_ontology_get_ontology (TrackerDomainOntology *domain_ontology);
-
-gchar * tracker_domain_ontology_get_domain (TrackerDomainOntology *domain_ontology,
- const gchar *suffix);
-
-gboolean tracker_domain_ontology_uses_miner (TrackerDomainOntology *domain_ontology,
- const gchar *suffix);
-
-#endif /* __TRACKER_DOMAIN_ONTOLOGY_H__ */
diff --git a/src/libtracker-common/tracker-ioprio.c b/src/libtracker-common/tracker-ioprio.c
deleted file mode 100644
index 6554f489c..000000000
--- a/src/libtracker-common/tracker-ioprio.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2005, Novell, Inc.
- * Copyright (C) 2006, Jamie McCracken <jamiemcc@gnome.org>
- * Copyright (C) 2006, Anders Aagaard
- *
- * Based mostly on code by Robert Love <rml@novell.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "config.h"
-
-#ifdef __linux__
-
-#include <stdio.h>
-#include <errno.h>
-
-#ifdef HAVE_LINUX_UNISTD_H
-#include <linux/unistd.h>
-#endif
-
-#include <sys/syscall.h>
-#include <unistd.h>
-
-#include <glib/gstdio.h>
-
-#endif /* __linux__ */
-
-#include "tracker-ioprio.h"
-
-/* We assume ALL linux architectures have the syscalls defined here */
-#ifdef __linux__
-
-/* Make sure the system call is supported */
-#ifndef __NR_ioprio_set
-
-#if defined(__i386__)
-#define __NR_ioprio_set 289
-#define __NR_ioprio_get 290
-#elif defined(__powerpc__) || defined(__powerpc64__)
-#define __NR_ioprio_set 273
-#define __NR_ioprio_get 274
-#elif defined(__x86_64__)
-#define __NR_ioprio_set 251
-#define __NR_ioprio_get 252
-#elif defined(__ia64__)
-#define __NR_ioprio_set 1274
-#define __NR_ioprio_get 1275
-#elif defined(__alpha__)
-#define __NR_ioprio_set 442
-#define __NR_ioprio_get 443
-#elif defined(__s390x__) || defined(__s390__)
-#define __NR_ioprio_set 282
-#define __NR_ioprio_get 283
-#elif defined(__SH4__)
-#define __NR_ioprio_set 288
-#define __NR_ioprio_get 289
-#elif defined(__SH5__)
-#define __NR_ioprio_set 316
-#define __NR_ioprio_get 317
-#elif defined(__sparc__) || defined(__sparc64__)
-#define __NR_ioprio_set 196
-#define __NR_ioprio_get 218
-#elif defined(__arm__)
-#define __NR_ioprio_set 314
-#define __NR_ioprio_get 315
-#else
-#error "Unsupported architecture!"
-#endif
-
-#endif /* __NR_ioprio_set */
-
-enum {
- IOPRIO_CLASS_NONE,
- IOPRIO_CLASS_RT,
- IOPRIO_CLASS_BE,
- IOPRIO_CLASS_IDLE,
-};
-
-enum {
- IOPRIO_WHO_PROCESS = 1,
- IOPRIO_WHO_PGRP,
- IOPRIO_WHO_USER,
-};
-
-#define IOPRIO_CLASS_SHIFT 13
-
-static inline int
-ioprio_set (int which, int who, int ioprio_val)
-{
- return syscall (__NR_ioprio_set, which, who, ioprio_val);
-}
-
-static int
-set_io_priority_idle (void)
-{
- int ioprio, ioclass;
-
- ioprio = 7; /* priority is ignored with idle class */
- ioclass = IOPRIO_CLASS_IDLE << IOPRIO_CLASS_SHIFT;
-
- return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio | ioclass);
-}
-
-static int
-set_io_priority_best_effort (int ioprio_val)
-{
- int ioclass;
-
- ioclass = IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
-
- return ioprio_set (IOPRIO_WHO_PROCESS, 0, ioprio_val | ioclass);
-}
-
-void
-tracker_ioprio_init (void)
-{
- if (set_io_priority_idle () == -1) {
- g_message ("Could not set idle IO priority, attempting best effort of 7");
-
- if (set_io_priority_best_effort (7) == -1) {
- g_message ("Could not set best effort IO priority either, giving up");
- }
- }
-}
-
-#else /* __linux__ */
-
-void
-tracker_ioprio_init (void)
-{
-}
-
-#endif /* __linux__ */
diff --git a/src/libtracker-common/tracker-ioprio.h b/src/libtracker-common/tracker-ioprio.h
deleted file mode 100644
index 86ef14762..000000000
--- a/src/libtracker-common/tracker-ioprio.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2006, Anders Aagaard
- * 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 Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser 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 __LIBTRACKER_COMMON_IOPRIO_H__
-#define __LIBTRACKER_COMMON_IOPRIO_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION)
-#error "only <libtracker-common/tracker-common.h> must be included directly."
-#endif
-
-void tracker_ioprio_init (void);
-
-G_END_DECLS
-
-#endif /* __LIBTRACKER_COMMON_IOPRIO_H__ */