From ef6a3af717132e0750f226fa8a0ee0f3c98e19f0 Mon Sep 17 00:00:00 2001 From: Michael Zucci Date: Mon, 20 Sep 2004 05:59:55 +0000 Subject: Merged notzed-eplugin-2-branch to head. svn path=/trunk/; revision=27300 --- e-util/e-account.c | 196 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 156 insertions(+), 40 deletions(-) (limited to 'e-util/e-account.c') diff --git a/e-util/e-account.c b/e-util/e-account.c index 37132017f0..61282ced8e 100644 --- a/e-util/e-account.c +++ b/e-util/e-account.c @@ -37,6 +37,13 @@ #define PARENT_TYPE G_TYPE_OBJECT static GObjectClass *parent_class = NULL; +enum { + CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + /* lock mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts disable adding mail accounts Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable @@ -81,6 +88,16 @@ class_init (GObjectClass *object_class) /* virtual method override */ object_class->finalize = finalize; + + signals[CHANGED] = + g_signal_new("changed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EAccountClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, + G_TYPE_INT); } static void @@ -89,6 +106,9 @@ init (EAccount *account) account->id = g_new0 (EAccountIdentity, 1); account->source = g_new0 (EAccountService, 1); account->transport = g_new0 (EAccountService, 1); + + account->source->auto_check = FALSE; + account->source->auto_check_time = 10; } static void @@ -412,10 +432,11 @@ e_account_set_from_xml (EAccount *account, const char *xml) xmlFreeDoc (doc); + g_signal_emit(account, signals[CHANGED], 0, -1); + return changed; } - /** * e_account_import: * @dest: destination account object @@ -481,8 +502,9 @@ e_account_import (EAccount *dest, EAccount *src) dest->smime_encrypt_to_self = src->smime_encrypt_to_self; g_free (dest->smime_encrypt_key); dest->smime_encrypt_key = g_strdup (src->smime_encrypt_key); -} + g_signal_emit(dest, signals[CHANGED], 0, -1); +} /** * e_account_to_xml: @@ -641,44 +663,55 @@ static struct _system_info { { "transport", 1<\n%s\n", xml); + g_free(xml); +} + +/* TODO: should it return true if it changed? */ +void e_account_set_string(EAccount *ea, e_account_item_t type, const char *val) +{ + char **p; + + if (!e_account_writable(ea, type)) { + g_warning("Trying to set non-writable option account value"); + } else { + p = (char **)addr(ea, type); + printf("Setting string %d: old '%s' new '%s'\n", type, *p, val); + if (*p != val + && (*p == NULL || val == NULL || strcmp(*p, val) != 0)) { + g_free(*p); + *p = g_strdup(val); + + dump_account(ea); + g_signal_emit(ea, signals[CHANGED], 0, type); + } + } +} + +void e_account_set_int(EAccount *ea, e_account_item_t type, int val) +{ + if (!e_account_writable(ea, type)) { + g_warning("Trying to set non-writable option account value"); + } else { + int *p = (int *)addr(ea, type); + + if (*p != val) { + *p = val; + dump_account(ea); + g_signal_emit(ea, signals[CHANGED], 0, type); + } + } +} + +void e_account_set_bool(EAccount *ea, e_account_item_t type, gboolean val) +{ + if (!e_account_writable(ea, type)) { + g_warning("Trying to set non-writable option account value"); + } else { + gboolean *p = (gboolean *)addr(ea, type); + + if (*p != val) { + *p = val; + dump_account(ea); + g_signal_emit(ea, signals[CHANGED], 0, type); + } + } +} + gboolean e_account_writable_option(EAccount *ea, const char *protocol, const char *option) { @@ -789,5 +905,5 @@ e_account_writable(EAccount *ea, e_account_item_t type) { ea_setting_setup(); - return (account_perms[type].perms & ea_perms) == 0; + return (account_info[type].perms & ea_perms) == 0; } -- cgit v1.2.3