Commit Graph

2167 Commits

Author SHA1 Message Date
Frediano Ziglio
6d4db4f0bf Base FOREACH_DCC on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:24 +01:00
Frediano Ziglio
9b5f93d1a7 Base FOREACH_CLIENT on GLIST_FOREACH
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:22 +01:00
Frediano Ziglio
3fa2f12c1f Use proper FOREACH_DCC instead of FOREACH_CLIENT
FOREACH_DCC should be more DisplayChannel related.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:20 +01:00
Frediano Ziglio
545ba23e18 RedChannel: Use more FOREACH_CLIENT macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:18 +01:00
Frediano Ziglio
eabafbd09f RedChannel: Add FOREACH_CHANNEL_CLIENT and use it to iterate
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:14 +01:00
Frediano Ziglio
f1d593b025 Introduce some macros to simplify iteration on GList
Noting that coding by hand these loop introduced some regression
I'm trying to introduce back from macros.
Before trying something harder to make possible to bind the type of
the content I'm trying some simple macro as were before.
I added the type to avoid some blindly void* casts.
Also the GListIter is introduced to avoid the possibility to exchange
easily some parameters.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:42:08 +01:00
Frediano Ziglio
54fa96f6eb Use spice_realloc instead of manually code it
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:34:53 +01:00
Frediano Ziglio
30184bb7fb Remove only set serial field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-09-21 16:32:08 +01:00
Frediano Ziglio
9481af181d Simplify send_free_list
The check for free_list->wait.header.wait_count was always true.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-09-20 13:10:52 +01:00
Frediano Ziglio
eebc89b85b Revert if to make code more readable
Keep all code to send SPICE_MSG_LIST together.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2016-09-20 13:10:39 +01:00
Jonathon Jongsma
8f9fd3a826 Use and introduce channel client cast macros
In anticipation of porting to GObject, use casting macros (e.g.
MAIN_CHANNEL_CLIENT()) to cast RedChannelClient types. This will help
reduce the changeset slightly porting to GObject and thus make it easier
to review those upcoming changes.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-20 09:14:17 +01:00
Jonathon Jongsma
21c6da814a Change RedCharDevicePrivate::clients to GList
More Ring cleanup. At the moment, we only support a single client, so
this is only a one-element list
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
8340688c9d Change RedCharDevice::write_queue to GQueue
Change a couple more Rings to GQueue
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
039d3150ab Change Drawable->pipes from Ring to GList
This improves the readability of the code and keeps things
encapsulated better.
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
a78a7d2510 RedChannelClient: store pipe items in a GQueue
Instead of using a Ring (and having a ring item link in every pipe
item), store them in a GQueue. This also necesitated changing
RedCharDeviceVDIPort->priv->read_bufs to a GList as well.

Also Optimise client pipe by passing pipe position instead of data.
This avoids having the search the data scanning all the queue changing
the order of these operations from O(n) to O(1).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-19 07:47:05 -05:00
Jonathon Jongsma
46c83dfe1f Rename display_channel_set_monitors_config_to_primary()
Since this function is a DisplayChannel method, use a name consistent
with naming conventions.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
5e74387d25 Add DisplayChannelPrivate struct
Move all of the DisplayChannel data memembers into a private struct to
encapsulate things better. This necessitated a few new 'public' methods
and a small bit of refactoring to avoid poking into DisplayChannel
internals from too many places. The DisplayChannel and the
DisplayChannelClient are still far too intertwined to completely avoid
accessing private data, so at the moment the private struct is defined
in display-channel.h and the DisplayChannelClient implementation
still accesses it sometimes.
2016-09-16 13:40:09 -05:00
Jonathon Jongsma
fede3f38c5 Improve encapsulation of DisplayChannel
Add a couple new functions to the header so that they can be called by
other objects rather than poking into the internals of the struct.
2016-09-16 13:40:09 -05:00
Pavel Grunt
83ff645d54 reds: Simplify vdi_port_read_buf_process
Reuse and handle the return value from agent_msg_filter_process_data

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 12:21:06 +01:00
Frediano Ziglio
b0528f334a replay: Rename eof to error
The eof variable and enumeration will be used for all errors
so avoid confusion.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 12:06:19 +01:00
Frediano Ziglio
bd8ccfcd78 replay: Assure read_binary receives a NULL pointer
read_binary do not allocate a buffer for no-NULL pointers.
Avoid using uninitialized data and allocate proper buffer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 12:00:27 +01:00
Pavel Grunt
cd80b9fc78 agent-filter: Use enum as return value
Explicitely discard AGENT_MSG_FILTER_MONITORS_CONFIG messages
from the agent.

