1
/* main.c generated by valac 0.16.1, 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
8
* it under the terms of the GNU General Public License version 3 as
9
* published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
* Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com>
20
* Alex Launi <alex.launi@canonical.com>
25
#include <glib-object.h>
29
#include <glib/gi18n-lib.h>
33
#define UNITY_MUSIC_LENS_TYPE_DAEMON (unity_music_lens_daemon_get_type ())
34
#define UNITY_MUSIC_LENS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_DAEMON, UnityMusicLensDaemon))
35
#define UNITY_MUSIC_LENS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_DAEMON, UnityMusicLensDaemonClass))
36
#define UNITY_MUSIC_LENS_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_DAEMON))
37
#define UNITY_MUSIC_LENS_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_DAEMON))
38
#define UNITY_MUSIC_LENS_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_DAEMON, UnityMusicLensDaemonClass))
40
typedef struct _UnityMusicLensDaemon UnityMusicLensDaemon;
41
typedef struct _UnityMusicLensDaemonClass UnityMusicLensDaemonClass;
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* unity_music_lens_app;
49
GApplication* unity_music_lens_app = NULL;
50
extern UnityMusicLensDaemon* unity_music_lens_daemon;
51
UnityMusicLensDaemon* unity_music_lens_daemon = NULL;
53
GType unity_music_lens_daemon_get_type (void) G_GNUC_CONST;
54
gboolean unity_music_lens_dbus_name_has_owner (const gchar* name);
55
gint unity_music_lens_main (gchar** args, int args_length1);
56
#define CONFIG_PACKAGE "unity-lens-music"
57
#define CONFIG_LOCALEDIR "/usr/share/locale"
58
UnityMusicLensDaemon* unity_music_lens_daemon_new (void);
59
UnityMusicLensDaemon* unity_music_lens_daemon_construct (GType object_type);
62
gboolean unity_music_lens_dbus_name_has_owner (const gchar* name) {
63
gboolean result = FALSE;
64
GError * _inner_error_ = NULL;
65
g_return_val_if_fail (name != NULL, FALSE);
67
gboolean has_owner = FALSE;
68
GDBusConnection* _tmp0_ = NULL;
70
GDBusConnection* _tmp1_;
76
GVariant* _tmp7_ = NULL;
80
_tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
82
if (_inner_error_ != NULL) {
83
goto __catch3_g_error;
87
_tmp3_ = g_variant_new ("(s)", _tmp2_, NULL);
88
_tmp4_ = g_variant_ref_sink (_tmp3_);
89
_tmp5_ = g_variant_type_new ("(b)");
91
_tmp7_ = g_dbus_connection_call_sync (_tmp1_, "org.freedesktop.DBus", "/org/freedesktop/dbus", "org.freedesktop.DBus", "NameHasOwner", _tmp4_, _tmp6_, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &_inner_error_);
93
_g_variant_type_free0 (_tmp6_);
94
_g_variant_unref0 (_tmp4_);
96
if (_inner_error_ != NULL) {
97
_g_object_unref0 (bus);
98
goto __catch3_g_error;
101
g_variant_get (_tmp9_, "(b)", &has_owner, NULL);
103
_g_variant_unref0 (_result_);
104
_g_object_unref0 (bus);
111
const gchar* _tmp10_;
113
const gchar* _tmp12_;
115
_inner_error_ = NULL;
118
_tmp12_ = _tmp11_->message;
119
g_warning ("main.vala:47: Unable to decide whether '%s' is running: %s", _tmp10_, _tmp12_);
123
if (_inner_error_ != NULL) {
124
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);
125
g_clear_error (&_inner_error_);
133
gint unity_music_lens_main (gchar** args, int args_length1) {
135
gboolean _tmp0_ = FALSE;
136
UnityMusicLensDaemon* _tmp1_;
137
GApplication* _tmp2_;
138
GApplication* _tmp6_;
139
gboolean _tmp7_ = FALSE;
140
GApplication* _tmp8_;
141
GApplication* _tmp9_;
143
GError * _inner_error_ = NULL;
144
textdomain (CONFIG_PACKAGE);
145
bindtextdomain (CONFIG_PACKAGE, CONFIG_LOCALEDIR);
146
bind_textdomain_codeset (CONFIG_PACKAGE, "UTF-8");
147
setlocale (LC_ALL, "");
148
_tmp0_ = unity_music_lens_dbus_name_has_owner ("com.canonical.Unity.Lens.Music");
150
g_print ("%s", "Another instance of the Unity Music Daemon " "already appears to be running.\nBailing out.\n");
154
_tmp1_ = unity_music_lens_daemon_new ();
155
_g_object_unref0 (unity_music_lens_daemon);
156
unity_music_lens_daemon = _tmp1_;
157
_tmp2_ = g_application_new ("com.canonical.Unity.Lens.Music", G_APPLICATION_IS_SERVICE);
158
_g_object_unref0 (unity_music_lens_app);
159
unity_music_lens_app = _tmp2_;
161
GApplication* _tmp3_;
162
_tmp3_ = unity_music_lens_app;
163
g_application_register (_tmp3_, NULL, &_inner_error_);
164
if (_inner_error_ != NULL) {
165
goto __catch4_g_error;
175
_inner_error_ = NULL;
177
_tmp5_ = _tmp4_->message;
178
g_print ("Failed to start music daemon: %s\n", _tmp5_);
184
if (_inner_error_ != NULL) {
185
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);
186
g_clear_error (&_inner_error_);
189
_tmp6_ = unity_music_lens_app;
190
_tmp7_ = g_application_get_is_remote (_tmp6_);
192
g_print ("%s", "Another instance of the Unity Music Daemon " "already appears to be running.\nBailing out.\n");
196
_tmp8_ = unity_music_lens_app;
197
g_application_hold (_tmp8_);
198
_tmp9_ = unity_music_lens_app;
199
_tmp10_ = g_application_run (_tmp9_, 0, NULL);
205
int main (int argc, char ** argv) {
207
return unity_music_lens_main (argv, argc);