10302
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Gaim is the legal property of its developers, whose names are too numerous
|
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
6 * source distribution.
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 *
|
|
22 */
|
|
23
|
|
24 #include "internal.h"
|
|
25 #include "gtkgaim.h"
|
|
26
|
|
27 #include "account.h"
|
|
28 #include "conversation.h"
|
|
29 #include "core.h"
|
|
30 #include "debug.h"
|
|
31 #include "eventloop.h"
|
|
32 #include "ft.h"
|
|
33 #include "log.h"
|
|
34 #include "notify.h"
|
|
35 #include "prefs.h"
|
|
36 #include "prpl.h"
|
|
37 #include "pounce.h"
|
|
38 #include "sound.h"
|
|
39 #include "status.h"
|
|
40 #include "util.h"
|
|
41
|
|
42 #include "gtkaccount.h"
|
|
43 #include "gtkblist.h"
|
|
44 #include "gtkconn.h"
|
|
45 #include "gtkconv.h"
|
|
46 #include "gtkdebug.h"
|
|
47 #include "gtkdialogs.h"
|
|
48 #include "gtkeventloop.h"
|
|
49 #include "gtkft.h"
|
|
50 #include "gtknotify.h"
|
|
51 #include "gtkplugin.h"
|
|
52 #include "gtkpounce.h"
|
|
53 #include "gtkprefs.h"
|
|
54 #include "gtkprivacy.h"
|
|
55 #include "gtkrequest.h"
|
|
56 #include "gtkroomlist.h"
|
|
57 #include "gtksound.h"
|
|
58 #include "gtkutils.h"
|
|
59 #include "gtkstock.h"
|
|
60
|
|
61 #if HAVE_SIGNAL_H
|
|
62 # include <signal.h>
|
|
63 #endif
|
|
64
|
|
65 #include <getopt.h>
|
|
66
|
|
67 #ifdef HAVE_STARTUP_NOTIFICATION
|
|
68 # define SN_API_NOT_YET_FROZEN
|
|
69 # include <libsn/sn-launchee.h>
|
|
70 # include <gdk/gdkx.h>
|
|
71 #endif
|
|
72
|
|
73 #ifdef HAVE_STARTUP_NOTIFICATION
|
|
74 static SnLauncheeContext *sn_context = NULL;
|
|
75 static SnDisplay *sn_display = NULL;
|
|
76 #endif
|
|
77
|
|
78 int docklet_count = 0;
|
|
79
|
|
80 #if HAVE_SIGNAL_H
|
|
81 /*
|
|
82 * Lists of signals we wish to catch and those we wish to ignore.
|
|
83 * Each list terminated with -1
|
|
84 */
|
|
85 static int catch_sig_list[] = {
|
|
86 SIGSEGV,
|
|
87 SIGHUP,
|
|
88 SIGINT,
|
|
89 SIGTERM,
|
|
90 SIGQUIT,
|
|
91 SIGCHLD,
|
|
92 -1
|
|
93 };
|
|
94
|
|
95 static int ignore_sig_list[] = {
|
|
96 SIGPIPE,
|
|
97 -1
|
|
98 };
|
|
99 #endif
|
|
100
|
10323
|
101 static int
|
|
102 dologin_named(const char *name)
|
10302
|
103 {
|
|
104 GaimAccount *account;
|
10323
|
105 char **names;
|
|
106 int i;
|
|
107 int ret = -1;
|
10302
|
108
|
10323
|
109 if (name != NULL) { /* list of names given */
|
|
110 names = g_strsplit(name, ",", 64);
|
|
111 for (i = 0; names[i] != NULL; i++) {
|
|
112 account = gaim_accounts_find(names[i], NULL);
|
|
113 if (account != NULL) { /* found a user */
|
|
114 ret = 0;
|
10302
|
115 gaim_account_connect(account);
|
|
116 }
|
|
117 }
|
|
118 g_strfreev(names);
|
10323
|
119 } else { /* no name given, use the first account */
|
10302
|
120 account = (GaimAccount *)gaim_accounts_get_all()->data;
|
10323
|
121 ret = 0;
|
10302
|
122 gaim_account_connect(account);
|
|
123 }
|
|
124
|
10323
|
125 return ret;
|
10302
|
126 }
|
|
127
|
|
128 static void
|
|
129 clean_pid(void)
|
|
130 {
|
|
131 #ifndef _WIN32
|
|
132 int status;
|
|
133 pid_t pid;
|
|
134
|
|
135 do {
|
|
136 pid = waitpid(-1, &status, WNOHANG);
|
|
137 } while (pid != 0 && pid != (pid_t)-1);
|
|
138 if(pid == (pid_t)-1 && errno != ECHILD) {
|
|
139 char errmsg[BUFSIZ];
|
|
140 snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
|
|
141 perror(errmsg);
|
|
142 }
|
|
143 #endif
|
|
144 }
|
|
145
|
|
146 #if HAVE_SIGNAL_H
|
10323
|
147 void
|
|
148 sighandler(int sig)
|
10302
|
149 {
|
|
150 switch (sig) {
|
|
151 case SIGHUP:
|
10323
|
152 gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
|
10302
|
153 gaim_connections_disconnect_all();
|
|
154 break;
|
|
155 case SIGSEGV:
|
|
156 #ifndef DEBUG
|
|
157 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n"
|
|
158 "This is a bug in the software and has happened through\n"
|
|
159 "no fault of your own.\n\n"
|
|
160 "It is possible that this bug is already fixed in CVS.\n"
|
10323
|
161 "If you can reproduce the crash, please notify the gaim\n"
|
10302
|
162 "maintainers by reporting a bug at\n"
|
|
163 GAIM_WEBSITE "bug.php\n\n"
|
|
164 "Please make sure to specify what you were doing at the time,\n"
|
|
165 "and post the backtrace from the core file. If you do not know\n"
|
|
166 "how to get the backtrace, please get instructions at\n"
|
|
167 GAIM_WEBSITE "gdb.php. If you need further\n"
|
|
168 "assistance, please IM either RobFlynn or SeanEgn and\n"
|
|
169 "they can help you.\n");
|
|
170 #else
|
|
171 fprintf(stderr, "Hi, user. We need to talk.\n"
|
|
172 "I think something's gone wrong here. It's probably my fault.\n"
|
|
173 "No, really, it's not you... it's me... no no no, I think we get along well\n"
|
|
174 "it's just that.... well, I want to see other people. I... what?!? NO! I haven't\n"
|
|
175 "been cheating on you!! How many times do you want me to tell you?! And for the\n"
|
|
176 "last time, it's just a rash!\n");
|
|
177 /*g_on_error_query (g_get_prgname());*/
|
|
178 #endif
|
|
179 abort();
|
|
180 break;
|
|
181 case SIGCHLD:
|
|
182 clean_pid();
|
|
183 #if HAVE_SIGNAL_H
|
|
184 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */
|
|
185 #endif
|
|
186 break;
|
|
187 default:
|
10323
|
188 gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
|
10302
|
189 gaim_connections_disconnect_all();
|
|
190
|
|
191 gaim_plugins_unload_all();
|
|
192
|
|
193 if (gtk_main_level())
|
|
194 gtk_main_quit();
|
|
195 exit(0);
|
|
196 }
|
|
197 }
|
|
198 #endif
|
|
199
|
10323
|
200 static int
|
|
201 ui_main()
|
10302
|
202 {
|
|
203 #ifndef _WIN32
|
|
204 GList *icons = NULL;
|
|
205 GdkPixbuf *icon = NULL;
|
|
206 char *icon_path;
|
|
207 #endif
|
|
208
|
|
209 if (current_smiley_theme == NULL) {
|
|
210 smiley_theme_probe();
|
10323
|
211 if (smiley_themes != NULL) {
|
10302
|
212 struct smiley_theme *smile = smiley_themes->data;
|
|
213 load_smiley_theme(smile->path, TRUE);
|
|
214 }
|
|
215 }
|
|
216
|
|
217 gaim_gtk_blist_setup_sort_methods();
|
|
218
|
|
219 #ifndef _WIN32
|
|
220 /* use the nice PNG icon for all the windows */
|
|
221 icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL);
|
|
222 icon = gdk_pixbuf_new_from_file(icon_path, NULL);
|
|
223 g_free(icon_path);
|
|
224 if (icon) {
|
|
225 icons = g_list_append(icons,icon);
|
|
226 gtk_window_set_default_icon_list(icons);
|
|
227 g_object_unref(G_OBJECT(icon));
|
|
228 g_list_free(icons);
|
|
229 } else {
|
10323
|
230 gaim_debug_error("ui_main",
|
|
231 "Failed to load the default window icon!\n");
|
10302
|
232 }
|
|
233 #endif
|
|
234
|
|
235 return 0;
|
|
236 }
|
|
237
|
|
238 static void
|
|
239 debug_init(void)
|
|
240 {
|
|
241 gaim_debug_set_ui_ops(gaim_gtk_debug_get_ui_ops());
|
|
242 gaim_gtk_debug_init();
|
|
243 }
|
|
244
|
|
245 static void
|
|
246 gaim_gtk_ui_init(void)
|
|
247 {
|
|
248 /* Set the UI operation structures. */
|
|
249 gaim_accounts_set_ui_ops(gaim_gtk_accounts_get_ui_ops());
|
|
250 gaim_conversations_set_win_ui_ops(gaim_gtk_conversations_get_win_ui_ops());
|
|
251 gaim_xfers_set_ui_ops(gaim_gtk_xfers_get_ui_ops());
|
|
252 gaim_blist_set_ui_ops(gaim_gtk_blist_get_ui_ops());
|
|
253 gaim_notify_set_ui_ops(gaim_gtk_notify_get_ui_ops());
|
|
254 gaim_privacy_set_ui_ops(gaim_gtk_privacy_get_ui_ops());
|
|
255 gaim_request_set_ui_ops(gaim_gtk_request_get_ui_ops());
|
|
256 gaim_sound_set_ui_ops(gaim_gtk_sound_get_ui_ops());
|
|
257 gaim_connections_set_ui_ops(gaim_gtk_connections_get_ui_ops());
|
|
258
|
|
259 gaim_gtk_stock_init();
|
|
260 gaim_gtk_prefs_init();
|
|
261 gaim_gtk_account_init();
|
|
262 gaim_gtk_blist_init();
|
|
263 gaim_gtk_conversations_init();
|
|
264 gaim_gtk_pounces_init();
|
|
265 gaim_gtk_privacy_init();
|
|
266 gaim_gtk_xfers_init();
|
|
267 gaim_gtk_roomlist_init();
|
|
268 }
|
|
269
|
|
270 static void
|
|
271 gaim_gtk_quit(void)
|
|
272 {
|
|
273 /* XXX? */
|
|
274 /* YYY is there an XXX here? */
|
|
275
|
|
276 /* captain's log, stardate... */
|
|
277 /* LOG system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */
|
|
278
|
|
279 #ifdef USE_SM
|
|
280 /* unplug */
|
|
281 session_end();
|
|
282 #endif
|
|
283
|
|
284 /* Save the plugins we have loaded for next time. */
|
|
285 gaim_gtk_plugins_save();
|
|
286
|
|
287 /* and end it all... */
|
|
288 gtk_main_quit();
|
|
289 }
|
|
290
|
|
291 static GaimCoreUiOps core_ops =
|
|
292 {
|
|
293 gaim_gtk_prefs_init,
|
|
294 debug_init,
|
|
295 gaim_gtk_ui_init,
|
|
296 gaim_gtk_quit
|
|
297 };
|
|
298
|
|
299 static GaimCoreUiOps *
|
|
300 gaim_gtk_core_get_ui_ops(void)
|
|
301 {
|
|
302 return &core_ops;
|
|
303 }
|
|
304
|
|
305 static void
|
10320
|
306 show_usage(const char *name, gboolean terse)
|
10302
|
307 {
|
10320
|
308 char *text;
|
|
309 char *text_conv;
|
|
310 GError *error = NULL;
|
10302
|
311
|
10320
|
312 if (terse) {
|
|
313 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
|
|
314 } else {
|
|
315 text = g_strdup_printf(_("Gaim %s\n"
|
10302
|
316 "Usage: %s [OPTION]...\n\n"
|
|
317 " -a, --acct display account editor window\n"
|
|
318 " -c, --config=DIR use DIR for config files\n"
|
|
319 " -d, --debug print debugging messages to stdout\n"
|
10320
|
320 " -h, --help display this help and exit\n"
|
10323
|
321 " -n, --nologin don't automatically login\n"
|
10320
|
322 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n"
|
|
323 " account(s) to use, seperated by commas)\n"
|
10323
|
324 " -v, --version display the current version and exit\n"), VERSION, name);
|
10302
|
325 }
|
|
326
|
10320
|
327 /* tries to convert 'text' to users locale */
|
|
328 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error);
|
|
329 if (text_conv != NULL) {
|
|
330 puts(text_conv);
|
|
331 g_free(text_conv);
|
10302
|
332 }
|
10320
|
333 /* use 'text' as a fallback */
|
|
334 else {
|
|
335 g_warning("%s\n", error->message);
|
|
336 g_error_free(error);
|
|
337 puts(text);
|
|
338 }
|
|
339 g_free(text);
|
10302
|
340 }
|
|
341
|
|
342 #ifdef HAVE_STARTUP_NOTIFICATION
|
|
343 static void
|
|
344 sn_error_trap_push(SnDisplay *display, Display *xdisplay)
|
|
345 {
|
|
346 gdk_error_trap_push();
|
|
347 }
|
|
348
|
|
349 static void
|
|
350 sn_error_trap_pop(SnDisplay *display, Display *xdisplay)
|
|
351 {
|
|
352 gdk_error_trap_pop();
|
|
353 }
|
|
354
|
|
355 static void
|
|
356 startup_notification_complete(void)
|
|
357 {
|
|
358 Display *xdisplay;
|
|
359
|
|
360 xdisplay = GDK_DISPLAY();
|
|
361 sn_display = sn_display_new(xdisplay,
|
|
362 sn_error_trap_push,
|
|
363 sn_error_trap_pop);
|
|
364 sn_context =
|
|
365 sn_launchee_context_new_from_environment(sn_display,
|
|
366 DefaultScreen(xdisplay));
|
|
367
|
|
368 if (sn_context != NULL)
|
|
369 {
|
|
370 sn_launchee_context_complete(sn_context);
|
|
371 sn_launchee_context_unref(sn_context);
|
|
372
|
|
373 sn_display_unref(sn_display);
|
|
374 }
|
|
375 }
|
|
376 #endif /* HAVE_STARTUP_NOTIFICATION */
|
|
377
|
|
378 #ifndef _WIN32
|
|
379 static char *gaim_find_binary_location(void *symbol, void *data)
|
|
380 {
|
|
381 static char *fullname = NULL;
|
|
382 static gboolean first = TRUE;
|
|
383
|
|
384 char *argv0 = data;
|
|
385 struct stat st;
|
|
386 char *basebuf, *linkbuf, *fullbuf;
|
|
387
|
|
388 if (!first)
|
|
389 /* We've already been through this. */
|
|
390 return strdup(fullname);
|
|
391
|
|
392 first = FALSE;
|
|
393
|
|
394 if (!argv0)
|
|
395 return NULL;
|
|
396
|
|
397
|
|
398 basebuf = g_find_program_in_path(argv0);
|
|
399
|
|
400 /* But we still need to deal with symbolic links */
|
|
401 lstat(basebuf, &st);
|
|
402 while ((st.st_mode & S_IFLNK) == S_IFLNK) {
|
|
403 linkbuf = g_malloc(1024);
|
|
404 readlink(basebuf, linkbuf, 1024);
|
|
405 if (linkbuf[0] == G_DIR_SEPARATOR) {
|
|
406 /* an absolute path */
|
|
407 fullbuf = g_strdup(linkbuf);
|
|
408 } else {
|
|
409 char *dirbuf = g_path_get_dirname(basebuf);
|
|
410 /* a relative path */
|
|
411 fullbuf = g_strdup_printf("%s%s%s",
|
|
412 dirbuf, G_DIR_SEPARATOR_S,
|
|
413 linkbuf);
|
|
414 g_free(dirbuf);
|
|
415 }
|
|
416 /* There's no memory leak here. Really! */
|
|
417 g_free(linkbuf);
|
|
418 g_free(basebuf);
|
|
419 basebuf = fullbuf;
|
|
420 lstat(basebuf, &st);
|
|
421 }
|
|
422
|
|
423 fullname = basebuf;
|
|
424 return strdup(fullname);
|
|
425 }
|
|
426 #endif /* #ifndef _WIN32 */
|
|
427
|
|
428 /* FUCKING GET ME A TOWEL! */
|
|
429 #ifdef _WIN32
|
|
430 int gaim_main(HINSTANCE hint, int argc, char *argv[])
|
|
431 #else
|
|
432 int main(int argc, char *argv[])
|
|
433 #endif
|
|
434 {
|
10323
|
435 gboolean opt_acct = FALSE;
|
|
436 gboolean opt_help = FALSE;
|
|
437 gboolean opt_login = FALSE;
|
|
438 gboolean opt_nologin = FALSE;
|
|
439 gboolean opt_version = FALSE;
|
|
440 char *opt_config_dir_arg = NULL;
|
|
441 char *opt_login_arg = NULL;
|
|
442 char *opt_session_arg = NULL;
|
|
443 int dologin_ret = -1;
|
10302
|
444 char *plugin_search_paths[3];
|
|
445 #if HAVE_SIGNAL_H
|
|
446 int sig_indx; /* for setting up signal catching */
|
|
447 sigset_t sigset;
|
|
448 void (*prev_sig_disp)();
|
|
449 #endif
|
10323
|
450 int opt;
|
10302
|
451 gboolean gui_check;
|
10307
|
452 gboolean debug_enabled;
|
10302
|
453 gchar *gaimrc, *accountsxml;
|
10323
|
454 char errmsg[BUFSIZ];
|
10302
|
455
|
|
456 struct option long_options[] = {
|
10323
|
457 {"acct", no_argument, NULL, 'a'},
|
|
458 {"config", required_argument, NULL, 'c'},
|
|
459 {"debug", no_argument, NULL, 'd'},
|
|
460 {"help", no_argument, NULL, 'h'},
|
|
461 {"login", optional_argument, NULL, 'l'},
|
|
462 {"nologin", no_argument, NULL, 'n'},
|
|
463 {"session", required_argument, NULL, 's'},
|
|
464 {"version", no_argument, NULL, 'v'},
|
10302
|
465 {0, 0, 0, 0}
|
|
466 };
|
|
467
|
|
468 #ifdef DEBUG
|
10307
|
469 debug_enabled = TRUE;
|
|
470 #else
|
|
471 debug_enabled = FALSE;
|
10302
|
472 #endif
|
10307
|
473
|
10302
|
474 #ifndef _WIN32
|
|
475 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]);
|
|
476 #endif
|
|
477 #ifdef ENABLE_NLS
|
|
478 bindtextdomain(PACKAGE, LOCALEDIR);
|
|
479 bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
480 textdomain(PACKAGE);
|
|
481 #endif
|
|
482
|
|
483 #if HAVE_SIGNAL_H
|
|
484 /* Let's not violate any PLA's!!!! */
|
|
485 /* jseymour: whatever the fsck that means */
|
|
486 /* Robot101: for some reason things like gdm like to block *
|
|
487 * useful signals like SIGCHLD, so we unblock all the ones we *
|
|
488 * declare a handler for. thanks JSeymour and Vann. */
|
|
489 if (sigemptyset(&sigset)) {
|
|
490 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set");
|
|
491 perror(errmsg);
|
|
492 }
|
|
493 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
|
|
494 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) {
|
|
495 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching",
|
|
496 catch_sig_list[sig_indx]);
|
|
497 perror(errmsg);
|
|
498 }
|
|
499 if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
|
|
500 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking",
|
|
501 catch_sig_list[sig_indx]);
|
|
502 perror(errmsg);
|
|
503 }
|
|
504 }
|
|
505 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
|
|
506 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) {
|
|
507 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore",
|
|
508 ignore_sig_list[sig_indx]);
|
|
509 perror(errmsg);
|
|
510 }
|
|
511 }
|
|
512
|
|
513 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
|
|
514 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals");
|
|
515 perror(errmsg);
|
10307
|
516 }
|
10302
|
517 #endif
|
|
518
|
|
519 /* scan command-line options */
|
|
520 opterr = 1;
|
|
521 while ((opt = getopt_long(argc, argv,
|
|
522 #ifndef _WIN32
|
10323
|
523 "ac:dhnl::s:v",
|
10302
|
524 #else
|
10323
|
525 "ac:dhnl::v",
|
10302
|
526 #endif
|
|
527 long_options, NULL)) != -1) {
|
|
528 switch (opt) {
|
|
529 case 'a': /* account editor */
|
10323
|
530 opt_acct = TRUE;
|
|
531 break;
|
|
532 case 'c': /* config dir */
|
|
533 g_free(opt_config_dir_arg);
|
|
534 opt_config_dir_arg = g_strdup(optarg);
|
10302
|
535 break;
|
|
536 case 'd': /* debug */
|
10307
|
537 debug_enabled = TRUE;
|
10302
|
538 break;
|
10323
|
539 case 'h': /* help */
|
|
540 opt_help = TRUE;
|
|
541 break;
|
|
542 case 'n': /* no autologin */
|
|
543 opt_nologin = TRUE;
|
10302
|
544 break;
|
10323
|
545 case 'l': /* login, option username */
|
|
546 opt_login = TRUE;
|
|
547 g_free(opt_login_arg);
|
|
548 if (optarg != NULL)
|
|
549 opt_login_arg = g_strdup(optarg);
|
10302
|
550 break;
|
10320
|
551 case 's': /* use existing session ID */
|
10323
|
552 g_free(opt_session_arg);
|
10320
|
553 opt_session_arg = g_strdup(optarg);
|
|
554 break;
|
10323
|
555 case 'v': /* version */
|
|
556 opt_version = TRUE;
|
10320
|
557 break;
|
10323
|
558 case '?': /* show terse help */
|
10302
|
559 default:
|
10320
|
560 show_usage(argv[0], TRUE);
|
10302
|
561 return 0;
|
|
562 break;
|
|
563 }
|
|
564 }
|
|
565
|
|
566 /* show help message */
|
|
567 if (opt_help) {
|
10320
|
568 show_usage(argv[0], FALSE);
|
10302
|
569 return 0;
|
|
570 }
|
|
571 /* show version message */
|
|
572 if (opt_version) {
|
10323
|
573 printf("Gaim %s\n", VERSION);
|
10302
|
574 return 0;
|
|
575 }
|
|
576
|
10323
|
577 /* set a user-specified config directory */
|
|
578 if (opt_config_dir_arg != NULL) {
|
|
579 set_gaim_user_dir(opt_config_dir_arg);
|
|
580 }
|
|
581
|
10320
|
582 gui_check = gtk_init_check(&argc, &argv);
|
10302
|
583 if (!gui_check) {
|
|
584 char *display = gdk_get_display();
|
|
585
|
|
586 g_warning("cannot open display: %s", display ? display : "unset");
|
|
587 g_free(display);
|
|
588
|
|
589 return 1;
|
|
590 }
|
|
591
|
|
592 #ifdef _WIN32
|
10323
|
593 wgaim_init(hint);
|
10302
|
594 #endif
|
|
595 gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops());
|
|
596 gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops());
|
|
597
|
|
598 if (!gaim_core_init(GAIM_GTK_UI)) {
|
|
599 fprintf(stderr,
|
|
600 "Initialization of the Gaim core failed. Dumping core.\n"
|
|
601 "Please report this!\n");
|
|
602 abort();
|
|
603 }
|
|
604
|
10307
|
605 gaim_debug_set_enabled(debug_enabled);
|
|
606
|
10302
|
607 plugin_search_paths[0] = g_strdup(LIBDIR);
|
|
608 plugin_search_paths[1] = gaim_user_dir();
|
|
609 plugin_search_paths[2] = g_build_filename(gaim_user_dir(), "plugins", NULL);
|
|
610
|
|
611 gaim_plugins_set_search_paths(sizeof(plugin_search_paths) /
|
|
612 sizeof(*plugin_search_paths),
|
|
613 plugin_search_paths);
|
|
614
|
|
615 g_free(plugin_search_paths[0]);
|
|
616 g_free(plugin_search_paths[2]);
|
|
617
|
|
618 gaim_plugins_probe(NULL);
|
|
619
|
|
620 /* XXX - Remove this check. Maybe in 2005. --KingAnt, 25 Jul 2004 */
|
|
621 gaimrc = g_build_filename(gaim_home_dir(), ".gaimrc", NULL);
|
|
622 accountsxml = g_build_filename(gaim_user_dir(), "accounts.xml", NULL);
|
|
623 if (g_file_test(gaimrc, G_FILE_TEST_EXISTS) &&
|
|
624 !g_file_test(accountsxml, G_FILE_TEST_EXISTS)) {
|
|
625 gaim_notify_error(NULL, NULL, _("Unable to load preferences"), _("Gaim was not able to load your preferences because they are stored in an old format that is no longer used. Please reconfigure your settings using the Preferences window."));
|
|
626 }
|
|
627 g_free(gaimrc);
|
|
628 g_free(accountsxml);
|
|
629
|
|
630 gaim_accounts_load();
|
|
631
|
|
632 gaim_set_blist(gaim_blist_new());
|
|
633 gaim_blist_load();
|
|
634
|
|
635 gaim_prefs_load();
|
|
636 gaim_prefs_update_old();
|
|
637 gaim_gtk_prefs_update_old();
|
|
638
|
|
639 /* load plugins we had when we quit */
|
|
640 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded");
|
|
641
|
|
642 gaim_pounces_load();
|
|
643 gaim_statuses_load();
|
|
644
|
|
645 ui_main();
|
|
646
|
|
647 #ifdef USE_SM
|
|
648 session_init(argv[0], opt_session_arg, opt_config_dir_arg);
|
|
649 #endif
|
|
650 if (opt_session_arg != NULL) {
|
|
651 g_free(opt_session_arg);
|
|
652 opt_session_arg = NULL;
|
|
653 }
|
|
654 if (opt_config_dir_arg != NULL) {
|
|
655 g_free(opt_config_dir_arg);
|
|
656 opt_config_dir_arg = NULL;
|
|
657 }
|
|
658
|
|
659 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled"))
|
|
660 gaim_gtk_debug_window_show();
|
|
661
|
10323
|
662 gaim_blist_show();
|
|
663
|
10302
|
664 if (opt_login) {
|
|
665 dologin_ret = dologin_named(opt_login_arg);
|
|
666 if (opt_login_arg != NULL) {
|
|
667 g_free(opt_login_arg);
|
|
668 opt_login_arg = NULL;
|
|
669 }
|
|
670 }
|
|
671
|
|
672 if (!opt_acct && !opt_nologin)
|
|
673 gaim_accounts_auto_login(GAIM_GTK_UI);
|
|
674
|
10323
|
675 if (opt_acct || (gaim_accounts_get_all() == NULL)) {
|
10302
|
676 gaim_gtk_accounts_window_show();
|
10315
|
677 }
|
10302
|
678
|
|
679 #ifdef HAVE_STARTUP_NOTIFICATION
|
|
680 startup_notification_complete();
|
|
681 #endif
|
10320
|
682
|
10302
|
683 gtk_main();
|
10320
|
684
|
10302
|
685 #ifdef _WIN32
|
|
686 wgaim_cleanup();
|
|
687 #endif
|
|
688
|
|
689 return 0;
|
|
690 }
|