Mercurial > pidgin.yaz
annotate src/gtkmain.c @ 13089:b553326bc468
[gaim-migrate @ 15451]
Various i18n improvements from Bj??rn Voigt
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 01 Feb 2006 06:07:53 +0000 |
parents | 01e09b601840 |
children | 4f615c9fb63a |
rev | line source |
---|---|
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" | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
41 #include "whiteboard.h" |
10302 | 42 |
43 #include "gtkaccount.h" | |
44 #include "gtkblist.h" | |
45 #include "gtkconn.h" | |
46 #include "gtkconv.h" | |
47 #include "gtkdebug.h" | |
48 #include "gtkdialogs.h" | |
49 #include "gtkeventloop.h" | |
50 #include "gtkft.h" | |
12024 | 51 #include "gtkmedia.h" |
11907 | 52 #include "gtkidle.h" |
12838
cb36bc2db7c5
[gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents:
12670
diff
changeset
|
53 #include "gtklog.h" |
10302 | 54 #include "gtknotify.h" |
55 #include "gtkplugin.h" | |
56 #include "gtkpounce.h" | |
57 #include "gtkprefs.h" | |
58 #include "gtkprivacy.h" | |
59 #include "gtkrequest.h" | |
60 #include "gtkroomlist.h" | |
10574 | 61 #include "gtksavedstatuses.h" |
12246 | 62 #include "gtksession.h" |
10302 | 63 #include "gtksound.h" |
11525 | 64 #include "gtkthemes.h" |
10302 | 65 #include "gtkutils.h" |
66 #include "gtkstock.h" | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
67 #include "gtkwhiteboard.h" |
10302 | 68 |
69 #if HAVE_SIGNAL_H | |
70 # include <signal.h> | |
71 #endif | |
72 | |
73 #include <getopt.h> | |
74 | |
75 #ifdef HAVE_STARTUP_NOTIFICATION | |
76 # define SN_API_NOT_YET_FROZEN | |
77 # include <libsn/sn-launchee.h> | |
78 # include <gdk/gdkx.h> | |
79 #endif | |
80 | |
12572
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
81 #ifdef _WIN32 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
82 # include "wspell.h" |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
83 #endif |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
84 |
11055 | 85 |
86 | |
10302 | 87 #ifdef HAVE_STARTUP_NOTIFICATION |
88 static SnLauncheeContext *sn_context = NULL; | |
89 static SnDisplay *sn_display = NULL; | |
90 #endif | |
91 | |
92 #if HAVE_SIGNAL_H | |
93 /* | |
94 * Lists of signals we wish to catch and those we wish to ignore. | |
95 * Each list terminated with -1 | |
96 */ | |
97 static int catch_sig_list[] = { | |
98 SIGSEGV, | |
99 SIGHUP, | |
100 SIGINT, | |
101 SIGTERM, | |
102 SIGQUIT, | |
103 SIGCHLD, | |
104 -1 | |
105 }; | |
106 | |
107 static int ignore_sig_list[] = { | |
108 SIGPIPE, | |
109 -1 | |
110 }; | |
111 #endif | |
112 | |
10323 | 113 static int |
114 dologin_named(const char *name) | |
10302 | 115 { |
116 GaimAccount *account; | |
10323 | 117 char **names; |
118 int i; | |
119 int ret = -1; | |
10302 | 120 |
10323 | 121 if (name != NULL) { /* list of names given */ |
122 names = g_strsplit(name, ",", 64); | |
123 for (i = 0; names[i] != NULL; i++) { | |
124 account = gaim_accounts_find(names[i], NULL); | |
125 if (account != NULL) { /* found a user */ | |
126 ret = 0; | |
10738 | 127 gaim_account_connect(account); |
10302 | 128 } |
129 } | |
130 g_strfreev(names); | |
10323 | 131 } else { /* no name given, use the first account */ |
11520 | 132 GList *accounts; |
133 | |
134 accounts = gaim_accounts_get_all(); | |
135 if (accounts != NULL) | |
136 { | |
137 account = (GaimAccount *)accounts->data; | |
138 ret = 0; | |
139 gaim_account_connect(account); | |
140 } | |
10302 | 141 } |
142 | |
10323 | 143 return ret; |
10302 | 144 } |
145 | |
10333 | 146 #if HAVE_SIGNAL_H |
10302 | 147 static void |
148 clean_pid(void) | |
149 { | |
150 int status; | |
151 pid_t pid; | |
152 | |
153 do { | |
154 pid = waitpid(-1, &status, WNOHANG); | |
155 } while (pid != 0 && pid != (pid_t)-1); | |
10334 | 156 |
157 if ((pid == (pid_t) - 1) && (errno != ECHILD)) { | |
10302 | 158 char errmsg[BUFSIZ]; |
159 snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid); | |
160 perror(errmsg); | |
161 } | |
162 } | |
163 | |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
164 char *segfault_message; |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
165 |
10871 | 166 static void |
10323 | 167 sighandler(int sig) |
10302 | 168 { |
169 switch (sig) { | |
170 case SIGHUP: | |
10323 | 171 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); |
10302 | 172 gaim_connections_disconnect_all(); |
173 break; | |
174 case SIGSEGV: | |
13089 | 175 gaim_print_utf8_to_console(stderr, segfault_message); |
10302 | 176 abort(); |
177 break; | |
178 case SIGCHLD: | |
179 clean_pid(); | |
180 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ | |
181 break; | |
182 default: | |
10323 | 183 gaim_debug_warning("sighandler", "Caught signal %d\n", sig); |
10302 | 184 gaim_connections_disconnect_all(); |
185 | |
186 gaim_plugins_unload_all(); | |
187 | |
188 if (gtk_main_level()) | |
189 gtk_main_quit(); | |
190 exit(0); | |
191 } | |
192 } | |
193 #endif | |
194 | |
10323 | 195 static int |
196 ui_main() | |
10302 | 197 { |
198 #ifndef _WIN32 | |
199 GList *icons = NULL; | |
200 GdkPixbuf *icon = NULL; | |
201 char *icon_path; | |
202 #endif | |
203 | |
11525 | 204 gaim_gtkthemes_init(); |
10302 | 205 |
206 gaim_gtk_blist_setup_sort_methods(); | |
207 | |
208 #ifndef _WIN32 | |
209 /* use the nice PNG icon for all the windows */ | |
210 icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL); | |
211 icon = gdk_pixbuf_new_from_file(icon_path, NULL); | |
212 g_free(icon_path); | |
213 if (icon) { | |
214 icons = g_list_append(icons,icon); | |
215 gtk_window_set_default_icon_list(icons); | |
216 g_object_unref(G_OBJECT(icon)); | |
217 g_list_free(icons); | |
218 } else { | |
10323 | 219 gaim_debug_error("ui_main", |
220 "Failed to load the default window icon!\n"); | |
10302 | 221 } |
222 #endif | |
223 | |
224 return 0; | |
225 } | |
226 | |
227 static void | |
228 debug_init(void) | |
229 { | |
230 gaim_debug_set_ui_ops(gaim_gtk_debug_get_ui_ops()); | |
231 gaim_gtk_debug_init(); | |
232 } | |
233 | |
234 static void | |
235 gaim_gtk_ui_init(void) | |
236 { | |
237 /* Set the UI operation structures. */ | |
238 gaim_accounts_set_ui_ops(gaim_gtk_accounts_get_ui_ops()); | |
239 gaim_xfers_set_ui_ops(gaim_gtk_xfers_get_ui_ops()); | |
240 gaim_blist_set_ui_ops(gaim_gtk_blist_get_ui_ops()); | |
241 gaim_notify_set_ui_ops(gaim_gtk_notify_get_ui_ops()); | |
242 gaim_privacy_set_ui_ops(gaim_gtk_privacy_get_ui_ops()); | |
243 gaim_request_set_ui_ops(gaim_gtk_request_get_ui_ops()); | |
244 gaim_sound_set_ui_ops(gaim_gtk_sound_get_ui_ops()); | |
245 gaim_connections_set_ui_ops(gaim_gtk_connections_get_ui_ops()); | |
11475
7fab28c991f3
[gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
11403
diff
changeset
|
246 gaim_whiteboard_set_ui_ops(gaim_gtk_whiteboard_get_ui_ops()); |
12272 | 247 #ifdef USE_SCREENSAVER |
248 gaim_idle_set_ui_ops(gaim_gtk_idle_get_ui_ops()); | |
249 #endif | |
10302 | 250 |
251 gaim_gtk_stock_init(); | |
252 gaim_gtk_prefs_init(); | |
253 gaim_gtk_account_init(); | |
13014 | 254 gaim_gtk_connection_init(); |
10302 | 255 gaim_gtk_blist_init(); |
10574 | 256 gaim_gtk_status_init(); |
10302 | 257 gaim_gtk_conversations_init(); |
258 gaim_gtk_pounces_init(); | |
259 gaim_gtk_privacy_init(); | |
260 gaim_gtk_xfers_init(); | |
261 gaim_gtk_roomlist_init(); | |
12838
cb36bc2db7c5
[gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents:
12670
diff
changeset
|
262 gaim_gtk_log_init(); |
12030
7165a7a444da
[gaim-migrate @ 14323]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12024
diff
changeset
|
263 #ifdef HAVE_VV |
12024 | 264 gaim_gtk_media_init(); |
265 #endif | |
10302 | 266 } |
267 | |
268 static void | |
269 gaim_gtk_quit(void) | |
270 { | |
271 #ifdef USE_SM | |
272 /* unplug */ | |
12246 | 273 gaim_gtk_session_end(); |
10302 | 274 #endif |
275 | |
276 /* Save the plugins we have loaded for next time. */ | |
277 gaim_gtk_plugins_save(); | |
278 | |
10574 | 279 /* Uninit */ |
280 gaim_gtk_conversations_uninit(); | |
281 gaim_gtk_status_uninit(); | |
282 gaim_gtk_blist_uninit(); | |
13014 | 283 gaim_gtk_connection_uninit(); |
10574 | 284 gaim_gtk_account_uninit(); |
11010 | 285 gaim_gtk_xfers_uninit(); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11010
diff
changeset
|
286 gaim_gtk_debug_uninit(); |
10574 | 287 |
10302 | 288 /* and end it all... */ |
289 gtk_main_quit(); | |
290 } | |
291 | |
292 static GaimCoreUiOps core_ops = | |
293 { | |
294 gaim_gtk_prefs_init, | |
295 debug_init, | |
296 gaim_gtk_ui_init, | |
297 gaim_gtk_quit | |
298 }; | |
299 | |
300 static GaimCoreUiOps * | |
301 gaim_gtk_core_get_ui_ops(void) | |
302 { | |
303 return &core_ops; | |
304 } | |
305 | |
306 static void | |
10320 | 307 show_usage(const char *name, gboolean terse) |
10302 | 308 { |
10320 | 309 char *text; |
12846 | 310 |
10320 | 311 if (terse) { |
312 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name); | |
313 } else { | |
314 text = g_strdup_printf(_("Gaim %s\n" | |
10302 | 315 "Usage: %s [OPTION]...\n\n" |
316 " -c, --config=DIR use DIR for config files\n" | |
317 " -d, --debug print debugging messages to stdout\n" | |
10320 | 318 " -h, --help display this help and exit\n" |
10323 | 319 " -n, --nologin don't automatically login\n" |
10320 | 320 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
11673
922d0483ca88
[gaim-migrate @ 13959]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
321 " account(s) to use, separated by commas)\n" |
10323 | 322 " -v, --version display the current version and exit\n"), VERSION, name); |
10302 | 323 } |
324 | |
13089 | 325 gaim_print_utf8_to_console(stdout, text); |
10320 | 326 g_free(text); |
10302 | 327 } |
328 | |
329 #ifdef HAVE_STARTUP_NOTIFICATION | |
330 static void | |
331 sn_error_trap_push(SnDisplay *display, Display *xdisplay) | |
332 { | |
333 gdk_error_trap_push(); | |
334 } | |
335 | |
336 static void | |
337 sn_error_trap_pop(SnDisplay *display, Display *xdisplay) | |
338 { | |
339 gdk_error_trap_pop(); | |
340 } | |
341 | |
342 static void | |
343 startup_notification_complete(void) | |
344 { | |
345 Display *xdisplay; | |
346 | |
347 xdisplay = GDK_DISPLAY(); | |
348 sn_display = sn_display_new(xdisplay, | |
349 sn_error_trap_push, | |
350 sn_error_trap_pop); | |
351 sn_context = | |
352 sn_launchee_context_new_from_environment(sn_display, | |
353 DefaultScreen(xdisplay)); | |
354 | |
355 if (sn_context != NULL) | |
356 { | |
357 sn_launchee_context_complete(sn_context); | |
358 sn_launchee_context_unref(sn_context); | |
359 | |
360 sn_display_unref(sn_display); | |
361 } | |
362 } | |
363 #endif /* HAVE_STARTUP_NOTIFICATION */ | |
364 | |
365 #ifndef _WIN32 | |
366 static char *gaim_find_binary_location(void *symbol, void *data) | |
367 { | |
368 static char *fullname = NULL; | |
369 static gboolean first = TRUE; | |
370 | |
371 char *argv0 = data; | |
372 struct stat st; | |
373 char *basebuf, *linkbuf, *fullbuf; | |
374 | |
375 if (!first) | |
376 /* We've already been through this. */ | |
377 return strdup(fullname); | |
378 | |
379 first = FALSE; | |
380 | |
381 if (!argv0) | |
382 return NULL; | |
383 | |
384 | |
385 basebuf = g_find_program_in_path(argv0); | |
386 | |
387 /* But we still need to deal with symbolic links */ | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
388 g_lstat(basebuf, &st); |
10302 | 389 while ((st.st_mode & S_IFLNK) == S_IFLNK) { |
390 linkbuf = g_malloc(1024); | |
391 readlink(basebuf, linkbuf, 1024); | |
392 if (linkbuf[0] == G_DIR_SEPARATOR) { | |
393 /* an absolute path */ | |
394 fullbuf = g_strdup(linkbuf); | |
395 } else { | |
396 char *dirbuf = g_path_get_dirname(basebuf); | |
397 /* a relative path */ | |
398 fullbuf = g_strdup_printf("%s%s%s", | |
399 dirbuf, G_DIR_SEPARATOR_S, | |
400 linkbuf); | |
401 g_free(dirbuf); | |
402 } | |
403 /* There's no memory leak here. Really! */ | |
404 g_free(linkbuf); | |
405 g_free(basebuf); | |
406 basebuf = fullbuf; | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
407 g_lstat(basebuf, &st); |
10302 | 408 } |
409 | |
410 fullname = basebuf; | |
411 return strdup(fullname); | |
412 } | |
413 #endif /* #ifndef _WIN32 */ | |
414 | |
415 /* FUCKING GET ME A TOWEL! */ | |
416 #ifdef _WIN32 | |
417 int gaim_main(HINSTANCE hint, int argc, char *argv[]) | |
418 #else | |
419 int main(int argc, char *argv[]) | |
420 #endif | |
421 { | |
10323 | 422 gboolean opt_help = FALSE; |
423 gboolean opt_login = FALSE; | |
424 gboolean opt_nologin = FALSE; | |
425 gboolean opt_version = FALSE; | |
426 char *opt_config_dir_arg = NULL; | |
427 char *opt_login_arg = NULL; | |
428 char *opt_session_arg = NULL; | |
429 int dologin_ret = -1; | |
10447 | 430 char *search_path; |
10302 | 431 #if HAVE_SIGNAL_H |
432 int sig_indx; /* for setting up signal catching */ | |
433 sigset_t sigset; | |
12409
d51cf8896f5c
[gaim-migrate @ 14716]
Richard Laager <rlaager@wiktel.com>
parents:
12342
diff
changeset
|
434 RETSIGTYPE (*prev_sig_disp)(int); |
10302 | 435 #endif |
10323 | 436 int opt; |
10302 | 437 gboolean gui_check; |
10307 | 438 gboolean debug_enabled; |
10334 | 439 #if HAVE_SIGNAL_H |
10323 | 440 char errmsg[BUFSIZ]; |
10334 | 441 #endif |
10302 | 442 |
443 struct option long_options[] = { | |
10323 | 444 {"config", required_argument, NULL, 'c'}, |
445 {"debug", no_argument, NULL, 'd'}, | |
446 {"help", no_argument, NULL, 'h'}, | |
447 {"login", optional_argument, NULL, 'l'}, | |
448 {"nologin", no_argument, NULL, 'n'}, | |
449 {"session", required_argument, NULL, 's'}, | |
450 {"version", no_argument, NULL, 'v'}, | |
10302 | 451 {0, 0, 0, 0} |
452 }; | |
453 | |
454 #ifdef DEBUG | |
10307 | 455 debug_enabled = TRUE; |
456 #else | |
457 debug_enabled = FALSE; | |
10302 | 458 #endif |
10307 | 459 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
460 #ifdef GAIM_FATAL_ASSERTS |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
461 /* Make g_return_... functions fatal. */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
462 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
463 #endif |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
464 |
10302 | 465 #ifndef _WIN32 |
466 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]); | |
467 #endif | |
468 #ifdef ENABLE_NLS | |
469 bindtextdomain(PACKAGE, LOCALEDIR); | |
470 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
471 textdomain(PACKAGE); | |
472 #endif | |
473 | |
13089 | 474 #ifdef HAVE_SETLOCALE |
475 /* Locale initialization is not complete here. See gtk_init_check() */ | |
476 setlocale(LC_ALL, ""); | |
477 #endif | |
11080 | 478 |
10302 | 479 #if HAVE_SIGNAL_H |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
480 |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
481 #ifndef DEBUG |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
482 /* We translate this here in case the crash breaks gettext. */ |
13089 | 483 segfault_message = g_strdup_printf(_( |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
484 "Gaim has segfaulted and attempted to dump a core file.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
485 "This is a bug in the software and has happened through\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
486 "no fault of your own.\n\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
487 "It is possible that this bug is already fixed in CVS.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
488 "If you can reproduce the crash, please notify the gaim\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
489 "developers by reporting a bug at\n" |
13089 | 490 "%sbug.php\n\n" |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
491 "Please make sure to specify what you were doing at the time\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
492 "and post the backtrace from the core file. If you do not know\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
493 "how to get the backtrace, please read the instructions at\n" |
13089 | 494 "%sgdb.php. If you need further\n" |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
495 "assistance, please IM either SeanEgn or LSchiere (via AIM).\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
496 "Contact information for Sean and Luke on other protocols is at\n" |
13089 | 497 "%scontactinfo.php.\n"), |
498 GAIM_WEBSITE, GAIM_WEBSITE, GAIM_WEBSITE | |
499 ); | |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
500 #else |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
501 /* Don't mark this for translation. */ |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
502 segfault_message = g_strdup( |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
503 "Hi, user. We need to talk.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
504 "I think something's gone wrong here. It's probably my fault.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
505 "No, really, it's not you... it's me... no no no, I think we get along well\n" |
12670
f57ff720957f
[gaim-migrate @ 15013]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
506 "it's just that.... well, I want to see other people. I... what?!? NO! I \n" |
f57ff720957f
[gaim-migrate @ 15013]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
507 "haven't been cheating on you!! How many times do you want me to tell you?! And\n" |
f57ff720957f
[gaim-migrate @ 15013]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
508 "for the last time, it's just a rash!\n" |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
509 ); |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
510 #endif |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
511 |
10302 | 512 /* Let's not violate any PLA's!!!! */ |
513 /* jseymour: whatever the fsck that means */ | |
514 /* Robot101: for some reason things like gdm like to block * | |
515 * useful signals like SIGCHLD, so we unblock all the ones we * | |
516 * declare a handler for. thanks JSeymour and Vann. */ | |
517 if (sigemptyset(&sigset)) { | |
518 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); | |
519 perror(errmsg); | |
520 } | |
521 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { | |
522 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { | |
523 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", | |
524 catch_sig_list[sig_indx]); | |
525 perror(errmsg); | |
526 } | |
527 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { | |
528 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", | |
529 catch_sig_list[sig_indx]); | |
530 perror(errmsg); | |
531 } | |
532 } | |
533 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { | |
534 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { | |
535 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", | |
536 ignore_sig_list[sig_indx]); | |
537 perror(errmsg); | |
538 } | |
539 } | |
540 | |
541 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { | |
542 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); | |
543 perror(errmsg); | |
10307 | 544 } |
10302 | 545 #endif |
546 | |
547 /* scan command-line options */ | |
548 opterr = 1; | |
549 while ((opt = getopt_long(argc, argv, | |
550 #ifndef _WIN32 | |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
551 "c:dhnl::s:v", |
10302 | 552 #else |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
553 "c:dhnl::v", |
10302 | 554 #endif |
555 long_options, NULL)) != -1) { | |
556 switch (opt) { | |
10323 | 557 case 'c': /* config dir */ |
558 g_free(opt_config_dir_arg); | |
559 opt_config_dir_arg = g_strdup(optarg); | |
10302 | 560 break; |
561 case 'd': /* debug */ | |
10307 | 562 debug_enabled = TRUE; |
10302 | 563 break; |
10323 | 564 case 'h': /* help */ |
565 opt_help = TRUE; | |
566 break; | |
567 case 'n': /* no autologin */ | |
568 opt_nologin = TRUE; | |
10302 | 569 break; |
10323 | 570 case 'l': /* login, option username */ |
571 opt_login = TRUE; | |
572 g_free(opt_login_arg); | |
573 if (optarg != NULL) | |
574 opt_login_arg = g_strdup(optarg); | |
10302 | 575 break; |
10320 | 576 case 's': /* use existing session ID */ |
10323 | 577 g_free(opt_session_arg); |
10320 | 578 opt_session_arg = g_strdup(optarg); |
579 break; | |
10323 | 580 case 'v': /* version */ |
581 opt_version = TRUE; | |
10320 | 582 break; |
10323 | 583 case '?': /* show terse help */ |
10302 | 584 default: |
10320 | 585 show_usage(argv[0], TRUE); |
10302 | 586 return 0; |
587 break; | |
588 } | |
589 } | |
590 | |
591 /* show help message */ | |
592 if (opt_help) { | |
10320 | 593 show_usage(argv[0], FALSE); |
10302 | 594 return 0; |
595 } | |
596 /* show version message */ | |
597 if (opt_version) { | |
10323 | 598 printf("Gaim %s\n", VERSION); |
10302 | 599 return 0; |
600 } | |
601 | |
10323 | 602 /* set a user-specified config directory */ |
603 if (opt_config_dir_arg != NULL) { | |
10871 | 604 gaim_util_set_user_dir(opt_config_dir_arg); |
10323 | 605 } |
606 | |
10448 | 607 /* |
608 * We're done piddling around with command line arguments. | |
609 * Fire up this baby. | |
610 */ | |
611 | |
612 gaim_debug_set_enabled(debug_enabled); | |
613 | |
10302 | 614 #ifdef _WIN32 |
10323 | 615 wgaim_init(hint); |
10302 | 616 #endif |
11067 | 617 |
12572
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
618 search_path = g_build_filename(gaim_user_dir(), "gtkrc-2.0", NULL); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
619 gtk_rc_add_default_file(search_path); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
620 g_free(search_path); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
621 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
622 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
623 gui_check = gtk_init_check(&argc, &argv); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
624 if (!gui_check) { |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
625 char *display = gdk_get_display(); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
626 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
627 printf("Gaim %s\n", VERSION); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
628 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
629 g_warning("cannot open display: %s", display ? display : "unset"); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
630 g_free(display); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
631 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
632 return 1; |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
633 } |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
634 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
635 #ifdef _WIN32 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
636 /** TODO: Move this to a wgaim_gtk_init() if we need such a thing */ |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
637 wgaim_gtkspell_init(); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
638 #endif |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
639 |
10302 | 640 gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops()); |
641 gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops()); | |
642 | |
12342 | 643 /* |
644 * Set plugin search directories. Give priority to the plugins | |
645 * in user's home directory. | |
646 */ | |
10447 | 647 search_path = g_build_filename(gaim_user_dir(), "plugins", NULL); |
648 gaim_plugins_add_search_path(search_path); | |
649 g_free(search_path); | |
12342 | 650 gaim_plugins_add_search_path(LIBDIR); |
10447 | 651 |
10302 | 652 if (!gaim_core_init(GAIM_GTK_UI)) { |
653 fprintf(stderr, | |
654 "Initialization of the Gaim core failed. Dumping core.\n" | |
655 "Please report this!\n"); | |
656 abort(); | |
657 } | |
658 | |
10428 | 659 /* TODO: Move blist loading into gaim_blist_init() */ |
10302 | 660 gaim_set_blist(gaim_blist_new()); |
661 gaim_blist_load(); | |
662 | |
10433 | 663 /* TODO: Move prefs loading into gaim_prefs_init() */ |
10302 | 664 gaim_prefs_load(); |
665 gaim_prefs_update_old(); | |
666 gaim_gtk_prefs_update_old(); | |
667 | |
668 /* load plugins we had when we quit */ | |
669 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); | |
670 | |
10433 | 671 /* TODO: Move pounces loading into gaim_pounces_init() */ |
10302 | 672 gaim_pounces_load(); |
673 | |
674 ui_main(); | |
675 | |
676 #ifdef USE_SM | |
12246 | 677 gaim_gtk_session_init(argv[0], opt_session_arg, opt_config_dir_arg); |
10302 | 678 #endif |
679 if (opt_session_arg != NULL) { | |
680 g_free(opt_session_arg); | |
681 opt_session_arg = NULL; | |
682 } | |
683 if (opt_config_dir_arg != NULL) { | |
684 g_free(opt_config_dir_arg); | |
685 opt_config_dir_arg = NULL; | |
686 } | |
687 | |
12011 | 688 /* |
689 * We want to show the blist early in the init process so the | |
690 * user feels warm and fuzzy (not cold and prickley). | |
691 */ | |
692 gaim_blist_show(); | |
693 | |
10302 | 694 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled")) |
695 gaim_gtk_debug_window_show(); | |
696 | |
697 if (opt_login) { | |
698 dologin_ret = dologin_named(opt_login_arg); | |
699 if (opt_login_arg != NULL) { | |
700 g_free(opt_login_arg); | |
701 opt_login_arg = NULL; | |
702 } | |
703 } | |
704 | |
11806 | 705 if (opt_nologin) |
706 { | |
707 /* Set all accounts to "offline" */ | |
708 GaimSavedStatus *saved_status; | |
13024 | 709 saved_status = gaim_savedstatus_get_current(); |
710 gaim_savedstatus_set_type(saved_status, GAIM_STATUS_OFFLINE); | |
11806 | 711 gaim_savedstatus_activate(saved_status); |
712 } | |
713 else | |
10738 | 714 { |
11348 | 715 /* Everything is good to go--sign on already */ |
12857
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
716 if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
717 gaim_savedstatus_activate(gaim_savedstatus_get_startup()); |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
718 gaim_accounts_restore_current_statuses(); |
10738 | 719 } |
10302 | 720 |
11785 | 721 if (gaim_accounts_get_all_active() == NULL) |
11403 | 722 { |
10302 | 723 gaim_gtk_accounts_window_show(); |
10315 | 724 } |
10302 | 725 |
726 #ifdef HAVE_STARTUP_NOTIFICATION | |
727 startup_notification_complete(); | |
728 #endif | |
10320 | 729 |
10302 | 730 gtk_main(); |
10320 | 731 |
12562
e3b4abe7e0f8
[gaim-migrate @ 14881]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12556
diff
changeset
|
732 #if HAVE_SIGNAL_H |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
733 g_free(segfault_message); |
12562
e3b4abe7e0f8
[gaim-migrate @ 14881]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12556
diff
changeset
|
734 #endif |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
735 |
10302 | 736 #ifdef _WIN32 |
737 wgaim_cleanup(); | |
738 #endif | |
739 | |
740 return 0; | |
741 } |