2
* Copyright (C) 2011 Canonical Ltd.
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.
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.
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/>.
16
* Authored by Ken VanDine <ken.vandine@canonical.com>
23
static Application? app = null;
24
static Daemon? daemon = null;
26
public static bool dbus_name_has_owner (string name)
30
DBusConnection bus = Bus.get_sync (BusType.SESSION);
31
Variant result = bus.call_sync ("org.freedesktop.DBus",
32
"/org/freedesktop/dbus",
33
"org.freedesktop.DBus",
35
new Variant ("(s)", name),
36
new VariantType ("(b)"),
37
DBusCallFlags.NO_AUTO_START,
39
result.get ("(b)", out has_owner);
42
warning ("Unable to decide whether '%s' is running: %s", name, e.message);
48
public static int main (string[] args)
50
GLib.Intl.textdomain (Config.PACKAGE);
51
GLib.Intl.bindtextdomain (Config.PACKAGE, Config.LOCALE_DIR);
52
GLib.Intl.bind_textdomain_codeset (Config.PACKAGE, "UTF-8");
53
GLib.Intl.setlocale(GLib.LocaleCategory.ALL, "");
55
DesktopAppInfo.set_desktop_env ("GNOME");
57
/* Export the place daemon on the session bus - as everywhere else
58
* these values should match those definedd in the .place file */
60
if (dbus_name_has_owner ("com.canonical.Unity.Gwibber"))
62
print ("Another instance of the Unity Gwibber Daemon " +
63
"already appears to be running.\nBailing out.\n");
67
daemon = new Daemon ();
68
/* Use GApplication directly for single instance app functionality */
69
app = new Application ("com.canonical.Unity.Gwibber",
70
ApplicationFlags.IS_SERVICE);
74
/* FIXME: We get this error if another daemon is already running,
75
* but it uses a generic error so we can't detect this reliably... */
76
print ("Failed to start applications daemon: %s\n", e.message);
80
if (app.get_is_remote ())
82
print ("Another instance of the Unity Applications Daemon " +
83
"already appears to be running.\nBailing out.\n");
87
/* Hold()ing the app makes sure the GApplication doesn't exit */
91
} /* end Gwibber namespace */