[virt-tools-list] [libosinfo 5/8] Add API to add/list medias to/from OS

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Thu Aug 4 18:21:12 UTC 2011


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

---
 docs/reference/Libosinfo-sections.txt |    2 +
 osinfo/libosinfo.syms                 |    2 +
 osinfo/osinfo_os.c                    |   37 +++++++++++++++++++++++++++++++++
 osinfo/osinfo_os.h                    |    4 +++
 4 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/docs/reference/Libosinfo-sections.txt b/docs/reference/Libosinfo-sections.txt
index f8c7afd..0aee98f 100644
--- a/docs/reference/Libosinfo-sections.txt
+++ b/docs/reference/Libosinfo-sections.txt
@@ -111,6 +111,8 @@ osinfo_os_get_devices
 osinfo_os_get_device_links
 osinfo_os_add_device
 osinfo_os_get_family
+osinfo_os_get_media_list
+osinfo_os_add_media
 <SUBSECTION Standard>
 OSINFO_OS
 OSINFO_IS_OS
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index bb35021..aadcbc3 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -110,6 +110,8 @@ LIBOSINFO_0.0.1 {
 	osinfo_os_get_device_links;
 	osinfo_os_add_device;
 	osinfo_os_get_family;
+	osinfo_os_get_media_list;
+	osinfo_os_add_media;
 	osinfo_oslist_get_type;
 	osinfo_oslist_new;
 	osinfo_oslist_new_copy;
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index b0b6e4e..117e000 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -44,6 +44,8 @@ struct _OsinfoOsPrivate
 {
     // Value: List of device_link structs
     GList *deviceLinks;
+
+    OsinfoMediaList *medias;
 };
 
 struct _OsinfoOsDeviceLink {
@@ -136,6 +138,7 @@ osinfo_os_init (OsinfoOs *os)
     os->priv = priv = OSINFO_OS_GET_PRIVATE(os);
 
     os->priv->deviceLinks = NULL;
+    os->priv->medias = osinfo_medialist_new ();
 }
 
 /**
@@ -259,6 +262,40 @@ const gchar *osinfo_os_get_family(OsinfoOs *os)
     return osinfo_entity_get_param_value(OSINFO_ENTITY(os), "family");
 }
 
+/**
+ * osinfo_os_get_media_list:
+ * @os: an operating system
+ *
+ * Get all installation medias associated with operating system @os.
+ *
+ * Returns: (transfer full): A list of medias
+ */
+OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os)
+{
+    g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+    OsinfoMediaList *newList = osinfo_medialist_new();
+
+    osinfo_list_add_all(OSINFO_LIST(newList), OSINFO_LIST(os->priv->medias));
+
+    return newList;
+}
+
+/**
+ * osinfo_os_add_media:
+ * @os: an operating system
+ * @media: (transfer none): the media to add
+ *
+ * Adds installation media @media to operating system @os.
+ */
+void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media)
+{
+    g_return_if_fail(OSINFO_IS_OS(os));
+    g_return_if_fail(OSINFO_IS_MEDIA(media));
+
+    osinfo_list_add(OSINFO_LIST(os->priv->medias), OSINFO_ENTITY(media));
+}
+
 /*
  * Local variables:
  *  indent-tabs-mode: nil
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index f9ffb30..d1a0f9b 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -26,6 +26,8 @@
 #include <osinfo/osinfo_product.h>
 #include <osinfo/osinfo_device.h>
 #include <osinfo/osinfo_devicelist.h>
+#include <osinfo/osinfo_medialist.h>
+#include <osinfo/osinfo_media.h>
 
 #ifndef __OSINFO_OS_H__
 #define __OSINFO_OS_H__
@@ -76,6 +78,8 @@ OsinfoDeviceLinkList *osinfo_os_get_device_links(OsinfoOs *os, OsinfoFilter *fil
 
 OsinfoDeviceLink *osinfo_os_add_device(OsinfoOs *os, OsinfoDevice *dev);
 const gchar *osinfo_os_get_family(OsinfoOs *os);
+OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
+void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
 
 #endif /* __OSINFO_OS_H__ */
 /*
-- 
1.7.6




More information about the virt-tools-list mailing list