mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-07 03:14:03 +00:00
red-channel: Separate RedChannelCapabilities
Add function to initialize and destroy this type. Add GType type for boxing it. These changes a in preparation for next patch. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
5b3f79f8a7
commit
89a722ce03
@ -101,6 +101,8 @@ libserver_la_SOURCES = \
|
||||
red-channel.h \
|
||||
red-channel-client.c \
|
||||
red-channel-client.h \
|
||||
red-channel-capabilities.c \
|
||||
red-channel-capabilities.h \
|
||||
red-client.c \
|
||||
red-client.h \
|
||||
red-common.h \
|
||||
|
||||
68
server/red-channel-capabilities.c
Normal file
68
server/red-channel-capabilities.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (C) 2017 Red Hat, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <common/mem.h>
|
||||
#include <common/macros.h>
|
||||
|
||||
#include "red-channel-capabilities.h"
|
||||
|
||||
GType red_channel_capabilities_type;
|
||||
|
||||
void red_channel_capabilities_init(RedChannelCapabilities *dest,
|
||||
const RedChannelCapabilities *caps)
|
||||
{
|
||||
*dest = *caps;
|
||||
if (caps->common_caps) {
|
||||
dest->common_caps = spice_memdup(caps->common_caps,
|
||||
caps->num_common_caps * sizeof(uint32_t));
|
||||
}
|
||||
if (caps->num_caps) {
|
||||
dest->caps = spice_memdup(caps->caps, caps->num_caps * sizeof(uint32_t));
|
||||
}
|
||||
}
|
||||
|
||||
void red_channel_capabilities_reset(RedChannelCapabilities *caps)
|
||||
{
|
||||
free(caps->common_caps);
|
||||
free(caps->caps);
|
||||
memset(caps, 0, sizeof(*caps));
|
||||
}
|
||||
|
||||
static RedChannelCapabilities *red_channel_capabilities_dup(const RedChannelCapabilities *caps)
|
||||
{
|
||||
RedChannelCapabilities *res = spice_new(RedChannelCapabilities, 1);
|
||||
red_channel_capabilities_init(res, caps);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void red_channel_capabilities_free(RedChannelCapabilities *caps)
|
||||
{
|
||||
red_channel_capabilities_reset(caps);
|
||||
free(caps);
|
||||
}
|
||||
|
||||
SPICE_CONSTRUCTOR_FUNC(red_channel_capabilities_construct)
|
||||
{
|
||||
red_channel_capabilities_type =
|
||||
g_boxed_type_register_static("red_channel_capabilities_type",
|
||||
(GBoxedCopyFunc) red_channel_capabilities_dup,
|
||||
(GBoxedFreeFunc) red_channel_capabilities_free);
|
||||
}
|
||||
51
server/red-channel-capabilities.h
Normal file
51
server/red-channel-capabilities.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
Copyright (C) 2009-2017 Red Hat, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RED_CHANNEL_CAPABILITIES_H_
|
||||
#define RED_CHANNEL_CAPABILITIES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Holds channel capabilities.
|
||||
* Channel capabilities are composed by a common part
|
||||
* and a specific one. */
|
||||
typedef struct RedChannelCapabilities {
|
||||
int num_common_caps;
|
||||
uint32_t *common_caps;
|
||||
int num_caps;
|
||||
uint32_t *caps;
|
||||
} RedChannelCapabilities;
|
||||
|
||||
/* Initialize the structure based on a previous one. */
|
||||
void red_channel_capabilities_init(RedChannelCapabilities *dest,
|
||||
const RedChannelCapabilities *caps);
|
||||
|
||||
/* Reset capabilities.
|
||||
* All resources are freed by this function. */
|
||||
void red_channel_capabilities_reset(RedChannelCapabilities *caps);
|
||||
|
||||
/* GObject type that can be used to box RedChannelCapabilities */
|
||||
extern GType red_channel_capabilities_type;
|
||||
#define RED_TYPE_CHANNEL_CAPABILITIES red_channel_capabilities_type
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
@ -34,6 +34,7 @@
|
||||
#include "reds-stream.h"
|
||||
#include "stat.h"
|
||||
#include "red-pipe-item.h"
|
||||
#include "red-channel-capabilities.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -135,13 +136,6 @@ struct RedChannelClass
|
||||
|
||||
/* Red Channel interface */
|
||||
|
||||
typedef struct RedChannelCapabilities {
|
||||
int num_common_caps;
|
||||
uint32_t *common_caps;
|
||||
int num_caps;
|
||||
uint32_t *caps;
|
||||
} RedChannelCapabilities;
|
||||
|
||||
GType red_channel_get_type(void) G_GNUC_CONST;
|
||||
|
||||
void red_channel_add_client(RedChannel *channel, RedChannelClient *rcc);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user