summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2021-05-20 15:31:04 +0200
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2021-05-20 17:31:43 -0400
commitb30ab47408a4e888c1d4e75319ce272e83b6d8ae (patch)
treeb970f58bd0b2c5fb6910a55f12186294dfe2fafd /lib
parentf586aa896a8a354135d8241bcede50af59c38b73 (diff)
PkPackage: Add update severity property
This can be used by backends, to provide an update severity for the package.
Diffstat (limited to 'lib')
-rw-r--r--lib/packagekit-glib2/pk-client.c8
-rw-r--r--lib/packagekit-glib2/pk-enum.c1
-rw-r--r--lib/packagekit-glib2/pk-enum.h2
-rw-r--r--lib/packagekit-glib2/pk-package.c72
-rw-r--r--lib/packagekit-glib2/pk-package.h4
5 files changed, 85 insertions, 2 deletions
diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c
index 8b47ff8ee..33e599625 100644
--- a/lib/packagekit-glib2/pk-client.c
+++ b/lib/packagekit-glib2/pk-client.c
@@ -753,6 +753,7 @@ pk_client_properties_changed_cb (GDBusProxy *proxy,
static void
pk_client_signal_package (PkClientState *state,
PkInfoEnum info_enum,
+ PkInfoEnum update_severity,
const gchar *package_id,
const gchar *summary)
{
@@ -769,6 +770,7 @@ pk_client_signal_package (PkClientState *state,
g_object_set (package,
"info", info_enum,
"summary", summary,
+ "update-severity", update_severity,
"role", state->role,
"transaction-id", state->transaction_id,
NULL);
@@ -1083,8 +1085,12 @@ pk_client_signal_cb (GDBusProxy *proxy,
&tmp_uint,
&tmp_str[1],
&tmp_str[2]);
+ /* The 'info' and 'update-severity' are encoded in the single value */
+ tmp_uint2 = tmp_uint & 0xFFFF;
+ tmp_uint3 = (tmp_uint >> 16) & 0xFFFF;
pk_client_signal_package (state,
- tmp_uint,
+ tmp_uint2,
+ tmp_uint3,
tmp_str[1],
tmp_str[2]);
return;
diff --git a/lib/packagekit-glib2/pk-enum.c b/lib/packagekit-glib2/pk-enum.c
index a0ca160d4..55f6e753a 100644
--- a/lib/packagekit-glib2/pk-enum.c
+++ b/lib/packagekit-glib2/pk-enum.c
@@ -321,6 +321,7 @@ static const PkEnumMatch enum_info[] = {
{PK_INFO_ENUM_DECOMPRESSING, "decompressing"},
{PK_INFO_ENUM_UNTRUSTED, "untrusted"},
{PK_INFO_ENUM_TRUSTED, "trusted"},
+ {PK_INFO_ENUM_CRITICAL, "critical"},
{0, NULL}
};
diff --git a/lib/packagekit-glib2/pk-enum.h b/lib/packagekit-glib2/pk-enum.h
index 3838b6fcc..8f4570a0b 100644
--- a/lib/packagekit-glib2/pk-enum.h
+++ b/lib/packagekit-glib2/pk-enum.h
@@ -642,6 +642,7 @@ typedef enum {
* @PK_INFO_ENUM_UNTRUSTED:
* @PK_INFO_ENUM_TRUSTED:
* @PK_INFO_ENUM_UNAVAILABLE: Package is unavailable
+ * @PK_INFO_ENUM_CRITICAL: Update severity is critical; Since: 1.2.4
* @PK_INFO_ENUM_LAST:
*
* The enumerated types used in Package() - these have to refer to a specific
@@ -674,6 +675,7 @@ typedef enum {
PK_INFO_ENUM_UNTRUSTED,
PK_INFO_ENUM_TRUSTED,
PK_INFO_ENUM_UNAVAILABLE,
+ PK_INFO_ENUM_CRITICAL, /* Since: 1.2.4 */
PK_INFO_ENUM_LAST
} PkInfoEnum;
diff --git a/lib/packagekit-glib2/pk-package.c b/lib/packagekit-glib2/pk-package.c
index a4d4e7345..5f2ee9624 100644
--- a/lib/packagekit-glib2/pk-package.c
+++ b/lib/packagekit-glib2/pk-package.c
@@ -70,6 +70,7 @@ struct _PkPackagePrivate
PkUpdateStateEnum update_state;
gchar *update_issued;
gchar *update_updated;
+ PkInfoEnum update_severity;
};
enum {
@@ -98,6 +99,7 @@ enum {
PROP_UPDATE_STATE,
PROP_UPDATE_ISSUED,
PROP_UPDATE_UPDATED,
+ PROP_UPDATE_SEVERITY,
PROP_LAST
};
@@ -479,6 +481,9 @@ pk_package_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
case PROP_UPDATE_UPDATED:
g_value_set_string (value, priv->update_updated);
break;
+ case PROP_UPDATE_SEVERITY:
+ g_value_set_enum (value, priv->update_severity);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -561,6 +566,9 @@ pk_package_set_property (GObject *object, guint prop_id, const GValue *value, GP
g_free (priv->update_updated);
priv->update_updated = g_strdup (g_value_get_string (value));
break;
+ case PROP_UPDATE_SEVERITY:
+ pk_package_set_update_severity (package, g_value_get_enum (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -789,6 +797,20 @@ pk_package_class_init (PkPackageClass *klass)
g_object_class_install_property (object_class, PROP_UPDATE_UPDATED, pspec);
/**
+ * PkPackage:update-severity:
+ *
+ * Can be one of %PK_INFO_ENUM_UNKNOWN, %PK_INFO_ENUM_LOW, %PK_INFO_ENUM_NORMAL,
+ * %PK_INFO_ENUM_IMPORTANT or %PK_INFO_ENUM_CRITICAL.
+ *
+ * Since: 1.2.4
+ */
+ pspec = g_param_spec_enum ("update-severity", NULL,
+ "Package update severity",
+ PK_TYPE_INFO_ENUM, PK_INFO_ENUM_UNKNOWN,
+ G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_UPDATE_SEVERITY, pspec);
+
+ /**
* PkPackage::changed:
* @package: the #PkPackage instance that emitted the signal
*
@@ -861,3 +883,53 @@ pk_package_new (void)
package = g_object_new (PK_TYPE_PACKAGE, NULL);
return PK_PACKAGE (package);
}
+
+/**
+ * pk_package_get_update_severity:
+ * @package: a #PkPackage
+ *
+ * Returns the @package update severity. Can be one of %PK_INFO_ENUM_UNKNOWN,
+ * %PK_INFO_ENUM_LOW, %PK_INFO_ENUM_NORMAL, %PK_INFO_ENUM_IMPORTANT or
+ * %PK_INFO_ENUM_CRITICAL.
+ *
+ * Returns: the @package update severity, if known.
+ *
+ * Since: 1.2.4
+ **/
+PkInfoEnum
+pk_package_get_update_severity (PkPackage *package)
+{
+ g_return_val_if_fail (PK_IS_PACKAGE (package), PK_INFO_ENUM_UNKNOWN);
+
+ return package->priv->update_severity;
+}
+
+/**
+ * pk_package_set_update_severity:
+ * @package: a #PkPackage
+ * @update_severity: a #PkInfoEnum
+ *
+ * Set an update severity for the @package. The @update_severity can be
+ * one of %PK_INFO_ENUM_UNKNOWN, %PK_INFO_ENUM_LOW, %PK_INFO_ENUM_NORMAL,
+ * %PK_INFO_ENUM_IMPORTANT or %PK_INFO_ENUM_CRITICAL.
+ *
+ * Since: 1.2.4
+ **/
+void
+pk_package_set_update_severity (PkPackage *package,
+ PkInfoEnum update_severity)
+{
+ g_return_if_fail (PK_IS_PACKAGE (package));
+ g_return_if_fail (update_severity == PK_INFO_ENUM_UNKNOWN ||
+ update_severity == PK_INFO_ENUM_LOW ||
+ update_severity == PK_INFO_ENUM_NORMAL ||
+ update_severity == PK_INFO_ENUM_IMPORTANT ||
+ update_severity == PK_INFO_ENUM_CRITICAL);
+
+ if (package->priv->update_severity == update_severity)
+ return;
+
+ package->priv->update_severity = update_severity;
+
+ g_object_notify (G_OBJECT (package), "update-severity");
+}
diff --git a/lib/packagekit-glib2/pk-package.h b/lib/packagekit-glib2/pk-package.h
index 9655775b5..62bcfe7e3 100644
--- a/lib/packagekit-glib2/pk-package.h
+++ b/lib/packagekit-glib2/pk-package.h
@@ -96,7 +96,9 @@ const gchar *pk_package_get_name (PkPackage *package);
const gchar *pk_package_get_version (PkPackage *package);
const gchar *pk_package_get_arch (PkPackage *package);
const gchar *pk_package_get_data (PkPackage *package);
-
+PkInfoEnum pk_package_get_update_severity (PkPackage *package);
+void pk_package_set_update_severity (PkPackage *package,
+ PkInfoEnum update_severity);
G_END_DECLS
#endif /* __PK_PACKAGE_H */