[virt-tools-list] [virt-viewer 5/7] Add ovirt-specific properties to VirtViewerFile
Jonathon Jongsma
jjongsma at redhat.com
Wed Apr 16 22:08:17 UTC 2014
If all of these new ovirt-specific keys have 'ovirt-' prefixes anyway, do we really need to separate them into a separate [ovirt] group? I don't really care either way, but it does make the code a bit more verbose.
----- Original Message -----
> From: "Christophe Fergeau" <cfergeau at redhat.com>
> To: virt-tools-list at redhat.com
> Sent: Wednesday, April 16, 2014 11:59:52 AM
> Subject: [virt-tools-list] [virt-viewer 5/7] Add ovirt-specific properties to VirtViewerFile
>
> They will be useful to implement foreign menu support through
> oVirt REST API
> ---
> src/virt-viewer-file.c | 108
> +++++++++++++++++++++++++++++++++++++++++++++++++
> src/virt-viewer-file.h | 8 ++++
> 2 files changed, 116 insertions(+)
>
> diff --git a/src/virt-viewer-file.c b/src/virt-viewer-file.c
> index db224e0..640b664 100644
> --- a/src/virt-viewer-file.c
> +++ b/src/virt-viewer-file.c
> @@ -66,6 +66,17 @@
> * - delete-this-file: int (0 or 1 atm)
> * - proxy: proxy URL, like http://user:pass@foobar:8080
> *
> + * There is an optional [ovirt] section which can be used to specify
> + * the connection parameters to interact with the remote oVirt REST API.
> + * This is currently used to present a list of CDRom images which can be
> + * inserted in the VM.
> + *
> + * - host: string containing the URL of the oVirt engine
> + * - guid: string containing the guid of the oVirt VM we are connecting to
> + * - jsessionid: string containing an authentication cookie to be used to
> + * connect to the oVirt engine without being asked for credentials
> + * - ca: string PEM data (use \n to seperate the lines)
> + *
> * (the file can be extended with extra groups or keys, which should
> * be prefixed with x- to avoid later conflicts)
> */
> @@ -79,6 +90,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 MAIN_GROUP "virt-viewer"
> +#define OVIRT_GROUP "ovirt"
>
> enum {
> PROP_DUMMY_PROPERTY,
> @@ -107,6 +119,10 @@ enum {
> PROP_SECURE_CHANNELS,
> PROP_DELETE_THIS_FILE,
> PROP_SECURE_ATTENTION,
> + PROP_OVIRT_HOST,
> + PROP_OVIRT_VM_GUID,
> + PROP_OVIRT_JSESSIONID,
> + PROP_OVIRT_CA,
> };
>
> VirtViewerFile*
> @@ -609,6 +625,58 @@ virt_viewer_file_set_secure_channels(VirtViewerFile*
> self, const gchar* const* v
> g_object_notify(G_OBJECT(self), "secure-channels");
> }
>
> +gchar*
> +virt_viewer_file_get_ovirt_host(VirtViewerFile* self)
> +{
> + return virt_viewer_file_get_string(self, OVIRT_GROUP, "ovirt-host");
> +}
> +
> +void
> +virt_viewer_file_set_ovirt_host(VirtViewerFile* self, const gchar* value)
> +{
> + virt_viewer_file_set_string(self, OVIRT_GROUP, "ovirt-host", value);
> + g_object_notify(G_OBJECT(self), "ovirt-host");
> +}
> +
> +gchar*
> +virt_viewer_file_get_ovirt_vm_guid(VirtViewerFile* self)
> +{
> + return virt_viewer_file_get_string(self, MAIN_GROUP, "ovirt-vm-guid");
> +}
> +
> +void
> +virt_viewer_file_set_ovirt_vm_guid(VirtViewerFile* self, const gchar* value)
> +{
> + virt_viewer_file_set_string(self, OVIRT_GROUP, "ovirt-vm-guid", value);
> + g_object_notify(G_OBJECT(self), "ovirt-vm-guid");
> +}
> +
> +gchar*
> +virt_viewer_file_get_ovirt_jsessionid(VirtViewerFile* self)
> +{
> + return virt_viewer_file_get_string(self, OVIRT_GROUP,
> "ovirt-jsessionid");
> +}
> +
> +void
> +virt_viewer_file_set_ovirt_jsessionid(VirtViewerFile* self, const gchar*
> value)
> +{
> + virt_viewer_file_set_string(self, OVIRT_GROUP, "ovirt-jsessionid",
> value);
> + g_object_notify(G_OBJECT(self), "ovirt-jsessionid");
> +}
> +
> +gchar*
> +virt_viewer_file_get_ovirt_ca(VirtViewerFile* self)
> +{
> + return virt_viewer_file_get_string(self, OVIRT_GROUP, "ovirt-ca");
> +}
> +
> +void
> +virt_viewer_file_set_ovirt_ca(VirtViewerFile* self, const gchar* value)
> +{
> + virt_viewer_file_set_string(self, OVIRT_GROUP, "ovirt-ca", value);
> + g_object_notify(G_OBJECT(self), "ovirt-ca");
> +}
> +
> static void
> spice_hotkey_set_accel(const gchar *accel_path, const gchar *key)
> {
> @@ -770,6 +838,18 @@ virt_viewer_file_set_property(GObject* object, guint
> property_id,
> case PROP_DELETE_THIS_FILE:
> virt_viewer_file_set_delete_this_file(self, g_value_get_int(value));
> break;
> + case PROP_OVIRT_HOST:
> + virt_viewer_file_set_ovirt_host(self, g_value_get_string(value));
> + break;
> + case PROP_OVIRT_VM_GUID:
> + virt_viewer_file_set_ovirt_vm_guid(self, g_value_get_string(value));
> + break;
> + case PROP_OVIRT_JSESSIONID:
> + virt_viewer_file_set_ovirt_jsessionid(self,
> g_value_get_string(value));
> + break;
> + case PROP_OVIRT_CA:
> + virt_viewer_file_set_ovirt_ca(self, g_value_get_string(value));
> + break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
> break;
> @@ -858,6 +938,18 @@ virt_viewer_file_get_property(GObject* object, guint
> property_id,
> case PROP_DELETE_THIS_FILE:
> g_value_set_int(value, virt_viewer_file_get_delete_this_file(self));
> break;
> + case PROP_OVIRT_HOST:
> + g_value_take_string(value, virt_viewer_file_get_ovirt_host(self));
> + break;
> + case PROP_OVIRT_VM_GUID:
> + g_value_take_string(value,
> virt_viewer_file_get_ovirt_vm_guid(self));
> + break;
> + case PROP_OVIRT_JSESSIONID:
> + g_value_take_string(value,
> virt_viewer_file_get_ovirt_jsessionid(self));
> + break;
> + case PROP_OVIRT_CA:
> + g_value_take_string(value, virt_viewer_file_get_ovirt_ca(self));
> + break;
> default:
> G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
> break;
> @@ -992,4 +1084,20 @@ virt_viewer_file_class_init(VirtViewerFileClass* klass)
> g_object_class_install_property(G_OBJECT_CLASS(klass),
> PROP_DELETE_THIS_FILE,
> g_param_spec_int("delete-this-file", "delete-this-file",
> "delete-this-file", 0, 1, 0,
> G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
> +
> + g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_HOST,
> + g_param_spec_string("ovirt-host", "ovirt-host", "ovirt-host", NULL,
> + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
> +
> + g_object_class_install_property(G_OBJECT_CLASS(klass),
> PROP_OVIRT_VM_GUID,
> + g_param_spec_string("ovirt-vm-guid", "ovirt-vm-guid",
> "ovirt-vm-guid", NULL,
> + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
> +
> + g_object_class_install_property(G_OBJECT_CLASS(klass),
> PROP_OVIRT_JSESSIONID,
> + g_param_spec_string("ovirt-jsessionid", "ovirt-jsessionid",
> "ovirt-jsessionid", NULL,
> + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
> +
> + g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OVIRT_CA,
> + g_param_spec_string("ovirt-ca", "ovirt-ca", "ovirt-ca", NULL,
> + G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE));
> }
> diff --git a/src/virt-viewer-file.h b/src/virt-viewer-file.h
> index 9507bf9..f4b030c 100644
> --- a/src/virt-viewer-file.h
> +++ b/src/virt-viewer-file.h
> @@ -108,6 +108,14 @@ gint
> virt_viewer_file_get_delete_this_file(VirtViewerFile* self);
> void virt_viewer_file_set_delete_this_file(VirtViewerFile* self, gint
> value);
> gchar* virt_viewer_file_get_secure_attention(VirtViewerFile* self);
> void virt_viewer_file_set_secure_attention(VirtViewerFile* self, const
> gchar* value);
> +gchar* virt_viewer_file_get_ovirt_host(VirtViewerFile* self);
> +void virt_viewer_file_set_ovirt_host(VirtViewerFile* self, const gchar*
> value);
> +gchar* virt_viewer_file_get_ovirt_vm_guid(VirtViewerFile* self);
> +void virt_viewer_file_set_ovirt_vm_guid(VirtViewerFile* self, const gchar*
> value);
> +gchar* virt_viewer_file_get_ovirt_jsessionid(VirtViewerFile* self);
> +void virt_viewer_file_set_ovirt_jsessionid(VirtViewerFile* self, const
> gchar* value);
> +gchar* virt_viewer_file_get_ovirt_ca(VirtViewerFile* self);
> +void virt_viewer_file_set_ovirt_ca(VirtViewerFile* self, const gchar*
> value);
>
> G_END_DECLS
>
> --
> 1.9.0
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
More information about the virt-tools-list
mailing list