* update for the modest-protocol-info changes
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 15 May 2007 11:22:08 +0000 (11:22 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 15 May 2007 11:22:08 +0000 (11:22 +0000)
pmo-trunk-r1870

src/modest-account-mgr-helpers.c
src/modest-account-mgr-helpers.h
src/modest-account-mgr.c
src/modest-account-mgr.h
src/modest-tny-account.c
src/modest-tny-folder.c

index dae640f..d2859c2 100644 (file)
@@ -233,10 +233,10 @@ modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account
 }
  
 
 }
  
 
-static ModestSecureAuthentication
+static ModestAuthProtocol
 get_secure_auth_for_conf_string(const gchar* value)
 {
 get_secure_auth_for_conf_string(const gchar* value)
 {
-       ModestSecureAuthentication result = MODEST_PROTOCOL_AUTH_NONE;
+       ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
        if (value) {
                if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE) == 0)
                        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;
 }
 
        return result;
 }
 
-ModestSecureAuthentication
+ModestAuthProtocol
 modest_server_account_get_secure_auth (ModestAccountMgr *self, 
        const gchar* account_name)
 {
 modest_server_account_get_secure_auth (ModestAccountMgr *self, 
        const gchar* account_name)
 {
-       ModestSecureAuthentication result = MODEST_PROTOCOL_AUTH_NONE;
+       ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
        gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, 
                TRUE /* server account */);
        if (value) {
        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, 
 
 void
 modest_server_account_set_secure_auth (ModestAccountMgr *self, 
-       const gchar* account_name, ModestSecureAuthentication secure_auth)
+       const gchar* account_name, ModestAuthProtocol secure_auth)
 {
        /* Get the conf string for the enum value: */
        const gchar* str_value = NULL;
 {
        /* Get the conf string for the enum value: */
        const gchar* str_value = NULL;
@@ -283,27 +283,27 @@ modest_server_account_set_secure_auth (ModestAccountMgr *self,
        modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
 }
 
        modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
 }
 
-static ModestSecureConnection
+static ModestConnectionProtocol
 get_security_for_conf_string(const gchar* value)
 {
 get_security_for_conf_string(const gchar* value)
 {
-       ModestSecureConnection result = MODEST_PROTOCOL_SECURITY_NONE;
+       ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
        if (value) {
                if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
        if (value) {
                if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
-                       result = MODEST_PROTOCOL_SECURITY_NONE;
+                       result = MODEST_PROTOCOL_CONNECTION_NORMAL;
                else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0)
                else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0)
-                       result = MODEST_PROTOCOL_SECURITY_TLS;
+                       result = MODEST_PROTOCOL_CONNECTION_TLS;
                else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
                else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
-                       result = MODEST_PROTOCOL_SECURITY_SSL;
+                       result = MODEST_PROTOCOL_CONNECTION_SSL;
        }
        
        return result;
 }
 
        }
        
        return result;
 }
 
-ModestSecureConnection
+ModestConnectionProtocol
 modest_server_account_get_security (ModestAccountMgr *self, 
        const gchar* account_name)
 {
 modest_server_account_get_security (ModestAccountMgr *self, 
        const gchar* account_name)
 {
-       ModestSecureConnection result = MODEST_PROTOCOL_SECURITY_NONE;
+       ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
        gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY, 
                TRUE /* server account */);
        if (value) {
        gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY, 
                TRUE /* server account */);
        if (value) {
@@ -317,15 +317,15 @@ modest_server_account_get_security (ModestAccountMgr *self,
 
 void
 modest_server_account_set_security (ModestAccountMgr *self, 
 
 void
 modest_server_account_set_security (ModestAccountMgr *self, 
-       const gchar* account_name, ModestSecureConnection security)
+       const gchar* account_name, ModestConnectionProtocol security)
 {
        /* Get the conf string for the enum value: */
        const gchar* str_value = NULL;
 {
        /* Get the conf string for the enum value: */
        const gchar* str_value = NULL;
-       if (security == MODEST_PROTOCOL_SECURITY_NONE)
+       if (security == MODEST_PROTOCOL_CONNECTION_NORMAL)
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
-       else if (security == MODEST_PROTOCOL_SECURITY_TLS)
+       else if (security == MODEST_PROTOCOL_CONNECTION_TLS)
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
-       else if (security == MODEST_PROTOCOL_SECURITY_SSL)
+       else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
        
        /* Set it in the configuration: */
                str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
        
        /* Set it in the configuration: */
@@ -345,7 +345,7 @@ modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar*
        data->hostname     = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_HOSTNAME,TRUE);
        data->username     = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_USERNAME,TRUE);  
        proto              = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
        data->hostname     = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_HOSTNAME,TRUE);
        data->username     = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_USERNAME,TRUE);  
        proto              = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
-       data->proto        = modest_protocol_info_get_protocol (proto);
+       data->proto        = modest_protocol_info_get_protocol (proto, MODEST_TRANSPORT_STORE_PROTOCOL);
        g_free (proto);
 
        data->port         = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE);
        g_free (proto);
 
        data->port         = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE);
