1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "unity-webapps-application-info.h"
#include "unity-webapps-application-manifest.h"
static gboolean
write_desktop_file (UnityWebappsApplicationManifest *manifest)
{
UnityWebappsApplicationInfo *info;
const gchar *name, *domain;
gchar *desktop_name;
GError *error;
name = unity_webapps_application_manifest_get_name (manifest);
domain = unity_webapps_application_manifest_get_domain (manifest);
if (!domain)
return FALSE;
info = unity_webapps_application_info_new (name, domain, "", NULL);
// It's a waste of time to free this.
desktop_name = unity_webapps_application_info_get_desktop_file_name (info);
error = NULL;
unity_webapps_application_info_write_desktop_file_to_path (info, desktop_name, &error);
if (error != NULL)
{
// No reason to free
g_warning ("Error writing desktop file: %s \n", error->message);
return FALSE;
}
return TRUE;
}
gint
main (gint argc, gchar **argv)
{
UnityWebappsApplicationManifest *manifest;
gboolean wrote;
g_type_init ();
if (argc != 2)
{
g_printf("Usage: unity-webapps-desktop-file <<path to manifest.json>>\n");
return 1;
}
manifest = unity_webapps_application_manifest_new_from_file (argv[1]);
if (manifest == FALSE)
{
g_printf("Failed to load and parse manifest file \n");
return 1;
}
wrote = write_desktop_file (manifest);
if (wrote == FALSE)
{
g_printf("Failed to write desktop file \n");
return 1;
}
return 0;
}
|