From 7dd43ed0b3b827799299291a53300db93d9b2711 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 14 May 2007 15:03:42 +0000 Subject: [PATCH] 2007-05-14 Murray Cumming * src/modest-protocol-info.h: Split the ModestProtocol enum into ModestProtocol, ModestSecureConnection, and ModestSecureAuthentication. There was no need to have these unrelated values in one enum. * src/: many files: Adapted to changed enum. This makes the code a bit clearer, and the compiler could catch some errors. pmo-trunk-r1857 --- ChangeLog2 | 9 +++ src/gnome/modest-account-assistant.c | 4 +- src/gnome/modest-store-widget.c | 12 ++-- src/gnome/modest-store-widget.h | 4 +- src/maemo/easysetup/modest-easysetup-wizard.c | 14 ++--- src/maemo/modest-account-settings-dialog.c | 18 +++--- src/maemo/modest-store-widget.c | 4 +- src/maemo/modest-transport-widget.c | 4 +- src/modest-account-mgr-helpers.c | 20 +++---- src/modest-account-mgr-helpers.h | 12 ++-- src/modest-account-mgr.c | 4 +- src/modest-account-mgr.h | 4 +- src/modest-protocol-info.c | 61 +++++++++++++-------- src/modest-protocol-info.h | 73 ++++++++++++++++--------- src/widgets/modest-secureauth-combo-box.c | 10 ++-- src/widgets/modest-secureauth-combo-box.h | 4 +- src/widgets/modest-serversecurity-combo-box.c | 14 ++--- src/widgets/modest-serversecurity-combo-box.h | 4 +- 18 files changed, 161 insertions(+), 114 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index 0b619b8..034672e 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,14 @@ 2007-05-14 Murray Cumming + * src/modest-protocol-info.h: Split the ModestProtocol enum + into ModestProtocol, ModestSecureConnection, and ModestSecureAuthentication. + There was no need to have these unrelated values in one enum. + + * src/: many files: Adapted to changed enum. This makes the code a bit + clearer, and the compiler could catch some errors. + +2007-05-14 Murray Cumming + * src/modest-tny-account-store.c: (modest_tny_account_store_alert): Show the detailed internal camel error message when an error happens during the configuration, so that our testers can give us more clues. diff --git a/src/gnome/modest-account-assistant.c b/src/gnome/modest-account-assistant.c index 5fe842a..7283af5 100644 --- a/src/gnome/modest-account-assistant.c +++ b/src/gnome/modest-account-assistant.c @@ -605,7 +605,9 @@ static void on_apply (ModestAccountAssistant *self, gpointer user_data) { ModestAccountAssistantPrivate *priv; - ModestProtocol proto, security, auth; + ModestProtocol proto = MODEST_PROTOCOL_UNKNOWN; + ModestSecureConnection security = MODEST_PROTOCOL_SECURITY_NONE; + ModestSecureAuthentication auth = MODEST_PROCOTOL_AUTH_NONE; gchar *store_name, *transport_name; const gchar *account_name, *username, *servername, *path; ModestStoreWidget *store; diff --git a/src/gnome/modest-store-widget.c b/src/gnome/modest-store-widget.c index d536e4a..f41090b 100644 --- a/src/gnome/modest-store-widget.c +++ b/src/gnome/modest-store-widget.c @@ -353,8 +353,8 @@ modest_store_widget_get_path (ModestStoreWidget *self) return NULL; } -static ModestProtocol -get_protocol_from_combo (GtkWidget *combo) +static gint +get_value_from_combo (GtkWidget *combo) { gchar *chosen; @@ -367,7 +367,7 @@ get_protocol_from_combo (GtkWidget *combo) } -ModestProtocol +ModestSecureAuthentication modest_store_widget_get_auth (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; @@ -375,10 +375,10 @@ modest_store_widget_get_auth (ModestStoreWidget *self) g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); - return get_protocol_from_combo (priv->auth); + return get_value_from_combo (priv->auth); } -ModestProtocol +ModestSecureConnection modest_store_widget_get_security (ModestStoreWidget *self) { ModestStoreWidgetPrivate *priv; @@ -386,5 +386,5 @@ modest_store_widget_get_security (ModestStoreWidget *self) g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN); priv = MODEST_STORE_WIDGET_GET_PRIVATE(self); - return get_protocol_from_combo (priv->security); + return get_value_from_combo (priv->security); } diff --git a/src/gnome/modest-store-widget.h b/src/gnome/modest-store-widget.h index d986720..b4bc8a9 100644 --- a/src/gnome/modest-store-widget.h +++ b/src/gnome/modest-store-widget.h @@ -40,8 +40,8 @@ const gchar* modest_store_widget_get_username (ModestStoreWidget *se const gchar* modest_store_widget_get_servername (ModestStoreWidget *self); ModestProtocol modest_store_widget_get_proto (ModestStoreWidget *self); gchar * modest_store_widget_get_path (ModestStoreWidget *self); -ModestProtocol modest_store_widget_get_auth (ModestStoreWidget *self); -ModestProtocol modest_store_widget_get_security (ModestStoreWidget *self); +ModestSecureAuthentication modest_store_widget_get_auth (ModestStoreWidget *self); +ModestSecureConnection modest_store_widget_get_security (ModestStoreWidget *self); G_END_DECLS diff --git a/src/maemo/easysetup/modest-easysetup-wizard.c b/src/maemo/easysetup/modest-easysetup-wizard.c index dd44d95..4c13b62 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard.c +++ b/src/maemo/easysetup/modest-easysetup-wizard.c @@ -486,7 +486,7 @@ static GtkWidget* create_page_complete_easysetup (ModestEasysetupWizardDialog *s */ static void update_incoming_server_title (ModestEasysetupWizardDialog *self) { - ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype ( + const ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype ( EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype)); const gchar* type = (protocol == MODEST_PROTOCOL_STORE_POP ? @@ -507,7 +507,7 @@ static void update_incoming_server_title (ModestEasysetupWizardDialog *self) */ static void update_incoming_server_security_choices (ModestEasysetupWizardDialog *self) { - ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype ( + const ModestProtocol protocol = easysetup_servertype_combo_box_get_active_servertype ( EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype)); /* Fill the combo with appropriately titled choices for POP or IMAP. */ @@ -1285,12 +1285,12 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled) const gchar* password = gtk_entry_get_text (GTK_ENTRY (self->entry_user_password)); /* Incoming server: */ - /* Note: We need something as default for the ModestProtocol values, + /* Note: We need something as default for the ModestProtocol* values, * or modest_account_mgr_add_server_account will fail. */ gchar* servername_incoming = NULL; ModestProtocol protocol_incoming = MODEST_PROTOCOL_STORE_POP; - ModestProtocol protocol_security_incoming = MODEST_PROTOCOL_SECURITY_NONE; - ModestProtocol protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_NONE; + ModestSecureConnection protocol_security_incoming = MODEST_PROTOCOL_SECURITY_NONE; + ModestSecureAuthentication protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_NONE; /* Get details from the specified presets: */ gchar* provider_id = easysetup_provider_combo_box_get_active_provider_id ( @@ -1381,8 +1381,8 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled) /* Outgoing server: */ gchar* servername_outgoing = NULL; ModestProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP; - ModestProtocol protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE; - ModestProtocol protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE; + ModestSecureConnection protocol_security_outgoing = MODEST_PROTOCOL_SECURITY_NONE; + ModestSecureAuthentication protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE; if(provider_id) { /* Use presets: */ diff --git a/src/maemo/modest-account-settings-dialog.c b/src/maemo/modest-account-settings-dialog.c index 9d6b01a..f2925c4 100644 --- a/src/maemo/modest-account-settings-dialog.c +++ b/src/maemo/modest-account-settings-dialog.c @@ -594,7 +594,7 @@ on_combo_outgoing_auth_changed (GtkComboBox *widget, gpointer user_data) { ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); - ModestProtocol protocol_security = + ModestSecureAuthentication protocol_security = modest_secureauth_combo_box_get_active_secureauth ( MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth)); const gboolean secureauth_used = protocol_security != MODEST_PROTOCOL_AUTH_NONE; @@ -1020,7 +1020,7 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc. * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported? */ - const ModestProtocol secure_auth = modest_server_account_get_secure_auth( + const ModestSecureAuthentication secure_auth = modest_server_account_get_secure_auth( dialog->account_manager, incoming_account->account_name); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth), secure_auth != MODEST_PROTOCOL_AUTH_PASSWORD); @@ -1029,7 +1029,7 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo update_incoming_server_title (dialog, incoming_account->proto); update_incoming_server_security_choices (dialog, incoming_account->proto); - const ModestProtocol security = modest_server_account_get_security ( + const ModestSecureConnection security = modest_server_account_get_security ( dialog->account_manager, incoming_account->account_name); modest_serversecurity_combo_box_set_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security), security); @@ -1052,7 +1052,7 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo outgoing_account->password ? outgoing_account->password : ""); /* Get the secure-auth setting: */ - const ModestProtocol secure_auth = modest_server_account_get_secure_auth( + const ModestSecureAuthentication secure_auth = modest_server_account_get_secure_auth( dialog->account_manager, outgoing_account->account_name); modest_secureauth_combo_box_set_active_secureauth ( MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth); @@ -1062,7 +1062,7 @@ void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialo MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto); /* Get the security setting: */ - const ModestProtocol security = modest_server_account_get_security ( + const ModestSecureConnection security = modest_server_account_get_security ( dialog->account_manager, outgoing_account->account_name); modest_serversecurity_combo_box_set_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security); @@ -1155,13 +1155,13 @@ save_configuration (ModestAccountSettingsDialog *dialog) * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc. * TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported? */ - const ModestProtocol protocol_authentication_incoming = gtk_toggle_button_get_active + const ModestSecureAuthentication protocol_authentication_incoming = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth)) ? MODEST_PROTOCOL_AUTH_CRAMMD5 : MODEST_PROTOCOL_AUTH_PASSWORD; modest_server_account_set_secure_auth (dialog->account_manager, incoming_account_name, protocol_authentication_incoming); - const ModestProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( + const ModestSecureConnection protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security)); modest_server_account_set_security (dialog->account_manager, incoming_account_name, protocol_security_incoming); @@ -1192,11 +1192,11 @@ save_configuration (ModestAccountSettingsDialog *dialog) modest_server_account_set_password (dialog->account_manager, outgoing_account_name, password); - const ModestProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity ( + const ModestSecureConnection protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security)); modest_server_account_set_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing); - const ModestProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth ( + const ModestSecureAuthentication protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth ( MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth)); modest_server_account_set_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing); diff --git a/src/maemo/modest-store-widget.c b/src/maemo/modest-store-widget.c index e6d38a8..95f575a 100644 --- a/src/maemo/modest-store-widget.c +++ b/src/maemo/modest-store-widget.c @@ -228,7 +228,7 @@ imap_pop_configuration (ModestStoreWidget *self) gtk_label_set_markup (GTK_LABEL(label),_("Security")); gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_SECURITY); + protos = modest_protocol_info_get_protocol_security_pair_list (); priv->security = modest_combo_box_new (protos, g_str_equal); modest_pair_list_free (protos); @@ -245,7 +245,7 @@ imap_pop_configuration (ModestStoreWidget *self) gtk_label_set_text (GTK_LABEL(label),_("Authentication:")); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH); + protos = modest_protocol_info_get_protocol_auth_pair_list (); combo = modest_combo_box_new (protos, g_str_equal); modest_pair_list_free (protos); diff --git a/src/maemo/modest-transport-widget.c b/src/maemo/modest-transport-widget.c index aed6f45..f909a2c 100644 --- a/src/maemo/modest-transport-widget.c +++ b/src/maemo/modest-transport-widget.c @@ -185,7 +185,7 @@ smtp_configuration (ModestTransportWidget *self) gtk_label_set_text (GTK_LABEL(label),_("Connection type:")); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH); + protos = modest_protocol_info_get_protocol_security_pair_list (); combo = modest_combo_box_new (protos, g_str_equal); modest_pair_list_free (protos); @@ -198,7 +198,7 @@ smtp_configuration (ModestTransportWidget *self) gtk_label_set_text (GTK_LABEL(label),_("Authentication:")); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6); - protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH); + protos = modest_protocol_info_get_protocol_auth_pair_list (); combo = modest_combo_box_new (protos, g_str_equal); modest_pair_list_free (protos); diff --git a/src/modest-account-mgr-helpers.c b/src/modest-account-mgr-helpers.c index 7451b31..dae640f 100644 --- a/src/modest-account-mgr-helpers.c +++ b/src/modest-account-mgr-helpers.c @@ -233,10 +233,10 @@ modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account } -static ModestProtocol +static ModestSecureAuthentication get_secure_auth_for_conf_string(const gchar* value) { - ModestProtocol result = MODEST_PROTOCOL_AUTH_NONE; + ModestSecureAuthentication result = MODEST_PROTOCOL_AUTH_NONE; if (value) { if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE) == 0) result = MODEST_PROTOCOL_AUTH_NONE; @@ -249,11 +249,11 @@ get_secure_auth_for_conf_string(const gchar* value) return result; } -ModestProtocol +ModestSecureAuthentication modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name) { - ModestProtocol result = MODEST_PROTOCOL_AUTH_NONE; + ModestSecureAuthentication result = MODEST_PROTOCOL_AUTH_NONE; gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, TRUE /* server account */); if (value) { @@ -268,7 +268,7 @@ modest_server_account_get_secure_auth (ModestAccountMgr *self, void modest_server_account_set_secure_auth (ModestAccountMgr *self, - const gchar* account_name, ModestProtocol secure_auth) + const gchar* account_name, ModestSecureAuthentication secure_auth) { /* Get the conf string for the enum value: */ const gchar* str_value = NULL; @@ -283,10 +283,10 @@ modest_server_account_set_secure_auth (ModestAccountMgr *self, modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE); } -static ModestProtocol +static ModestSecureConnection get_security_for_conf_string(const gchar* value) { - ModestProtocol result = MODEST_PROTOCOL_SECURITY_NONE; + ModestSecureConnection result = MODEST_PROTOCOL_SECURITY_NONE; if (value) { if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0) result = MODEST_PROTOCOL_SECURITY_NONE; @@ -299,11 +299,11 @@ get_security_for_conf_string(const gchar* value) return result; } -ModestProtocol +ModestSecureConnection modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name) { - ModestProtocol result = MODEST_PROTOCOL_SECURITY_NONE; + ModestSecureConnection result = MODEST_PROTOCOL_SECURITY_NONE; gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY, TRUE /* server account */); if (value) { @@ -317,7 +317,7 @@ modest_server_account_get_security (ModestAccountMgr *self, void modest_server_account_set_security (ModestAccountMgr *self, - const gchar* account_name, ModestProtocol security) + const gchar* account_name, ModestSecureConnection security) { /* Get the conf string for the enum value: */ const gchar* str_value = NULL; diff --git a/src/modest-account-mgr-helpers.h b/src/modest-account-mgr-helpers.h index 67b6959..b06b9e1 100644 --- a/src/modest-account-mgr-helpers.h +++ b/src/modest-account-mgr-helpers.h @@ -49,8 +49,8 @@ typedef struct { gchar *password; time_t last_updated; gint port; /* Or 0, if the default should be used. */ - ModestProtocol secure_auth; - ModestProtocol security; + ModestSecureAuthentication secure_auth; + ModestSecureConnection security; } ModestServerAccountData; typedef struct { @@ -326,7 +326,7 @@ modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account * * Returns: The secure authentication enum value. */ -ModestProtocol +ModestSecureAuthentication modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name); /** @@ -339,7 +339,7 @@ modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* acco */ void modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name, - ModestProtocol secure_auth); + ModestSecureAuthentication secure_auth); /** * modest_server_account_data_get_security: @@ -350,7 +350,7 @@ modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* acco * * Returns: The security enum value. */ -ModestProtocol +ModestSecureConnection modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name); /** @@ -362,7 +362,7 @@ modest_server_account_get_security (ModestAccountMgr *self, const gchar* account */ void modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name, - ModestProtocol security); + ModestSecureConnection security); ModestServerAccountData* modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name); diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index 432fc80..2d6169c 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -307,8 +307,8 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, const gchar * name, const gchar *hostname, const gchar * username, const gchar * password, ModestProtocol proto, - ModestProtocol security, - ModestProtocol auth) + ModestSecureConnection security, + ModestSecureAuthentication auth) { ModestAccountMgrPrivate *priv; gchar *key; diff --git a/src/modest-account-mgr.h b/src/modest-account-mgr.h index 85ddd38..65a8322 100644 --- a/src/modest-account-mgr.h +++ b/src/modest-account-mgr.h @@ -125,8 +125,8 @@ gboolean modest_account_mgr_add_server_account (ModestAccountMgr *self, const gchar *username, const gchar *password, ModestProtocol proto, - ModestProtocol security, - ModestProtocol auth); + ModestSecureConnection security, + ModestSecureAuthentication auth); /** diff --git a/src/modest-protocol-info.c b/src/modest-protocol-info.c index 42584d0..7a69136 100644 --- a/src/modest-protocol-info.c +++ b/src/modest-protocol-info.c @@ -46,20 +46,28 @@ static const ProtocolInfo ProtocolMap[] = { { MODEST_PROTOCOL_STORE_POP, "pop", N_("POP3") }, { MODEST_PROTOCOL_STORE_IMAP, "imap", N_("IMAPv4") }, { MODEST_PROTOCOL_STORE_MAILDIR, "maildir", N_("Maildir") }, - { MODEST_PROTOCOL_STORE_MBOX, "mbox", N_("MBox") }, + { MODEST_PROTOCOL_STORE_MBOX, "mbox", N_("MBox") } +}; +const guint PROTOCOL_SECURITY_MAP_SIZE = sizeof(ProtocolMap)/sizeof(ProtocolInfo); +static const ProtocolInfo ProtocolSecurityMap[] = { { MODEST_PROTOCOL_SECURITY_NONE, "none", N_("None") }, { MODEST_PROTOCOL_SECURITY_SSL, "ssl", N_("SSL") }, { MODEST_PROTOCOL_SECURITY_TLS, "tls", N_("TLS") }, - { MODEST_PROTOCOL_SECURITY_TLS_OP, "tls-op", N_("TLS when possible") }, /* op stands for optional */ + { MODEST_PROTOCOL_SECURITY_TLS_OP, "tls-op", N_("TLS when possible") } /* op stands for optional */ +}; +const guint PROTOCOL_MAP_SIZE = sizeof(ProtocolSecurityMap)/sizeof(ProtocolInfo); +static const ProtocolInfo ProtocolAuthMap[] = { { MODEST_PROTOCOL_AUTH_NONE, "none", N_("None") }, { MODEST_PROTOCOL_AUTH_PASSWORD, "password", N_("Password") }, { MODEST_PROTOCOL_AUTH_CRAMMD5, "cram-md5", N_("Cram MD5") } }; -const guint PROTOCOL_MAP_SIZE = sizeof(ProtocolMap)/sizeof(ProtocolInfo); +const guint PROTOCOL_AUTH_MAP_SIZE = sizeof(ProtocolAuthMap)/sizeof(ProtocolInfo); + +#if 0 GSList* modest_protocol_info_get_protocol_list (ModestProtocolType type) { @@ -77,22 +85,17 @@ modest_protocol_info_get_protocol_list (ModestProtocolType type) } return proto_list; } +#endif - - -ModestPairList* -modest_protocol_info_get_protocol_pair_list (ModestProtocolType type) +static ModestPairList* +modest_protocol_info_get_pair_list (const ProtocolInfo* map, guint size) { ModestPairList *proto_list = NULL; int i; - - g_return_val_if_fail (type > MODEST_PROTOCOL_TYPE_UNKNOWN && type < MODEST_PROTOCOL_TYPE_NUM, - NULL); - for (i = 0; i != PROTOCOL_MAP_SIZE; ++i) { - ProtocolInfo info = (ProtocolInfo)ProtocolMap[i]; - if (modest_protocol_info_get_protocol_type(info.proto) == type) - proto_list = g_slist_append (proto_list, + for (i = 0; i != size; ++i) { + const ProtocolInfo info = map[i]; + proto_list = g_slist_append (proto_list, (gpointer)modest_pair_new( (gpointer)info.name, (gpointer)info.display_name, @@ -101,6 +104,26 @@ modest_protocol_info_get_protocol_pair_list (ModestProtocolType type) return proto_list; } +ModestPairList* +modest_protocol_info_get_protocol_pair_list () +{ + return modest_protocol_info_get_pair_list (ProtocolMap, PROTOCOL_MAP_SIZE); +} + +ModestPairList* +modest_protocol_info_get_protocol_security_pair_list () +{ + return modest_protocol_info_get_pair_list (ProtocolSecurityMap, PROTOCOL_SECURITY_MAP_SIZE); +} + + +ModestPairList* +modest_protocol_info_get_protocol_auth_pair_list () +{ + return modest_protocol_info_get_pair_list (ProtocolAuthMap, PROTOCOL_AUTH_MAP_SIZE); +} + + ModestProtocolType modest_protocol_info_get_protocol_type (ModestProtocol proto) @@ -116,16 +139,6 @@ modest_protocol_info_get_protocol_type (ModestProtocol proto) case MODEST_PROTOCOL_STORE_MBOX: return MODEST_PROTOCOL_TYPE_STORE; - case MODEST_PROTOCOL_SECURITY_NONE: - case MODEST_PROTOCOL_SECURITY_SSL: - case MODEST_PROTOCOL_SECURITY_TLS: - case MODEST_PROTOCOL_SECURITY_TLS_OP: - return MODEST_PROTOCOL_TYPE_SECURITY; - - case MODEST_PROTOCOL_AUTH_NONE: - case MODEST_PROTOCOL_AUTH_PASSWORD: - return MODEST_PROTOCOL_TYPE_AUTH; - default: return MODEST_PROTOCOL_TYPE_UNKNOWN; } diff --git a/src/modest-protocol-info.h b/src/modest-protocol-info.h index 51e5791..523eef3 100644 --- a/src/modest-protocol-info.h +++ b/src/modest-protocol-info.h @@ -39,38 +39,37 @@ G_BEGIN_DECLS typedef enum { MODEST_PROTOCOL_UNKNOWN, - MODEST_PROTOCOL_TRANSPORT_SENDMAIL, + MODEST_PROTOCOL_TRANSPORT_SENDMAIL, MODEST_PROTOCOL_TRANSPORT_SMTP, MODEST_PROTOCOL_STORE_POP, MODEST_PROTOCOL_STORE_IMAP, MODEST_PROTOCOL_STORE_MAILDIR, - MODEST_PROTOCOL_STORE_MBOX, + MODEST_PROTOCOL_STORE_MBOX +} ModestProtocol; + + +typedef enum { + MODEST_PROTOCOL_TYPE_UNKNOWN, + MODEST_PROTOCOL_TYPE_TRANSPORT, + MODEST_PROTOCOL_TYPE_STORE +} ModestProtocolType; +typedef enum { MODEST_PROTOCOL_SECURITY_NONE, MODEST_PROTOCOL_SECURITY_SSL, MODEST_PROTOCOL_SECURITY_TLS, - MODEST_PROTOCOL_SECURITY_TLS_OP, + MODEST_PROTOCOL_SECURITY_TLS_OP +} ModestSecureConnection; +typedef enum { MODEST_PROTOCOL_AUTH_NONE, MODEST_PROTOCOL_AUTH_PASSWORD, - MODEST_PROTOCOL_AUTH_CRAMMD5, + MODEST_PROTOCOL_AUTH_CRAMMD5 +} ModestSecureAuthentication; - MODEST_PROTOCOL_NUM -} ModestProtocol; - - -typedef enum { - MODEST_PROTOCOL_TYPE_UNKNOWN, - MODEST_PROTOCOL_TYPE_TRANSPORT, - MODEST_PROTOCOL_TYPE_STORE, - MODEST_PROTOCOL_TYPE_SECURITY, - MODEST_PROTOCOL_TYPE_AUTH, - - MODEST_PROTOCOL_TYPE_NUM -} ModestProtocolType; - +#if 0 /** * modest_protocol_info_get_list: * @type: the type of list you want, it should NOT be MODEST_PROTOCOL_TYPE_UNKNOWN @@ -83,20 +82,44 @@ typedef enum { * for them. */ GSList* modest_protocol_info_get_protocol_list (ModestProtocolType type); +#endif /** - * modest_protocol_info_get_list: - * @type: the type of list you want, it should NOT be MODEST_PROTOCOL_TYPE_UNKNOWN + * modest_protocol_info_get_protocol_pair_list: * - * return the list of -tupels of the given @type. - * the elements of the returned list are ModestPairs - * this is a convenience function for use with ModestComboBox + * return the list of -tupels of protocols. + * The elements of the returned list are ModestPairs + * This is a convenience function for use with ModestComboBox * - * Returns: a list of protocols of the given @type; after use, it should be freed + * Returns: a list of protocols. After use, it should be freed + * with modest_pair_list_free + */ +ModestPairList* modest_protocol_info_get_protocol_pair_list (); + +/** + * modest_protocol_info_get_protocol_security_pair_list: + * + * return the list of -tupels of protocol secure connection methods. + * The elements of the returned list are ModestPairs + * This is a convenience function for use with ModestComboBox + * + * Returns: a list of secure connection methods. After use, it should be freed + * with modest_pair_list_free + */ +ModestPairList* modest_protocol_info_get_protocol_security_pair_list (); + +/** + * modest_protocol_info_get_protocol_auth_pair_list: + * + * return the list of -tupels of protocol secure authentication methods. + * The elements of the returned list are ModestPairs + * This is a convenience function for use with ModestComboBox + * + * Returns: a list of secure authentication methods. After use, it should be freed * with modest_pair_list_free */ -ModestPairList* modest_protocol_info_get_protocol_pair_list (ModestProtocolType type); +ModestPairList* modest_protocol_info_get_protocol_auth_pair_list (); /** diff --git a/src/widgets/modest-secureauth-combo-box.c b/src/widgets/modest-secureauth-combo-box.c index c8cf960..ddb9359 100644 --- a/src/widgets/modest-secureauth-combo-box.c +++ b/src/widgets/modest-secureauth-combo-box.c @@ -145,9 +145,9 @@ void modest_secureauth_combo_box_fill (ModestSecureauthComboBox *combobox) /** * Returns the selected secureauth, - * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected. + * or MODEST_PROTOCOL_AUTH_NONE if no secureauth was selected. */ -ModestProtocol +ModestSecureAuthentication modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox) { GtkTreeIter active; @@ -155,12 +155,12 @@ modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *com if (found) { ModestSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox); - ModestProtocol secureauth = MODEST_PROTOCOL_UNKNOWN; + ModestProtocol secureauth = MODEST_PROTOCOL_AUTH_NONE; gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &secureauth, -1); return secureauth; } - return MODEST_PROTOCOL_UNKNOWN; /* Failed. */ + return MODEST_PROTOCOL_AUTH_NONE; /* Failed. */ } /* This allows us to pass more than one piece of data to the signal handler, @@ -196,7 +196,7 @@ on_model_foreach_select_id(GtkTreeModel *model, * or MODEST_PROTOCOL_UNKNOWN if no secureauth was selected. */ gboolean -modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestProtocol secureauth) +modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestSecureAuthentication secureauth) { ModestSecureauthComboBoxPrivate *priv = SECUREAUTH_COMBO_BOX_GET_PRIVATE (combobox); diff --git a/src/widgets/modest-secureauth-combo-box.h b/src/widgets/modest-secureauth-combo-box.h index e86bc3e..8f9d046 100644 --- a/src/widgets/modest-secureauth-combo-box.h +++ b/src/widgets/modest-secureauth-combo-box.h @@ -45,9 +45,9 @@ GType modest_secureauth_combo_box_get_type (void); ModestSecureauthComboBox* modest_secureauth_combo_box_new (void); -ModestProtocol modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox); +ModestSecureAuthentication modest_secureauth_combo_box_get_active_secureauth (ModestSecureauthComboBox *combobox); -gboolean modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestProtocol secureauth); +gboolean modest_secureauth_combo_box_set_active_secureauth (ModestSecureauthComboBox *combobox, ModestSecureAuthentication secureauth); G_END_DECLS diff --git a/src/widgets/modest-serversecurity-combo-box.c b/src/widgets/modest-serversecurity-combo-box.c index 62baf79..58d784e 100644 --- a/src/widgets/modest-serversecurity-combo-box.c +++ b/src/widgets/modest-serversecurity-combo-box.c @@ -154,7 +154,7 @@ void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobo } } -static gint get_port_for_security (ModestProtocol protocol, ModestProtocol security) +static gint get_port_for_security (ModestProtocol protocol, ModestSecureConnection security) { /* See the UI spec, section Email Wizards, Incoming Details [MSG-WIZ001]: */ gint result = 0; @@ -182,9 +182,9 @@ static gint get_port_for_security (ModestProtocol protocol, ModestProtocol secur /** * Returns the selected serversecurity, - * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected. + * or MODEST_PROTOCOL_SECURITY_NONE if no serversecurity was selected. */ -ModestProtocol +ModestSecureConnection modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *combobox) { GtkTreeIter active; @@ -192,12 +192,12 @@ modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityC if (found) { ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox); - ModestProtocol serversecurity = MODEST_PROTOCOL_UNKNOWN; + ModestSecureConnection serversecurity = MODEST_PROTOCOL_SECURITY_NONE; gtk_tree_model_get (priv->model, &active, MODEL_COL_ID, &serversecurity, -1); return serversecurity; } - return MODEST_PROTOCOL_UNKNOWN; /* Failed. */ + return MODEST_PROTOCOL_SECURITY_NONE; /* Failed. */ } /** @@ -209,7 +209,7 @@ modest_serversecurity_combo_box_get_active_serversecurity_port (ModestServersecu { ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox); - const ModestProtocol security = modest_serversecurity_combo_box_get_active_serversecurity + const ModestSecureConnection security = modest_serversecurity_combo_box_get_active_serversecurity (combobox); return get_port_for_security (priv->protocol, security); } @@ -247,7 +247,7 @@ on_model_foreach_select_id(GtkTreeModel *model, * or MODEST_PROTOCOL_UNKNOWN if no serversecurity was selected. */ gboolean -modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox, ModestProtocol serversecurity) +modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox, ModestSecureConnection serversecurity) { ModestServersecurityComboBoxPrivate *priv = SERVERSECURITY_COMBO_BOX_GET_PRIVATE (combobox); diff --git a/src/widgets/modest-serversecurity-combo-box.h b/src/widgets/modest-serversecurity-combo-box.h index c30d5a0..606b8d3 100644 --- a/src/widgets/modest-serversecurity-combo-box.h +++ b/src/widgets/modest-serversecurity-combo-box.h @@ -47,9 +47,9 @@ ModestServersecurityComboBox* modest_serversecurity_combo_box_new (void); void modest_serversecurity_combo_box_fill (ModestServersecurityComboBox *combobox, ModestProtocol protocol); -ModestProtocol modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *combobox); +ModestSecureConnection modest_serversecurity_combo_box_get_active_serversecurity (ModestServersecurityComboBox *combobox); -gboolean modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox, ModestProtocol serversecurity); +gboolean modest_serversecurity_combo_box_set_active_serversecurity (ModestServersecurityComboBox *combobox, ModestSecureConnection serversecurity); gint modest_serversecurity_combo_box_get_active_serversecurity_port (ModestServersecurityComboBox *combobox); -- 1.7.9.5