From b73af3b0d5e5d149301ffc188f2082f01b4ada3e Mon Sep 17 00:00:00 2001 From: Martyn Russell Date: Fri, 10 Oct 2014 22:21:01 +0100 Subject: libtracker-common: Removed all locale runtime update management General consensus was that we should remove this now, it's not useful and GNOME at least expects a log out when changing the locale. --- src/libtracker-common/Makefile.am | 11 - src/libtracker-common/tracker-common.h | 4 - src/libtracker-common/tracker-locale-gconfdbus.c | 563 --------------------- src/libtracker-common/tracker-locale-gconfdbus.h | 44 -- src/libtracker-common/tracker-locale.c | 53 +- src/libtracker-common/tracker-locale.h | 18 +- src/libtracker-common/tracker-meego.cpp | 94 ---- src/libtracker-common/tracker-meego.h | 37 -- src/libtracker-common/tracker-miner-locale.c | 24 +- src/libtracker-data/tracker-db-interface-sqlite.c | 20 - src/miners/apps/tracker-miner-applications.c | 50 -- src/miners/user-guides/tracker-miner-user-guides.c | 44 -- src/tracker-store/Makefile.am | 2 - src/tracker-store/tracker-locale-change.c | 152 ------ src/tracker-store/tracker-locale-change.h | 32 -- src/tracker-store/tracker-main.vala | 5 - 16 files changed, 17 insertions(+), 1136 deletions(-) delete mode 100644 src/libtracker-common/tracker-locale-gconfdbus.c delete mode 100644 src/libtracker-common/tracker-locale-gconfdbus.h delete mode 100644 src/libtracker-common/tracker-meego.cpp delete mode 100644 src/libtracker-common/tracker-meego.h delete mode 100644 src/tracker-store/tracker-locale-change.c delete mode 100644 src/tracker-store/tracker-locale-change.h diff --git a/src/libtracker-common/Makefile.am b/src/libtracker-common/Makefile.am index baa729864..b44a2212e 100644 --- a/src/libtracker-common/Makefile.am +++ b/src/libtracker-common/Makefile.am @@ -52,17 +52,6 @@ libtracker_common_la_SOURCES += tracker-language.c noinst_HEADERS += tracker-language.h endif -if HAVE_MEEGOTOUCH -libtracker_common_la_SOURCES += - tracker-locale-gconfdbus.c \ - tracker-locale-gconfdbus.h \ - tracker-meego.cpp \ - tracker-meego.h -noinst_HEADERS += \ - tracker-locale-gconfdbus.h \ - tracker-meego.h -endif - libtracker_common_la_LIBADD = \ $(BUILD_LIBS) \ $(LIBTRACKER_COMMON_LIBS) \ diff --git a/src/libtracker-common/tracker-common.h b/src/libtracker-common/tracker-common.h index c82684f7e..44f329214 100644 --- a/src/libtracker-common/tracker-common.h +++ b/src/libtracker-common/tracker-common.h @@ -44,10 +44,6 @@ #include "tracker-miner-locale.h" #include "tracker-enum-types.h" -#ifdef HAVE_MEEGOTOUCH -#include "tracker-miner-meego.h" -#endif /* HAVE_MEEGOTOUCH */ - #undef __LIBTRACKER_COMMON_INSIDE__ #endif /* __LIBTRACKER_COMMON_H__ */ diff --git a/src/libtracker-common/tracker-locale-gconfdbus.c b/src/libtracker-common/tracker-locale-gconfdbus.c deleted file mode 100644 index 064567808..000000000 --- a/src/libtracker-common/tracker-locale-gconfdbus.c +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Copyright (C) 2011 Nokia - * - * 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 -#include - -#include -#include -#include - -#include "tracker-locale-gconfdbus.h" - -/* This helps with testing, change all the names in gconf-dbus and then you - * can run it in parallel with an upstream gconf-d of the GNOME platform */ -#define GCONF_DBUS_NAME "GConf" - -#define GCONF_DBUS_SERVICE "org.gnome." GCONF_DBUS_NAME -#define GCONF_DBUS_SERVER_INTERFACE "org.gnome." GCONF_DBUS_NAME ".Server" -#define GCONF_DBUS_DATABASE_INTERFACE "org.gnome." GCONF_DBUS_NAME ".Database" -#define GCONF_DBUS_SERVER_OBJECT "/org/gnome/" GCONF_DBUS_NAME "/Server" -#define GCONF_DBUS_CLIENT_OBJECT "/org/gnome/" GCONF_DBUS_NAME "/Client" -#define GCONF_DBUS_CLIENT_INTERFACE "org.gnome." GCONF_DBUS_NAME ".Client" - -/* Base dir for all gconf locale values */ -#define MEEGOTOUCH_LOCALE_DIR "/meegotouch/i18n" - -#define TRACKER_DISABLE_MEEGOTOUCH_LOCALE_ENV "TRACKER_DISABLE_MEEGOTOUCH_LOCALE" - -static gchar*gconf_dbus_default_db = NULL; -static GDBusConnection *connection = NULL; -static gboolean service_running = FALSE; -static guint watch_name_id = 0; -static guint registration_id = 0; -static GMutex subscribers_mutex; -GDBusNodeInfo *introspection_data = NULL; -static gboolean meegotouch_mode = TRUE; -static gboolean first_time = TRUE; - -/* gconf keys for tracker locales, as defined in: - * http://apidocs.meego.com/1.0/mtf/i18n.html - */ -static const gchar *gconf_locales[TRACKER_LOCALE_LAST] = { - MEEGOTOUCH_LOCALE_DIR "/language", - MEEGOTOUCH_LOCALE_DIR "/lc_time", - MEEGOTOUCH_LOCALE_DIR "/lc_collate", - MEEGOTOUCH_LOCALE_DIR "/lc_numeric", - MEEGOTOUCH_LOCALE_DIR "/lc_monetary" -}; - -/* Structure to hold the notification data of each subscriber */ -typedef struct { - TrackerLocaleID id; - TrackerLocaleNotifyFunc func; - gpointer user_data; - GFreeFunc destroy_notify; -} TrackerLocaleNotification; - -/* List of subscribers which want to get notified of locale changes */ -static GSList *subscribers; - -static const gchar introspection_xml[] = - "" - " " - " " - " " - " " - " " - " " - " " - ""; - -static gboolean -check_gconf_dbus_default_db (void) { - if (gconf_dbus_default_db == NULL || !g_variant_is_object_path (gconf_dbus_default_db)) { - g_critical ("gconf_dbus_default_db is '%s', which is not a valid D-Bus object path.", - gconf_dbus_default_db ? gconf_dbus_default_db : "(null)"); - return FALSE; - } else { - return TRUE; - } -} - -static gboolean -add_notify (void) -{ - GVariant *reply; - GError *error = NULL; - - if (!check_gconf_dbus_default_db ()) { - return FALSE; - } - - reply = g_dbus_connection_call_sync (connection, - GCONF_DBUS_SERVICE, - gconf_dbus_default_db, - GCONF_DBUS_DATABASE_INTERFACE, - "AddNotify", - g_variant_new ("(s)", MEEGOTOUCH_LOCALE_DIR), - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - - if (error) { - g_critical ("%s", error->message); - g_clear_error (&error); - return FALSE; - } - - if (reply) { - g_variant_unref (reply); - } - - return TRUE; -} - -static void -handle_method_call (GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - if (g_strcmp0 (method_name, "Notify") == 0) { - const gchar *key = NULL, *value = NULL; - const gchar *schema = NULL, *database = NULL; - const gchar *namespace_name = NULL; - gboolean is_set, is_default, is_writable; - gint type, i; - GSList *li; - - if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(ss(s(is)bsbb))"))) { - g_variant_get (parameters, "(&s&s(&s(i&s)b&sbb))", - &database, &namespace_name, - &key, &type, &value, - &is_set, &schema, - &is_default, &is_writable, - NULL); - - /* Find the proper locale to change */ - for (i = 0; i < TRACKER_LOCALE_LAST; i++) { - if (strcmp (gconf_locales[i], key) == 0) { - break; - } - } - - /* Oh, not found? */ - if (i == TRACKER_LOCALE_LAST) { - g_debug ("Skipping change on gconf key '%s' as not really needed", key); - return; - } - - /* Ensure a proper value was set */ - if (value == NULL || value[0] == '\0') { - g_warning ("Locale value for '%s' cannot be NULL, not changing %s", - gconf_locales[i], - tracker_locale_get_name (i)); - return; - } - - tracker_locale_set (i, value); - - g_mutex_lock (&subscribers_mutex); - - for (li = subscribers; li; li = g_slist_next (li)) { - TrackerLocaleNotification *data = li->data; - - if (i == data->id) { - g_debug ("Notifying locale '%s' change to subscriber '%p'", - tracker_locale_get_name(i), - data); - data->func (i, data->user_data); - } - } - - g_mutex_unlock (&subscribers_mutex); - } - } -} - -static GVariant * -handle_get_property (GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, - const gchar *property_name, - GError **error, - gpointer user_data) -{ - return NULL; -} - -static gboolean -handle_set_property (GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, - const gchar *property_name, - GVariant *value, - GError **error, - gpointer user_data) -{ - return TRUE; -} - - - -static gchar * -get_value_from_config (const gchar *key_in) -{ - const gchar *locale = setlocale (LC_CTYPE, NULL); - const gchar *key, *value, *schema; - gchar *val = NULL; - gboolean is_set, is_default, is_writable; - gint type; - GError *error = NULL; - GVariant *reply; - - if (!check_gconf_dbus_default_db ()) { - return NULL; - } - - reply = g_dbus_connection_call_sync (connection, - GCONF_DBUS_SERVICE, - gconf_dbus_default_db, - GCONF_DBUS_DATABASE_INTERFACE, - "LookupExtended", - g_variant_new ("(ssb)", key_in, locale, TRUE), - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - - if (error) { - g_critical ("%s", error->message); - g_clear_error (&error); - - return NULL; - } - - if (g_variant_is_of_type (reply, G_VARIANT_TYPE ("((s(is)bsbb))"))) { - g_variant_get (reply, "((&s(i&s)b&sbb))", - &key, &type, &value, - &is_set, &schema, - &is_default, &is_writable, - NULL); - - val = g_strdup (value); - } - - g_variant_unref (reply); - - return val; -} - - -static void -on_gconfd_dbus_appeared (GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, - gpointer user_data) -{ - guint i; - - service_running = TRUE; - add_notify (); - - if (!first_time) { - /* And (re)initialize all */ - for (i = 0; i < TRACKER_LOCALE_LAST; i++) { - gchar *str; - - str = get_value_from_config (gconf_locales[i]); - if (str) { - tracker_locale_set (i, str); - g_free (str); - } - } - } - - first_time = FALSE; -} - -static void -on_gconfd_dbus_disappeared (GDBusConnection *connection, - const gchar *name, - gpointer user_data) -{ - service_running = FALSE; -} - -void -tracker_locale_gconfdbus_init (void) -{ - if (!g_getenv (TRACKER_DISABLE_MEEGOTOUCH_LOCALE_ENV) && meegotouch_mode) { - GError *error = NULL; - GVariant *reply; - guint i; - GDBusInterfaceVTable interface_vtable = { - handle_method_call, - handle_get_property, - handle_set_property - }; - - g_message ("Retrieving locale from GConf is ENABLED"); - - connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - - if (error) { - g_warning ("%s", error->message); - g_clear_error (&error); - return; - } - - service_running = TRUE; - - reply = g_dbus_connection_call_sync (connection, - GCONF_DBUS_SERVICE, - GCONF_DBUS_SERVER_OBJECT, - GCONF_DBUS_SERVER_INTERFACE, - "GetDefaultDatabase", - NULL, - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - - - if (error) { - if (error->code == G_DBUS_ERROR_UNKNOWN_METHOD) { - g_warning ("GetDefaultDatabase doesn't exist on %s, this GConf " - "doesn't look like a gconf-dbus.\n" - "Continuing in non-meegotouch mode", - GCONF_DBUS_SERVER_OBJECT); - meegotouch_mode = FALSE; - } else { - g_critical ("%s", error->message); - g_clear_error (&error); - } - - g_object_unref (connection); - connection = NULL; - return; - } - - g_variant_get (reply, "(s)", &gconf_dbus_default_db, NULL); - - g_variant_unref (reply); - - if (gconf_dbus_default_db == NULL || !g_variant_is_object_path (gconf_dbus_default_db)) { - g_critical (GCONF_DBUS_SERVER_INTERFACE ".GetDefaultDatabase returned '%s', which is not a valid D-Bus object path.", - gconf_dbus_default_db ? gconf_dbus_default_db : "(null)"); - - g_free (gconf_dbus_default_db); - gconf_dbus_default_db = NULL; - - g_object_unref (connection); - connection = NULL; - return; - } - - introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error); - - if (error) { - g_critical ("%s", error->message); - g_clear_error (&error); - - g_free (gconf_dbus_default_db); - gconf_dbus_default_db = NULL; - - g_object_unref (connection); - connection = NULL; - return; - } - - registration_id = - g_dbus_connection_register_object (connection, - GCONF_DBUS_CLIENT_OBJECT, - introspection_data->interfaces[0], - &interface_vtable, - NULL, - NULL, - &error); - - if (error) { - g_critical ("%s", error->message); - g_clear_error (&error); - - g_dbus_node_info_unref (introspection_data); - introspection_data = NULL; - - g_free (gconf_dbus_default_db); - gconf_dbus_default_db = NULL; - - g_object_unref (connection); - connection = NULL; - return; - } - - first_time = TRUE; - - watch_name_id = g_bus_watch_name_on_connection (connection, - GCONF_DBUS_SERVICE, - G_BUS_NAME_WATCHER_FLAGS_NONE, - on_gconfd_dbus_appeared, - on_gconfd_dbus_disappeared, - NULL, NULL); - - /* And initialize all (must be synchronously done at the return of this - * function, which is why we do the first_time trick in on_gconfd_dbus_ - * appeared above) */ - - for (i = 0; i < TRACKER_LOCALE_LAST; i++) { - gchar *str; - - str = get_value_from_config (gconf_locales[i]); - if (str) { - tracker_locale_set (i, str); - g_free (str); - } - } - } -} - -void -tracker_locale_gconfdbus_shutdown (void) -{ - if (gconf_dbus_default_db != NULL && connection != NULL && check_gconf_dbus_default_db ()) { - GVariant *reply; - GError *error = NULL; - - reply = g_dbus_connection_call_sync (connection, - GCONF_DBUS_SERVICE, - gconf_dbus_default_db, - GCONF_DBUS_DATABASE_INTERFACE, - "RemoveNotify", - g_variant_new ("(s)", MEEGOTOUCH_LOCALE_DIR), - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - &error); - - if (error) { - g_warning ("%s", error->message); - g_clear_error (&error); - } else { - g_variant_unref (reply); - } - } - - if (watch_name_id != 0) { - g_bus_unwatch_name (watch_name_id); - watch_name_id = 0; - } - - if (registration_id != 0) { - g_dbus_connection_unregister_object (connection, registration_id); - registration_id = 0; - } - - g_free (gconf_dbus_default_db); - gconf_dbus_default_db = NULL; - - if (introspection_data) { - g_dbus_node_info_unref (introspection_data); - introspection_data = NULL; - } - - if (connection) { - g_object_unref (connection); - connection = NULL; - } -} - -gpointer -tracker_locale_gconfdbus_notify_add (TrackerLocaleID id, - TrackerLocaleNotifyFunc func, - gpointer user_data, - GFreeFunc destroy_notify) -{ - TrackerLocaleNotification *data; - - /* Can be called from a thread */ - - g_assert (func != NULL); - - data = g_slice_new (TrackerLocaleNotification); - data->id = id; - data->func = func; - data->user_data = user_data; - data->destroy_notify = destroy_notify; - - g_mutex_lock (&subscribers_mutex); - subscribers = g_slist_prepend (subscribers, data); - g_mutex_unlock (&subscribers_mutex); - - return data; -} - -static gboolean -destroy_locale_notify (gpointer data_p) -{ - /* Always on mainloop */ - - TrackerLocaleNotification *data = data_p; - - /* Call the provided destroy_notify if any. */ - if (data->destroy_notify) { - data->destroy_notify (data->user_data); - } - - /* And fully dispose the notification data */ - g_slice_free (TrackerLocaleNotification, data); - - return FALSE; -} - -void -tracker_locale_gconfdbus_notify_remove (gpointer notification_id) -{ - GSList *li; - - /* Can be called from a thread */ - - g_mutex_lock (&subscribers_mutex); - - li = g_slist_find (subscribers, notification_id); - if (li) { - TrackerLocaleNotification *data = li->data; - - /* Remove item from list of subscribers */ - subscribers = g_slist_delete_link (subscribers, li); - - g_idle_add (destroy_locale_notify, data); - } - - g_mutex_unlock (&subscribers_mutex); -} diff --git a/src/libtracker-common/tracker-locale-gconfdbus.h b/src/libtracker-common/tracker-locale-gconfdbus.h deleted file mode 100644 index 237ffebe5..000000000 --- a/src/libtracker-common/tracker-locale-gconfdbus.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2011 Nokia - * - * 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_LOCALE_GCONFDBUS_H__ -#define __LIBTRACKER_COMMON_LOCALE_GCONFDBUS_H__ - -#include - -G_BEGIN_DECLS - -#if !defined (__LIBTRACKER_COMMON_INSIDE__) && !defined (TRACKER_COMPILATION) -#error "only must be included directly." -#endif - -#include "tracker-locale.h" - -void tracker_locale_gconfdbus_init (void); -void tracker_locale_gconfdbus_shutdown (void); - -gpointer tracker_locale_gconfdbus_notify_add (TrackerLocaleID id, - TrackerLocaleNotifyFunc func, - gpointer user_data, - GFreeFunc destroy_notify); -void tracker_locale_gconfdbus_notify_remove (gpointer notification_id); - -G_END_DECLS - -#endif /* __LIBTRACKER_COMMON_LOCALE_GCONFDBUS_H__ */ diff --git a/src/libtracker-common/tracker-locale.c b/src/libtracker-common/tracker-locale.c index e2cfab1dd..e76c10b25 100644 --- a/src/libtracker-common/tracker-locale.c +++ b/src/libtracker-common/tracker-locale.c @@ -26,10 +26,6 @@ #include "tracker-locale.h" -#ifdef HAVE_MEEGOTOUCH -#include "tracker-locale-gconfdbus.h" -#endif /* HAVE_MEEGOTOUCH */ - /* Current locales in use. They will be stored in heap and available throughout * the whole program execution, so will be reported as still reachable by Valgrind. */ @@ -102,23 +98,11 @@ tracker_locale_set (TrackerLocaleID id, g_rec_mutex_unlock (&locales_mutex); } -void -tracker_locale_shutdown (void) -{ -#ifdef HAVE_MEEGOTOUCH - tracker_locale_gconfdbus_shutdown (); -#endif /* HAVE_MEEGOTOUCH */ -} - void tracker_locale_init (void) { guint i; -#ifdef HAVE_MEEGOTOUCH - tracker_locale_gconfdbus_init (); -#endif /* HAVE_MEEGOTOUCH */ - /* Initialize those not retrieved from gconf, or if not in meegotouch */ for (i = 0; i < TRACKER_LOCALE_LAST; i++) { if (!current_locales[i]) { @@ -159,6 +143,19 @@ tracker_locale_init (void) initialized = TRUE; } +void +tracker_locale_shutdown (void) +{ + gint i; + + for (i = 0; i < TRACKER_LOCALE_LAST; i++) { + g_free (current_locales[i]); + current_locales[i] = NULL; + } + + initialized = FALSE; +} + gchar * tracker_locale_get (TrackerLocaleID id) { @@ -176,27 +173,3 @@ tracker_locale_get (TrackerLocaleID id) return locale; } - -gpointer -tracker_locale_notify_add (TrackerLocaleID id, - TrackerLocaleNotifyFunc func, - gpointer user_data, - GFreeFunc destroy_notify) -{ -#ifdef HAVE_MEEGOTOUCH - return tracker_locale_gconfdbus_notify_add (id, func, user_data, destroy_notify); -#else - /* If not using gconf locales, this is a no-op... */ - return NULL; -#endif /* HAVE_MEEGOTOUCH */ -} - -void -tracker_locale_notify_remove (gpointer notification_id) -{ -#ifdef HAVE_MEEGOTOUCH - return tracker_locale_gconfdbus_notify_remove (notification_id); -#else - /* If not using gconf locales, this is a no-op... */ -#endif /* HAVE_MEEGOTOUCH */ -} diff --git a/src/libtracker-common/tracker-locale.h b/src/libtracker-common/tracker-locale.h index 3ade737bd..d1b800338 100644 --- a/src/libtracker-common/tracker-locale.h +++ b/src/libtracker-common/tracker-locale.h @@ -38,32 +38,18 @@ typedef enum { TRACKER_LOCALE_LAST } TrackerLocaleID; -/* Callback for the notification of locale changes */ -typedef void (* TrackerLocaleNotifyFunc) (TrackerLocaleID id, - gpointer user_data); +void tracker_locale_init (void); +void tracker_locale_shutdown (void); /* Get the current locale of the given type. * Note that it returns a newly-allocated string which should be g_free()-ed */ gchar *tracker_locale_get (TrackerLocaleID id); -/* Adds a new subscriber to locale change notifications. - * Returns a pointer which identifies the subscription. - */ -gpointer tracker_locale_notify_add (TrackerLocaleID id, - TrackerLocaleNotifyFunc func, - gpointer user_data, - GFreeFunc destroy_notify); - -/* Remove a given subscriber, passing the id you got in _add() */ -void tracker_locale_notify_remove (gpointer notification_id); - const gchar* tracker_locale_get_name (guint i); void tracker_locale_set (TrackerLocaleID id, const gchar *value); -void tracker_locale_init (void); -void tracker_locale_shutdown (void); G_END_DECLS diff --git a/src/libtracker-common/tracker-meego.cpp b/src/libtracker-common/tracker-meego.cpp deleted file mode 100644 index 2d840aa53..000000000 --- a/src/libtracker-common/tracker-meego.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2010, Nokia (ivan.frade@nokia.com) - * - * This program 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 program 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 program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#include -#include - -#include - -#include "tracker-miner-meego.h" - -static QCoreApplication *app = NULL; -/* - * MeeGo application functions... - */ -void -tracker_meego_init (void) -{ - char *argv[] = { "dummy", NULL }; - int argc = 1; - - /* We need the app for loading translations */ - app = new QApplication (argc, argv, FALSE); -} - -void -tracker_meego_shutdown (void) -{ - delete app; -} - -/* The meego desktop files are using the qt translation system to get - * localized strings using catalog and string ids. QApplication and - * MLocale are needed for loading the translation catalogs. The - * returned string is a multi-string one which has parts of different - * length separated by '\x9C' unicode escape sequences. - * - * FIXME: This is insane, try to get rid of at least some of the extra - * layers here. - */ -gchar * -tracker_meego_translate (const gchar *catalogue, - const gchar *id) -{ - /* Get the system default locale */ - MLocale locale; - - /* Load the catalog from disk if not already there */ - if(!locale.isInstalledTrCatalog (catalogue)) { - locale.installTrCatalog (catalogue); - MLocale::setDefault (locale); - } - - gchar *ret = g_strdup (qtTrId (id).toUtf8 ().data ()); - - /* We only want the first string of the multi-string, so if - * the separator character is found (encoded as C2:9C in UTF-8), - * we just end the string in that point */ - gchar *next_string = strstr (ret, "\xC2\x9C"); - if (next_string) { - *next_string = '\0'; - } - - return ret; -} - -/* - * MeeGo general functions... - */ -gchar * -tracker_meego_get_locale (void) -{ - /* Get the system default locale */ - MLocale locale; - - return g_strdup (locale.name ().toAscii ().data ()); -} diff --git a/src/libtracker-common/tracker-meego.h b/src/libtracker-common/tracker-meego.h deleted file mode 100644 index d9724b6bd..000000000 --- a/src/libtracker-common/tracker-meego.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010, Nokia - * - * 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 __LIBTRACKER_COMMON_MEEGO_H__ -#define __LIBTRACKER_COMMON_MEEGO_H__ - -G_BEGIN_DECLS - -void tracker_meego_init (void); -void tracker_meego_shutdown (void); - -/* MeeGo general functions */ -gchar *tracker_meego_get_locale (void); - -/* MeeGo application functions */ -gchar *tracker_meego_translate (const gchar *catalogue, - const gchar *id); - -G_END_DECLS - -#endif /* __LIBTRACKER_COMMON_MEEGO_H__ */ diff --git a/src/libtracker-common/tracker-miner-locale.c b/src/libtracker-common/tracker-miner-locale.c index 9cf39f5ae..a247383b7 100644 --- a/src/libtracker-common/tracker-miner-locale.c +++ b/src/libtracker-common/tracker-miner-locale.c @@ -20,12 +20,8 @@ #include "config.h" #include -#include - +#include "tracker-locale.h" #include "tracker-miner-locale.h" -#ifdef HAVE_MEEGOTOUCH -#include "tracker-miner-meego.h" -#endif /* NOTE: This applies to more miners than just the application miner, * it's kept this way to avoid breaking things. @@ -35,18 +31,8 @@ static gchar * miner_locale_get_filename (void) { - gchar *data_dir; - gchar *filename; - /* Locate locale file */ - data_dir = g_build_filename (g_get_user_cache_dir (), - "tracker", - NULL); - filename = g_build_filename (data_dir, TRACKER_MINER_LOCALE_FILE, NULL); - - g_free (data_dir); - - return filename; + return g_build_filename (g_get_user_cache_dir (), "tracker", TRACKER_MINER_LOCALE_FILE, NULL); } static gchar * @@ -86,14 +72,8 @@ miner_locale_get_current (void) { gchar *current_locale; -#ifdef HAVE_MEEGOTOUCH - /* If we have meegotouch enabled, take the correct locale as the one from - * meegotouch. */ - current_locale = tracker_miner_meego_get_locale (); -#else /* Get current tracker LANG locale */ current_locale = tracker_locale_get (TRACKER_LOCALE_LANGUAGE); -#endif return current_locale; } diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c index 12903bfe1..2cbac29b8 100644 --- a/src/libtracker-data/tracker-db-interface-sqlite.c +++ b/src/libtracker-data/tracker-db-interface-sqlite.c @@ -921,17 +921,6 @@ check_interrupt (void *user_data) return g_cancellable_is_cancelled (db_interface->cancellable) ? 1 : 0; } -static void -tracker_locale_notify_cb (TrackerLocaleID id, - gpointer user_data) -{ - TrackerDBInterface *db_interface = user_data; - - /* Request a collator reset. Use thread-safe methods as this function will get - * called from the main thread */ - g_atomic_int_compare_and_exchange (&(db_interface->collator_reset_requested), FALSE, TRUE); -} - static void open_database (TrackerDBInterface *db_interface, GError **error) @@ -963,11 +952,6 @@ open_database (TrackerDBInterface *db_interface, /* Set our unicode collation function */ tracker_db_interface_sqlite_reset_collator (db_interface); - /* And register for updates on locale changes */ - db_interface->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_COLLATE, - tracker_locale_notify_cb, - db_interface, - NULL); sqlite3_progress_handler (db_interface->db, 100, check_interrupt, db_interface); @@ -1360,10 +1344,6 @@ tracker_db_interface_sqlite_finalize (GObject *object) g_free (db_interface->filename); g_free (db_interface->busy_status); - if (db_interface->locale_notification_id) { - tracker_locale_notify_remove (db_interface->locale_notification_id); - } - G_OBJECT_CLASS (tracker_db_interface_parent_class)->finalize (object); } diff --git a/src/miners/apps/tracker-miner-applications.c b/src/miners/apps/tracker-miner-applications.c index 4ea4434ca..9e092dd13 100644 --- a/src/miners/apps/tracker-miner-applications.c +++ b/src/miners/apps/tracker-miner-applications.c @@ -42,8 +42,6 @@ static gboolean miner_applications_process_file_attributes (TrackerMinerFS GFile *file, TrackerSparqlBuilder *sparql, GCancellable *cancellable); -static void miner_applications_finalize (GObject *object); - static GQuark miner_applications_error_quark = 0; @@ -67,11 +65,8 @@ G_DEFINE_TYPE_WITH_CODE (TrackerMinerApplications, tracker_miner_applications, T static void tracker_miner_applications_class_init (TrackerMinerApplicationsClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); TrackerMinerFSClass *miner_fs_class = TRACKER_MINER_FS_CLASS (klass); - object_class->finalize = miner_applications_finalize; - miner_fs_class->process_file = miner_applications_process_file; miner_fs_class->process_file_attributes = miner_applications_process_file_attributes; @@ -127,11 +122,6 @@ miner_applications_basedir_add (TrackerMinerFS *fs, static void miner_applications_add_directories (TrackerMinerFS *fs) { -#ifdef HAVE_MEEGOTOUCH - TrackerIndexingTree *indexing_tree; - GFile *file; - const gchar *path; -#endif /* HAVE_MEEGOTOUCH */ const gchar * const *xdg_dirs; const gchar *user_data_dir; gint i; @@ -171,19 +161,6 @@ miner_applications_add_directories (TrackerMinerFS *fs) #endif /* HAVE_MEEGOTOUCH */ } -static void -tracker_locale_notify_cb (TrackerLocaleID id, - gpointer user_data) -{ - TrackerMiner *miner = user_data; - - if (tracker_miner_applications_detect_locale_changed (miner)) { - tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner), TRUE); - - miner_applications_add_directories (TRACKER_MINER_FS (miner)); - } -} - static void miner_finished_cb (TrackerMinerFS *fs, gdouble seconds_elapsed, @@ -205,12 +182,10 @@ miner_applications_initable_init (GInitable *initable, GError **error) { TrackerMinerFS *fs; - TrackerMinerApplications *app; GError *inner_error = NULL; TrackerIndexingTree *indexing_tree; fs = TRACKER_MINER_FS (initable); - app = TRACKER_MINER_APPLICATIONS (initable); indexing_tree = tracker_miner_fs_get_indexing_tree (fs); /* Set up files filter, deny every file, but @@ -238,34 +213,9 @@ miner_applications_initable_init (GInitable *initable, miner_applications_add_directories (fs); -#ifdef HAVE_MEEGOTOUCH - tracker_meego_init (); -#endif /* HAVE_MEEGOTOUCH */ - - app->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_LANGUAGE, - tracker_locale_notify_cb, - app, - NULL); - return TRUE; } -static void -miner_applications_finalize (GObject *object) -{ - TrackerMinerApplications *app; - - app = TRACKER_MINER_APPLICATIONS (object); - - tracker_locale_notify_remove (app->locale_notification_id); - -#ifdef HAVE_MEEGOTOUCH - tracker_meego_shutdown (); -#endif /* HAVE_MEEGOTOUCH */ - - G_OBJECT_CLASS (tracker_miner_applications_parent_class)->finalize (object); -} - static void insert_data_from_desktop_file (TrackerSparqlBuilder *sparql, const gchar *subject, diff --git a/src/miners/user-guides/tracker-miner-user-guides.c b/src/miners/user-guides/tracker-miner-user-guides.c index 3c513dcee..8328dfacc 100644 --- a/src/miners/user-guides/tracker-miner-user-guides.c +++ b/src/miners/user-guides/tracker-miner-user-guides.c @@ -60,7 +60,6 @@ static gboolean miner_userguides_process_file_attributes (TrackerMinerFS * GFile *file, TrackerSparqlBuilder *sparql, GCancellable *cancellable); -static void miner_userguides_finalize (GObject *object); static void parser_get_file_content (const gchar *uri, gssize max_extract_size, gchar **content, @@ -77,11 +76,8 @@ G_DEFINE_TYPE_WITH_CODE (TrackerMinerUserguides, tracker_miner_userguides, TRACK static void tracker_miner_userguides_class_init (TrackerMinerUserguidesClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); TrackerMinerFSClass *miner_fs_class = TRACKER_MINER_FS_CLASS (klass); - object_class->finalize = miner_userguides_finalize; - miner_fs_class->process_file = miner_userguides_process_file; miner_fs_class->process_file_attributes = miner_userguides_process_file_attributes; @@ -217,19 +213,6 @@ miner_userguides_add_directories (TrackerMinerFS *fs) } } -static void -tracker_locale_notify_cb (TrackerLocaleID id, - gpointer user_data) -{ - TrackerMiner *miner = user_data; - - if (tracker_miner_userguides_detect_locale_changed (miner)) { - tracker_miner_fs_set_mtime_checking (TRACKER_MINER_FS (miner), TRUE); - - miner_userguides_add_directories (TRACKER_MINER_FS (miner)); - } -} - static void miner_finished_cb (TrackerMinerFS *fs, gdouble seconds_elapsed, @@ -251,12 +234,10 @@ miner_userguides_initable_init (GInitable *initable, GError **error) { TrackerMinerFS *fs; - TrackerMinerUserguides *app; GError *inner_error = NULL; TrackerIndexingTree *indexing_tree; fs = TRACKER_MINER_FS (initable); - app = TRACKER_MINER_USERGUIDES (initable); indexing_tree = tracker_miner_fs_get_indexing_tree (fs); /* Set up files filter, deny every file, but @@ -281,34 +262,9 @@ miner_userguides_initable_init (GInitable *initable, miner_userguides_add_directories (fs); -#ifdef HAVE_MEEGOTOUCH - tracker_meego_init (); -#endif /* HAVE_MEEGOTOUCH */ - - app->locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_LANGUAGE, - tracker_locale_notify_cb, - app, - NULL); - return TRUE; } -static void -miner_userguides_finalize (GObject *object) -{ - TrackerMinerUserguides *app; - - app = TRACKER_MINER_USERGUIDES (object); - - tracker_locale_notify_remove (app->locale_notification_id); - -#ifdef HAVE_MEEGOTOUCH - tracker_meego_shutdown (); -#endif /* HAVE_MEEGOTOUCH */ - - G_OBJECT_CLASS (tracker_miner_userguides_parent_class)->finalize (object); -} - static const gchar * get_file_urn (TrackerMinerFS *miner, GFile *file, diff --git a/src/tracker-store/Makefile.am b/src/tracker-store/Makefile.am index 4c201de46..7e4845acc 100644 --- a/src/tracker-store/Makefile.am +++ b/src/tracker-store/Makefile.am @@ -22,7 +22,6 @@ tracker_store_SOURCES = \ tracker-config.c \ tracker-dbus.vala \ tracker-events.c \ - tracker-locale-change.c \ tracker-main.vala \ tracker-resources.vala \ tracker-statistics.vala \ @@ -34,7 +33,6 @@ tracker_store_SOURCES = \ noinst_HEADERS = \ tracker-config.h \ tracker-events.h \ - tracker-locale-change.h \ tracker-store.h \ tracker-writeback.h diff --git a/src/tracker-store/tracker-locale-change.c b/src/tracker-store/tracker-locale-change.c deleted file mode 100644 index 46f1477d4..000000000 --- a/src/tracker-store/tracker-locale-change.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2010 Nokia - * - * 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 -#include -#include - -#include -#include -#include - -#include -#include - -#include "tracker-store.h" -#include "tracker-events.h" -#include "tracker-locale-change.h" - -typedef struct { - gpointer resources; -} TrackerLocaleChangeContext; - -/* Private */ -static gpointer locale_notification_id; -static gboolean locale_change_notified; - -static void -locale_change_process_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - TrackerStatus *notifier; - TrackerBusyCallback busy_callback; - gpointer busy_user_data; - GDestroyNotify busy_destroy_notify; - TrackerLocaleChangeContext *ctxt = user_data; - GError *error = NULL; - - notifier = TRACKER_STATUS (tracker_dbus_get_object (TRACKER_TYPE_STATUS)); - - busy_callback = tracker_status_get_callback (notifier, - &busy_user_data, - &busy_destroy_notify); - - g_message ("Processing locale change..."); - /* Reload! This will regenerate indexes with the new locale */ - tracker_data_manager_reload (busy_callback, - busy_user_data, - "Changing locale", - &error); - - if (error) { - g_critical ("Error reloading database for locale change: %s", - error->message); - g_error_free (error); - } - - busy_destroy_notify (busy_user_data); - - if (ctxt->resources) { - tracker_events_init (); - tracker_resources_enable_signals (ctxt->resources); - g_object_unref (ctxt->resources); - } - g_free (ctxt); - - tracker_store_resume (); - - locale_change_notified = FALSE; -} - -static gboolean -locale_change_process_idle_cb (gpointer data) -{ - TrackerLocaleChangeContext *ctxt; - - ctxt = g_new0 (TrackerLocaleChangeContext, 1); - ctxt->resources = tracker_dbus_get_object (TRACKER_TYPE_RESOURCES); - if (ctxt->resources) { - g_object_ref (ctxt->resources); - tracker_resources_disable_signals (ctxt->resources); - tracker_events_shutdown (); - } - - /* Note: Right now, the passed callback may be called instantly and not - * in an idle. */ - g_message ("Setting tracker-store as inactive..."); - tracker_store_pause (locale_change_process_cb, ctxt); - - return FALSE; -} - -static void -locale_notify_cb (TrackerLocaleID id, - gpointer user_data) -{ - if (locale_change_notified) { - g_message ("Locale change was already notified, not doing it again"); - } else { - locale_change_notified = TRUE; - /* Set an idle callback to process the locale change. - * NOTE: We cannot process it right here because we will be - * closing and opening new connections to the DB while doing it, - * and the DB connections are also part of the subscriber list - * for locale changes, so we may end up waiting to acquire an - * already locked mutex. - */ - g_message ("Locale change notified, preparing to rebuild indexes..."); - g_idle_add (locale_change_process_idle_cb, NULL); - } -} - -void -tracker_locale_change_initialize_subscription (void) -{ - gchar *collation_locale; - - collation_locale = tracker_locale_get (TRACKER_LOCALE_COLLATE); - - g_debug ("Initial collation locale is '%s', subscribing for updates...", - collation_locale); - - locale_notification_id = tracker_locale_notify_add (TRACKER_LOCALE_COLLATE, - locale_notify_cb, - NULL, - NULL); - g_free (collation_locale); -} - -void -tracker_locale_change_shutdown_subscription (void) -{ - tracker_locale_notify_remove (locale_notification_id); -} diff --git a/src/tracker-store/tracker-locale-change.h b/src/tracker-store/tracker-locale-change.h deleted file mode 100644 index 7d630012c..000000000 --- a/src/tracker-store/tracker-locale-change.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Nokia - * - * 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_STORE_LOCALE_CHANGE_H__ -#define __TRACKER_STORE_LOCALE_CHANGE_H__ - -#include - -G_BEGIN_DECLS - -void tracker_locale_change_initialize_subscription (void); -void tracker_locale_change_shutdown_subscription (void); - -G_END_DECLS - -#endif /* __TRACKER_STORE_LOCALE_CHANGE_H__ */ diff --git a/src/tracker-store/tracker-main.vala b/src/tracker-store/tracker-main.vala index 7d611319f..8d991c6eb 100644 --- a/src/tracker-store/tracker-main.vala +++ b/src/tracker-store/tracker-main.vala @@ -285,9 +285,6 @@ License which can be viewed at: notifier = null; if (!shutdown) { - /* Setup subscription to get notified of locale changes */ - Tracker.locale_change_initialize_subscription (); - Tracker.DBus.register_prepare_class_signal (); Tracker.Events.init (); @@ -322,8 +319,6 @@ License which can be viewed at: Tracker.Writeback.shutdown (); Tracker.Events.shutdown (); - Tracker.locale_change_shutdown_subscription (); - Tracker.DBus.shutdown (); Tracker.Data.Manager.shutdown (); Tracker.Log.shutdown (); -- cgit v1.2.1