1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
27 #include <libtelepathy/tp-helpers.h>
28 #include <libmissioncontrol/mc-account-monitor.h>
29 #include <libmissioncontrol/mission-control.h>
31 #include <libempathy/gossip-debug.h>
33 #define DEBUG_DOMAIN "Launcher"
35 static void error_cb (MissionControl *mc,
38 static void service_ended_cb (MissionControl *mc,
40 static void start_mission_control (MissionControl *mc);
46 error_cb (MissionControl *mc,
51 gossip_debug (DEBUG_DOMAIN, "Error: %s", error->message);
56 service_ended_cb (MissionControl *mc,
59 gossip_debug (DEBUG_DOMAIN, "Mission Control stopped");
63 account_enabled_cb (McAccountMonitor *monitor,
67 gossip_debug (DEBUG_DOMAIN, "Account enabled: %s", unique_name);
68 start_mission_control (mc);
72 start_mission_control (MissionControl *mc)
76 presence = mission_control_get_presence_actual (mc, NULL);
78 if (presence != MC_PRESENCE_UNSET &&
79 presence != MC_PRESENCE_OFFLINE) {
80 /* MC is already running and online, nothing to do */
84 gossip_debug (DEBUG_DOMAIN, "Starting Mission Control...");
86 /* FIXME: Save/Restore status message */
87 mission_control_set_presence (mc, MC_PRESENCE_AVAILABLE,
89 (McCallback) error_cb,
92 mission_control_connect_all_with_default_presence (mc,
93 (McCallback) error_cb,
98 main (int argc, char *argv[])
100 GMainLoop *main_loop;
102 McAccountMonitor *monitor;
106 main_loop = g_main_loop_new (NULL, FALSE);
107 monitor = mc_account_monitor_new ();
108 mc = mission_control_new (tp_get_bus ());
110 g_signal_connect (monitor, "account-enabled",
111 G_CALLBACK (account_enabled_cb),
113 g_signal_connect (mc, "ServiceEnded",
114 G_CALLBACK (service_ended_cb),
117 start_mission_control (mc);
119 g_main_loop_run (main_loop);
121 g_object_unref (monitor);