aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@novell.com>2010-12-02 01:48:01 +0800
committerFederico Mena Quintero <federico@novell.com>2010-12-04 07:56:54 +0800
commitddda6649744b49e3fbd2221c015aea2571300ab2 (patch)
tree2a788436b556711aed4d9757bc721e09102027ea
parent558599a20190c54446be716625cf129bc60db199 (diff)
downloadgsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar.gz
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar.bz2
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar.lz
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar.xz
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.tar.zst
gsoc2013-evolution-ddda6649744b49e3fbd2221c015aea2571300ab2.zip
Function to set a CamelURL's defaults based on a provider's defaults
In http://bugs.meego.com/show_bug.cgi?id=6498, part of the problem is that when a mail account is created through the startup wizard in Express mode, that account does not receive the default values that were defined by its respective CamelProvider (i.e. the provider->extra_conf CamelProviderConfEntry structures). However, the defaults *are* used if an account is created when not in Express mode. The problem is that Express mode doesn't include the "Receiving options" page in its mail account editor, while non-express mode does. The utility functions to populate that page's widgets are the ones responsible for setting the provider's default values on the CamelURL for the new account. Since in Express mode those widgets don't even get created, the provider's defaults are never even considered. Here, what we do is to pull out the logic from those functions that create widgets, so that we have set_provider_defaults_on_url(), a single function to set default values from a CamelProvider into a CamelURL. We will use that function to set the defaults in both Express and non-express modes, instead of depending on the widget code to do that. Signed-off-by: Federico Mena Quintero <federico@novell.com>
-rw-r--r--mail/em-account-editor.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index d1e05795b0..96c5c27434 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -3670,6 +3670,95 @@ em_account_editor_commit (EMAccountEditor *emae)
}
static void
+set_checkbox_default (CamelProviderConfEntry *entry, CamelURL *url)
+{
+ const gchar *value;
+
+ g_assert (entry->type == CAMEL_PROVIDER_CONF_CHECKBOX);
+
+ if (atoi (entry->value) != 0)
+ value = "";
+ else
+ value = NULL;
+
+ camel_url_set_param (url, entry->name, value);
+
+ /* FIXME: do we need to call emae_uri_changed()? */
+}
+
+static void
+set_entry_default (CamelProviderConfEntry *entry, CamelURL *url)
+{
+ g_assert (entry->type == CAMEL_PROVIDER_CONF_ENTRY);
+
+ camel_url_set_param (url, entry->name, entry->value);
+ /* FIXME: This comes from emae_option_entry(). That function calls
+ * emae_uri_changed(), but the corresponding emae_option_toggle() does
+ * not call emae_uri_changed() when it creates the checkbuttons - do
+ * we need to call that function at all?
+ */
+}
+
+static void
+set_checkspin_default (CamelProviderConfEntry *entry, CamelURL *url)
+{
+ gdouble min, def, max;
+ gchar on;
+
+ g_assert (entry->type == CAMEL_PROVIDER_CONF_CHECKSPIN);
+
+ /* FIXME: this is a fugly api. See emae_option_checkspin() */
+ if (sscanf (entry->value, "%c:%lf:%lf:%lf", &on, &min, &def, &max) != 4) {
+ min = 0.0;
+ def = 0.0;
+ max = 1.0;
+ }
+
+ if (on == 'y') {
+ gchar value[16];
+
+ sprintf (value, "%d", (gint) def);
+ camel_url_set_param (url, entry->name, value);
+ } else
+ camel_url_set_param (url, entry->name, NULL);
+
+ /* FIXME: do we need to call emae_uri_changed()? */
+}
+
+static void
+set_provider_defaults_on_url (CamelProvider *provider, CamelURL *url)
+{
+ CamelProviderConfEntry *entries;
+ int i;
+
+ entries = provider->extra_conf;
+
+ for (i = 0; entries && entries[i].type != CAMEL_PROVIDER_CONF_END; i++) {
+ switch (entries[i].type) {
+ case CAMEL_PROVIDER_CONF_CHECKBOX:
+ set_checkbox_default (entries + i, url);
+ break;
+
+ case CAMEL_PROVIDER_CONF_ENTRY:
+ set_entry_default (entries + i, url);
+ break;
+
+ case CAMEL_PROVIDER_CONF_CHECKSPIN:
+ set_checkspin_default (entries + i, url);
+ break;
+
+ default:
+ /* Other entry types don't have defaults, or so can be
+ * inferred from emae_option_*(). But see
+ * emae_option_options() - that *may* need something,
+ * but that function doesn't actually modify the
+ * CamelURL. */
+ break;
+ }
+ }
+}
+
+static void
em_account_editor_construct (EMAccountEditor *emae, EMAccountEditorType type, const gchar *id)
{
EMAccountEditorPrivate *priv = emae->priv;