Also remove unused AGENT_MSG_FILTER_END

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 11:54:56 +01:00
Frediano Ziglio
80b1e816c6 Remove unused drawable parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:29:19 +01:00
Frediano Ziglio
57dfbebaa9 Reduce indentation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:17:10 +01:00
Frediano Ziglio
5ccad56915 Simplify some boolean arithmetic
Pass boolean directly.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-16 09:14:24 +01:00
Jonathon Jongsma
b6cbb26e25 Replace a couple Rings with GList
Make RedsState::mig_target_clients into a GList to improve encapsulation
and maintainability. Also RedsMigTargetClient::pending_links. With
GList, a type implementation can be ignorant of whether they're
contained within a list or not.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-16 08:49:59 +01:00
Jonathon Jongsma
b08f132102 Make glz_dictionary_list a GList
Removing more intrusive RingItems from various structures and improving
readibility.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 16:06:34 +01:00
Jonathon Jongsma
867bee66a7 Add CursorChannelPrivate struct
Encapsulate private data of CursorChannel in a private struct. This
isn't very useful at the moment, but it will help prepare the way for
porting the RedChannel heirarchy to GObject.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-15 15:34:31 +01:00
Uri Lublin
4cb02250f4 dcc_compress_image: fix a possible overflow when calculating image_size
Both src->stride and src->y are uint32_t
Fixed by making one of them uint64_t

Found by coverity

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:27 +01:00
Uri Lublin
37e4cae9d4 dcc_gl_draw_item_new: allocate item when needed
Prevents a leak on early return.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:25 +01:00
Uri Lublin
dc6c57668a dcc_gl_scanout_item_new: allocate item when needed
Prevents a leak on early return.

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:23 +01:00
Uri Lublin
42066f03ec dcc: do not check the pointer returned by spice_new
The rest of the code assumes spice_new does not return NULL

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-15 15:16:00 +01:00
Pavel Grunt
5d6e3ff1e9 agent-filter: Constantify parameter
Filter should not modify data

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-12 13:22:11 +01:00
Frediano Ziglio
0f6ccd8af5 Remove global key_modifiers_timer variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-12 13:18:40 +01:00
Frediano Ziglio
9432b01663 Remove unused structure declaration
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-09-12 13:04:38 +01:00
Jonathon Jongsma
249d418d33 RedsState: clean up spice_server_char_device_add_interface
Previously we were creating a variable named 'dev_state' and then
apparently not using it. Well, we *were* actually using it, but in a
convoluted sort of way. Creating a new RedCharDevice has a
side-effect of setting itself as the 'st' attribute of
SpiceCharDeviceInstance. So 'dev_state' and 'char_device->st' are in
fact the same variable. But they were being used interchangeably, which
was rather confusing. For example

if (dev_state)
    // do something with char_device->st

So this patch doesn't actually change anything, but it makes the code a
bit easier to follow.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-09 15:09:37 +01:00
Christophe Fergeau
0ae0814696 Fix 'freezed' typo
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-09 14:56:31 +01:00
Jonathon Jongsma
8f1f60d46f Use RED_CHANNEL_CLIENT() macro for casting
Also remove (main|inputs)_channel_client_get_base() function to prepare
for porting to GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-08 11:41:57 +01:00
Victor Toso
f9c4f6da0e mcc: early return and lower indentation
main_channel_client_start_net_test() checks MainChannelClient already
which is the single reason why main_channel_client_push_ping() could
fail. Reorganizing this code a little bit.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 10:04:14 +01:00
Victor Toso
b7353a0c61 mcc: early return and lower indentation
Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 10:04:09 +01:00
Jonathon Jongsma
7188cefdd2 Rename RCC_TO_DCC() to DISPLAY_CHANNEL_CLIENT()
Prepare for port to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
82d4edc75a Add DisplayChannelClientPrivate and CursorChannelPrivate structs
These need to be introduced at the same time since cache-item.tmpl.c
assumes that both of these classes will have a cache in the same place:
either within the channel client struct itself or (now) within a priv
struct owned by the channel client.

This encapsulates private data and prepares for porting to GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
51ccb44af0 Add RedChannelClientPrivate struct
Encapsulate private data and prepare for port to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
aa2430e5ad Add MainChannelClientPrivate struct
Encapsulate private data and prepare for port to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
e8a8607f5f Add InputsChannelClientPrivate struct
Encapsulate private data and prepare for port to GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
9b1e018da6 Add SmartCardChannelClientPrivate struct
Prepare to port to GObject by encapsulating all private data

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:40:15 +01:00
Jonathon Jongsma
7dd8e8be76 Move CursorChannelClient to separate file
Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:38:04 +01:00
Jonathon Jongsma
bed132d6e2 Move RedChannelClient to separate file
Reduce direct access to RedChannelClient, and get ready to convert to
GObject.

Acked-by: Frediano Ziglio <fziglio@redhat.com
2016-09-08 09:37:59 +01:00
Pavel Grunt
1796160095 tests: Check setting of agent properties
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-07 14:18:50 +02:00
Pavel Grunt
bf68b73ba6 reds: Do not crash when setting agent property
Agent properties like file transfer or copy & paste can be disabled by
calling spice_server_set_agent_{copypaste, file_xfer} before the spice
server is initialized. In that case the call crashes the server because
the agent device is created after the initialization.

To avoid the crash this commit introduce a helper function for setting
the agent properties after the server is initialized.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-07 14:18:05 +02:00