Commit Graph

3713 Commits

Author SHA1 Message Date
Frediano Ziglio
20408491fa video-stream: Move some structure definition to use more RedPipeItemNum
Users of structures needs enumeration definitions too.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:25 +01:00
Frediano Ziglio
228db683ba dcc: Move some structure definition to use more RedPipeItemNum
Users of structures needs enumeration definitions too.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:22 +01:00
Frediano Ziglio
f4bc555b62 dcc: Remove red_drawable_pipe_item_new, use constructor
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:20 +01:00
Frediano Ziglio
fe9ad0d5ba red-pipe-item: Remove red_pipe_item_(un)ref
Most code uses now red::shared_ptr

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:18 +01:00
Frediano Ziglio
8a0d9369bc char-device: Use list and shared pointers for RedCharDeviceClient queue
Automatically handle ownership avoiding using red_pipe_item_(un)ref.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:16 +01:00
Frediano Ziglio
76fe97a157 char-device: Make RedCharDeviceClient a proper class
Provide constructor and destructor, use new/delete.
This allows additional fields to be properly initialized if needed.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:12 +01:00
Frediano Ziglio
39efd79d53 spicevmc: Simplify code to compress messages
Remove some conditional compilation.
Make try_compress_lz4 return success or failure and change the
messages making easier to read result from try_compress_lz4.
Remove "n" parameter from try_compress_lz4, use message size
instead.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:10 +01:00
Frediano Ziglio
dd9b78fd78 Use smart pointers for RedPipeItem
Reduces usage of manual reference counting.
Avoids usage of new and use instead red::make_shared to both
create and own pipe items.
Use move semantic to reduce useless copies.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:08 +01:00
Frediano Ziglio
22fc6a48e6 red-channel-client: Change GQueue into a std::list
Starts using smart pointers in the queue.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:06 +01:00
Frediano Ziglio
586e45f185 cursor-channel: Remove cursor_pipe_item_new function, use constructor
This is a preparation to move to smart pointers.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:04 +01:00
Frediano Ziglio
bd6d043152 Remove some red_pipe_item_(un)ref usage
Replace with smart pointers instead.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:48:02 +01:00
Frediano Ziglio
93405ae3c6 Automatically release some pipe item resources
Now that items are managed by constructors/destructors avoid some
manual releases.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:59 +01:00
Frediano Ziglio
fa404f73d8 main-channel-client: Pass directly a RedPipeItem from VDI
Provides a base class to allows RedCharDeviceVDIPort to pass
a RedPipeItem to MainChannelClient instead of having to wrap
into another item.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:58 +01:00
Frediano Ziglio
d55c8837f8 red-pipe-item: Add and use a small utility class for easier initialization
Most of the times each class has an associated constant so
allows to be able to define the constant at declaration time.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:55 +01:00
Frediano Ziglio
a30df693cf red-pipe-item: Use inheritance on RedPipeItem
This allows to:
- reuse reference counting;
- avoid having to manually call g_free to release item memory;
- assure item is initialized;
- avoids some manual casts.

