diff options
-rw-r--r-- | libappstream-builder/asb-app.c | 50 | ||||
-rw-r--r-- | libappstream-builder/asb-app.h | 5 | ||||
-rw-r--r-- | libappstream-builder/asb-context.c | 8 | ||||
-rw-r--r-- | libappstream-builder/asb-plugin-loader.c | 2 | ||||
-rw-r--r-- | libappstream-builder/asb-task.c | 10 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-blacklist.c | 2 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-desktop.c | 12 | ||||
-rw-r--r-- | libappstream-builder/plugins/asb-plugin-hardcoded.c | 10 | ||||
-rw-r--r-- | libappstream-glib/as-app.c | 42 | ||||
-rw-r--r-- | libappstream-glib/as-app.h | 5 |
10 files changed, 74 insertions, 72 deletions
diff --git a/libappstream-builder/asb-app.c b/libappstream-builder/asb-app.c index 78cfd81..374fb89 100644 --- a/libappstream-builder/asb-app.c +++ b/libappstream-builder/asb-app.c @@ -38,7 +38,6 @@ typedef struct _AsbAppPrivate AsbAppPrivate; struct _AsbAppPrivate { - GPtrArray *vetos; GPtrArray *requires_appdata; GdkPixbuf *pixbuf; AsbPackage *pkg; @@ -58,7 +57,6 @@ asb_app_finalize (GObject *object) AsbApp *app = ASB_APP (object); AsbAppPrivate *priv = GET_PRIVATE (app); - g_ptr_array_unref (priv->vetos); g_ptr_array_unref (priv->requires_appdata); if (priv->pixbuf != NULL) g_object_unref (priv->pixbuf); @@ -75,7 +73,6 @@ static void asb_app_init (AsbApp *app) { AsbAppPrivate *priv = GET_PRIVATE (app); - priv->vetos = g_ptr_array_new_with_free_func (g_free); priv->requires_appdata = g_ptr_array_new_with_free_func (g_free); /* all untrusted */ @@ -131,12 +128,14 @@ void asb_app_set_veto_description (AsbApp *app) { AsbAppPrivate *priv = GET_PRIVATE (app); + GPtrArray *vetos; const gchar *tmp; guint i; _cleanup_string_free_ GString *str = NULL; /* application has no vetos */ - if (priv->vetos->len == 0) + vetos = as_app_get_vetos (AS_APP (app)); + if (vetos->len == 0) return; /* log */ @@ -148,9 +147,9 @@ asb_app_set_veto_description (AsbApp *app) /* update description */ str = g_string_new ("<p>Not included in metadata because:</p>"); g_string_append (str, "<ul>"); - for (i = 0; i < priv->vetos->len; i++) { + for (i = 0; i < vetos->len; i++) { _cleanup_free_ gchar *tmp_safe = NULL; - tmp = g_ptr_array_index (priv->vetos, i); + tmp = g_ptr_array_index (vetos, i); asb_package_log (priv->pkg, ASB_PACKAGE_LOG_LEVEL_WARNING, " - %s", tmp); @@ -163,28 +162,6 @@ asb_app_set_veto_description (AsbApp *app) } /** - * asb_app_add_veto: - * @app: A #AsbApp - * @fmt: format string - * @...: varargs - * - * Adds a reason to not include the application. - * - * Since: 0.1.0 - **/ -void -asb_app_add_veto (AsbApp *app, const gchar *fmt, ...) -{ - AsbAppPrivate *priv = GET_PRIVATE (app); - gchar *tmp; - va_list args; - va_start (args, fmt); - tmp = g_strdup_vprintf (fmt, args); - va_end (args); - g_ptr_array_add (priv->vetos, tmp); -} - -/** * asb_app_add_requires_appdata: * @app: A #AsbApp * @fmt: format string @@ -267,23 +244,6 @@ asb_app_get_requires_appdata (AsbApp *app) } /** - * asb_app_get_vetos: - * @app: A #AsbApp - * - * Gets the list of vetos. - * - * Returns: (transfer none) (element-type utf8): A list of vetos - * - * Since: 0.1.0 - **/ -GPtrArray * -asb_app_get_vetos (AsbApp *app) -{ - AsbAppPrivate *priv = GET_PRIVATE (app); - return priv->vetos; -} - -/** * asb_app_get_package: * @app: A #AsbApp * diff --git a/libappstream-builder/asb-app.h b/libappstream-builder/asb-app.h index 68f3587..5a5372c 100644 --- a/libappstream-builder/asb-app.h +++ b/libappstream-builder/asb-app.h @@ -57,10 +57,6 @@ GType asb_app_get_type (void); AsbApp *asb_app_new (AsbPackage *pkg, const gchar *id_full); gchar *asb_app_to_xml (AsbApp *app); -void asb_app_add_veto (AsbApp *app, - const gchar *fmt, - ...) - G_GNUC_PRINTF(2,3); void asb_app_add_requires_appdata (AsbApp *app, const gchar *fmt, ...) @@ -75,7 +71,6 @@ gboolean asb_app_add_screenshot_source (AsbApp *app, GError **error); GPtrArray *asb_app_get_requires_appdata (AsbApp *app); -GPtrArray *asb_app_get_vetos (AsbApp *app); AsbPackage *asb_app_get_package (AsbApp *app); gboolean asb_app_save_resources (AsbApp *app, diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c index 1be826e..92f1226 100644 --- a/libappstream-builder/asb-context.c +++ b/libappstream-builder/asb-context.c @@ -641,7 +641,7 @@ asb_context_write_xml (AsbContext *ctx, for (l = priv->apps; l != NULL; l = l->next) { app = AS_APP (l->data); if (ASB_IS_APP (app)) { - if (asb_app_get_vetos(ASB_APP(app))->len > 0) + if (as_app_get_vetos(app)->len > 0) continue; } as_store_add_app (store, app); @@ -679,7 +679,7 @@ asb_context_detect_pkgname_dups (AsbContext *ctx, GError **error) pkgname = as_app_get_pkgname_default (app); if (pkgname == NULL) continue; - if (ASB_IS_APP (app) && asb_app_get_vetos(ASB_APP(app))->len > 0) + if (ASB_IS_APP (app) && as_app_get_vetos(app)->len > 0) continue; found = g_hash_table_lookup (hash, pkgname); if (found != NULL) { @@ -738,7 +738,7 @@ asb_context_detect_missing_parents (AsbContext *ctx, GError **error) continue; /* do not add the addon */ - asb_app_add_veto (ASB_APP (app), "%s has no parent of '%s'\n", + as_app_add_veto (app, "%s has no parent of '%s'\n", as_app_get_id_full (app), tmp); g_print ("WARNING: %s has no parent of '%s'\n", as_app_get_id_full (app), tmp); @@ -769,7 +769,7 @@ asb_context_write_xml_fail (AsbContext *ctx, app = AS_APP (l->data); if (!ASB_IS_APP (app)) continue; - if (asb_app_get_vetos(ASB_APP(app))->len == 0) + if (as_app_get_vetos(app)->len == 0) continue; if (as_app_get_metadata_item (app, "NoDisplay") != NULL) continue; diff --git a/libappstream-builder/asb-plugin-loader.c b/libappstream-builder/asb-plugin-loader.c index afa7201..3f10303 100644 --- a/libappstream-builder/asb-plugin-loader.c +++ b/libappstream-builder/asb-plugin-loader.c @@ -303,7 +303,7 @@ asb_plugin_loader_merge (AsbPluginLoader *plugin_loader, GList **apps) continue; } tmp = asb_package_get_nevr (asb_app_get_package (found)); - asb_app_add_veto (app, "duplicate of %s", tmp); + as_app_add_veto (AS_APP (app), "duplicate of %s", tmp); asb_package_log (asb_app_get_package (app), ASB_PACKAGE_LOG_LEVEL_WARNING, "duplicate %s not included as added from %s", diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c index cc7d654..894d072 100644 --- a/libappstream-builder/asb-task.c +++ b/libappstream-builder/asb-task.c @@ -352,14 +352,14 @@ asb_task_process (AsbTask *task, GError **error_not_used) /* don't include components that have no name or comment */ if (as_app_get_name (AS_APP (app), "C") == NULL) - asb_app_add_veto (app, "No 'Name' in desktop or <name> in AppData"); + as_app_add_veto (AS_APP (app), "No 'Name' in desktop or <name> in AppData"); if (as_app_get_comment (AS_APP (app), "C") == NULL) - asb_app_add_veto (app, "No 'Comment' in desktop or <summary> in AppData"); + as_app_add_veto (AS_APP (app), "No 'Comment' in desktop or <summary> in AppData"); /* don't include apps that have no icon */ if (as_app_get_id_kind (AS_APP (app)) != AS_ID_KIND_ADDON) { if (as_app_get_icon (AS_APP (app)) == NULL) - asb_app_add_veto (app, "Has no Icon"); + as_app_add_veto (AS_APP (app), "Has no Icon"); } /* veto apps that *still* require appdata */ @@ -367,10 +367,10 @@ asb_task_process (AsbTask *task, GError **error_not_used) for (i = 0; i < array->len; i++) { tmp = g_ptr_array_index (array, i); if (tmp == NULL) { - asb_app_add_veto (app, "Required AppData"); + as_app_add_veto (AS_APP (app), "Required AppData"); continue; } - asb_app_add_veto (app, "Required AppData: %s", tmp); + as_app_add_veto (AS_APP (app), "Required AppData: %s", tmp); } /* list all the reasons we're ignoring the app */ diff --git a/libappstream-builder/plugins/asb-plugin-blacklist.c b/libappstream-builder/plugins/asb-plugin-blacklist.c index 036baee..29184a6 100644 --- a/libappstream-builder/plugins/asb-plugin-blacklist.c +++ b/libappstream-builder/plugins/asb-plugin-blacklist.c @@ -113,7 +113,7 @@ asb_plugin_process_app (AsbPlugin *plugin, { const gchar *tmp; if (as_utils_is_blacklisted_id (as_app_get_id (AS_APP (app)))) - asb_app_add_veto (app, "Not an application"); + as_app_add_veto (AS_APP (app), "Not an application"); tmp = asb_glob_value_search (plugin->priv->vetos, as_app_get_id (AS_APP (app))); if (tmp != NULL) diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c index 0058828..dab9929 100644 --- a/libappstream-builder/plugins/asb-plugin-desktop.c +++ b/libappstream-builder/plugins/asb-plugin-desktop.c @@ -312,7 +312,7 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* NoDisplay apps are never included */ if (as_app_get_metadata_item (AS_APP (app), "NoDisplay") != NULL) - asb_app_add_veto (app, "NoDisplay=true"); + as_app_add_veto (AS_APP (app), "NoDisplay=true"); /* Settings or DesktopSettings requires AppData */ if (as_app_has_category (AS_APP (app), "Settings")) @@ -332,17 +332,17 @@ asb_plugin_process_filename (AsbPlugin *plugin, /* is icon XPM or GIF */ if (g_str_has_suffix (key, ".xpm")) - asb_app_add_veto (app, "Uses XPM icon: %s", key); + as_app_add_veto (AS_APP (app), "Uses XPM icon: %s", key); else if (g_str_has_suffix (key, ".gif")) - asb_app_add_veto (app, "Uses GIF icon: %s", key); + as_app_add_veto (AS_APP (app), "Uses GIF icon: %s", key); else if (g_str_has_suffix (key, ".ico")) - asb_app_add_veto (app, "Uses ICO icon: %s", key); + as_app_add_veto (AS_APP (app), "Uses ICO icon: %s", key); /* find icon */ pixbuf = asb_app_find_icon (app, tmpdir, key, &error_local); if (pixbuf == NULL) { - asb_app_add_veto (app, "Failed to find icon: %s", - error_local->message); + as_app_add_veto (AS_APP (app), "Failed to find icon: %s", + error_local->message); } else { /* save in target directory */ icon_filename = g_strdup_printf ("%s.png", diff --git a/libappstream-builder/plugins/asb-plugin-hardcoded.c b/libappstream-builder/plugins/asb-plugin-hardcoded.c index e3bd9d6..e5b6653 100644 --- a/libappstream-builder/plugins/asb-plugin-hardcoded.c +++ b/libappstream-builder/plugins/asb-plugin-hardcoded.c @@ -231,23 +231,23 @@ asb_plugin_process_app (AsbPlugin *plugin, /* look for ancient toolkits */ for (i = 0; deps != NULL && deps[i] != NULL; i++) { if (g_strcmp0 (deps[i], "libgtk-1.2.so.0") == 0) { - asb_app_add_veto (app, "Uses obsolete GTK1 toolkit"); + as_app_add_veto (AS_APP (app), "Uses obsolete GTK1 toolkit"); break; } if (g_strcmp0 (deps[i], "libglib-1.2.so.0") == 0) { - asb_app_add_veto (app, "Uses obsolete GLib library"); + as_app_add_veto (AS_APP (app), "Uses obsolete GLib library"); break; } if (g_strcmp0 (deps[i], "libqt-mt.so.3") == 0) { - asb_app_add_veto (app, "Uses obsolete QT3 toolkit"); + as_app_add_veto (AS_APP (app), "Uses obsolete QT3 toolkit"); break; } if (g_strcmp0 (deps[i], "liblcms.so.1") == 0) { - asb_app_add_veto (app, "Uses obsolete LCMS library"); + as_app_add_veto (AS_APP (app), "Uses obsolete LCMS library"); break; } if (g_strcmp0 (deps[i], "libelektra.so.4") == 0) { - asb_app_add_veto (app, "Uses obsolete Elektra library"); + as_app_add_veto (AS_APP (app), "Uses obsolete Elektra library"); break; } if (g_strcmp0 (deps[i], "libXt.so.6") == 0) { diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 92c8b9a..430fd25 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -72,6 +72,7 @@ struct _AsAppPrivate GPtrArray *releases; /* of AsRelease */ GPtrArray *provides; /* of AsProvide */ GPtrArray *screenshots; /* of AsScreenshot */ + GPtrArray *vetos; /* of string */ AsAppSourceKind source_kind; AsAppState state; AsAppTrustFlags trust_flags; @@ -267,6 +268,7 @@ as_app_finalize (GObject *object) g_ptr_array_unref (priv->provides); g_ptr_array_unref (priv->screenshots); g_ptr_array_unref (priv->token_cache); + g_ptr_array_unref (priv->vetos); G_OBJECT_CLASS (as_app_parent_class)->finalize (object); } @@ -302,6 +304,7 @@ as_app_init (AsApp *app) priv->provides = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); priv->screenshots = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); priv->token_cache = g_ptr_array_new_with_free_func ((GDestroyNotify) as_app_token_item_free); + priv->vetos = g_ptr_array_new_with_free_func (g_free); priv->comments = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); priv->developer_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); @@ -3943,6 +3946,45 @@ as_app_to_file (AsApp *app, } /** + * as_app_get_vetos: + * @app: A #AsApp + * + * Gets the list of vetos. + * + * Returns: (transfer none) (element-type utf8): A list of vetos + * + * Since: 0.2.5 + **/ +GPtrArray * +as_app_get_vetos (AsApp *app) +{ + AsAppPrivate *priv = GET_PRIVATE (app); + return priv->vetos; +} + +/** + * as_app_add_veto: + * @app: A #AsApp + * @fmt: format string + * @...: varargs + * + * Adds a reason to not include the application in the metadata. + * + * Since: 0.2.5 + **/ +void +as_app_add_veto (AsApp *app, const gchar *fmt, ...) +{ + AsAppPrivate *priv = GET_PRIVATE (app); + gchar *tmp; + va_list args; + va_start (args, fmt); + tmp = g_strdup_vprintf (fmt, args); + va_end (args); + g_ptr_array_add (priv->vetos, tmp); +} + +/** * as_app_new: * * Creates a new #AsApp. diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h index 70c084f..59c2382 100644 --- a/libappstream-glib/as-app.h +++ b/libappstream-glib/as-app.h @@ -233,6 +233,7 @@ GHashTable *as_app_get_developer_names (AsApp *app); GHashTable *as_app_get_metadata (AsApp *app); GHashTable *as_app_get_descriptions (AsApp *app); GHashTable *as_app_get_urls (AsApp *app); +GPtrArray *as_app_get_vetos (AsApp *app); const gchar *as_app_get_icon (AsApp *app); const gchar *as_app_get_icon_path (AsApp *app); const gchar *as_app_get_id (AsApp *app); @@ -379,6 +380,10 @@ void as_app_subsume (AsApp *app, void as_app_subsume_full (AsApp *app, AsApp *donor, AsAppSubsumeFlags flags); +void as_app_add_veto (AsApp *app, + const gchar *fmt, + ...) + G_GNUC_PRINTF(2,3); guint as_app_search_matches_all (AsApp *app, gchar **search); guint as_app_search_matches (AsApp *app, |