/** * gs_plugin_xdg_app_set_app_metadata: */ static gboolean gs_plugin_xdg_app_set_app_metadata (GsApp *app, const gchar *data, gsize length, GError **error) { g_autofree gchar *name = NULL; g_autofree gchar *runtime = NULL; g_autofree gchar *source = NULL; g_autoptr(GKeyFile) kf = NULL; g_autoptr(GsApp) app_runtime = NULL; kf = g_key_file_new (); if (!g_key_file_load_from_data (kf, data, length, G_KEY_FILE_NONE, error)) return FALSE; name = g_key_file_get_string (kf, "Application", "name", error); if (name == NULL) return FALSE; gs_app_set_xdgapp_name (app, name); runtime = g_key_file_get_string (kf, "Application", "runtime", error); if (runtime == NULL) return FALSE; g_debug ("runtime for %s is %s", name, runtime); /* create runtime */ app_runtime = gs_appstream_create_runtime (app, runtime); if (app_runtime != NULL) gs_app_set_runtime (app, app_runtime); return TRUE; }
/** * gs_refine_item_management_plugin: */ static void gs_refine_item_management_plugin (GsApp *app, AsApp *item) { GPtrArray *bundles; const gchar *management_plugin = NULL; const gchar *runtime = NULL; guint i; /* find the default bundle kind */ bundles = as_app_get_bundles (item); for (i = 0; i < bundles->len; i++) { AsBundle *bundle = g_ptr_array_index (bundles, i); if (as_bundle_get_kind (bundle) == AS_BUNDLE_KIND_XDG_APP) { management_plugin = "XgdApp"; gs_app_add_source (app, as_bundle_get_id (bundle)); /* automatically add runtime */ runtime = as_bundle_get_runtime (bundle); if (runtime != NULL) { g_autoptr(GsApp) app2 = NULL; app2 = gs_appstream_create_runtime (app, runtime); if (app2 != NULL) { g_debug ("runtime for %s is %s", gs_app_get_id (app), runtime); gs_app_set_runtime (app, app2); } } break; } if (as_bundle_get_kind (bundle) == AS_BUNDLE_KIND_LIMBA) { management_plugin = "Limba"; gs_app_add_source (app, as_bundle_get_id (bundle)); break; } } /* fall back to PackageKit */ if (management_plugin == NULL && as_app_get_pkgname_default (item) != NULL) management_plugin = "PackageKit"; if (management_plugin != NULL) gs_app_set_management_plugin (app, management_plugin); }