/* ... */
};
+CamelServiceAuthType camel_nntp_anonymous_authtype = {
+ N_("Anonymous"),
+
+ N_("This option will connect to the NNTP server anonymously, without "
+ "authentication."),
+
+ "ANONYMOUS",
+ FALSE
+};
+
CamelServiceAuthType camel_nntp_password_authtype = {
N_("Password"),
N_("This option will authenticate with the NNTP server using a "
"plaintext password."),
- "",
+ "PLAIN",
TRUE
};
void
camel_provider_module_init (void)
{
+ GList *auth_types;
+
+ auth_types = g_list_append (NULL, &camel_nntp_anonymous_authtype);
+ auth_types = g_list_append (auth_types, &camel_nntp_password_authtype);
+
news_provider.object_types[CAMEL_PROVIDER_STORE] = camel_nntp_store_get_type ();
news_provider.url_hash = nntp_url_hash;
news_provider.url_equal = nntp_url_equal;
- news_provider.authtypes = g_list_append (NULL, &camel_nntp_password_authtype);
+ news_provider.authtypes = auth_types;
news_provider.translation_domain = GETTEXT_PACKAGE;
camel_provider_register (&news_provider);
gboolean retval = FALSE;
guchar *buf;
guint len;
- gchar *host;
- gchar *path;
- gchar *user;
+ gchar *host, *path, *user, *mechanism;
session = camel_service_get_session (service);
user_cache_dir = camel_service_get_user_cache_dir (service);
network_settings = CAMEL_NETWORK_SETTINGS (settings);
host = camel_network_settings_dup_host (network_settings);
user = camel_network_settings_dup_user (network_settings);
+ mechanism = camel_network_settings_dup_auth_mechanism (network_settings);
g_object_unref (settings);
goto fail;
}
- /* if we have username, try it here */
- if (user != NULL && *user != '\0') {
+ /* backward compatibility, empty 'mechanism' is a non-migrated account */
+ if ((user != NULL && *user != '\0' && (!mechanism || !*mechanism)) ||
+ (mechanism && *mechanism && g_strcmp0 (mechanism, "ANONYMOUS") != 0)) {
+
+ if (!user || !*user) {
+ g_set_error_literal (
+ error, CAMEL_SERVICE_ERROR,
+ CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+ _("Cannot authenticate without a username"));
+ goto fail;
+ }
/* XXX No SASL support. */
if (!camel_session_authenticate_sync (
fail:
g_free (host);
g_free (user);
+ g_free (mechanism);
return retval;
}
return name;
}
+extern CamelServiceAuthType camel_nntp_anonymous_authtype;
extern CamelServiceAuthType camel_nntp_password_authtype;
static CamelAuthenticationResult
g_object_unref (settings);
- if (user == NULL) {
+ if (!user || !*user) {
g_set_error_literal (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
GCancellable *cancellable,
GError **error)
{
- return g_list_append (NULL, &camel_nntp_password_authtype);
+ GList *auth_types;
+
+ auth_types = g_list_append (NULL, &camel_nntp_anonymous_authtype);
+ auth_types = g_list_append (auth_types, &camel_nntp_password_authtype);
+
+ return auth_types;
}
static CamelFolder *