[anjal] Redo account editor. Use from Evo's code mostly.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Redo account editor. Use from Evo's code mostly.
- Date: Thu, 30 Apr 2009 13:44:04 -0400 (EDT)
commit 3f1bb8341e342087c818c0c7b4f6002bf6b43cc7
Author: Srinivasa Ragavan <sragavan novell com>
Date: Thu Apr 30 23:03:57 2009 +0530
Redo account editor. Use from Evo's code mostly.
---
src/mail-account-view.c | 375 ++++++++++-------------------------------------
src/mail-account-view.h | 36 +----
2 files changed, 79 insertions(+), 332 deletions(-)
diff --git a/src/mail-account-view.c b/src/mail-account-view.c
index 7706441..d342507 100644
--- a/src/mail-account-view.c
+++ b/src/mail-account-view.c
@@ -79,315 +79,84 @@ mail_account_view_class_init (MailAccountViewClass *klass)
}
-static gint
-provider_compare (const CamelProvider *p1, const CamelProvider *p2)
-{
- /* sort providers based on "location" (ie. local or remote) */
- if (p1->flags & CAMEL_PROVIDER_IS_REMOTE) {
- if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
- return 0;
- return -1;
- } else {
- if (p2->flags & CAMEL_PROVIDER_IS_REMOTE)
- return 1;
- return 0;
- }
-}
-
-static GtkWidget *
-create_identity_page (MailAccountView *view)
-{
- GtkWidget *table, *box, *tmp, *label, *entry;
-
- table = gtk_table_new (4,2, FALSE);
- gtk_table_set_row_spacings (table, 12);
- label = gtk_label_new (_("Name:"));
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->full_name = entry;
- gtk_widget_show (label);
- gtk_table_attach (table, label, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Email:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->email = entry;
- gtk_table_attach (table, label, 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
+enum {
+ ENC_NONE=0,
+ ENC_TLS,
+ ENC_SSL
+};
-/*
- label = gtk_label_new (_("Reply-to:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- gtk_table_attach (table, label, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Organization:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- gtk_table_attach (table, label, 0, 1, 3, 4, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 3, 4, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-*/
- label = gtk_label_new (_("Password:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->password = entry;
- gtk_entry_set_visibility (entry, FALSE);
- gtk_table_attach (table, label, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- gtk_widget_show(table);
-
- return table;
-}
+enum {
+ SRV_IMAP=0,
+ SRV_POP,
+ SRV_LAST
+};
-static void
-fill_identity (MailAccountView *view)
-{
- if (view->original) {
- gtk_entry_set_text(view->full_name, e_account_get_string(view->account, E_ACCOUNT_ID_NAME));
- gtk_entry_set_text(view->email, e_account_get_string(view->account, E_ACCOUNT_ID_ADDRESS));
- } else {
- gtk_entry_set_text(view->full_name, g_get_real_name());
- }
-}
+enum {
+ GMAIL = 0,
+ YAHOO,
+ AOL
+};
+struct _server_prefill {
+ char *key;
+ char *recv;
+ char *send;
+ int proto;
+ int ssl;
+} std_server [] = {
+ {"gmail", "imap.gmail.com", "smtp.gmail.com", SRV_IMAP, ENC_SSL},
+ {"yahoo", "pop3.yahoo.com", "smtp.yahoo.com", SRV_POP, ENC_NONE},
+ {"aol", "imap.aol.com", "smtp.aol.com", SRV_IMAP, ENC_NONE},
+};
-static GtkWidget *
-create_receive_page (MailAccountView *view)
+static int
+check_servers (char *server)
{
- GtkWidget *table, *box, *tmp, *label, *entry;
-
- table = gtk_table_new (6,2, FALSE);
- gtk_table_set_row_spacings (table, 12);
-
- label = gtk_label_new (_("Email:"));
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->source->email = entry;
- gtk_widget_show (label);
-
- label = gtk_label_new (_("Server type:"));
- gtk_widget_show (label);
- entry = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (entry, _("IMAP"));
- gtk_combo_box_append_text (entry, _("POP"));
- gtk_combo_box_set_active (entry, 0);
- gtk_widget_show(entry);
- view->source->providers = entry;
- gtk_table_attach (table, label, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Server address:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->source->hostname = entry;
- gtk_table_attach (table, label, 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Username:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->source->username = entry;
- gtk_table_attach (table, label, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
-
- label = gtk_label_new (_("Use encryption:"));
- gtk_widget_show (label);
- box = gtk_hbox_new (FALSE, 0);
- entry = gtk_combo_box_new_text ();
- gtk_widget_show(entry);
- view->source->use_ssl = entry;
- gtk_combo_box_append_text (entry, _("SSL"));
- gtk_combo_box_append_text (entry, _("TLS"));
- gtk_combo_box_append_text (entry, _("None"));
- gtk_combo_box_set_active (entry, 0);
- gtk_box_pack_start (box, entry, FALSE, FALSE, 0);
- tmp = gtk_label_new (_("Port:"));
- gtk_widget_show(tmp);
- gtk_box_pack_start (box, tmp, FALSE, FALSE, 12);
- entry = gtk_entry_new ();
- gtk_entry_set_max_length (entry, 3);
- gtk_widget_show(entry);
- view->source->port = entry;
- gtk_box_pack_start (box, entry, FALSE, FALSE, 0);
- gtk_widget_show(box);
- gtk_table_attach (table, label, 0, 1, 3, 4, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, box, 1, 2, 3, 4, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
-
- label = gtk_label_new (_("Authentication type:"));
- gtk_widget_show (label);
- entry = gtk_combo_box_new_text ();
- view->source->authtype = entry;
- gtk_combo_box_append_text (entry, _("None"));
- gtk_combo_box_append_text (entry, _("Password"));
- gtk_combo_box_set_active (entry, 0);
- gtk_widget_show(entry);
- gtk_table_attach (table, label, 0, 1, 4, 5, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 4, 5, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Password:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->source->password = entry;
- gtk_entry_set_visibility (entry, FALSE);
-
- gtk_table_attach (table, label, 0, 1, 5, 6, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 5, 6, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
+ int len = G_N_ELEMENTS(std_server), i;
- gtk_widget_show(table);
+ for (i=0; i<len; i++) {
+ if (strstr(server, std_server[i].key) != NULL)
+ return i;
+ }
- return table;
+ return -1;
}
static void
-fill_receive (MailAccountView *view)
+save_identity (MailAccountView *view)
{
- char *uri = e_account_get_string(view->account, E_ACCOUNT_SOURCE_URL);
- CamelURL *url = camel_url_new(uri, NULL);
-
- if (view->original) {
- char *port;
- const char *ssl;
-
- ssl = camel_url_get_param (url, "use_ssl");
- printf("%s\n", url->protocol);
- if (strcmp(url->protocol, "imap") == 0 ||
- (strcmp(url->protocol, "groupwise") == 0 && g_getenv("USE_IMAP") != NULL)) {
- port = (ssl && *ssl == 'a') ? "993" : "143";
- gtk_combo_box_set_active (view->source->providers, 0);
- }
- else if (strcmp(url->protocol, "pop") == 0) {
- port = (ssl && *ssl == 'a') ? "995" : "110";
- gtk_combo_box_set_active (view->source->providers, 1);
- }
- if (url->port) {
- char *str = g_strdup_printf("%d", url->port);
- gtk_entry_set_text (view->source->port, str);
- g_free(str);
- } else {
- gtk_entry_set_text (view->source->port, port);
+#if 0
+ if (!view->original) {
+ char *tmp = gtk_entry_get_text (view->email);
+ char **token;
+ int index;
+ if (tmp && *tmp) {
+ token = g_strsplit (tmp, "@", 2);
+ index = check_servers(token[1]);
+
+ gtk_entry_set_text (view->source->username, token[0]);
+ gtk_entry_set_text (view->transport->username, token[0]);
+ if (index != -1) {
+ gtk_combo_box_set_active (view->source->providers, std_server[index].proto);
+ gtk_combo_box_set_active (view->source->use_ssl, std_server[index].ssl);
+ gtk_combo_box_set_active (view->transport->use_ssl, std_server[index].ssl);
+
+ gtk_entry_set_text (view->source->hostname, std_server[index].recv);
+ gtk_entry_set_text (view->transport->hostname, std_server[index].send);
+ }
+ g_strfreev(token);
}
- gtk_entry_set_text (view->source->hostname, url->host);
- gtk_entry_set_text (view->source->username, url->user);
-
- } else {
- if (url)
- gtk_entry_set_text (view->source->hostname, url->host);
}
-
+#endif
}
-static GtkWidget *
-create_send_page (MailAccountView *view)
+static void
+save_send (MailAccountView *view)
{
- GtkWidget *table, *box, *tmp, *label, *entry;
-
- table = gtk_table_new (6,2, FALSE);
- gtk_table_set_row_spacings (table, 12);
-
- label = gtk_label_new (_("Server address:"));
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->transport->hostname = entry;
- gtk_widget_show (label);
- gtk_table_attach (table, label, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Username:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->transport->username = entry;
- gtk_table_attach (table, label, 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Use encryption:"));
- gtk_widget_show (label);
- box = gtk_hbox_new (FALSE, 0);
- entry = gtk_combo_box_new_text ();
- gtk_widget_show(entry);
- view->transport->use_ssl = entry;
- gtk_combo_box_append_text (entry, _("SSL"));
- gtk_combo_box_append_text (entry, _("TLS"));
- gtk_combo_box_append_text (entry, _("None"));
- gtk_combo_box_set_active (entry, 0);
- gtk_box_pack_start (box, entry, FALSE, FALSE, 0);
- tmp = gtk_label_new (_("Port:"));
- gtk_widget_show(tmp);
- gtk_box_pack_start (box, tmp, FALSE, FALSE, 12);
- entry = gtk_entry_new ();
- gtk_entry_set_max_length (entry, 3);
- gtk_widget_show(entry);
- view->transport->port = entry;
- gtk_box_pack_start (box, entry, FALSE, FALSE, 0);
- gtk_widget_show(box);
- gtk_table_attach (table, label, 0, 1, 2, 3, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, box, 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Authentication type:"));
- gtk_widget_show (label);
- entry = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (entry, _("None"));
- gtk_combo_box_append_text (entry, _("Password"));
- gtk_combo_box_set_active (entry, 0);
- gtk_widget_show(entry);
- view->transport->authtype = entry;
- gtk_table_attach (table, label, 0, 1, 3, 4, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 3, 4, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- label = gtk_label_new (_("Password:"));
- gtk_widget_show (label);
- entry = gtk_entry_new ();
- gtk_widget_show(entry);
- view->transport->password = entry;
- gtk_entry_set_visibility (entry, FALSE);
- gtk_table_attach (table, label, 0, 1, 4, 5, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, entry, 1, 2, 4, 5, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
-
- gtk_widget_show(table);
-
- return table;
}
-static void
-fill_send (MailAccountView *view)
+static void
+save_account (MailAccountView *view)
{
- char *uri = e_account_get_string(view->account, E_ACCOUNT_SOURCE_URL);
- CamelURL *url = camel_url_new(uri, NULL);
-
- if (view->original) {
- char *port;
- const char *ssl;
-
- ssl = camel_url_get_param (url, "use_ssl");
- port = (ssl && *ssl == 'a') ? "465" : "25";
-
- if (url->port) {
- char *str = g_strdup_printf("%d", url->port);
- gtk_entry_set_text (view->transport->port, str);
- g_free(str);
- } else {
- gtk_entry_set_text (view->transport->port, port);
- }
- gtk_entry_set_text (view->transport->hostname, url->host);
- gtk_entry_set_text (view->transport->username, url->user);
-
- } else {
- if(url)
- gtk_entry_set_text (view->transport->hostname, url->host);
- }
-
-
}
#define IDENTITY_DETAIL N_("To use the email application you'll need to setup an account. Put your email address and password in below \nand we'll try and work out all the settings. If we can't do it automatically you'll need your server details as well.")
@@ -405,16 +174,26 @@ struct _page_text {
char *detail;
GtkWidget * (*create_page) (MailAccountView *view);
void (*fill_page) (MailAccountView *view);
+ void (*save_page) (MailAccountView *view);
} mail_account_pages[] = {
- { MAV_IDENTITY_PAGE, N_("Identity"), N_("Next - Receiving mail"), NULL, IDENTITY_DETAIL, create_identity_page, fill_identity },
- { MAV_RECV_PAGE, N_("Receiving mail"), N_("Next - Sending mail"), N_("Back - Identity"), RECEIVE_DETAIL, create_receive_page, fill_receive},
- { MAV_SEND_PAGE, N_("Sending mail"), N_("Next - Review account"), N_("Back - Receiving mail"), SEND_DETAIL, create_send_page, fill_send},
- { MAV_REVIEW_PAGE, N_("Review account"), N_("Finish"), N_("Back - Sending"), REVIEW_DETAIL, NULL, NULL},
+ //{ MAV_IDENTITY_PAGE, N_("Identity"), N_("Next - Receiving mail"), NULL, IDENTITY_DETAIL, create_identity_page, fill_identity, save_identity },
+ //{ MAV_RECV_PAGE, N_("Receiving mail"), N_("Next - Sending mail"), N_("Back - Identity"), RECEIVE_DETAIL, create_receive_page, fill_receive, save_receive},
+ //{ MAV_SEND_PAGE, N_("Sending mail"), N_("Next - Review account"), N_("Back - Receiving mail"), SEND_DETAIL, create_send_page, fill_send, save_send},
+ //{ MAV_REVIEW_PAGE, N_("Review account"), N_("Finish"), N_("Back - Sending"), REVIEW_DETAIL, NULL, NULL, save_account},
+
+ { MAV_IDENTITY_PAGE, N_("Identity"), N_("Next - Receiving mail"), NULL, IDENTITY_DETAIL, NULL, NULL, save_identity, },
+ { MAV_RECV_PAGE, N_("Receiving mail"), N_("Next - Sending mail"), N_("Back - Identity"), RECEIVE_DETAIL, NULL, NULL, NULL },
+ { MAV_SEND_PAGE, N_("Sending mail"), N_("Next - Review account"), N_("Back - Receiving mail"), SEND_DETAIL, NULL, NULL, NULL},
+ { MAV_REVIEW_PAGE, N_("Review account"), N_("Finish"), N_("Back - Sending"), REVIEW_DETAIL, NULL, NULL, NULL},
};
static void
mav_next_pressed (GtkButton *button, MailAccountView *mav)
{
+
+ if (mail_account_pages[mav->current_page].save_page) {
+ (*mail_account_pages[mav->current_page].save_page) (mav);
+ }
if (mav->current_page == MAV_LAST - 1)
return;
@@ -522,9 +301,6 @@ mail_account_view_construct (MailAccountView *view)
gtk_scrolled_window_add_with_viewport (view->scroll, view->page_widget);
gtk_widget_show_all (view->scroll);
- view->source = g_new0 (MailAccountService, 1);
- view->transport = g_new0 (MailAccountService, 1);
-
if (view->original) {
char *xml;
@@ -543,16 +319,17 @@ mail_account_view_construct (MailAccountView *view)
e_account_set_string(view->account, E_ACCOUNT_SENT_FOLDER_URI,
mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT));
}
- view->providers = g_list_sort(camel_provider_list(TRUE), (GCompareFunc)provider_compare);
for (i=0; i<MAV_LAST; i++) {
view->pages[i] = mav_construct_page (view, i);
+ view->wpages[i] = view->pages[i]->box;
gtk_box_pack_start (view->page_widget, view->pages[i]->box, TRUE, TRUE, 0);
gtk_widget_hide (view->pages[i]->box);
}
gtk_widget_show (view->pages[0]->box);
view->current_page = 0;
gtk_box_pack_start (view, view->scroll, TRUE, TRUE, 0);
+ view->edit = em_account_editor_new_for_pages (view->original, EMAE_PAGES, "org.gnome.evolution.mail.config.accountWizard", view->wpages);
}
MailAccountView *
diff --git a/src/mail-account-view.h b/src/mail-account-view.h
index 97668ee..7531c8f 100644
--- a/src/mail-account-view.h
+++ b/src/mail-account-view.h
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <webkit/webkit.h>
+#include "mail/em-account-editor.h"
#include <libedataserver/e-account-list.h>
#include <camel/camel-provider.h>
@@ -66,18 +67,10 @@ typedef struct _MailAccountView {
EAccount *original;
EAccount *account;
- GList *providers;
-
MAVPage *pages[4];
+ GtkWidget *wpages[4];
int current_page;
-
- /* Identity */
- GtkWidget *full_name;
- GtkWidget *email;
- GtkWidget *password;
-
- MailAccountService *source;
- MailAccountService *transport;
+ struct _EMAccountEditor *edit;
MailAccountViewPrivate *priv;
} MailAccountView;
@@ -89,29 +82,6 @@ typedef struct _MailAccountViewClass {
} MailAccountViewClass;
-struct _MailAccountService {
- MailAccountView *mav;
-
- /* NOTE: keep all widgets together, first frame last check_dialog */
- struct _GtkComboBox *providers;
-
- struct _GtkEntry *email;
- struct _GtkEntry *hostname;
- struct _GtkEntry *username;
-
- struct _GtkComboBox *use_ssl;
- struct _GtkEntry *port;
-
- struct _GtkComboBox *authtype;
- struct _GtkEntry *password;
-
- struct _GtkButton *check_supported;
-
- GList *authtypes; /* if "Check supported" */
- CamelProvider *provider;
- CamelProviderType type;
-};
-
MailAccountView *mail_account_view_new (EAccount *account);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]