From: Dirk-Jan C. Binnema Date: Tue, 15 May 2007 11:22:08 +0000 (+0000) Subject: * update for the modest-protocol-info changes X-Git-Tag: git_migration_finished~3603 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=66390524cd133ecdbe9a4365c08d60fe7547b300 * update for the modest-protocol-info changes pmo-trunk-r1870 --- diff --git a/src/modest-account-mgr-helpers.c b/src/modest-account-mgr-helpers.c index dae640f..d2859c2 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 ModestSecureAuthentication +static ModestAuthProtocol 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; @@ -249,11 +249,11 @@ get_secure_auth_for_conf_string(const gchar* value) return result; } -ModestSecureAuthentication +ModestAuthProtocol 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) { @@ -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, ModestSecureAuthentication secure_auth) + const gchar* account_name, ModestAuthProtocol secure_auth) { /* 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); } -static ModestSecureConnection +static ModestConnectionProtocol 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) - result = MODEST_PROTOCOL_SECURITY_NONE; + result = MODEST_PROTOCOL_CONNECTION_NORMAL; 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) - result = MODEST_PROTOCOL_SECURITY_SSL; + result = MODEST_PROTOCOL_CONNECTION_SSL; } return result; } -ModestSecureConnection +ModestConnectionProtocol 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) { @@ -317,15 +317,15 @@ modest_server_account_get_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; - if (security == MODEST_PROTOCOL_SECURITY_NONE) + if (security == MODEST_PROTOCOL_CONNECTION_NORMAL) 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; - 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: */ @@ -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->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); diff --git a/src/modest-account-mgr-helpers.h b/src/modest-account-mgr-helpers.h index b06b9e1..1c40224 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. */ - ModestSecureAuthentication secure_auth; - ModestSecureConnection security; + ModestAuthProtocol secure_auth; + ModestConnectionProtocol security; } ModestServerAccountData; typedef struct { @@ -326,7 +326,7 @@ modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account * * Returns: The secure authentication enum value. */ -ModestSecureAuthentication +ModestAuthProtocol 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, - ModestSecureAuthentication secure_auth); + ModestAuthProtocol 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. */ -ModestSecureConnection +ModestConnectionProtocol 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, - ModestSecureConnection security); + ModestConnectionProtocol 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 2d6169c..b0b7910 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -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, - ModestSecureConnection security, - ModestSecureAuthentication auth) + ModestConnectionProtocol security, + ModestAuthProtocol auth) { 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); - - 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); @@ -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, - 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); @@ -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, - 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); @@ -396,12 +395,12 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, 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); } - + 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, - 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) { @@ -551,13 +551,6 @@ modest_account_mgr_search_server_accounts (ModestAccountMgr * self, 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); @@ -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); - 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; diff --git a/src/modest-account-mgr.h b/src/modest-account-mgr.h index 65a8322..b5e02f8 100644 --- a/src/modest-account-mgr.h +++ b/src/modest-account-mgr.h @@ -49,7 +49,6 @@ G_BEGIN_DECLS typedef struct _ModestAccountMgr ModestAccountMgr; typedef struct _ModestAccountMgrClass ModestAccountMgrClass; - 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, - ModestSecureConnection security, - ModestSecureAuthentication auth); + ModestConnectionProtocol security, + ModestAuthProtocol auth); /** diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 8776762..c18daa3 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -169,7 +169,8 @@ modest_tny_account_new_from_server_account (ModestAccountMgr *account_mgr, /* 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: */ @@ -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) { - case MODEST_PROTOCOL_SECURITY_NONE: + case MODEST_PROTOCOL_CONNECTION_NORMAL: 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; - 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: @@ -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); } - 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 */ diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index 14474d2..62438ab 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -137,8 +137,8 @@ modest_tny_folder_get_rules (const TnyFolder *folder) 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;