Commit 87efc5c0 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

EBookBackendFile: Implement EBookBackend->set_locale() & ->get_locale()

parent 87a2a86d
......@@ -79,6 +79,7 @@ struct _EBookBackendFilePrivate {
gchar *base_directory;
gchar *photo_dirname;
gchar *revision;
gchar *locale;
gint rev_counter;
gboolean revision_guards;
GRWLock lock;
......@@ -665,6 +666,22 @@ e_book_backend_file_load_revision (EBookBackendFile *bf)
}
}
static void
e_book_backend_file_load_locale (EBookBackendFile *bf)
{
GError *error = NULL;
if (!e_book_backend_sqlitedb_get_locale (bf->priv->sqlitedb,
SQLITEDB_FOLDER_ID,
&bf->priv->locale,
&error)) {
g_warning (
G_STRLOC ": Error loading database locale setting: %s",
error ? error->message : "Unknown error");
g_clear_error (&error);
}
}
static void
set_revision (EBookBackendFile *bf,
EContact *contact)
......@@ -1496,6 +1513,7 @@ e_book_backend_file_finalize (GObject *object)
g_free (priv->photo_dirname);
g_free (priv->revision);
g_free (priv->locale);
g_free (priv->base_directory);
g_rw_lock_clear (&(priv->lock));
......@@ -1503,6 +1521,33 @@ e_book_backend_file_finalize (GObject *object)
G_OBJECT_CLASS (e_book_backend_file_parent_class)->finalize (object);
}
static void
e_book_backend_file_set_locale (EBookBackend *backend,
const gchar *locale)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
GError *error = NULL;
if (!e_book_backend_sqlitedb_set_locale (bf->priv->sqlitedb,
SQLITEDB_FOLDER_ID,
locale,
&error)) {
g_free (bf->priv->locale);
bf->priv->locale = g_strdup (locale);
g_warning ("Failed to set locale on SQLiteDB: %s", error->message);
g_error_free (error);
}
}
static const gchar *
e_book_backend_file_get_locale (EBookBackend *backend)
{
EBookBackendFile *bf = E_BOOK_BACKEND_FILE (backend);
return bf->priv->locale;
}
static gboolean
book_backend_file_initable_init (GInitable *initable,
GCancellable *cancellable,
......@@ -1623,6 +1668,9 @@ book_backend_file_initable_init (GInitable *initable,
}
}
/* Load the locale */
e_book_backend_file_load_locale (E_BOOK_BACKEND_FILE (initable));
/* Resolve the photo directory here. */
priv->photo_dirname =
e_book_backend_file_extract_path_from_source (
......@@ -1696,6 +1744,8 @@ e_book_backend_file_class_init (EBookBackendFileClass *class)
backend_class->notify_update = e_book_backend_file_notify_update;
backend_class->get_direct_book = e_book_backend_file_get_direct_book;
backend_class->configure_direct = e_book_backend_file_configure_direct;
backend_class->set_locale = e_book_backend_file_set_locale;
backend_class->get_locale = e_book_backend_file_get_locale;
sync_class->open_sync = e_book_backend_file_open;
sync_class->get_backend_property_sync = e_book_backend_file_get_backend_property;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment