[evolution-data-server/camel-socks-proxy-master: 7/10] Change CamelNNTPStore to use the new API
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/camel-socks-proxy-master: 7/10] Change CamelNNTPStore to use the new API
- Date: Sat, 24 Jul 2010 03:06:30 +0000 (UTC)
commit 2d6a6589908e39b68c893b2ddcb011dd042c457f
Author: Federico Mena Quintero <federico novell com>
Date: Mon Jul 12 15:49:40 2010 -0500
Change CamelNNTPStore to use the new API
Signed-off-by: Federico Mena Quintero <federico novell com>
camel/providers/nntp/camel-nntp-store.c | 40 ++++++++----------------------
1 files changed, 11 insertions(+), 29 deletions(-)
---
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index ba2272c..01c19ee 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -49,8 +49,8 @@
#define w(x)
#define dd(x) (camel_debug("nntp")?(x):0)
-#define NNTP_PORT "119"
-#define NNTPS_PORT "563"
+#define NNTP_PORT 119
+#define NNTPS_PORT 563
#define DUMP_EXTENSIONS
@@ -205,7 +205,7 @@ enum {
#endif
static gboolean
-connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, GError **error)
+connect_to_server (CamelService *service, const char *host, const char *serv, gint fallback_port, gint ssl_mode, GError **error)
{
CamelNNTPStore *store = (CamelNNTPStore *) service;
CamelDiscoStore *disco_store = (CamelDiscoStore*) service;
@@ -247,7 +247,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, GE
g_free (socks_host);
}
- if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, ai, error) == -1) {
+ if (camel_tcp_stream_connect ((CamelTcpStream *) tcp_stream, host, serv, fallback_port, error) == -1) {
g_prefix_error (
error, _("Could not connect to %s: "),
service->url->host);
@@ -317,7 +317,7 @@ connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, GE
static struct {
const gchar *value;
const gchar *serv;
- const gchar *port;
+ gint fallback_port;
gint mode;
} ssl_options[] = {
{ "", "nntps", NNTPS_PORT, MODE_SSL }, /* really old (1.x) */
@@ -330,11 +330,10 @@ static struct {
static gboolean
nntp_connect_online (CamelService *service, GError **error)
{
- struct addrinfo hints, *ai;
const gchar *ssl_mode;
- gint mode, ret, i;
+ gint mode, i;
gchar *serv;
- const gchar *port;
+ gint fallback_port;
GError *local_error = NULL;
if ((ssl_mode = camel_url_get_param (service->url, "use_ssl"))) {
@@ -343,37 +342,20 @@ nntp_connect_online (CamelService *service, GError **error)
break;
mode = ssl_options[i].mode;
serv = (gchar *) ssl_options[i].serv;
- port = ssl_options[i].port;
+ fallback_port = ssl_options[i].fallback_port;
} else {
mode = MODE_CLEAR;
serv = (gchar *) "nntp";
- port = NNTP_PORT;
+ fallback_port = NNTP_PORT;
}
if (service->url->port) {
serv = g_alloca (16);
sprintf (serv, "%d", service->url->port);
- port = NULL;
+ fallback_port = 0;
}
- memset (&hints, 0, sizeof (hints));
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = PF_UNSPEC;
- ai = camel_getaddrinfo(service->url->host, serv, &hints, &local_error);
- if (ai == NULL && port != NULL && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_clear_error (&local_error);
- ai = camel_getaddrinfo(service->url->host, port, &hints, &local_error);
- }
- if (ai == NULL) {
- g_propagate_error (error, local_error);
- return FALSE;
- }
-
- ret = connect_to_server (service, ai, mode, error);
-
- camel_freeaddrinfo (ai);
-
- return ret;
+ return connect_to_server (service, service->url->host, serv, fallback_port, mode, error);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]