It will also allows to use smart pointers.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:53 +01:00
Frediano Ziglio
45e964dc5a red-pipe-item: Better encapsulate marshaller_unref_pipe_item
To avoid memory errors marshaller_unref_pipe_item should be
matched with a previous call to red_pipe_item_ref.
This is correctly done but to reduce the possibility of breaking
this rule move both referencing and unreferencing into a new
RedPipeItem::add_to_marshaller method.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-13 19:47:45 +01:00
Frediano Ziglio
65d7d24f21 test-gst: Handle better errors from callback
Exit more cleanly, otherwise sometimes some strange failures
occurs. This is due to the fact that a thread is cleaning up
everything while the others are still working.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-12 20:05:30 +01:00
Frediano Ziglio
1cd063d5fe test-gst: Returns specific error if encoder is not supported
This allows to detect missing required system packages.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-12 20:04:34 +01:00
Frediano Ziglio
6a230f3609 smartcard: Remove usage of tokens
RedCharDeviceSmartcard is not using token handling (which is designed
only for VDAgent) so push directly to client.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-07-03 10:47:34 +01:00
Frediano Ziglio
d60cef04e9 inputs-channel-client: Update RECEIVE_BUF_SIZE
For historical reasons this was computed using VDAgent details.
Provide a more suitable and simple constant.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-02 21:17:58 +01:00
Frediano Ziglio
d5a0e9d0ef video-stream: Remove only assigned "fps" field
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-02 21:11:47 +01:00
Frediano Ziglio
f028c9b787 event-loop: Avoid useless cast
"func" is already a "SpiceWatchFunc", remove the first cast to
the same type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-29 09:14:25 +01:00
Frediano Ziglio
24c8692e5f Remove useless "common/ring.h" include
Not used directly by these source files.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-29 08:56:36 +01:00
Frediano Ziglio
0acf650afa reds: Remove not used preprocessor macros
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-27 06:29:53 +01:00
Frediano Ziglio
7f37f0bf82 gstreamer-encoder: Propagate correctly VideoEncodeResults
Do not use "int" to return VideoEncodeResults result type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-26 10:07:28 +01:00
Frediano Ziglio
4a34111711 reds: Avoid a "end" label just to free password
"password" is pretty small, allocate on stack directly.
RSA is currently 1024 bits, that is more or less 128 bytes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-06-26 10:06:40 +01:00
Frediano Ziglio
ba065d1bdf char-device: Update documentation reference
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:09:34 +01:00
Frediano Ziglio
3868e13bf3 video-encoder: Fix parameter name
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:09:32 +01:00
Frediano Ziglio
69640d1054 reds: Remove useless label and goto statements
Not needed anymore.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Francesco Giudici <fgiudici@redhat.com>
2020-06-25 16:09:25 +01:00
Frediano Ziglio
364a1fde82 video-stream: Better check for value from environment
Do not allow negative values from "SPICE_BIT_RATE".

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:42:54 +01:00
Frediano Ziglio
b174e757fa Enable -Wshadow warning
This flag allows to catch variables or arguments hiding other
variables or attributes.
It helps avoiding some possible mistakes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:18:59 +01:00
Frediano Ziglio
9f4fbc2a08 red-channel-client: Initialise properly "monitor_latency"
This is a regression of commit 176970f3f1
(cfr "red-channel-client: Remove GObject type").

Attribute was not initialised.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:18:59 +01:00
Frediano Ziglio
4043757754 utils: Change comments to generate Doxygen output
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:12:37 +01:00
Frediano Ziglio
4c25ce1877 dispatcher: Update documentation
Move to Doxygen (output was not meant to generate output
automatically).
Update some part that were outdated.
Typo messsage_type -> message_type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:12:37 +01:00
Frediano Ziglio
dc65afb03a common-graphics-channel: Use marshaller structure for RedCachePipeItem
Allows to simplify a bit marshalling code in both CursorChannel
and DisplayChannel as they use the same marshalling structure.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 13:24:06 +01:00
Frediano Ziglio
e7cdaa668d cache-item: Move RedCachePipeItem declaration to common-graphics-channel.h
The pipe items are meant to be used by channel clients, so move
declaration where channel clients is.
This item is used by both CursorChannelClient and DisplayChannelClient
so the CommonGraphicsChannel is the proper place.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 13:24:06 +01:00
Frediano Ziglio
255f6b2fd3 cache-item: Simplify structure used for just memory optimization
RedCacheItem was using an union to reuse cache item memory
as a pipe item to release that specific cache item.
Instead of spreading that structure everywhere move the specific
optimization all in cache-item.tmpl.cpp.
This make also code less cluttered.
Add some comment on specific code.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 13:24:06 +01:00
Frediano Ziglio
a10e496c46 char-device: Remove "sin" parameter from read_one_msg_from_device
Not much used, can be retrieved from the class if needed.