index b06b9e1..1c40224 100644 (file)
@@ -49,8 +49,8 @@ typedef struct {
        gchar            *password;
        time_t            last_updated;
        gint             port; /* Or 0, if the default should be used. */
        gchar            *password;
        time_t            last_updated;
        gint             port; /* Or 0, if the default should be used. */
-       ModestSecureAuthentication   secure_auth;
-       ModestSecureConnection   security;
+       ModestAuthProtocol   secure_auth;
+       ModestConnectionProtocol   security;
 } ModestServerAccountData;
 
 typedef struct {
 } ModestServerAccountData;
 
 typedef struct {
@@ -326,7 +326,7 @@ modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account
  *
  * Returns: The secure authentication enum value.
  */
  *
  * Returns: The secure authentication enum value.
  */
-ModestSecureAuthentication
+ModestAuthProtocol
 modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name);
 
 /**
 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, 
  */
 void
 modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name, 
-       ModestSecureAuthentication secure_auth);
+                                      ModestAuthProtocol secure_auth);
        
 /**
  * modest_server_account_data_get_security:
        
 /**
  * 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.
  */
  *
  * Returns: The security enum value.
  */
-ModestSecureConnection
+ModestConnectionProtocol
 modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name);
 
 /**
 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, 
  */
 void
 modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name, 
-       ModestSecureConnection security);
+                                   ModestConnectionProtocol security);
 
 ModestServerAccountData*
 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name);
 
 ModestServerAccountData*
 modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name);
index 2d6169c..b0b7910 100644 (file)
@@ -307,22 +307,17 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
                                       const gchar * name, const gchar *hostname,
                                       const gchar * username, const gchar * password,
                                       ModestProtocol proto,
                                       const gchar * name, const gchar *hostname,
                                       const gchar * username, const gchar * password,
                                       ModestProtocol proto,
