summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2021-05-20 15:14:16 +0200
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2021-05-20 17:33:16 -0400
commit3741c6842b676d33e235a43098a4647cae84d4e1 (patch)
tree68646d8ff4fad875cc8ccf83e5f8bffdb37cf2f5 /lib
parent820bdadd9b83190e964ffc56e9a3ee542353eefb (diff)
PkDetails: Add 'download-size' property
This can be used to distinguish the download size and whether the package is already downloaded; use this in the dnf backend.
Diffstat (limited to 'lib')
-rw-r--r--lib/packagekit-glib2/pk-client.c2
-rw-r--r--lib/packagekit-glib2/pk-details.c36
-rw-r--r--lib/packagekit-glib2/pk-details.h1
3 files changed, 39 insertions, 0 deletions
diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c
index 33e599625..dd6165b16 100644
--- a/lib/packagekit-glib2/pk-client.c
+++ b/lib/packagekit-glib2/pk-client.c
@@ -1109,6 +1109,8 @@ pk_client_signal_cb (GDBusProxy *proxy,
g_object_set (item, "group", g_variant_get_uint32 (value), NULL);
else if (g_strcmp0 (key, "size") == 0)
g_object_set (item, "size", g_variant_get_uint64 (value), NULL);
+ else if (g_strcmp0 (key, "download-size") == 0)
+ g_object_set (item, "download-size", g_variant_get_uint64 (value), NULL);
else
g_object_set (item, key, g_variant_get_string (value, NULL), NULL);
}
diff --git a/lib/packagekit-glib2/pk-details.c b/lib/packagekit-glib2/pk-details.c
index fc1d6f000..5e71a5c5d 100644
--- a/lib/packagekit-glib2/pk-details.c
+++ b/lib/packagekit-glib2/pk-details.c
@@ -53,6 +53,7 @@ struct _PkDetailsPrivate
gchar *url;
gchar *summary;
guint64 size;
+ guint64 download_size;
};
enum {
@@ -64,6 +65,7 @@ enum {
PROP_URL,
PROP_SIZE,
PROP_SUMMARY,
+ PROP_DOWNLOAD_SIZE,
PROP_LAST
};
@@ -189,6 +191,23 @@ pk_details_get_size (PkDetails *details)
return details->priv->size;
}
+/**
+ * pk_details_get_download_size:
+ * @details: a #PkDetails instance
+ *
+ * Gets the package download size.
+ *
+ * Returns: the package download size, 0 if already downloaded and G_MAXUINT64 when unknown
+ *
+ * Since: 1.2.4
+ **/
+guint64
+pk_details_get_download_size (PkDetails *details)
+{
+ g_return_val_if_fail (details != NULL, G_MAXUINT64);
+ return details->priv->download_size;
+}
+
/*
* pk_details_get_property:
**/
@@ -220,6 +239,9 @@ pk_details_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case PROP_SUMMARY:
g_value_set_string (value, priv->summary);
break;
+ case PROP_DOWNLOAD_SIZE:
+ g_value_set_uint64 (value, priv->download_size);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -262,6 +284,9 @@ pk_details_set_property (GObject *object, guint prop_id, const GValue *value, GP
case PROP_SIZE:
priv->size = g_value_get_uint64 (value);
break;
+ case PROP_DOWNLOAD_SIZE:
+ priv->download_size = g_value_get_uint64 (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -350,6 +375,16 @@ pk_details_class_init (PkDetailsClass *klass)
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SUMMARY, pspec);
+ /**
+ * PkDetails:download-size:
+ *
+ * Since: 1.2.4
+ */
+ pspec = g_param_spec_uint64 ("download-size", NULL, NULL,
+ 0, G_MAXUINT64, G_MAXUINT64,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_DOWNLOAD_SIZE, pspec);
+
g_type_class_add_private (klass, sizeof (PkDetailsPrivate));
}
@@ -360,6 +395,7 @@ static void
pk_details_init (PkDetails *details)
{
details->priv = PK_DETAILS_GET_PRIVATE (details);
+ details->priv->download_size = G_MAXUINT64;
}
/*
diff --git a/lib/packagekit-glib2/pk-details.h b/lib/packagekit-glib2/pk-details.h
index 611a04ccf..7828aeccc 100644
--- a/lib/packagekit-glib2/pk-details.h
+++ b/lib/packagekit-glib2/pk-details.h
@@ -75,6 +75,7 @@ const gchar *pk_details_get_description (PkDetails *details);
const gchar *pk_details_get_url (PkDetails *details);
guint64 pk_details_get_size (PkDetails *details);
const gchar *pk_details_get_summary (PkDetails *details);
+guint64 pk_details_get_download_size (PkDetails *details);
G_END_DECLS