Re: [evolution-patches] 67895, nntp not always authenticating




this is an updated patch which includes authenticating right at the start.  however i have no idea if we need to do it before or after mode reader, etc.

this may or may not override the treatment of the auth required return code, i would guess that processing is still required.

On Tue, 2004-10-12 at 12:25 +0800, Not Zed wrote:

you can get auth required at any command, this should handle more/if not all cases.

--
Michael Zucchi <notzed ximian com>
"born to die, live to work, it's all downhill from here"
Novell's Evolution and Free Software Developer
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2251.2.17
diff -u -p -r1.2251.2.17 ChangeLog
--- camel/ChangeLog	12 Oct 2004 02:01:22 -0000	1.2251.2.17
+++ camel/ChangeLog	12 Oct 2004 04:43:55 -0000
@@ -1,3 +1,21 @@
+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-11  Not Zed  <NotZed Ximian com>
 
 	** See bug #67211.
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-store.c,v
retrieving revision 1.65.14.7
diff -u -p -r1.65.14.7 camel-nntp-store.c
--- camel/providers/nntp/camel-nntp-store.c	11 Oct 2004 01:37:41 -0000	1.65.14.7
+++ camel/providers/nntp/camel-nntp-store.c	12 Oct 2004 04:43:57 -0000
@@ -112,7 +112,7 @@ xover_setup(CamelNNTPStore *store, Camel
 	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));
@@ -254,10 +254,15 @@ connect_to_server (CamelService *service
 		
 		goto fail;
 	}
+
+	/* 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 (store, ex, (char **) &buf, "mode reader") == -1
-	    || camel_nntp_raw_command (store, ex, (char **) &buf, "date") == -1)
+	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)
@@ -1261,6 +1266,33 @@ camel_nntp_raw_command(CamelNNTPStore *s
 	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, ...)
 {
@@ -1295,7 +1327,7 @@ camel_nntp_command (CamelNNTPStore *stor
 
 		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);
Index: camel/providers/nntp/camel-nntp-store.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-store.h,v
retrieving revision 1.17
diff -u -p -r1.17 camel-nntp-store.h
--- camel/providers/nntp/camel-nntp-store.h	3 Jun 2004 09:29:08 -0000	1.17
+++ camel/providers/nntp/camel-nntp-store.h	12 Oct 2004 04:43:57 -0000
@@ -102,6 +102,7 @@ CamelType camel_nntp_store_get_type (voi
 
 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
Index: camel/providers/nntp/camel-nntp-summary.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-summary.c,v
retrieving revision 1.15
diff -u -p -r1.15 camel-nntp-summary.c
--- camel/providers/nntp/camel-nntp-summary.c	3 Jun 2004 09:29:08 -0000	1.15
+++ camel/providers/nntp/camel-nntp-summary.c	12 Oct 2004 04:43:58 -0000
@@ -217,7 +217,7 @@ add_range_xover(CamelNNTPSummary *cns, C
 
 	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)
@@ -318,7 +318,7 @@ add_range_head(CamelNNTPSummary *cns, Ca
 	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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]