There are some apparent test removal on reds.cpp.
The test "if (!reds->vdagent)" apparently disappeared but it's included in
the while.
reds->agent_dev cannot be NULL as SPICE server allows only one agent and we
are into a member of an object so it must be reds->agent_dev.get() == this.
As there's only an agent and as the interface (sin) is extracted from that
agent it must be reds->agent_dev.get() == sin->st and either reds->vdagent
== sin or reds->vdagent == NULL.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 12:49:43 +01:00
Frediano Ziglio
479a1a74a2 Reuse RedCharDevice::read
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 12:49:41 +01:00
Frediano Ziglio
66dacecda9 char-device: Add a read method to simplify reading data
Avoid to pass throught SpiceCharDeviceInterface.
When data is read from device the device get marked as active.
This is coherent with what is done in red_char_device_read_from_device.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 12:49:26 +01:00
Frediano Ziglio
3c8037d39f Remove DISPLAY_CHANNEL cast reusing DCC_TO_DC
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-23 10:39:08 +01:00
Frediano Ziglio
d8dccabb7d red-channel: Simplify some preprocessor macros
Just pass rest of the arguments.
Removes some extra semicolon.
This change also remove a specific GCC extension.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-19 14:24:48 +01:00
Frediano Ziglio
43c7cb167e sound: Better management of PersistentPipeItem life
The handling of that specific pipe item reference counting
was a bit confusing. In particular every time before adding to
the queue the item was reset causing the reference counter to
be 1 however it was not sure that the item was not still referenced
when added again to the queue.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-19 14:22:23 +01:00
Frediano Ziglio
66ee75a810 sound: Do not depend on pipe item remove to detect data message sent
The assumption is a bit fragile as code could change adding
additional references to the pipe item.
Instead use marshaller cleanup routines, this surely will be
triggered when the message is queued to the network.
This also causes some additional cleanups.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-19 14:22:17 +01:00
Frediano Ziglio
0f2c28a63b test-display-base: Reuse SPICE_GNUC_NORETURN macro
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-19 13:34:55 +01:00
Frediano Ziglio
edebd1cc74 utils: Remove shared_ptr::release
It's never used.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-19 10:56:05 +01:00
Uri Lublin
7edd55d95b image_encoders_free_glz_drawables: enc is never NULL
It is called from 2 places.
1. display-channel.cpp:
   dcc_get_encoders always returns a non-null pointer.
2. image-encoders.cpp: image_encoders_release_glz
   <- image_encoders_free (where enc is not checked)
   <- dcc.c:image_encoders_free
   where non-null pointer is passed.

Signed-off-by: Uri Lublin <uril@redhat.com>
2020-06-19 10:50:58 +01:00
Frediano Ziglio
8875e79c7c reds: Use socket_close instead of close
socket_close is mapped to close under Unix but under Windows
you should call closesocket instead so call socket_close which
will map to the proper close function on both environments.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-06-18 16:57:50 +01:00
Uri Lublin
21323c8b6f glz_dictionary_window_add_image: error out when failed to alloc an image
__glz_dictionary_window_alloc_image may return NULL.
Check that the image was created successfully and if not
then error out using dict->cur_usr->error like it's done
few lines below.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:53:22 +01:00
Uri Lublin
031ab732dd glz_enc_dictionary_restore: return NULL upon failure
glz_enc_dictionary_create may return NULL.
glz_enc_dictionary_restore itself may return NULL so
add one more check.

Found-by: gcc (10) analyzer

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:53:19 +01:00
Uri Lublin
954eabaeb7 test-websocket: check setsockopt return value
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:48:25 +01:00
Frediano Ziglio
982d14dd69 dispatcher: Move some private functions to DispatcherPrivate
Reduce declaration in the header.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-17 10:59:38 +02:00
Frediano Ziglio
b8f4d7d2c7 websocket: Fix possible integer overflow
The shift of a uint_8 number by a number > 32 causes an overflow.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-06-16 15:17:06 +01:00
Frediano Ziglio
70347f3175 dcc: Remove unused result from dcc_add_surface_area_image
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-16 11:27:53 +01:00
Frediano Ziglio
87b6b1993e sound: Make receive_buf field private
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-14 14:31:32 +01:00
Frediano Ziglio
87270d3037 basic-event-loop: Remove useless "ring.h" include
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-10 16:52:32 +01:00
Frediano Ziglio
4466230a85 red-parse-qxl: Add a note on red_get_cursor
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-10 10:13:20 +01:00
Frediano Ziglio
f03d094942 reds: Remove usage of "this"
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-08 10:00:43 +01:00
Frediano Ziglio
3c74601652 main-channel-client: Make some members const
Also use a more explicit return type.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-08 09:05:28 +01:00
Frediano Ziglio
64435c8934 main-channel: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-07 20:51:07 +01:00
Frediano Ziglio
39c513b604 red-common: Fix typo in comment
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@redhat.com>
2020-06-04 11:07:32 +02:00
Frediano Ziglio
6c900f0442 inputs-channel-client: Avoid attribute shadowing
This regression was caused by commit
"2ffa7d00c60808e2f640df9bc9b5d62598455588"
(cfr "Improve encapsulation for InputsChannelClient")

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-06-04 09:34:18 +01:00
Frediano Ziglio
853a6df224 Avoid useless SPICE_CXX_GLIB_ALLOCATOR usage
Behaviour was already inherited.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-06-04 09:34:12 +01:00
Frediano Ziglio
4dbc6dae01 cursor-channel: Turn cursor_channel_reset into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:44 +01:00
Frediano Ziglio
e044c5bd50 cursor-channel: Turn cursor_channel_set_mouse_mode into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:42 +01:00
Frediano Ziglio
f30d35a8c7 cursor-channel: Turn cursor_channel_do_init into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:41 +01:00
Frediano Ziglio
0528fadff3 cursor-channel: Turn cursor_channel_process_cmd into method
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:38 +01:00
Frediano Ziglio
aa0dddde0f sound: Move define "trick" to spice-wrapped.h header
The spice-wrapped.h was introduced to deal with such tricks
in the code and limit them to a single place.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:37:36 +01:00
Frediano Ziglio
bd17418f9e char-device: Make RedCharDevice::write_retry private
Not meant to be called externally.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:36:11 +01:00
Frediano Ziglio
19f3406db6 spicevmc: Cleanup some "this" usage
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:34:03 +01:00
Frediano Ziglio
fc55e9fa27 image-encoders: Fix compile warnings for ARM7 platform
Compiling under ARM7 GCC compiler report these warning:

image-encoders.cpp: In function 'int lz4_usr_more_space(Lz4EncoderUsrContext*, uint8_t**)':
image-encoders.cpp:261:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
  261 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
      |                                ^~~~~~~~~~~~~~
image-encoders.cpp: In function 'int lz4_usr_more_lines(Lz4EncoderUsrContext*, uint8_t**)':
image-encoders.cpp:329:32: error: cast from 'Lz4EncoderUsrContext*' to 'Lz4Data*' increases required alignment of target type [-Werror=cast-align]
  329 |     EncoderData *usr_data = &(((Lz4Data *)usr)->data);
      |                                ^~~~~~~~~~~~~~

In all other occurrences of these cast we are already using
SPICE_CONTAINEROF.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Rope <jrope@redhat.com>
2020-05-28 14:32:41 +01:00
Frediano Ziglio
88c25a18de Fix compatibility with TCP sockets and Darwin
Using socket pairs and trying to set a TCP level option on the
socket setsockopt returns EINVAL error and not ENOTSUP as
expected.
Check this case and handle as ENOTSUP (ignoring it).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
4f82cec197 Fix compatibility with ENOTSUP and Darwin
Darwin uses also the constant EOPNOTSUPP for the same reasons.
In some versions EOPNOTSUPP is defined as ENOTSUP.
Check both values, not only ENOTSUP.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
90453ddf06 Fix compatibility with TCP_KEEPIDLE and Darwin
Darwin uses for the same setting the TCP_KEEPALIVE option.
Use TCP_KEEPALIVE instead of TCP_KEEPIDLE for Darwin.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
6684a3b5ef Fix compatibility with pthread_setname_np and Darwin
On Darwin pthread_setname_np accepts only an argument and
set current thread name.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Frediano Ziglio
ee4cf6a07c Fix compatibility with MSG_NOSIGNAL and Darwin
Darwin does not have MSG_NOSIGNAL but allows to set a SO_NOSIGPIPE
option to disable sending SIGPIPE writing to closed socket.
Note that *BSD has the SO_NOSIGPIPE option but does not affect all
write calls so instead continue to use MSG_NOSIGNAL instead on
that systems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:01:47 +01:00
Kevin Pouget
2d971c6ec0 server/meson.build: fix bug when project version is unknown
When `build-aux/git-version-gen` is not able to find the project
version (no git tags and no `.tarball-version`), it returns 'UNKNOWN'
(instead of the project version like `0.14.3.185-15b1`).

This `UNKNOWN` value fails `meson build` command:

    server/meson.build:8:0: ERROR: Index 1 out of bounds of array of size 1.

With this patch, we set a default major/minor/micro value when the
actual version is unknown. This is the same as the `autoconf`
historical behavior.

Fixes #41.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-19 10:49:43 +02:00
Gilmar Santos Jr
15b1e2a3bb red-stream: WebDAV doesn't work when SASL is active
When SASL is active, if a read request is made and SASL buffer contains some
data (but not enough to fulfill the request), upon return the taken data from
the buffer is not accounted for and hence part of the message gets discarded.

red_stream_sasl_read function takes available data from sasl buffer and returns
if it's enough. If it's not, nbyte is decremented and buf pointer is
incremented to account for the taken data (if any). Then it tries to get more
data from the socket and decode it.

Suppose there was some data in the sasl buffer, but not enough. Then the socket
is not readable (EAGAIN, EINTR, whatever) or the new data isn't enough for
sasl_decode (hence decodedlen == 0). In both cases the function returns as if
no data was read, but it took some data from sasl buffer. This data is lost and
from this point on the communication ceases on the channel (eventually new data
is read, but messages are corrupt without the parts previously discarded).

