[libosinfo PATCH 5/6] os: Introduce APIs to deal with images

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

 



Now that we can load images' information from osinfo-db, let's introduce
the APIs needed to add and list the images related to an OS.

https://gitlab.com/libosinfo/osinfo-db/issues/10

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 osinfo/osinfo_os.c | 37 +++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_os.h |  4 ++++
 2 files changed, 41 insertions(+)

diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 4f74331..6e12a06 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -52,6 +52,7 @@ struct _OsinfoOsPrivate
 
     OsinfoMediaList *medias;
     OsinfoTreeList *trees;
+    OsinfoImageList *images;
     OsinfoOsVariantList *variants;
     OsinfoResourcesList *minimum;
     OsinfoResourcesList *recommended;
@@ -116,6 +117,7 @@ osinfo_os_finalize(GObject *object)
     g_list_free(os->priv->deviceLinks);
     g_object_unref(os->priv->medias);
     g_object_unref(os->priv->trees);
+    g_object_unref(os->priv->images);
     g_object_unref(os->priv->variants);
     g_object_unref(os->priv->minimum);
     g_object_unref(os->priv->recommended);
@@ -181,6 +183,7 @@ osinfo_os_init(OsinfoOs *os)
     os->priv->deviceLinks = NULL;
     os->priv->medias = osinfo_medialist_new();
     os->priv->trees = osinfo_treelist_new();
+    os->priv->images = osinfo_imagelist_new();
     os->priv->variants = osinfo_os_variantlist_new();
     os->priv->minimum = osinfo_resourceslist_new();
     os->priv->recommended = osinfo_resourceslist_new();
@@ -494,6 +497,40 @@ void osinfo_os_add_tree(OsinfoOs *os, OsinfoTree *tree)
     osinfo_list_add(OSINFO_LIST(os->priv->trees), OSINFO_ENTITY(tree));
 }
 
+/**
+ * osinfo_os_get_image_list:
+ * @os: an operating system
+ *
+ * Get all installed images associated with operating system @os.
+ *
+ * Returns: (transfer full): A list of images
+ */
+OsinfoImageList *osinfo_os_get_image_list(OsinfoOs *os)
+{
+    g_return_val_if_fail(OSINFO_IS_OS(os), NULL);
+
+    OsinfoImageList *newList = osinfo_imagelist_new();
+
+    osinfo_list_add_all(OSINFO_LIST(newList), OSINFO_LIST(os->priv->images));
+
+    return newList;
+}
+
+/**
+ * osinfo_os_add_image:
+ * @os: an operating system
+ * @image: (transfer none): the image to add
+ *
+ * Adds an installed image @image to operating system @os.
+ */
+void osinfo_os_add_image(OsinfoOs *os, OsinfoImage *image)
+{
+    g_return_if_fail(OSINFO_IS_OS(os));
+    g_return_if_fail(OSINFO_IS_IMAGE(image));
+
+    osinfo_list_add(OSINFO_LIST(os->priv->images), OSINFO_ENTITY(image));
+}
+
 /**
  * osinfo_os_get_variant_list:
  * @os: an operating system
diff --git a/osinfo/osinfo_os.h b/osinfo/osinfo_os.h
index 96bd6e3..d51bbb4 100644
--- a/osinfo/osinfo_os.h
+++ b/osinfo/osinfo_os.h
@@ -34,6 +34,8 @@
 #include <osinfo/osinfo_tree.h>
 #include <osinfo/osinfo_resources.h>
 #include <osinfo/osinfo_resourceslist.h>
+#include <osinfo/osinfo_image.h>
+#include <osinfo/osinfo_imagelist.h>
 
 #ifndef __OSINFO_OS_H__
 #define __OSINFO_OS_H__
@@ -116,6 +118,8 @@ OsinfoMediaList *osinfo_os_get_media_list(OsinfoOs *os);
 void osinfo_os_add_media(OsinfoOs *os, OsinfoMedia *media);
 OsinfoTreeList *osinfo_os_get_tree_list(OsinfoOs *os);
 void osinfo_os_add_tree(OsinfoOs *os, OsinfoTree *tree);
+OsinfoImageList *osinfo_os_get_image_list(OsinfoOs *os);
+void osinfo_os_add_image(OsinfoOs *os, OsinfoImage *image);
 OsinfoOsVariantList *osinfo_os_get_variant_list(OsinfoOs *os);
 void osinfo_os_add_variant(OsinfoOs *os, OsinfoOsVariant *variant);
 OsinfoResourcesList *osinfo_os_get_minimum_resources(OsinfoOs *os);
-- 
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