As a temporary solution, just printf ("\a"); to make a beep :-)
2002-01-21 Jeffrey Stedfast <fejj@ximian.com> * camel-filter-driver.c (do_beep): As a temporary solution, just printf ("\a"); to make a beep :-) * providers/imap/camel-imap-command.c (imap_command_strdup_vprintf): Encode the mailbox to UTF-7 here. * providers/imap/camel-imap-utils.c (imap_parse_list_response): Decode the mailbox name as we parse the list response. (imap_mailbox_decode): It's only an illegal mailbox name if it didn't switch back to US-ASCII mode. svn path=/trunk/; revision=15421
This commit is contained in:

committed by
Jeffrey Stedfast

parent
16b174cf0e
commit
cf8db42ff8
@ -1,3 +1,16 @@
|
|||||||
|
2002-01-21 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
|
* camel-filter-driver.c (do_beep): As a temporary solution, just
|
||||||
|
printf ("\a"); to make a beep :-)
|
||||||
|
|
||||||
|
* providers/imap/camel-imap-command.c
|
||||||
|
(imap_command_strdup_vprintf): Encode the mailbox to UTF-7 here.
|
||||||
|
|
||||||
|
* providers/imap/camel-imap-utils.c (imap_parse_list_response):
|
||||||
|
Decode the mailbox name as we parse the list response.
|
||||||
|
(imap_mailbox_decode): It's only an illegal mailbox name if it
|
||||||
|
didn't switch back to US-ASCII mode.
|
||||||
|
|
||||||
2002-01-18 Jeffrey Stedfast <fejj@ximian.com>
|
2002-01-18 Jeffrey Stedfast <fejj@ximian.com>
|
||||||
|
|
||||||
* providers/imap/camel-imap-utils.c (imap_mailbox_decode): New
|
* providers/imap/camel-imap-utils.c (imap_mailbox_decode): New
|
||||||
|
@ -570,7 +570,7 @@ do_beep (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriv
|
|||||||
d(fprintf (stderr, "beep\n"));
|
d(fprintf (stderr, "beep\n"));
|
||||||
|
|
||||||
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Beep");
|
camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Beep");
|
||||||
/*gdk_beep ();*/
|
printf ("\a");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ uuencode_close (unsigned char *in, size_t len, unsigned char *out, unsigned char
|
|||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
while (i < 3) {
|
while (i < 3) {
|
||||||
saved <<= 8;
|
saved <<= 8 | 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,12 +588,14 @@ camel_imap_response_extract (CamelImapStore *store,
|
|||||||
int len = strlen (type), i;
|
int len = strlen (type), i;
|
||||||
char *resp;
|
char *resp;
|
||||||
|
|
||||||
|
len = strlen (type);
|
||||||
|
|
||||||
for (i = 0; i < response->untagged->len; i++) {
|
for (i = 0; i < response->untagged->len; i++) {
|
||||||
resp = response->untagged->pdata[i];
|
resp = response->untagged->pdata[i];
|
||||||
/* Skip "* ", and initial sequence number, if present */
|
/* Skip "* ", and initial sequence number, if present */
|
||||||
strtoul (resp + 2, &resp, 10);
|
strtoul (resp + 2, &resp, 10);
|
||||||
if (*resp == ' ')
|
if (*resp == ' ')
|
||||||
resp = imap_next_word (resp);
|
resp = (char *) imap_next_word (resp);
|
||||||
|
|
||||||
if (!g_strncasecmp (resp, type, len))
|
if (!g_strncasecmp (resp, type, len))
|
||||||
break;
|
break;
|
||||||
@ -741,8 +743,14 @@ imap_command_strdup_vprintf (CamelImapStore *store, const char *fmt,
|
|||||||
case 'S':
|
case 'S':
|
||||||
case 'F':
|
case 'F':
|
||||||
string = args->pdata[i++];
|
string = args->pdata[i++];
|
||||||
if (*p == 'F')
|
if (*p == 'F') {
|
||||||
string = imap_namespace_concat (store, string);
|
char *mailbox;
|
||||||
|
|
||||||
|
mailbox = imap_namespace_concat (store, string);
|
||||||
|
string = imap_mailbox_encode (mailbox, strlen (mailbox));
|
||||||
|
g_free (mailbox);
|
||||||
|
}
|
||||||
|
|
||||||
if (store->capabilities & IMAP_CAPABILITY_LITERALPLUS) {
|
if (store->capabilities & IMAP_CAPABILITY_LITERALPLUS) {
|
||||||
op += sprintf (op, "{%d+}\r\n%s",
|
op += sprintf (op, "{%d+}\r\n%s",
|
||||||
strlen (string), string);
|
strlen (string), string);
|
||||||
|
@ -624,9 +624,10 @@ imap_connect_online (CamelService *service, CamelException *ex)
|
|||||||
CamelImapStore *store = CAMEL_IMAP_STORE (service);
|
CamelImapStore *store = CAMEL_IMAP_STORE (service);
|
||||||
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (service);
|
CamelDiscoStore *disco_store = CAMEL_DISCO_STORE (service);
|
||||||
CamelImapResponse *response;
|
CamelImapResponse *response;
|
||||||
int i, flags, len;
|
|
||||||
char *result, *name, *path;
|
char *result, *name, *path;
|
||||||
FILE *storeinfo;
|
FILE *storeinfo;
|
||||||
|
int i, flags;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
CAMEL_IMAP_STORE_LOCK (store, command_lock);
|
CAMEL_IMAP_STORE_LOCK (store, command_lock);
|
||||||
if (!connect_to_server (service, ex) ||
|
if (!connect_to_server (service, ex) ||
|
||||||
|
@ -33,13 +33,13 @@
|
|||||||
|
|
||||||
#define d(x) x
|
#define d(x) x
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
imap_next_word (const char *buf)
|
imap_next_word (const char *buf)
|
||||||
{
|
{
|
||||||
char *word;
|
const char *word;
|
||||||
|
|
||||||
/* skip over current word */
|
/* skip over current word */
|
||||||
for (word = (char *)buf; *word && *word != ' '; word++);
|
for (word = buf; *word && *word != ' '; word++);
|
||||||
|
|
||||||
/* skip over white space */
|
/* skip over white space */
|
||||||
for ( ; *word && *word == ' '; word++);
|
for ( ; *word && *word == ' '; word++);
|
||||||
@ -63,8 +63,8 @@ imap_next_word (const char *buf)
|
|||||||
gboolean
|
gboolean
|
||||||
imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, char *sep, char **folder)
|
imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, char *sep, char **folder)
|
||||||
{
|
{
|
||||||
char *word;
|
const char *word;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
if (*buf != '*')
|
if (*buf != '*')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -117,22 +117,34 @@ imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, ch
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
char *real_name;
|
char *astring, *mailbox;
|
||||||
int n_len;
|
size_t nlen;
|
||||||
|
|
||||||
/* get the folder name */
|
/* get the folder name */
|
||||||
word = imap_next_word (word);
|
word = imap_next_word (word);
|
||||||
real_name = imap_parse_astring (&word, &len);
|
astring = imap_parse_astring ((char **) &word, &len);
|
||||||
n_len = strlen (store->namespace);
|
if (!astring)
|
||||||
if (!strncmp (real_name, store->namespace, n_len))
|
return FALSE;
|
||||||
*folder = g_strdup (real_name + n_len);
|
|
||||||
else if (!g_strcasecmp (real_name, "INBOX")) {
|
mailbox = imap_mailbox_decode (astring, strlen (astring));
|
||||||
*folder = g_strdup (real_name);
|
g_free (astring);
|
||||||
|
if (!mailbox)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
nlen = strlen (store->namespace);
|
||||||
|
|
||||||
|
if (!strncmp (mailbox, store->namespace, nlen)) {
|
||||||
|
/* strip off the namespace */
|
||||||
|
if (nlen > 0)
|
||||||
|
memmove (mailbox, mailbox + nlen, (len - nlen) + 1);
|
||||||
|
*folder = mailbox;
|
||||||
|
} else if (!g_strcasecmp (mailbox, "INBOX")) {
|
||||||
|
*folder = mailbox;
|
||||||
} else {
|
} else {
|
||||||
g_warning ("IMAP folder name \"%s\" does not begin with \"%s\"", real_name, store->namespace);
|
g_warning ("IMAP folder name \"%s\" does not begin with \"%s\"", mailbox, store->namespace);
|
||||||
*folder = g_strdup (real_name);
|
*folder = mailbox;
|
||||||
}
|
}
|
||||||
g_free (real_name);
|
|
||||||
return *folder != NULL;
|
return *folder != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,10 +186,8 @@ imap_parse_folder_name (CamelImapStore *store, const char *folder_name)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == store->dir_sep) {
|
if (*p == store->dir_sep)
|
||||||
/* FIXME: decode mailbox */
|
|
||||||
g_ptr_array_add (heirarchy, g_strndup (folder_name, p - folder_name));
|
g_ptr_array_add (heirarchy, g_strndup (folder_name, p - folder_name));
|
||||||
}
|
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -276,7 +286,7 @@ static char imap_atom_specials[128] = {
|
|||||||
/**
|
/**
|
||||||
* imap_parse_string_generic:
|
* imap_parse_string_generic:
|
||||||
* @str_p: a pointer to a string
|
* @str_p: a pointer to a string
|
||||||
* @len: a pointer to an int to return the length in
|
* @len: a pointer to a size_t to return the length in
|
||||||
* @type: type of string (#IMAP_STRING, #IMAP_ASTRING, or #IMAP_NSTRING)
|
* @type: type of string (#IMAP_STRING, #IMAP_ASTRING, or #IMAP_NSTRING)
|
||||||
* to parse.
|
* to parse.
|
||||||
*
|
*
|
||||||
@ -295,7 +305,7 @@ static char imap_atom_specials[128] = {
|
|||||||
* latter, it will point to the character after the NIL.)
|
* latter, it will point to the character after the NIL.)
|
||||||
**/
|
**/
|
||||||
char *
|
char *
|
||||||
imap_parse_string_generic (char **str_p, int *len, int type)
|
imap_parse_string_generic (char **str_p, size_t *len, int type)
|
||||||
{
|
{
|
||||||
char *str = *str_p;
|
char *str = *str_p;
|
||||||
char *out;
|
char *out;
|
||||||
@ -304,7 +314,7 @@ imap_parse_string_generic (char **str_p, int *len, int type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
else if (*str == '"') {
|
else if (*str == '"') {
|
||||||
char *p;
|
char *p;
|
||||||
int size;
|
size_t size;
|
||||||
|
|
||||||
str++;
|
str++;
|
||||||
size = strcspn (str, "\"") + 1;
|
size = strcspn (str, "\"") + 1;
|
||||||
@ -476,7 +486,7 @@ imap_parse_body (char **body_p, CamelFolder *folder,
|
|||||||
char *body = *body_p;
|
char *body = *body_p;
|
||||||
CamelMessageContentInfo *child;
|
CamelMessageContentInfo *child;
|
||||||
CamelContentType *type;
|
CamelContentType *type;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
if (!body || *body++ != '(') {
|
if (!body || *body++ != '(') {
|
||||||
*body_p = NULL;
|
*body_p = NULL;
|
||||||
@ -533,7 +543,7 @@ imap_parse_body (char **body_p, CamelFolder *folder,
|
|||||||
/* single part */
|
/* single part */
|
||||||
char *main_type, *subtype;
|
char *main_type, *subtype;
|
||||||
char *id, *description, *encoding;
|
char *id, *description, *encoding;
|
||||||
guint32 size;
|
guint32 size = 0;
|
||||||
|
|
||||||
main_type = imap_parse_string (&body, &len);
|
main_type = imap_parse_string (&body, &len);
|
||||||
skip_char (&body, ' ');
|
skip_char (&body, ' ');
|
||||||
@ -815,7 +825,7 @@ imap_uid_array_free (GPtrArray *arr)
|
|||||||
char *
|
char *
|
||||||
imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix)
|
imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix)
|
||||||
{
|
{
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen (prefix);
|
len = strlen (prefix);
|
||||||
if (len == 0 || prefix[len - 1] == imap_store->dir_sep)
|
if (len == 0 || prefix[len - 1] == imap_store->dir_sep)
|
||||||
@ -859,7 +869,7 @@ enum {
|
|||||||
#define encode_mode(c) (is_usascii (c) ? MODE_USASCII : (c) == '&' ? MODE_AMPERSAND : MODE_MODUTF7)
|
#define encode_mode(c) (is_usascii (c) ? MODE_USASCII : (c) == '&' ? MODE_AMPERSAND : MODE_MODUTF7)
|
||||||
|
|
||||||
char *
|
char *
|
||||||
imap_mailbox_encode (const unsigned char *in, int inlen)
|
imap_mailbox_encode (const unsigned char *in, size_t inlen)
|
||||||
{
|
{
|
||||||
const unsigned char *start, *inptr, *inend;
|
const unsigned char *start, *inptr, *inend;
|
||||||
unsigned char *mailbox, *m, *mend;
|
unsigned char *mailbox, *m, *mend;
|
||||||
@ -981,7 +991,7 @@ imap_mailbox_encode (const unsigned char *in, int inlen)
|
|||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
imap_mailbox_decode (const unsigned char *in, int inlen)
|
imap_mailbox_decode (const unsigned char *in, size_t inlen)
|
||||||
{
|
{
|
||||||
const unsigned char *start, *inptr, *inend;
|
const unsigned char *start, *inptr, *inend;
|
||||||
unsigned char *mailbox, *m, *mend;
|
unsigned char *mailbox, *m, *mend;
|
||||||
@ -1033,7 +1043,7 @@ imap_mailbox_decode (const unsigned char *in, int inlen)
|
|||||||
|
|
||||||
conv = iconv (cd, &inbuf, &buflen, &outbuf, &outleft);
|
conv = iconv (cd, &inbuf, &buflen, &outbuf, &outleft);
|
||||||
if (conv == (size_t) -1) {
|
if (conv == (size_t) -1) {
|
||||||
g_warning ("error decoding mailbox from UTF-7!");
|
g_warning ("error decoding mailbox: %.*s", inlen, in);
|
||||||
}
|
}
|
||||||
iconv (cd, NULL, NULL, NULL, NULL);
|
iconv (cd, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
@ -1082,7 +1092,7 @@ imap_mailbox_decode (const unsigned char *in, int inlen)
|
|||||||
|
|
||||||
conv = iconv (cd, &inbuf, &buflen, &outbuf, &outleft);
|
conv = iconv (cd, &inbuf, &buflen, &outbuf, &outleft);
|
||||||
if (conv == (size_t) -1) {
|
if (conv == (size_t) -1) {
|
||||||
g_warning ("error decoding mailbox from UTF-7!");
|
g_warning ("error decoding mailbox: %.*s", inlen, in);
|
||||||
}
|
}
|
||||||
iconv (cd, NULL, NULL, NULL, NULL);
|
iconv (cd, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
@ -1090,8 +1100,11 @@ imap_mailbox_decode (const unsigned char *in, int inlen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (mode_switch == '-') {
|
||||||
/* illegal encoded mailbox... */
|
/* illegal encoded mailbox... */
|
||||||
g_warning ("illegal mailbox name encountered!");
|
g_warning ("illegal mailbox name encountered: %.*s", inlen, in);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy (m, start, inptr - start);
|
memcpy (m, start, inptr - start);
|
||||||
m += (inptr - start);
|
m += (inptr - start);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,12 @@ extern "C" {
|
|||||||
#pragma }
|
#pragma }
|
||||||
#endif /* __cplusplus }*/
|
#endif /* __cplusplus }*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "camel-folder-summary.h"
|
#include "camel-folder-summary.h"
|
||||||
#include "camel-imap-types.h"
|
#include "camel-imap-types.h"
|
||||||
|
|
||||||
char *imap_next_word (const char *buf);
|
const char *imap_next_word (const char *buf);
|
||||||
|
|
||||||
#define IMAP_LIST_FLAG_NOINFERIORS (1 << 0)
|
#define IMAP_LIST_FLAG_NOINFERIORS (1 << 0)
|
||||||
#define IMAP_LIST_FLAG_NOSELECT (1 << 1)
|
#define IMAP_LIST_FLAG_NOSELECT (1 << 1)
|
||||||
@ -49,7 +51,7 @@ guint32 imap_parse_flag_list (char **flag_list);
|
|||||||
|
|
||||||
enum { IMAP_STRING, IMAP_NSTRING, IMAP_ASTRING };
|
enum { IMAP_STRING, IMAP_NSTRING, IMAP_ASTRING };
|
||||||
|
|
||||||
char *imap_parse_string_generic (char **str_p, int *len, int type);
|
char *imap_parse_string_generic (char **str_p, size_t *len, int type);
|
||||||
|
|
||||||
#define imap_parse_string(str_p, len_p) \
|
#define imap_parse_string(str_p, len_p) \
|
||||||
imap_parse_string_generic (str_p, len_p, IMAP_STRING)
|
imap_parse_string_generic (str_p, len_p, IMAP_STRING)
|
||||||
@ -72,8 +74,8 @@ void imap_uid_array_free (GPtrArray *arr);
|
|||||||
char *imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix);
|
char *imap_concat (CamelImapStore *imap_store, const char *prefix, const char *suffix);
|
||||||
char *imap_namespace_concat (CamelImapStore *store, const char *name);
|
char *imap_namespace_concat (CamelImapStore *store, const char *name);
|
||||||
|
|
||||||
char *imap_mailbox_encode (const unsigned char *in, int inlen);
|
char *imap_mailbox_encode (const unsigned char *in, size_t inlen);
|
||||||
char *imap_mailbox_decode (const unsigned char *in, int inlen);
|
char *imap_mailbox_decode (const unsigned char *in, size_t inlen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user