61.2.15
by Ted Gould
Going C on this one |
1 |
/*
|
2 |
* Copyright 2013 Canonical Ltd.
|
|
3 |
*
|
|
4 |
* This program is free software: you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 3, as published
|
|
6 |
* by the Free Software Foundation.
|
|
7 |
*
|
|
8 |
* This program is distributed in the hope that it will be useful, but
|
|
9 |
* WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
10 |
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
11 |
* PURPOSE. See the GNU General Public License for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU General Public License along
|
|
14 |
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15 |
*
|
|
16 |
* Authors:
|
|
17 |
* Ted Gould <ted.gould@canonical.com>
|
|
18 |
*/
|
|
19 |
||
20 |
#include <gio/gio.h> |
|
21 |
||
22 |
int
|
|
23 |
main (int argc, char * argv[]) |
|
24 |
{
|
|
25 |
const gchar * job = g_getenv("JOB"); |
|
61.2.17
by Ted Gould
Fleshing out the handler |
26 |
g_return_val_if_fail(job != NULL, -1); |
27 |
||
28 |
const gchar * instance = g_getenv("INSTANCE"); |
|
29 |
g_return_val_if_fail(instance != NULL, -1); |
|
30 |
||
31 |
gboolean crashed = FALSE; |
|
32 |
if (g_getenv("EXIT_STATUS") != NULL || g_getenv("EXIT_SIGNAL") != NULL) { |
|
33 |
crashed = TRUE; |
|
34 |
}
|
|
35 |
||
36 |
gchar * appid = g_strdup(instance); |
|
37 |
if (g_strcmp0(job, "application-legacy") == 0) { |
|
38 |
gchar * lasthyphenstanding = g_strrstr(appid, "-"); |
|
39 |
if (lasthyphenstanding != NULL) { |
|
40 |
lasthyphenstanding[0] = '\0'; |
|
41 |
} else { |
|
42 |
g_warning("Legacy job instance '%s' is missing a hyphen", appid); |
|
43 |
}
|
|
44 |
}
|
|
45 |
||
46 |
GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); |
|
47 |
g_return_val_if_fail(bus != NULL, -1); |
|
48 |
||
49 |
GError * error = NULL; |
|
50 |
g_dbus_connection_emit_signal(bus, |
|
51 |
NULL, /* destination */ |
|
52 |
"/", /* path */ |
|
53 |
"com.canonical.UbuntuAppLaunch", |
|
144.4.7
by Ted Gould
Errors caught by the test suite |
54 |
"ApplicationFailed", |
61.2.17
by Ted Gould
Fleshing out the handler |
55 |
g_variant_new("(ss)", appid, crashed ? "crash" : "start-failure"), |
56 |
&error); |
|
57 |
||
58 |
g_debug("Emitting failed event '%s' for app '%s'", crashed ? "crash" : "start-failure", appid); |
|
61.2.18
by Ted Gould
Make sure the signal gets out |
59 |
|
60 |
if (error != NULL) { |
|
61.2.17
by Ted Gould
Fleshing out the handler |
61 |
g_warning("Unable to emit signal: %s", error->message); |
62 |
g_error_free(error); |
|
63 |
return -1; |
|
64 |
}
|
|
65 |
||
66 |
g_dbus_connection_flush_sync(bus, NULL, NULL); |
|
61.2.18
by Ted Gould
Make sure the signal gets out |
67 |
g_object_unref(bus); |
61.2.17
by Ted Gould
Fleshing out the handler |
68 |
g_free(appid); |
69 |
||
61.2.15
by Ted Gould
Going C on this one |
70 |
return 0; |
71 |
}
|
|
72 |