On the other hand, if some data is read from sasl buffer and everything else
works fine, the output buffer contains all the data, but the count returned
only inform the caller about the newly read data (which causes the similar
effect of discarding part of the message).

Fixes: https://gitlab.freedesktop.org/spice/spice/-/issues/40

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-11 19:09:15 +01:00
Frediano Ziglio
21f9d25aa8 Update filenames in comments
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-11 08:14:47 +01:00
Frediano Ziglio
a21e66b7b3 test-dispatcher: Test dispatcher
Test that dispatcher work.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-05 05:15:43 +01:00
Frediano Ziglio
09e01153b7 utils: Fix typo in comment 2020-05-05 05:14:53 +01:00
Frediano Ziglio
62801ad9ac char-device: Remove obsolete declaration
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-05 05:14:53 +01:00
Frediano Ziglio
851b136bb4 sound: Make functions exported not visible
Allows the compiler to do some additional optimizations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
46cda65123 build: Remove GObject dependency
Not used anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
31f0ce2086 Avoids registering type just to get the nick of an enum value
We don't use anymore GObject parameters so avoid having to
register enum values to GType system to use them.
We just need to get the nick value of the enum values for
debug purposes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
fd06625ba1 red-stream-device: Better encapsulation
Remove all members public, set correct access and create
missing methods.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
1e9205a3b8 char-device: Remove GObject from RedCharDevice
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f6f998004b Wrap spice.h in order to do some adjustment
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
be5bda4d4f utils: Add red::weak_ptr and red::shared_ptr_counted_weak
Implements weak pointers and helper to implement them.
They will be used for RedCharDevice.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2b9e1dcd55 dispatcher: Reuse base reference counting for Dispatcher hierararchy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
724f23e4bd Use red::shared_ptr_counted for RedChannelClient
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
597461e443 Add and use red::make_shared
Allow to create an object already contained in a shared pointer
to avoid having not owned objects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
5126e38367 Use shared_ptr implementation to handle reference counting
This allows to make easier the management of owning.
Reference counting is automatically updated based on shared
pointers modification.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
bf04d7d721 utils: Very skinny share_ptr implementation for our references
It will be used to refactor reference counting code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
54c0830919 input-channels: Improve encapsulation
Update member access to limit it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
b28db35af5 reds: Make mig_wait_disconnect_clients a std::forward_list
In the meanwhile remove a leak on the program.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
9dcf937767 reds: Move qxl_instances to red::safe_list
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
454b18fcae char-device: Convert some static functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
1411383483 char-device: Automatically convert functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
5f7aaf2a9a char-device: Remove define trick, won't work on C++
C++ check parameter type, not founding the functions at
link time.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
26e6d15551 char-device: Prepare to move functions to methods
Move structure declaration at the end.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2b11c917dc Do not use GError to just return an error string
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
4233df686e reds: Move clients to safe_list
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
ec66702526 reds: Use red::safe_list instead of GList
Use an utility list.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
767a9caded Allow to compile without C++ library
Provide a suitable allocator using GLib

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
fe0298a290 safe-list: Add a class to implement a list with safe iterators
The reason to not using STL is that our code from how was designed requires
the iterator to be safe to the delete of the element pointed by the iterator.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
350646608d red-channel: Small simplification
Use std::max to make code smaller

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
ab7486a9e8 main-channel-client: Automatically convert
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
9fd105e925 main-channel: Automatic convert functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
fef97b14e5 red-client: Make RedClient pure C++
Remove GObject.
Add access protection.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
cc86a7fb53 red-client: Automatically convert functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
43c6bf91b7 reds: Remove a weak pointer usage
RedCharDevice can all be removed just calling unref, beside
the agent that needs special threatment.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f4aefa728e Remove GObject from Dispatcher hierarchy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f680cc7870 dispatcher: Add a more safe dispatcher_send_message_custom version
Use a template to wrap the other dispatcher_send_message_custom
avoiding having to pass a void* opaque and extract payload size
from passed type.
Will be used more by next commit when Dispatchers are turned into
C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
164a333f99 Define and use (un)ref
Avoids g_object_(un)ref.
This in preparation to remove GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
75679dc95d dispatcher: Use IS-A relationship for Dispatcher hierarchy
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
ea0d056bb7 char-device: Define and use (un)ref
Prepare to remove GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
9e5781e81c char-device: Do not use signals just to call our routine
The only notify was done from the same file.
All other read of the property were replaced.
Preparing to remove GObject.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
13f27ab8e9 sound: Make on_message_done a virtual function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
16f89a80fa inputs-channel: Move some methods to protected
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
4372c0a3ff inputs-channels-client: Call pipe_add_init from InputsChannelClient::init
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
411cb26301 main-channel: Remove some casts
Add MainChannelClient::get_channel to avoid to manually cast
to derived type.
Pass objects as MainChannelClient instead of RedChannelClient if
we need a MainChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2d865a78da red-channel-client: Make start_connectivity_monitoring protected
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
aecbdd9e5b red-channel-client: Make handle_message protected
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
9ae11a3545 red-channel-client: Move some methods to a protected section
Reduce visibility and increase encapsulation.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f42a20c508 Improve CommonGraphicsChannel encapsulation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2bf72a5ce2 stream-channel: More incapsulation for StreamChannel
Put all functions into methods.
Separate public/private part.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
6444fd6cfe inputs-channel: More C++ on InputsChannel
Removed ugly converts putting in InputsChannelClient::get_channel().
Removed silly accessors.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
9df07e3f20 inputs-channel: Make InputsChannel more encapsulated
Put functions into methods.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
104aa6e1af Remove GObject from RedChannel
The patch seems pretty huge but mainly are mechanical steps:
- remove GObject declarations
- do not inherit from GObject
- add SPICE_CXX_GLIB_ALLOCATOR to avoid using C++ allocators
- CLASS_init and CLASS_constructor code goes into C++ constructor
- CLASS_dispose and CLASS_finalize code goes into C++ destructor
- g_object_new is replaced by new operator
- class members goes into virtual methods
- class parameters became argument to constructor
- use push-visibility.h and pop-visibility.h to limit visibility
- temporary use XXX_CAST for old GObject casts, they will
  be replaced
