summaryrefslogtreecommitdiff
path: root/server/dcc.h
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2019-05-19 22:00:39 +0100
committerFrediano Ziglio <freddy77@gmail.com>2020-05-01 06:58:09 +0100
commit176970f3f18e26ef52f16155bc5fa6edbc60705a (patch)
tree713ca073daafa55d67b6cdbf767b2de31d242112 /server/dcc.h
parent38cd152952968e37d0cc96e95e3e5e47a2f66c2f (diff)
red-channel-client: Remove GObject type
Make all RedChannelClient hierarchy a C++ class. This allows to use virtual methods. Added a normal contructor instead or properties and g_object_new. As we remove GObject conversion macros I added a macro XXX_CAST to create a function to replace the old macro. They will be removed when more type safety is introduced. There's a new SPICE_CXX_GLIB_ALLOCATOR macro in red-common.h. This macro, added to a class define the class allocator allowing to use, in this case, GLib for allocation. This to avoid C++ library dependency and to initialize all structure to 0 (not all fields are manually initialized, will be improved with more encapsulation). Currently the methods are mainly public, access will be modified when more encapsulation (all functions in method) are done. Some classes are now defined in the header, C++ uses access to limit accessibility but for efficiency and type safety/inline and other features require types to be defined in the headers. Some fields were moved from XxxPrivate structure to class, C++ has accessibility. Many destructors are defined as protected to forbid the use of stack, this as these objects uses internal reference counting to have normal pointers. Maybe in the future pointers like std::shared_ptr could be used instead. Reference counting is now implemented very easily using atomic operations. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'server/dcc.h')
-rw-r--r--server/dcc.h42
1 files changed, 18 insertions, 24 deletions
diff --git a/server/dcc.h b/server/dcc.h
index 740829b1..3974d284 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -19,8 +19,6 @@
#ifndef DCC_H_
#define DCC_H_
-#include <glib-object.h>
-
#include "image-encoders.h"
#include "image-cache.h"
#include "pixmap-cache.h"
@@ -29,34 +27,30 @@
G_BEGIN_DECLS
-#define TYPE_DISPLAY_CHANNEL_CLIENT display_channel_client_get_type()
-
-#define DISPLAY_CHANNEL_CLIENT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_DISPLAY_CHANNEL_CLIENT, DisplayChannelClient))
-#define DISPLAY_CHANNEL_CLIENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), TYPE_DISPLAY_CHANNEL_CLIENT, DisplayChannelClientClass))
-#define IS_DISPLAY_CHANNEL_CLIENT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_DISPLAY_CHANNEL_CLIENT))
-#define IS_DISPLAY_CHANNEL_CLIENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_DISPLAY_CHANNEL_CLIENT))
-#define DISPLAY_CHANNEL_CLIENT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_DISPLAY_CHANNEL_CLIENT, DisplayChannelClientClass))
-
+struct DisplayChannel;
struct DisplayChannelClientPrivate;
-struct DisplayChannelClient final: public CommonGraphicsChannelClient
+class DisplayChannelClient final: public CommonGraphicsChannelClient
{
- int is_low_bandwidth;
+protected:
+ ~DisplayChannelClient();
+public:
+ DisplayChannelClient(DisplayChannel *display,
+ RedClient *client, RedStream *stream,
+ RedChannelCapabilities *caps,
+ uint32_t id,
+ SpiceImageCompression image_compression,
+ spice_wan_compression_t jpeg_state,
+ spice_wan_compression_t zlib_glz_state);
+
+ virtual bool config_socket() override;
+ virtual void on_disconnect() override;
+
+ DisplayChannelClientPrivate *priv = nullptr;
- DisplayChannelClientPrivate *priv;
-};
-
-struct DisplayChannelClientClass {
- CommonGraphicsChannelClientClass parent_class;
+ int is_low_bandwidth;
};
-GType display_channel_client_get_type(void) G_GNUC_CONST;
-
#define PALETTE_CACHE_HASH_SHIFT 8
#define PALETTE_CACHE_HASH_SIZE (1 << PALETTE_CACHE_HASH_SHIFT)
#define PALETTE_CACHE_HASH_MASK (PALETTE_CACHE_HASH_SIZE - 1)