[anjal] Commit most of Account Setup. It now has basic frame work and read from
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Commit most of Account Setup. It now has basic frame work and read from
- Date: Wed, 29 Apr 2009 16:43:52 -0400 (EDT)
commit 8b951b3b34031ee0ec3e5909afb19a47774ef62c
Author: Srinivasa Ragavan <sragavan novell com>
Date: Thu Apr 30 02:12:27 2009 +0530
Commit most of Account Setup. It now has basic frame work and read from
Account url
---
src/mail-account-view.c | 173 +++++++++++++++++++++++++++++++++++++++++-----
src/mail-account-view.h | 31 +++------
src/mail-view.c | 2 +-
3 files changed, 164 insertions(+), 42 deletions(-)
diff --git a/src/mail-account-view.c b/src/mail-account-view.c
index 60747d2..7706441 100644
--- a/src/mail-account-view.c
+++ b/src/mail-account-view.c
@@ -104,6 +104,7 @@ create_identity_page (MailAccountView *view)
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);
@@ -112,9 +113,11 @@ create_identity_page (MailAccountView *view)
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);
+/*
label = gtk_label_new (_("Reply-to:"));
gtk_widget_show (label);
entry = gtk_entry_new ();
@@ -128,11 +131,32 @@ create_identity_page (MailAccountView *view)
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;
}
+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());
+ }
+}
+
static GtkWidget *
create_receive_page (MailAccountView *view)
{
@@ -144,9 +168,8 @@ create_receive_page (MailAccountView *view)
label = gtk_label_new (_("Email:"));
entry = gtk_entry_new ();
gtk_widget_show(entry);
+ view->source->email = 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 (_("Server type:"));
gtk_widget_show (label);
@@ -154,30 +177,34 @@ create_receive_page (MailAccountView *view)
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);
- 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);
+ 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);
- 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);
+ 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);
- 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);
+ 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"));
@@ -189,25 +216,77 @@ create_receive_page (MailAccountView *view)
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, 4, 5, GTK_SHRINK, GTK_SHRINK, 10, 3);
- gtk_table_attach (table, box, 1, 2, 4, 5, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 10, 3);
+ 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);
-
gtk_widget_show(table);
return table;
}
+static void
+fill_receive (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);
+ }
+ 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);
+ }
+
+}
+
static GtkWidget *
create_send_page (MailAccountView *view)
{
@@ -219,6 +298,7 @@ create_send_page (MailAccountView *view)
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);
@@ -227,6 +307,7 @@ create_send_page (MailAccountView *view)
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);
@@ -235,6 +316,7 @@ create_send_page (MailAccountView *view)
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"));
@@ -246,24 +328,68 @@ create_send_page (MailAccountView *view)
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, 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);
+ 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)
+{
+ 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.")
#define RECEIVE_DETAIL N_("Sorry, we can't work out the settings to get your mail automatically. Please enter them below. We've tried \n to make a start with the details you just entered but you may need to change them.")
@@ -278,11 +404,12 @@ struct _page_text {
char *prev;
char *detail;
GtkWidget * (*create_page) (MailAccountView *view);
+ void (*fill_page) (MailAccountView *view);
} mail_account_pages[] = {
- { MAV_IDENTITY_PAGE, N_("Identity"), N_("Next - Receiving mail"), NULL, IDENTITY_DETAIL, create_identity_page },
- { MAV_RECV_PAGE, N_("Receiving mail"), N_("Next - Sending mail"), N_("Back - Identity"), RECEIVE_DETAIL, create_receive_page},
- { MAV_SEND_PAGE, N_("Sending mail"), N_("Next - Review account"), N_("Back - Receiving mail"), SEND_DETAIL, create_send_page},
- { MAV_REVIEW_PAGE, N_("Review account"), N_("Finish"), N_("Back - Sending"), REVIEW_DETAIL, NULL},
+ { 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},
};
static void
@@ -343,6 +470,10 @@ mav_construct_page(MailAccountView *view, MAVPageType type)
gtk_box_pack_start (page->box, tmp, FALSE, FALSE, 3);
}
+ if (mail_account_pages[type].fill_page) {
+ (*mail_account_pages[type].fill_page) (view);
+ }
+
if (mail_account_pages[type].prev) {
box = gtk_hbox_new(FALSE, 0);
tmp = gtk_image_new_from_pixbuf (e_icon_factory_get_icon("go-previous", E_ICON_SIZE_BUTTON));
@@ -391,6 +522,9 @@ 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;
@@ -422,11 +556,12 @@ mail_account_view_construct (MailAccountView *view)
}
MailAccountView *
-mail_account_view_new ()
+mail_account_view_new (EAccount *account)
{
MailAccountView *view = g_object_new (MAIL_ACCOUNT_VIEW_TYPE, NULL);
view->type = MAIL_VIEW_ACCOUNT;
view->uri = "account://";
+ view->original = mail_config_get_default_account();
mail_account_view_construct (view);
return view;
diff --git a/src/mail-account-view.h b/src/mail-account-view.h
index 6dad80a..97668ee 100644
--- a/src/mail-account-view.h
+++ b/src/mail-account-view.h
@@ -70,6 +70,11 @@ typedef struct _MailAccountView {
MAVPage *pages[4];
int current_page;
+
+ /* Identity */
+ GtkWidget *full_name;
+ GtkWidget *email;
+ GtkWidget *password;
MailAccountService *source;
MailAccountService *transport;
@@ -88,43 +93,25 @@ struct _MailAccountService {
MailAccountView *mav;
/* NOTE: keep all widgets together, first frame last check_dialog */
- struct _GtkWidget *frame;
- struct _GtkWidget *container;
-
struct _GtkComboBox *providers;
- struct _GtkLabel *description;
- struct _GtkLabel *hostlabel;
+ struct _GtkEntry *email;
struct _GtkEntry *hostname;
- struct _GtkLabel *userlabel;
struct _GtkEntry *username;
- struct _GtkEntry *path;
- struct _GtkLabel *pathlabel;
- struct _GtkWidget *pathentry;
- struct _GtkWidget *ssl_frame;
struct _GtkComboBox *use_ssl;
- struct _GtkWidget *ssl_hbox;
- struct _GtkWidget *no_ssl;
+ struct _GtkEntry *port;
- struct _GtkWidget *auth_frame;
struct _GtkComboBox *authtype;
+ struct _GtkEntry *password;
- struct _GtkWidget *authitem;
- struct _GtkToggleButton *remember;
struct _GtkButton *check_supported;
- struct _GtkToggleButton *needs_auth;
-
- struct _GtkWidget *check_dialog;
- int check_id;
GList *authtypes; /* if "Check supported" */
CamelProvider *provider;
CamelProviderType type;
-
- int auth_changed_id;
};
-MailAccountView *mail_account_view_new (void);
+MailAccountView *mail_account_view_new (EAccount *account);
#endif
diff --git a/src/mail-view.c b/src/mail-view.c
index c635e62..6b589c5 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -332,7 +332,7 @@ mail_view_add_settings (MailView *mv)
static MailViewChild *
mail_view_add_account (MailView *mv)
{
- MailAccountView *msv = mail_account_view_new ();
+ MailAccountView *msv = mail_account_view_new (NULL);
gint position = 0;
gtk_widget_show (msv);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]