1
/* main.c generated by valac 0.12.0, the Vala compiler
2
* generated from main.vala, do not modify */
5
* Copyright (C) 2011 Canonical Ltd.
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 3, as published
9
* by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranties of
13
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
* PURPOSE. See the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
19
* Authored by Ken VanDine <ken.vandine@canonical.com>
23
#include <glib-object.h>
27
#include <glib/gi18n-lib.h>
30
#include <gio/gdesktopappinfo.h>
33
#define GWIBBER_TYPE_DAEMON (gwibber_daemon_get_type ())
34
#define GWIBBER_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWIBBER_TYPE_DAEMON, GwibberDaemon))
35
#define GWIBBER_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GWIBBER_TYPE_DAEMON, GwibberDaemonClass))
36
#define GWIBBER_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWIBBER_TYPE_DAEMON))
37
#define GWIBBER_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GWIBBER_TYPE_DAEMON))
38
#define GWIBBER_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWIBBER_TYPE_DAEMON, GwibberDaemonClass))
40
typedef struct _GwibberDaemon GwibberDaemon;
41
typedef struct _GwibberDaemonClass GwibberDaemonClass;
42
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
43
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
44
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
45
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
48
extern GApplication* gwibber_app;
49
GApplication* gwibber_app = NULL;
50
extern GwibberDaemon* gwibber_daemon;
51
GwibberDaemon* gwibber_daemon = NULL;
53
GType gwibber_daemon_get_type (void) G_GNUC_CONST;
54
gboolean gwibber_dbus_name_has_owner (const gchar* name);
55
gint gwibber_main (gchar** args, int args_length1);
56
GwibberDaemon* gwibber_daemon_new (void);
57
GwibberDaemon* gwibber_daemon_construct (GType object_type);
60
gboolean gwibber_dbus_name_has_owner (const gchar* name) {
61
gboolean result = FALSE;
62
gboolean has_owner = FALSE;
63
GDBusConnection* _tmp0_ = NULL;
65
GVariant* _tmp1_ = NULL;
67
GVariantType* _tmp3_ = NULL;
69
GVariant* _tmp5_ = NULL;
72
GError * _inner_error_ = NULL;
73
g_return_val_if_fail (name != NULL, FALSE);
74
_tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
76
if (_inner_error_ != NULL) {
77
if (_inner_error_->domain == G_IO_ERROR) {
78
goto __catch1_g_io_error;
80
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
81
g_clear_error (&_inner_error_);
84
_tmp1_ = g_variant_new ("(s)", name, NULL);
85
_tmp2_ = g_variant_ref_sink (_tmp1_);
86
_tmp3_ = g_variant_type_new ("(b)");
88
_tmp5_ = g_dbus_connection_call_sync (bus, "org.freedesktop.DBus", "/org/freedesktop/dbus", "org.freedesktop.DBus", "NameHasOwner", _tmp2_, _tmp4_, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &_inner_error_);
90
_g_variant_type_free0 (_tmp4_);
91
_g_variant_unref0 (_tmp2_);
93
if (_inner_error_ != NULL) {
94
_g_object_unref0 (bus);
95
if (_inner_error_->domain == G_IO_ERROR) {
96
goto __catch1_g_io_error;
100
g_variant_get (_result_, "(b)", &has_owner, NULL);
102
_g_variant_unref0 (_result_);
103
_g_object_unref0 (bus);
105
_g_variant_unref0 (_result_);
106
_g_object_unref0 (bus);
112
_inner_error_ = NULL;
113
g_warning ("main.vala:42: Unable to decide whether '%s' is running: %s", name, e->message);
117
if (_inner_error_ != NULL) {
118
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
119
g_clear_error (&_inner_error_);
127
gint gwibber_main (gchar** args, int args_length1) {
130
GwibberDaemon* _tmp1_ = NULL;
131
GApplication* _tmp2_ = NULL;
134
GError * _inner_error_ = NULL;
135
textdomain (PACKAGE);
136
bindtextdomain (PACKAGE, LOCALE_DIR);
137
bind_textdomain_codeset (PACKAGE, "UTF-8");
138
setlocale (LC_ALL, "");
139
g_desktop_app_info_set_desktop_env ("GNOME");
140
_tmp0_ = gwibber_dbus_name_has_owner ("com.canonical.Unity.Gwibber");
142
g_print ("%s", "Another instance of the Unity Gwibber Daemon " "already appears to be running.\nBailing out.\n");
146
_tmp1_ = gwibber_daemon_new ();
147
_g_object_unref0 (gwibber_daemon);
148
gwibber_daemon = _tmp1_;
149
_tmp2_ = g_application_new ("com.canonical.Unity.Gwibber", G_APPLICATION_IS_SERVICE);
150
_g_object_unref0 (gwibber_app);
151
gwibber_app = _tmp2_;
152
g_application_register (gwibber_app, NULL, &_inner_error_);
153
if (_inner_error_ != NULL) {
154
goto __catch2_g_error;
161
_inner_error_ = NULL;
162
g_print ("Failed to start applications daemon: %s\n", e->message);
168
if (_inner_error_ != NULL) {
169
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
170
g_clear_error (&_inner_error_);
173
_tmp3_ = g_application_get_is_remote (gwibber_app);
175
g_print ("%s", "Another instance of the Unity Applications Daemon " "already appears to be running.\nBailing out.\n");
179
g_application_hold (gwibber_app);
180
_tmp4_ = g_application_run (gwibber_app, 0, NULL);
186
int main (int argc, char ** argv) {
188
return gwibber_main (argv, argc);