comparison pidgin/gtkmain.c @ 25343:b38cbefca6ad

Add a -f/--force-online option to Pidgin which tells libpurple to claim the network is available, even if NetworkManager (or Windows) says it isn't. This is useful for offline development with nullprpl. If you don't like -f for this and would just like to keep the long option, I'm fine with that. Also, remove a -x/--nocrash option in Pidgin that doesn't seem to do anything.
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Nov 2008 06:06:35 +0000
parents 38a2f78f80a7
children 3687049b4faf
comparison
equal deleted inserted replaced
25342:291b84bf4f8b 25343:b38cbefca6ad
388 #ifndef WIN32 388 #ifndef WIN32
389 text = g_strdup_printf(_("%s %s\n" 389 text = g_strdup_printf(_("%s %s\n"
390 "Usage: %s [OPTION]...\n\n" 390 "Usage: %s [OPTION]...\n\n"
391 " -c, --config=DIR use DIR for config files\n" 391 " -c, --config=DIR use DIR for config files\n"
392 " -d, --debug print debugging messages to stdout\n" 392 " -d, --debug print debugging messages to stdout\n"
393 " -f, --force-online force online, regardless of network status\n"
393 " -h, --help display this help and exit\n" 394 " -h, --help display this help and exit\n"
394 " -m, --multiple do not ensure single instance\n" 395 " -m, --multiple do not ensure single instance\n"
395 " -n, --nologin don't automatically login\n" 396 " -n, --nologin don't automatically login\n"
396 " -l, --login[=NAME] enable specified account(s) (optional argument NAME\n" 397 " -l, --login[=NAME] enable specified account(s) (optional argument NAME\n"
397 " specifies account(s) to use, separated by commas.\n" 398 " specifies account(s) to use, separated by commas.\n"
401 #else 402 #else
402 text = g_strdup_printf(_("%s %s\n" 403 text = g_strdup_printf(_("%s %s\n"
403 "Usage: %s [OPTION]...\n\n" 404 "Usage: %s [OPTION]...\n\n"
404 " -c, --config=DIR use DIR for config files\n" 405 " -c, --config=DIR use DIR for config files\n"
405 " -d, --debug print debugging messages to stdout\n" 406 " -d, --debug print debugging messages to stdout\n"
407 " -f, --force-online force online, regardless of network status\n"
406 " -h, --help display this help and exit\n" 408 " -h, --help display this help and exit\n"
407 " -m, --multiple do not ensure single instance\n" 409 " -m, --multiple do not ensure single instance\n"
408 " -n, --nologin don't automatically login\n" 410 " -n, --nologin don't automatically login\n"
409 " -l, --login[=NAME] enable specified account(s) (optional argument NAME\n" 411 " -l, --login[=NAME] enable specified account(s) (optional argument NAME\n"
410 " specifies account(s) to use, separated by commas.\n" 412 " specifies account(s) to use, separated by commas.\n"
460 int pidgin_main(HINSTANCE hint, int argc, char *argv[]) 462 int pidgin_main(HINSTANCE hint, int argc, char *argv[])
461 #else 463 #else
462 int main(int argc, char *argv[]) 464 int main(int argc, char *argv[])
463 #endif 465 #endif
464 { 466 {
467 gboolean opt_force_online = FALSE;
465 gboolean opt_help = FALSE; 468 gboolean opt_help = FALSE;
466 gboolean opt_login = FALSE; 469 gboolean opt_login = FALSE;
467 gboolean opt_nologin = FALSE; 470 gboolean opt_nologin = FALSE;
468 gboolean opt_nocrash = FALSE;
469 gboolean opt_version = FALSE; 471 gboolean opt_version = FALSE;
470 gboolean opt_si = TRUE; /* Check for single instance? */ 472 gboolean opt_si = TRUE; /* Check for single instance? */
471 char *opt_config_dir_arg = NULL; 473 char *opt_config_dir_arg = NULL;
472 char *opt_login_arg = NULL; 474 char *opt_login_arg = NULL;
473 char *opt_session_arg = NULL; 475 char *opt_session_arg = NULL;
488 gboolean debug_enabled; 490 gboolean debug_enabled;
489 gboolean migration_failed = FALSE; 491 gboolean migration_failed = FALSE;
490 GList *active_accounts; 492 GList *active_accounts;
491 493
492 struct option long_options[] = { 494 struct option long_options[] = {
493 {"config", required_argument, NULL, 'c'}, 495 {"config", required_argument, NULL, 'c'},
494 {"debug", no_argument, NULL, 'd'}, 496 {"debug", no_argument, NULL, 'd'},
495 {"help", no_argument, NULL, 'h'}, 497 {"force-online", no_argument, NULL, 'd'},
496 {"login", optional_argument, NULL, 'l'}, 498 {"help", no_argument, NULL, 'h'},
497 {"multiple", no_argument, NULL, 'm'}, 499 {"login", optional_argument, NULL, 'l'},
498 {"nologin", no_argument, NULL, 'n'}, 500 {"multiple", no_argument, NULL, 'm'},
499 {"nocrash", no_argument, NULL, 'x'}, 501 {"nologin", no_argument, NULL, 'n'},
500 {"session", required_argument, NULL, 's'}, 502 {"session", required_argument, NULL, 's'},
501 {"version", no_argument, NULL, 'v'}, 503 {"version", no_argument, NULL, 'v'},
502 {"display", required_argument, NULL, 'D'}, 504 {"display", required_argument, NULL, 'D'},
503 {"sync", no_argument, NULL, 'S'}, 505 {"sync", no_argument, NULL, 'S'},
504 {0, 0, 0, 0} 506 {0, 0, 0, 0}
505 }; 507 };
506 508
507 #ifdef DEBUG 509 #ifdef DEBUG
508 debug_enabled = TRUE; 510 debug_enabled = TRUE;
605 607
606 /* scan command-line options */ 608 /* scan command-line options */
607 opterr = 1; 609 opterr = 1;
608 while ((opt = getopt_long(argc, argv, 610 while ((opt = getopt_long(argc, argv,
609 #ifndef _WIN32 611 #ifndef _WIN32
610 "c:dhmnl::s:v", 612 "c:dfhmnl::s:v",
611 #else 613 #else
612 "c:dhmnl::v", 614 "c:dfhmnl::v",
613 #endif 615 #endif
614 long_options, NULL)) != -1) { 616 long_options, NULL)) != -1) {
615 switch (opt) { 617 switch (opt) {
616 case 'c': /* config dir */ 618 case 'c': /* config dir */
617 g_free(opt_config_dir_arg); 619 g_free(opt_config_dir_arg);
618 opt_config_dir_arg = g_strdup(optarg); 620 opt_config_dir_arg = g_strdup(optarg);
619 break; 621 break;
620 case 'd': /* debug */ 622 case 'd': /* debug */
621 debug_enabled = TRUE; 623 debug_enabled = TRUE;
622 break; 624 break;
625 case 'f': /* force-online */
626 opt_force_online = TRUE;
627 break;
623 case 'h': /* help */ 628 case 'h': /* help */
624 opt_help = TRUE; 629 opt_help = TRUE;
625 break; 630 break;
626 case 'n': /* no autologin */ 631 case 'n': /* no autologin */
627 opt_nologin = TRUE; 632 opt_nologin = TRUE;
639 case 'v': /* version */ 644 case 'v': /* version */
640 opt_version = TRUE; 645 opt_version = TRUE;
641 break; 646 break;
642 case 'm': /* do not ensure single instance. */ 647 case 'm': /* do not ensure single instance. */
643 opt_si = FALSE; 648 opt_si = FALSE;
644 break;
645 case 'x': /* --nocrash */
646 opt_nocrash = TRUE;
647 break; 649 break;
648 case 'D': /* --display */ 650 case 'D': /* --display */
649 case 'S': /* --sync */ 651 case 'S': /* --sync */
650 /* handled by gtk_init_check below */ 652 /* handled by gtk_init_check below */
651 break; 653 break;
819 if (opt_config_dir_arg != NULL) { 821 if (opt_config_dir_arg != NULL) {
820 g_free(opt_config_dir_arg); 822 g_free(opt_config_dir_arg);
821 opt_config_dir_arg = NULL; 823 opt_config_dir_arg = NULL;
822 } 824 }
823 825
826 /* This needs to be before purple_blist_show() so the
827 * statusbox gets the forced online status. */
828 if (opt_force_online)
829 purple_network_force_online();
830
824 /* 831 /*
825 * We want to show the blist early in the init process so the 832 * We want to show the blist early in the init process so the
826 * user feels warm and fuzzy (not cold and prickley). 833 * user feels warm and fuzzy (not cold and prickley).
827 */ 834 */
828 purple_blist_show(); 835 purple_blist_show();