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 ("Locale change detected, so resetting miner to " "remove all previously created items..."); miner_applications_reset (miner); } return changed; }
gboolean tracker_miner_applications_detect_locale_changed (TrackerMiner *miner) { gboolean changed; changed = tracker_miner_locale_changed (); if (changed) { g_message ("Locale change detected, so resetting miner to " "remove all previously created items..."); miner_applications_reset (miner); } return changed; }