diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-09-19 03:02:15 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-09-19 03:02:15 +0800 |
commit | 91195af48f02c220eb2eca29c2ab417faf8a705f (patch) | |
tree | c038f47f62273301e6241056556de733d911483f /camel | |
parent | 21c57eeb74e30e5c2a42c066889b7ca6cd874d74 (diff) | |
download | gsoc2013-evolution-91195af48f02c220eb2eca29c2ab417faf8a705f.tar.gz gsoc2013-evolution-91195af48f02c220eb2eca29c2ab417faf8a705f.tar.zst gsoc2013-evolution-91195af48f02c220eb2eca29c2ab417faf8a705f.zip |
New function to replace the one from camel-mime-part.c
2003-09-18 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-utils.c (camel_transfer_encoding_to_string): New
function to replace the one from camel-mime-part.c
(camel_transfer_encoding_from_string): Same.
(camel_content_transfer_encoding_decode): Renamed from
camel_header_content_encoding_decode().
* camel-mime-part.c (camel_mime_part_encoding_to_string): Removed.
(camel_mime_part_encoding_from_string): Removed.
* camel-data-wrapper.[c,h]: updated for CamelTransferEncoding
namespace changes
* camel-folder-summary.c: updated for CamelTransferEncoding
namespace changes
* camel-mime-filter-bestenc.[c,h]: updated for CamelTransferEncoding
namespace changes
* camel-mime-message.c: updated for CamelTransferEncoding
namespace changes
* camel-mime-part-utils.c: updated for CamelTransferEncoding
namespace changes
* camel-multipart-signed.c: updated for CamelTransferEncoding
namespace changes
* camel-smime-context.c: updated for CamelTransferEncoding
namespace changes
* providers/imapp/camel-imapp-utils.c: updated for
CamelTransferEncoding namespace changes
* tests/lib/messages.c: updated for CamelTransferEncoding
namespace changes
* tests/message/test1.c: updated for CamelTransferEncoding
namespace changes
svn path=/trunk/; revision=22617
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 41 | ||||
-rw-r--r-- | camel/camel-data-wrapper.c | 8 | ||||
-rw-r--r-- | camel/camel-data-wrapper.h | 2 | ||||
-rw-r--r-- | camel/camel-folder-summary.c | 4 | ||||
-rw-r--r-- | camel/camel-mime-filter-bestenc.c | 18 | ||||
-rw-r--r-- | camel/camel-mime-filter-bestenc.h | 2 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 12 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 4 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 54 | ||||
-rw-r--r-- | camel/camel-mime-part.h | 10 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 39 | ||||
-rw-r--r-- | camel/camel-mime-utils.h | 25 | ||||
-rw-r--r-- | camel/camel-multipart-signed.c | 8 | ||||
-rw-r--r-- | camel/camel-smime-context.c | 8 | ||||
-rw-r--r-- | camel/providers/imapp/camel-imapp-utils.c | 2 | ||||
-rw-r--r-- | camel/tests/lib/messages.c | 6 | ||||
-rw-r--r-- | camel/tests/message/test1.c | 2 |
17 files changed, 142 insertions, 103 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 9d2f4ae684..5588c52786 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,46 @@ 2003-09-18 Jeffrey Stedfast <fejj@ximian.com> + * camel-mime-utils.c (camel_transfer_encoding_to_string): New + function to replace the one from camel-mime-part.c + (camel_transfer_encoding_from_string): Same. + (camel_content_transfer_encoding_decode): Renamed from + camel_header_content_encoding_decode(). + + * camel-mime-part.c (camel_mime_part_encoding_to_string): Removed. + (camel_mime_part_encoding_from_string): Removed. + + * camel-data-wrapper.[c,h]: updated for CamelTransferEncoding + namespace changes + + * camel-folder-summary.c: updated for CamelTransferEncoding + namespace changes + + * camel-mime-filter-bestenc.[c,h]: updated for CamelTransferEncoding + namespace changes + + * camel-mime-message.c: updated for CamelTransferEncoding + namespace changes + + * camel-mime-part-utils.c: updated for CamelTransferEncoding + namespace changes + + * camel-multipart-signed.c: updated for CamelTransferEncoding + namespace changes + + * camel-smime-context.c: updated for CamelTransferEncoding + namespace changes + + * providers/imapp/camel-imapp-utils.c: updated for + CamelTransferEncoding namespace changes + + * tests/lib/messages.c: updated for CamelTransferEncoding + namespace changes + + * tests/message/test1.c: updated for CamelTransferEncoding + namespace changes + +2003-09-18 Jeffrey Stedfast <fejj@ximian.com> + * camel-mime-utils.[c,h]: namespaced the encoding/decoding routines. diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index 9cacbaf5e3..e30cd10927 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -76,7 +76,7 @@ camel_data_wrapper_init (gpointer object, gpointer klass) pthread_mutex_init (&camel_data_wrapper->priv->stream_lock, NULL); camel_data_wrapper->mime_type = camel_content_type_new ("application", "octet-stream"); - camel_data_wrapper->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT; + camel_data_wrapper->encoding = CAMEL_TRANSFER_ENCODING_DEFAULT; camel_data_wrapper->offline = FALSE; } @@ -179,17 +179,17 @@ decode_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) fstream = (CamelStream *) camel_stream_filter_new_with_stream (stream); switch (data_wrapper->encoding) { - case CAMEL_MIME_PART_ENCODING_BASE64: + case CAMEL_TRANSFER_ENCODING_BASE64: filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_BASE64_DEC); camel_stream_filter_add (CAMEL_STREAM_FILTER (fstream), filter); camel_object_unref (filter); break; - case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE: + case CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE: filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_QP_DEC); camel_stream_filter_add (CAMEL_STREAM_FILTER (fstream), filter); camel_object_unref (filter); break; - case CAMEL_MIME_PART_ENCODING_UUENCODE: + case CAMEL_TRANSFER_ENCODING_UUENCODE: filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_UU_DEC); camel_stream_filter_add (CAMEL_STREAM_FILTER (fstream), filter); camel_object_unref (filter); diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h index cfe7a8cf53..1e22595019 100644 --- a/camel/camel-data-wrapper.h +++ b/camel/camel-data-wrapper.h @@ -45,7 +45,7 @@ struct _CamelDataWrapper { CamelObject parent_object; struct _CamelDataWrapperPrivate *priv; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; CamelContentType *mime_type; CamelStream *stream; diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index d7c08219c5..3ad9eb31ad 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -1877,7 +1877,7 @@ content_info_new (CamelFolderSummary *s, struct _camel_header_raw *h) charset = e_iconv_locale_charset (); ci->id = camel_header_msgid_decode (camel_header_raw_find (&h, "content-id", NULL)); ci->description = camel_header_decode_string (camel_header_raw_find (&h, "content-description", NULL), NULL); - ci->encoding = camel_header_content_encoding_decode (camel_header_raw_find (&h, "content-transfer-encoding", NULL)); + ci->encoding = camel_content_transfer_encoding_decode (camel_header_raw_find (&h, "content-transfer-encoding", NULL)); return ci; } @@ -2022,7 +2022,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam d(printf("generating index:\n")); - encoding = camel_header_content_encoding_decode(camel_mime_parser_header(mp, "content-transfer-encoding", NULL)); + encoding = camel_content_transfer_encoding_decode(camel_mime_parser_header(mp, "content-transfer-encoding", NULL)); if (encoding) { if (!strcasecmp(encoding, "base64")) { d(printf(" decoding base64\n")); diff --git a/camel/camel-mime-filter-bestenc.c b/camel/camel-mime-filter-bestenc.c index 5fc0bb9985..2752652003 100644 --- a/camel/camel-mime-filter-bestenc.c +++ b/camel/camel-mime-filter-bestenc.c @@ -219,10 +219,10 @@ camel_mime_filter_bestenc_new (unsigned int flags) * * Return value: **/ -CamelMimePartEncodingType +CamelTransferEncoding camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required) { - CamelMimePartEncodingType bestenc; + CamelTransferEncoding bestenc; int istext; istext = (required & CAMEL_BESTENC_TEXT) ? 1 : 0; @@ -238,15 +238,15 @@ camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBest that will never let it show. Unfortunately only base64 can at present, although qp could be modified to allow it too */ if ((f->flags & CAMEL_BESTENC_NO_FROM) && f->hadfrom) - return CAMEL_MIME_PART_ENCODING_BASE64; + return CAMEL_TRANSFER_ENCODING_BASE64; /* if we need to encode, see how we do it */ if (required == CAMEL_BESTENC_BINARY) - bestenc = CAMEL_MIME_PART_ENCODING_BINARY; + bestenc = CAMEL_TRANSFER_ENCODING_BINARY; else if (istext && (f->count0 == 0 && f->count8 < (f->total * 17 / 100))) - bestenc = CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE; + bestenc = CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE; else - bestenc = CAMEL_MIME_PART_ENCODING_BASE64; + bestenc = CAMEL_TRANSFER_ENCODING_BASE64; /* if we have nocrlf order, or long lines, we need to encode always */ if (f->crlfnoorder || f->maxline >= 998) @@ -254,7 +254,7 @@ camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBest /* if we have no 8 bit chars or nul's, we can just use 7 bit */ if (f->count8 + f->count0 == 0) - return CAMEL_MIME_PART_ENCODING_7BIT; + return CAMEL_TRANSFER_ENCODING_7BIT; /* otherwise, we see if we can use 8 bit, or not */ switch(required) { @@ -264,12 +264,12 @@ camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBest case CAMEL_BESTENC_BINARY: default: if (f->count0 == 0) - return CAMEL_MIME_PART_ENCODING_8BIT; + return CAMEL_TRANSFER_ENCODING_8BIT; else return bestenc; } - return CAMEL_MIME_PART_ENCODING_DEFAULT; + return CAMEL_TRANSFER_ENCODING_DEFAULT; } /** diff --git a/camel/camel-mime-filter-bestenc.h b/camel/camel-mime-filter-bestenc.h index de4a82d502..be0b8ae37a 100644 --- a/camel/camel-mime-filter-bestenc.h +++ b/camel/camel-mime-filter-bestenc.h @@ -90,7 +90,7 @@ CamelType camel_mime_filter_bestenc_get_type (void); CamelMimeFilterBestenc *camel_mime_filter_bestenc_new (unsigned int flags); -CamelMimePartEncodingType camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required); +CamelTransferEncoding camel_mime_filter_bestenc_get_best_encoding(CamelMimeFilterBestenc *f, CamelBestencEncoding required); const char * camel_mime_filter_bestenc_get_best_charset(CamelMimeFilterBestenc *f); void camel_mime_filter_bestenc_set_flags(CamelMimeFilterBestenc *f, unsigned int flags); diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 65e4207a19..b292e22bd0 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -647,13 +647,13 @@ camel_mime_message_foreach_part (CamelMimeMessage *msg, CamelPartFunc callback, static gboolean check_8bit (CamelMimeMessage *msg, CamelMimePart *part, void *data) { - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; int *has8bit = data; /* check this part, and stop as soon as we are done */ encoding = camel_mime_part_get_encoding (part); - *has8bit = encoding == CAMEL_MIME_PART_ENCODING_8BIT || encoding == CAMEL_MIME_PART_ENCODING_BINARY; + *has8bit = encoding == CAMEL_TRANSFER_ENCODING_8BIT || encoding == CAMEL_TRANSFER_ENCODING_BINARY; return !(*has8bit); } @@ -669,11 +669,11 @@ camel_mime_message_has_8bit_parts (CamelMimeMessage *msg) } /* finds the best charset and transfer encoding for a given part */ -static CamelMimePartEncodingType +static CamelTransferEncoding find_best_encoding (CamelMimePart *part, CamelBestencRequired required, CamelBestencEncoding enctype, char **charsetp) { CamelMimeFilterCharset *charenc = NULL; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; CamelMimeFilterBestenc *bestenc; unsigned int flags, callerflags; CamelDataWrapper *content; @@ -695,7 +695,7 @@ find_best_encoding (CamelMimePart *part, CamelBestencRequired required, CamelBes /* charset might not be right here, but it'll get the right stuff if it is ever set */ *charsetp = NULL; - return CAMEL_MIME_PART_ENCODING_DEFAULT; + return CAMEL_TRANSFER_ENCODING_DEFAULT; } istext = camel_content_type_is (((CamelDataWrapper *) part)->mime_type, "text", "*"); @@ -797,7 +797,7 @@ static gboolean best_encoding (CamelMimeMessage *msg, CamelMimePart *part, void *datap) { struct _enc_data *data = datap; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; CamelDataWrapper *wrapper; char *charset; diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index e2df274abb..f063b3af80 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -88,7 +88,7 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse ct = camel_mime_parser_content_type (mp); - encoding = camel_header_content_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL)); + encoding = camel_content_transfer_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL)); switch (camel_mime_parser_state (mp)) { case CAMEL_MIME_PARSER_STATE_HEADER: @@ -125,7 +125,7 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse if (content) { if (encoding) - content->encoding = camel_mime_part_encoding_from_string (encoding); + content->encoding = camel_transfer_encoding_from_string (encoding); /* would you believe you have to set this BEFORE you set the content object??? oh my god !!!! */ camel_data_wrapper_set_mime_type_field (content, camel_mime_part_get_content_type (dw)); diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 88ec42c53d..80d6a6bf94 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -166,7 +166,7 @@ camel_mime_part_init (gpointer object, gpointer klass) mime_part->content_MD5 = NULL; mime_part->content_location = NULL; mime_part->content_languages = NULL; - mime_part->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT; + mime_part->encoding = CAMEL_TRANSFER_ENCODING_DEFAULT; } @@ -241,7 +241,7 @@ process_header(CamelMedium *medium, const char *name, const char *value) break; case HEADER_ENCODING: text = camel_header_token_decode (value); - mime_part->encoding = camel_mime_part_encoding_from_string (text); + mime_part->encoding = camel_transfer_encoding_from_string (text); g_free (text); break; case HEADER_CONTENT_MD5: @@ -482,16 +482,16 @@ camel_mime_part_get_content_location (CamelMimePart *mime_part) void camel_mime_part_set_encoding (CamelMimePart *mime_part, - CamelMimePartEncodingType encoding) + CamelTransferEncoding encoding) { const char *text; - text = camel_mime_part_encoding_to_string (encoding); + text = camel_transfer_encoding_to_string (encoding); camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Transfer-Encoding", text); } -CamelMimePartEncodingType +CamelTransferEncoding camel_mime_part_get_encoding (CamelMimePart *mime_part) { return mime_part->encoding; @@ -690,13 +690,13 @@ write_to_stream (CamelDataWrapper *dw, CamelStream *stream) if (mp->encoding != content->encoding) { switch (mp->encoding) { - case CAMEL_MIME_PART_ENCODING_BASE64: + case CAMEL_TRANSFER_ENCODING_BASE64: filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_BASE64_ENC); break; - case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE: + case CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE: filter = (CamelMimeFilter *) camel_mime_filter_basic_new_type (CAMEL_MIME_FILTER_BASIC_QP_ENC); break; - case CAMEL_MIME_PART_ENCODING_UUENCODE: + case CAMEL_TRANSFER_ENCODING_UUENCODE: filename = camel_mime_part_get_filename (mp); count = camel_stream_printf (ostream, "begin 644 %s\n", filename ? filename : "untitled"); if (count == -1) @@ -759,7 +759,7 @@ write_to_stream (CamelDataWrapper *dw, CamelStream *stream) total += count; - if (reencode && mp->encoding == CAMEL_MIME_PART_ENCODING_UUENCODE) { + if (reencode && mp->encoding == CAMEL_TRANSFER_ENCODING_UUENCODE) { count = camel_stream_write (ostream, "end\n", 4); if (count == -1) return -1; @@ -860,42 +860,6 @@ construct_from_stream(CamelDataWrapper *dw, CamelStream *s) return ret; } -/* this must be kept in sync with the header */ -static const char *encodings[] = { - "", - "7bit", - "8bit", - "base64", - "quoted-printable", - "binary", - "x-uuencode", -}; - -const char * -camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding) -{ - if (encoding >= sizeof(encodings)/sizeof(encodings[0])) - encoding = 0; - - return encodings[encoding]; -} - -/* FIXME I am not sure this is the correct way to do this. */ -CamelMimePartEncodingType -camel_mime_part_encoding_from_string (const char *string) -{ - int i; - - if (string != NULL) { - for (i=0;i<sizeof(encodings)/sizeof(encodings[0]);i++) - if (!strcasecmp(string, encodings[i])) - return i; - } - - return CAMEL_MIME_PART_ENCODING_DEFAULT; -} - - /******************************/ /** Misc utility functions **/ diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h index 5c3d7d9b59..2e7ea48a9c 100644 --- a/camel/camel-mime-part.h +++ b/camel/camel-mime-part.h @@ -56,7 +56,7 @@ struct _CamelMimePart { char *content_MD5; char *content_location; GList *content_languages; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; }; typedef struct _CamelMimePartClass { @@ -90,8 +90,8 @@ const char *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part); void camel_mime_part_set_content_location (CamelMimePart *mime_part, const char *); const char *camel_mime_part_get_content_location (CamelMimePart *mime_part); -void camel_mime_part_set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType type); -CamelMimePartEncodingType camel_mime_part_get_encoding (CamelMimePart *mime_part); +void camel_mime_part_set_encoding (CamelMimePart *mime_part, CamelTransferEncoding type); +CamelTransferEncoding camel_mime_part_get_encoding (CamelMimePart *mime_part); void camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages); const GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); @@ -100,10 +100,6 @@ const GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); void camel_mime_part_set_content_type (CamelMimePart *mime_part, const char *content_type); CamelContentType *camel_mime_part_get_content_type (CamelMimePart *mime_part); -/* FIXME: move to camel-mime-utils, and rename CamelEncodingType or CamelTransferEncoding */ -const char * camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding); -CamelMimePartEncodingType camel_mime_part_encoding_from_string (const char *string); - /* construction */ int camel_mime_part_construct_from_parser (CamelMimePart *, CamelMimeParser *); diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 197ae69058..06bde77f7c 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -2871,6 +2871,40 @@ camel_header_address_decode(const char *in, const char *charset) return list; } +/* this must be kept in sync with the header */ +static const char *encodings[] = { + "", + "7bit", + "8bit", + "base64", + "quoted-printable", + "binary", + "x-uuencode", +}; + +const char * +camel_transfer_encoding_to_string (CamelTransferEncoding encoding) +{ + if (encoding >= sizeof (encodings) / sizeof (encodings[0])) + encoding = 0; + + return encodings[encoding]; +} + +CamelTransferEncoding +camel_transfer_encoding_from_string (const char *string) +{ + int i; + + if (string != NULL) { + for (i = 0; i < sizeof (encodings) / sizeof (encodings[0]); i++) + if (!strcasecmp (string, encodings[i])) + return i; + } + + return CAMEL_TRANSFER_ENCODING_DEFAULT; +} + void camel_header_mime_decode(const char *in, int *maj, int *min) { @@ -3324,10 +3358,11 @@ camel_content_type_simple (CamelContentType *ct) } char * -camel_header_content_encoding_decode(const char *in) +camel_content_transfer_encoding_decode (const char *in) { if (in) - return decode_token(&in); + return decode_token (&in); + return NULL; } diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h index 5e2fa766a9..3048950411 100644 --- a/camel/camel-mime-utils.h +++ b/camel/camel-mime-utils.h @@ -43,16 +43,16 @@ extern "C" { #define CAMEL_UUDECODE_STATE_MASK (CAMEL_UUDECODE_STATE_BEGIN | CAMEL_UUDECODE_STATE_END) /* note, if you change this, make sure you change the 'encodings' array in camel-mime-part.c */ -typedef enum _CamelMimePartEncodingType { - CAMEL_MIME_PART_ENCODING_DEFAULT, - CAMEL_MIME_PART_ENCODING_7BIT, - CAMEL_MIME_PART_ENCODING_8BIT, - CAMEL_MIME_PART_ENCODING_BASE64, - CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE, - CAMEL_MIME_PART_ENCODING_BINARY, - CAMEL_MIME_PART_ENCODING_UUENCODE, - CAMEL_MIME_PART_NUM_ENCODINGS -} CamelMimePartEncodingType; +typedef enum _CamelTransferEncoding { + CAMEL_TRANSFER_ENCODING_DEFAULT, + CAMEL_TRANSFER_ENCODING_7BIT, + CAMEL_TRANSFER_ENCODING_8BIT, + CAMEL_TRANSFER_ENCODING_BASE64, + CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE, + CAMEL_TRANSFER_ENCODING_BINARY, + CAMEL_TRANSFER_ENCODING_UUENCODE, + CAMEL_TRANSFER_NUM_ENCODINGS +} CamelTransferEncoding; /* a list of references for this message */ struct _camel_header_references { @@ -159,7 +159,7 @@ void camel_content_disposition_unref (CamelContentDisposition *); char *camel_content_disposition_format (CamelContentDisposition *d); /* decode the contents of a content-encoding header */ -char *camel_header_content_encoding_decode (const char *in); +char *camel_content_transfer_encoding_decode (const char *in); /* raw headers */ void camel_header_raw_append (struct _camel_header_raw **list, const char *name, const char *value, int offset); @@ -212,6 +212,9 @@ struct _camel_header_references *camel_header_references_dup (const struct _came /* decode content-location */ char *camel_header_location_decode (const char *in); +const char *camel_transfer_encoding_to_string (CamelTransferEncoding encoding); +CamelTransferEncoding camel_transfer_encoding_from_string (const char *string); + /* decode the mime-type header */ void camel_header_mime_decode (const char *in, int *maj, int *min); diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c index 63c48a5b98..c249690ad4 100644 --- a/camel/camel-multipart-signed.c +++ b/camel/camel-multipart-signed.c @@ -545,7 +545,7 @@ static void prepare_sign(CamelMimePart *mime_part) { CamelDataWrapper *wrapper; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; int parts, i; wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part)); @@ -561,9 +561,9 @@ prepare_sign(CamelMimePart *mime_part) } else { encoding = camel_mime_part_get_encoding(mime_part); - if (encoding != CAMEL_MIME_PART_ENCODING_BASE64 - && encoding != CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE) { - camel_mime_part_set_encoding(mime_part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE); + if (encoding != CAMEL_TRANSFER_ENCODING_BASE64 + && encoding != CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE) { + camel_mime_part_set_encoding(mime_part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE); } } } diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c index 9ba1d2be74..dfd7ecd7f4 100644 --- a/camel/camel-smime-context.c +++ b/camel/camel-smime-context.c @@ -289,7 +289,7 @@ smime_sign_restore (CamelMimePart *mime_part, GSList **encodings) *encodings = (*encodings)->next; } } else { - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; if (CAMEL_IS_MIME_MESSAGE (wrapper)) { /* restore the message parts' subparts */ @@ -320,7 +320,7 @@ smime_sign_prepare (CamelMimePart *mime_part, GSList **encodings) smime_sign_prepare (part, encodings); } } else { - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; if (CAMEL_IS_MIME_MESSAGE (wrapper)) { /* prepare the message parts' subparts */ @@ -330,8 +330,8 @@ smime_sign_prepare (CamelMimePart *mime_part, GSList **encodings) /* FIXME: find the best encoding for this part and use that instead?? */ /* the encoding should really be QP or Base64 */ - if (encoding != CAMEL_MIME_PART_ENCODING_BASE64) - camel_mime_part_set_encoding (mime_part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE); + if (encoding != CAMEL_TRANSFER_ENCODING_BASE64) + camel_mime_part_set_encoding (mime_part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE); *encodings = g_slist_append (*encodings, GINT_TO_POINTER (encoding)); } diff --git a/camel/providers/imapp/camel-imapp-utils.c b/camel/providers/imapp/camel-imapp-utils.c index dcbc362554..e20499689d 100644 --- a/camel/providers/imapp/camel-imapp-utils.c +++ b/camel/providers/imapp/camel-imapp-utils.c @@ -320,7 +320,7 @@ media_text ::= <"> "TEXT" <"> SPACE media_subtype struct _body_fields { CamelContentType *ct; char *msgid, *desc; - CamelMimePartEncodingType encoding; + CamelTransferEncoding encoding; guint32 size; };*/ diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c index 5a687e8df3..ff3485f9c2 100644 --- a/camel/tests/lib/messages.c +++ b/camel/tests/lib/messages.c @@ -256,8 +256,8 @@ message_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int depth) printf("%sPart <%s>\n", s, ((CamelObject *)part)->klass->name); printf("%sContent-Type: %s\n", s, mime_type); g_free(mime_type); - printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)part)->encoding)); - printf("%s part encoding: %s\n", s, camel_mime_part_encoding_to_string(part->encoding)); + printf("%s encoding: %s\n", s, camel_transfer_encoding_to_string(((CamelDataWrapper *)part)->encoding)); + printf("%s part encoding: %s\n", s, camel_transfer_encoding_to_string(part->encoding)); containee = camel_medium_get_content_object (CAMEL_MEDIUM (part)); @@ -268,7 +268,7 @@ message_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int depth) printf("%sContent <%s>\n", s, ((CamelObject *)containee)->klass->name); printf ("%sContent-Type: %s\n", s, mime_type); g_free (mime_type); - printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)containee)->encoding)); + printf("%s encoding: %s\n", s, camel_transfer_encoding_to_string(((CamelDataWrapper *)containee)->encoding)); /* using the object types is more accurate than using the mime/types */ if (CAMEL_IS_MULTIPART (containee)) { diff --git a/camel/tests/message/test1.c b/camel/tests/message/test1.c index 6eadfcacc2..3c16dab963 100644 --- a/camel/tests/message/test1.c +++ b/camel/tests/message/test1.c @@ -164,7 +164,7 @@ int main(int argc, char **argv) len = texts[j].len; for (i=0;i<CAMEL_MIME_PART_NUM_ENCODINGS;i++) { - push("test simple message, encoding %s", camel_mime_part_encoding_to_string(i)); + push("test simple message, encoding %s", camel_transfer_encoding_to_string(i)); msg = test_message_create_simple(); push("set simple content"); |