comparison src/main.c @ 5859:022786c7ab53

[gaim-migrate @ 6290] CUI is gone, long live gaim-remote! The old CUI functionality, which was for remote-controlling gaim, is now a Core Plugin, so any future UI (including the current, normal gaim gtk UI) can be remote-controlled. Applications will soon be able to link against the library and header files and provide their own remote-control of gaim, but why bother? :) If you use gaim-remote, make sure to load the new plugin. It won't auto-load. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 14 Jun 2003 06:06:40 +0000
parents 96e5b32e75ad
children d6b5cab288bb
comparison
equal deleted inserted replaced
5858:96e5b32e75ad 5859:022786c7ab53
48 #include <ctype.h> 48 #include <ctype.h>
49 #include "prpl.h" 49 #include "prpl.h"
50 #include "sound.h" 50 #include "sound.h"
51 #include "gtksound.h" 51 #include "gtksound.h"
52 #include "gaim.h" 52 #include "gaim.h"
53 #include "gaim-socket.h"
54 #include "account.h" 53 #include "account.h"
55 #include "prefs.h" 54 #include "prefs.h"
56 #include "notify.h" 55 #include "notify.h"
57 #include "gtkaccount.h" 56 #include "gtkaccount.h"
58 #include "gtkblist.h" 57 #include "gtkblist.h"
424 gaim_debug(GAIM_DEBUG_WARNING, "sighandler", 423 gaim_debug(GAIM_DEBUG_WARNING, "sighandler",
425 "Caught signal %d\n", sig); 424 "Caught signal %d\n", sig);
426 gaim_connections_disconnect_all(); 425 gaim_connections_disconnect_all();
427 break; 426 break;
428 case SIGSEGV: 427 case SIGSEGV:
429 core_quit();
430 #ifndef DEBUG 428 #ifndef DEBUG
431 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" 429 fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n"
432 "This is a bug in the software and has happened through\n" 430 "This is a bug in the software and has happened through\n"
433 "no fault of your own.\n\n" 431 "no fault of your own.\n\n"
434 "It is possible that this bug is already fixed in CVS.\n" 432 "It is possible that this bug is already fixed in CVS.\n"
461 459
462 gaim_plugins_unload_all(); 460 gaim_plugins_unload_all();
463 461
464 if (gtk_main_level()) 462 if (gtk_main_level())
465 gtk_main_quit(); 463 gtk_main_quit();
466 core_quit();
467 exit(0); 464 exit(0);
468 } 465 }
469 } 466 }
470 #endif 467 #endif
471 468
469 static int ui_main()
470 {
472 #ifndef _WIN32 471 #ifndef _WIN32
473 static gboolean socket_readable(GIOChannel *source, GIOCondition cond, gpointer ud)
474 {
475 guchar type;
476 guchar subtype;
477 guint32 len;
478 guchar *data;
479 guint32 x;
480 GError *error;
481
482 gaim_debug(GAIM_DEBUG_INFO, "core socket", "Core says: ");
483 g_io_channel_read_chars(source, &type, sizeof(type), &x, &error);
484 if(error)
485 g_error_free(error);
486 if (x == 0) {
487 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n");
488 g_io_channel_shutdown(source, TRUE, &error);
489 if(error)
490 g_free(error);
491 return FALSE;
492 }
493 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", type);
494 g_io_channel_read_chars(source, &subtype, sizeof(subtype), &x, &error);
495 if(error)
496 g_error_free(error);
497 if (x == 0) {
498 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n");
499 g_io_channel_shutdown(source, TRUE, &error);
500 if(error)
501 g_error_free(error);
502 return FALSE;
503 }
504
505 gaim_debug(GAIM_DEBUG_INFO, NULL, "%d ", subtype);
506 g_io_channel_read_chars(source, (guchar *)&len, sizeof(len), &x, &error);
507 if(error)
508 g_error_free(error);
509 if (x == 0) {
510 gaim_debug(GAIM_DEBUG_ERROR, NULL, "CORE IS GONE!\n");
511 g_io_channel_shutdown(source, TRUE, &error);
512 if(error)
513 g_error_free(error);
514 return FALSE;
515 }
516
517 gaim_debug(GAIM_DEBUG_INFO, NULL, "(%d bytes)\n", len);
518
519 data = g_malloc(len);
520 g_io_channel_read_chars(source, data, len, &x, &error);
521 if(error)
522 g_error_free(error);
523 if (x != len) {
524 gaim_debug(GAIM_DEBUG_ERROR, "core socket",
525 "CORE IS GONE! (read %d/%d bytes)\n", x, len);
526 g_free(data);
527 g_io_channel_shutdown(source, TRUE, &error);
528 if(error)
529 g_error_free(error);
530 return FALSE;
531 }
532
533 g_free(data);
534 return TRUE;
535 }
536 #endif /* _WIN32 */
537
538 static int ui_main()
539 {
540 #ifndef _WIN32
541 GIOChannel *channel;
542 int UI_fd;
543 char name[256];
544 GList *icons = NULL; 472 GList *icons = NULL;
545 GdkPixbuf *icon = NULL; 473 GdkPixbuf *icon = NULL;
546 char *icon_path; 474 char *icon_path;
547 #endif 475 #endif
548 476
569 g_list_free(icons); 497 g_list_free(icons);
570 } else { 498 } else {
571 gaim_debug(GAIM_DEBUG_ERROR, "ui_main", 499 gaim_debug(GAIM_DEBUG_ERROR, "ui_main",
572 "Failed to load the default window icon!\n"); 500 "Failed to load the default window icon!\n");
573 } 501 }
574
575 g_snprintf(name, sizeof(name), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), gaim_session);
576 UI_fd = gaim_connect_to_session(0);
577 if (UI_fd < 0)
578 return 1;
579
580 channel = g_io_channel_unix_new(UI_fd);
581 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, socket_readable, NULL);
582 #endif 502 #endif
583 503
584 return 0; 504 return 0;
585 } 505 }
586 506
923 #ifdef _WIN32 843 #ifdef _WIN32
924 /* Various win32 initializations */ 844 /* Various win32 initializations */
925 wgaim_init(); 845 wgaim_init();
926 #endif 846 #endif
927 847
928 core_main(); 848 gaim_set_blist(gaim_blist_new());
849 gaim_blist_load();
850
929 load_pounces(); 851 load_pounces();
930 ui_main(); 852 ui_main();
931 853
932 #ifdef USE_SM 854 #ifdef USE_SM
933 session_init(argv[0], opt_session_arg); 855 session_init(argv[0], opt_session_arg);
956 g_free(opt_login_arg); 878 g_free(opt_login_arg);
957 opt_login_arg = NULL; 879 opt_login_arg = NULL;
958 } 880 }
959 } 881 }
960 882
961 if (!opt_acct && !opt_nologin && gaim_session == 0) 883 if (!opt_acct && !opt_nologin)
962 gaim_accounts_auto_login(GAIM_GTK_UI); 884 gaim_accounts_auto_login(GAIM_GTK_UI);
963 885
964 if (opt_acct) { 886 if (opt_acct) {
965 gaim_gtk_account_dialog_show(); 887 gaim_gtk_account_dialog_show();
966 } else if ((dologin_ret == -1) && !gaim_connections_get_all()) 888 } else if ((dologin_ret == -1) && !gaim_connections_get_all())
967 show_login(); 889 show_login();
968 890
969 gtk_main(); 891 gtk_main();
970 core_quit();
971 gaim_sound_shutdown(); 892 gaim_sound_shutdown();
972 #ifdef _WIN32 893 #ifdef _WIN32
973 wgaim_cleanup(); 894 wgaim_cleanup();
974 #endif 895 #endif
975 return 0; 896 return 0;