[Spice-devel] [PATCH v3 12/17] Remove DummyChannel* objects

Frediano Ziglio fziglio at redhat.com
Tue Nov 29 14:57:12 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/Makefile.am            |   4 +-
 server/dummy-channel-client.c | 138 +-----------------------------------
 server/dummy-channel-client.h |  64 +----------------
 server/dummy-channel.c        |  94 +------------------------
 server/dummy-channel.h        |  60 +---------------
 5 files changed, 360 deletions(-)
 delete mode 100644 server/dummy-channel-client.c
 delete mode 100644 server/dummy-channel-client.h
 delete mode 100644 server/dummy-channel.c
 delete mode 100644 server/dummy-channel.h

diff --git a/server/Makefile.am b/server/Makefile.am
index ae79ed7..1442bf1 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -104,10 +104,6 @@ libserver_la_SOURCES =				\
 	red-channel-client-private.h		\
 	red-client.c				\
 	red-client.h				\
-	dummy-channel.c				\
-	dummy-channel.h				\
-	dummy-channel-client.c			\
-	dummy-channel-client.h			\
 	red-common.h				\
 	dispatcher.c				\
 	dispatcher.h				\
diff --git a/server/dummy-channel-client.c b/server/dummy-channel-client.c
deleted file mode 100644
index 61d5683..0000000
--- a/server/dummy-channel-client.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-   Copyright (C) 2009-2015 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "dummy-channel-client.h"
-#include "red-channel.h"
-#include "red-client.h"
-
-static void dummy_channel_client_initable_interface_init(GInitableIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(DummyChannelClient, dummy_channel_client, RED_TYPE_CHANNEL_CLIENT,
-                        G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE,
-                                              dummy_channel_client_initable_interface_init))
-
-#define DUMMY_CHANNEL_CLIENT_PRIVATE(o) \
-    (G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_DUMMY_CHANNEL_CLIENT, DummyChannelClientPrivate))
-
-struct DummyChannelClientPrivate
-{
-    gboolean connected;
-};
-
-static gboolean dummy_channel_client_initable_init(GInitable *initable,
-                                                   GCancellable *cancellable,
-                                                   GError **error)
-{
-    GError *local_error = NULL;
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(initable);
-    RedClient *client = red_channel_client_get_client(rcc);
-    RedChannel *channel = red_channel_client_get_channel(rcc);
-
-    red_channel_add_client(channel, rcc);
-    if (!red_client_add_channel(client, rcc, &local_error)) {
-        red_channel_remove_client(channel, rcc);
-    }
-
-    if (local_error) {
-        g_warning("Failed to create channel client: %s", local_error->message);
-        g_propagate_error(error, local_error);
-    }
-    return local_error == NULL;
-}
-
-static void dummy_channel_client_initable_interface_init(GInitableIface *iface)
-{
-    iface->init = dummy_channel_client_initable_init;
-}
-
-static gboolean dummy_channel_client_is_connected(RedChannelClient *rcc)
-{
-    return DUMMY_CHANNEL_CLIENT(rcc)->priv->connected;
-}
-
-static void dummy_channel_client_disconnect(RedChannelClient *rcc)
-{
-    DummyChannelClient *self = DUMMY_CHANNEL_CLIENT(rcc);
-    RedChannel *channel = red_channel_client_get_channel(rcc);
-    GList *link;
-    uint32_t type, id;
-
-    if (channel && (link = g_list_find(red_channel_get_clients(channel), rcc))) {
-        g_object_get(channel, "channel-type", &type, "id", &id, NULL);
-        spice_printerr("rcc=%p (channel=%p type=%d id=%d)", rcc, channel,
-                       type, id);
-        red_channel_remove_client(channel, link->data);
-    }
-    self->priv->connected = FALSE;
-}
-
-static void
-dummy_channel_client_class_init(DummyChannelClientClass *klass)
-{
-    RedChannelClientClass *cc_class = RED_CHANNEL_CLIENT_CLASS(klass);
-
-    g_type_class_add_private(klass, sizeof(DummyChannelClientPrivate));
-
-    cc_class->is_connected = dummy_channel_client_is_connected;
-    cc_class->disconnect = dummy_channel_client_disconnect;
-}
-
-static void
-dummy_channel_client_init(DummyChannelClient *self)
-{
-    self->priv = DUMMY_CHANNEL_CLIENT_PRIVATE(self);
-
-    self->priv->connected = TRUE;
-}
-
-RedChannelClient* dummy_channel_client_create(RedChannel *channel,
-                                              RedClient  *client,
-                                              int num_common_caps,
-                                              uint32_t *common_caps,
-                                              int num_caps, uint32_t *caps)
-{
-    RedChannelClient *rcc;
-    GArray *common_caps_array = NULL, *caps_array = NULL;
-
-    if (common_caps) {
-        common_caps_array = g_array_sized_new(FALSE, FALSE, sizeof (*common_caps),
-                                              num_common_caps);
-        g_array_append_vals(common_caps_array, common_caps, num_common_caps);
-    }
-    if (caps) {
-        caps_array = g_array_sized_new(FALSE, FALSE, sizeof (*caps), num_caps);
-        g_array_append_vals(caps_array, caps, num_caps);
-    }
-
-    rcc = g_initable_new(TYPE_DUMMY_CHANNEL_CLIENT,
-                         NULL, NULL,
-                         "channel", channel,
-                         "client", client,
-                         "caps", caps_array,
-                         "common-caps", common_caps_array,
-                         NULL);
-
-    if (caps_array)
-        g_array_unref(caps_array);
-    if (common_caps_array)
-        g_array_unref(common_caps_array);
-
-    return rcc;
-}
diff --git a/server/dummy-channel-client.h b/server/dummy-channel-client.h
deleted file mode 100644
index 8013aa2..0000000
--- a/server/dummy-channel-client.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-   Copyright (C) 2009-2015 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-   */
-#ifndef __DUMMY_CHANNEL_CLIENT_H__
-#define __DUMMY_CHANNEL_CLIENT_H__
-
-#include <glib-object.h>
-
-#include "red-channel-client.h"
-
-G_BEGIN_DECLS
-
-#define TYPE_DUMMY_CHANNEL_CLIENT dummy_channel_client_get_type()
-
-#define DUMMY_CHANNEL_CLIENT(obj) \
-    (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DUMMY_CHANNEL_CLIENT, DummyChannelClient))
-#define DUMMY_CHANNEL_CLIENT_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DUMMY_CHANNEL_CLIENT, DummyChannelClientClass))
-#define IS_DUMMY_CHANNEL_CLIENT(obj) \
-    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DUMMY_CHANNEL_CLIENT))
-#define IS_DUMMY_CHANNEL_CLIENT_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DUMMY_CHANNEL_CLIENT))
-#define DUMMY_CHANNEL_CLIENT_GET_CLASS(obj) \
-    (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DUMMY_CHANNEL_CLIENT, DummyChannelClientClass))
-
-typedef struct DummyChannelClient DummyChannelClient;
-typedef struct DummyChannelClientClass DummyChannelClientClass;
-typedef struct DummyChannelClientPrivate DummyChannelClientPrivate;
-
-struct DummyChannelClient
-{
-    RedChannelClient parent;
-
-    DummyChannelClientPrivate *priv;
-};
-
-struct DummyChannelClientClass
-{
-    RedChannelClientClass parent_class;
-};
-
-GType dummy_channel_client_get_type(void) G_GNUC_CONST;
-
-RedChannelClient *dummy_channel_client_create(RedChannel *channel,
-                                              RedClient  *client,
-                                              int num_common_caps, uint32_t *common_caps,
-                                              int num_caps, uint32_t *caps);
-
-G_END_DECLS
-
-#endif /* __DUMMY_CHANNEL_CLIENT_H__ */
diff --git a/server/dummy-channel.c b/server/dummy-channel.c
deleted file mode 100644
index aecd3a6..0000000
--- a/server/dummy-channel.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-   Copyright (C) 2016 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "dummy-channel.h"
-
-G_DEFINE_TYPE(DummyChannel, dummy_channel, RED_TYPE_CHANNEL)
-
-static int dummy_config_socket(RedChannelClient *self)
-{
-    return 1;
-}
-
-static void dummy_on_disconnect(RedChannelClient *self)
-{
-}
-
-static uint8_t* dummy_alloc_recv_buf(RedChannelClient *self,
-                                     uint16_t type,
-                                     uint32_t size)
-{
-    return NULL;
-}
-
-static void dummy_release_recv_buf(RedChannelClient *self,
-                                   uint16_t type,
-                                   uint32_t size,
-                                   uint8_t *msg)
-{
-}
-
-static void
-dummy_channel_class_init(DummyChannelClass *klass)
-{
-    RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
-    channel_class->config_socket = dummy_config_socket;
-    channel_class->on_disconnect = dummy_on_disconnect;
-    channel_class->alloc_recv_buf = dummy_alloc_recv_buf;
-    channel_class->release_recv_buf = dummy_release_recv_buf;
-}
-
-static void
-dummy_channel_init(DummyChannel *self)
-{
-}
-
-// TODO: red_worker can use this one
-static void dummy_watch_update_mask(const SpiceCoreInterfaceInternal *iface,
-                                    SpiceWatch *watch, int event_mask)
-{
-}
-
-static SpiceWatch *dummy_watch_add(const SpiceCoreInterfaceInternal *iface,
-                                   int fd, int event_mask, SpiceWatchFunc func, void *opaque)
-{
-    return NULL; // apparently allowed?
-}
-
-static void dummy_watch_remove(const SpiceCoreInterfaceInternal *iface, SpiceWatch *watch)
-{
-}
-
-// TODO: actually, since I also use channel_client_dummy, no need for core. Can be NULL
-static const SpiceCoreInterfaceInternal dummy_core = {
-    .watch_update_mask = dummy_watch_update_mask,
-    .watch_add = dummy_watch_add,
-    .watch_remove = dummy_watch_remove,
-};
-
-RedChannel *dummy_channel_new(RedsState *reds, uint32_t type, uint32_t id)
-{
-    return g_object_new(TYPE_DUMMY_CHANNEL,
-                        "spice-server", reds,
-                        "core-interface", &dummy_core,
-                        "channel-type", type,
-                        "id", id,
-                        NULL);
-}
diff --git a/server/dummy-channel.h b/server/dummy-channel.h
deleted file mode 100644
index 9527633..0000000
--- a/server/dummy-channel.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-   Copyright (C) 2009-2015 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-   */
-
-#ifndef __DUMMY_CHANNEL_H__
-#define __DUMMY_CHANNEL_H__
-
-#include <glib-object.h>
-
-#include "red-channel.h"
-
-G_BEGIN_DECLS
-
-// TODO: tmp, for channels that don't use RedChannel yet (e.g., snd channel), but
-// do use the client callbacks. So the channel clients are not connected (the channel doesn't
-// have list of them, but they do have a link to the channel, and the client has a list of them)
-
-#define TYPE_DUMMY_CHANNEL dummy_channel_get_type()
-
-#define DUMMY_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_DUMMY_CHANNEL, DummyChannel))
-#define DUMMY_CHANNEL_CLASS(klass) \
-    (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_DUMMY_CHANNEL, DummyChannelClass))
-#define _IS_DUMMY_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_DUMMY_CHANNEL))
-#define _IS_DUMMY_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_DUMMY_CHANNEL))
-#define DUMMY_CHANNEL_GET_CLASS(obj) \
-    (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_DUMMY_CHANNEL, DummyChannelClass))
-
-typedef struct DummyChannel DummyChannel;
-typedef struct DummyChannelClass DummyChannelClass;
-
-struct DummyChannel
-{
-    RedChannel parent;
-};
-
-struct DummyChannelClass
-{
-    RedChannelClass parent_class;
-};
-
-GType dummy_channel_get_type(void) G_GNUC_CONST;
-
-RedChannel *dummy_channel_new(RedsState *reds, uint32_t type, uint32_t id);
-
-G_END_DECLS
-
-#endif /* __DUMMY_CHANNEL_H__ */
-- 
git-series 0.9.1


More information about the Spice-devel mailing list