Adding this class more fore completness to the GVirConfigDomainGraphicsRemote than for any other reason. This patch introduces a new hierarchy in the project, where, instead of having GVirConfigDomainGraphics{Desktop,Sdl} inheriting from GVirConfigDomainGraphics, these classes will inherit from GVirConfigDomainGraphicsLocal (see the next patches), which inherits from GVirConfigDomainGraphics (it will cause ABI breakages, though). Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- libvirt-gconfig/Makefile.am | 2 + .../libvirt-gconfig-domain-graphics-local.c | 97 ++++++++++++++++++++++ .../libvirt-gconfig-domain-graphics-local.h | 68 +++++++++++++++ libvirt-gconfig/libvirt-gconfig.h | 1 + libvirt-gconfig/libvirt-gconfig.sym | 3 + po/POTFILES.in | 1 + 6 files changed, 172 insertions(+) create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 45fc559..5361fa7 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -46,6 +46,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-filesys.h \ libvirt-gconfig-domain-graphics.h \ libvirt-gconfig-domain-graphics-desktop.h \ + libvirt-gconfig-domain-graphics-local.h \ libvirt-gconfig-domain-graphics-rdp.h \ libvirt-gconfig-domain-graphics-remote.h \ libvirt-gconfig-domain-graphics-sdl.h \ @@ -138,6 +139,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-filesys.c \ libvirt-gconfig-domain-graphics.c \ libvirt-gconfig-domain-graphics-desktop.c \ + libvirt-gconfig-domain-graphics-local.c \ libvirt-gconfig-domain-graphics-rdp.c \ libvirt-gconfig-domain-graphics-remote.c \ libvirt-gconfig-domain-graphics-sdl.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c new file mode 100644 index 0000000..3a0fe51 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c @@ -0,0 +1,97 @@ +/* + * libvirt-gconfig-domain-graphics-local.c: libvirt domain graphics local configuration + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + * + * Author: Fabiano Fidêncio <fidencio@xxxxxxxxxx> + */ + +#include <config.h> + +#include <glib/gi18n-lib.h> + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-private.h" + +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalPrivate)) + +struct _GVirConfigDomainGraphicsLocalPrivate +{ + gboolean unused; +}; + +typedef GVirConfigObject *(*GVirConfigDomainGraphicsLocalNewFromXml)(const gchar *xml, GError **error); + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainGraphicsLocal, gvir_config_domain_graphics_local, GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS); + +static void gvir_config_domain_graphics_local_class_init(GVirConfigDomainGraphicsLocalClass *klass) +{ + g_type_class_add_private(klass, sizeof(GVirConfigDomainGraphicsLocalPrivate)); +} + +static void gvir_config_domain_graphics_local_init(GVirConfigDomainGraphicsLocal *graphics) +{ + graphics->priv = GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_PRIVATE(graphics); +} + +GVirConfigDomainGraphicsLocal * +gvir_config_domain_graphics_local_new_from_xml(const gchar *xml, + GError **error) +{ + GVirConfigDomainGraphicsLocalNewFromXml functions[] = { + (GVirConfigDomainGraphicsLocalNewFromXml)gvir_config_domain_graphics_sdl_new_from_xml, + (GVirConfigDomainGraphicsLocalNewFromXml)gvir_config_domain_graphics_desktop_new_from_xml, + }; + GVirConfigObject *object; + + for (int i = 0; i < G_N_ELEMENTS(functions); i++) { + GVirConfigDomainGraphicsLocalNewFromXml function = functions[i]; + + object = GVIR_CONFIG_OBJECT(function(xml, error)); + if (object != NULL) + break; + } + + if (object == NULL) { + g_set_error(error, + GVIR_CONFIG_OBJECT_ERROR, + 0, + _("Unable to create a new GraphicLocal object from the XML")); + } + + return GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(object); +} + +const gchar *gvir_config_domain_graphics_local_get_display(GVirConfigDomainGraphicsLocal *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(graphics), NULL); + + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(graphics), + NULL, + "display"); +} + +gboolean gvir_config_domain_graphics_local_get_fullscreen(GVirConfigDomainGraphicsLocal *graphics) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(graphics), FALSE); + + return gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(graphics), + NULL, + "fullscreen", + FALSE); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h new file mode 100644 index 0000000..6494e42 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h @@ -0,0 +1,68 @@ +/* + * libvirt-gconfig-domain-graphics-local.h: libvirt domain graphics local configuration + * + * Copyright (C) 2016 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + * + * Author: Fabiano Fidêncio <fidencio@xxxxxxxxxx> + */ + +#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD) +#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly." +#endif + +#ifndef __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LOCAL_H__ +#define __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LOCAL_H__ + +G_BEGIN_DECLS + +#define GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL (gvir_config_domain_graphics_local_get_type ()) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocal)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalClass)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL)) +#define GVIR_CONFIG_IS_DOMAIN_GRAPHICS_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL)) +#define GVIR_CONFIG_DOMAIN_GRAPHICS_LOCAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_GRAPHICS_LOCAL, GVirConfigDomainGraphicsLocalClass)) + +typedef struct _GVirConfigDomainGraphicsLocal GVirConfigDomainGraphicsLocal; +typedef struct _GVirConfigDomainGraphicsLocalPrivate GVirConfigDomainGraphicsLocalPrivate; +typedef struct _GVirConfigDomainGraphicsLocalClass GVirConfigDomainGraphicsLocalClass; + +struct _GVirConfigDomainGraphicsLocal +{ + GVirConfigDomainGraphics parent; + + GVirConfigDomainGraphicsLocalPrivate *priv; + + /* Do not add fields to this struct */ +}; + +struct _GVirConfigDomainGraphicsLocalClass +{ + GVirConfigDomainGraphicsClass parent_class; + + gpointer padding[20]; +}; + +GType gvir_config_domain_graphics_local_get_type(void); + +GVirConfigDomainGraphicsLocal *gvir_config_domain_graphics_local_new_from_xml(const gchar *xml, + GError **error); +const gchar *gvir_config_domain_graphics_local_get_display(GVirConfigDomainGraphicsLocal *graphics); +gboolean gvir_config_domain_graphics_local_get_fullscreen(GVirConfigDomainGraphicsLocal *graphics); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_DOMAIN_GRAPHICS_LOCAL_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 1ff369b..22e9c67 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -62,6 +62,7 @@ #include <libvirt-gconfig/libvirt-gconfig-domain-disk-driver.h> #include <libvirt-gconfig/libvirt-gconfig-domain-filesys.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics.h> +#include <libvirt-gconfig/libvirt-gconfig-domain-graphics-local.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-desktop.h> #include <libvirt-gconfig/libvirt-gconfig-domain-graphics-rdp.h> diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 6dca69a..bb745f5 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -735,6 +735,9 @@ global: LIBVIRT_GCONFIG_0.2.4 { global: + gvir_config_domain_graphics_local_get_display; + gvir_config_domain_graphics_local_get_fullscreen; + gvir_config_domain_graphics_local_get_type; gvir_config_domain_graphics_rdp_get_autoport; gvir_config_domain_graphics_rdp_get_host; gvir_config_domain_graphics_rdp_set_host; diff --git a/po/POTFILES.in b/po/POTFILES.in index da68459..7102849 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ libvirt-gconfig/libvirt-gconfig-helpers.c libvirt-gconfig/libvirt-gconfig-object.c +libvirt-gconfig/libvirt-gconfig-domain-graphics-local.c libvirt-gconfig/libvirt-gconfig-domain-graphics-remote.c libvirt-gobject/libvirt-gobject-connection.c libvirt-gobject/libvirt-gobject-stream.c -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list