Mercurial > pidgin
annotate src/gtkmain.c @ 12871:2422097a7a5e
[gaim-migrate @ 15223]
Whitespace in some .c and .h files that I hadn't had a reason to touch before,
this is it's own commit mostly to show how easy it was to get perl plugins to
support individual plugin pref frames, as opposed to just one for all the
loaded perl plugins.
And some whitespace that I missed in Conversation.xs.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Sat, 14 Jan 2006 07:12:46 +0000 |
parents | e5f780a6137b |
children | 5efbb0162f86 |
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: | |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
175 fprintf(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(); | |
254 gaim_gtk_blist_init(); | |
10574 | 255 gaim_gtk_status_init(); |
10302 | 256 gaim_gtk_conversations_init(); |
257 gaim_gtk_pounces_init(); | |
258 gaim_gtk_privacy_init(); | |
259 gaim_gtk_xfers_init(); | |
260 gaim_gtk_roomlist_init(); | |
12838
cb36bc2db7c5
[gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents:
12670
diff
changeset
|
261 gaim_gtk_log_init(); |
12030
7165a7a444da
[gaim-migrate @ 14323]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12024
diff
changeset
|
262 #ifdef HAVE_VV |
12024 | 263 gaim_gtk_media_init(); |
264 #endif | |
10302 | 265 } |
266 | |
267 static void | |
268 gaim_gtk_quit(void) | |
269 { | |
270 #ifdef USE_SM | |
271 /* unplug */ | |
12246 | 272 gaim_gtk_session_end(); |
10302 | 273 #endif |
274 | |
275 /* Save the plugins we have loaded for next time. */ | |
276 gaim_gtk_plugins_save(); | |
277 | |
10574 | 278 /* Uninit */ |
279 gaim_gtk_conversations_uninit(); | |
280 gaim_gtk_status_uninit(); | |
281 gaim_gtk_blist_uninit(); | |
282 gaim_gtk_account_uninit(); | |
11010 | 283 gaim_gtk_xfers_uninit(); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11010
diff
changeset
|
284 gaim_gtk_debug_uninit(); |
10574 | 285 |
10302 | 286 /* and end it all... */ |
287 gtk_main_quit(); | |
288 } | |
289 | |
290 static GaimCoreUiOps core_ops = | |
291 { | |
292 gaim_gtk_prefs_init, | |
293 debug_init, | |
294 gaim_gtk_ui_init, | |
295 gaim_gtk_quit | |
296 }; | |
297 | |
298 static GaimCoreUiOps * | |
299 gaim_gtk_core_get_ui_ops(void) | |
300 { | |
301 return &core_ops; | |
302 } | |
303 | |
304 static void | |
10320 | 305 show_usage(const char *name, gboolean terse) |
10302 | 306 { |
10320 | 307 char *text; |
308 char *text_conv; | |
309 GError *error = NULL; | |
10302 | 310 |
12846 | 311 #ifdef HAVE_SETLOCALE |
312 /* Locale initialization is not complete here. See gtk_init_check() */ | |
313 setlocale(LC_ALL, ""); | |
314 #endif | |
315 | |
10320 | 316 if (terse) { |
317 text = g_strdup_printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name); | |
318 } else { | |
319 text = g_strdup_printf(_("Gaim %s\n" | |
10302 | 320 "Usage: %s [OPTION]...\n\n" |
321 " -c, --config=DIR use DIR for config files\n" | |
322 " -d, --debug print debugging messages to stdout\n" | |
10320 | 323 " -h, --help display this help and exit\n" |
10323 | 324 " -n, --nologin don't automatically login\n" |
10320 | 325 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
11673
922d0483ca88
[gaim-migrate @ 13959]
Richard Laager <rlaager@wiktel.com>
parents:
11581
diff
changeset
|
326 " account(s) to use, separated by commas)\n" |
10323 | 327 " -v, --version display the current version and exit\n"), VERSION, name); |
10302 | 328 } |
329 | |
10320 | 330 /* tries to convert 'text' to users locale */ |
331 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error); | |
332 if (text_conv != NULL) { | |
333 puts(text_conv); | |
334 g_free(text_conv); | |
10302 | 335 } |
10320 | 336 /* use 'text' as a fallback */ |
337 else { | |
338 g_warning("%s\n", error->message); | |
339 g_error_free(error); | |
340 puts(text); | |
341 } | |
342 g_free(text); | |
10302 | 343 } |
344 | |
345 #ifdef HAVE_STARTUP_NOTIFICATION | |
346 static void | |
347 sn_error_trap_push(SnDisplay *display, Display *xdisplay) | |
348 { | |
349 gdk_error_trap_push(); | |
350 } | |
351 | |
352 static void | |
353 sn_error_trap_pop(SnDisplay *display, Display *xdisplay) | |
354 { | |
355 gdk_error_trap_pop(); | |
356 } | |
357 | |
358 static void | |
359 startup_notification_complete(void) | |
360 { | |
361 Display *xdisplay; | |
362 | |
363 xdisplay = GDK_DISPLAY(); | |
364 sn_display = sn_display_new(xdisplay, | |
365 sn_error_trap_push, | |
366 sn_error_trap_pop); | |
367 sn_context = | |
368 sn_launchee_context_new_from_environment(sn_display, | |
369 DefaultScreen(xdisplay)); | |
370 | |
371 if (sn_context != NULL) | |
372 { | |
373 sn_launchee_context_complete(sn_context); | |
374 sn_launchee_context_unref(sn_context); | |
375 | |
376 sn_display_unref(sn_display); | |
377 } | |
378 } | |
379 #endif /* HAVE_STARTUP_NOTIFICATION */ | |
380 | |
381 #ifndef _WIN32 | |
382 static char *gaim_find_binary_location(void *symbol, void *data) | |
383 { | |
384 static char *fullname = NULL; | |
385 static gboolean first = TRUE; | |
386 | |
387 char *argv0 = data; | |
388 struct stat st; | |
389 char *basebuf, *linkbuf, *fullbuf; | |
390 | |
391 if (!first) | |
392 /* We've already been through this. */ | |
393 return strdup(fullname); | |
394 | |
395 first = FALSE; | |
396 | |
397 if (!argv0) | |
398 return NULL; | |
399 | |
400 | |
401 basebuf = g_find_program_in_path(argv0); | |
402 | |
403 /* But we still need to deal with symbolic links */ | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
404 g_lstat(basebuf, &st); |
10302 | 405 while ((st.st_mode & S_IFLNK) == S_IFLNK) { |
406 linkbuf = g_malloc(1024); | |
407 readlink(basebuf, linkbuf, 1024); | |
408 if (linkbuf[0] == G_DIR_SEPARATOR) { | |
409 /* an absolute path */ | |
410 fullbuf = g_strdup(linkbuf); | |
411 } else { | |
412 char *dirbuf = g_path_get_dirname(basebuf); | |
413 /* a relative path */ | |
414 fullbuf = g_strdup_printf("%s%s%s", | |
415 dirbuf, G_DIR_SEPARATOR_S, | |
416 linkbuf); | |
417 g_free(dirbuf); | |
418 } | |
419 /* There's no memory leak here. Really! */ | |
420 g_free(linkbuf); | |
421 g_free(basebuf); | |
422 basebuf = fullbuf; | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10581
diff
changeset
|
423 g_lstat(basebuf, &st); |
10302 | 424 } |
425 | |
426 fullname = basebuf; | |
427 return strdup(fullname); | |
428 } | |
429 #endif /* #ifndef _WIN32 */ | |
430 | |
431 /* FUCKING GET ME A TOWEL! */ | |
432 #ifdef _WIN32 | |
433 int gaim_main(HINSTANCE hint, int argc, char *argv[]) | |
434 #else | |
435 int main(int argc, char *argv[]) | |
436 #endif | |
437 { | |
10323 | 438 gboolean opt_help = FALSE; |
439 gboolean opt_login = FALSE; | |
440 gboolean opt_nologin = FALSE; | |
441 gboolean opt_version = FALSE; | |
442 char *opt_config_dir_arg = NULL; | |
443 char *opt_login_arg = NULL; | |
444 char *opt_session_arg = NULL; | |
445 int dologin_ret = -1; | |
10447 | 446 char *search_path; |
10302 | 447 #if HAVE_SIGNAL_H |
448 int sig_indx; /* for setting up signal catching */ | |
449 sigset_t sigset; | |
12409
d51cf8896f5c
[gaim-migrate @ 14716]
Richard Laager <rlaager@wiktel.com>
parents:
12342
diff
changeset
|
450 RETSIGTYPE (*prev_sig_disp)(int); |
10302 | 451 #endif |
10323 | 452 int opt; |
10302 | 453 gboolean gui_check; |
10307 | 454 gboolean debug_enabled; |
10334 | 455 #if HAVE_SIGNAL_H |
10323 | 456 char errmsg[BUFSIZ]; |
10334 | 457 #endif |
10302 | 458 |
459 struct option long_options[] = { | |
10323 | 460 {"config", required_argument, NULL, 'c'}, |
461 {"debug", no_argument, NULL, 'd'}, | |
462 {"help", no_argument, NULL, 'h'}, | |
463 {"login", optional_argument, NULL, 'l'}, | |
464 {"nologin", no_argument, NULL, 'n'}, | |
465 {"session", required_argument, NULL, 's'}, | |
466 {"version", no_argument, NULL, 'v'}, | |
10302 | 467 {0, 0, 0, 0} |
468 }; | |
469 | |
470 #ifdef DEBUG | |
10307 | 471 debug_enabled = TRUE; |
472 #else | |
473 debug_enabled = FALSE; | |
10302 | 474 #endif |
10307 | 475 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
476 #ifdef GAIM_FATAL_ASSERTS |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
477 /* Make g_return_... functions fatal. */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
478 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
479 #endif |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12572
diff
changeset
|
480 |
10302 | 481 #ifndef _WIN32 |
482 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]); | |
483 #endif | |
484 #ifdef ENABLE_NLS | |
485 bindtextdomain(PACKAGE, LOCALEDIR); | |
486 bind_textdomain_codeset(PACKAGE, "UTF-8"); | |
487 textdomain(PACKAGE); | |
488 #endif | |
489 | |
11080 | 490 |
10302 | 491 #if HAVE_SIGNAL_H |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
492 |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
493 #ifndef DEBUG |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
494 /* We translate this here in case the crash breaks gettext. */ |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
495 segfault_message = g_strdup(_( |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
496 "Gaim has segfaulted and attempted to dump a core file.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
497 "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
|
498 "no fault of your own.\n\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
499 "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
|
500 "If you can reproduce the crash, please notify the gaim\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
501 "developers by reporting a bug at\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
502 GAIM_WEBSITE "bug.php\n\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
503 "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
|
504 "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
|
505 "how to get the backtrace, please read the instructions at\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
506 GAIM_WEBSITE "gdb.php. If you need further\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
507 "assistance, please IM either SeanEgn or LSchiere (via AIM).\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
508 "Contact information for Sean and Luke on other protocols is at\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
509 GAIM_WEBSITE "contactinfo.php.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
510 )); |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
511 #else |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
512 /* Don't mark this for translation. */ |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
513 segfault_message = g_strdup( |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
514 "Hi, user. We need to talk.\n" |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
515 "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
|
516 "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
|
517 "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
|
518 "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
|
519 "for the last time, it's just a rash!\n" |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
520 ); |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
521 #endif |
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
522 |
10302 | 523 /* Let's not violate any PLA's!!!! */ |
524 /* jseymour: whatever the fsck that means */ | |
525 /* Robot101: for some reason things like gdm like to block * | |
526 * useful signals like SIGCHLD, so we unblock all the ones we * | |
527 * declare a handler for. thanks JSeymour and Vann. */ | |
528 if (sigemptyset(&sigset)) { | |
529 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); | |
530 perror(errmsg); | |
531 } | |
532 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { | |
533 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { | |
534 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", | |
535 catch_sig_list[sig_indx]); | |
536 perror(errmsg); | |
537 } | |
538 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { | |
539 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", | |
540 catch_sig_list[sig_indx]); | |
541 perror(errmsg); | |
542 } | |
543 } | |
544 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { | |
545 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { | |
546 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", | |
547 ignore_sig_list[sig_indx]); | |
548 perror(errmsg); | |
549 } | |
550 } | |
551 | |
552 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { | |
553 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); | |
554 perror(errmsg); | |
10307 | 555 } |
10302 | 556 #endif |
557 | |
558 /* scan command-line options */ | |
559 opterr = 1; | |
560 while ((opt = getopt_long(argc, argv, | |
561 #ifndef _WIN32 | |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
562 "c:dhnl::s:v", |
10302 | 563 #else |
11795
f48e2acaa5d2
[gaim-migrate @ 14086]
Richard Laager <rlaager@wiktel.com>
parents:
11785
diff
changeset
|
564 "c:dhnl::v", |
10302 | 565 #endif |
566 long_options, NULL)) != -1) { | |
567 switch (opt) { | |
10323 | 568 case 'c': /* config dir */ |
569 g_free(opt_config_dir_arg); | |
570 opt_config_dir_arg = g_strdup(optarg); | |
10302 | 571 break; |
572 case 'd': /* debug */ | |
10307 | 573 debug_enabled = TRUE; |
10302 | 574 break; |
10323 | 575 case 'h': /* help */ |
576 opt_help = TRUE; | |
577 break; | |
578 case 'n': /* no autologin */ | |
579 opt_nologin = TRUE; | |
10302 | 580 break; |
10323 | 581 case 'l': /* login, option username */ |
582 opt_login = TRUE; | |
583 g_free(opt_login_arg); | |
584 if (optarg != NULL) | |
585 opt_login_arg = g_strdup(optarg); | |
10302 | 586 break; |
10320 | 587 case 's': /* use existing session ID */ |
10323 | 588 g_free(opt_session_arg); |
10320 | 589 opt_session_arg = g_strdup(optarg); |
590 break; | |
10323 | 591 case 'v': /* version */ |
592 opt_version = TRUE; | |
10320 | 593 break; |
10323 | 594 case '?': /* show terse help */ |
10302 | 595 default: |
10320 | 596 show_usage(argv[0], TRUE); |
10302 | 597 return 0; |
598 break; | |
599 } | |
600 } | |
601 | |
602 /* show help message */ | |
603 if (opt_help) { | |
10320 | 604 show_usage(argv[0], FALSE); |
10302 | 605 return 0; |
606 } | |
607 /* show version message */ | |
608 if (opt_version) { | |
10323 | 609 printf("Gaim %s\n", VERSION); |
10302 | 610 return 0; |
611 } | |
612 | |
10323 | 613 /* set a user-specified config directory */ |
614 if (opt_config_dir_arg != NULL) { | |
10871 | 615 gaim_util_set_user_dir(opt_config_dir_arg); |
10323 | 616 } |
617 | |
10448 | 618 /* |
619 * We're done piddling around with command line arguments. | |
620 * Fire up this baby. | |
621 */ | |
622 | |
623 gaim_debug_set_enabled(debug_enabled); | |
624 | |
10302 | 625 #ifdef _WIN32 |
10323 | 626 wgaim_init(hint); |
10302 | 627 #endif |
11067 | 628 |
12572
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
629 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
|
630 gtk_rc_add_default_file(search_path); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
631 g_free(search_path); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
632 |
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 gui_check = gtk_init_check(&argc, &argv); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
635 if (!gui_check) { |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
636 char *display = gdk_get_display(); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
637 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
638 printf("Gaim %s\n", VERSION); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
639 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
640 g_warning("cannot open display: %s", display ? display : "unset"); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
641 g_free(display); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
642 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
643 return 1; |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
644 } |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
645 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
646 #ifdef _WIN32 |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
647 /** 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
|
648 wgaim_gtkspell_init(); |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
649 #endif |
bf01b160ab0d
[gaim-migrate @ 14891]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12562
diff
changeset
|
650 |
10302 | 651 gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops()); |
652 gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops()); | |
653 | |
12342 | 654 /* |
655 * Set plugin search directories. Give priority to the plugins | |
656 * in user's home directory. | |
657 */ | |
10447 | 658 search_path = g_build_filename(gaim_user_dir(), "plugins", NULL); |
659 gaim_plugins_add_search_path(search_path); | |
660 g_free(search_path); | |
12342 | 661 gaim_plugins_add_search_path(LIBDIR); |
10447 | 662 |
10302 | 663 if (!gaim_core_init(GAIM_GTK_UI)) { |
664 fprintf(stderr, | |
665 "Initialization of the Gaim core failed. Dumping core.\n" | |
666 "Please report this!\n"); | |
667 abort(); | |
668 } | |
669 | |
10428 | 670 /* TODO: Move blist loading into gaim_blist_init() */ |
10302 | 671 gaim_set_blist(gaim_blist_new()); |
672 gaim_blist_load(); | |
673 | |
10433 | 674 /* TODO: Move prefs loading into gaim_prefs_init() */ |
10302 | 675 gaim_prefs_load(); |
676 gaim_prefs_update_old(); | |
677 gaim_gtk_prefs_update_old(); | |
678 | |
679 /* load plugins we had when we quit */ | |
680 gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); | |
681 | |
10433 | 682 /* TODO: Move pounces loading into gaim_pounces_init() */ |
10302 | 683 gaim_pounces_load(); |
684 | |
685 ui_main(); | |
686 | |
687 #ifdef USE_SM | |
12246 | 688 gaim_gtk_session_init(argv[0], opt_session_arg, opt_config_dir_arg); |
10302 | 689 #endif |
690 if (opt_session_arg != NULL) { | |
691 g_free(opt_session_arg); | |
692 opt_session_arg = NULL; | |
693 } | |
694 if (opt_config_dir_arg != NULL) { | |
695 g_free(opt_config_dir_arg); | |
696 opt_config_dir_arg = NULL; | |
697 } | |
698 | |
12011 | 699 /* |
700 * We want to show the blist early in the init process so the | |
701 * user feels warm and fuzzy (not cold and prickley). | |
702 */ | |
703 gaim_blist_show(); | |
704 | |
10302 | 705 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled")) |
706 gaim_gtk_debug_window_show(); | |
707 | |
708 if (opt_login) { | |
709 dologin_ret = dologin_named(opt_login_arg); | |
710 if (opt_login_arg != NULL) { | |
711 g_free(opt_login_arg); | |
712 opt_login_arg = NULL; | |
713 } | |
714 } | |
715 | |
11806 | 716 if (opt_nologin) |
717 { | |
718 /* Set all accounts to "offline" */ | |
719 GaimSavedStatus *saved_status; | |
720 saved_status = gaim_savedstatus_find(_("Default")); | |
721 if (saved_status == NULL) | |
722 saved_status = gaim_savedstatus_new(_("Default"), GAIM_STATUS_OFFLINE); | |
723 else | |
724 gaim_savedstatus_set_type(saved_status, GAIM_STATUS_OFFLINE); | |
725 gaim_savedstatus_activate(saved_status); | |
726 } | |
727 else | |
10738 | 728 { |
11348 | 729 /* Everything is good to go--sign on already */ |
12857
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
730 if (!gaim_prefs_get_bool("/core/savedstatus/startup_current_status")) |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
731 gaim_savedstatus_activate(gaim_savedstatus_get_startup()); |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12846
diff
changeset
|
732 gaim_accounts_restore_current_statuses(); |
10738 | 733 } |
10302 | 734 |
11785 | 735 if (gaim_accounts_get_all_active() == NULL) |
11403 | 736 { |
10302 | 737 gaim_gtk_accounts_window_show(); |
10315 | 738 } |
10302 | 739 |
740 #ifdef HAVE_STARTUP_NOTIFICATION | |
741 startup_notification_complete(); | |
742 #endif | |
10320 | 743 |
10302 | 744 gtk_main(); |
10320 | 745 |
12562
e3b4abe7e0f8
[gaim-migrate @ 14881]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12556
diff
changeset
|
746 #if HAVE_SIGNAL_H |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
747 g_free(segfault_message); |
12562
e3b4abe7e0f8
[gaim-migrate @ 14881]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12556
diff
changeset
|
748 #endif |
12556
14e094d7568f
[gaim-migrate @ 14875]
Richard Laager <rlaager@wiktel.com>
parents:
12409
diff
changeset
|
749 |
10302 | 750 #ifdef _WIN32 |
751 wgaim_cleanup(); | |
752 #endif | |
753 | |
754 return 0; | |
755 } |