- g_object_get is replaced by accessors

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
3136a11f39 cursor-channel-client: Use covariance to avoid some casts
CursorChannelClient knows that the channel is a CursorChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
0807ccea59 cursor-channel-client: Move all public functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
435ea33540 Reduce C++ symbols visibility
This allows the compiler to do some more optimisations on the
produced binary.
To allows possible future portability include header/footer in
some helper header files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
bd4b1caeb8 Use template to make adding timers/watches safer
Instead of forcibly cast functions cast only if data pointer and
function pointers match. This also allows to remove dangerous
casts all over the place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
fdedbe9e94 dcc-send: Avoid to call DISPLAY_CHANNEL_CLIENT to cast
It's useless now, it's always a DisplayChannelClient, pass the
right type.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
cf51158811 red-channel-client: Move handle_migrate_data_get_serial as a virtual function
Virtual functions cannot be null so use a return value instead
and return the serial using a reference.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
d5ea93d3a8 Make disconnect a virtual function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
70367fd460 red-channel-client: Move handle_migrate_flush_mark as a virtual function
Note that the return value was removed as not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
28a4fc5a10 red-channel-client: Move migrate as virtual method
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2b04f644f6 red-channel-client: Move handle_migrate_data as virtual function
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2ffa7d00c6 inputs-channel-client: Improve encapsulation for InputsChannelClient
Move most inputs_channel_client_* functions inside the class.
This also helps preparing handle_migrate_data to be virtual.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
669df4fb38 red-channel-client: Make send_item a virtual function
The items are send from RedChannelClient so move the callback
to a virtual function in RedChannelClient instead of RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
851696a645 red-channel-client: Preparation, rename send_item to avoid clash
We will use this name for a virtual function from RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
7720039ee0 red-channel-client: Move handle_message as a virtual function
The messages coming are from the client so it's a better place
to be in RedChannelClient instead of RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
1ac616c4a3 Use utils.hpp for allocating/removing priv field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
b86f6e9a53 utils: Add red::unique_ptr
red::unique_link will be used to manage "priv" fields.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
61affed2a2 red-channel-client: Better private initialisation
Initialise RedChannelClientPrivate fields from the new
constructor instead from RedChannelClient.
Also change some fields to constants (actually many of them).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2023bb3767 red-channel-client: Remove "self"
It was left unchanged to reduce diff.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
d8e5838054 red-channel-client: Move all functions to methods
Improve incapsulation.
The only not mechanical change is the addition of timer_add to
make timer settings a bit more type safe.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
78193dff16 red-channel-capabilities: Removed unused stuff from RedChannelCapabilities
Not used anymore

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
176970f3f1 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>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
38cd152952 automake: Link with C++ linker
If automake sees no C++ files in the source it assumes have to
use C linker settings not linking C++ library.
This was not a problem as code did not use C++ libraries but next
patch will use pure virtual function call.
It could be provided but as later we will use RTTI use C++ library.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
6e14b6bc99 Reimplement video-codes update with no GObject signals
This is in preparation to remove GObjects, as signals require them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
69fbef6fff Add RedChannel::(un)ref for reference counting and use them
This will reduce code to avoid gobject and make code less
type unsafe.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
3a05720eaa Introduce some utilities for C++
red::add_ref will be used to increment a reference counter
and return the object pointer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
77af39d6b5 Update header style
Avoid typedef useless in C++.
Remove useless forward declarations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
8671f659f4 Constify some methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
552c26b0a8 Move all red_channel_* functions in header as methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
874e745088 Move all red_channel_client_* functions in header as methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2b078c44d7 Remove COMMON_GRAPHICS_CHANNEL where possible
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
08fab74cd7 Avoid useless downcast to RedChannelClient or RedChannel
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
3720e5a686 Remove RED_CHANNEL where possible
Used Coccinelle:

