[Libosinfo] [libosinfo 3/3] Implement osinfo_platform_get_all_devices()
Christophe Fergeau
cfergeau at redhat.com
Wed Apr 3 08:04:07 UTC 2013
On Tue, Apr 02, 2013 at 05:39:47PM +0300, Zeeshan Ali (Khattak) wrote:
> On Tue, Apr 2, 2013 at 12:17 PM, Christophe Fergeau <cfergeau at redhat.com> wrote:
> > ---
> > osinfo/libosinfo.syms | 4 ++++
> > osinfo/osinfo_platform.c | 38 ++++++++++++++++++++++++++++++++++++++
> > osinfo/osinfo_platform.h | 1 +
> > 3 files changed, 43 insertions(+)
> >
> > diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> > index 45689a2..8fcf327 100644
> > --- a/osinfo/libosinfo.syms
> > +++ b/osinfo/libosinfo.syms
> > @@ -413,6 +413,10 @@ LIBOSINFO_0.2.6 {
> > osinfo_install_script_get_post_install_drivers_signing_req;
> > } LIBOSINFO_0.2.3;
> >
> > +LIBOSINFO_0.2.7 {
> > + osinfo_platform_get_all_devices;
> > +} LIBOSINFO_0.2.6;
> > +
> > /* Symbols in next release...
> >
> > LIBOSINFO_0.0.2 {
> > diff --git a/osinfo/osinfo_platform.c b/osinfo/osinfo_platform.c
> > index 222eb93..1bb3ecf 100644
> > --- a/osinfo/osinfo_platform.c
> > +++ b/osinfo/osinfo_platform.c
> > @@ -25,6 +25,7 @@
> > #include <config.h>
> >
> > #include <osinfo/osinfo.h>
> > +#include "osinfo/osinfo_product_private.h"
> > #include <glib/gi18n-lib.h>
> >
> > G_DEFINE_TYPE (OsinfoPlatform, osinfo_platform, OSINFO_TYPE_PRODUCT);
> > @@ -101,6 +102,43 @@ OsinfoPlatform *osinfo_platform_new(const gchar *id)
> > NULL);
> > }
> >
> > +struct GetAllDevicesData {
> > + OsinfoFilter *filter;
> > + OsinfoDeviceList *devices;
> > +};
> > +
> > +static void get_all_devices_cb(OsinfoProduct *product, gpointer user_data)
> > +{
> > + OsinfoDeviceList *devices;
> > + OsinfoList *tmp_list;
> > + struct GetAllDevicesData *foreach_data = (struct GetAllDevicesData *)user_data;
> > +
> > + g_return_if_fail(OSINFO_IS_PLATFORM(product));
> > +
> > + devices = osinfo_platform_get_devices(OSINFO_PLATFORM(product),
> > + foreach_data->filter);
> > + tmp_list = osinfo_list_new_union(OSINFO_LIST(foreach_data->devices),
> > + OSINFO_LIST(devices));
> > + g_object_unref(foreach_data->devices);
> > + g_object_unref(devices);
> > + foreach_data->devices = OSINFO_DEVICELIST(tmp_list);
> > +}
>
> Some docs would be nice.
>
> > +OsinfoDeviceList *osinfo_platform_get_all_devices(OsinfoPlatform *platform,
> > + OsinfoFilter *filter)
> > +{
> > + struct GetAllDevicesData foreach_data = {
> > + .filter = filter,
> > + .devices = osinfo_devicelist_new()
> > + };
> > +
> > + osinfo_product_foreach_related(OSINFO_PRODUCT(platform),
> > + OSINFO_PRODUCT_FOREACH_FLAG_UPGRADES,
> > + get_all_devices_cb,
> > + &foreach_data);
>
> Seems in _os_get_all_devices() we are looking for `DERIVES_FROM |
> CLONES`, Some reasoning for this contrast would be nice.
For some reason, I'm only seeing this email after pushing, I thought
everything was ACK'ed, sorry for that. I'll send a followup patch.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20130403/3603e97b/attachment.sig>
More information about the Libosinfo
mailing list