Skip to content

Commit df1151b

Browse files
committed
Revert g_mime_parser_options_set_warning_callback() and added _full() version
Fixes issue #172
1 parent 846bf3e commit df1151b

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

examples/msgcheck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ check_msg_file (const gchar *filename)
110110
parser = g_mime_parser_new ();
111111
g_mime_parser_init_with_stream (parser, stream);
112112
options = g_mime_parser_options_new ();
113-
g_mime_parser_options_set_warning_callback (options, parser_issue, NULL, NULL);
113+
g_mime_parser_options_set_warning_callback (options, parser_issue, NULL);
114114
message = g_mime_parser_construct_message (parser, options);
115115
g_mime_parser_options_free (options);
116116
g_object_unref (parser);

gmime/gmime-parser-options.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ g_mime_parser_options_shutdown (void)
7070
if (default_options == NULL)
7171
return;
7272

73-
if (default_options->notify) {
74-
default_options->notify(default_options->warning_user_data);
75-
}
73+
if (default_options->notify)
74+
default_options->notify (default_options->warning_user_data);
75+
7676
g_strfreev (default_options->charsets);
7777
g_slice_free (GMimeParserOptions, default_options);
7878
default_options = NULL;
@@ -193,9 +193,9 @@ g_mime_parser_options_free (GMimeParserOptions *options)
193193
g_return_if_fail (options != NULL);
194194

195195
if (options != default_options) {
196-
if (options->notify) {
197-
options->notify(options->warning_user_data);
198-
}
196+
if (options->notify)
197+
options->notify (options->warning_user_data);
198+
199199
g_strfreev (options->charsets);
200200
g_slice_free (GMimeParserOptions, options);
201201
}
@@ -450,18 +450,31 @@ g_mime_parser_options_get_warning_callback (GMimeParserOptions *options)
450450
* @options: a #GMimeParserOptions
451451
* @warning_cb: a #GMimeParserWarningFunc or %NULL to clear the callback
452452
* @user_data: data passed to the warning callback function
453+
*
454+
* Registers the callback function being called if the parser detects any issues.
455+
**/
456+
void
457+
g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data)
458+
{
459+
g_mime_parser_options_set_warning_callback_full (options, warning_cb, user_data, NULL);
460+
}
461+
462+
/**
463+
* g_mime_parser_options_set_warning_callback_full:
464+
* @options: a #GMimeParserOptions
465+
* @warning_cb: a #GMimeParserWarningFunc or %NULL to clear the callback
466+
* @user_data: data passed to the warning callback function
453467
* @notify: callback function ran on destruction
454468
*
455469
* Registers the callback function being called if the parser detects any issues.
456470
**/
457471
void
458-
g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify)
472+
g_mime_parser_options_set_warning_callback_full (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify)
459473
{
460474
g_return_if_fail (options != NULL);
461475

462-
if (options->notify) {
463-
options->notify(options->warning_user_data);
464-
}
476+
if (options->notify)
477+
options->notify (options->warning_user_data);
465478

466479
options->warning_cb = warning_cb;
467480
options->warning_user_data = user_data;

gmime/gmime-parser-options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ const char **g_mime_parser_options_get_fallback_charsets (GMimeParserOptions *op
128128
void g_mime_parser_options_set_fallback_charsets (GMimeParserOptions *options, const char **charsets);
129129

130130
GMimeParserWarningFunc g_mime_parser_options_get_warning_callback (GMimeParserOptions *options);
131-
void g_mime_parser_options_set_warning_callback (GMimeParserOptions *options,
132-
GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify);
131+
void g_mime_parser_options_set_warning_callback (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data);
132+
void g_mime_parser_options_set_warning_callback_full (GMimeParserOptions *options, GMimeParserWarningFunc warning_cb, gpointer user_data, GDestroyNotify notify);
133133

134134
G_END_DECLS
135135

0 commit comments

Comments
 (0)