[gmime: 3/6] Register GMimeParserOptions as a boxed type



commit 0f4725ea35f7dd22f2916057640582d402334af6
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Thu Mar 30 10:09:43 2017 -0400

    Register GMimeParserOptions as a boxed type

 gmime/gmime-header.c         |    6 +++---
 gmime/gmime-internal.h       |    1 -
 gmime/gmime-parser-options.c |    9 ++++++---
 gmime/gmime-parser-options.h |    8 ++++++++
 gmime/gmime-references.h     |    4 ----
 tests/test-mime.c            |    2 +-
 6 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gmime/gmime-header.c b/gmime/gmime-header.c
index 0952e3e..eaa6ca5 100644
--- a/gmime/gmime-header.c
+++ b/gmime/gmime-header.c
@@ -555,7 +555,7 @@ g_mime_header_format_references (GMimeHeader *header, GMimeFormatOptions *option
        /* Note: we don't want to break in the middle of msgid tokens as
           it seems to break a lot of clients (and servers) */
        newline = g_mime_format_options_get_newline (options);
-       refs = g_mime_references_parse (value);
+       refs = g_mime_references_parse (header->options, value);
        str = g_string_new (header->raw_name);
        g_string_append_c (str, ':');
        cur = n = str->len;
@@ -1042,7 +1042,7 @@ g_mime_header_list_new (GMimeParserOptions *options)
        g_return_val_if_fail (options != NULL, NULL);
        
        headers = g_object_newv (GMIME_TYPE_HEADER_LIST, 0, NULL);
-       headers->options = _g_mime_parser_options_clone (options);
+       headers->options = g_mime_parser_options_clone (options);
        
        return headers;
 }
@@ -1090,7 +1090,7 @@ void
 _g_mime_header_list_set_options (GMimeHeaderList *headers, GMimeParserOptions *options)
 {
        g_mime_parser_options_free (headers->options);
-       headers->options = _g_mime_parser_options_clone (options);
+       headers->options = g_mime_parser_options_clone (options);
 }
 
 
diff --git a/gmime/gmime-internal.h b/gmime/gmime-internal.h
index b1ad5d6..61334df 100644
--- a/gmime/gmime-internal.h
+++ b/gmime/gmime-internal.h
@@ -50,7 +50,6 @@ G_GNUC_INTERNAL GMimeFormatOptions *_g_mime_format_options_clone (GMimeFormatOpt
 /* GMimeParserOptions */
 G_GNUC_INTERNAL void g_mime_parser_options_init (void);
 G_GNUC_INTERNAL void g_mime_parser_options_shutdown (void);
-G_GNUC_INTERNAL GMimeParserOptions *_g_mime_parser_options_clone (GMimeParserOptions *options);
 
 /* GMimeHeader */
 G_GNUC_INTERNAL void _g_mime_header_set_raw_value (GMimeHeader *header, const char *raw_value);
diff --git a/gmime/gmime-parser-options.c b/gmime/gmime-parser-options.c
index 73cc0cb..627ce9b 100644
--- a/gmime/gmime-parser-options.c
+++ b/gmime/gmime-parser-options.c
@@ -27,6 +27,7 @@
 
 #include "gmime-parser-options.h"
 
+
 static char *default_charsets[3] = { "utf-8", "iso-8859-1", NULL };
 
 static GMimeParserOptions *default_options = NULL;
@@ -43,6 +44,8 @@ static GMimeParserOptions *default_options = NULL;
  **/
 
 
+G_DEFINE_BOXED_TYPE (GMimeParserOptions, g_mime_parser_options, g_mime_parser_options_clone, 
g_mime_parser_options_free);
+
 void
 g_mime_parser_options_init (void)
 {
@@ -103,15 +106,15 @@ g_mime_parser_options_new (void)
 
 
 /**
- * _g_mime_parser_options_clone:
+ * g_mime_parser_options_clone:
  * @options: a #GMimeParserOptions
  *
  * Clones a #GMimeParserOptions.
  *
- * Returns: a newly allocated #GMimeParserOptions.
+ * Returns: (transfer full): a newly allocated #GMimeParserOptions.
  **/
 GMimeParserOptions *
-_g_mime_parser_options_clone (GMimeParserOptions *options)
+g_mime_parser_options_clone (GMimeParserOptions *options)
 {
        GMimeParserOptions *clone;
        guint i, n = 0;
diff --git a/gmime/gmime-parser-options.h b/gmime/gmime-parser-options.h
index 8633495..6346a29 100644
--- a/gmime/gmime-parser-options.h
+++ b/gmime/gmime-parser-options.h
@@ -23,9 +23,12 @@
 #define __GMIME_PARSER_OPTIONS_H__
 
 #include <glib.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
+#define GMIME_TYPE_PARSER_OPTIONS (gmime_parser_options_get_type ())
+
 /**
  * GMimeRfcComplianceMode:
  * @GMIME_RFC_COMPLIANCE_LOOSE: Attempt to be much more liberal accepting broken and/or invalid formatting.
@@ -54,11 +57,16 @@ typedef struct {
        char **charsets;
 } GMimeParserOptions;
 
+
+GType g_mime_parser_options_get_type (void) G_GNUC_CONST;
+
 GMimeParserOptions *g_mime_parser_options_get_default (void);
 
 GMimeParserOptions *g_mime_parser_options_new (void);
 void g_mime_parser_options_free (GMimeParserOptions *options);
 
+GMimeParserOptions *g_mime_parser_options_clone (GMimeParserOptions *options);
+
 GMimeRfcComplianceMode g_mime_parser_options_get_address_compliance_mode (GMimeParserOptions *options);
 void g_mime_parser_options_set_address_compliance_mode (GMimeParserOptions *options, GMimeRfcComplianceMode 
mode);
 
diff --git a/gmime/gmime-references.h b/gmime/gmime-references.h
index 7bb3a8e..e625f4e 100644
--- a/gmime/gmime-references.h
+++ b/gmime/gmime-references.h
@@ -22,12 +22,8 @@
 #ifndef __GMIME_REFERENCES_H__
 #define __GMIME_REFERENCES_H__
 
-#include <glib.h>
-#include <glib-object.h>
-
 #include <gmime/gmime-parser-options.h>
 
-
 G_BEGIN_DECLS
 
 #define GMIME_TYPE_REFERENCES (gmime_references_get_type ())
diff --git a/tests/test-mime.c b/tests/test-mime.c
index bc73ea2..246cd0e 100644
--- a/tests/test-mime.c
+++ b/tests/test-mime.c
@@ -751,7 +751,7 @@ test_references (GMimeParserOptions *options)
        for (i = 0; i < G_N_ELEMENTS (references); i++) {
                testsuite_check ("references[%u]", i);
                try {
-                       if (!(refs = g_mime_references_parse (references[i].input)))
+                       if (!(refs = g_mime_references_parse (options, references[i].input)))
                                throw (exception_new ("failed to parse references"));
                        
                        if (g_mime_references_length (refs) != references[i].count)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]