24
24
#include "app-info.h"
26
26
/* Try and get a manifest and do a couple sanity checks on it */
28
get_manifest (const gchar * pkg)
28
get_manifest (const gchar * pkg, gchar ** pkgpath)
30
30
/* Get the directory from click */
31
31
GError * error = NULL;
55
55
g_object_unref(user);
59
if (pkgpath != NULL) {
60
*pkgpath = click_user_get_path(user, pkg, &error);
62
g_warning("Unable to get the Click package directory for %s: %s", pkg, error->message);
58
68
g_object_unref(user);
60
70
if (!json_object_has_member(manifest, "version")) {
203
/* Look to see if the app id results in a desktop file, if so, fill in the params */
205
evaluate_dir (const gchar * dir, const gchar * desktop, gchar ** appdir, gchar ** appdesktop)
207
char * fulldir = g_build_filename(dir, "applications", desktop, NULL);
208
gboolean found = FALSE;
210
if (g_file_test(fulldir, G_FILE_TEST_EXISTS)) {
211
if (appdir != NULL) {
212
*appdir = g_strdup(dir);
215
if (appdesktop != NULL) {
216
*appdesktop = g_strdup_printf("applications/%s", desktop);
226
/* Handle the legacy case where we look through the data directories */
228
app_info_legacy (const gchar * appid, gchar ** appdir, gchar ** appdesktop)
230
gchar * desktop = g_strdup_printf("%s.desktop", appid);
232
/* Special case the user's dir */
233
if (evaluate_dir(g_get_user_data_dir(), desktop, appdir, appdesktop)) {
238
const char * const * data_dirs = g_get_system_data_dirs();
240
for (i = 0; data_dirs[i] != NULL; i++) {
241
if (evaluate_dir(data_dirs[i], desktop, appdir, appdesktop)) {
193
250
/* Handle the libertine case where we look in the container */
195
252
app_info_libertine (const gchar * appid, gchar ** appdir, gchar ** appdesktop)
285
if (appdir != NULL) {
286
*appdir = desktopdir;
291
if (appdesktop != NULL) {
292
*appdesktop = g_build_filename("applications", desktopname, NULL);
228
296
g_free(desktopname);
229
297
g_free(container);
232
if (appdir != NULL) {
233
*appdir = desktopdir;
303
/* Get the information on where the desktop file is from libclick */
305
app_info_click (const gchar * appid, gchar ** appdir, gchar ** appdesktop)
307
gchar * package = NULL;
308
gchar * application = NULL;
310
if (!ubuntu_app_launch_app_id_parse(appid, &package, &application, NULL)) {
314
JsonObject * manifest = get_manifest(package, appdir);
315
if (manifest == NULL) {
238
323
if (appdesktop != NULL) {
239
*appdesktop = desktopfile;
324
JsonObject * hooks = json_object_get_object_member(manifest, "hooks");
326
json_object_unref(manifest);
331
JsonObject * appobj = json_object_get_object_member(hooks, application);
334
if (appobj == NULL) {
335
json_object_unref(manifest);
339
const gchar * desktop = json_object_get_string_member(appobj, "desktop");
340
if (desktop == NULL) {
341
json_object_unref(manifest);
345
*appdesktop = g_strdup(desktop);
350
json_object_unref(manifest);