gmime r1326 - in trunk: . docs/reference gmime mono
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1326 - in trunk: . docs/reference gmime mono
- Date: Sun, 1 Jun 2008 21:26:10 +0000 (UTC)
Author: fejj
Date: Sun Jun 1 21:26:09 2008
New Revision: 1326
URL: http://svn.gnome.org/viewvc/gmime?rev=1326&view=rev
Log:
2008-06-01 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-part.c: Updated for GMimeFilterCRLF changes.
* gmime/gmime-multipart-signed.c: Updated for GMimeFilterCRLF
changes.
* gmime/gmime-multipart-encrypted.c: Updated for GMimeFilterCRLF
changes.
* gmime/gmime-filter-crlf.c (g_mime_filter_crlf_new): No longer
takes 2 enum arguments, rather it now takes 2 bool arguments which
makes the API simpler to understand.
* gmime/gmime-filter-best.c (g_mime_filter_best_new): Changed the
unsigned int flags argument to be an enum so developers could more
easily figure out what the argument was.
Modified:
trunk/ChangeLog
trunk/docs/reference/gmime-sections.txt
trunk/docs/reference/gmime.hierarchy
trunk/gmime/gmime-filter-best.c
trunk/gmime/gmime-filter-best.h
trunk/gmime/gmime-filter-crlf.c
trunk/gmime/gmime-filter-crlf.h
trunk/gmime/gmime-multipart-encrypted.c
trunk/gmime/gmime-multipart-signed.c
trunk/gmime/gmime-part.c
trunk/mono/gmime-api.raw
Modified: trunk/docs/reference/gmime-sections.txt
==============================================================================
--- trunk/docs/reference/gmime-sections.txt (original)
+++ trunk/docs/reference/gmime-sections.txt Sun Jun 1 21:26:09 2008
@@ -301,6 +301,7 @@
<FILE>gmime-filter-best</FILE>
GMimeFilterBest
GMimeBestEncoding
+GMimeFilterBestFlags
g_mime_filter_best_new
g_mime_filter_best_charset
g_mime_filter_best_encoding
@@ -339,8 +340,6 @@
<SECTION>
<FILE>gmime-filter-crlf</FILE>
GMimeFilterCRLF
-GMimeFilterCRLFDirection
-GMimeFilterCRLFMode
g_mime_filter_crlf_new
<SUBSECTION Private>
Modified: trunk/docs/reference/gmime.hierarchy
==============================================================================
--- trunk/docs/reference/gmime.hierarchy (original)
+++ trunk/docs/reference/gmime.hierarchy Sun Jun 1 21:26:09 2008
@@ -36,3 +36,4 @@
GMimeStreamMmap
GMimeStreamNull
GInterface
+ GTypePlugin
Modified: trunk/gmime/gmime-filter-best.c
==============================================================================
--- trunk/gmime/gmime-filter-best.c (original)
+++ trunk/gmime/gmime-filter-best.c Sun Jun 1 21:26:09 2008
@@ -118,24 +118,25 @@
}
static void
-filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
- char **out, size_t *outlen, size_t *outprespace)
+filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
+ char **outbuf, size_t *outlen, size_t *outprespace)
{
GMimeFilterBest *best = (GMimeFilterBest *) filter;
register unsigned char *inptr, *inend;
+ register unsigned char c;
size_t left;
if (best->flags & GMIME_FILTER_BEST_CHARSET)
- g_mime_charset_step (&best->charset, in, len);
+ g_mime_charset_step (&best->charset, inbuf, inlen);
if (best->flags & GMIME_FILTER_BEST_ENCODING) {
- best->total += len;
+ best->total += inlen;
- inptr = (unsigned char *) in;
- inend = inptr + len;
+ inptr = (unsigned char *) inbuf;
+ inend = inptr + inlen;
while (inptr < inend) {
- register unsigned char c = '\0';
+ c = 0;
if (best->midline) {
while (inptr < inend && (c = *inptr++) != '\n') {
@@ -151,9 +152,9 @@
}
if (c == '\n') {
+ best->maxline = MAX (best->maxline, best->linelen);
best->startline = TRUE;
best->midline = FALSE;
- best->maxline = MAX (best->maxline, best->linelen);
}
}
@@ -177,7 +178,6 @@
} else {
if (!strncmp ((char *) inptr, "From ", 5)) {
best->hadfrom = TRUE;
-
inptr += 5;
}
}
@@ -188,9 +188,9 @@
}
}
- *out = in;
- *outlen = len;
*outprespace = prespace;
+ *outlen = inlen;
+ *outbuf = inbuf;
}
static void
@@ -240,7 +240,7 @@
* Returns: a new best filter with flags @flags.
**/
GMimeFilter *
-g_mime_filter_best_new (unsigned int flags)
+g_mime_filter_best_new (GMimeFilterBestFlags flags)
{
GMimeFilterBest *new;
Modified: trunk/gmime/gmime-filter-best.h
==============================================================================
--- trunk/gmime/gmime-filter-best.h (original)
+++ trunk/gmime/gmime-filter-best.h Sun Jun 1 21:26:09 2008
@@ -39,11 +39,31 @@
typedef struct _GMimeFilterBest GMimeFilterBest;
typedef struct _GMimeFilterBestClass GMimeFilterBestClass;
-enum {
- GMIME_FILTER_BEST_CHARSET = (1 << 0),
- GMIME_FILTER_BEST_ENCODING = (1 << 1)
-};
+/**
+ * GMimeFilterBestFlags:
+ * @GMIME_FILTER_BEST_CHARSET: Enable best-charset detection.
+ * @GMIME_FILTER_BEST_ENCODING: Enable best-encoding detection.
+ *
+ * Bit flags to enable charset and/or encoding scanning to make
+ * educated guesses as to what the best charset and/or encodings to
+ * use for the content passed through the filter.
+ **/
+typedef enum {
+ GMIME_FILTER_BEST_CHARSET = (1 << 0),
+ GMIME_FILTER_BEST_ENCODING = (1 << 1)
+} GMimeFilterBestFlags;
+
+/**
+ * GMimeBestEncoding:
+ * @GMIME_BEST_ENCODING_7BIT: The stream data must fit within the 7bit ASCII range.
+ * @GMIME_BEST_ENCODING_8BIT: The stream data may have bytes with the high bit set, but no null bytes.
+ * @GMIME_BEST_ENCODING_BINARY: The stream may contain any binary data.
+ *
+ * Used with g_mime_filter_best_encoding() as the 'required'
+ * argument. These values provide a means of letting the filter know
+ * what the encoding requirements are for the stream.
+ **/
typedef enum {
GMIME_BEST_ENCODING_7BIT,
GMIME_BEST_ENCODING_8BIT,
@@ -53,7 +73,7 @@
struct _GMimeFilterBest {
GMimeFilter parent_object;
- unsigned int flags;
+ GMimeFilterBestFlags flags;
/* for best charset detection */
GMimeCharset charset;
@@ -82,7 +102,7 @@
GType g_mime_filter_best_get_type (void);
-GMimeFilter *g_mime_filter_best_new (unsigned int flags);
+GMimeFilter *g_mime_filter_best_new (GMimeFilterBestFlags flags);
const char *g_mime_filter_best_charset (GMimeFilterBest *best);
Modified: trunk/gmime/gmime-filter-crlf.c
==============================================================================
--- trunk/gmime/gmime-filter-crlf.c (original)
+++ trunk/gmime/gmime-filter-crlf.c Sun Jun 1 21:26:09 2008
@@ -111,26 +111,20 @@
{
GMimeFilterCRLF *crlf = (GMimeFilterCRLF *) filter;
- return g_mime_filter_crlf_new (crlf->direction, crlf->mode);
+ return g_mime_filter_crlf_new (crlf->encode, crlf->dots);
}
static void
-filter_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
- char **out, size_t *outlen, size_t *outprespace)
+filter_filter (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
+ char **outbuf, size_t *outlen, size_t *outprespace)
{
GMimeFilterCRLF *crlf = (GMimeFilterCRLF *) filter;
- register const char *inptr;
- const char *inend;
- gboolean do_dots;
+ register const char *inptr = inbuf;
+ const char *inend = inbuf + inlen;
char *outptr;
- do_dots = crlf->mode == GMIME_FILTER_CRLF_MODE_CRLF_DOTS;
-
- inptr = in;
- inend = in + len;
-
- if (crlf->direction == GMIME_FILTER_CRLF_ENCODE) {
- g_mime_filter_set_size (filter, 3 * len, FALSE);
+ if (crlf->encode) {
+ g_mime_filter_set_size (filter, 3 * inlen, FALSE);
outptr = filter->outbuf;
while (inptr < inend) {
@@ -142,7 +136,7 @@
*outptr++ = '\r';
crlf->saw_cr = FALSE;
} else {
- if (do_dots && *inptr == '.' && crlf->saw_lf)
+ if (crlf->dots && *inptr == '.' && crlf->saw_lf)
*outptr++ = '.';
crlf->saw_cr = FALSE;
@@ -152,7 +146,7 @@
*outptr++ = *inptr++;
}
} else {
- g_mime_filter_set_size (filter, len + 1, FALSE);
+ g_mime_filter_set_size (filter, inlen + 1, FALSE);
outptr = filter->outbuf;
while (inptr < inend) {
@@ -173,7 +167,7 @@
*outptr++ = *inptr;
}
- if (do_dots && *inptr == '.') {
+ if (crlf->dots && *inptr == '.') {
if (crlf->saw_lf) {
crlf->saw_dot = TRUE;
crlf->saw_lf = FALSE;
@@ -189,17 +183,17 @@
}
}
- *out = filter->outbuf;
*outlen = outptr - filter->outbuf;
*outprespace = filter->outpre;
+ *outbuf = filter->outbuf;
}
static void
-filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
- char **out, size_t *outlen, size_t *outprespace)
+filter_complete (GMimeFilter *filter, char *inbuf, size_t inlen, size_t prespace,
+ char **outbuf, size_t *outlen, size_t *outprespace)
{
- if (in && len)
- filter_filter (filter, in, len, prespace, out, outlen, outprespace);
+ if (inbuf && inlen)
+ filter_filter (filter, inbuf, inlen, prespace, outbuf, outlen, outprespace);
}
static void
@@ -215,21 +209,32 @@
/**
* g_mime_filter_crlf_new:
- * @direction: encode direction
- * @mode: crlf or crlf & dot mode
+ * @encode: %TRUE if the filter should encode or %FALSE otherwise
+ * @dots: encode/decode dots (as for SMTP)
+ *
+ * Creates a new #GMimeFilterCRLF filter.
+ *
+ * If @encode is %TRUE, then lone line-feeds ('\n') will be 'encoded'
+ * into the canonical CRLF end-of-line sequence ("\r\n") otherwise
+ * CRLF sequences will be 'decoded' into the UNIX line-ending form
+ * ('\n').
*
- * Creates a new GMimeFilterCRLF filter.
+ * The @dots parameter tells the filter whether or not it should
+ * encode or decode lines beginning with a dot ('.'). If both @encode
+ * and @dots are %TRUE, then a '.' at the beginning of a line will be
+ * 'encoded' into "..". If @encode is %FALSE, then ".." at the
+ * beginning of a line will be decoded into a single '.'.
*
- * Returns: a new crlf(/dot) filter.
+ * Returns: a new #GMimeFilterCRLF filter.
**/
GMimeFilter *
-g_mime_filter_crlf_new (GMimeFilterCRLFDirection direction, GMimeFilterCRLFMode mode)
+g_mime_filter_crlf_new (gboolean encode, gboolean dots)
{
GMimeFilterCRLF *new;
new = g_object_new (GMIME_TYPE_FILTER_CRLF, NULL);
- new->direction = direction;
- new->mode = mode;
+ new->encode = encode;
+ new->dots = dots;
return (GMimeFilter *) new;
}
Modified: trunk/gmime/gmime-filter-crlf.h
==============================================================================
--- trunk/gmime/gmime-filter-crlf.h (original)
+++ trunk/gmime/gmime-filter-crlf.h Sun Jun 1 21:26:09 2008
@@ -36,38 +36,12 @@
typedef struct _GMimeFilterCRLF GMimeFilterCRLF;
typedef struct _GMimeFilterCRLFClass GMimeFilterCRLFClass;
-
-/**
- * GMimeFilterCRLFDirection:
- * @GMIME_FILTER_CRLF_ENCODE: Convert from Unix line endings to CRLF.
- * @GMIME_FILTER_CRLF_DECODE: Convert from CRLF to Unix line endings.
- *
- * The direction in which the CRLF filter should convert.
- **/
-typedef enum {
- GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_DECODE
-} GMimeFilterCRLFDirection;
-
-
-/**
- * GMimeFilterCRLFMode:
- * @GMIME_FILTER_CRLF_MODE_CRLF_DOTS: Escape lines beginning with a '.'
- * @GMIME_FILTER_CRLF_MODE_CRLF_ONLY: Do only LF->CRLF conversion
- *
- * The mode for the #GMimeFilterCRLF filter.
- **/
-typedef enum {
- GMIME_FILTER_CRLF_MODE_CRLF_DOTS,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY
-} GMimeFilterCRLFMode;
-
-
struct _GMimeFilterCRLF {
GMimeFilter parent_object;
- GMimeFilterCRLFDirection direction;
- GMimeFilterCRLFMode mode;
+ gboolean encode;
+ gboolean dots;
+
gboolean saw_cr;
gboolean saw_lf;
gboolean saw_dot;
@@ -81,7 +55,7 @@
GType g_mime_filter_crlf_get_type (void);
-GMimeFilter *g_mime_filter_crlf_new (GMimeFilterCRLFDirection direction, GMimeFilterCRLFMode mode);
+GMimeFilter *g_mime_filter_crlf_new (gboolean encode, gboolean dots);
G_END_DECLS
Modified: trunk/gmime/gmime-multipart-encrypted.c
==============================================================================
--- trunk/gmime/gmime-multipart-encrypted.c (original)
+++ trunk/gmime/gmime-multipart-encrypted.c Sun Jun 1 21:26:09 2008
@@ -260,8 +260,7 @@
stream = g_mime_stream_mem_new ();
filtered_stream = g_mime_stream_filter_new (stream);
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
@@ -405,8 +404,7 @@
stream = g_mime_stream_mem_new ();
filtered_stream = g_mime_stream_filter_new (stream);
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_DECODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlf_filter = g_mime_filter_crlf_new (FALSE, FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
Modified: trunk/gmime/gmime-multipart-signed.c
==============================================================================
--- trunk/gmime/gmime-multipart-signed.c (original)
+++ trunk/gmime/gmime-multipart-signed.c Sun Jun 1 21:26:09 2008
@@ -327,8 +327,7 @@
/* Note: see rfc2015 or rfc3156, section 5.1 */
filtered_stream = g_mime_stream_filter_new (stream);
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
@@ -460,8 +459,7 @@
filtered_stream = g_mime_stream_filter_new (stream);
/* Note: see rfc2015 or rfc3156, section 5.1 */
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE);
g_mime_stream_filter_add (GMIME_STREAM_FILTER (filtered_stream), crlf_filter);
g_object_unref (crlf_filter);
Modified: trunk/gmime/gmime-part.c
==============================================================================
--- trunk/gmime/gmime-part.c (original)
+++ trunk/gmime/gmime-part.c Sun Jun 1 21:26:09 2008
@@ -603,9 +603,7 @@
if (g_mime_content_type_is_type (content_type, "text", "*")) {
GMimeFilter *crlf_filter;
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
-
+ crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE);
g_mime_stream_filter_add (filtered_stream, crlf_filter);
g_object_unref (crlf_filter);
}
@@ -668,9 +666,7 @@
if (g_mime_content_type_is_type (content_type, "text", "*")) {
GMimeFilter *crlf_filter;
- crlf_filter = g_mime_filter_crlf_new (GMIME_FILTER_CRLF_ENCODE,
- GMIME_FILTER_CRLF_MODE_CRLF_ONLY);
-
+ crlf_filter = g_mime_filter_crlf_new (TRUE, FALSE);
g_mime_stream_filter_add (filtered_stream, crlf_filter);
g_object_unref (crlf_filter);
}
Modified: trunk/mono/gmime-api.raw
==============================================================================
--- trunk/mono/gmime-api.raw (original)
+++ trunk/mono/gmime-api.raw Sun Jun 1 21:26:09 2008
@@ -34,13 +34,9 @@
<member cname="GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE" name="Quotedprintable" />
<member cname="GMIME_CONTENT_ENCODING_UUENCODE" name="Uuencode" />
</enum>
- <enum name="FilterCRLFDirection" cname="GMimeFilterCRLFDirection" type="enum">
- <member cname="GMIME_FILTER_CRLF_ENCODE" name="Encode" />
- <member cname="GMIME_FILTER_CRLF_DECODE" name="Decode" />
- </enum>
- <enum name="FilterCRLFMode" cname="GMimeFilterCRLFMode" type="enum">
- <member cname="GMIME_FILTER_CRLF_MODE_CRLF_DOTS" name="Dots" />
- <member cname="GMIME_FILTER_CRLF_MODE_CRLF_ONLY" name="Only" />
+ <enum name="FilterBestFlags" cname="GMimeFilterBestFlags" type="flags">
+ <member cname="GMIME_FILTER_BEST_CHARSET" name="Charset" value="1 << 0" />
+ <member cname="GMIME_FILTER_BEST_ENCODING" name="Encoding" value="1 << 1" />
</enum>
<enum name="FilterFromMode" cname="GMimeFilterFromMode" type="enum">
<member cname="GMIME_FILTER_FROM_MODE_DEFAULT" name="Default" />
@@ -432,7 +428,7 @@
</constructor>
</object>
<object name="FilterBest" cname="GMimeFilterBest" parent="GMimeFilter">
- <field name="Flags" cname="flags" type="unsigned int" />
+ <field name="Flags" cname="flags" type="GMimeFilterBestFlags" />
<field name="Charset" cname="charset" type="GMimeCharset" />
<field name="Count0" cname="count0" type="unsigned int" />
<field name="Count8" cname="count8" type="unsigned int" />
@@ -458,7 +454,7 @@
</method>
<constructor cname="g_mime_filter_best_new">
<parameters>
- <parameter type="unsigned-int" name="flags" />
+ <parameter type="GMimeFilterBestFlags" name="flags" />
</parameters>
</constructor>
</object>
@@ -477,8 +473,8 @@
</constructor>
</object>
<object name="FilterCRLF" cname="GMimeFilterCRLF" parent="GMimeFilter">
- <field name="Direction" cname="direction" type="GMimeFilterCRLFDirection" />
- <field name="Mode" cname="mode" type="GMimeFilterCRLFMode" />
+ <field name="Encode" cname="encode" type="gboolean" />
+ <field name="Dots" cname="dots" type="gboolean" />
<field name="SawCr" cname="saw_cr" type="gboolean" />
<field name="SawLf" cname="saw_lf" type="gboolean" />
<field name="SawDot" cname="saw_dot" type="gboolean" />
@@ -487,8 +483,8 @@
</method>
<constructor cname="g_mime_filter_crlf_new">
<parameters>
- <parameter type="GMimeFilterCRLFDirection" name="direction" />
- <parameter type="GMimeFilterCRLFMode" name="mode" />
+ <parameter type="gboolean" name="encode" />
+ <parameter type="gboolean" name="dots" />
</parameters>
</constructor>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]