channel security cleanup

- drop spice_channel_name_t enum, use spice-protocol defines instead.
- switch spice_server_set_channel_security() channel parameter from
  enum to string.
- drop spice_server_set_default_channel_security(), use
  spice_server_set_channel_security with channel == NULL instead.
This commit is contained in:
Gerd Hoffmann 2010-03-23 15:47:25 +01:00
parent edc1af5f67
commit 43caec519e
2 changed files with 24 additions and 33 deletions

View File

@ -3728,16 +3728,6 @@ static void reds_do_set_playback_compression_2(const VDICmdArg *args)
reds_do_set_playback_compression(args[0].string_val);
}
static void set_all_channels_security(uint32_t security)
{
while (channels_security) {
ChannelSecurityOptions *temp = channels_security;
channels_security = channels_security->next;
free(temp);
}
default_channel_security = security;
}
static void set_one_channel_security(int id, uint32_t security)
{
ChannelSecurityOptions *security_options;
@ -5197,17 +5187,32 @@ spice_image_compression_t spice_server_get_image_compression(SpiceServer *s)
return image_compression;
}
int spice_server_set_channel_security(SpiceServer *s,
spice_channel_name_t channel,
int security)
int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security)
{
static const char *names[] = {
[ SPICE_CHANNEL_MAIN ] = "main",
[ SPICE_CHANNEL_DISPLAY ] = "display",
[ SPICE_CHANNEL_INPUTS ] = "inputs",
[ SPICE_CHANNEL_CURSOR ] = "cursor",
[ SPICE_CHANNEL_PLAYBACK ] = "playback",
[ SPICE_CHANNEL_RECORD ] = "record",
[ SPICE_CHANNEL_TUNNEL ] = "tunnel",
};
int i;
ASSERT(reds == s);
if (channel == SPICE_CHANNEL_NAME_ALL) {
set_all_channels_security(security);
} else {
set_one_channel_security(channel, security);
if (channel == NULL) {
default_channel_security = security;
return 0;
}
return 0;
for (i = 0; i < SPICE_N_ELEMENTS(names); i++) {
if (names[i] && strcmp(names[i], channel) == 0) {
set_one_channel_security(i, security);
return 0;
}
}
return -1;
}
int spice_server_set_mouse_absolute(SpiceServer *s, int absolute)

View File

@ -61,24 +61,10 @@ int spice_server_set_image_compression(SpiceServer *s,
spice_image_compression_t comp);
spice_image_compression_t spice_server_get_image_compression(SpiceServer *s);
typedef enum {
SPICE_CHANNEL_NAME_INVALID = 0,
SPICE_CHANNEL_NAME_MAIN = 1,
SPICE_CHANNEL_NAME_DISPLAY,
SPICE_CHANNEL_NAME_INPUTS,
SPICE_CHANNEL_NAME_CURSOR,
SPICE_CHANNEL_NAME_PLAYBACK,
SPICE_CHANNEL_NAME_RECORD,
SPICE_CHANNEL_NAME_TUNNEL,
SPICE_CHANNEL_NAME_ALL = 999,
} spice_channel_name_t;
#define SPICE_CHANNEL_SECURITY_NONE (1 << 0)
#define SPICE_CHANNEL_SECURITY_SSL (1 << 1)
int spice_server_set_channel_security(SpiceServer *s,
spice_channel_name_t channel,
int security);
int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security);
int spice_server_set_mouse_absolute(SpiceServer *s, int absolute);