Mercurial > pidgin
comparison src/aim.c @ 1009:d496fe2614a6
[gaim-migrate @ 1019]
command-line options for the app. not for the applet because most of the time you don't run it from the command line anyway. thanks bmiller
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 20 Oct 2000 00:35:30 +0000 |
parents | 1d8f05ea6bdf |
children | 5bad25457843 |
comparison
equal
deleted
inserted
replaced
1008:1b99caffcd98 | 1009:d496fe2614a6 |
---|---|
51 #if HAVE_SIGNAL_H | 51 #if HAVE_SIGNAL_H |
52 #include <signal.h> | 52 #include <signal.h> |
53 #endif | 53 #endif |
54 #include "locale.h" | 54 #include "locale.h" |
55 #include "gtkticker.h" | 55 #include "gtkticker.h" |
56 #ifndef USE_GNOME | |
57 #include <getopt.h> | |
58 #endif | |
56 | 59 |
57 static GtkWidget *name; | 60 static GtkWidget *name; |
58 static GtkWidget *pass; | 61 static GtkWidget *pass; |
59 | 62 |
60 GList *permit = NULL; | 63 GList *permit = NULL; |
70 | 73 |
71 void BuddyTickerCreateWindow( void ); | 74 void BuddyTickerCreateWindow( void ); |
72 | 75 |
73 char toc_addy[16]; | 76 char toc_addy[16]; |
74 char *quad_addr = NULL; | 77 char *quad_addr = NULL; |
78 | |
75 | 79 |
76 void cancel_logon(void) | 80 void cancel_logon(void) |
77 { | 81 { |
78 #ifdef USE_APPLET | 82 #ifdef USE_APPLET |
79 applet_buddy_show = FALSE; | 83 applet_buddy_show = FALSE; |
428 fprintf(stderr, "God damn, I tripped.\n"); | 432 fprintf(stderr, "God damn, I tripped.\n"); |
429 exit(11); /* signal 11 */ | 433 exit(11); /* signal 11 */ |
430 } | 434 } |
431 #endif | 435 #endif |
432 | 436 |
437 | |
433 int main(int argc, char *argv[]) | 438 int main(int argc, char *argv[]) |
434 { | 439 { |
440 char opt, i; | |
441 int opt_acct = 0, opt_help = 0, opt_version = 0, | |
442 opt_user = 0, opt_login = 0, do_login_ret = -1; | |
443 char *opt_user_arg = NULL, *opt_login_arg = NULL; | |
444 | |
445 #ifdef USE_GNOME | |
446 poptContext popt_context; | |
447 struct poptOption popt_options[] = | |
448 { | |
449 {"acct", 'a', POPT_ARG_NONE, &opt_acct, 'a', | |
450 "Display account editor window", NULL}, | |
451 {"login", 'l', POPT_ARG_STRING, NULL, 'l', | |
452 "Automatically login (optional argument NAME specifies account(s) to use)", "[NAME]"}, | |
453 {"user", 'u', POPT_ARG_STRING, &opt_user_arg, 'u', | |
454 "Use account NAME", "NAME"}, | |
455 {0, 0, 0, 0, 0, 0, 0} | |
456 }; | |
457 #else | |
458 struct option long_options[] = | |
459 { | |
460 {"acct", no_argument, NULL, 'a'}, | |
461 {"help", no_argument, NULL, 'h'}, | |
462 {"login", optional_argument, NULL, 'l'}, | |
463 {"user", required_argument, NULL, 'u'}, | |
464 {"version", no_argument, NULL, 'v'}, | |
465 {0, 0, 0, 0} | |
466 }; | |
467 #endif /* USE_GNOME */ | |
468 | |
469 | |
435 #ifdef ENABLE_NLS | 470 #ifdef ENABLE_NLS |
436 bindtextdomain(PACKAGE, LOCALEDIR); | 471 bindtextdomain(PACKAGE, LOCALEDIR); |
437 textdomain(PACKAGE); | 472 textdomain(PACKAGE); |
438 #endif | 473 #endif |
439 | 474 |
440 #if HAVE_SIGNAL_H | 475 #if HAVE_SIGNAL_H |
441 /* Let's not violate any PLA's!!!! */ | 476 /* Let's not violate any PLA's!!!! */ |
442 /* signal(SIGSEGV, sighandler); */ | 477 /* signal(SIGSEGV, sighandler); */ |
443 #endif | 478 #endif |
444 | 479 |
445 if (argc > 1 && !strcmp(argv[1], "--version")) { | 480 |
481 #ifdef USE_APPLET | |
482 init_applet_mgr(argc, argv); | |
483 #elif defined USE_GNOME | |
484 for (i = 0; i < argc; i++) { | |
485 /* --login option */ | |
486 if (strstr (argv[i], "--l") == argv[i]) { | |
487 char *equals; | |
488 opt_login = 1; | |
489 if ((equals = strchr(argv[i], '=')) != NULL) { | |
490 /* --login=NAME */ | |
491 opt_login_arg = g_strdup (equals+1); | |
492 } else if (i+1 < argc && argv[i+1][0] != '-') { | |
493 /* --login NAME */ | |
494 opt_login_arg = g_strdup (argv[i+1]); | |
495 strcpy (argv[i+1], " "); | |
496 } | |
497 strcpy (argv[i], " "); | |
498 } | |
499 /* -l option */ | |
500 else if (strstr (argv[i], "-l") == argv[i]) { | |
501 opt_login = 1; | |
502 if (strlen (argv[i]) > 2) { | |
503 /* -lNAME */ | |
504 opt_login_arg = g_strdup (argv[i]+2); | |
505 } else if (i+1 < argc && argv[i+1][0] != '-') { | |
506 /* -l NAME */ | |
507 opt_login_arg = g_strdup (argv[i+1]); | |
508 strcpy (argv[i+1], " "); | |
509 } | |
510 strcpy (argv[i], " "); | |
511 } | |
512 } | |
513 | |
514 gnome_init_with_popt_table(PACKAGE,VERSION,argc,argv, | |
515 popt_options,0,NULL); | |
516 #else | |
517 gtk_init(&argc, &argv); | |
518 | |
519 /* scan command-line options */ | |
520 opterr = 1; | |
521 while ((opt = getopt_long (argc, argv, /*"ahl::u:v"*/"ahl::u:v", | |
522 long_options, NULL)) != -1) { | |
523 switch (opt) { | |
524 case 'u': /* set user */ | |
525 opt_user = 1; | |
526 opt_user_arg = g_strdup (optarg); | |
527 break; | |
528 case 'l': | |
529 opt_login = 1; | |
530 opt_login_arg = g_strdup (optarg); | |
531 break; | |
532 case 'a': /* account editor */ | |
533 opt_acct = 1; | |
534 break; | |
535 case 'v': /* version */ | |
536 opt_version = 1; | |
537 break; | |
538 case 'h': /* help */ | |
539 opt_help = 1; | |
540 break; | |
541 case '?': | |
542 default: | |
543 show_usage(1, argv[0]); | |
544 return 0; | |
545 break; | |
546 } | |
547 } | |
548 | |
549 #endif /* USE_GNOME */ | |
550 | |
551 /* show help message */ | |
552 if (opt_help) { | |
553 show_usage(0, argv[0]); | |
554 return 0; | |
555 } | |
556 /* show version window */ | |
557 if (opt_version) { | |
446 gtk_init(&argc, &argv); | 558 gtk_init(&argc, &argv); |
447 set_defaults(FALSE); /* needed for open_url_nw */ | 559 set_defaults(FALSE); /* needed for open_url_nw */ |
448 load_prefs(); | 560 load_prefs(); |
449 show_about(0, (void *)1); | 561 show_about(0, (void *)1); |
450 gtk_main(); | 562 gtk_main(); |
451 return 0; | 563 return 0; |
452 } | 564 } |
453 | 565 |
454 #ifdef USE_APPLET | |
455 init_applet_mgr(argc, argv); | |
456 #elif defined USE_GNOME | |
457 gnome_init(PACKAGE,VERSION,argc,argv); | |
458 #else | |
459 gtk_init(&argc, &argv); | |
460 #endif /* USE_GNOME */ | |
461 | 566 |
462 set_defaults(FALSE); | 567 set_defaults(FALSE); |
463 load_prefs(); | 568 load_prefs(); |
569 | |
570 /* set the default username */ | |
571 if (opt_user_arg != NULL) { | |
572 set_first_user (opt_user_arg); | |
573 #ifndef USE_GNOME | |
574 g_free (opt_user_arg); | |
575 opt_user_arg = NULL; | |
576 #endif /* USE_GNOME */ | |
577 } | |
464 | 578 |
465 if (general_options & OPT_GEN_DEBUG) | 579 if (general_options & OPT_GEN_DEBUG) |
466 show_debug(NULL); | 580 show_debug(NULL); |
467 | 581 |
468 gdk_threads_enter(); | 582 gdk_threads_enter(); |
469 | 583 |
470 #ifdef USE_PERL | 584 #ifdef USE_PERL |
471 perl_init(); | 585 perl_init(); |
472 perl_autoload(); | 586 perl_autoload(); |
473 #endif | 587 #endif |
474 | |
475 static_proto_init(); | 588 static_proto_init(); |
476 auto_login(); | 589 |
590 /* deal with --login */ | |
591 if (opt_login) { | |
592 do_login_ret = do_auto_login (opt_login_arg); | |
593 if (opt_login_arg != NULL) { | |
594 g_free (opt_login_arg); | |
595 opt_login_arg = NULL; | |
596 } | |
597 } | |
598 | |
599 if (!opt_acct) | |
600 auto_login(); | |
477 | 601 |
478 #ifdef USE_APPLET | 602 #ifdef USE_APPLET |
479 applet_widget_register_callback(APPLET_WIDGET(applet), | 603 applet_widget_register_callback(APPLET_WIDGET(applet), |
480 "prefs", | 604 "prefs", |
481 _("Preferences"), | 605 _("Preferences"), |
497 update_pixmaps(); | 621 update_pixmaps(); |
498 | 622 |
499 applet_widget_gtk_main(); | 623 applet_widget_gtk_main(); |
500 #else | 624 #else |
501 | 625 |
502 show_login(); | 626 if (opt_acct) { |
627 account_editor (NULL, NULL); | |
628 } else if (do_login_ret == -1) | |
629 show_login(); | |
503 gtk_main(); | 630 gtk_main(); |
504 | 631 |
505 #endif /* USE_APPLET */ | 632 #endif /* USE_APPLET */ |
506 gdk_threads_leave(); | 633 gdk_threads_leave(); |
507 | 634 |