[Spice-devel] [RFC PATCH spice-gtk] Adjust SpicePortChannel method names
Frediano Ziglio
fziglio at redhat.com
Mon Sep 18 07:03:18 UTC 2017
>
> Name functions correctly to allow them to be picked up as methods under
> introspection
> ---
> src/channel-port.c | 73
> ++++++++++++++++++++++++++++++++++++++++++++++++-
> src/channel-port.h | 15 ++++++++++
> src/map-file | 3 ++
> src/spice-glib-sym-file | 3 ++
> tools/spicy.c | 6 ++--
> 5 files changed, 96 insertions(+), 4 deletions(-)
>
> diff --git a/src/channel-port.c b/src/channel-port.c
> index d922e4b..f9f0940 100644
> --- a/src/channel-port.c
> +++ b/src/channel-port.c
> @@ -277,6 +277,7 @@ static void port_handle_msg(SpiceChannel *channel,
> SpiceMsgIn *in)
> * the operation.
> *
> * Since: 0.15
> + * Deprecated: 0.35: use spice_port_channel_write_async() instead.
> **/
> void spice_port_write_async(SpicePortChannel *self,
> const void *buffer, gsize count,
> @@ -284,6 +285,34 @@ void spice_port_write_async(SpicePortChannel *self,
> GAsyncReadyCallback callback,
> gpointer user_data)
> {
> + G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> + spice_port_channel_write_async(self, buffer, count, cancellable,
> callback, user_data);
> + G_GNUC_END_IGNORE_DEPRECATIONS
Why you need to disable deprecation warnings if you are calling a
non deprecated function?
Which compilers are we using?
Cannot we use alias attribute (gcc/clang) or other options?
As far as I can see they are just renames.
> +}
> +
> +/**
> + * spice_port_channel_write_async:
> + * @port: A #SpicePortChannel
> + * @buffer: (array length=count) (element-type guint8): the buffer
> + * containing the data to write
> + * @count: the number of bytes to write
> + * @cancellable: (allow-none): optional GCancellable object, NULL to ignore
> + * @callback: (scope async): callback to call when the request is satisfied
> + * @user_data: (closure): the data to pass to callback function
> + *
> + * Request an asynchronous write of count bytes from @buffer into the
> + * @port. When the operation is finished @callback will be called. You
> + * can then call spice_port_write_finish() to get the result of
> + * the operation.
> + *
> + * Since: 0.35
> + **/
> +void spice_port_channel_write_async(SpicePortChannel *self,
> + const void *buffer, gsize count,
> + GCancellable *cancellable,
> + GAsyncReadyCallback callback,
> + gpointer user_data)
> +{
> SpicePortChannelPrivate *c;
>
> g_return_if_fail(SPICE_IS_PORT_CHANNEL(self));
> @@ -292,7 +321,7 @@ void spice_port_write_async(SpicePortChannel *self,
>
> if (!c->opened) {
> g_task_report_new_error(self, callback,
> - user_data, spice_port_write_async,
> + user_data, spice_port_channel_write_async,
> SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> "The port is not opened");
> return;
> @@ -313,10 +342,31 @@ void spice_port_write_async(SpicePortChannel *self,
> *
> * Returns: a #gssize containing the number of bytes written to the stream.
> * Since: 0.15
> + * Deprecated: 0.35: use spice_port_channel_write_finish() instead.
> **/
> gssize spice_port_write_finish(SpicePortChannel *self,
> GAsyncResult *result, GError **error)
> {
> + G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> + return spice_port_channel_write_finish(self, result, error);
> + G_GNUC_END_IGNORE_DEPRECATIONS
> +}
> +
> +/**
> + * spice_port_channel_write_finish:
> + * @port: a #SpicePortChannel
> + * @result: a #GAsyncResult
> + * @error: a #GError location to store the error occurring, or %NULL
> + * to ignore
> + *
> + * Finishes a port write operation.
> + *
> + * Returns: a #gssize containing the number of bytes written to the stream.
> + * Since: 0.35
> + **/
> +gssize spice_port_channel_write_finish(SpicePortChannel *self,
> + GAsyncResult *result, GError **error)
> +{
> g_return_val_if_fail(SPICE_IS_PORT_CHANNEL(self), -1);
>
> return spice_vmc_write_finish(SPICE_CHANNEL(self), result, error);
> @@ -334,9 +384,30 @@ gssize spice_port_write_finish(SpicePortChannel *self,
> * state.
> *
> * Since: 0.15
> + * Deprecated: 0.35: use spice_port_channel_event() instead
> **/
> void spice_port_event(SpicePortChannel *self, guint8 event)
> {
> + G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> + spice_port_channel_event(self, event);
> + G_GNUC_END_IGNORE_DEPRECATIONS
> +}
> +
> +/**
> + * spice_port_channel_event:
> + * @port: a #SpicePortChannel
> + * @event: a SPICE_PORT_EVENT value
> + *
> + * Send an event to the port.
> + *
> + * Note: The values SPICE_PORT_EVENT_CLOSED and
> + * SPICE_PORT_EVENT_OPENED are managed by the channel connection
> + * state.
> + *
> + * Since: 0.35
> + **/
> +void spice_port_channel_event(SpicePortChannel *self, guint8 event)
> +{
> SpiceMsgcPortEvent e;
> SpiceMsgOut *msg;
>
> diff --git a/src/channel-port.h b/src/channel-port.h
> index 8fc19cc..3c80d61 100644
> --- a/src/channel-port.h
> +++ b/src/channel-port.h
> @@ -66,14 +66,29 @@ struct _SpicePortChannelClass {
>
> GType spice_port_channel_get_type(void);
>
> +void spice_port_channel_write_async(SpicePortChannel *port,
> + const void *buffer, gsize count,
> + GCancellable *cancellable,
> + GAsyncReadyCallback callback,
> + gpointer user_data);
> +gssize spice_port_channel_write_finish(SpicePortChannel *port,
> + GAsyncResult *result, GError
> **error);
> +void spice_port_channel_event(SpicePortChannel *port, guint8 event);
> +
> +
> +#ifndef SPICE_DISABLE_DEPRECATED
> +G_DEPRECATED_FOR(spice_port_channel_write_async)
> void spice_port_write_async(SpicePortChannel *port,
> const void *buffer, gsize count,
> GCancellable *cancellable,
> GAsyncReadyCallback callback,
> gpointer user_data);
> +G_DEPRECATED_FOR(spice_port_channel_write_finish)
> gssize spice_port_write_finish(SpicePortChannel *port,
> GAsyncResult *result, GError **error);
> +G_DEPRECATED_FOR(spice_port_channel_event)
> void spice_port_event(SpicePortChannel *port, guint8 event);
> +#endif
>
> G_END_DECLS
>
> diff --git a/src/map-file b/src/map-file
> index 668ff41..de4f421 100644
> --- a/src/map-file
> +++ b/src/map-file
> @@ -86,7 +86,10 @@ spice_main_update_display;
> spice_main_update_display_enabled;
> spice_playback_channel_get_type;
> spice_playback_channel_set_delay;
> +spice_port_channel_event;
> spice_port_channel_get_type;
> +spice_port_channel_write_async;
> +spice_port_channel_write_finish;
> spice_port_event;
> spice_port_write_async;
> spice_port_write_finish;
> diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
> index e061744..79c75f1 100644
> --- a/src/spice-glib-sym-file
> +++ b/src/spice-glib-sym-file
> @@ -65,7 +65,10 @@ spice_main_update_display
> spice_main_update_display_enabled
> spice_playback_channel_get_type
> spice_playback_channel_set_delay
> +spice_port_channel_event
> spice_port_channel_get_type
> +spice_port_channel_write_async
> +spice_port_channel_write_finish
> spice_port_event
> spice_port_write_async
> spice_port_write_finish
> diff --git a/tools/spicy.c b/tools/spicy.c
> index a09f8cd..d71d996 100644
> --- a/tools/spicy.c
> +++ b/tools/spicy.c
> @@ -1484,7 +1484,7 @@ static void port_write_cb(GObject *source_object,
> SpicePortChannel *port = SPICE_PORT_CHANNEL(source_object);
> GError *error = NULL;
>
> - spice_port_write_finish(port, res, &error);
> + spice_port_channel_write_finish(port, res, &error);
> if (error != NULL)
> g_warning("%s", error->message);
> g_clear_error(&error);
> @@ -1519,7 +1519,7 @@ static gboolean input_cb(GIOChannel *gin, GIOCondition
> condition, gpointer data)
> return FALSE;
>
> if (stdin_port != NULL)
> - spice_port_write_async(stdin_port, buf, bytes_read, NULL,
> port_write_cb, NULL);
> + spice_port_channel_write_async(stdin_port, buf, bytes_read, NULL,
> port_write_cb, NULL);
>
> return TRUE;
> }
> @@ -1543,7 +1543,7 @@ static void port_opened(SpiceChannel *channel,
> GParamSpec *pspec,
> if (opened) {
> /* only send a break event and disconnect */
> if (g_strcmp0(name, "org.spice.spicy.break") == 0) {
> - spice_port_event(port, SPICE_PORT_EVENT_BREAK);
> + spice_port_channel_event(port, SPICE_PORT_EVENT_BREAK);
> spice_channel_flush_async(channel, NULL, port_flushed_cb, conn);
> }
>
Frediano
More information about the Spice-devel
mailing list