[Spice-devel] [PATCH 12/17] Add red_channel_get_server()

Frediano Ziglio fziglio at redhat.com
Thu Feb 11 19:24:11 UTC 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Instead of poking into the internals of the RedChannel, provide an
accessor.
---
 server/inputs-channel.c | 4 ++--
 server/main-channel.c   | 2 +-
 server/red-channel.c    | 5 +++++
 server/red-channel.h    | 1 +
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index bb1c5ea..677d071 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -305,7 +305,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     InputsChannel *inputs_channel = (InputsChannel *)rcc->channel;
     InputsChannelClient *icc = (InputsChannelClient *)rcc;
     uint32_t i;
-    RedsState *reds = inputs_channel->base.reds;
+    RedsState *reds = red_channel_get_server((RedChannel*)inputs_channel);
 
     switch (type) {
     case SPICE_MSGC_INPUTS_KEY_DOWN: {
@@ -676,7 +676,7 @@ int inputs_channel_set_keyboard(InputsChannel *inputs, SpiceKbdInstance *keyboar
         return -1;
     }
     inputs->keyboard = keyboard;
-    inputs->keyboard->st = spice_kbd_state_new(inputs->base.reds);
+    inputs->keyboard->st = spice_kbd_state_new(red_channel_get_server((RedChannel*)inputs));
     return 0;
 }
 
diff --git a/server/main-channel.c b/server/main-channel.c
index 8547b52..c168545 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -1088,7 +1088,7 @@ static MainChannelClient *main_channel_client_create(MainChannel *main_chan, Red
     mcc->connection_id = connection_id;
     mcc->bitrate_per_sec = ~0;
 #ifdef RED_STATISTICS
-    core = reds_get_core_interface(main_chan->base.reds);
+    core = reds_get_core_interface(red_channel_get_server((RedChannel*)main_chan));
     if (!(mcc->ping_timer = core->timer_add(core, ping_timer_cb, NULL))) {
         spice_error("ping timer create failed");
     }
diff --git a/server/red-channel.c b/server/red-channel.c
index 490f08a..905abcd 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -2454,3 +2454,8 @@ void red_channel_client_disconnect_if_pending_send(RedChannelClient *rcc)
         spice_assert(red_channel_client_no_item_being_sent(rcc));
     }
 }
+
+RedsState* red_channel_get_server(RedChannel *channel)
+{
+    return channel->reds;
+}
diff --git a/server/red-channel.h b/server/red-channel.h
index 3a12ae0..837ee32 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -565,6 +565,7 @@ uint32_t red_channel_sum_pipes_size(RedChannel *channel);
 typedef void (*channel_client_callback)(RedChannelClient *rcc);
 typedef void (*channel_client_callback_data)(RedChannelClient *rcc, void *data);
 void red_channel_apply_clients(RedChannel *channel, channel_client_callback v);
+RedsState* red_channel_get_server(RedChannel *channel);
 
 struct RedsState;
 
-- 
2.5.0



More information about the Spice-devel mailing list