[PATCH 05/11] move all item creation in main-channel-client.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Frediano Ziglio <fziglio@xxxxxxxxxx>

Move all core to create and destroy MainChannel pipe items in a single
place.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/main-channel-client.c | 34 ++++++++++++++++++++++++++++++++++
 server/main-channel-client.h | 15 +++++++++------
 server/main-channel.c        | 29 +----------------------------
 3 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 2a2fac5..ea09976 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -101,6 +101,17 @@ typedef struct RedNotifyPipeItem {
     char *msg;
 } RedNotifyPipeItem;
 
+typedef struct RedMouseModePipeItem {
+    RedPipeItem base;
+    int current_mode;
+    int is_client_mouse_allowed;
+} RedMouseModePipeItem;
+
+typedef struct RedMultiMediaTimePipeItem {
+    RedPipeItem base;
+    int time;
+} RedMultiMediaTimePipeItem;
+
 #define ZERO_BUF_SIZE 4096
 
 static const uint8_t zero_page[ZERO_BUF_SIZE] = {0};
@@ -280,6 +291,29 @@ void main_channel_client_push_notify(MainChannelClient *mcc, const char *msg)
     red_channel_client_pipe_add_push(&mcc->base, item);
 }
 
+RedPipeItem *main_mouse_mode_item_new(RedChannelClient *rcc, void *data, int num)
+{
+    RedMouseModePipeItem *item = spice_malloc(sizeof(RedMouseModePipeItem));
+    MainMouseModeItemInfo *info = data;
+
+    red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MOUSE_MODE);
+    item->current_mode = info->current_mode;
+    item->is_client_mouse_allowed = info->is_client_mouse_allowed;
+    return &item->base;
+}
+
+RedPipeItem *main_multi_media_time_item_new(RedChannelClient *rcc,
+                                            void *data, int num)
+{
+    MainMultiMediaTimeItemInfo *info = data;
+    RedMultiMediaTimePipeItem *item;
+
+    item = spice_malloc(sizeof(RedMultiMediaTimePipeItem));
+    red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MULTI_MEDIA_TIME);
+    item->time = info->time;
+    return &item->base;
+}
+
 void main_channel_client_handle_migrate_connected(MainChannelClient *mcc,
                                                   int success,
                                                   int seamless)
diff --git a/server/main-channel-client.h b/server/main-channel-client.h
index 5bbaac6..439e812 100644
--- a/server/main-channel-client.h
+++ b/server/main-channel-client.h
@@ -94,15 +94,18 @@ enum {
     RED_PIPE_ITEM_TYPE_MAIN_AGENT_CONNECTED_TOKENS,
 };
 
-typedef struct RedMouseModePipeItem {
-    RedPipeItem base;
+typedef struct MainMouseModeItemInfo {
     int current_mode;
     int is_client_mouse_allowed;
-} RedMouseModePipeItem;
+} MainMouseModeItemInfo;
 
-typedef struct RedMultiMediaTimePipeItem {
-    RedPipeItem base;
+RedPipeItem *main_mouse_mode_item_new(RedChannelClient *rcc, void *data, int num);
+
+typedef struct MainMultiMediaTimeItemInfo {
     int time;
-} RedMultiMediaTimePipeItem;
+} MainMultiMediaTimeItemInfo;
+
+RedPipeItem *main_multi_media_time_item_new(RedChannelClient *rcc,
+                                            void *data, int num);
 
 #endif /* __MAIN_CHANNEL_CLIENT_H__ */
diff --git a/server/main-channel.c b/server/main-channel.c
index 0464186..4808658 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -56,33 +56,6 @@ RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t c
     return NULL;
 }
 
-typedef struct MainMouseModeItemInfo {
-    int current_mode;
-    int is_client_mouse_allowed;
-} MainMouseModeItemInfo;
-
-static RedPipeItem *main_mouse_mode_item_new(RedChannelClient *rcc, void *data, int num)
-{
-    RedMouseModePipeItem *item = spice_malloc(sizeof(RedMouseModePipeItem));
-    MainMouseModeItemInfo *info = data;
-
-    red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MOUSE_MODE);
-    item->current_mode = info->current_mode;
-    item->is_client_mouse_allowed = info->is_client_mouse_allowed;
-    return &item->base;
-}
-
-static RedPipeItem *main_multi_media_time_item_new(RedChannelClient *rcc,
-                                                   void *data, int num)
-{
-    RedMultiMediaTimePipeItem *item, *info = data;
-
-    item = spice_malloc(sizeof(RedMultiMediaTimePipeItem));
-    red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_MAIN_MULTI_MEDIA_TIME);
-    item->time = info->time;
-    return &item->base;
-}
-
 static void main_channel_push_channels(MainChannelClient *mcc)
 {
     if (red_client_during_migrate_at_target((main_channel_client_get_base(mcc))->client)) {
@@ -148,7 +121,7 @@ static int main_channel_handle_migrate_data(RedChannelClient *rcc,
 
 void main_channel_push_multi_media_time(MainChannel *main_chan, int time)
 {
-    RedMultiMediaTimePipeItem info = {
+    MainMultiMediaTimeItemInfo info = {
         .time = time,
     };
 
-- 
2.4.11

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]