From be00bf6ac1a1397207ee17c559f637741fb0e640 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 19 Oct 2004 06:35:44 +0000 Subject: ** See bug #67014. 2004-10-11 Not Zed ** See bug #67014. * mail-errors.xml: added "checking-service" error. * em-account-editor.c (em_account_editor_construct): keep track of the dialogue (emae_editor_destroyed): , and clean up when destroyed. * em-account-editor.c (emae_check_authtype) (emae_check_authtype_response, emae_check_authtype_done): handle checking authtype gui here. * mail-config.c (check_service_describe, check_service_check) (check_response, mail_config_check_service): removed. * mail-ops.c (mail_check_service): moved here from mail-config, and modified to be a re-usable threaded function. svn path=/trunk/; revision=27615 --- mail/ChangeLog | 20 +++++++++ mail/em-account-editor.c | 59 ++++++++++++++++++++---- mail/mail-config.c | 114 ----------------------------------------------- mail/mail-config.h | 3 -- mail/mail-errors.xml | 7 +++ mail/mail-errors.xml.h | 4 ++ mail/mail-ops.c | 77 ++++++++++++++++++++++++++++++++ mail/mail-ops.h | 3 ++ 8 files changed, 162 insertions(+), 125 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 752865b4c9..ad57a40fa2 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,23 @@ +2004-10-11 Not Zed + + ** See bug #67014. + + * mail-errors.xml: added "checking-service" error. + + * em-account-editor.c (em_account_editor_construct): keep track of + the dialogue + (emae_editor_destroyed): , and clean up when destroyed. + + * em-account-editor.c (emae_check_authtype) + (emae_check_authtype_response, emae_check_authtype_done): handle + checking authtype gui here. + + * mail-config.c (check_service_describe, check_service_check) + (check_response, mail_config_check_service): removed. + + * mail-ops.c (mail_check_service): moved here from mail-config, + and modified to be a re-usable threaded function. + 2004-10-18 Not Zed ** See bug #68006. diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index d80bc9edbd..5cfde83efb 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -123,6 +123,9 @@ typedef struct _EMAccountEditorService { struct _GtkButton *check_supported; struct _GtkToggleButton *needs_auth; + struct _GtkWidget *check_dialog; + int check_id; + GList *authtypes; /* if "Check supported" */ CamelProvider *provider; CamelProviderType type; @@ -1407,19 +1410,51 @@ emae_setup_authtype(EMAccountEditor *emae, EMAccountEditorService *service) return (GtkWidget *)dropdown; } +static void emae_check_authtype_done(const char *uri, CamelProviderType type, GList *types, void *data) +{ + EMAccountEditorService *service = data; + + if (service->check_dialog) { + if (service->authtypes) + g_list_free(service->authtypes); + + service->authtypes = g_list_copy(types); + emae_setup_authtype(service->emae, service); + gtk_widget_destroy(service->check_dialog); + } + + if (service->emae->editor) + gtk_widget_set_sensitive(service->emae->editor, TRUE); + + service->check_id = -1; + g_object_unref(service->emae); +} + +static void emae_check_authtype_response(GtkWidget *d, int button, EMAccountEditorService *service) +{ + mail_msg_cancel(service->check_id); + gtk_widget_destroy(service->check_dialog); + service->check_dialog = NULL; + + if (service->emae->editor) + gtk_widget_set_sensitive(service->emae->editor, TRUE); +} + static void emae_check_authtype(GtkWidget *w, EMAccountEditorService *service) { EMAccountEditor *emae = service->emae; const char *uri; - if (service->authtypes) { - g_list_free(service->authtypes); - service->authtypes = NULL; - } - + /* TODO: do we need to remove the auth mechanism from the uri? */ uri = e_account_get_string(emae->account, emae_service_info[service->type].account_uri_key); - if (mail_config_check_service(uri, service->type, &service->authtypes, (GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emae->editor))) - emae_setup_authtype(emae, service); + g_object_ref(emae); + + service->check_dialog = e_error_new((GtkWindow *)gtk_widget_get_toplevel(emae->editor), + "mail:checking-service", NULL); + g_signal_connect(service->check_dialog, "response", G_CALLBACK(emae_check_authtype_response), service); + gtk_widget_show(service->check_dialog); + gtk_widget_set_sensitive(emae->editor, FALSE); + service->check_id = mail_check_service(uri, service->type, emae_check_authtype_done, service); } static void @@ -2331,6 +2366,13 @@ emae_commit(EConfig *ec, GSList *items, void *data) e_account_list_save(accounts); } +static void +emae_editor_destroyed(GtkWidget *dialog, EMAccountEditor *emae) +{ + emae->editor = NULL; + g_object_unref(emae); +} + void em_account_editor_construct(EMAccountEditor *emae, EAccount *account, em_account_editor_t type) { @@ -2435,5 +2477,6 @@ em_account_editor_construct(EMAccountEditor *emae, EAccount *account, em_account e_config_set_target((EConfig *)ec, (EConfigTarget *)target); emae->editor = e_config_create_window((EConfig *)ec, NULL, type==EMAE_NOTEBOOK?_("Account Editor"):_("Evolution Account Assistant")); - /* FIXME: need to hook onto destroy as required */ + g_object_ref(emae); + g_signal_connect(emae->editor, "destroy", G_CALLBACK(emae_editor_destroyed), emae); } diff --git a/mail/mail-config.c b/mail/mail-config.c index c16113d4ab..c1c8adf02d 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -878,120 +878,6 @@ mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix) return filename; } - -/* Async service-checking/authtype-lookup code. */ -struct _check_msg { - struct _mail_msg msg; - - const char *url; - CamelProviderType type; - GList **authtypes; - gboolean *success; -}; - -static char * -check_service_describe (struct _mail_msg *mm, int complete) -{ - return g_strdup (_("Checking Service")); -} - -static void -check_service_check (struct _mail_msg *mm) -{ - struct _check_msg *m = (struct _check_msg *)mm; - CamelService *service = NULL; - - camel_operation_register(mm->cancel); - - service = camel_session_get_service (session, m->url, m->type, &mm->ex); - if (!service) { - camel_operation_unregister(mm->cancel); - return; - } - - if (m->authtypes) - *m->authtypes = camel_service_query_auth_types (service, &mm->ex); - else - camel_service_connect (service, &mm->ex); - - camel_object_unref (service); - *m->success = !camel_exception_is_set(&mm->ex); - - camel_operation_unregister(mm->cancel); -} - -static struct _mail_msg_op check_service_op = { - check_service_describe, - check_service_check, - NULL, - NULL -}; - -static void -check_response (GtkDialog *dialog, int button, gpointer data) -{ - int *msg_id = data; - - mail_msg_cancel (*msg_id); -} - -/** - * mail_config_check_service: - * @url: service url - * @type: provider type - * @authtypes: set to list of supported authtypes on return if non-%NULL. - * - * Checks the service for validity. If @authtypes is non-%NULL, it will - * be filled in with a list of supported authtypes. - * - * Return value: %TRUE on success or %FALSE on error. - **/ -gboolean -mail_config_check_service (const char *url, CamelProviderType type, GList **authtypes, GtkWindow *window) -{ - static GtkWidget *dialog = NULL; - gboolean ret = FALSE; - struct _check_msg *m; - GtkWidget *label; - int id; - - if (dialog) { - gdk_window_raise (dialog->window); - *authtypes = NULL; - return FALSE; - } - - m = mail_msg_new (&check_service_op, NULL, sizeof(*m)); - m->url = url; - m->type = type; - m->authtypes = authtypes; - m->success = &ret; - - id = m->msg.seq; - e_thread_put(mail_thread_new, (EMsg *)m); - - /* FIXME: make this use e-error. - * It has to be modal otherwise we can get nasty re-entrancy whilst waiting for the - * subthread to complete. - * FIXME: make this whole function async to deal with this issue */ - dialog = gtk_dialog_new_with_buttons(_("Connecting to server..."), window, - GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - NULL); - label = gtk_label_new (_("Connecting to server...")); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG (dialog)->vbox), - label, TRUE, TRUE, 10); - g_signal_connect(dialog, "response", G_CALLBACK (check_response), &id); - gtk_widget_show_all (dialog); - - mail_msg_wait(id); - - gtk_widget_destroy (dialog); - dialog = NULL; - - return ret; -} - ESignatureList * mail_config_get_signatures (void) { diff --git a/mail/mail-config.h b/mail/mail-config.h index 3618e9465c..679dabeb7d 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -161,9 +161,6 @@ void mail_config_uri_deleted (GCompareFunc uri_cmp, const char *uri); char *mail_config_folder_to_cachename (struct _CamelFolder *folder, const char *prefix); char *mail_config_folder_to_safe_url (struct _CamelFolder *folder); -/* Ugh, this totally does not belong in this module */ -gboolean mail_config_check_service (const char *url, CamelProviderType type, GList **authtypes, struct _GtkWindow *window); - GType evolution_mail_config_get_type (void); gboolean evolution_mail_config_factory_init (void); diff --git a/mail/mail-errors.xml b/mail/mail-errors.xml index 04208457a5..a71b35962d 100644 --- a/mail/mail-errors.xml +++ b/mail/mail-errors.xml @@ -318,6 +318,13 @@ You can choose to ignore this folder, overwrite or append its contents, or quit. you can accept its license. + + Querying server + Please wait. + Querying server for a list of supported authentication mechanisms. +