[virt-tools-list] [virt-viewer 4/7] Add 'group' argument to VirtViewerFile helpers
Christophe Fergeau
cfergeau at redhat.com
Wed Apr 16 16:59:51 UTC 2014
For foreign menu support, we'll need a way to pass oVirt-specific
information in the .vv file. This will be done through an additional
[ovirt] section, this commit is in preparation for that.
---
src/virt-viewer-file.c | 153 +++++++++++++++++++++++++++----------------------
1 file changed, 84 insertions(+), 69 deletions(-)
diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
index 09f76b3..db224e0 100644
--- a/src/virt-viewer-file.c
+++ b/src/virt-viewer-file.c
@@ -78,7 +78,7 @@ G_DEFINE_TYPE(VirtViewerFile, virt_viewer_file, G_TYPE_OBJECT);
#define VIRT_VIEWER_FILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_FILE, VirtViewerFilePrivate))
-#define GROUP "virt-viewer"
+#define MAIN_GROUP "virt-viewer"
enum {
PROP_DUMMY_PROPERTY,
@@ -128,7 +128,7 @@ virt_viewer_file_new(const gchar* location, GError** error)
return NULL;
}
- if (!g_key_file_has_group (keyfile, GROUP) ||
+ if (!g_key_file_has_group (keyfile, MAIN_GROUP) ||
!virt_viewer_file_is_set(self, "type")) {
inner_error = g_error_new_literal(G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_NOT_FOUND, "Invalid file");
@@ -155,7 +155,7 @@ virt_viewer_file_is_set(VirtViewerFile* self, const gchar* key)
g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), FALSE);
g_return_val_if_fail(key != NULL, FALSE);
- set = g_key_file_has_key(self->priv->keyfile, GROUP, key, &inner_error);
+ set = g_key_file_has_key(self->priv->keyfile, MAIN_GROUP, key, &inner_error);
if (inner_error == NULL)
return set;
else {
@@ -165,17 +165,20 @@ virt_viewer_file_is_set(VirtViewerFile* self, const gchar* key)
}
static void
-virt_viewer_file_set_string(VirtViewerFile* self, const gchar* key, const gchar* value)
+virt_viewer_file_set_string(VirtViewerFile* self, const char *group,
+ const gchar* key, const gchar* value)
{
g_return_if_fail(VIRT_VIEWER_IS_FILE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(value != NULL);
- g_key_file_set_string(self->priv->keyfile, GROUP, key, value);
+ g_key_file_set_string(self->priv->keyfile, group, key, value);
}
static gchar*
-virt_viewer_file_get_string(VirtViewerFile* self, const gchar* key)
+virt_viewer_file_get_string(VirtViewerFile* self,
+ const char *group,
+ const gchar* key)
{
GError* inner_error = NULL;
gchar* result = NULL;
@@ -183,7 +186,7 @@ virt_viewer_file_get_string(VirtViewerFile* self, const gchar* key)
g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), NULL);
g_return_val_if_fail(key != NULL, NULL);
- result = g_key_file_get_string(self->priv->keyfile, GROUP, key, &inner_error);
+ result = g_key_file_get_string(self->priv->keyfile, group, key, &inner_error);
if (inner_error && inner_error->domain != G_KEY_FILE_ERROR)
g_critical("%s", inner_error->message);
g_clear_error(&inner_error);
@@ -192,16 +195,19 @@ virt_viewer_file_get_string(VirtViewerFile* self, const gchar* key)
}
static void
-virt_viewer_file_set_string_list(VirtViewerFile* self, const gchar* key, const gchar* const* value, gsize length)
+virt_viewer_file_set_string_list(VirtViewerFile* self, const char *group,
+ const gchar* key, const gchar* const* value,
+ gsize length)
{
g_return_if_fail(VIRT_VIEWER_IS_FILE(self));
g_return_if_fail(key != NULL);
- g_key_file_set_string_list(self->priv->keyfile, GROUP, key, value, length);
+ g_key_file_set_string_list(self->priv->keyfile, group, key, value, length);
}
static gchar**
-virt_viewer_file_get_string_list(VirtViewerFile* self, const gchar* key, gsize* length)
+virt_viewer_file_get_string_list(VirtViewerFile* self, const char *group,
+ const gchar* key, gsize* length)
{
GError* inner_error = NULL;
gchar** result = NULL;
@@ -209,7 +215,7 @@ virt_viewer_file_get_string_list(VirtViewerFile* self, const gchar* key, gsize*
g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), NULL);
g_return_val_if_fail(key != NULL, NULL);
- result = g_key_file_get_string_list(self->priv->keyfile, GROUP, key, length, &inner_error);
+ result = g_key_file_get_string_list(self->priv->keyfile, group, key, length, &inner_error);
if (inner_error && inner_error->domain != G_KEY_FILE_ERROR)
g_critical("%s", inner_error->message);
g_clear_error(&inner_error);
@@ -218,16 +224,19 @@ virt_viewer_file_get_string_list(VirtViewerFile* self, const gchar* key, gsize*
}
static void
-virt_viewer_file_set_int(VirtViewerFile* self, const gchar* key, gint value)
+virt_viewer_file_set_int(VirtViewerFile* self, const char *group,
+ const gchar* key, gint value)
{
g_return_if_fail(VIRT_VIEWER_IS_FILE(self));
g_return_if_fail(key != NULL);
- g_key_file_set_integer(self->priv->keyfile, GROUP, key, value);
+ g_key_file_set_integer(self->priv->keyfile, group, key, value);
}
static gint
-virt_viewer_file_get_int(VirtViewerFile* self, const gchar* key)
+virt_viewer_file_get_int(VirtViewerFile* self,
+ const char *group,
+ const gchar* key)
{
GError* inner_error = NULL;
gint result;
@@ -235,7 +244,7 @@ virt_viewer_file_get_int(VirtViewerFile* self, const gchar* key)
g_return_val_if_fail(VIRT_VIEWER_IS_FILE(self), -1);
g_return_val_if_fail(key != NULL, -1);
- result = g_key_file_get_integer(self->priv->keyfile, GROUP, key, &inner_error);
+ result = g_key_file_get_integer(self->priv->keyfile, group, key, &inner_error);
if (inner_error && inner_error->domain != G_KEY_FILE_ERROR)
g_critical("%s", inner_error->message);
g_clear_error(&inner_error);
@@ -246,351 +255,357 @@ virt_viewer_file_get_int(VirtViewerFile* self, const gchar* key)
gchar*
virt_viewer_file_get_ca(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "ca");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "ca");
}
void
virt_viewer_file_set_ca(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "ca", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "ca", value);
g_object_notify(G_OBJECT(self), "ca");
}
gchar*
virt_viewer_file_get_host(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "host");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "host");
}
void
virt_viewer_file_set_host(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "host", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "host", value);
g_object_notify(G_OBJECT(self), "host");
}
gchar*
virt_viewer_file_get_file_type(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "type");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "type");
}
void
virt_viewer_file_set_type(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "type", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "type", value);
g_object_notify(G_OBJECT(self), "type");
}
gint
virt_viewer_file_get_port(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "port");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "port");
}
void
virt_viewer_file_set_port(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "port", value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "port", value);
g_object_notify(G_OBJECT(self), "port");
}
gint
virt_viewer_file_get_tls_port(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "tls-port");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "tls-port");
}
void
virt_viewer_file_set_tls_port(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "tls-port", value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "tls-port", value);
g_object_notify(G_OBJECT(self), "tls-port");
}
gchar*
virt_viewer_file_get_username(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "username");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "username");
}
gchar*
virt_viewer_file_get_password(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "password");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "password");
}
void
virt_viewer_file_set_username(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "username", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "username", value);
g_object_notify(G_OBJECT(self), "username");
}
void
virt_viewer_file_set_password(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "password", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "password", value);
g_object_notify(G_OBJECT(self), "password");
}
gchar**
virt_viewer_file_get_disable_channels(VirtViewerFile* self, gsize* length)
{
- return virt_viewer_file_get_string_list(self, "disable-channels", length);
+ return virt_viewer_file_get_string_list(self, MAIN_GROUP,
+ "disable-channels", length);
}
void
virt_viewer_file_set_disable_channels(VirtViewerFile* self, const gchar* const* value, gsize length)
{
- virt_viewer_file_set_string_list(self, "disable-channels", value, length);
+ virt_viewer_file_set_string_list(self, MAIN_GROUP,
+ "disable-channels", value, length);
g_object_notify(G_OBJECT(self), "disable-channels");
}
gchar**
virt_viewer_file_get_disable_effects(VirtViewerFile* self, gsize* length)
{
- return virt_viewer_file_get_string_list(self, "disable-effects", length);
+ return virt_viewer_file_get_string_list(self, MAIN_GROUP,
+ "disable-effects", length);
}
void
virt_viewer_file_set_disable_effects(VirtViewerFile* self, const gchar* const* value, gsize length)
{
- virt_viewer_file_set_string_list(self, "disable-effects", value, length);
+ virt_viewer_file_set_string_list(self, MAIN_GROUP,
+ "disable-effects", value, length);
g_object_notify(G_OBJECT(self), "disable-effects");
}
gchar*
virt_viewer_file_get_tls_ciphers(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "tls-ciphers");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "tls-ciphers");
}
void
virt_viewer_file_set_tls_ciphers(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "tls-ciphers", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "tls-ciphers", value);
g_object_notify(G_OBJECT(self), "tls-ciphers");
}
gchar*
virt_viewer_file_get_host_subject(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "host-subject");
+ return virt_viewer_file_get_string(self, MAIN_GROUP,
+ "host-subject");
}
void
virt_viewer_file_set_host_subject(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "host-subject", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP,
+ "host-subject", value);
g_object_notify(G_OBJECT(self), "host-subject");
}
gint
virt_viewer_file_get_fullscreen(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "fullscreen");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "fullscreen");
}
void
virt_viewer_file_set_fullscreen(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "fullscreen", !!value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "fullscreen", !!value);
g_object_notify(G_OBJECT(self), "fullscreen");
}
gchar*
virt_viewer_file_get_title(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "title");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "title");
}
void
virt_viewer_file_set_title(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "title", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "title", value);
g_object_notify(G_OBJECT(self), "title");
}
gchar*
virt_viewer_file_get_toggle_fullscreen(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "toggle-fullscreen");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "toggle-fullscreen");
}
void
virt_viewer_file_set_toggle_fullscreen(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "toggle-fullscreen", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "toggle-fullscreen", value);
g_object_notify(G_OBJECT(self), "toggle-fullscreen");
}
gchar*
virt_viewer_file_get_release_cursor(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "release-cursor");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "release-cursor");
}
void
virt_viewer_file_set_release_cursor(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "release-cursor", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "release-cursor", value);
g_object_notify(G_OBJECT(self), "release-cursor");
}
gchar*
virt_viewer_file_get_secure_attention(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "secure-attention");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "secure-attention");
}
void
virt_viewer_file_set_secure_attention(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "secure-attention", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "secure-attention", value);
g_object_notify(G_OBJECT(self), "secure-attention");
}
gchar*
virt_viewer_file_get_smartcard_remove(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "smartcard-remove");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "smartcard-remove");
}
void
virt_viewer_file_set_smartcard_remove(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "smartcard-remove", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "smartcard-remove", value);
g_object_notify(G_OBJECT(self), "smartcard-remove");
}
gchar*
virt_viewer_file_get_smartcard_insert(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "smartcard-insert");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "smartcard-insert");
}
void
virt_viewer_file_set_smartcard_insert(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "smartcard-insert", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "smartcard-insert", value);
g_object_notify(G_OBJECT(self), "smartcard-insert");
}
gint
virt_viewer_file_get_enable_smartcard(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "enable-smartcard");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "enable-smartcard");
}
void
virt_viewer_file_set_enable_smartcard(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "enable-smartcard", !!value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "enable-smartcard", !!value);
g_object_notify(G_OBJECT(self), "enable-smartcard");
}
gint
virt_viewer_file_get_enable_usbredir(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "enable-usbredir");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "enable-usbredir");
}
void
virt_viewer_file_set_enable_usbredir(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "enable-usbredir", !!value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "enable-usbredir", !!value);
g_object_notify(G_OBJECT(self), "enable-usbredir");
}
gint
virt_viewer_file_get_delete_this_file(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "delete-this-file");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "delete-this-file");
}
void
virt_viewer_file_set_delete_this_file(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "delete-this-file", !!value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "delete-this-file", !!value);
g_object_notify(G_OBJECT(self), "delete-this-file");
}
gint
virt_viewer_file_get_color_depth(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "color-depth");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "color-depth");
}
void
virt_viewer_file_set_color_depth(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "color-depth", value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "color-depth", value);
g_object_notify(G_OBJECT(self), "color-depth");
}
gint
virt_viewer_file_get_enable_usb_autoshare(VirtViewerFile* self)
{
- return virt_viewer_file_get_int(self, "enable-usb-autoshare");
+ return virt_viewer_file_get_int(self, MAIN_GROUP, "enable-usb-autoshare");
}
void
virt_viewer_file_set_enable_usb_autoshare(VirtViewerFile* self, gint value)
{
- virt_viewer_file_set_int(self, "enable-usb-autoshare", !!value);
+ virt_viewer_file_set_int(self, MAIN_GROUP, "enable-usb-autoshare", !!value);
g_object_notify(G_OBJECT(self), "enable-usb-autoshare");
}
gchar*
virt_viewer_file_get_usb_filter(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "usb-filter");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "usb-filter");
}
void
virt_viewer_file_set_usb_filter(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "usb-filter", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "usb-filter", value);
g_object_notify(G_OBJECT(self), "usb-filter");
}
gchar*
virt_viewer_file_get_proxy(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "proxy");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "proxy");
}
void
virt_viewer_file_set_proxy(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "proxy", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "proxy", value);
g_object_notify(G_OBJECT(self), "proxy");
}
gchar*
virt_viewer_file_get_version(VirtViewerFile* self)
{
- return virt_viewer_file_get_string(self, "version");
+ return virt_viewer_file_get_string(self, MAIN_GROUP, "version");
}
void
virt_viewer_file_set_version(VirtViewerFile* self, const gchar* value)
{
- virt_viewer_file_set_string(self, "version", value);
+ virt_viewer_file_set_string(self, MAIN_GROUP, "version", value);
g_object_notify(G_OBJECT(self), "version");
}
gchar**
virt_viewer_file_get_secure_channels(VirtViewerFile* self, gsize* length)
{
- return virt_viewer_file_get_string_list(self, "secure-channels", length);
+ return virt_viewer_file_get_string_list(self, MAIN_GROUP, "secure-channels", length);
}
void
virt_viewer_file_set_secure_channels(VirtViewerFile* self, const gchar* const* value, gsize length)
{
- virt_viewer_file_set_string_list(self, "secure-channels", value, length);
+ virt_viewer_file_set_string_list(self, MAIN_GROUP, "secure-channels", value, length);
g_object_notify(G_OBJECT(self), "secure-channels");
}
--
1.9.0
More information about the virt-tools-list
mailing list