aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-10-13 10:20:40 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-10-13 10:20:40 +0800
commit894f6a90c2d22d88c45c0226c898b16ed5110a67 (patch)
treee760c73d8ed6aa6e347a6172fa7c5311399de1a3
parent7553a0698cdb6567ec9ecf6bdf438949caf88ed5 (diff)
downloadgsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar.gz
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar.bz2
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar.lz
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar.xz
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.tar.zst
gsoc2013-evolution-894f6a90c2d22d88c45c0226c898b16ed5110a67.zip
kill cast as lvalue warning.
2004-10-13 Not Zed <NotZed@Ximian.com> * providers/imap4/camel-imap4-folder.c (camel_imap4_folder_new) (imap4_sync_changes, imap4_sync): * providers/imap4/camel-imap4-summary.c (untagged_fetch_all): kill cast as lvalue warning. * camel-string-utils.h: add prototype for camel_toupper. * providers/imap4/camel-imap4-utils.c: * providers/imap4/camel-imap4-summary.c: * providers/imap4/camel-imap4-folder.c: * providers/imap4/camel-imap4-engine.c: * providers/imap4/camel-imap4-command.c: * providers/imap4/camel-imap4-store.c: include camel-i18n.h. 2004-10-12 Not Zed <NotZed@Ximian.com> ** See bug ??? * providers/nntp/camel-nntp-store.c (connect_to_server): if we have a username, try to authenticate before doing anything else. ** See bug #67895. * providers/nntp/camel-nntp-summary.c (add_range_xover) (add_range_head): use raw_command_auth since we might need auth here. * providers/nntp/camel-nntp-store.c (camel_nntp_raw_command_auth): new almost-raw command that also does auth. (xover_setup, connect_to_server, camel_nntp_command): use raw_command_auth since we might need auth here. 2004-10-12 Not Zed <NotZed@Ximian.com> ** See bug #67898 and probably others. * providers/imapp/camel-imapp-store.c (connect_to_server): * providers/pop3/camel-pop3-store.c (connect_to_server_wrapper): * providers/imap4/camel-imap4-store.c (connect_to_server_wrapper): * providers/imap/camel-imap-store.c (connect_to_server_wrapper): * providers/nntp/camel-nntp-store.c (connect_to_server_wrapper): * providers/smtp/camel-smtp-transport.c (connect_to_server_wrapper): Fallback to hard-coded port number if the name lookup fails and no port was supplied. svn path=/trunk/; revision=27562
-rw-r--r--camel/ChangeLog47
-rw-r--r--camel/camel-string-utils.h1
-rw-r--r--camel/providers/imap/camel-imap-store.c30
-rw-r--r--camel/providers/imap4/camel-imap4-command.c1
-rw-r--r--camel/providers/imap4/camel-imap4-engine.c1
-rw-r--r--camel/providers/imap4/camel-imap4-folder.c9
-rw-r--r--camel/providers/imap4/camel-imap4-store.c26
-rw-r--r--camel/providers/imap4/camel-imap4-summary.c7
-rw-r--r--camel/providers/imap4/camel-imap4-utils.c1
-rw-r--r--camel/providers/imapp/camel-imapp-store.c14
-rw-r--r--camel/providers/nntp/camel-nntp-store.c72
-rw-r--r--camel/providers/nntp/camel-nntp-store.h1
-rw-r--r--camel/providers/nntp/camel-nntp-summary.c4
-rw-r--r--camel/providers/pop3/camel-pop3-store.c27
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c27
15 files changed, 210 insertions, 58 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3f75ad95c9..bc797a5ef1 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,50 @@
+2004-10-13 Not Zed <NotZed@Ximian.com>
+
+ * providers/imap4/camel-imap4-folder.c (camel_imap4_folder_new)
+ (imap4_sync_changes, imap4_sync):
+ * providers/imap4/camel-imap4-summary.c (untagged_fetch_all): kill
+ cast as lvalue warning.
+
+ * camel-string-utils.h: add prototype for camel_toupper.
+
+ * providers/imap4/camel-imap4-utils.c:
+ * providers/imap4/camel-imap4-summary.c:
+ * providers/imap4/camel-imap4-folder.c:
+ * providers/imap4/camel-imap4-engine.c:
+ * providers/imap4/camel-imap4-command.c:
+ * providers/imap4/camel-imap4-store.c: include camel-i18n.h.
+
+2004-10-12 Not Zed <NotZed@Ximian.com>
+
+ ** See bug ???
+
+ * providers/nntp/camel-nntp-store.c (connect_to_server): if we
+ have a username, try to authenticate before doing anything else.
+
+ ** See bug #67895.
+
+ * providers/nntp/camel-nntp-summary.c (add_range_xover)
+ (add_range_head): use raw_command_auth since we might need auth
+ here.
+
+ * providers/nntp/camel-nntp-store.c (camel_nntp_raw_command_auth):
+ new almost-raw command that also does auth.
+ (xover_setup, connect_to_server, camel_nntp_command): use
+ raw_command_auth since we might need auth here.
+
+2004-10-12 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #67898 and probably others.
+
+ * providers/imapp/camel-imapp-store.c (connect_to_server):
+ * providers/pop3/camel-pop3-store.c (connect_to_server_wrapper):
+ * providers/imap4/camel-imap4-store.c (connect_to_server_wrapper):
+ * providers/imap/camel-imap-store.c (connect_to_server_wrapper):
+ * providers/nntp/camel-nntp-store.c (connect_to_server_wrapper):
+ * providers/smtp/camel-smtp-transport.c (connect_to_server_wrapper):
+ Fallback to hard-coded port number if the name lookup fails and no
+ port was supplied.
+
2004-10-11 Not Zed <NotZed@Ximian.com>
** See bug #67211.
diff --git a/camel/camel-string-utils.h b/camel/camel-string-utils.h
index e8a5bf3ffb..c6557551d2 100644
--- a/camel/camel-string-utils.h
+++ b/camel/camel-string-utils.h
@@ -40,6 +40,7 @@ char *camel_strstrcase (const char *haystack, const char *needle);
const char *camel_strdown (char *str);
char camel_tolower(char c);
+char camel_toupper(char c);
#ifdef __cplusplus
}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index bc89bae55b..afe9ed8c4b 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -66,8 +66,8 @@
#define d(x)
/* Specified in RFC 2060 */
-#define IMAP_PORT 143
-#define SIMAP_PORT 993
+#define IMAP_PORT "143"
+#define IMAPS_PORT "993"
static CamelDiscoStoreClass *parent_class = NULL;
@@ -867,13 +867,14 @@ connect_to_server_process (CamelService *service, const char *cmd, CamelExceptio
static struct {
char *value;
char *serv;
+ char *port;
int mode;
} ssl_options[] = {
- { "", "imaps", MODE_SSL }, /* really old (1.x) */
- { "always", "imaps", MODE_SSL },
- { "when-possible", "imap", MODE_TLS },
- { "never", "imap", MODE_CLEAR },
- { NULL, "imap", MODE_CLEAR },
+ { "", "imaps", IMAPS_PORT, MODE_SSL }, /* really old (1.x) */
+ { "always", "imaps", IMAPS_PORT, MODE_SSL },
+ { "when-possible", "imap", IMAP_PORT, MODE_TLS },
+ { "never", "imap", IMAP_PORT, MODE_CLEAR },
+ { NULL, "imap", IMAP_PORT, MODE_CLEAR },
};
static gboolean
@@ -883,7 +884,8 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
struct addrinfo hints, *ai;
int mode, ret, i;
char *serv;
-
+ const char *port;
+
if ((command = camel_url_get_param (service->url, "command")))
return connect_to_server_process (service, command, ex);
@@ -893,22 +895,30 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
break;
mode = ssl_options[i].mode;
serv = ssl_options[i].serv;
+ port = ssl_options[i].port;
} else {
mode = MODE_CLEAR;
serv = "imap";
+ port = IMAP_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
+ port = NULL;
}
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- if (!(ai = camel_getaddrinfo (service->url->host, serv, &hints, ex)))
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
+ if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
+ camel_exception_clear (ex);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ }
+ if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
camel_freeaddrinfo (ai);
diff --git a/camel/providers/imap4/camel-imap4-command.c b/camel/providers/imap4/camel-imap4-command.c
index 9b6061dbd4..b01abe9141 100644
--- a/camel/providers/imap4/camel-imap4-command.c
+++ b/camel/providers/imap4/camel-imap4-command.c
@@ -29,6 +29,7 @@
#include <camel/camel-stream-null.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-crlf.h>
+#include <camel/camel-i18n.h>
#include "camel-imap4-stream.h"
#include "camel-imap4-engine.h"
diff --git a/camel/providers/imap4/camel-imap4-engine.c b/camel/providers/imap4/camel-imap4-engine.c
index 88c03310ae..f2e94f27a4 100644
--- a/camel/providers/imap4/camel-imap4-engine.c
+++ b/camel/providers/imap4/camel-imap4-engine.c
@@ -28,6 +28,7 @@
#include <camel/camel-sasl.h>
#include <camel/camel-stream-buffer.h>
+#include <camel/camel-i18n.h>
#include "camel-imap4-summary.h"
#include "camel-imap4-command.h"
diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c
index 7175a81476..81296985bc 100644
--- a/camel/providers/imap4/camel-imap4-folder.c
+++ b/camel/providers/imap4/camel-imap4-folder.c
@@ -42,6 +42,7 @@
#include <camel/camel-stream-mem.h>
#include <camel/camel-stream-filter.h>
#include <camel/camel-mime-filter-crlf.h>
+#include <camel/camel-i18n.h>
#include "camel-imap4-utils.h"
#include "camel-imap4-store.h"
@@ -278,7 +279,7 @@ camel_imap4_folder_new (CamelStore *store, const char *full_name, CamelException
utf7_name = camel_utf8_utf7 (utf7_name);
- folder = (CamelFolder *) imap_folder = (CamelIMAP4Folder *) camel_object_new (CAMEL_TYPE_IMAP4_FOLDER);
+ folder = (CamelFolder *) (imap_folder = (CamelIMAP4Folder *)camel_object_new (CAMEL_TYPE_IMAP4_FOLDER));
camel_folder_construct (folder, store, full_name, name);
imap_folder->utf7_name = utf7_name;
@@ -399,7 +400,7 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
continue;
for (j = 0; j < sync->len; j++) {
- iinfo = (CamelIMAP4MessageInfo *) info = sync->pdata[j];
+ iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[j]);
camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags);
if (diff.changed & imap4_flags[i].flag) {
if (diff.bits & imap4_flags[i].flag) {
@@ -432,7 +433,7 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex)
return-1;
for (i = 0; i < sync->len; i++) {
- iinfo = (CamelIMAP4MessageInfo *) info = sync->pdata[i];
+ iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[i]);
info->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
iinfo->server_flags = info->flags & folder->permanent_flags;
}
@@ -458,7 +459,7 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
sync = g_ptr_array_new ();
max = camel_folder_summary_count (folder->summary);
for (i = 0; i < max; i++) {
- iinfo = (CamelIMAP4MessageInfo *) info = camel_folder_summary_index (folder->summary, i);
+ iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_index (folder->summary, i));
if (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) {
camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags);
diff.changed &= folder->permanent_flags;
diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c
index 1e9e742f29..a4ca4c4e9e 100644
--- a/camel/providers/imap4/camel-imap4-store.c
+++ b/camel/providers/imap4/camel-imap4-store.c
@@ -34,6 +34,8 @@
#include <camel/camel-private.h>
+#include <camel/camel-i18n.h>
+
#include "camel-imap4-store.h"
#include "camel-imap4-engine.h"
#include "camel-imap4-folder.h"
@@ -275,13 +277,14 @@ connect_to_server (CamelIMAP4Engine *engine, struct addrinfo *ai, int ssl_mode,
static struct {
char *value;
char *serv;
+ char *port;
int mode;
} ssl_options[] = {
- { "", "imaps", MODE_SSL }, /* really old (1.x) */
- { "always", "imaps", MODE_SSL },
- { "when-possible", "imap", MODE_TLS },
- { "never", "imap", MODE_CLEAR },
- { NULL, "imap", MODE_CLEAR },
+ { "", "imaps", "993", MODE_SSL }, /* really old (1.x) */
+ { "always", "imaps", "993", MODE_SSL },
+ { "when-possible", "imap", "143", MODE_TLS },
+ { "never", "imap", "143", MODE_CLEAR },
+ { NULL, "imap", "143", MODE_CLEAR },
};
static gboolean
@@ -292,27 +295,36 @@ connect_to_server_wrapper (CamelIMAP4Engine *engine, CamelException *ex)
const char *ssl_mode;
int mode, ret, i;
char *serv;
-
+ const char *port;
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
mode = ssl_options[i].mode;
serv = ssl_options[i].serv;
+ port = ssl_options[i].port;
} else {
mode = MODE_CLEAR;
serv = "imap";
+ port = "143";
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
+ port = NULL;
}
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- if (!(ai = camel_getaddrinfo (service->url->host, serv, &hints, ex)))
+ ai = camel_getaddrinfo (service->url->host, serv, &hints, ex);
+ if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
+ camel_exception_clear (ex);
+ ai = camel_getaddrinfo (service->url->host, port, &hints, ex);
+ }
+ if (ai == NULL)
return FALSE;
ret = connect_to_server (engine, ai, mode, ex);
diff --git a/camel/providers/imap4/camel-imap4-summary.c b/camel/providers/imap4/camel-imap4-summary.c
index 27b13d9099..c79c36d4d7 100644
--- a/camel/providers/imap4/camel-imap4-summary.c
+++ b/camel/providers/imap4/camel-imap4-summary.c
@@ -35,6 +35,7 @@
#include <e-util/md5-utils.h>
#include <camel/camel-file-utils.h>
+#include <camel/camel-i18n.h>
#include "camel-imap4-store.h"
#include "camel-imap4-engine.h"
@@ -775,20 +776,20 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind
* server is probably notifying us of a FLAGS change
* by another client? */
g_assert (index < summary->messages->len);
- iinfo = (CamelIMAP4MessageInfo *) info = summary->messages->pdata[index - 1];
+ iinfo = (CamelIMAP4MessageInfo *)(info = summary->messages->pdata[index - 1]);
g_assert (info != NULL);
} else {
if (index > (added->len + fetch->first - 1))
g_ptr_array_set_size (added, index - fetch->first + 1);
if (!(envelope = added->pdata[index - fetch->first])) {
- iinfo = (CamelIMAP4MessageInfo *) info = camel_folder_summary_info_new (summary);
+ iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_info_new (summary));
envelope = g_new (struct imap4_envelope_t, 1);
added->pdata[index - fetch->first] = envelope;
envelope->info = info;
envelope->changed = 0;
} else {
- iinfo = (CamelIMAP4MessageInfo *) info = envelope->info;
+ iinfo = (CamelIMAP4MessageInfo *) (info = envelope->info);
}
}
diff --git a/camel/providers/imap4/camel-imap4-utils.c b/camel/providers/imap4/camel-imap4-utils.c
index ecad1d28cf..55c6431dc7 100644
--- a/camel/providers/imap4/camel-imap4-utils.c
+++ b/camel/providers/imap4/camel-imap4-utils.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <camel/camel-store.h>
+#include <camel/camel-i18n.h>
#include "camel-imap4-engine.h"
#include "camel-imap4-stream.h"
diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c
index 00ba0d00ce..23b6d3ca32 100644
--- a/camel/providers/imapp/camel-imapp-store.c
+++ b/camel/providers/imapp/camel-imapp-store.c
@@ -196,6 +196,7 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls)
ex = camel_exception_new();
CAMEL_TRY {
char *serv;
+ const char *port = NULL;
struct addrinfo *ai, hints = { 0 };
/* parent class connect initialization */
@@ -206,16 +207,20 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls)
if (service->url->port) {
serv = g_alloca(16);
sprintf(serv, "%d", service->url->port);
- } else
+ } else {
serv = "imap";
+ port = "143";
+ }
#ifdef HAVE_SSL
if (camel_url_get_param (service->url, "use_ssl")) {
if (try_starttls)
tcp_stream = camel_tcp_stream_ssl_new_raw (service->session, service->url->host, STARTTLS_FLAGS);
else {
- if (service->url->port == 0)
+ if (service->url->port == 0) {
serv = "imaps";
+ port = "993";
+ }
tcp_stream = camel_tcp_stream_ssl_new (service->session, service->url->host, SSL_PORT_FLAGS);
}
} else {
@@ -227,6 +232,11 @@ connect_to_server (CamelService *service, int ssl_mode, int try_starttls)
hints.ai_socktype = SOCK_STREAM;
ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
+ if (ex->id && ex->id != CAMEL_EXCEPTION_USER_CANCEL && port != NULL) {
+ camel_exception_clear(ex);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ }
+
if (ex->id)
camel_exception_throw_ex(ex);
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 1d4f43cc52..67ca1829a1 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -58,8 +58,8 @@
extern int camel_verbose_debug;
#define dd(x) (camel_verbose_debug?(x):0)
-#define NNTP_PORT 119
-#define NNTPS_PORT 563
+#define NNTP_PORT "119"
+#define NNTPS_PORT "563"
#define DUMP_EXTENSIONS
@@ -71,6 +71,8 @@ static CamelServiceClass *service_class = NULL;
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
#define CNNTPF_CLASS(so) CAMEL_NNTP_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static int camel_nntp_try_authenticate (CamelNNTPStore *store, CamelException *ex);
+
static void nntp_construct (CamelService *service, CamelSession *session,
CamelProvider *provider, CamelURL *url,
CamelException *ex);
@@ -107,7 +109,7 @@ xover_setup(CamelNNTPStore *store, CamelException *ex)
if (store->xover || getenv("CAMEL_NNTP_DISABLE_XOVER") != NULL)
return 0;
- ret = camel_nntp_raw_command(store, ex, &line, "list overview.fmt");
+ ret = camel_nntp_raw_command_auth(store, ex, &line, "list overview.fmt");
if (ret == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("NNTP Command failed: %s"), g_strerror(errno));
@@ -248,11 +250,16 @@ connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, Cam
goto fail;
}
-
- /* set 'reader' mode & ignore return code, also ping the server, inn goes offline very quickly otherwise */
- if (camel_nntp_raw_command (store, ex, (char **) &buf, "mode reader") == -1
- || camel_nntp_raw_command (store, ex, (char **) &buf, "date") == -1)
+
+ /* if we have username, try it here */
+ if (service->url->user != NULL
+ && camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
goto fail;
+
+ /* set 'reader' mode & ignore return code, also ping the server, inn goes offline very quickly otherwise */
+ if (camel_nntp_raw_command_auth (store, ex, (char **) &buf, "mode reader") == -1
+ || camel_nntp_raw_command_auth (store, ex, (char **) &buf, "date") == -1)
+ goto fail;
if (xover_setup(store, ex) == -1)
goto fail;
@@ -274,13 +281,14 @@ connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, Cam
static struct {
char *value;
char *serv;
+ char *port;
int mode;
} ssl_options[] = {
- { "", "nntps", MODE_SSL }, /* really old (1.x) */
- { "always", "nntps", MODE_SSL },
- { "when-possible", "nntp", MODE_TLS },
- { "never", "nntp", MODE_CLEAR },
- { NULL, "nntp", MODE_CLEAR },
+ { "", "nntps", NNTPS_PORT, MODE_SSL }, /* really old (1.x) */
+ { "always", "nntps", NNTPS_PORT, MODE_SSL },
+ { "when-possible", "nntp", NNTP_PORT, MODE_TLS },
+ { "never", "nntp", NNTP_PORT, MODE_CLEAR },
+ { NULL, "nntp", NNTP_PORT, MODE_CLEAR },
};
static gboolean
@@ -290,6 +298,7 @@ nntp_connect_online (CamelService *service, CamelException *ex)
const char *ssl_mode;
int mode, ret, i;
char *serv;
+ const char *port;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -297,20 +306,28 @@ nntp_connect_online (CamelService *service, CamelException *ex)
break;
mode = ssl_options[i].mode;
serv = ssl_options[i].serv;
+ port = ssl_options[i].port;
} else {
mode = MODE_CLEAR;
serv = "nntp";
+ port = NNTP_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
+ port = NULL;
}
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- if (!(ai = camel_getaddrinfo (service->url->host, serv, &hints, ex)))
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
+ if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
+ camel_exception_clear (ex);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ }
+ if (ai == NULL)
return FALSE;
ret = connect_to_server (service, ai, mode, ex);
@@ -1252,6 +1269,33 @@ camel_nntp_raw_command(CamelNNTPStore *store, CamelException *ex, char **line, c
return ret;
}
+/* use this where you also need auth to be handled, i.e. most cases where you'd try raw command */
+int
+camel_nntp_raw_command_auth(CamelNNTPStore *store, CamelException *ex, char **line, const char *fmt, ...)
+{
+ int ret, retry, go;
+ va_list ap;
+
+ retry = 0;
+
+ do {
+ go = FALSE;
+ retry++;
+
+ va_start(ap, fmt);
+ ret = camel_nntp_raw_commandv(store, ex, line, fmt, ap);
+ va_end(ap);
+
+ if (ret == NNTP_AUTH_REQUIRED) {
+ if (camel_nntp_try_authenticate(store, ex) != NNTP_AUTH_ACCEPTED)
+ return -1;
+ go = TRUE;
+ }
+ } while (retry < 3 && go);
+
+ return ret;
+}
+
int
camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *folder, char **line, const char *fmt, ...)
{
@@ -1286,7 +1330,7 @@ camel_nntp_command (CamelNNTPStore *store, CamelException *ex, CamelNNTPFolder *
if (folder != NULL
&& (store->current_folder == NULL || strcmp(store->current_folder, ((CamelFolder *)folder)->full_name) != 0)) {
- ret = camel_nntp_raw_command(store, ex, line, "group %s", ((CamelFolder *)folder)->full_name);
+ ret = camel_nntp_raw_command_auth(store, ex, line, "group %s", ((CamelFolder *)folder)->full_name);
if (ret == 211) {
g_free(store->current_folder);
store->current_folder = g_strdup(((CamelFolder *)folder)->full_name);
diff --git a/camel/providers/nntp/camel-nntp-store.h b/camel/providers/nntp/camel-nntp-store.h
index 0e68f4ae57..a9bd682cbd 100644
--- a/camel/providers/nntp/camel-nntp-store.h
+++ b/camel/providers/nntp/camel-nntp-store.h
@@ -102,6 +102,7 @@ CamelType camel_nntp_store_get_type (void);
int camel_nntp_raw_commandv (CamelNNTPStore *store, struct _CamelException *ex, char **line, const char *fmt, va_list ap);
int camel_nntp_raw_command(CamelNNTPStore *store, struct _CamelException *ex, char **line, const char *fmt, ...);
+int camel_nntp_raw_command_auth(CamelNNTPStore *store, struct _CamelException *ex, char **line, const char *fmt, ...);
int camel_nntp_command (CamelNNTPStore *store, struct _CamelException *ex, struct _CamelNNTPFolder *folder, char **line, const char *fmt, ...);
#ifdef __cplusplus
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 6a1d208760..bb2dda8809 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -218,7 +218,7 @@ add_range_xover(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high,
camel_operation_start(NULL, _("%s: Scanning new messages"), ((CamelService *)store)->url->host);
- ret = camel_nntp_raw_command(store, ex, &line, "xover %r", low, high);
+ ret = camel_nntp_raw_command_auth(store, ex, &line, "xover %r", low, high);
if (ret != 224) {
camel_operation_end(NULL);
if (ret != -1)
@@ -319,7 +319,7 @@ add_range_head(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high,
for (i=low;i<high+1;i++) {
camel_operation_progress(NULL, (count * 100) / total);
count++;
- ret = camel_nntp_raw_command(store, ex, &line, "head %u", i);
+ ret = camel_nntp_raw_command_auth(store, ex, &line, "head %u", i);
/* unknown article, ignore */
if (ret == 423)
continue;
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 1c7b9d025d..75868910fa 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -57,7 +57,8 @@
#include "camel-i18n.h"
/* Specified in RFC 1939 */
-#define POP3_PORT 110
+#define POP3_PORT "110"
+#define POP3S_PORT "995"
static CamelStoreClass *parent_class = NULL;
@@ -269,13 +270,14 @@ connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, Cam
static struct {
char *value;
char *serv;
+ char *port;
int mode;
} ssl_options[] = {
- { "", "pop3s", MODE_SSL }, /* really old (1.x) */
- { "always", "pop3s", MODE_SSL },
- { "when-possible", "pop3", MODE_TLS },
- { "never", "pop3", MODE_CLEAR },
- { NULL, "pop3", MODE_CLEAR },
+ { "", "pop3s", POP3S_PORT, MODE_SSL }, /* really old (1.x) */
+ { "always", "pop3s", POP3S_PORT, MODE_SSL },
+ { "when-possible", "pop3", POP3S_PORT, MODE_TLS },
+ { "never", "pop3", POP3S_PORT, MODE_CLEAR },
+ { NULL, "pop3", POP3S_PORT, MODE_CLEAR },
};
static gboolean
@@ -285,27 +287,36 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
const char *ssl_mode;
int mode, ret, i;
char *serv;
-
+ const char *port;
+
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
if (!strcmp (ssl_options[i].value, ssl_mode))
break;
mode = ssl_options[i].mode;
serv = ssl_options[i].serv;
+ port = ssl_options[i].port;
} else {
mode = MODE_CLEAR;
serv = "pop3";
+ port = POP3S_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
+ port = NULL;
}
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- if (!(ai = camel_getaddrinfo (service->url->host, serv, &hints, ex)))
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
+ if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
+ camel_exception_clear (ex);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ }
+ if (ai == NULL)
return FALSE;
ret = connect_to_server (service, ai, mode, ex);
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index a6e555badf..e3d6ad3f34 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -61,7 +61,8 @@ extern int camel_verbose_debug;
#define d(x) (camel_verbose_debug ? (x) : 0)
/* Specified in RFC 821 */
-#define SMTP_PORT 25
+#define SMTP_PORT "25"
+#define SMTPS_PORT "465"
/* camel smtp transport class prototypes */
static gboolean smtp_send_to (CamelTransport *transport, CamelMimeMessage *message,
@@ -377,13 +378,14 @@ connect_to_server (CamelService *service, struct addrinfo *ai, int ssl_mode, Cam
static struct {
char *value;
char *serv;
+ char *port;
int mode;
} ssl_options[] = {
- { "", "smtps", MODE_SSL }, /* really old (1.x) */
- { "always", "smtps", MODE_SSL },
- { "when-possible", "smtp", MODE_TLS },
- { "never", "smtp", MODE_CLEAR },
- { NULL, "smtp", MODE_CLEAR },
+ { "", "smtps", SMTPS_PORT, MODE_SSL }, /* really old (1.x) */
+ { "always", "smtps", SMTPS_PORT, MODE_SSL },
+ { "when-possible", "smtp", SMTP_PORT, MODE_TLS },
+ { "never", "smtp", SMTP_PORT, MODE_CLEAR },
+ { NULL, "smtp", SMTP_PORT, MODE_CLEAR },
};
static gboolean
@@ -393,6 +395,7 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
const char *ssl_mode;
int mode, ret, i;
char *serv;
+ const char *port;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
for (i = 0; ssl_options[i].value; i++)
@@ -400,22 +403,30 @@ connect_to_server_wrapper (CamelService *service, CamelException *ex)
break;
mode = ssl_options[i].mode;
serv = ssl_options[i].serv;
+ port = ssl_options[i].port;
} else {
mode = MODE_CLEAR;
serv = "smtp";
+ port = SMTP_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
+ port = NULL;
}
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = PF_UNSPEC;
- if (!(ai = camel_getaddrinfo (service->url->host, serv, &hints, ex)))
+ ai = camel_getaddrinfo(service->url->host, serv, &hints, ex);
+ if (ai == NULL && port != NULL && camel_exception_get_id(ex) != CAMEL_EXCEPTION_USER_CANCEL) {
+ camel_exception_clear (ex);
+ ai = camel_getaddrinfo(service->url->host, port, &hints, ex);
+ }
+ if (ai == NULL)
return FALSE;
-
+
ret = connect_to_server (service, ai, mode, ex);
camel_freeaddrinfo (ai);