-                                      ModestSecureConnection security,
-                                      ModestSecureAuthentication auth)
+                                      ModestConnectionProtocol security,
+                                      ModestAuthProtocol auth)
 {
        ModestAccountMgrPrivate *priv;
        gchar *key;
 {
        ModestAccountMgrPrivate *priv;
        gchar *key;
-       ModestProtocolType proto_type;
        gboolean ok = TRUE;
        GError *err = NULL;
        
        g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
        g_return_val_if_fail (name, FALSE);
        g_return_val_if_fail (strchr(name, '/') == NULL, FALSE);
        gboolean ok = TRUE;
        GError *err = NULL;
        
        g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
        g_return_val_if_fail (name, FALSE);
        g_return_val_if_fail (strchr(name, '/') == NULL, FALSE);
-
-       proto_type = modest_protocol_info_get_protocol_type (proto);
-       g_return_val_if_fail (proto_type == MODEST_PROTOCOL_TYPE_TRANSPORT ||
-                             proto_type == MODEST_PROTOCOL_TYPE_STORE, FALSE);
                              
        priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
        
                              
        priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
        
@@ -374,7 +369,9 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
        /* proto */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
        /* proto */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
-                                    modest_protocol_info_get_protocol_name(proto), &err);
+                                    modest_protocol_info_get_protocol_name(proto,
+                                                                           MODEST_TRANSPORT_STORE_PROTOCOL),
+                                    &err);
        if (err) {
                g_printerr ("modest: failed to set %s: %s\n", key, err->message);
                g_error_free (err);
        if (err) {
                g_printerr ("modest: failed to set %s: %s\n", key, err->message);
                g_error_free (err);
@@ -387,7 +384,9 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
        /* auth mechanism */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
        /* auth mechanism */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
-                                    modest_protocol_info_get_protocol_name (auth), &err);
+                                    modest_protocol_info_get_protocol_name (auth,
+                                                                            MODEST_AUTH_PROTOCOL),
+                                    &err);
        if (err) {
                g_printerr ("modest: failed to set %s: %s\n", key, err->message);
                g_error_free (err);
        if (err) {
                g_printerr ("modest: failed to set %s: %s\n", key, err->message);
                g_error_free (err);
@@ -396,12 +395,12 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self,
        g_free (key);
        if (!ok)
                goto cleanup;
        g_free (key);
        if (!ok)
                goto cleanup;
-
-       if (proto_type == MODEST_PROTOCOL_TYPE_STORE) {
+       
+       if (modest_protocol_info_protocol_is_store(proto)) {
                /* Add the security settings: */
                modest_server_account_set_security (self, name, security);
        }
                /* Add the security settings: */
                modest_server_account_set_security (self, name, security);
        }
-
+       
 cleanup:
        if (!ok) {
                g_printerr ("modest: failed to add server account\n");
 cleanup:
        if (!ok) {
                g_printerr ("modest: failed to add server account\n");
@@ -434,7 +433,8 @@ modest_account_mgr_add_server_account_uri (ModestAccountMgr * self,
        /* proto */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
        /* proto */
        key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_PROTO, TRUE);
        ok = modest_conf_set_string (priv->modest_conf, key,
-                                    modest_protocol_info_get_protocol_name(proto), NULL);
+                                    modest_protocol_info_get_protocol_name(proto, MODEST_TRANSPORT_STORE_PROTOCOL),
+                                    NULL);
        g_free (key);
 
        if (!ok) {
        g_free (key);
 
        if (!ok) {
@@ -551,13 +551,6 @@ modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
        GError *err = NULL;
        
        g_return_val_if_fail (self, NULL);
        GError *err = NULL;
        
        g_return_val_if_fail (self, NULL);
-
-       if (proto != MODEST_PROTOCOL_UNKNOWN) {
-               ModestProtocolType proto_type;
-               proto_type = modest_protocol_info_get_protocol_type (proto);
-               g_return_val_if_fail (proto_type == MODEST_PROTOCOL_TYPE_TRANSPORT ||
-                                     proto_type == MODEST_PROTOCOL_TYPE_STORE, NULL);
-       }
        
        key      = _modest_account_mgr_get_account_keyname (account_name, NULL, TRUE);
        priv     = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
        
        key      = _modest_account_mgr_get_account_keyname (account_name, NULL, TRUE);
        priv     = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
@@ -578,11 +571,9 @@ modest_account_mgr_search_server_accounts (ModestAccountMgr * self,
        while (cursor) { 
                gchar *account   = _modest_account_mgr_account_from_key ((gchar*)cursor->data, NULL, NULL);
                gchar *acc_proto = modest_account_mgr_get_string (self, account, MODEST_ACCOUNT_PROTO,TRUE);
        while (cursor) { 
                gchar *account   = _modest_account_mgr_account_from_key ((gchar*)cursor->data, NULL, NULL);
                gchar *acc_proto = modest_account_mgr_get_string (self, account, MODEST_ACCOUNT_PROTO,TRUE);
-               ModestProtocol     this_proto = modest_protocol_info_get_protocol (acc_proto);
-               ModestProtocolType this_type  = modest_protocol_info_get_protocol_type (this_proto);
-
-               if ((this_type  != MODEST_PROTOCOL_TYPE_UNKNOWN && this_type  != type) ||
-                   (this_proto != MODEST_PROTOCOL_UNKNOWN      && this_proto != proto)) {
+               ModestProtocol     this_proto = modest_protocol_info_get_protocol (acc_proto,
+                                                                                  MODEST_TRANSPORT_STORE_PROTOCOL);
+               if (this_proto != MODEST_PROTOCOL_UNKNOWN && this_proto != proto) {
                        GSList *nxt = cursor->next;
                        accounts = g_slist_delete_link (accounts, cursor);
                        cursor = nxt;
                        GSList *nxt = cursor->next;
                        accounts = g_slist_delete_link (accounts, cursor);
                        cursor = nxt;
index 65a8322..b5e02f8 100644 (file)
@@ -49,7 +49,6 @@ G_BEGIN_DECLS
 typedef struct _ModestAccountMgr      ModestAccountMgr;
 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
 
 typedef struct _ModestAccountMgr      ModestAccountMgr;
 typedef struct _ModestAccountMgrClass ModestAccountMgrClass;
 
-
 struct _ModestAccountMgr {
         GObject parent;
 };
 struct _ModestAccountMgr {
         GObject parent;
 };
@@ -125,8 +124,8 @@ gboolean modest_account_mgr_add_server_account    (ModestAccountMgr *self,
                                                   const gchar *username,
                                                   const gchar *password,
                                                   ModestProtocol proto,
                                                   const gchar *username,
                                                   const gchar *password,
                                                   ModestProtocol proto,
-                                                  ModestSecureConnection security,
-                                                  ModestSecureAuthentication auth);
+                                                  ModestConnectionProtocol security,
+                                                  ModestAuthProtocol auth);
 
 
 /**
 
 
 /**
index 8776762..c18daa3 100644 (file)
@@ -169,7 +169,8 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
 
        /* Proto */
        tny_account_set_proto (tny_account,
 
        /* Proto */
        tny_account_set_proto (tny_account,
-                              modest_protocol_info_get_protocol_name(account_data->proto));
+                              modest_protocol_info_get_protocol_name(account_data->proto,
+                                                                     MODEST_TRANSPORT_STORE_PROTOCOL));
 
               
        /* mbox and maildir accounts use a URI instead of the rest: */
 
               
        /* mbox and maildir accounts use a URI instead of the rest: */
@@ -181,14 +182,14 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
                /* Enable secure connection settings: */
                const gchar* option_security = NULL;
                switch (account_data->security) {
                /* Enable secure connection settings: */
                const gchar* option_security = NULL;
                switch (account_data->security) {
-               case MODEST_PROTOCOL_SECURITY_NONE:
+               case MODEST_PROTOCOL_CONNECTION_NORMAL:
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_NEVER;
                        break;
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_NEVER;
                        break;
-               case MODEST_PROTOCOL_SECURITY_SSL:
-               case MODEST_PROTOCOL_SECURITY_TLS:
+               case MODEST_PROTOCOL_CONNECTION_SSL:
+               case MODEST_PROTOCOL_CONNECTION_TLS:
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
                        break;
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_ALWAYS;;
                        break;
-               case MODEST_PROTOCOL_SECURITY_TLS_OP:
+               case MODEST_PROTOCOL_CONNECTION_TLS_OP:
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
                        break;
                default:
                        option_security = MODEST_ACCOUNT_OPTION_SSL "= " MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE;
                        break;
                default:
@@ -235,7 +236,7 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr,
                        tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
                }
                
                        tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
                }
                
-               if (account_data->proto == MODEST_PROTOCOL_TYPE_STORE) {
+               if (modest_protocol_info_protocol_is_store(account_data->proto)) {
                        /* Other connection options. Some options are only valid for IMAP
                           accounts but it's OK for just now since POP is still not
                           supported */
                        /* Other connection options. Some options are only valid for IMAP
                           accounts but it's OK for just now since POP is still not
                           supported */
index 14474d2..62438ab 100644 (file)
@@ -137,8 +137,8 @@ modest_tny_folder_get_rules   (const TnyFolder *folder)
                if (!account)
                        return -1; /* no account: nothing is allowed */
                
                if (!account)
                        return -1; /* no account: nothing is allowed */
                
-               proto = modest_protocol_info_get_protocol (
-                       tny_account_get_proto (account));
+               proto = modest_protocol_info_get_protocol (tny_account_get_proto (account),
+                                                          MODEST_TRANSPORT_STORE_PROTOCOL);
 
                if (proto == MODEST_PROTOCOL_STORE_IMAP) {
                        rules = 0;
 
                if (proto == MODEST_PROTOCOL_STORE_IMAP) {
                        rules = 0;