red-channel-client: Remove GObject type

Enterprise / Virtualization / SPICE - Frediano Ziglio [redhat.com] - 1 May 2020 05:58 EDT

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.

176970f3 red-channel-client: Remove GObject type
server/common-graphics-channel.cpp | 50 +----
server/common-graphics-channel.h | 37 +---
server/cursor-channel-client.cpp | 66 +++----
server/cursor-channel-client.h | 34 +---
server/cursor-channel.cpp | 4 +-
server/dcc-private.h | 16 +-
server/dcc-send.cpp | 3 +
server/dcc.cpp | 206 +++++----------------
server/dcc.h | 42 ++---
server/display-channel.cpp | 2 +
server/inputs-channel-client.cpp | 87 ++-------
server/inputs-channel-client.h | 33 ++--
server/inputs-channel.cpp | 2 +
server/main-channel-client.cpp | 160 +++++-----------
server/main-channel-client.h | 37 ++--
server/main-channel.cpp | 2 +
server/red-channel-client.cpp | 281 +++++-----------------------
server/red-channel-client.h | 49 +++--
server/red-common.h | 20 ++
server/smartcard-channel-client.cpp | 129 +++++--------
server/smartcard-channel-client.h | 38 ++--
server/smartcard.cpp | 2 +
server/sound.cpp | 355 +++++++++++++-----------------------
server/spicevmc.cpp | 72 ++------
server/stream-channel.cpp | 105 +++--------
server/tests/test-channel.cpp | 47 +----
26 files changed, 589 insertions(+), 1290 deletions(-)

Upstream: cgit.freedesktop.org


  • Share