Mercurial > pidgin.yaz
comparison src/main.c @ 6179:16e384bb7fbf
[gaim-migrate @ 6664]
Core/UI split the core initialization and shutdown. I think I got all the
bugs worked out. It's looking nice and stable here, but if it causes CVS to
go to hell for everyone.. er, try to fix it or let me know :) I don't have
this in patch form.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 17 Jul 2003 10:35:43 +0000 |
parents | 0d2bd49c611e |
children | 1fc158d6ebdb |
comparison
equal
deleted
inserted
replaced
6178:06e28a7b72c3 | 6179:16e384bb7fbf |
---|---|
21 | 21 |
22 #include "internal.h" | 22 #include "internal.h" |
23 | 23 |
24 #include "account.h" | 24 #include "account.h" |
25 #include "conversation.h" | 25 #include "conversation.h" |
26 #include "core.h" | |
26 #include "debug.h" | 27 #include "debug.h" |
27 #include "ft.h" | 28 #include "ft.h" |
28 #include "log.h" | 29 #include "log.h" |
29 #include "notify.h" | 30 #include "notify.h" |
30 #include "prefs.h" | 31 #include "prefs.h" |
31 #include "prpl.h" | 32 #include "prpl.h" |
32 #include "pounce.h" | 33 #include "pounce.h" |
33 #include "sound.h" | 34 #include "sound.h" |
34 #include "status.h" | 35 #include "status.h" |
35 #include "util.h" | 36 #include "util.h" |
36 | |
37 //#include "gaim.h" | |
38 | 37 |
39 #include "gtkaccount.h" | 38 #include "gtkaccount.h" |
40 #include "gtkblist.h" | 39 #include "gtkblist.h" |
41 #include "gtkconn.h" | 40 #include "gtkconn.h" |
42 #include "gtkconv.h" | 41 #include "gtkconv.h" |
56 # include <signal.h> | 55 # include <signal.h> |
57 #endif | 56 #endif |
58 | 57 |
59 #include "locale.h" | 58 #include "locale.h" |
60 #include <getopt.h> | 59 #include <getopt.h> |
61 | |
62 #if 0 | |
63 #ifdef GAIM_PLUGINS | |
64 # ifndef _WIN32 | |
65 # include <dlfcn.h> | |
66 # endif | |
67 #endif /* GAIM_PLUGINS */ | |
68 | |
69 #include <gtk/gtk.h> | |
70 #ifndef _WIN32 | |
71 #include <gdk/gdkx.h> | |
72 #include <unistd.h> | |
73 #include <sys/socket.h> | |
74 #include <netinet/in.h> | |
75 #include <arpa/inet.h> | |
76 #include <sys/un.h> | |
77 #include <sys/wait.h> | |
78 #endif /* !_WIN32 */ | |
79 #include <gdk/gdk.h> | |
80 #include <sys/types.h> | |
81 #include <sys/stat.h> | |
82 #include <errno.h> | |
83 #include <stdio.h> | |
84 #include <string.h> | |
85 #include <stdarg.h> | |
86 #include <stdlib.h> | |
87 #include <ctype.h> | |
88 #include "prpl.h" | |
89 #include "sound.h" | |
90 #include "gtksound.h" | |
91 #include "gaim.h" | |
92 #include "account.h" | |
93 #include "prefs.h" | |
94 #include "notify.h" | |
95 #include "gtkaccount.h" | |
96 #include "gtkblist.h" | |
97 #include "gtkconn.h" | |
98 #include "gtkdebug.h" | |
99 #include "gtknotify.h" | |
100 #include "gtkrequest.h" | |
101 #include "gtksound.h" | |
102 #if HAVE_SIGNAL_H | |
103 #include <signal.h> | |
104 #endif | |
105 #include "locale.h" | |
106 #include <getopt.h> | |
107 | |
108 #ifdef _WIN32 | |
109 #include "win32dep.h" | |
110 #endif | |
111 #endif | |
112 | 60 |
113 extern void load_prefs(); | 61 extern void load_prefs(); |
114 extern void load_pounces(); | 62 extern void load_pounces(); |
115 | 63 |
116 static GtkWidget *name; | 64 static GtkWidget *name; |
152 SIGPIPE, | 100 SIGPIPE, |
153 -1 | 101 -1 |
154 }; | 102 }; |
155 #endif | 103 #endif |
156 | 104 |
157 STATIC_PROTO_INIT | |
158 | |
159 void do_quit() | |
160 { | |
161 /* captain's log, stardate... */ | |
162 system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); | |
163 | |
164 /* the self destruct sequence has been initiated */ | |
165 gaim_event_broadcast(event_quit); | |
166 | |
167 /* transmission ends */ | |
168 gaim_connections_disconnect_all(); | |
169 | |
170 /* record what we have before we blow it away... */ | |
171 gaim_prefs_sync(); | |
172 gaim_accounts_sync(); | |
173 | |
174 gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n"); | |
175 gaim_plugins_destroy_all(); | |
176 | |
177 /* XXX */ | |
178 #if 0 | |
179 #ifdef USE_PERL | |
180 /* yup, perl too */ | |
181 perl_end(); | |
182 #endif | |
183 #endif | |
184 | |
185 #ifdef USE_SM | |
186 /* unplug */ | |
187 session_end(); | |
188 #endif | |
189 | |
190 /* and end it all... */ | |
191 gtk_main_quit(); | |
192 } | |
193 | |
194 | |
195 static guint snd_tmout = 0; | 105 static guint snd_tmout = 0; |
196 static gboolean sound_timeout(gpointer data) | 106 static gboolean sound_timeout(gpointer data) |
197 { | 107 { |
198 gaim_gtk_sound_set_login_mute(FALSE); | 108 gaim_gtk_sound_set_login_mute(FALSE); |
199 snd_tmout = 0; | 109 snd_tmout = 0; |
337 #ifdef _WIN32 | 247 #ifdef _WIN32 |
338 wgaim_systray_minimize(mainwindow); | 248 wgaim_systray_minimize(mainwindow); |
339 #endif | 249 #endif |
340 gtk_widget_hide(mainwindow); | 250 gtk_widget_hide(mainwindow); |
341 } else | 251 } else |
342 do_quit(); | 252 gaim_core_quit(); |
343 } | 253 } |
344 | 254 |
345 void show_login() | 255 void show_login() |
346 { | 256 { |
347 GtkWidget *image; | 257 GtkWidget *image; |
574 gpointer user_data) { | 484 gpointer user_data) { |
575 gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); | 485 gaim_debug(GAIM_DEBUG_MISC, "log", "%s - %s\n", domain, msg); |
576 g_log_default_handler(domain, flags, msg, user_data); | 486 g_log_default_handler(domain, flags, msg, user_data); |
577 } | 487 } |
578 #endif /* _WIN32 */ | 488 #endif /* _WIN32 */ |
489 | |
490 static void | |
491 debug_init(void) | |
492 { | |
493 gaim_set_debug_ui_ops(gaim_get_gtk_debug_ui_ops()); | |
494 gaim_gtk_debug_init(); | |
495 } | |
496 | |
497 static void | |
498 gaim_gtk_ui_init(void) | |
499 { | |
500 /* Set the UI operation structures. */ | |
501 gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); | |
502 gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); | |
503 gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); | |
504 gaim_set_notify_ui_ops(gaim_get_gtk_notify_ui_ops()); | |
505 gaim_set_request_ui_ops(gaim_get_gtk_request_ui_ops()); | |
506 gaim_set_sound_ui_ops(gaim_get_gtk_sound_ui_ops()); | |
507 gaim_set_connection_ui_ops(gaim_get_gtk_connection_ui_ops()); | |
508 | |
509 gaim_gtk_prefs_init(); | |
510 gaim_gtk_blist_init(); | |
511 gaim_gtk_conversation_init(); | |
512 gaim_gtk_pounces_init(); | |
513 gaim_gtk_xfer_init(); | |
514 } | |
515 | |
516 static void | |
517 gaim_gtk_quit(void) | |
518 { | |
519 /* XXX? */ | |
520 | |
521 /* captain's log, stardate... */ | |
522 system_log(log_quit, NULL, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); | |
523 | |
524 #ifdef USE_SM | |
525 /* unplug */ | |
526 session_end(); | |
527 #endif | |
528 | |
529 /* and end it all... */ | |
530 gtk_main_quit(); | |
531 } | |
532 | |
533 static GaimCoreUiOps core_ops = | |
534 { | |
535 gaim_gtk_prefs_init, | |
536 debug_init, | |
537 gaim_gtk_ui_init, | |
538 gaim_gtk_quit | |
539 }; | |
540 | |
541 static GaimCoreUiOps * | |
542 gaim_get_gtk_core_ui_ops(void) | |
543 { | |
544 return &core_ops; | |
545 } | |
579 | 546 |
580 /* FUCKING GET ME A TOWEL! */ | 547 /* FUCKING GET ME A TOWEL! */ |
581 #ifdef _WIN32 | 548 #ifdef _WIN32 |
582 int gaim_main(int argc, char *argv[]) | 549 int gaim_main(int argc, char *argv[]) |
583 #else | 550 #else |
831 if (opt_version) { | 798 if (opt_version) { |
832 printf("Gaim %s\n",VERSION); | 799 printf("Gaim %s\n",VERSION); |
833 return 0; | 800 return 0; |
834 } | 801 } |
835 | 802 |
803 gaim_gtk_stock_init(); | |
804 | |
805 gaim_set_core_ui_ops(gaim_get_gtk_core_ui_ops()); | |
806 | |
807 if (!gaim_core_init(GAIM_GTK_UI)) { | |
808 fprintf(stderr, | |
809 "Initialization of the Gaim core failed. Dumping core.\n" | |
810 "Please report this!\n"); | |
811 abort(); | |
812 } | |
813 | |
814 #if 0 | |
836 /* This has to be done before the debug stuff. */ | 815 /* This has to be done before the debug stuff. */ |
837 gaim_gtk_stock_init(); | 816 gaim_gtk_stock_init(); |
838 | 817 |
839 static_proto_init(); | 818 static_proto_init(); |
840 | 819 |
841 gaim_prefs_init(); | 820 gaim_prefs_init(); |
842 gaim_gtk_prefs_init(); | |
843 | 821 |
844 /* This kind of has to be here.. sucks, but it's important. */ | 822 /* This kind of has to be here.. sucks, but it's important. */ |
845 gaim_set_debug_ui_ops(gaim_get_gtk_debug_ui_ops()); | |
846 gaim_gtk_debug_init(); | 823 gaim_gtk_debug_init(); |
847 | |
848 /* Set the UI operation structures. */ | |
849 gaim_set_win_ui_ops(gaim_get_gtk_window_ui_ops()); | |
850 gaim_set_xfer_ui_ops(gaim_get_gtk_xfer_ui_ops()); | |
851 gaim_set_blist_ui_ops(gaim_get_gtk_blist_ui_ops()); | |
852 gaim_set_notify_ui_ops(gaim_get_gtk_notify_ui_ops()); | |
853 gaim_set_request_ui_ops(gaim_get_gtk_request_ui_ops()); | |
854 gaim_set_sound_ui_ops(gaim_get_gtk_sound_ui_ops()); | |
855 gaim_set_connection_ui_ops(gaim_get_gtk_connection_ui_ops()); | |
856 | 824 |
857 gaim_conversation_init(); | 825 gaim_conversation_init(); |
858 gaim_proxy_init(); | 826 gaim_proxy_init(); |
859 gaim_sound_init(); | 827 gaim_sound_init(); |
860 gaim_pounces_init(); | 828 gaim_pounces_init(); |
861 | 829 |
830 gaim_gtk_prefs_init(); | |
862 gaim_gtk_blist_init(); | 831 gaim_gtk_blist_init(); |
863 gaim_gtk_conversation_init(); | 832 gaim_gtk_conversation_init(); |
864 gaim_gtk_pounces_init(); | 833 gaim_gtk_pounces_init(); |
865 gaim_gtk_xfer_init(); | 834 gaim_gtk_xfer_init(); |
835 #endif | |
866 | 836 |
867 plugin_search_paths[0] = LIBDIR; | 837 plugin_search_paths[0] = LIBDIR; |
868 plugin_search_paths[1] = gaim_user_dir(); | 838 plugin_search_paths[1] = gaim_user_dir(); |
869 plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); | 839 plugin_search_paths[2] = g_strdup_printf("%s/plugins", gaim_user_dir()); |
870 | 840 |