~ci-train-bot/ubuntu-app-launch/ubuntu-app-launch-ubuntu-yakkety-landing-1944

« back to all changes in this revision

Viewing changes to libubuntu-app-launch/app-info.c

Migrate starting and stopping applications to new classes

Approved by: Charles Kerr, unity-api-1-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "app-info.h"
25
25
 
26
26
/* Try and get a manifest and do a couple sanity checks on it */
27
 
JsonObject *
 
27
static JsonObject *
28
28
get_manifest (const gchar * pkg, gchar ** pkgpath)
29
29
{
30
30
        /* Get the directory from click */
352
352
        return TRUE;
353
353
}
354
354
 
 
355
/* Determine whether it's a click package by looking for the symlink
 
356
   that is created by the desktop hook */
 
357
static gboolean
 
358
is_click (const gchar * appid)
 
359
{
 
360
        gchar * appiddesktop = g_strdup_printf("%s.desktop", appid);
 
361
        gchar * click_link = NULL;
 
362
        const gchar * link_farm_dir = g_getenv("UBUNTU_APP_LAUNCH_LINK_FARM");
 
363
        if (G_LIKELY(link_farm_dir == NULL)) {
 
364
                click_link = g_build_filename(g_get_user_cache_dir(), "ubuntu-app-launch", "desktop", appiddesktop, NULL);
 
365
        } else {
 
366
                click_link = g_build_filename(link_farm_dir, appiddesktop, NULL);
 
367
        }
 
368
        g_free(appiddesktop);
 
369
        gboolean click = g_file_test(click_link, G_FILE_TEST_EXISTS);
 
370
        g_free(click_link);
 
371
 
 
372
        return click;
 
373
}
 
374
 
 
375
/* Determine whether an AppId is realated to a Libertine container by
 
376
   checking the container and program name. */
 
377
static gboolean
 
378
is_libertine (const gchar * appid)
 
379
{
 
380
        if (app_info_libertine(appid, NULL, NULL)) {
 
381
                g_debug("Libertine application detected: %s", appid);
 
382
                return TRUE;
 
383
        } else {
 
384
                return FALSE;
 
385
        }
 
386
}
 
387
 
 
388
gboolean
 
389
ubuntu_app_launch_application_info (const gchar * appid, gchar ** appdir, gchar ** appdesktop)
 
390
{
 
391
        if (is_click(appid)) {
 
392
                return app_info_click(appid, appdir, appdesktop);
 
393
        } else if (is_libertine(appid)) {
 
394
                return app_info_libertine(appid, appdir, appdesktop);
 
395
        } else {
 
396
                return app_info_legacy(appid, appdir, appdesktop);
 
397
        }
 
398
}
 
399