Mercurial > pidgin.yaz
comparison src/core.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 | 7574c6e35fd9 |
children | 0342af6a8b36 |
comparison
equal
deleted
inserted
replaced
6178:06e28a7b72c3 | 6179:16e384bb7fbf |
---|---|
1 /* | 1 /** |
2 * @file core.c Gaim Core API | |
3 * @ingroup core | |
4 * | |
2 * gaim | 5 * gaim |
3 * | 6 * |
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
4 * | 8 * |
5 * This program is free software; you can redistribute it and/or modify | 9 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by | 10 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; either version 2 of the License, or | 11 * the Free Software Foundation; either version 2 of the License, or |
8 * (at your option) any later version. | 12 * (at your option) any later version. |
13 * GNU General Public License for more details. | 17 * GNU General Public License for more details. |
14 * | 18 * |
15 * You should have received a copy of the GNU General Public License | 19 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 20 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | |
19 */ | 22 */ |
23 #include "internal.h" | |
24 #include "connection.h" | |
25 #include "conversation.h" | |
26 #include "core.h" | |
27 #include "debug.h" | |
28 #include "plugin.h" | |
29 #include "pounce.h" | |
30 #include "prefs.h" | |
31 #include "proxy.h" | |
32 #include "sound.h" | |
20 | 33 |
21 /* DONE! */ | 34 struct GaimCore |
35 { | |
36 char *ui; | |
37 | |
38 void *reserved; | |
39 }; | |
40 | |
41 static GaimCoreUiOps *_ops = NULL; | |
42 static GaimCore *_core = NULL; | |
43 | |
44 STATIC_PROTO_INIT | |
45 | |
46 gboolean | |
47 gaim_core_init(const char *ui) | |
48 { | |
49 GaimCoreUiOps *ops; | |
50 GaimCore *core; | |
51 | |
52 g_return_val_if_fail(ui != NULL, FALSE); | |
53 g_return_val_if_fail(gaim_get_core() == NULL, FALSE); | |
54 | |
55 _core = core = g_new0(GaimCore, 1); | |
56 core->ui = g_strdup(ui); | |
57 core->reserved = NULL; | |
58 | |
59 ops = gaim_get_core_ui_ops(); | |
60 | |
61 /* Initialize all static protocols. */ | |
62 static_proto_init(); | |
63 | |
64 printf("gaim_prefs_init\n"); | |
65 gaim_prefs_init(); | |
66 | |
67 if (ops != NULL) { | |
68 if (ops->ui_prefs_init != NULL) | |
69 ops->ui_prefs_init(); | |
70 | |
71 if (ops->debug_ui_init != NULL) | |
72 ops->debug_ui_init(); | |
73 } | |
74 | |
75 printf("conversation_init\n"); | |
76 gaim_conversation_init(); | |
77 gaim_proxy_init(); | |
78 gaim_sound_init(); | |
79 gaim_pounces_init(); | |
80 | |
81 if (ops != NULL && ops->ui_init != NULL) | |
82 ops->ui_init(); | |
83 | |
84 return TRUE; | |
85 } | |
86 | |
87 void | |
88 gaim_core_quit(void) | |
89 { | |
90 GaimCoreUiOps *ops; | |
91 GaimCore *core = gaim_get_core(); | |
92 | |
93 g_return_if_fail(core != NULL); | |
94 | |
95 ops = gaim_get_core_ui_ops(); | |
96 | |
97 if (ops != NULL && ops->quit != NULL) | |
98 ops->quit(); | |
99 | |
100 /* The self destruct sequence has been initiated */ | |
101 gaim_event_broadcast(event_quit); | |
102 | |
103 /* Transmission ends */ | |
104 gaim_connections_disconnect_all(); | |
105 | |
106 /* Record what we have before we blow it away... */ | |
107 gaim_prefs_sync(); | |
108 gaim_accounts_sync(); | |
109 | |
110 gaim_debug(GAIM_DEBUG_INFO, "main", "Unloading all plugins\n"); | |
111 gaim_plugins_destroy_all(); | |
112 | |
113 if (core->ui != NULL) { | |
114 g_free(core->ui); | |
115 core->ui = NULL; | |
116 } | |
117 | |
118 g_free(core); | |
119 | |
120 _core = NULL; | |
121 } | |
122 | |
123 const char * | |
124 gaim_core_get_ui(void) | |
125 { | |
126 GaimCore *core = gaim_get_core(); | |
127 | |
128 g_return_val_if_fail(core != NULL, NULL); | |
129 | |
130 return core->ui; | |
131 } | |
132 | |
133 GaimCore * | |
134 gaim_get_core(void) | |
135 { | |
136 return _core; | |
137 } | |
138 | |
139 void | |
140 gaim_set_core_ui_ops(GaimCoreUiOps *ops) | |
141 { | |
142 _ops = ops; | |
143 } | |
144 | |
145 GaimCoreUiOps * | |
146 gaim_get_core_ui_ops(void) | |
147 { | |
148 return _ops; | |
149 } |