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>
28
#include <glib/gi18n.h>
31
#include <libgnome/gnome-program.h>
32
#include <libgnomeui/gnome-ui-init.h>
34
#include <libmissioncontrol/mc-account.h>
35
#include <libmissioncontrol/mc-account-monitor.h>
36
#include <libmissioncontrol/mission-control.h>
38
#include <libempathy/gossip-debug.h>
39
#include <libempathy/gossip-utils.h>
40
#include <libempathy/gossip-presence.h>
41
#include <libempathy/gossip-paths.h>
42
#include <libempathy-gtk/empathy-main-window.h>
43
#include <libempathy-gtk/empathy-status-icon.h>
45
#include "empathy-filter.h"
47
#define DEBUG_DOMAIN "EmpathyMain"
49
static void error_cb (MissionControl *mc,
52
static void service_ended_cb (MissionControl *mc,
54
static void operation_error_cb (MissionControl *mc,
58
static void start_mission_control (MissionControl *mc);
61
error_cb (MissionControl *mc,
66
gossip_debug (DEBUG_DOMAIN, "Error: %s", error->message);
71
service_ended_cb (MissionControl *mc,
74
gossip_debug (DEBUG_DOMAIN, "Mission Control stopped");
78
operation_error_cb (MissionControl *mc,
83
gossip_debug (DEBUG_DOMAIN, "Error code %d during operation %d",
89
account_enabled_cb (McAccountMonitor *monitor,
93
gossip_debug (DEBUG_DOMAIN, "Account enabled: %s", unique_name);
94
start_mission_control (mc);
98
start_mission_control (MissionControl *mc)
102
presence = mission_control_get_presence_actual (mc, NULL);
104
if (presence > MC_PRESENCE_OFFLINE) {
105
/* MC is already running and online, nothing to do */
109
gossip_debug (DEBUG_DOMAIN, "Starting Mission Control...");
111
mission_control_set_presence (mc,
112
MC_PRESENCE_AVAILABLE,
114
(McCallback) error_cb,
119
new_channel_cb (EmpathyFilter *filter,
122
guint context_handle,
125
gossip_debug (DEBUG_DOMAIN, "Filtering context handle: %d",
127
empathy_filter_process (filter, context_handle, TRUE);
131
main (int argc, char *argv[])
133
EmpathyStatusIcon *icon;
136
McAccountMonitor *monitor;
137
EmpathyFilter *filter;
139
GnomeProgram *program;
140
gboolean no_connect = FALSE;
141
GOptionContext *context;
142
GOptionEntry options[] = {
144
0, G_OPTION_ARG_NONE, &no_connect,
145
N_("Don't connect on startup"),
149
localedir = gossip_paths_get_locale_path ();
150
bindtextdomain (GETTEXT_PACKAGE, localedir);
151
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
152
textdomain (GETTEXT_PACKAGE);
155
context = g_option_context_new (_("- Empathy Instant Messenger"));
156
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
158
g_set_application_name (PACKAGE_NAME);
160
program = gnome_program_init ("empathy",
164
GNOME_PROGRAM_STANDARD_PROPERTIES,
165
"goption-context", context,
166
GNOME_PARAM_HUMAN_READABLE_NAME, PACKAGE_NAME,
169
gtk_window_set_default_icon_name ("empathy");
171
/* Setting up channel filter */
172
filter = empathy_filter_new ();
173
g_signal_connect (filter, "new-channel",
174
G_CALLBACK (new_channel_cb),
178
monitor = mc_account_monitor_new ();
179
mc = gossip_mission_control_new ();
180
g_signal_connect (monitor, "account-enabled",
181
G_CALLBACK (account_enabled_cb),
183
g_signal_connect (mc, "ServiceEnded",
184
G_CALLBACK (service_ended_cb),
186
g_signal_connect (mc, "Error",
187
G_CALLBACK (operation_error_cb),
191
start_mission_control (mc);
195
window = empathy_main_window_show ();
196
icon = empathy_status_icon_new (GTK_WINDOW (window));
200
mission_control_set_presence (mc,
204
g_object_unref (monitor);
206
g_object_unref (icon);
207
g_object_unref (program);