[evolution-kolab/ek-wip-xfb: 5/8] KolabSettingsHandler: added a user home dir char field



commit 38ac190f7d4b9150b7d8d9a4e18d00189321d222
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Tue Oct 23 12:02:18 2012 +0200

    KolabSettingsHandler: added a user home dir char field
    
    * new char field to get the user's home dir
    * this is a read-only field, writing it
      is denied

 src/libekolab/kolab-settings-handler.c |   38 ++++++++++++++++++++++++++++++++
 src/libekolab/kolab-settings-handler.h |    1 +
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/kolab-settings-handler.c b/src/libekolab/kolab-settings-handler.c
index f7bdf34..8041e15 100644
--- a/src/libekolab/kolab-settings-handler.c
+++ b/src/libekolab/kolab-settings-handler.c
@@ -79,6 +79,8 @@ static gboolean settings_handler_char_get_func_camel_cache_dir (KolabSettingsHan
 static gboolean settings_handler_char_set_func_camel_cache_dir (KolabSettingsHandler*, gchar*, GError**);
 static gboolean settings_handler_char_get_func_camel_config_dir (KolabSettingsHandler*, GError**);
 static gboolean settings_handler_char_set_func_camel_config_dir (KolabSettingsHandler*, gchar*, GError**);
+static gboolean settings_handler_char_get_func_user_home_dir (KolabSettingsHandler*, GError**);
+static gboolean settings_handler_char_set_func_user_home_dir (KolabSettingsHandler*, gchar*, GError**);
 static gboolean settings_handler_uint_set_func_folder_context (KolabSettingsHandler*, guint value, GError**);
 
 static KolabSettingsHandlerGetFunc _kolab_settings_handler_char_get_funcs[] = {
@@ -86,6 +88,7 @@ static KolabSettingsHandlerGetFunc _kolab_settings_handler_char_get_funcs[] = {
 	settings_handler_char_get_func_camel_cache_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CACHE_DIR */
 	settings_handler_char_get_func_camel_config_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CONFIG_DIR */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_ACCOUNT_DIR */
+	settings_handler_char_get_func_user_home_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD */
 };
@@ -95,6 +98,7 @@ static KolabSettingsHandlerCharSetFunc _kolab_settings_handler_char_set_funcs[]
 	settings_handler_char_set_func_camel_cache_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CACHE_DIR */
 	settings_handler_char_set_func_camel_config_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CONFIG_DIR */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_ACCOUNT_DIR */
+	settings_handler_char_set_func_user_home_dir, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID */
 	NULL, /* KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD */
 };
@@ -220,6 +224,27 @@ settings_handler_char_get_func_camel_cache_dir (KolabSettingsHandler *self, GErr
 }
 
 static gboolean
+settings_handler_char_get_func_user_home_dir (KolabSettingsHandler *self, GError **err)
+{
+	KolabSettingsHandlerPrivate *priv = NULL;
+	gchar *home_dir = NULL;
+
+	g_assert (KOLAB_IS_SETTINGS_HANDLER (self));
+	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+	priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
+
+	home_dir = priv->sdata_char[KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR];
+	if (home_dir != NULL)
+		return TRUE;
+
+	home_dir = g_strdup (g_get_home_dir ());
+
+	priv->sdata_char[KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR] = home_dir;
+	return TRUE;
+}
+
+static gboolean
 settings_handler_char_set_func_camel_data_dir (KolabSettingsHandler *self, gchar *value, GError **err)
 {
 	(void)self;
@@ -245,6 +270,19 @@ settings_handler_char_set_func_camel_cache_dir (KolabSettingsHandler *self, gcha
 }
 
 static gboolean
+settings_handler_char_set_func_user_home_dir (KolabSettingsHandler *self, gchar *value, GError **err)
+{
+	(void)self;
+	(void)value;
+	/* FIXME mark as a translatable string */
+	g_set_error (err,
+	             KOLAB_BACKEND_ERROR,
+	             KOLAB_BACKEND_ERROR_GENERIC,
+	             "Cannot set user home directory, it is a read-only resource");
+	return FALSE;
+}
+
+static gboolean
 settings_handler_char_get_func_camel_config_dir (KolabSettingsHandler *self, GError **err)
 {
 	KolabSettingsHandlerPrivate *priv = KOLAB_SETTINGS_HANDLER_PRIVATE (self);
diff --git a/src/libekolab/kolab-settings-handler.h b/src/libekolab/kolab-settings-handler.h
index 02f1b7d..daab89d 100644
--- a/src/libekolab/kolab-settings-handler.h
+++ b/src/libekolab/kolab-settings-handler.h
@@ -125,6 +125,7 @@ typedef enum {
 	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CACHE_DIR,
 	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_CONFIG_DIR,
 	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_CAMEL_ACCOUNT_DIR,
+	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_USER_HOME_DIR,
 	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_ESOURCE_UID,
 	KOLAB_SETTINGS_HANDLER_CHAR_FIELD_KOLAB_USER_PASSWORD,
 	KOLAB_SETTINGS_HANDLER_CHAR_LAST_FIELD



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]