From bc6046b8f1bb7c50cae563c08cb9d55c956ff38b Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 18 Mar 2004 04:55:10 +0000 Subject: added interface to find out if various fields or server options are 2004-03-18 Not Zed * e-account.c (e_account_writable, e_account_writable_option): added interface to find out if various fields or server options are writable. to work around gconf limitations. svn path=/trunk/; revision=25109 --- e-util/e-account.c | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 224 insertions(+), 1 deletion(-) (limited to 'e-util/e-account.c') diff --git a/e-util/e-account.c b/e-util/e-account.c index 80e36bf0a1..d14761a029 100644 --- a/e-util/e-account.c +++ b/e-util/e-account.c @@ -32,9 +32,46 @@ #include #include +#include + #define PARENT_TYPE G_TYPE_OBJECT static GObjectClass *parent_class = NULL; +/* +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 +disable editing mail accounts Relatively difficult -- involves redesign of the XML blobs which describe accounts +disable removing mail accounts +lock default character encoding Simple -- Gconf key + a little UI work to desensitize widgets, etc +disable free busy publishing +disable specific mime types (from being viewed) 90% done already (Unknown MIME types still pose a problem) +lock image loading preference +lock junk mail filtering settings +** junk mail per account +lock work week +lock first day of work week +lock working hours +disable forward as icalendar +lock color options for tasks +lock default contact filing format +* forbid signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable +* lock user to having 1 specific signature Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable +* forbid adding/removing signatures Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable +* lock each account to a certain signature Relatively difficult -- involved redesign of the XML blobs which describe accounts +* set default folders +set trash emptying frequency +* lock displayed mail headers Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable +* lock authentication type (for incoming mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts +* lock authentication type (for outgoing mail) Relatively difficult -- involves redesign of the XML blobs which describe accounts +* lock minimum check mail on server frequency Simple -- can be done with just a Gconf key and some UI work to make assoc. widgets unavailable +** lock save password +* require ssl always Relatively difficult -- involves redesign of the XML blobs which describe accounts +** lock imap subscribed folder option +** lock filtering of inbox +** lock source account/options +** lock destination account/options +*/ + static void finalize (GObject *); static void @@ -528,7 +565,6 @@ e_account_to_xml (EAccount *account) return tmp; } - /** * e_account_uid_from_xml: * @xml: an XML account description @@ -558,3 +594,190 @@ e_account_uid_from_xml (const char *xml) return uid; } + +enum { + EAP_IMAP_SUBSCRIBED = 0, + EAP_IMAP_NAMESPACE, + EAP_FILTER_INBOX, + EAP_FILTER_JUNK, + EAP_FORCE_SSL, + EAP_LOCK_SIGNATURE, + EAP_LOCK_AUTH, + EAP_LOCK_AUTOCHECK, + EAP_LOCK_DEFAULT_FOLDERS, + EAP_LOCK_SAVE_PASSWD, + EAP_LOCK_SOURCE_URL, + EAP_LOCK_TRANSPORT_URL, +}; + +static struct _system_info { + const char *key; + guint32 perm; +} system_perms[] = { + { "imap_subscribed", 1<key, '/'); + g_return_if_fail (tkey != NULL); + + info = g_hash_table_lookup(ea_system_table, tkey+1); + if (info) { + if (gconf_value_get_bool(value)) + ea_perms |= info->perm; + else + ea_perms &= ~info->perm; + } + + printf("checking key '%s', new perms '%08x'\n", tkey+1, ea_perms); +} + +static void +ea_setting_setup(void) +{ + GConfClient *gconf = gconf_client_get_default(); + GConfEntry *entry; + GError *err = NULL; + int i; + char key[64]; + + if (ea_option_table != NULL) + return; + + ea_option_table = g_hash_table_new(g_str_hash, g_str_equal); + for (i=0;imessage); + g_error_free(err); + } + + gconf_client_notify_add(gconf, LOCK_BASE, (GConfClientNotifyFunc)ea_setting_notify, NULL, NULL, NULL); + g_object_unref(gconf); +} + +gboolean +e_account_writable_option(EAccount *ea, const char *protocol, const char *option) +{ + char *key; + struct _option_info *info; + + ea_setting_setup(); + + key = alloca(strlen(protocol)+strlen(option)+2); + sprintf(key, "%s_%s", protocol, option); + + info = g_hash_table_lookup(ea_option_table, key); + if (info == NULL) { + sprintf(key, "*_%s", option); + info = g_hash_table_lookup(ea_option_table, key); + } + + printf("checking writable option '%s' perms=%08x\n", option, info?info->perms:0); + + return info == NULL + || (info->perms & ea_perms) == 0; +} + +gboolean +e_account_writable(EAccount *ea, e_account_item_t type) +{ + ea_setting_setup(); + + return (account_perms[type].perms & ea_perms) == 0; +} -- cgit