| 425 char *opt_session_arg = NULL; |
431 char *opt_session_arg = NULL; |
| 426 char *search_path; |
432 char *search_path; |
| 427 GtkCssProvider *provider; |
433 GtkCssProvider *provider; |
| 428 GdkScreen *screen; |
434 GdkScreen *screen; |
| 429 GList *accounts; |
435 GList *accounts; |
| |
436 #ifndef _WIN32 |
| 430 int sig_indx; /* for setting up signal catching */ |
437 int sig_indx; /* for setting up signal catching */ |
| 431 sigset_t sigset; |
438 sigset_t sigset; |
| 432 char errmsg[BUFSIZ]; |
439 char errmsg[BUFSIZ]; |
| 433 GIOChannel *signal_channel; |
440 GIOChannel *signal_channel; |
| 434 GIOStatus signal_status; |
441 GIOStatus signal_status; |
| 435 guint signal_channel_watcher; |
442 guint signal_channel_watcher; |
| 436 GError *error; |
|
| 437 #ifndef DEBUG |
443 #ifndef DEBUG |
| 438 char *segfault_message_tmp; |
444 char *segfault_message_tmp; |
| 439 #endif /* DEBUG */ |
445 #endif /* DEBUG */ |
| |
446 #endif /* !_WIN32 */ |
| 440 int opt; |
447 int opt; |
| 441 gboolean gui_check; |
448 gboolean gui_check; |
| 442 gboolean debug_enabled, debug_colored; |
449 gboolean debug_enabled, debug_colored; |
| 443 GList *active_accounts; |
450 GList *active_accounts; |
| 444 GStatBuf st; |
451 GStatBuf st; |
| |
452 GError *error; |
| 445 |
453 |
| 446 struct option long_options[] = { |
454 struct option long_options[] = { |
| 447 {"config", required_argument, NULL, 'c'}, |
455 {"config", required_argument, NULL, 'c'}, |
| 448 {"debug", optional_argument, NULL, 'd'}, |
456 {"debug", optional_argument, NULL, 'd'}, |
| 449 {"force-online", no_argument, NULL, 'f'}, |
457 {"force-online", no_argument, NULL, 'f'}, |
| 471 textdomain(PACKAGE); |
479 textdomain(PACKAGE); |
| 472 #endif |
480 #endif |
| 473 |
481 |
| 474 /* Locale initialization is not complete here. See gtk_init_check() */ |
482 /* Locale initialization is not complete here. See gtk_init_check() */ |
| 475 setlocale(LC_ALL, ""); |
483 setlocale(LC_ALL, ""); |
| |
484 |
| |
485 #ifndef _WIN32 |
| 476 |
486 |
| 477 #ifndef DEBUG |
487 #ifndef DEBUG |
| 478 /* We translate this here in case the crash breaks gettext. */ |
488 /* We translate this here in case the crash breaks gettext. */ |
| 479 segfault_message_tmp = g_strdup_printf(_( |
489 segfault_message_tmp = g_strdup_printf(_( |
| 480 "%s %s has segfaulted and attempted to dump a core file.\n" |
490 "%s %s has segfaulted and attempted to dump a core file.\n" |
| 572 |
582 |
| 573 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { |
583 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { |
| 574 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals"); |
584 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals"); |
| 575 perror(errmsg); |
585 perror(errmsg); |
| 576 } |
586 } |
| |
587 #endif /* !_WIN32 */ |
| 577 |
588 |
| 578 /* scan command-line options */ |
589 /* scan command-line options */ |
| 579 opterr = 1; |
590 opterr = 1; |
| 580 while ((opt = getopt_long(argc, argv, |
591 while ((opt = getopt_long(argc, argv, |
| 581 #ifndef _WIN32 |
592 #ifndef _WIN32 |
| 624 /* handled by gtk_init_check below */ |
635 /* handled by gtk_init_check below */ |
| 625 break; |
636 break; |
| 626 case '?': /* show terse help */ |
637 case '?': /* show terse help */ |
| 627 default: |
638 default: |
| 628 show_usage(argv[0], TRUE); |
639 show_usage(argv[0], TRUE); |
| |
640 #ifndef _WIN32 |
| 629 g_free(segfault_message); |
641 g_free(segfault_message); |
| |
642 #endif |
| 630 return 0; |
643 return 0; |
| 631 break; |
644 break; |
| 632 } |
645 } |
| 633 } |
646 } |
| 634 |
647 |
| 635 /* show help message */ |
648 /* show help message */ |
| 636 if (opt_help) { |
649 if (opt_help) { |
| 637 show_usage(argv[0], FALSE); |
650 show_usage(argv[0], FALSE); |
| |
651 #ifndef _WIN32 |
| 638 g_free(segfault_message); |
652 g_free(segfault_message); |
| |
653 #endif |
| 639 return 0; |
654 return 0; |
| 640 } |
655 } |
| 641 /* show version message */ |
656 /* show version message */ |
| 642 if (opt_version) { |
657 if (opt_version) { |
| 643 printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION, |
658 printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION, |
| 644 purple_core_get_version()); |
659 purple_core_get_version()); |
| |
660 #ifndef _WIN32 |
| 645 g_free(segfault_message); |
661 g_free(segfault_message); |
| |
662 #endif |
| 646 return 0; |
663 return 0; |
| 647 } |
664 } |
| 648 |
665 |
| 649 /* set a user-specified config directory */ |
666 /* set a user-specified config directory */ |
| 650 if (opt_config_dir_arg != NULL) { |
667 if (opt_config_dir_arg != NULL) { |
| 675 const char *display = gdk_display_get_name(gdk_display_get_default()); |
692 const char *display = gdk_display_get_name(gdk_display_get_default()); |
| 676 |
693 |
| 677 printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION); |
694 printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION); |
| 678 |
695 |
| 679 g_warning("cannot open display: %s", display ? display : "unset"); |
696 g_warning("cannot open display: %s", display ? display : "unset"); |
| |
697 #ifndef _WIN32 |
| 680 g_free(segfault_message); |
698 g_free(segfault_message); |
| |
699 #endif |
| 681 |
700 |
| 682 return 1; |
701 return 1; |
| 683 } |
702 } |
| 684 |
703 |
| 685 search_path = g_build_filename(purple_user_dir(), "gtk-3.0.css", NULL); |
704 search_path = g_build_filename(purple_user_dir(), "gtk-3.0.css", NULL); |
| 709 |
728 |
| 710 if (!purple_core_init(PIDGIN_UI)) { |
729 if (!purple_core_init(PIDGIN_UI)) { |
| 711 fprintf(stderr, |
730 fprintf(stderr, |
| 712 "Initialization of the libpurple core failed. Dumping core.\n" |
731 "Initialization of the libpurple core failed. Dumping core.\n" |
| 713 "Please report this!\n"); |
732 "Please report this!\n"); |
| |
733 #ifndef _WIN32 |
| 714 g_free(segfault_message); |
734 g_free(segfault_message); |
| |
735 #endif |
| 715 abort(); |
736 abort(); |
| 716 } |
737 } |
| 717 |
738 |
| 718 search_path = g_build_filename(purple_user_dir(), "plugins", NULL); |
739 search_path = g_build_filename(purple_user_dir(), "plugins", NULL); |
| 719 if (!g_stat(search_path, &st)) |
740 if (!g_stat(search_path, &st)) |
| 735 dbus_message_unref(message); |
756 dbus_message_unref(message); |
| 736 #endif |
757 #endif |
| 737 gdk_notify_startup_complete(); |
758 gdk_notify_startup_complete(); |
| 738 purple_core_quit(); |
759 purple_core_quit(); |
| 739 g_printerr(_("Exiting because another libpurple client is already running.\n")); |
760 g_printerr(_("Exiting because another libpurple client is already running.\n")); |
| |
761 #ifndef _WIN32 |
| 740 g_free(segfault_message); |
762 g_free(segfault_message); |
| |
763 #endif |
| 741 return 0; |
764 return 0; |
| 742 } |
765 } |
| 743 |
766 |
| 744 /* load plugins we had when we quit */ |
767 /* load plugins we had when we quit */ |
| 745 purple_plugins_load_saved(PIDGIN_PREFS_ROOT "/plugins/loaded"); |
768 purple_plugins_load_saved(PIDGIN_PREFS_ROOT "/plugins/loaded"); |