diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 29 | ||||
-rw-r--r-- | mail/mail-config-gui.c | 195 | ||||
-rw-r--r-- | mail/mail-ops.c | 25 | ||||
-rw-r--r-- | mail/message-list.c | 2 |
4 files changed, 204 insertions, 47 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index e5852981b5..5b09940faa 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,11 @@ +2000-09-05 Peter Williams <peterw@helixcode.com> + + * mail-ops.c (cleanup_load_folder): Check for NULL folder. + (mail_do_setup_folder): Copy the 'name' parameter so that + we can free it. + + * message-list.c (nuke_uids): Depth '-1' means "unlimited", not 0. + 2000-09-05 Dan Winship <danw@helixcode.com> * component-factory.c (owner_set_cb): Re-rename "Sent". @@ -130,6 +138,27 @@ needed by `evolution_storage_new_folder()'. * mail-vfolder.c (vfolder_refresh): Likewise. +2000-08-31 Peter Williams <peterw@helixcode.com> + + * folder-browser.c (folder_browser_new): Don't ref the shell: + causes a race upon exit. + (folder_browser_destroy): Don't unref it. + + * mail-config-gui.c (service_page_item_new): Add a checkbutton + "use default port" to make life simple. + (service_page_get_url): Honor use_default_port. + (service_page_set_url): Set use_default_port based on the input + URL. + (toggle_port): New function, sets the sensitivity of the + port entry based on "use default port" + + (config_do_query_authtypes): Make this asynchronous, as it + may involve connecting to a server. + (service_page_detect): Call the async auth querier. + (service_page_item_new): Put the authentication stuff in if + the url_flags have URL_ALLOW_AUTH. Call the async auth querier + to get the info. + 2000-08-30 Ettore Perazzoli <ettore@helixcode.com> * mail-view.c (mail_view_create): Make the HTML widget grab the diff --git a/mail/mail-config-gui.c b/mail/mail-config-gui.c index abe582fe27..49466b64a4 100644 --- a/mail/mail-config-gui.c +++ b/mail/mail-config-gui.c @@ -36,6 +36,7 @@ #include "e-util/e-unicode.h" #include "mail.h" #include "mail-threads.h" +#include "mail-tools.h" #include "mail-config.h" #include "mail-config-gui.h" @@ -50,7 +51,6 @@ typedef struct CamelProvider *provider; CamelService *service; CamelProviderType type; - GList *authtypes; } MailService; struct _MailDialogIdentityPage @@ -86,6 +86,7 @@ typedef struct GtkWidget *keep_on_server; gint pnum; gint default_port; + GtkWidget *use_default_port; } MailDialogServicePageItem; struct _MailDialogServicePage @@ -178,6 +179,7 @@ typedef struct /* private prototypes - these are ugly, rename some of them? */ static void config_do_test_service (const char *url, CamelProviderType type); +static void config_do_query_authtypes (MailDialogServicePage *page, const char *url, CamelProviderType type); static void html_size_req (GtkWidget *widget, GtkRequisition *requisition); static GtkWidget *html_new (gboolean white); @@ -306,18 +308,15 @@ provider_list_add (GSList *services, CamelProviderType type, url = g_strdup_printf ("%s:", prov->protocol); service = camel_session_get_service (session, url, type, ex); + camel_exception_free (ex); g_free (url); - if (!service) { - camel_exception_free (ex); + if (!service) return services; - } mcs = g_new (MailService, 1); mcs->provider = prov; mcs->service = service; mcs->type = type; - mcs->authtypes = camel_service_query_auth_types (mcs->service, ex); - camel_exception_free (ex); return g_slist_prepend (services, mcs); } @@ -589,7 +588,7 @@ service_page_get_url (MailDialogServicePage *page) url->user = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (spitem->user), 0, -1); if (spitem->host) url->host = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (spitem->host), 0, -1); - if (spitem->port) { + if (spitem->port && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (spitem->use_default_port))) { gchar *val; val = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (spitem->port), 0, -1); @@ -600,7 +599,10 @@ service_page_get_url (MailDialogServicePage *page) url->port = 0; g_free (val); + } else { + url->port = 0; } + if (spitem->path) { gchar *path; path = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (spitem->path), @@ -665,6 +667,8 @@ service_page_set_url (MailDialogServicePage *page, MailConfigService *service) if (url && url->port) { tmp = g_strdup_printf ("%d", url->port); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (spitem->use_default_port), + FALSE); } else if (spitem->default_port) { tmp = g_strdup_printf ("%d", spitem->default_port); } else { @@ -839,33 +843,11 @@ service_page_detect (GtkWidget *button, MailDialogServicePage *page) { MailDialogServicePageItem *spitem; char *url = NULL; - CamelException *ex; - CamelService *service; - GList *authtypes; spitem = page->spitem; url = service_page_get_url (page); - ex = camel_exception_new (); - service = camel_session_get_service (session, url, spitem->type, ex); - g_free (url); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) - goto error; - - authtypes = camel_service_query_auth_types (service, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) - goto error; - - service_page_item_auth_fill (page, spitem, authtypes); - - camel_exception_free (ex); - - return; - - error: - error_dialog (button, "Could not detect supported authentication " - "types:\n%s", camel_exception_get_description (ex)); - camel_exception_free (ex); + config_do_query_authtypes (page, url, spitem->type); } static void @@ -895,6 +877,18 @@ service_page_add_elem (MailDialogServicePage *page, GtkWidget *table, return entry; } +static void +toggle_port (GtkWidget *w, gpointer user_data) +{ + MailDialogServicePage *page; + gboolean val; + + page = (MailDialogServicePage *) user_data; + + val = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)); + gtk_widget_set_sensitive (page->spitem->port, val); +} + static MailDialogServicePageItem * service_page_item_new (MailDialogServicePage *page, MailService *mcs) { @@ -926,11 +920,39 @@ service_page_item_new (MailDialogServicePage *page, MailService *mcs) service_flags = mcs->service->url_flags & ~CAMEL_SERVICE_URL_NEED_AUTH; if (service_flags & CAMEL_SERVICE_URL_ALLOW_HOST) { + GtkWidget *w; + item->host = service_page_add_elem (page, table, row++, _("Server:")); item->hostneed = ((service_flags & CAMEL_SERVICE_URL_NEED_HOST) == CAMEL_SERVICE_URL_NEED_HOST); - item->port = service_page_add_elem (page, table, row++, _("Port:")); + item->default_port = mcs->provider->default_ports[mcs->type]; + + w = gtk_label_new (_("Port:")); + gtk_table_attach (GTK_TABLE (table), w, 0, 1, + row, row + 1, GTK_FILL, 0, 0, 0); + gtk_misc_set_alignment (GTK_MISC (w), 1, 0.5); + + item->port = gtk_entry_new(); + gtk_table_attach (GTK_TABLE (table), item->port, + 1, 2, row, row + 1, + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, + 0, 0); + gtk_signal_connect (GTK_OBJECT (item->port), "changed", + GTK_SIGNAL_FUNC (service_page_item_changed), page); + gtk_widget_set_sensitive (item->port, FALSE); + + item->use_default_port = gtk_check_button_new_with_label (_("Use default port")); + gtk_table_attach (GTK_TABLE (table), item->use_default_port, + 2, 3, row, row + 1, + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, + 0, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->use_default_port), + TRUE); + gtk_signal_connect (GTK_OBJECT (item->use_default_port), "toggled", + GTK_SIGNAL_FUNC (toggle_port), + page); + row++; } if (service_flags & CAMEL_SERVICE_URL_ALLOW_USER) { @@ -945,8 +967,9 @@ service_page_item_new (MailDialogServicePage *page, MailService *mcs) == CAMEL_SERVICE_URL_NEED_PATH); } - if (mcs->authtypes) { + if (mcs->service->url_flags & CAMEL_SERVICE_URL_ALLOW_AUTH) { GtkWidget *label; + gchar *url; label = gtk_label_new (_("Authentication:")); gtk_table_attach (GTK_TABLE (table), label, 0, 1, @@ -977,8 +1000,10 @@ service_page_item_new (MailDialogServicePage *page, MailService *mcs) 0, 3, row + 1, row + 2, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - service_page_item_auth_fill (page, item, mcs->authtypes); - + /* this is done async */ + url = camel_url_to_string (mcs->service->url, FALSE); + config_do_query_authtypes (page, url, mcs->type); + g_free (url); row += 2; } @@ -2317,3 +2342,105 @@ config_do_test_service (const char *url, CamelProviderType type) mail_operation_queue (&op_test_service, input, TRUE); } + +/* ************************************************************************ */ + +typedef struct query_authtypes_input_s { + MailDialogServicePage *page; + gchar *url; + CamelProviderType type; +} query_authtypes_input_t; + +typedef struct query_authtypes_data_s { + CamelService *service; + GList *items; +} query_authtypes_data_t; + +static gchar *describe_query_authtypes (gpointer in_data, gboolean gerund); +static void setup_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex); +static void do_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex); +static void cleanup_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex); + +static gchar *describe_query_authtypes (gpointer in_data, gboolean gerund) +{ + query_authtypes_input_t *input = (query_authtypes_input_t *) in_data; + + if (gerund) { + return g_strdup_printf (_("Querying authorization capabilities of \"%s\""), input->url); + } else { + return g_strdup_printf (_("Query authorization at \"%s\""), input->url); + } +} + +static void setup_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex) +{ + query_authtypes_input_t *input = (query_authtypes_input_t *) in_data; + query_authtypes_data_t *data = (query_authtypes_data_t *) op_data; + + if (!input->page) { + camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, + "No service page was provided to test"); + return; + } + + if (!input->url) { + camel_exception_set (ex, CAMEL_EXCEPTION_INVALID_PARAM, + "No URL was provided to test"); + return; + } + + data->items = NULL; + data->service = NULL; +} + +static void do_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex) +{ + query_authtypes_input_t *input = (query_authtypes_input_t *) in_data; + query_authtypes_data_t *data = (query_authtypes_data_t *) op_data; + + data->service = camel_session_get_service (session, input->url, input->type, ex); + if (!data->service) + return; + + data->items = camel_service_query_auth_types (data->service, ex); +} + +static void cleanup_query_authtypes (gpointer in_data, gpointer op_data, CamelException *ex) +{ + query_authtypes_input_t *input = (query_authtypes_input_t *) in_data; + query_authtypes_data_t *data = (query_authtypes_data_t *) op_data; + + if (data->items && input->page->spitem->auth_optionmenu && + GTK_WIDGET_VISIBLE (input->page->spitem->auth_optionmenu)) + service_page_item_auth_fill (input->page, input->page->spitem, data->items); + + if (data->service) { + mail_tool_camel_lock_up(); + camel_service_free_auth_types (data->service, data->items); + camel_object_unref (CAMEL_OBJECT (data->service)); + mail_tool_camel_lock_down(); + } + + g_free (input->url); +} + +static const mail_operation_spec op_query_authtypes = { + describe_query_authtypes, + sizeof (query_authtypes_data_t), + setup_query_authtypes, + do_query_authtypes, + cleanup_query_authtypes +}; + +static void +config_do_query_authtypes (MailDialogServicePage *page, const char *url, CamelProviderType type) +{ + query_authtypes_input_t *input; + + input = g_new (query_authtypes_input_t, 1); + input->page = page; + input->url = g_strdup (url); + input->type = type; + + mail_operation_queue (&op_query_authtypes, input, TRUE); +} diff --git a/mail/mail-ops.c b/mail/mail-ops.c index a122f19a33..5cb1287ff1 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1594,16 +1594,17 @@ cleanup_load_folder (gpointer in_data, gpointer op_data, CamelException *ex) { load_folder_input_t *input = (load_folder_input_t *) in_data; - gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_entry), - camel_folder_has_search_capability (input-> - fb-> - folder)); - gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_menu), - camel_folder_has_search_capability (input-> - fb-> - folder)); - - message_list_set_folder (input->fb->message_list, input->fb->folder); + if (input->fb->folder) { + gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_entry), + camel_folder_has_search_capability (input-> + fb-> + folder)); + gtk_widget_set_sensitive (GTK_WIDGET (input->fb->search_menu), + camel_folder_has_search_capability (input-> + fb-> + folder)); + message_list_set_folder (input->fb->message_list, input->fb->folder); + } /*g_free (input->url); = fb->uri now */ } @@ -2104,7 +2105,7 @@ mail_do_edit_messages (CamelFolder *folder, GPtrArray *uids, /* ** SETUP FOLDER ****************************************************** */ typedef struct setup_folder_input_s { - const char *name; + gchar *name; CamelFolder **folder; } setup_folder_input_t; @@ -2167,7 +2168,7 @@ mail_do_setup_folder (const char *name, CamelFolder **folder) setup_folder_input_t *input; input = g_new (setup_folder_input_t, 1); - input->name = name; + input->name = g_strdup (name); input->folder = folder; mail_operation_queue (&op_setup_folder, input, TRUE); } diff --git a/mail/message-list.c b/mail/message-list.c index 8ee4541248..004163c0d5 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -862,7 +862,7 @@ nuke_uids (GtkObject *o) ETreeModel *etm = E_TREE_MODEL (o); g_node_traverse (etm->root, G_IN_ORDER, - G_TRAVERSE_ALL, 0, + G_TRAVERSE_ALL, -1, nuke_uids_cb, etm); } |