@@
expression E;
@@

-RED_CHANNEL(E)
+E

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e204677a43 Remove RED_CHANNEL_CLIENT where possible
Used Coccinelle:

@@
expression E;
@@

-RED_CHANNEL_CLIENT(E)
+E

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e6e6ded681 Use C++ IS-A relationship for RedChannelClient and RedChannel
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e788e6e476 Remove conversion warnings
Use casts to avoid all that warning.
They should go away once you use more type safe types.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
17a7251e56 Remove warnings about combining GParamFlags types
C++ thread enum a bit more safely than C not allowing to combine
them. Avoid warning combining them and passing to functions
expecting enums.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
d8b1519c35 Remove -Wliteral-suffix warnings
Avoids warnings like

main-channel-client.cpp:538:27: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
    "net test: latency %f ms, bitrate %"G_GUINT64_FORMAT" bps (%f Mbps)%s",
    ^

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
2561f1db94 Avoid conversion warnings calling Windows sockets
Some Windows socket functions accepts char* instead of classic void*
causing some warning. Force the cast.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e54224730e Change string check
In C++ GLib add function declaration (function parameters).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
6db395dc74 Make sure empty structure are ABI compatible
Empty structure are not really portable however adding
an zero size array seems to be the way to have a zero
size structure portably.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
2f7474427b Do not leave not initialized fields in the middle
Some old GNU compilers does not allow this (like CentOS 7 one)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
238f53d702 Declare public exported functions as C
Allows to link externally from a C program.
This will allow C++ code to respect C ABI.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
505b90e179 Avoid double definitions
In C++ that code would define variable twice giving error.
Define only one.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
48adb67c13 Fix order of initializers
C++ complaints if they are not in the order of
declaration.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
81c04623ea Avoid to use reserved C++ keywords
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
7b36374170 Adjust some warnings
Remove -Werror and add -fpermissive, this will allow to compile C code with
a GNU C++ compiler.

Ignore warnings as our code use some feature like empty arrays.

Remove warnings not available in C++.

Bump GLIB_VERSION_MAX_ALLOWED to reduce the warning, looks like the
GLib headers for C++ are not able to handle them correctly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
c4b4b967fb Allows C++ to be used in sources
Enable C++ compiler

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
bea4ad66b9 char-device: Remove pool handling
Memory pool handling does not give much but make code more complex.
Current implementation tends to only increasing buffer sizes
leading to potential cases where most of the allocated memory is
not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
1fbb58ac52 Fix compatibility with SOL_TCP and Darwin
Under Darwin SOL_TCP is not defined. Use IPPROTO_TCP instead.
Other part of SPICE server uses this constant instead already.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-20 15:17:59 +01:00
Frediano Ziglio
717ed19a8b Constify display_channel_update_monitors_config config parameter
No reason to change the structure.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-04-20 14:47:34 +01:00
Frediano Ziglio
01bbdbd281 red-qxl: Fix spice_qxl_update_area function indentation
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-04-17 18:59:55 +01:00
Frediano Ziglio
974692bda1 spice-qxl: Fix typo in callback name and remove obsolete parameter
attache_worker was always spelled wrongly.
Use anonymous union (standard feature already used in different
code in SPICE) to have an aliased attached_worker function.
Also removed a parameter from this new callback and deprecate
the old.
Due to C ABI removing a parameter is not an issue,
red-qxl.c:red_qxl_attach_worker will continue to pass the parameter,
new code will ignore, old code will receive it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-16 11:08:14 +01:00
Frediano Ziglio
6826487237 red-qxl: Avoid function that just call another static function
Inline the function directly, avoid useless function and developers
having to go up and down the code just to understand what these
function do.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-16 11:08:14 +01:00
Frediano Ziglio
6aa1a17c69 spice-qxl: Remove QXLWorker definition
It was made obsolete more than 6 years ago by

  commit fe0941fb02
  Author: Marc-André Lureau <marcandre.lureau@gmail.com>
  Date:   Thu Oct 3 22:52:38 2013 +0200

      server: mark deprecated symbols

