[libosinfo PATCH v3 3/5] install-script: Add _(get|set)_installation_source()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As install-scripts may behave differently depending on their
installation source, let's add two new methods to properly set what's
the installation source being used with the script and then decide what
we should do depending on the installation-source value.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 osinfo/libosinfo.syms          |  3 ++
 osinfo/osinfo_install_script.c | 58 +++++++++++++++++++++++++++++++++-
 osinfo/osinfo_install_script.h | 11 +++++++
 3 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index 0272e94..56cf9a5 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -543,7 +543,10 @@ LIBOSINFO_1.3.0 {
 	osinfo_imagelist_get_type;
 	osinfo_imagelist_new;
 
+	osinfo_install_script_get_installation_source;
 	osinfo_install_script_get_preferred_injection_method;
+	osinfo_install_script_installation_source_get_type;
+	osinfo_install_script_set_installation_source;
 	osinfo_install_script_set_preferred_injection_method;
 
 	osinfo_media_supports_installer_script;
diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c
index ff8a72e..19b9354 100644
--- a/osinfo/osinfo_install_script.c
+++ b/osinfo/osinfo_install_script.c
@@ -64,7 +64,8 @@ enum {
     PROP_PRODUCT_KEY_FORMAT,
     PROP_PATH_FORMAT,
     PROP_AVATAR_FORMAT,
-    PROP_PREFERRED_INJECTION_METHOD
+    PROP_PREFERRED_INJECTION_METHOD,
+    PROP_INSTALLATION_SOURCE
 };
 
 typedef struct _OsinfoInstallScriptGenerateData OsinfoInstallScriptGenerateData;
@@ -111,6 +112,11 @@ osinfo_install_script_set_property(GObject    *object,
                                                              g_value_get_flags(value));
         break;
 
+    case PROP_INSTALLATION_SOURCE:
+        osinfo_install_script_set_installation_source(script,
+                                                      g_value_get_enum(value));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -162,6 +168,11 @@ osinfo_install_script_get_property(GObject    *object,
                           osinfo_install_script_get_preferred_injection_method(script));
         break;
 
+    case PROP_INSTALLATION_SOURCE:
+        g_value_set_enum(value,
+                         osinfo_install_script_get_installation_source(script));
+        break;
+
     default:
         /* We don't have any other property... */
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@@ -277,6 +288,17 @@ osinfo_install_script_class_init(OsinfoInstallScriptClass *klass)
                                     PROP_PREFERRED_INJECTION_METHOD,
                                     pspec);
 
+    pspec = g_param_spec_enum("installation-source",
+                              "Installation Source",
+                              _("The installation source to be used"),
+                              OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE,
+                              OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+                              G_PARAM_READABLE |
+                              G_PARAM_STATIC_STRINGS);
+    g_object_class_install_property(g_klass,
+                                    PROP_INSTALLATION_SOURCE,
+                                    pspec);
+
     g_type_class_add_private(klass, sizeof(OsinfoInstallScriptPrivate));
 }
 
@@ -1855,6 +1877,40 @@ osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script
     return value->value;
 }
 
+/**
+ * osinfo_install_script_set_installation_source:
+ * @script: the install script
+ * @source: one of the installation sources:
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_NETWORK
+ *
+ * Set the installation source to be used with the @script.
+ */
+void osinfo_install_script_set_installation_source(OsinfoInstallScript *script,
+                                                   OsinfoInstallScriptInstallationSource source)
+{
+    osinfo_entity_set_param_enum(OSINFO_ENTITY(script),
+            OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE,
+            source,
+            OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE);
+}
+
+/**
+ * osinfo_install_script_get_installation_source:
+ * @script: the install script
+ *
+ * Returns: the installation source to be used with the script. If none is set, it defaults to
+ * OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA.
+ */
+OsinfoInstallScriptInstallationSource
+osinfo_install_script_get_installation_source(OsinfoInstallScript *script)
+{
+    return osinfo_entity_get_param_value_enum(OSINFO_ENTITY(script),
+            OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE,
+            OSINFO_TYPE_INSTALL_SCRIPT_INSTALLATION_SOURCE,
+            OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA);
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_install_script.h b/osinfo/osinfo_install_script.h
index ed634db..3e513e6 100644
--- a/osinfo/osinfo_install_script.h
+++ b/osinfo/osinfo_install_script.h
@@ -61,6 +61,7 @@ typedef struct _OsinfoInstallScriptPrivate OsinfoInstallScriptPrivate;
 #define OSINFO_INSTALL_SCRIPT_PROP_POST_INSTALL_DRIVERS_SIGNING_REQ "post-install-drivers-signing-req"
 #define OSINFO_INSTALL_SCRIPT_PROP_INJECTION_METHOD "injection-method"
 #define OSINFO_INSTALL_SCRIPT_PROP_PREFERRED_INJECTION_METHOD "preferred-injection-method"
+#define OSINFO_INSTALL_SCRIPT_PROP_INSTALLATION_SOURCE "installation-source"
 
 /* object */
 struct _OsinfoInstallScript
@@ -135,6 +136,11 @@ typedef enum {
     OSINFO_INSTALL_SCRIPT_INJECTION_METHOD_WEB    = 1 << 4,
 } OsinfoInstallScriptInjectionMethod;
 
+typedef enum {
+    OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_MEDIA,
+    OSINFO_INSTALL_SCRIPT_INSTALLATION_SOURCE_NETWORK
+} OsinfoInstallScriptInstallationSource;
+
 GType osinfo_install_script_get_type(void);
 
 OsinfoInstallScript *osinfo_install_script_new(const gchar *id);
@@ -259,6 +265,11 @@ gboolean osinfo_install_script_get_needs_internet(OsinfoInstallScript *script);
 void osinfo_install_script_set_preferred_injection_method(OsinfoInstallScript *script,
                                                           OsinfoInstallScriptInjectionMethod method);
 OsinfoInstallScriptInjectionMethod osinfo_install_script_get_preferred_injection_method(OsinfoInstallScript *script);
+
+void osinfo_install_script_set_installation_source(OsinfoInstallScript *script,
+                                                   OsinfoInstallScriptInstallationSource installer);
+OsinfoInstallScriptInstallationSource osinfo_install_script_get_installation_source(OsinfoInstallScript *script);
+
 #endif /* __OSINFO_INSTALL_SCRIPT_H__ */
 /*
  * Local variables:
-- 
2.19.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux