[Libosinfo] [PATCH 02/12] media: API to get/set ISO9660 volume size

Fabiano Fidêncio fabiano at fidencio.org
Sun Mar 15 16:18:08 UTC 2015


On Sun, Mar 15, 2015 at 5:04 PM, Zeeshan Ali (Khattak)
<zeeshanak at gnome.org> wrote:
> ---
>  osinfo/libosinfo.syms |  5 +++++
>  osinfo/osinfo_media.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  osinfo/osinfo_media.h |  2 ++
>  3 files changed, 50 insertions(+)
>
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index 5c423b9..2dba411 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -505,6 +505,11 @@ LIBOSINFO_0.2.11 {
>         osinfo_install_script_get_needs_internet;
>  } LIBOSINFO_0.2.10;
>
> +LIBOSINFO_0.2.12 {
> +    global:
> +       osinfo_media_get_volume_size;
> +} LIBOSINFO_0.2.11;
> +
>  /* Symbols in next release...
>
>    LIBOSINFO_0.0.2 {
> diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
> index 96f9603..e86df11 100644
> --- a/osinfo/osinfo_media.c
> +++ b/osinfo/osinfo_media.c
> @@ -156,6 +156,7 @@ enum {
>      PROP_INSTALLER_REBOOTS,
>      PROP_OS,
>      PROP_LANGUAGES,
> +    PROP_VOLUME_SIZE
>  };
>
>  static void
> @@ -230,6 +231,11 @@ osinfo_media_get_property(GObject    *object,
>          g_value_set_pointer(value, osinfo_media_get_languages(media));
>          break;
>
> +    case PROP_VOLUME_SIZE:
> +        g_value_set_int64(value,
> +                          osinfo_media_get_volume_size(media));
> +        break;
> +
>      default:
>          /* We don't have any other property... */
>          G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
> @@ -320,6 +326,12 @@ osinfo_media_set_property(GObject      *object,
>          osinfo_media_set_languages(media, g_value_get_pointer(value));
>          break;
>
> +    case PROP_VOLUME_SIZE:
> +        osinfo_entity_set_param_int64(OSINFO_ENTITY(media),
> +                                      OSINFO_MEDIA_PROP_VOLUME_SIZE,
> +                                      g_value_get_int64(value));
> +        break;
> +
>      default:
>          /* We don't have any other property... */
>          G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
> @@ -547,6 +559,21 @@ osinfo_media_class_init(OsinfoMediaClass *klass)
>                                   G_PARAM_READABLE |
>                                   G_PARAM_STATIC_STRINGS);
>      g_object_class_install_property(g_klass, PROP_LANGUAGES, pspec);
> +
> +    /**
> +     * OsinfoMedia:volume-size:
> +     *
> +     * Expected volume size, in bytes for ISO9660 image/device.
> +     */
> +    pspec = g_param_spec_int64("volume-size",
> +                               "VolumeSize",
> +                               _("Expected ISO9660 volume size, in bytes"),
> +                               G_MININT,
> +                               G_MAXINT64,
> +                               1 /* default value */,
> +                               G_PARAM_READWRITE |
> +                               G_PARAM_STATIC_STRINGS);
> +    g_object_class_install_property(g_klass, PROP_VOLUME_SIZE, pspec);
>  }
>

Hmmm. I'd go for -1 as a default value.

>  static void
> @@ -1217,6 +1244,22 @@ void osinfo_media_set_languages(OsinfoMedia *media, GList *languages)
>                                  OSINFO_MEDIA_PROP_LANG,
>                                  it->data);
>  }
> +
> +/**
> + * osinfo_media_get_volume_size:
> + * @media: an #OsinfoMedia instance
> + *
> + * Returns: (transfer none): the ISO9660 volume size, in bytes or -1 if size is
> + * unknown or media is not a ISO9660 device/image.
> + */
> +gint64 osinfo_media_get_volume_size(OsinfoMedia *media)
> +{
> +    g_return_val_if_fail(OSINFO_IS_MEDIA(media), -1);
> +
> +    return osinfo_entity_get_param_value_int64_with_default
> +        (OSINFO_ENTITY(media), OSINFO_MEDIA_PROP_VOLUME_SIZE, -1);
> +}
> +
>  /*
>   * Local variables:
>   *  indent-tabs-mode: nil
> diff --git a/osinfo/osinfo_media.h b/osinfo/osinfo_media.h
> index 8cf3e05..8ad39c4 100644
> --- a/osinfo/osinfo_media.h
> +++ b/osinfo/osinfo_media.h
> @@ -86,6 +86,7 @@ typedef struct _OsinfoMediaPrivate OsinfoMediaPrivate;
>  #define OSINFO_MEDIA_PROP_LANG_REGEX     "l10n-language-regex"
>  #define OSINFO_MEDIA_PROP_LANG_MAP       "l10n-language-map"
>  #define OSINFO_MEDIA_PROP_VARIANT        "variant"
> +#define OSINFO_MEDIA_PROP_VOLUME_SIZE    "volume-size"
>
>  /* object */
>  struct _OsinfoMedia
> @@ -135,6 +136,7 @@ GList *osinfo_media_get_languages(OsinfoMedia *media);
>  gboolean osinfo_media_get_installer(OsinfoMedia *media);
>  gboolean osinfo_media_get_live(OsinfoMedia *media);
>  gint osinfo_media_get_installer_reboots(OsinfoMedia *media);
> +gint64 osinfo_media_get_volume_size(OsinfoMedia *media);
>
>  #endif /* __OSINFO_MEDIA_H__ */
>  /*
> --
> 2.1.0
>
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo



-- 
Fabiano Fidêncio




More information about the Libosinfo mailing list