Mercurial > pidgin
comparison src/main.c @ 5211:0241d6b6702d
[gaim-migrate @ 5581]
Wrote a new debugging API, and of course core/ui split it. Debug statements
can now have debug levels and categories, for future filtering of stuff,
and color highlighting. It's nifty, m'kay?
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 26 Apr 2003 06:46:08 +0000 |
parents | fefad67de2c7 |
children | 1a53330dfd34 |
comparison
equal
deleted
inserted
replaced
5210:39bb2a35f8d9 | 5211:0241d6b6702d |
---|---|
49 #include "prpl.h" | 49 #include "prpl.h" |
50 #include "sound.h" | 50 #include "sound.h" |
51 #include "gaim.h" | 51 #include "gaim.h" |
52 #include "gaim-socket.h" | 52 #include "gaim-socket.h" |
53 #include "gtklist.h" | 53 #include "gtklist.h" |
54 #include "gtkdebug.h" | |
54 #if HAVE_SIGNAL_H | 55 #if HAVE_SIGNAL_H |
55 #include <signal.h> | 56 #include <signal.h> |
56 #endif | 57 #endif |
57 #include "locale.h" | 58 #include "locale.h" |
58 #include <getopt.h> | 59 #include <getopt.h> |
117 signoff_all(); | 118 signoff_all(); |
118 | 119 |
119 /* record what we have before we blow it away... */ | 120 /* record what we have before we blow it away... */ |
120 save_prefs(); | 121 save_prefs(); |
121 | 122 |
122 debug_printf("Unloading all plugins\n"); | 123 gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n"); |
123 gaim_plugins_unload_all(); | 124 gaim_plugins_unload_all(); |
124 | 125 |
125 /* XXX */ | 126 /* XXX */ |
126 #if 0 | 127 #if 0 |
127 #ifdef USE_PERL | 128 #ifdef USE_PERL |
402 #if HAVE_SIGNAL_H | 403 #if HAVE_SIGNAL_H |
403 void sighandler(int sig) | 404 void sighandler(int sig) |
404 { | 405 { |
405 switch (sig) { | 406 switch (sig) { |
406 case SIGHUP: | 407 case SIGHUP: |
407 debug_printf("caught signal %d\n", sig); | 408 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
409 "Caught signal %d\n", sig); | |
408 signoff_all(NULL, NULL); | 410 signoff_all(NULL, NULL); |
409 break; | 411 break; |
410 case SIGSEGV: | 412 case SIGSEGV: |
411 core_quit(); | 413 core_quit(); |
412 #ifndef DEBUG | 414 #ifndef DEBUG |
438 #if HAVE_SIGNAL_H | 440 #if HAVE_SIGNAL_H |
439 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ | 441 signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ |
440 #endif | 442 #endif |
441 break; | 443 break; |
442 default: | 444 default: |
443 debug_printf("caught signal %d\n", sig); | 445 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", |
446 "Caught signal %d\n", sig); | |
444 signoff_all(NULL, NULL); | 447 signoff_all(NULL, NULL); |
445 | 448 |
446 gaim_plugins_unload_all(); | 449 gaim_plugins_unload_all(); |
447 | 450 |
448 if (gtk_main_level()) | 451 if (gtk_main_level()) |
461 guint32 len; | 464 guint32 len; |
462 guchar *data; | 465 guchar *data; |
463 guint32 x; | 466 guint32 x; |
464 GError *error; | 467 GError *error; |
465 | 468 |
466 debug_printf("Core says: "); | 469 gaim_debug(GAIM_DEBUG_INFO, "core socket", "Core says: "); |
467 g_io_channel_read_chars(source, &type, sizeof(type), &x, &error); | 470 g_io_channel_read_chars(source, &type, sizeof(type), &x, &error); |
468 if(error) | 471 if(error) |
469 g_error_free(error); | 472 g_error_free(error); |
470 if (x == 0) { | 473 if (x == 0) { |
471 debug_printf("CORE IS GONE!\n"); | 474 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
472 g_io_channel_shutdown(source, TRUE, &error); | 475 g_io_channel_shutdown(source, TRUE, &error); |
473 if(error) | 476 if(error) |
474 g_free(error); | 477 g_free(error); |
475 return FALSE; | 478 return FALSE; |
476 } | 479 } |
477 debug_printf("%d ", type); | 480 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", type); |
478 g_io_channel_read_chars(source, &subtype, sizeof(subtype), &x, &error); | 481 g_io_channel_read_chars(source, &subtype, sizeof(subtype), &x, &error); |
479 if(error) | 482 if(error) |
480 g_error_free(error); | 483 g_error_free(error); |
481 if (x == 0) { | 484 if (x == 0) { |
482 debug_printf("CORE IS GONE!\n"); | 485 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
483 g_io_channel_shutdown(source, TRUE, &error); | 486 g_io_channel_shutdown(source, TRUE, &error); |
484 if(error) | 487 if(error) |
485 g_error_free(error); | 488 g_error_free(error); |
486 return FALSE; | 489 return FALSE; |
487 } | 490 } |
488 debug_printf("%d ", subtype); | 491 |
492 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", subtype); | |
489 g_io_channel_read_chars(source, (guchar *)&len, sizeof(len), &x, &error); | 493 g_io_channel_read_chars(source, (guchar *)&len, sizeof(len), &x, &error); |
490 if(error) | 494 if(error) |
491 g_error_free(error); | 495 g_error_free(error); |
492 if (x == 0) { | 496 if (x == 0) { |
493 debug_printf("CORE IS GONE!\n"); | 497 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n"); |
494 g_io_channel_shutdown(source, TRUE, &error); | 498 g_io_channel_shutdown(source, TRUE, &error); |
495 if(error) | 499 if(error) |
496 g_error_free(error); | 500 g_error_free(error); |
497 return FALSE; | 501 return FALSE; |
498 } | 502 } |
499 debug_printf("(%d bytes)\n", len); | 503 |
504 gaim_debug(GAIM_DEBUG_INFO, NULL, "(%d bytes)\n", len); | |
500 | 505 |
501 data = g_malloc(len); | 506 data = g_malloc(len); |
502 g_io_channel_read_chars(source, data, len, &x, &error); | 507 g_io_channel_read_chars(source, data, len, &x, &error); |
503 if(error) | 508 if(error) |
504 g_error_free(error); | 509 g_error_free(error); |
505 if (x != len) { | 510 if (x != len) { |
506 debug_printf("CORE IS GONE! (read %d/%d bytes)\n", x, len); | 511 gaim_debug(GAIM_DEBUG_ERROR, "core socket", |
512 "CORE IS GONE! (read %d/%d bytes)\n", x, len); | |
507 g_free(data); | 513 g_free(data); |
508 g_io_channel_shutdown(source, TRUE, &error); | 514 g_io_channel_shutdown(source, TRUE, &error); |
509 if(error) | 515 if(error) |
510 g_error_free(error); | 516 g_error_free(error); |
511 return FALSE; | 517 return FALSE; |
546 icons = g_list_append(icons,icon); | 552 icons = g_list_append(icons,icon); |
547 gtk_window_set_default_icon_list(icons); | 553 gtk_window_set_default_icon_list(icons); |
548 g_object_unref(G_OBJECT(icon)); | 554 g_object_unref(G_OBJECT(icon)); |
549 g_list_free(icons); | 555 g_list_free(icons); |
550 } else { | 556 } else { |
551 debug_printf("Failed to load default window icon!\n"); | 557 gaim_debug(GAIM_DEBUG_ERROR, "ui_main", |
558 "Failed to load the default window icon!\n"); | |
552 } | 559 } |
553 | 560 |
554 g_snprintf(name, sizeof(name), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); | 561 g_snprintf(name, sizeof(name), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session); |
555 UI_fd = gaim_connect_to_session(0); | 562 UI_fd = gaim_connect_to_session(0); |
556 if (UI_fd < 0) | 563 if (UI_fd < 0) |
583 | 590 |
584 #ifdef _WIN32 | 591 #ifdef _WIN32 |
585 /* WIN32 print and log handlers */ | 592 /* WIN32 print and log handlers */ |
586 | 593 |
587 static void gaim_dummy_print( const gchar* string ) { | 594 static void gaim_dummy_print( const gchar* string ) { |
588 return; | 595 return; |
589 } | 596 } |
590 | 597 |
591 static void gaim_dummy_log_handler (const gchar *domain, | 598 static void gaim_dummy_log_handler (const gchar *domain, |
592 GLogLevelFlags flags, | 599 GLogLevelFlags flags, |
593 const gchar *msg, | 600 const gchar *msg, |
594 gpointer user_data) { | 601 gpointer user_data) { |
595 return; | 602 return; |
596 } | 603 } |
597 | 604 |
598 static void gaim_log_handler (const gchar *domain, | 605 static void gaim_log_handler (const gchar *domain, |
599 GLogLevelFlags flags, | 606 GLogLevelFlags flags, |
600 const gchar *msg, | 607 const gchar *msg, |
601 gpointer user_data) { | 608 gpointer user_data) { |
602 debug_printf("%s - %s\n", domain, msg); | 609 gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); |
603 g_log_default_handler(domain, flags, msg, user_data); | 610 g_log_default_handler(domain, flags, msg, user_data); |
604 } | 611 } |
605 #endif /* _WIN32 */ | 612 #endif /* _WIN32 */ |
606 | 613 |
607 /* FUCKING GET ME A TOWEL! */ | 614 /* FUCKING GET ME A TOWEL! */ |
859 if (opt_version) { | 866 if (opt_version) { |
860 printf("Gaim %s\n",VERSION); | 867 printf("Gaim %s\n",VERSION); |
861 return 0; | 868 return 0; |
862 } | 869 } |
863 | 870 |
871 /* Set the UI operation structures. */ | |
872 gaim_set_debug_ui_ops(gaim_get_gtk_debug_ui_ops()); | |
873 gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); | |
874 gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); | |
875 gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); | |
876 | |
877 | |
864 plugin_search_paths[0] = LIBDIR; | 878 plugin_search_paths[0] = LIBDIR; |
865 plugin_search_paths[1] = gaim_user_dir(); | 879 plugin_search_paths[1] = gaim_user_dir(); |
866 plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); | 880 plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); |
867 | 881 |
868 gaim_plugins_set_search_paths(sizeof(plugin_search_paths) / | 882 gaim_plugins_set_search_paths(sizeof(plugin_search_paths) / |
875 | 889 |
876 #ifdef _WIN32 | 890 #ifdef _WIN32 |
877 /* Various win32 initializations */ | 891 /* Various win32 initializations */ |
878 wgaim_init(); | 892 wgaim_init(); |
879 #endif | 893 #endif |
880 | |
881 /* Set the UI operation structures. */ | |
882 gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); | |
883 gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); | |
884 gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); | |
885 | 894 |
886 load_prefs(); | 895 load_prefs(); |
887 core_main(); | 896 core_main(); |
888 load_pounces(); | 897 load_pounces(); |
889 ui_main(); | 898 ui_main(); |
902 g_free(opt_user_arg); | 911 g_free(opt_user_arg); |
903 opt_user_arg = NULL; | 912 opt_user_arg = NULL; |
904 } | 913 } |
905 | 914 |
906 if (misc_options & OPT_MISC_DEBUG) | 915 if (misc_options & OPT_MISC_DEBUG) |
907 show_debug(); | 916 gaim_gtk_debug_window_show(); |
908 | 917 |
909 static_proto_init(); | 918 static_proto_init(); |
910 | 919 |
911 /* deal with --login */ | 920 /* deal with --login */ |
912 if (opt_login) { | 921 if (opt_login) { |