[evolution-data-server/openismus-work-master: 28/134] EBookBackendFile: Implement EBookBackend->set_locale() & ->get_locale()
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 28/134] EBookBackendFile: Implement EBookBackend->set_locale() & ->get_locale()
- Date: Sat, 19 Oct 2013 18:59:22 +0000 (UTC)
commit 4e491a365af66e646544ad4afb5a3aa0a21fc542
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Thu May 23 16:26:26 2013 +0900
EBookBackendFile: Implement EBookBackend->set_locale() & ->get_locale()
addressbook/backends/file/e-book-backend-file.c | 51 +++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index 0201c5c..9ed04df 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -76,6 +76,7 @@ struct _EBookBackendFilePrivate {
gchar *base_directory;
gchar *photo_dirname;
gchar *revision;
+ gchar *locale;
gint rev_counter;
gboolean revision_guards;
GRWLock lock;
@@ -678,6 +679,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)
{
@@ -994,6 +1011,7 @@ 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));
@@ -1069,6 +1087,7 @@ book_backend_file_open_sync (EBookBackend *backend,
BOOK_BACKEND_PROPERTY_REVISION,
bf->priv->revision);
}
+
g_rw_lock_writer_unlock (&(bf->priv->lock));
e_backend_set_online (E_BACKEND (backend), TRUE);
@@ -1606,6 +1625,33 @@ book_backend_file_sync (EBookBackend *backend)
/* FIXME: Tell sqlite to dump NOW ! */
}
+static void
+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 *
+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,
@@ -1726,6 +1772,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 (
@@ -1767,6 +1816,8 @@ e_book_backend_file_class_init (EBookBackendFileClass *class)
backend_class->get_direct_book = book_backend_file_get_direct_book;
backend_class->configure_direct = book_backend_file_configure_direct;
backend_class->sync = book_backend_file_sync;
+ backend_class->set_locale = book_backend_file_set_locale;
+ backend_class->get_locale = book_backend_file_get_locale;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]