Hello community, here is the log from the commit of package jsonrpc-glib for openSUSE:Factory checked in at 2018-10-17 08:23:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/jsonrpc-glib (Old) and /work/SRC/openSUSE:Factory/.jsonrpc-glib.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "jsonrpc-glib" Wed Oct 17 08:23:08 2018 rev:6 rq:641255 version:3.30.1 Changes: -------- --- /work/SRC/openSUSE:Factory/jsonrpc-glib/jsonrpc-glib.changes 2018-06-22 13:28:34.793738834 +0200 +++ /work/SRC/openSUSE:Factory/.jsonrpc-glib.new/jsonrpc-glib.changes 2018-10-17 08:24:54.638689273 +0200 @@ -1,0 +2,44 @@ +Thu Oct 11 08:50:53 UTC 2018 - [email protected] + +- Update to version 3.30.1: + + When --buildtype=release is used, assertion checks are disabled + and -Bsymbolic is used. + +------------------------------------------------------------------- +Wed Sep 12 20:35:10 UTC 2018 - [email protected] + +- Update to version 3.30.0: + + No change, only bump version. + +------------------------------------------------------------------- +Fri Aug 17 01:16:44 UTC 2018 - [email protected] + +- Update to version 3.29.91: + + Fix of double-free in generated vala bindings. + + Floating reference fixes for some gvariants. + + Use g_bytes_new_take() to simplify memory tracking. + + Some variants are now unwrapped to simplify usage by consumers. + + Unit tests now disable SIGPIPE. + + test-client was removed as it was dead code. + +------------------------------------------------------------------- +Tue Jul 24 12:52:09 UTC 2018 - [email protected] + +- Update to version 3.29.4: + + More lenient testing for transient errors. + + Increased compiler warnings when building on GCC. + + Vala vapi generation improvements. + +------------------------------------------------------------------- +Thu Jun 21 02:27:25 UTC 2018 - [email protected] + +- Update to version 3.29.3: + + Various introspection fixes. + + Add JsonrpcServer::client-closed. + + Emit JsonrpcClient::failed upon panic. + + Helpers for strv message building and parsing. + + Support for boxing/unboxing a{sv} variants. + + A new variant for calling a remote method and get message id. + + Fixes for an invalid type propagation. + +------------------------------------------------------------------- Old: ---- jsonrpc-glib-3.28.1.tar.xz New: ---- jsonrpc-glib-3.30.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ jsonrpc-glib.spec ++++++ --- /var/tmp/diff_new_pack.0mQank/_old 2018-10-17 08:24:55.094688909 +0200 +++ /var/tmp/diff_new_pack.0mQank/_new 2018-10-17 08:24:55.094688909 +0200 @@ -12,20 +12,19 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define sover 1_0-1 Name: jsonrpc-glib -Version: 3.28.1 +Version: 3.30.1 Release: 0 Summary: Library to communicate with JSON-RPC based peers License: LGPL-2.1-or-later Group: Development/Libraries/GNOME URL: https://gitlab.gnome.org/GNOME/jsonrpc-glib -Source: http://download.gnome.org/sources/jsonrpc-glib/3.28/%{name}-%{version}.tar.xz - +Source0: https://download.gnome.org/sources/jsonrpc-glib/3.30/%{name}-%{version}.tar.xz BuildRequires: gtk-doc BuildRequires: meson >= 0.40.1 BuildRequires: pkgconfig ++++++ jsonrpc-glib-3.28.1.tar.xz -> jsonrpc-glib-3.30.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/NEWS new/jsonrpc-glib-3.30.1/NEWS --- old/jsonrpc-glib-3.28.1/NEWS 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/NEWS 2018-10-10 20:57:40.000000000 +0200 @@ -1,11 +1,56 @@ ============== -Version 3.28.1 +Version 3.30.1 ============== - • Fixes for invalid type propagation - • Fixes for gobject introspection - • Improved busy tracking in streams - • Ensure JsonrpcClient::failed is emitted in panic +Changes in this release: + + • When --buildtype=release is used, assertion checks are disabled + and -Bsymbolic is used. + +============== +Version 3.30.0 +============== + +No changes in this release since our beta 3.29.91. + +=============== +Version 3.29.91 +=============== + +Changes in this release: + + • Fix of double-free in generated vala bindings + • Floating reference fixes for some gvariants + • Use g_bytes_new_take() to simplify memory tracking + • Some variants are now unwrapped to simplify usage by consumers. + • Unit tests now disable SIGPIPE + • test-client was removed as it was dead code + +============== +Version 3.29.4 +============== + +Changes in this release: + + • More lenient testing for transient errors + • Increased compiler warnings when building on GCC + • Vala vapi generation improvements + +============== +Version 3.29.3 +============== + +Changes in this release: + + • Various introspection fixes + • Add JsonrpcServer::client-closed + • Emit JsonrpcClient::failed upon panic + • Helpers for strv message building and parsing + • Output stream now tracks busy status + • Support for boxing/unboxing a{sv} variants + • Version ABI macros were added + • A new variant for calling a remote method and get message id + • Fixes for an invalid type propagation ============== Version 3.28.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/meson.build new/jsonrpc-glib-3.30.1/meson.build --- old/jsonrpc-glib-3.28.1/meson.build 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/meson.build 2018-10-10 20:57:40.000000000 +0200 @@ -1,5 +1,5 @@ project('jsonrpc-glib', 'c', - version: '3.28.1', + version: '3.30.1', license: 'LGPLv2.1+', meson_version: '>= 0.40.1', default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ], @@ -42,33 +42,56 @@ test_c_args = [ '-Wcast-align', '-Wdeclaration-after-statement', - '-Wformat-nonliteral', - '-Wformat-security', - '-Wmissing-include-dirs', - '-Wnested-externs', - '-Wno-missing-field-initializers', - '-Wno-sign-compare', - '-Wno-unused-parameter', - '-Wpointer-arith', - '-Wredundant-decls', - '-Wswitch-default', - '-Wswitch-enum', - '-Wuninitialized', - ['-Werror=format-security', '-Werror=format=2' ], + '-Werror=address', + '-Werror=array-bounds', '-Werror=empty-body', + '-Werror=implicit', '-Werror=implicit-function-declaration', '-Werror=incompatible-pointer-types', - '-Werror=pointer-arith', '-Werror=init-self', '-Werror=int-conversion', + '-Werror=int-to-pointer-cast', + '-Werror=main', '-Werror=misleading-indentation', + '-Werror=missing-braces', '-Werror=missing-include-dirs', + '-Werror=nonnull', '-Werror=overflow', '-Werror=parenthesis', + '-Werror=pointer-arith', + '-Werror=pointer-to-int-cast', + '-Werror=redundant-decls', '-Werror=return-type', + '-Werror=sequence-point', '-Werror=shadow', '-Werror=strict-prototypes', + '-Werror=trigraphs', '-Werror=undef', + '-Werror=write-strings', + '-Wformat-nonliteral', + ['-Werror=format-security', '-Werror=format=2' ], + '-Wignored-qualifiers', + '-Wimplicit-function-declaration', + '-Wlogical-op', + # '-Wmissing-declarations', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', + '-Wnested-externs', + '-Wno-cast-function-type', + '-Wno-missing-field-initializers', + '-Wno-sign-compare', + '-Wno-unused-parameter', + '-Wold-style-definition', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wstrict-prototypes', + '-Wswitch-default', + '-Wswitch-enum', + '-Wundef', + '-Wuninitialized', + '-Wunused', + '-fno-strict-aliasing', ] if get_option('buildtype') != 'plain' test_c_args += '-fstack-protector-strong' @@ -102,6 +125,28 @@ endif endif +release_args = [] +global_link_args = [] +test_link_args = [ + '-Wl,-z,relro', + '-Wl,-z,now', +] +if not get_option('buildtype').startswith('debug') + # TODO: Maybe reuse 'b_ndebug' option + add_global_arguments(['-DG_DISABLE_CAST_CHECKS'], language: 'c') + release_args += [ '-DG_DISABLE_ASSERT' ] + test_link_args += [ + '-Wl,-Bsymbolic', + '-fno-plt', + ] +endif +foreach link_arg: test_link_args + if cc.links('int main () { return 0; }', name: link_arg, args: link_arg) + global_link_args += link_arg + endif +endforeach +add_project_link_arguments(global_link_args, language: 'c') + configure_file( output: 'config.h', configuration: config_h, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/Jsonrpc-1.0-custom.vala new/jsonrpc-glib-3.30.1/src/Jsonrpc-1.0-custom.vala --- old/jsonrpc-glib-3.28.1/src/Jsonrpc-1.0-custom.vala 1970-01-01 01:00:00.000000000 +0100 +++ new/jsonrpc-glib-3.30.1/src/Jsonrpc-1.0-custom.vala 2018-10-10 20:57:40.000000000 +0200 @@ -0,0 +1,64 @@ +namespace Jsonrpc { + namespace Message { + public struct GetBoolean { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_BOOLEAN")] + public static void* create (ref bool val); + } + public struct GetDict { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_DICT")] + public static void* create (ref GLib.VariantDict val); + } + public struct GetDouble { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_DOUBLE")] + public static void* create (ref double val); + } + public struct GetInt32 { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_INT32")] + public static void* create (ref int32 val); + } + public struct GetInt64 { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_INT64")] + public static void* create (ref int64 val); + } + public struct GetIter { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_ITER")] + public static void* create (ref GLib.VariantIter val); + } + public struct GetString { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_STRING")] + public static void* create (ref unowned string val); + } + public struct GetStrv { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_STRV")] + public static void* create ([CCode (array_length = false)] ref string[] val); + } + public struct GetVariant { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_GET_VARIANT")] + public static void* create (ref GLib.Variant val); + } + public struct PutBoolean { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_BOOLEAN")] + public static void* create (bool val); + } + public struct PutDouble { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_DOUBLE")] + public static void* create (double val); + } + public struct PutInt32 { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_INT32")] + public static void* create (int32 val); + } + public struct PutInt64 { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_INT64")] + public static void* create (int64 val); + } + public struct PutString { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_STRING")] + public static void* create (string val); + } + public struct PutStrv { + [CCode (cheader_filename = "jsonrpc-glib.h", cname = "JSONRPC_MESSAGE_PUT_STRV")] + public static void* create ([CCode (array_length = false)] string[] val); + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/Jsonrpc-1.0.metadata new/jsonrpc-glib-3.30.1/src/Jsonrpc-1.0.metadata --- old/jsonrpc-glib-3.28.1/src/Jsonrpc-1.0.metadata 1970-01-01 01:00:00.000000000 +0100 +++ new/jsonrpc-glib-3.30.1/src/Jsonrpc-1.0.metadata 2018-10-10 20:57:40.000000000 +0200 @@ -0,0 +1,22 @@ +message_new parent="Jsonrpc.Message" name="new" skip=false +message_new_array parent="Jsonrpc.Message" name="new_array" skip=false +message_parse parent="Jsonrpc.Message" name="parse" skip=false +message_parse_array parent="Jsonrpc.Message" name="parse_array" skip=false +MessagePutString parent="Jsonrpc.Message" name="PutString" +MessagePutStrv parent="Jsonrpc.Message" name="PutStrv" + .val array=true +MessagePutInt64 parent="Jsonrpc.Message" name="PutInt64" +MessagePutInt32 parent="Jsonrpc.Message" name="PutInt32" +MessagePutDouble parent="Jsonrpc.Message" name="PutDouble" +MessagePutBoolean parent="Jsonrpc.Message" name="PutBoolean" +MessageGetVariant parent="Jsonrpc.Message" name="GetVariant" +MessageGetStrv parent="Jsonrpc.Message" name="GetStrv" + .valptr array=true +MessageGetString parent="Jsonrpc.Message" name="GetString" +MessageGetIter parent="Jsonrpc.Message" name="GetIter" +MessageGetInt64 parent="Jsonrpc.Message" name="GetInt64" +MessageGetInt32 parent="Jsonrpc.Message" name="GetInt32" +MessageGetDouble parent="Jsonrpc.Message" name="GetDouble" +MessageGetDict parent="Jsonrpc.Message" name="GetDict" +MessageGetBoolean parent="Jsonrpc.Message" name="GetBoolean" +Client.call_with_id_async finish_name="jsonrpc_client_call_finish" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-client.c new/jsonrpc-glib-3.30.1/src/jsonrpc-client.c --- old/jsonrpc-glib-3.28.1/src/jsonrpc-client.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-client.c 2018-10-10 20:57:40.000000000 +0200 @@ -671,7 +671,7 @@ JsonrpcClientPrivate *priv = jsonrpc_client_get_instance_private (self); g_autoptr(GVariant) message = NULL; g_autoptr(GError) error = NULL; - g_auto(GVariantDict) dict = {{{ 0 }}}; + g_autoptr(GVariantDict) dict = NULL; g_assert (JSONRPC_IS_INPUT_STREAM (stream)); g_assert (JSONRPC_IS_CLIENT (self)); @@ -708,14 +708,14 @@ return; } - g_variant_dict_init (&dict, message); + dict = g_variant_dict_new (message); /* * If the message is malformed, we'll also need to perform another read. * We do this to try to be relaxed against failures. That seems to be * the JSONRPC way, although I'm not sure I like the idea. */ - if (!is_jsonrpc_reply (&dict)) + if (dict == NULL || !is_jsonrpc_reply (dict)) { error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_INVALID_DATA, @@ -728,29 +728,29 @@ * If the response does not have an "id" field, then it is a "notification" * and we need to emit the "notificiation" signal. */ - if (is_jsonrpc_notification (&dict)) + if (is_jsonrpc_notification (dict)) { g_autoptr(GVariant) params = NULL; const gchar *method_name = NULL; - if (g_variant_dict_lookup (&dict, "method", "&s", &method_name)) + if (g_variant_dict_lookup (dict, "method", "&s", &method_name)) { GQuark detail = g_quark_try_string (method_name); - params = g_variant_dict_lookup_value (&dict, "params", NULL); + params = g_variant_dict_lookup_value (dict, "params", NULL); g_signal_emit (self, signals [NOTIFICATION], detail, method_name, params); } goto begin_next_read; } - if (is_jsonrpc_result (&dict)) + if (is_jsonrpc_result (dict)) { g_autoptr(GVariant) params = NULL; gint64 id = -1; GTask *task; - if (!g_variant_dict_lookup (&dict, "id", "x", &id) || + if (!g_variant_dict_lookup (dict, "id", "x", &id) || NULL == (task = g_hash_table_lookup (priv->invocations, GINT_TO_POINTER (id)))) { error = g_error_new_literal (G_IO_ERROR, @@ -760,7 +760,7 @@ return; } - if (NULL != (params = g_variant_dict_lookup_value (&dict, "result", NULL))) + if (NULL != (params = g_variant_dict_lookup_value (dict, "result", NULL))) g_task_return_pointer (task, g_steal_pointer (¶ms), (GDestroyNotify)g_variant_unref); else g_task_return_pointer (task, NULL, NULL); @@ -771,7 +771,7 @@ /* * If this is a method call, emit the handle-call signal. */ - if (is_jsonrpc_call (&dict)) + if (is_jsonrpc_call (dict)) { g_autoptr(GVariant) id = NULL; g_autoptr(GVariant) params = NULL; @@ -779,8 +779,8 @@ gboolean ret = FALSE; GQuark detail; - if (!g_variant_dict_lookup (&dict, "method", "&s", &method_name) || - NULL == (id = g_variant_dict_lookup_value (&dict, "id", NULL))) + if (!g_variant_dict_lookup (dict, "method", "&s", &method_name) || + NULL == (id = g_variant_dict_lookup_value (dict, "id", NULL))) { error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_INVALID_DATA, @@ -789,7 +789,7 @@ return; } - params = g_variant_dict_lookup_value (&dict, "params", NULL); + params = g_variant_dict_lookup_value (dict, "params", NULL); g_assert (method_name != NULL); g_assert (id != NULL); @@ -810,18 +810,18 @@ * we need to dispatch it now. */ - if (g_variant_dict_contains (&dict, "id") && - g_variant_dict_contains (&dict, "error")) + if (g_variant_dict_contains (dict, "id") && + g_variant_dict_contains (dict, "error")) { g_autoptr(GVariant) error_variant = NULL; g_autofree gchar *errstr = NULL; gint64 id = -1; - error_variant = g_variant_dict_lookup_value (&dict, "error", NULL); + error_variant = g_variant_dict_lookup_value (dict, "error", NULL); errstr = g_variant_print (error_variant, FALSE); error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, errstr); - if (g_variant_dict_lookup (&dict, "id", "x", &id)) + if (g_variant_dict_lookup (dict, "id", "x", &id)) { GTask *task = g_hash_table_lookup (priv->invocations, GINT_TO_POINTER (id)); @@ -879,7 +879,7 @@ * @method: the name of the method to call * @params: (transfer none) (nullable): A #GVariant of parameters or %NULL * @cancellable: (nullable): A #GCancellable or %NULL - * @return_value: (nullable) (out): A location for a #GVariant. + * @return_value: (nullable) (out): A location for a #GVariant * * Synchronously calls @method with @params on the remote peer. * @@ -935,10 +935,12 @@ } /** - * jsonrpc_client_call_async: + * jsonrpc_client_call_with_id_async: * @self: A #JsonrpcClient * @method: the name of the method to call * @params: (transfer none) (nullable): A #GVariant of parameters or %NULL + * @id: (out) (transfer full) (optional): a location for a #GVariant + * describing the identifier used for the method call, or %NULL. * @cancellable: (nullable): A #GCancellable or %NULL * @callback: a callback to executed upon completion * @user_data: user data for @callback @@ -949,32 +951,49 @@ * call jsonrpc_client_call_finish() to complete the request and release * any memory held. * + * This function is similar to jsonrpc_client_call_async() except that + * it allows the caller to get the id of the command which might be useful + * in systems where you can cancel the operation (such as the Language + * Server Protocol). + * * If @params is floating, the floating reference is consumed. * - * Since: 3.26 + * Since: 3.30 */ void -jsonrpc_client_call_async (JsonrpcClient *self, - const gchar *method, - GVariant *params, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +jsonrpc_client_call_with_id_async (JsonrpcClient *self, + const gchar *method, + GVariant *params, + GVariant **id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { JsonrpcClientPrivate *priv = jsonrpc_client_get_instance_private (self); g_autoptr(GVariant) message = NULL; + g_autoptr(GVariant) sunk_variant = NULL; g_autoptr(GTask) task = NULL; g_autoptr(GError) error = NULL; GVariantDict dict; - gint64 id; + gint64 idval; g_return_if_fail (JSONRPC_IS_CLIENT (self)); g_return_if_fail (method != NULL); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); + if (id != NULL) + *id = NULL; + task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, jsonrpc_client_call_async); + if (params == NULL) + params = g_variant_new_maybe (G_VARIANT_TYPE_VARIANT, NULL); + + /* If we got a floating reference, we should consume it */ + if (g_variant_is_floating (params)) + sunk_variant = g_variant_ref_sink (params); + if (!jsonrpc_client_check_ready (self, &error)) { g_task_return_error (task, g_steal_pointer (&error)); @@ -987,23 +1006,18 @@ self, G_CONNECT_SWAPPED); - id = ++priv->sequence; - - g_task_set_task_data (task, GINT_TO_POINTER (id), NULL); + idval = ++priv->sequence; - /* Use empty maybe type for NULL, and floating reference will - * be consumed by g_variant_dict_insert_value() below. */ - if (params == NULL) - params = g_variant_new_maybe (G_VARIANT_TYPE_VARIANT, NULL); + g_task_set_task_data (task, GINT_TO_POINTER (idval), NULL); g_variant_dict_init (&dict, NULL); g_variant_dict_insert (&dict, "jsonrpc", "s", "2.0"); - g_variant_dict_insert (&dict, "id", "x", id); + g_variant_dict_insert (&dict, "id", "x", idval); g_variant_dict_insert (&dict, "method", "s", method); g_variant_dict_insert_value (&dict, "params", params); message = g_variant_dict_end (&dict); - g_hash_table_insert (priv->invocations, GINT_TO_POINTER (id), g_object_ref (task)); + g_hash_table_insert (priv->invocations, GINT_TO_POINTER (idval), g_object_ref (task)); jsonrpc_output_stream_write_message_async (priv->output_stream, message, @@ -1013,6 +1027,39 @@ if (priv->is_first_call) jsonrpc_client_start_listening (self); + + if (id != NULL) + *id = g_variant_take_ref (g_variant_new_int64 (idval)); +} + +/** + * jsonrpc_client_call_async: + * @self: A #JsonrpcClient + * @method: the name of the method to call + * @params: (transfer none) (nullable): A #GVariant of parameters or %NULL + * @cancellable: (nullable): A #GCancellable or %NULL + * @callback: a callback to executed upon completion + * @user_data: user data for @callback + * + * Asynchronously calls @method with @params on the remote peer. + * + * Upon completion or failure, @callback is executed and it should + * call jsonrpc_client_call_finish() to complete the request and release + * any memory held. + * + * If @params is floating, the floating reference is consumed. + * + * Since: 3.26 + */ +void +jsonrpc_client_call_async (JsonrpcClient *self, + const gchar *method, + GVariant *params, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + jsonrpc_client_call_with_id_async (self, method, params, NULL, cancellable, callback, user_data); } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-client.h new/jsonrpc-glib-3.30.1/src/jsonrpc-client.h --- old/jsonrpc-glib-3.28.1/src/jsonrpc-client.h 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-client.h 2018-10-10 20:57:40.000000000 +0200 @@ -91,6 +91,14 @@ GCancellable *cancellable, GVariant **return_value, GError **error); +JSONRPC_AVAILABLE_IN_3_30 +void jsonrpc_client_call_with_id_async (JsonrpcClient *self, + const gchar *method, + GVariant *params, + GVariant **id, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); JSONRPC_AVAILABLE_IN_3_26 void jsonrpc_client_call_async (JsonrpcClient *self, const gchar *method, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-input-stream.c new/jsonrpc-glib-3.30.1/src/jsonrpc-input-stream.c --- old/jsonrpc-glib-3.28.1/src/jsonrpc-input-stream.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-input-stream.c 2018-10-10 20:57:40.000000000 +0200 @@ -122,14 +122,12 @@ if (state->use_gvariant) { - message = g_variant_new_from_data (state->gvariant_type ? state->gvariant_type - : G_VARIANT_TYPE_VARDICT, - state->buffer, - state->content_length, - FALSE, - g_free, - state->buffer); - state->buffer = NULL; + g_autoptr(GBytes) bytes = NULL; + + bytes = g_bytes_new_take (g_steal_pointer (&state->buffer), state->content_length); + message = g_variant_new_from_bytes (state->gvariant_type ? state->gvariant_type + : G_VARIANT_TYPE_VARDICT, + bytes, FALSE); if G_UNLIKELY (jsonrpc_input_stream_debug && state->use_gvariant) { @@ -146,6 +144,10 @@ g_assert (state->buffer == NULL); g_assert (message != NULL || error != NULL); + /* Don't let message be floating */ + if (message != NULL) + g_variant_take_ref (message); + if (error != NULL) g_task_return_error (task, g_steal_pointer (&error)); else @@ -319,7 +321,13 @@ ret = local_message != NULL; if (message != NULL) - *message = g_steal_pointer (&local_message); + { + /* Unbox the variant if it is in a wrapper */ + if (local_message && g_variant_is_of_type (local_message, G_VARIANT_TYPE_VARIANT)) + *message = g_variant_get_variant (local_message); + else + *message = g_steal_pointer (&local_message); + } return ret; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-message.c new/jsonrpc-glib-3.30.1/src/jsonrpc-message.c --- old/jsonrpc-glib-3.28.1/src/jsonrpc-message.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-message.c 2018-10-10 20:57:40.000000000 +0200 @@ -40,12 +40,14 @@ sizeof ((_any)->magic.bytes)) == 0) #define IS_PUT_STRING(_any) COMPARE_MAGIC(_any, PUT_STRING) +#define IS_PUT_STRV(_any) COMPARE_MAGIC(_any, PUT_STRV) #define IS_PUT_INT32(_any) COMPARE_MAGIC(_any, PUT_INT32) #define IS_PUT_INT64(_any) COMPARE_MAGIC(_any, PUT_INT64) #define IS_PUT_BOOLEAN(_any) COMPARE_MAGIC(_any, PUT_BOOLEAN) #define IS_PUT_DOUBLE(_any) COMPARE_MAGIC(_any, PUT_DOUBLE) #define IS_GET_STRING(_any) COMPARE_MAGIC(_any, GET_STRING) +#define IS_GET_STRV(_any) COMPARE_MAGIC(_any, GET_STRV) #define IS_GET_INT32(_any) COMPARE_MAGIC(_any, GET_INT32) #define IS_GET_INT64(_any) COMPARE_MAGIC(_any, GET_INT64) #define IS_GET_BOOLEAN(_any) COMPARE_MAGIC(_any, GET_BOOLEAN) @@ -55,10 +57,10 @@ #define IS_GET_VARIANT(_any) COMPARE_MAGIC(_any, GET_VARIANT) static void jsonrpc_message_build_object (GVariantBuilder *builder, - gpointer param, + gconstpointer param, va_list *args); static void jsonrpc_message_build_array (GVariantBuilder *builder, - gpointer param, + gconstpointer param, va_list *args); static gboolean jsonrpc_message_parse_object (GVariantDict *dict, gpointer param, @@ -69,10 +71,10 @@ static void jsonrpc_message_build_object (GVariantBuilder *builder, - gpointer param, + gconstpointer param, va_list *args) { - JsonrpcMessageAny *keyptr = param; + const JsonrpcMessageAny *keyptr = param; JsonrpcMessageAny *valptr; const char *key; @@ -94,7 +96,7 @@ * we assume it is a raw key name like "foo". */ if (IS_PUT_STRING (keyptr)) - key = ((JsonrpcMessagePutString *)keyptr)->val; + key = ((const JsonrpcMessagePutString *)keyptr)->val; else key = (const char *)keyptr; @@ -103,7 +105,7 @@ /* * Now try to read the value for the key/val pair. */ - valptr = param = va_arg (*args, gpointer); + valptr = va_arg (*args, gpointer); g_variant_builder_open (builder, G_VARIANT_TYPE ("v")); @@ -111,14 +113,14 @@ { case '{': g_variant_builder_open (builder, G_VARIANT_TYPE ("a{sv}")); - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); jsonrpc_message_build_object (builder, param, args); g_variant_builder_close (builder); break; case '[': g_variant_builder_open (builder, G_VARIANT_TYPE ("av")); - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); jsonrpc_message_build_array (builder, param, args); g_variant_builder_close (builder); break; @@ -136,6 +138,13 @@ else g_variant_builder_add (builder, "ms", NULL); } + else if (IS_PUT_STRV (valptr)) + { + if (((JsonrpcMessagePutStrv *)valptr)->val != NULL) + g_variant_builder_add (builder, "^as", ((JsonrpcMessagePutStrv *)valptr)->val); + else + g_variant_builder_add (builder, "mas", NULL); + } else if (IS_PUT_INT32 (valptr)) g_variant_builder_add (builder, "i", ((JsonrpcMessagePutInt32 *)valptr)->val); else if (IS_PUT_INT64 (valptr)) @@ -155,7 +164,7 @@ /* * Try to build the next field in the object if there is one. */ - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); jsonrpc_message_build_object (builder, param, args); EXIT; @@ -163,10 +172,10 @@ static void jsonrpc_message_build_array (GVariantBuilder *builder, - gpointer param, + gconstpointer param, va_list *args) { - JsonrpcMessageAny *valptr = param; + const JsonrpcMessageAny *valptr = param; ENTRY; @@ -180,14 +189,14 @@ { case '{': g_variant_builder_open (builder, G_VARIANT_TYPE ("a{sv}")); - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); jsonrpc_message_build_object (builder, param, args); g_variant_builder_close (builder); break; case '[': g_variant_builder_open (builder, G_VARIANT_TYPE ("av")); - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); jsonrpc_message_build_array (builder, param, args); g_variant_builder_close (builder); break; @@ -220,7 +229,7 @@ g_variant_builder_close (builder); - param = va_arg (*args, gpointer); + param = va_arg (*args, gconstpointer); if (param != NULL) jsonrpc_message_build_array (builder, param, args); @@ -228,8 +237,8 @@ } static GVariant * -jsonrpc_message_new_valist (gpointer first_param, - va_list *args) +jsonrpc_message_new_valist (gconstpointer first_param, + va_list *args) { GVariantBuilder builder; @@ -242,7 +251,7 @@ } GVariant * -jsonrpc_message_new (gpointer first_param, +jsonrpc_message_new (gconstpointer first_param, ...) { GVariant *ret; @@ -261,8 +270,8 @@ } static GVariant * -jsonrpc_message_new_array_valist (gpointer first_param, - va_list *args) +jsonrpc_message_new_array_valist (gconstpointer first_param, + va_list *args) { GVariantBuilder builder; @@ -275,7 +284,7 @@ } GVariant * -jsonrpc_message_new_array (gpointer first_param, +jsonrpc_message_new_array (gconstpointer first_param, ...) { GVariant *ret; @@ -379,6 +388,48 @@ } } } + else if (IS_GET_STRV (valptr)) + { + g_autoptr(GVariant) v = g_variant_dict_lookup_value (dict, key, NULL); + + if (v != NULL) + { + if (g_variant_is_of_type (v, G_VARIANT_TYPE ("as"))) + { + *((JsonrpcMessageGetStrv *)valptr)->valptr = g_variant_dup_strv (v, NULL); + ret = TRUE; + } + else if (g_variant_is_of_type (v, G_VARIANT_TYPE ("av"))) + { + GPtrArray *ar = g_ptr_array_new (); + GVariantIter iter; + GVariant *item; + + g_variant_iter_init (&iter, v); + while ((item = g_variant_iter_next_value (&iter))) + { + GVariant *unwrap = g_variant_get_variant (item); + + if (g_variant_is_of_type (unwrap, G_VARIANT_TYPE_STRING)) + g_ptr_array_add (ar, g_variant_dup_string (unwrap, NULL)); + + g_variant_unref (unwrap); + g_variant_unref (item); + } + g_ptr_array_add (ar, NULL); + + *((JsonrpcMessageGetStrv *)valptr)->valptr = (gchar **)g_ptr_array_free (ar, FALSE); + ret = TRUE; + } + else if (g_variant_is_of_type (v, G_VARIANT_TYPE ("mav")) || + g_variant_is_of_type (v, G_VARIANT_TYPE ("mas")) || + g_variant_is_of_type (v, G_VARIANT_TYPE ("mv"))) + { + *((JsonrpcMessageGetStrv *)valptr)->valptr = NULL; + ret = TRUE; + } + } + } else if (IS_GET_INT32 (valptr)) ret = g_variant_dict_lookup (dict, key, "i", ((JsonrpcMessageGetInt32 *)valptr)->valptr); else if (IS_GET_INT64 (valptr)) @@ -561,12 +612,16 @@ jsonrpc_message_parse (GVariant *message, ...) { + g_autoptr(GVariant) unboxed = NULL; gboolean ret; va_list args; if (message == NULL) return FALSE; + if (g_variant_is_of_type (message, G_VARIANT_TYPE_VARIANT)) + message = unboxed = g_variant_get_variant (message); + if (!g_variant_is_of_type (message, G_VARIANT_TYPE ("a{sv}"))) return FALSE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-message.h new/jsonrpc-glib-3.30.1/src/jsonrpc-message.h --- old/jsonrpc-glib-3.28.1/src/jsonrpc-message.h 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-message.h 2018-10-10 20:57:40.000000000 +0200 @@ -44,12 +44,24 @@ typedef struct { JsonrpcMessageMagic magic; + const char * const *val; +} JsonrpcMessagePutStrv __attribute__((aligned (8))); + +typedef struct +{ + JsonrpcMessageMagic magic; const char **valptr; } JsonrpcMessageGetString __attribute__((aligned (8))); typedef struct { JsonrpcMessageMagic magic; + char ***valptr; +} JsonrpcMessageGetStrv __attribute__((aligned (8))); + +typedef struct +{ + JsonrpcMessageMagic magic; gint32 val; } JsonrpcMessagePutInt32 __attribute__((aligned (8))); @@ -118,6 +130,8 @@ #define _JSONRPC_MESSAGE_PUT_STRING_MAGIC _JSONRPC_MAGIC("PUTS") #define _JSONRPC_MESSAGE_GET_STRING_MAGIC _JSONRPC_MAGIC("GETS") +#define _JSONRPC_MESSAGE_PUT_STRV_MAGIC _JSONRPC_MAGIC("PUTZ") +#define _JSONRPC_MESSAGE_GET_STRV_MAGIC _JSONRPC_MAGIC("GETZ") #define _JSONRPC_MESSAGE_PUT_INT32_MAGIC _JSONRPC_MAGIC("PUTI") #define _JSONRPC_MESSAGE_GET_INT32_MAGIC _JSONRPC_MAGIC("GETI") #define _JSONRPC_MESSAGE_PUT_INT64_MAGIC _JSONRPC_MAGIC("PUTX") @@ -132,6 +146,8 @@ #define _JSONRPC_MESSAGE_PUT_STRING_MAGIC_C _JSONRPC_MAGIC_C('P','U','T','S') #define _JSONRPC_MESSAGE_GET_STRING_MAGIC_C _JSONRPC_MAGIC_C('G','E','T','S') +#define _JSONRPC_MESSAGE_PUT_STRV_MAGIC_C _JSONRPC_MAGIC_C('P','U','T','Z') +#define _JSONRPC_MESSAGE_GET_STRV_MAGIC_C _JSONRPC_MAGIC_C('G','E','T','Z') #define _JSONRPC_MESSAGE_PUT_INT32_MAGIC_C _JSONRPC_MAGIC_C('P','U','T','I') #define _JSONRPC_MESSAGE_GET_INT32_MAGIC_C _JSONRPC_MAGIC_C('G','E','T','I') #define _JSONRPC_MESSAGE_PUT_INT64_MAGIC_C _JSONRPC_MAGIC_C('P','U','T','X') @@ -158,6 +174,11 @@ #define JSONRPC_MESSAGE_GET_STRING(_valptr) \ (&((JsonrpcMessageGetString) { .magic = {_JSONRPC_MESSAGE_GET_STRING_MAGIC_C}, .valptr = _valptr })) +#define JSONRPC_MESSAGE_PUT_STRV(_val) \ + (&((JsonrpcMessagePutStrv) { .magic = {_JSONRPC_MESSAGE_PUT_STRV_MAGIC_C}, .val = _val })) +#define JSONRPC_MESSAGE_GET_STRV(_valptr) \ + (&((JsonrpcMessageGetStrv) { .magic = {_JSONRPC_MESSAGE_GET_STRV_MAGIC_C}, .valptr = _valptr })) + #define JSONRPC_MESSAGE_PUT_INT32(_val) \ (&((JsonrpcMessagePutInt32) { .magic = {_JSONRPC_MESSAGE_PUT_INT32_MAGIC_C}, .val = _val })) #define JSONRPC_MESSAGE_GET_INT32(_valptr) \ @@ -188,10 +209,10 @@ (&((JsonrpcMessageGetVariant) { .magic = {_JSONRPC_MESSAGE_GET_VARIANT_MAGIC_C}, .variantptr = _valptr })) JSONRPC_AVAILABLE_IN_3_26 -GVariant *jsonrpc_message_new (gpointer first_param, ...) G_GNUC_NULL_TERMINATED; +GVariant *jsonrpc_message_new (gconstpointer first_param, ...) G_GNUC_NULL_TERMINATED; JSONRPC_AVAILABLE_IN_3_26 -GVariant *jsonrpc_message_new_array (gpointer first_param, ...) G_GNUC_NULL_TERMINATED; +GVariant *jsonrpc_message_new_array (gconstpointer first_param, ...) G_GNUC_NULL_TERMINATED; JSONRPC_AVAILABLE_IN_3_26 gboolean jsonrpc_message_parse (GVariant *message, ...) G_GNUC_NULL_TERMINATED; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-server.c new/jsonrpc-glib-3.30.1/src/jsonrpc-server.c --- old/jsonrpc-glib-3.28.1/src/jsonrpc-server.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-server.c 2018-10-10 20:57:40.000000000 +0200 @@ -58,6 +58,7 @@ HANDLE_CALL, NOTIFICATION, CLIENT_ACCEPTED, + CLIENT_CLOSED, N_SIGNALS }; @@ -182,7 +183,7 @@ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, G_TYPE_VARIANT); - /** + /** * JsonrpcServer::client-accepted: * @self: A #JsonrpcServer * @client: A #JsonrpcClient @@ -204,6 +205,29 @@ g_signal_set_va_marshaller (signals [CLIENT_ACCEPTED], G_TYPE_FROM_CLASS (klass), g_cclosure_marshal_VOID__OBJECTv); + + /** + * JsonrpcServer::client-closed: + * @self: A #JsonrpcServer + * @client: A #JsonrpcClient + * + * This signal is emitted when a new client has been lost. + * + * Since: 3.30 + */ + signals [CLIENT_CLOSED] = + g_signal_new ("client-closed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (JsonrpcServerClass, client_closed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, + 1, + JSONRPC_TYPE_CLIENT); + g_signal_set_va_marshaller (signals [CLIENT_CLOSED], + G_TYPE_FROM_CLASS (klass), + g_cclosure_marshal_VOID__OBJECTv); } static void @@ -255,6 +279,7 @@ */ g_debug ("Lost connection to client [%p]", client); g_hash_table_steal (priv->clients, client); + g_signal_emit (self, signals [CLIENT_CLOSED], 0, client); g_idle_add_full (G_MAXINT, dummy_func, client, g_object_unref); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-server.h new/jsonrpc-glib-3.30.1/src/jsonrpc-server.h --- old/jsonrpc-glib-3.28.1/src/jsonrpc-server.h 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-server.h 2018-10-10 20:57:40.000000000 +0200 @@ -35,25 +35,27 @@ { GObjectClass parent_class; - gboolean (*handle_call) (JsonrpcServer *self, - JsonrpcClient *client, - const gchar *method, - GVariant *id, - GVariant *params); - void (*notification) (JsonrpcServer *self, - JsonrpcClient *client, - const gchar *method, - GVariant *params); + gboolean (*handle_call) (JsonrpcServer *self, + JsonrpcClient *client, + const gchar *method, + GVariant *id, + GVariant *params); + void (*notification) (JsonrpcServer *self, + JsonrpcClient *client, + const gchar *method, + GVariant *params); void (*client_accepted) (JsonrpcServer *self, JsonrpcClient *client); + void (*client_closed) (JsonrpcServer *self, + JsonrpcClient *client); + /*< private >*/ gpointer _reserved1; gpointer _reserved2; gpointer _reserved3; gpointer _reserved4; gpointer _reserved5; gpointer _reserved6; - gpointer _reserved7; }; typedef void (*JsonrpcServerHandler) (JsonrpcServer *self, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/jsonrpc-version-macros.h new/jsonrpc-glib-3.30.1/src/jsonrpc-version-macros.h --- old/jsonrpc-glib-3.28.1/src/jsonrpc-version-macros.h 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/jsonrpc-version-macros.h 2018-10-10 20:57:40.000000000 +0200 @@ -42,6 +42,7 @@ #define JSONRPC_VERSION_3_26 (G_ENCODE_VERSION (3, 26)) #define JSONRPC_VERSION_3_28 (G_ENCODE_VERSION (3, 28)) +#define JSONRPC_VERSION_3_30 (G_ENCODE_VERSION (3, 30)) #if (JSONRPC_MINOR_VERSION == 99) # define JSONRPC_VERSION_CUR_STABLE (G_ENCODE_VERSION (JSONRPC_MAJOR_VERSION + 1, 0)) @@ -140,4 +141,18 @@ # define JSONRPC_AVAILABLE_IN_3_28 _JSONRPC_EXTERN #endif +#if JSONRPC_VERSION_MIN_REQUIRED >= JSONRPC_VERSION_3_30 +# define JSONRPC_DEPRECATED_IN_3_30 JSONRPC_DEPRECATED +# define JSONRPC_DEPRECATED_IN_3_30_FOR(f) JSONRPC_DEPRECATED_FOR(f) +#else +# define JSONRPC_DEPRECATED_IN_3_30 _JSONRPC_EXTERN +# define JSONRPC_DEPRECATED_IN_3_30_FOR(f) _JSONRPC_EXTERN +#endif + +#if JSONRPC_VERSION_MAX_ALLOWED < JSONRPC_VERSION_3_30 +# define JSONRPC_AVAILABLE_IN_3_30 JSONRPC_UNAVAILABLE(3, 30) +#else +# define JSONRPC_AVAILABLE_IN_3_30 _JSONRPC_EXTERN +#endif + #endif /* JSONRPC_VERSION_MACROS_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/src/meson.build new/jsonrpc-glib-3.30.1/src/meson.build --- old/jsonrpc-glib-3.28.1/src/meson.build 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/src/meson.build 2018-10-10 20:57:40.000000000 +0200 @@ -52,7 +52,7 @@ 'jsonrpc-glib-' + apiversion, libjsonrpc_glib_sources, - c_args: hidden_visibility_args, + c_args: hidden_visibility_args + release_args, dependencies: libjsonrpc_glib_deps, soversion: soversion, version: libversion, @@ -85,7 +85,7 @@ if get_option('with_vapi') libjsonrpc_glib_vapi = gnome.generate_vapi('jsonrpc-glib-' + apiversion, - sources: libjsonrpc_glib_gir[0], + sources: [libjsonrpc_glib_gir[0], 'Jsonrpc-' + apiversion + '-custom.vala'], packages: [ 'gio-2.0', 'json-glib-1.0' ], install: true, install_dir: vapidir, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/meson.build new/jsonrpc-glib-3.30.1/tests/meson.build --- old/jsonrpc-glib-3.28.1/tests/meson.build 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/meson.build 2018-10-10 20:57:40.000000000 +0200 @@ -24,15 +24,6 @@ dependency('gio-unix-2.0'), ] -# Not automated, just for local testing -# Probably should remove this anyway since test-server -# does most of the same stuff. -test_client = executable('test-client', 'test-client.c', - c_args: test_cflags, - link_args: test_link_args, - dependencies: test_deps, -) - test_message = executable('test-message', 'test-message.c', c_args: test_cflags, link_args: test_link_args, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/test-client.c new/jsonrpc-glib-3.30.1/tests/test-client.c --- old/jsonrpc-glib-3.28.1/tests/test-client.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/test-client.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,131 +0,0 @@ -#include <stdlib.h> -#include <unistd.h> - -#include "jsonrpc-client.h" - -static JsonrpcClient *gClient; -static GMainLoop *main_loop; - -static void -close_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - g_main_loop_quit (main_loop); -} - -static gboolean -timeout_cb (gpointer data) -{ - jsonrpc_client_close_async (gClient, NULL, close_cb, NULL); - return G_SOURCE_REMOVE; -} - -static void -call_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - JsonrpcClient *client = (JsonrpcClient *)object; - g_autoptr(GError) error = NULL; - g_autoptr(GVariant) return_value = NULL; - - g_assert (JSONRPC_IS_CLIENT (client)); - g_assert (G_IS_ASYNC_RESULT (result)); - - if (!jsonrpc_client_call_finish (client, result, &return_value, &error)) - g_error ("%s", error->message); -} - -static void -wait_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - GSubprocess *subprocess = (GSubprocess *)object; - g_autoptr(GError) error = NULL; - - g_assert (G_IS_SUBPROCESS (subprocess)); - g_assert (G_IS_ASYNC_RESULT (result)); - - g_message ("rustls exited"); - - exit (1); -} - -static void -notification_cb (JsonrpcClient *client, - const gchar *method, - GVariant *params, - gpointer user_data) -{ - g_autofree gchar *str = g_variant_print (params, TRUE); - - g_message ("(Notification): %s: %s", method, str); -} - -gint -main (gint argc, - gchar *argv[]) -{ - g_autoptr(GIOStream) io_stream = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GSubprocess) subprocess = NULL; - g_auto(GVariantDict) params = { 0 }; - g_autofree gchar *path = NULL; - GInputStream *stdout_pipe; - GOutputStream *stdin_pipe; - - main_loop = g_main_loop_new (NULL, FALSE); - - subprocess = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | - G_SUBPROCESS_FLAGS_STDOUT_PIPE | - G_SUBPROCESS_FLAGS_STDERR_SILENCE, - &error, - "rls", - NULL); - - if (subprocess == NULL) - { - g_warning ("%s", error->message); - return EXIT_FAILURE; - } - - g_message ("rustls started"); - - stdin_pipe = g_subprocess_get_stdin_pipe (subprocess); - stdout_pipe = g_subprocess_get_stdout_pipe (subprocess); - io_stream = g_object_new (G_TYPE_SIMPLE_IO_STREAM, - "input-stream", stdout_pipe, - "output-stream", stdin_pipe, - NULL); - - gClient = jsonrpc_client_new (io_stream); - - g_signal_connect (gClient, - "notification", - G_CALLBACK (notification_cb), - NULL); - - g_subprocess_wait_async (subprocess, NULL, wait_cb, NULL); - - path = g_build_filename (g_get_home_dir (), - "Projects", - "rustls", - "sample_project", - NULL); - - g_variant_dict_init (¶ms, NULL); - g_variant_dict_insert (¶ms, "processId", "i", getpid ()); - g_variant_dict_insert (¶ms, "rootPath", "s", path); - g_variant_dict_insert_value (¶ms, "capabilities", g_variant_new ("a{sv}", NULL, NULL, NULL)); - - /* Use a method name with / to ensure we test more complex paths */ - jsonrpc_client_call_async (gClient, "initialize/foo", g_variant_dict_end (¶ms), NULL, call_cb, NULL); - - g_timeout_add_seconds (5, timeout_cb, NULL); - - g_main_loop_run (main_loop); - - return EXIT_SUCCESS; -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/test-gauntlet.c new/jsonrpc-glib-3.30.1/tests/test-gauntlet.c --- old/jsonrpc-glib-3.28.1/tests/test-gauntlet.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/test-gauntlet.c 2018-10-10 20:57:40.000000000 +0200 @@ -20,6 +20,7 @@ #include <gio/gunixoutputstream.h> #include <glib-unix.h> #include <jsonrpc-glib.h> +#include <signal.h> static GMainLoop *main_loop; @@ -52,14 +53,17 @@ gboolean r; r = jsonrpc_client_call_finish (JSONRPC_CLIENT (object), result, &res, &error); - g_assert_cmpint (error->domain, ==, G_IO_ERROR); + + if (r == FALSE) + { + g_assert_cmpint (error->domain, ==, G_IO_ERROR); #if 0 - /* We can't really guarantee this, given the ways the socket errors - * can be propagated. - */ - g_assert (error->code == 0 || error->code == G_IO_ERROR_NOT_CONNECTED); + /* We can't really guarantee this, given the ways the socket errors + * can be propagated. + */ + g_assert (error->code == 0 || error->code == G_IO_ERROR_NOT_CONNECTED); #endif - g_assert_false (r); + } g_main_loop_quit (main_loop); } @@ -80,6 +84,8 @@ gint pair_a[2]; gint pair_b[2]; + signal (SIGPIPE, SIG_IGN); + main_loop = g_main_loop_new (NULL, FALSE); r = g_unix_open_pipe (pair_a, FD_CLOEXEC, &error); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/test-message.c new/jsonrpc-glib-3.30.1/tests/test-message.c --- old/jsonrpc-glib-3.28.1/tests/test-message.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/test-message.c 2018-10-10 20:57:40.000000000 +0200 @@ -236,6 +236,61 @@ g_assert_cmpstr (content_type, ==, NULL); } +static void +test_strv (void) +{ + g_autoptr(GVariant) src = NULL; + static const gchar *ar[] = { "a", "b", "c", NULL }; + g_auto(GStrv) get_ar = NULL; + g_autofree gchar *print = NULL; + gboolean r; + + src = JSONRPC_MESSAGE_NEW ("key", JSONRPC_MESSAGE_PUT_STRV (ar)); + print = g_variant_print (src, TRUE); + g_assert_cmpstr (print, ==, "{'key': <['a', 'b', 'c']>}"); + + r = JSONRPC_MESSAGE_PARSE (src, "key", JSONRPC_MESSAGE_GET_STRV (&get_ar)); + g_assert_true (r); + g_assert_nonnull (get_ar); + g_assert_cmpstr (get_ar[0], ==, "a"); + g_assert_cmpstr (get_ar[1], ==, "b"); + g_assert_cmpstr (get_ar[2], ==, "c"); + g_assert_null (get_ar[3]); +} + +static void +test_null_strv (void) +{ + g_autoptr(GVariant) src = NULL; + g_auto(GStrv) get_ar = NULL; + g_auto(GStrv) get_ar_from_v = NULL; + g_autofree gchar *print = NULL; + g_autoptr(JsonNode) node = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) v = NULL; + gboolean r; + + src = JSONRPC_MESSAGE_NEW ("key", JSONRPC_MESSAGE_PUT_STRV (NULL)); + print = g_variant_print (src, TRUE); + g_assert_cmpstr (print, ==, "{'key': <@mas nothing>}"); + + r = JSONRPC_MESSAGE_PARSE (src, "key", JSONRPC_MESSAGE_GET_STRV (&get_ar)); + g_assert_true (r); + g_assert_null (get_ar); + + node = json_from_string ("{'key': null}", &error); + g_assert_no_error (error); + g_assert_nonnull (node); + + v = json_gvariant_deserialize (node, NULL, &error); + g_assert_no_error (error); + g_assert_nonnull (v); + + r = JSONRPC_MESSAGE_PARSE (v, "key", JSONRPC_MESSAGE_GET_STRV (&get_ar_from_v)); + g_assert_true (r); + g_assert_null (get_ar_from_v); +} + gint main (gint argc, gchar *argv[]) @@ -251,5 +306,7 @@ g_test_add_func ("/Jsonrpc/Message/new_array", test_new_array); g_test_add_func ("/Jsonrpc/Message/new_array_objs", test_new_array_objs); g_test_add_func ("/Jsonrpc/Message/null_string", test_null_string); + g_test_add_func ("/Jsonrpc/Message/strv", test_strv); + g_test_add_func ("/Jsonrpc/Message/null_strv", test_null_strv); return g_test_run (); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/test-server.c new/jsonrpc-glib-3.30.1/tests/test-server.c --- old/jsonrpc-glib-3.28.1/tests/test-server.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/test-server.c 2018-10-10 20:57:40.000000000 +0200 @@ -26,6 +26,7 @@ #include <gio/gunixinputstream.h> #include <glib-unix.h> #include <jsonrpc-glib.h> +#include <signal.h> #include <unistd.h> static void @@ -127,6 +128,8 @@ gint count = 0; gint r; + signal (SIGPIPE, SIG_IGN); + r = g_unix_open_pipe (pair_a, FD_CLOEXEC, &error); g_assert_no_error (error); g_assert_cmpint (r, ==, TRUE); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jsonrpc-glib-3.28.1/tests/test-stress.c new/jsonrpc-glib-3.30.1/tests/test-stress.c --- old/jsonrpc-glib-3.28.1/tests/test-stress.c 2018-06-19 05:04:45.000000000 +0200 +++ new/jsonrpc-glib-3.30.1/tests/test-stress.c 2018-10-10 20:57:40.000000000 +0200 @@ -20,6 +20,7 @@ #include <gio/gunixinputstream.h> #include <gio/gunixoutputstream.h> #include <jsonrpc-glib.h> +#include <signal.h> static GMainLoop *main_loop; static gint n_ops; @@ -189,6 +190,8 @@ gint pair1[2]; gint pair2[2]; + signal (SIGPIPE, SIG_IGN); + main_loop = g_main_loop_new (NULL, FALSE); n_ops = 1000;