For compatibility with spice_replay_next_cmd pass a QXLInstance
pointer. For more information see comment on
red-qxl.c:red_qxl_attach_worker.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-16 11:08:13 +01:00
Frediano Ziglio
2f130edfdd test-display-base: Remove only written "qxl_worker" from Test
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-13 15:55:11 +01:00
James Le Cuirot
f00224a094 build: Use Meson's pkgconfig module to generate the .pc file
The existing .pc file had the wrong dependencies for Windows and was
missing the optional private dependencies for static linking.

Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-08 18:57:52 +01:00
Frediano Ziglio
94a4578c87 Set SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION in RedChannel
Is set in any case, but do it once instead of every time
one client connects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-08 07:42:47 +01:00
Frediano Ziglio
595132dca8 ci: Fix for test-set-ticket leak detection
This suppression was present in former glib.supp version however
the suppression in glib.supp was updated to only catch "reachable"
leaks.
In early stages and few objects the leak could be detected as
"possible".

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-03 14:57:25 +01:00
Frediano Ziglio
aa199e6bc6 test-set-ticket: Test we can set the ticket before spice_server_init
Program should not crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-03 08:49:20 +01:00
Frediano Ziglio
f77f7d74a1 test-record: Fix a race condition running the test
This could happen if the machine is pretty busy.
I saw intermittent failures on CI and it happened on my
machine also while doing other batch job.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-03 08:48:43 +01:00
Frediano Ziglio
9ea93ab52b spicevmc: Check capabilities of the only possible client
RedVmcChannel can have only one client so check directly it
(the RedChannel version just iterate all clients).
Even if the channel would support multiple clients in this case
we would need to check only the one we are sending the message to.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-04-01 09:20:00 +01:00
Frediano Ziglio
948ec8b81b dispatcher: Move thread_id field from Dispatcher to MainDispatcher
Dispatcher is just storing the thead_id for MainDispatcher,
move thread_if to MainDispatcher to avoid useless field and API.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-26 14:36:14 +00:00
Frediano Ziglio
137ae60c9a build: Respect Meson's default_library option
Distributions like to be in control of this.
From a patch from  James Le Cuirot.

Instead of always build both shared and static libraries for
SPICE server (static is used for the tests) compile library
as user requested. In case we need the static library for tests
(which now can be disabled) create a static library extracting
objects from shared library.
This also fixes the problem that Meson installed the static
library even if not requested and just used for tests.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2020-03-26 14:35:23 +00:00
Frediano Ziglio
832ab9709c build: Fix a warning for Autoconf
Remove this warning:

server/Makefile.am:5: warning: SUBDIRS was already defined in condition TRUE, which includes condition ENABLE_TESTS ...
server/Makefile.am:2: ... 'SUBDIRS' previously defined here

This was caused by the recent commit 38c7964d53
("build: Make building the test binaries optional under Autoconf")

This problems was also causing some issues as "noinst_PROGRAMS" target
were not compiled as expected.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-26 14:11:38 +00:00
Frediano Ziglio
38c7964d53 build: Make building the test binaries optional under Autoconf
Following similar change for Meson.
Allow to save some time packaging and some dependencies.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-26 09:10:39 +00:00
James Le Cuirot
7a2b915551 build: Make building the test binaries optional under Meson
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-24 08:38:49 +00:00
Frediano Ziglio
271dd5de41 video-encoder: Use enumeration for encode_frame result type
Better clear the result type instead of a generic "int".

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-03-24 08:38:05 +00:00
Victor Toso
4194659c98 sound: default to Opus 48000 Hz
As celt's default 44100 Hz is deprecated.
Related: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 15:33:23 +00:00
Victor Toso
9136c639a2 sound: remove celt support
Follow up of spice-protocol's deprecation of celt mode.
See: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-03-17 15:33:20 +00:00