[Libosinfo] [libosinfo PATCH v4 07/10] os: Introduce APIs to deal with images

Fabiano Fidêncio fidencio at redhat.com
Fri Nov 23 10:54:41 UTC 2018


Let's introduce the needed APIs on os side to deal will the images.
For now, there's no info being loaded as the loader part depends on one
of these APIs.

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

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/libosinfo.syms |  2 ++
 osinfo/osinfo_os.c    | 37 +++++++++++++++++++++++++++++++++++++
 osinfo/osinfo_os.h    |  4 ++++
 3 files changed, 43 insertions(+)

diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
index abc72b0..5aac58e 100644
--- a/osinfo/libosinfo.syms
+++ b/osinfo/libosinfo.syms
@@ -542,8 +542,10 @@ LIBOSINFO_1.3.0 {
 	osinfo_imagelist_get_type;
 	osinfo_imagelist_new;
 
+	osinfo_os_add_image;
 	osinfo_os_add_maximum_resources;
 	osinfo_os_get_all_device_links;
+	osinfo_os_get_image_list;
 	osinfo_os_get_maximum_resources;
 } LIBOSINFO_0.2.13;
 
diff --git a/osinfo/osinfo_os.c b/osinfo/osinfo_os.c
index 303fe73..801afda 100644
--- a/osinfo/osinfo_os.c
+++ b/osinfo/osinfo_os.c
@@ -54,6 +54,7 @@ struct _OsinfoOsPrivate
 
     OsinfoMediaList *medias;
     OsinfoTreeList *trees;
+    OsinfoImageList *images;
     OsinfoOsVariantList *variants;
     OsinfoResourcesList *minimum;
     OsinfoResourcesList *recommended;
@@ -119,6 +120,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);
@@ -185,6 +187,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();
@@ -676,6 +679,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 ed132b8..4eb4b1b 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__
@@ -117,6 +119,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




More information about the Libosinfo mailing list