diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-03-02 13:45:15 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-03-05 18:19:07 +0100 |
commit | 36d8da628380e7a63df893846f96ee608b2e1af8 (patch) | |
tree | 4503e1737ec75f895f7aee1561ca166087939d52 /server/main_channel.c | |
parent | f0ff2e383efba62e4f0368facd855d54ae915821 (diff) | |
download | spice-36d8da628380e7a63df893846f96ee608b2e1af8.tar.gz spice-36d8da628380e7a63df893846f96ee608b2e1af8.tar.xz spice-36d8da628380e7a63df893846f96ee608b2e1af8.zip |
Send name & uuid to capable clients
Add spice_server_set_name() and spice_server_set_uuid() that allows
the client to identify a Spice server (useful to associate settings
with a particular server)
The SPICE_MSG_MAIN_NAME and SPICE_MSG_MAIN_UUID messages are only sent
to capable clients, announcing SPICE_MAIN_CAP_NAME_AND_UUID.
Diffstat (limited to 'server/main_channel.c')
-rw-r--r-- | server/main_channel.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/server/main_channel.c b/server/main_channel.c index 878f62d4..a871bc8c 100644 --- a/server/main_channel.c +++ b/server/main_channel.c @@ -103,6 +103,16 @@ typedef struct InitPipeItem { int ram_hint; } InitPipeItem; +typedef struct NamePipeItem { + PipeItem base; + SpiceMsgMainName msg; +} NamePipeItem; + +typedef struct UuidPipeItem { + PipeItem base; + SpiceMsgMainUuid msg; +} UuidPipeItem; + typedef struct NotifyPipeItem { PipeItem base; uint8_t *mess; @@ -267,6 +277,29 @@ static PipeItem *main_init_item_new(MainChannelClient *mcc, return &item->base; } +static PipeItem *main_name_item_new(MainChannelClient *mcc, const char *name) +{ + NamePipeItem *item = spice_malloc(sizeof(NamePipeItem) + strlen(name) + 1); + + red_channel_pipe_item_init(mcc->base.channel, &item->base, + SPICE_MSG_MAIN_NAME); + item->msg.name_len = strlen(name) + 1; + memcpy(&item->msg.name, name, item->msg.name_len); + + return &item->base; +} + +static PipeItem *main_uuid_item_new(MainChannelClient *mcc, const uint8_t uuid[16]) +{ + UuidPipeItem *item = spice_malloc(sizeof(UuidPipeItem)); + + red_channel_pipe_item_init(mcc->base.channel, &item->base, + SPICE_MSG_MAIN_UUID); + memcpy(item->msg.uuid, uuid, sizeof(item->msg.uuid)); + + return &item->base; +} + typedef struct NotifyPipeInfo { uint8_t *mess; int mess_len; @@ -501,6 +534,30 @@ static void main_channel_marshall_init(SpiceMarshaller *m, spice_marshall_msg_main_init(m, &init); } +void main_channel_push_name(MainChannelClient *mcc, const char *name) +{ + PipeItem *item; + + if (!red_channel_client_test_remote_cap(&mcc->base, + SPICE_MAIN_CAP_NAME_AND_UUID)) + return; + + item = main_name_item_new(mcc, name); + red_channel_client_pipe_add_push(&mcc->base, item); +} + +void main_channel_push_uuid(MainChannelClient *mcc, const uint8_t uuid[16]) +{ + PipeItem *item; + + if (!red_channel_client_test_remote_cap(&mcc->base, + SPICE_MAIN_CAP_NAME_AND_UUID)) + return; + + item = main_uuid_item_new(mcc, uuid); + red_channel_client_pipe_add_push(&mcc->base, item); +} + // TODO - some notifications are new client only (like "keyboard is insecure" on startup) void main_channel_push_notify(MainChannel *main_chan, uint8_t *mess, const int mess_len) { @@ -692,6 +749,14 @@ static void main_channel_send_item(RedChannelClient *rcc, PipeItem *base) case SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST: main_channel_marshall_migrate_switch(m, rcc); break; + case SPICE_MSG_MAIN_NAME: + spice_marshall_msg_main_name(m, &SPICE_CONTAINEROF(base, NamePipeItem, base)->msg); + break; + case SPICE_MSG_MAIN_UUID: + spice_marshall_msg_main_uuid(m, &SPICE_CONTAINEROF(base, UuidPipeItem, base)->msg); + break; + default: + break; }; red_channel_client_begin_send_message(rcc); } |