channel: build adapter for public core interface

Add wrapper functions for SpiceCoreInterface in order to present
a SpiceCoreInterfaceInternal. These functions just expect
SpiceCoreInterfaceInternal API and forward request to
SpiceCoreInterface.
This allows to change ABI details of internal one.

See comments in "channel: add interface parameters to
SpiceCoreInterfaceInternal" patch.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-01-07 17:20:21 +00:00
parent adc0751950
commit 9745ef5f9a
2 changed files with 58 additions and 5 deletions

View File

@ -42,8 +42,6 @@
typedef struct SpiceCoreInterfaceInternal SpiceCoreInterfaceInternal;
struct SpiceCoreInterfaceInternal {
SpiceBaseInterface base;
SpiceTimer *(*timer_add)(SpiceTimerFunc func, void *opaque);
void (*timer_start)(SpiceTimer *timer, uint32_t ms);
void (*timer_cancel)(SpiceTimer *timer);

View File

@ -74,6 +74,61 @@
SpiceCoreInterfaceInternal *core = NULL;
static SpiceCoreInterface *core_public = NULL;
static SpiceTimer *adapter_timer_add(SpiceTimerFunc func, void *opaque)
{
return core_public->timer_add(func, opaque);
}
static void adapter_timer_start(SpiceTimer *timer, uint32_t ms)
{
core_public->timer_start(timer, ms);
}
static void adapter_timer_cancel(SpiceTimer *timer)
{
core_public->timer_cancel(timer);
}
static void adapter_timer_remove(SpiceTimer *timer)
{
core_public->timer_remove(timer);
}
static SpiceWatch *adapter_watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
return core_public->watch_add(fd, event_mask, func, opaque);
}
static void adapter_watch_update_mask(SpiceWatch *watch, int event_mask)
{
core_public->watch_update_mask(watch, event_mask);
}
static void adapter_watch_remove(SpiceWatch *watch)
{
core_public->watch_remove(watch);
}
static void adapter_channel_event(int event, SpiceChannelEventInfo *info)
{
if (core_public->base.minor_version >= 3 && core_public->channel_event != NULL)
core_public->channel_event(event, info);
}
static SpiceCoreInterfaceInternal core_interface_adapter = {
.timer_add = adapter_timer_add,
.timer_start = adapter_timer_start,
.timer_cancel = adapter_timer_cancel,
.timer_remove = adapter_timer_remove,
.watch_add = adapter_watch_add,
.watch_update_mask = adapter_watch_update_mask,
.watch_remove = adapter_watch_remove,
.channel_event = adapter_channel_event,
};
static SpiceCharDeviceInstance *vdagent = NULL;
static SpiceMigrateInstance *migration_interface = NULL;
@ -177,8 +232,7 @@ static ChannelSecurityOptions *find_channel_security(int id)
void reds_handle_channel_event(int event, SpiceChannelEventInfo *info)
{
if (core->base.minor_version >= 3 && core->channel_event != NULL)
core->channel_event(event, info);
core->channel_event(event, info);
if (event == SPICE_CHANNEL_EVENT_DISCONNECTED) {
free(info);
@ -3275,7 +3329,8 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
spice_warning("bad core interface version");
goto err;
}
core = (SpiceCoreInterfaceInternal *) core_interface;
core_public = core_interface;
core = &core_interface_adapter;
reds->listen_socket = -1;
reds->secure_listen_socket = -1;
init_vd_agent_resources();