summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-02-26 14:29:14 +0000
committerRichard Hughes <richard@hughsie.com>2016-02-26 14:45:57 +0000
commite80e47382780c366c0801315dddfb66ae7252fdb (patch)
tree5b4412a2a857df6796a3179f6cb05f8d598436ee
parent21473242f967514558f3b603ed1dd3ee65e58afd (diff)
downloadappstream-glib-e80e47382780c366c0801315dddfb66ae7252fdb.tar.gz
Add AsAppQuirk
This allows us to get rid of several boolean fields in UI software.
-rw-r--r--libappstream-glib/as-app.c35
-rw-r--r--libappstream-glib/as-app.h20
2 files changed, 55 insertions, 0 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 53578db..3e6e618 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -82,6 +82,7 @@ typedef struct
AsAppSourceKind source_kind;
AsAppState state;
AsAppTrustFlags trust_flags;
+ AsAppQuirk quirk;
gchar *icon_path;
gchar *id_filename;
gchar *id;
@@ -1607,6 +1608,40 @@ as_app_set_trust_flags (AsApp *app, AsAppTrustFlags trust_flags)
}
/**
+ * as_app_has_quirk:
+ * @app: a #AsApp instance.
+ * @quirk: the #AsAppQuirk, e.g. %AS_APP_QUIRK_PROVENANCE
+ *
+ * Queries to see if an application has a specific attribute.
+ *
+ * Returns: %TRUE if the application has the attribute
+ *
+ * Since: 0.5.10
+ **/
+gboolean
+as_app_has_quirk (AsApp *app, AsAppQuirk quirk)
+{
+ AsAppPrivate *priv = GET_PRIVATE (app);
+ return (priv->quirk & quirk) > 0;
+}
+
+/**
+ * as_app_add_quirk:
+ * @app: a #AsApp instance.
+ * @quirk: the #AsAppQuirk, e.g. %AS_APP_QUIRK_PROVENANCE
+ *
+ * Adds a specific attribute to an application.
+ *
+ * Since: 0.5.10
+ **/
+void
+as_app_add_quirk (AsApp *app, AsAppQuirk quirk)
+{
+ AsAppPrivate *priv = GET_PRIVATE (app);
+ priv->quirk |= quirk;
+}
+
+/**
* as_app_set_kind:
* @app: a #AsApp instance.
* @kind: the #AsAppKind.
diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h
index 3ce1d01..3c1987e 100644
--- a/libappstream-glib/as-app.h
+++ b/libappstream-glib/as-app.h
@@ -208,6 +208,22 @@ typedef enum {
} AsAppKind;
/**
+ * AsAppQuirk:
+ * @AS_APP_QUIRK_NONE: No special attributes
+ * @AS_APP_QUIRK_PROVENANCE: Installed by OS vendor
+ * @AS_APP_QUIRK_COMPULSORY: Cannot be removed
+ *
+ * The component attributes.
+ **/
+typedef enum {
+ AS_APP_QUIRK_NONE = 0, /* Since: 0.5.10 */
+ AS_APP_QUIRK_PROVENANCE = 1 << 0, /* Since: 0.5.10 */
+ AS_APP_QUIRK_COMPULSORY = 1 << 1, /* Since: 0.5.10 */
+ /*< private >*/
+ AS_APP_QUIRK_LAST
+} AsAppQuirk;
+
+/**
* AsAppState:
* @AS_APP_STATE_UNKNOWN: Unknown state
* @AS_APP_STATE_INSTALLED: Application is installed
@@ -312,6 +328,8 @@ gboolean as_app_has_kudo_kind (AsApp *app,
AsKudoKind kudo);
gboolean as_app_has_permission (AsApp *app,
const gchar *permission);
+gboolean as_app_has_quirk (AsApp *app,
+ AsAppQuirk quirk);
/* setters */
void as_app_set_id (AsApp *app,
@@ -400,6 +418,8 @@ void as_app_add_addon (AsApp *app,
AsApp *addon);
void as_app_add_extends (AsApp *app,
const gchar *extends);
+void as_app_add_quirk (AsApp *app,
+ AsAppQuirk quirk);
/* object methods */
GPtrArray *as_app_validate (AsApp *app,