* add support for special port numbers; this fixes the
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 26 Oct 2007 15:12:09 +0000 (15:12 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 26 Oct 2007 15:12:09 +0000 (15:12 +0000)
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts* add support for special port numbers; this fixes the
  easysetup for ".mac"-accounts

pmo-trunk-r3593

src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/easysetup/modest-presets.c
src/maemo/easysetup/modest-presets.h

index f11e944..304c585 100644 (file)
@@ -1709,7 +1709,7 @@ static gboolean
 create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
 {
        ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
-       
+       guint special_port;
        gchar* display_name = get_entered_account_title (self);
 
        /* Some checks: */
@@ -1759,7 +1759,6 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                                                                                                   provider_id, 
                                                                                                   TRUE /* incoming */);
 
-               g_warning ("security incoming: %x", security_incoming);
                        
                /* We don't check for SMTP here as that is impossible for an incoming server. */
                if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP) {
@@ -1807,6 +1806,13 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
        gchar *store_name = modest_account_mgr_get_unused_account_name (self->account_manager, 
                                                                        store_name_start, TRUE /* server account */);
        g_free (store_name_start);
+
+       /* we check if there is a *special* port */
+       special_port = modest_presets_get_port (priv->presets, provider_id,
+                                               TRUE /* incoming */);
+       if (special_port != 0)
+               serverport_incoming = special_port;
+       
        gboolean created = modest_account_mgr_add_server_account (self->account_manager,
                                                                  store_name,
                                                                  servername_incoming,
@@ -1850,10 +1856,6 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                        modest_presets_get_info_server_security (priv->presets, provider_id, 
                                                                 FALSE /* incoming */);
 
-               /* TODO: The secure-smtp information in the presets data is currently wrong,
-                * so we choose a reasonable default. Remove this when the presets data is corrected: */
-               security_outgoing = security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP;
-
                protocol_security_outgoing = MODEST_PROTOCOL_CONNECTION_NORMAL;
                if (security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP) {
                        /* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
@@ -1864,8 +1866,7 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                        /* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
                        protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
                }
-       }
-       else {
+       } else {
                /* Use custom pages because no preset was specified: */
                servername_outgoing = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver) ));
                
@@ -1883,6 +1884,13 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
        gchar *transport_name = modest_account_mgr_get_unused_account_name (self->account_manager, 
                                                                            transport_name_start, TRUE /* server account */);
        g_free (transport_name_start);
+
+       /* we check if there is a *special* port */
+       special_port = modest_presets_get_port (priv->presets, provider_id,
+                                               FALSE /* incoming */);
+       if (special_port != 0)
+               serverport_outgoing = special_port;
+       
        created = modest_account_mgr_add_server_account (self->account_manager,
                                                         transport_name,
                                                         servername_outgoing,
index 3ac56dd..7dc7c64 100644 (file)
@@ -45,6 +45,7 @@
 #define MODEST_PRESETS_KEY_MAILBOX_TYPE        "MailboxType"
 #define MODEST_PRESETS_KEY_APOP                "APOPSecureLogin"
 #define MODEST_PRESETS_KEY_SECURE_SMTP         "SecureSmtp"
+#define MODEST_PRESETS_KEY_SMTP_PORT           "SmtpPort"
                                                    
 
 ModestPresets*
@@ -279,7 +280,29 @@ modest_presets_get_info_server_security (ModestPresets *self, const gchar *provi
        return info;
 }
 
-                                                       
+
+/*
+ * at the moment, this only for mac.com, which have a special SMTP port
+ */
+guint
+modest_presets_get_port (ModestPresets *self, const gchar* provider_id,
+                        gboolean incoming_server)
+{
+       guint port;
+       
+       g_return_val_if_fail (self && self->keyfile, 0);
+
+       if (incoming_server)
+               port = 0; /* not used yet */
+       else 
+               port = (guint)g_key_file_get_integer (self->keyfile, provider_id,
+                                                     MODEST_PRESETS_KEY_SMTP_PORT, NULL);
+
+       return port;
+}
+
+
+
 
        
 void
index a047f6e..998e9cf 100644 (file)
@@ -147,6 +147,22 @@ ModestPresetsSecurity          modest_presets_get_info_server_security (ModestPr
                                                    const gchar *provider_id,
                                                    gboolean incoming_server);
 
+
+/**
+ * modest_presets_get_port:
+ * @self: a valid ModestPresets instance
+ * @provider_id: ID of the provider 
+ * @incoming_server: get port# for the incoming mailserver if TRUE, for the outgoing server otherwise
+ *
+ * return the specific port number for some provider
+ * function return 0 if the normal port number is valid
+ *
+ * Returns: ModestPresetsSecurity ORable flags with the required information
+ */
+guint modest_presets_get_port (ModestPresets *self, const gchar* provider_id,
+                              gboolean incoming_server);
+
+
 /**
  * modest_presets_destroy:
  * @self: a valid ModestPresets instance (ie. must not be NULL)