[evolution-patches] 67895, nntp not always authenticating




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:23:42 -0000
@@ -1,3 +1,16 @@
+2004-10-12  Not Zed  <NotZed Ximian com>
+
+	** 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:23:44 -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));
@@ -256,8 +256,8 @@ connect_to_server (CamelService *service
 	}
 	
 	/* 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 +1261,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 +1322,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:23:44 -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:23:44 -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]