aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog14
-rw-r--r--camel/camel-mime-utils.c43
-rw-r--r--camel/camel-mime-utils.h13
-rw-r--r--camel/providers/nntp/camel-nntp-store.c5
-rw-r--r--camel/providers/nntp/camel-nntp-summary.c8
5 files changed, 81 insertions, 2 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index ed2de1a582..7785ce9db1 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2004-03-22 Not Zed <NotZed@Ximian.com>
+
+ * camel-mime-utils.c (camel_header_newsgroups_decode)
+ (camel_header_newsgroups_free): decode newsgroups header into a
+ list of newsgroups.
+
+ ** See #55887.
+
+ * providers/nntp/camel-nntp-summary.c (camel_nntp_summary_check):
+ NOOP if we're offline.
+
+ * providers/nntp/camel-nntp-store.c (nntp_connected): spit a
+ warning if we try to do stuff whilst offline, rather than crash.
+
2004-03-19 Not Zed <NotZed@Ximian.com>
* camel-disco-store.c (disco_connect): ref the diary before
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 56a9c4bfe2..6d1f6c3b46 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -2759,6 +2759,7 @@ header_references_decode_single (const char **in, struct _camel_header_reference
*in = inptr;
}
+/* TODO: why is this needed? Can't the other interface also work? */
struct _camel_header_references *
camel_header_references_inreplyto_decode (const char *in)
{
@@ -2849,6 +2850,48 @@ camel_header_address_decode(const char *in, const char *charset)
return list;
}
+struct _camel_header_newsgroup *
+camel_header_newsgroups_decode(const char *in)
+{
+ const char *inptr = in;
+ register char c;
+ struct _camel_header_newsgroup *head, *last, *ng;
+
+ head = NULL;
+ last = (struct _camel_header_newsgroup *)&head;
+
+ c = *in;
+ while (c) {
+ const char *start;
+
+ header_decode_lwsp(&inptr);
+ start = in;
+ while ((c = *in++) && !camel_mime_is_lwsp(c) && c != ',')
+ ;
+ if (start != in) {
+ ng = g_malloc(sizeof(*ng));
+ ng->newsgroup = g_strndup(start, in-start);
+ ng->next = NULL;
+ last->next = ng;
+ last = ng;
+ }
+ }
+
+ return head;
+}
+
+void
+camel_header_newsgroups_free(struct _camel_header_newsgroup *ng)
+{
+ while (ng) {
+ struct _camel_header_newsgroup *nng = ng->next;
+
+ g_free(ng->newsgroup);
+ g_free(ng);
+ ng = nng;
+ }
+}
+
/* this must be kept in sync with the header */
static const char *encodings[] = {
"",
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 98b4eb1f1f..d4e3012d95 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -106,6 +106,12 @@ struct _camel_header_address {
unsigned int refcount;
};
+struct _camel_header_newsgroup {
+ struct _camel_header_newsgroup *next;
+
+ char *newsgroup;
+};
+
/* MUST be called before everything else */
void camel_mime_utils_init(void);
@@ -190,6 +196,9 @@ char *camel_header_encode_string (const unsigned char *in);
/* encode a phrase, like the real name of an address */
char *camel_header_encode_phrase (const unsigned char *in);
+/* FIXME: these are the only 2 functions in this header which are ch_(action)_type
+ rather than ch_type_(action) */
+
/* decode an email date field into a GMT time, + optional offset */
time_t camel_header_decode_date (const char *in, int *saveoffset);
char *camel_header_format_date (time_t time, int offset);
@@ -212,6 +221,10 @@ struct _camel_header_references *camel_header_references_dup (const struct _came
/* decode content-location */
char *camel_header_location_decode (const char *in);
+/* nntp stuff */
+struct _camel_header_newsgroup *camel_header_newsgroups_decode(const char *in);
+void camel_header_newsgroups_free(struct _camel_header_newsgroup *ng);
+
const char *camel_transfer_encoding_to_string (CamelTransferEncoding encoding);
CamelTransferEncoding camel_transfer_encoding_from_string (const char *string);
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 815e3d7397..3b04f95052 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -1027,6 +1027,11 @@ camel_nntp_try_authenticate (CamelNNTPStore *store)
static gboolean
nntp_connected (CamelNNTPStore *store, CamelException *ex)
{
+ if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE) {
+ g_warning("Trying to talk to nntp session whilst offline");
+ return FALSE;
+ }
+
if (store->stream == NULL)
return camel_service_connect (CAMEL_SERVICE (store), ex);
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 8c0d5f8476..7923369754 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -242,14 +242,18 @@ camel_nntp_summary_check(CamelNNTPSummary *cns, CamelFolderChangeInfo *changes,
unsigned int n, f, l;
int count;
+ folder = (CamelFolder *)cns->folder;
+ store = (CamelNNTPStore *)folder->parent_store;
+
+ if (((CamelDiscoStore *)store)->status == CAMEL_DISCO_STORE_OFFLINE)
+ return 0;
+
if (xover_setup (cns, ex) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
_("Connection error: %s"), strerror(errno));
return -1;
}
- folder = (CamelFolder *)cns->folder;
- store = (CamelNNTPStore *)folder->parent_store;
s = (CamelFolderSummary *)cns;
ret = camel_nntp_command(store, &line, "group %s", folder->full_name);