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