Mercurial > pidgin
annotate libgaim/core.c @ 14234:04bdbbefbd1d
[gaim-migrate @ 16916]
Mark the messages from gnthistory as delayed, and don't print the timestamps
for delayed messages (I think it makes sense).
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 20 Aug 2006 19:37:33 +0000 |
parents | ab8a105eff62 |
children | f189327b9968 |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file core.c Gaim Core API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include "internal.h" | |
26 #include "cipher.h" | |
27 #include "connection.h" | |
28 #include "conversation.h" | |
29 #include "core.h" | |
30 #include "debug.h" | |
31 #include "ft.h" | |
32 #include "idle.h" | |
33 #include "network.h" | |
34 #include "notify.h" | |
35 #include "plugin.h" | |
36 #include "pounce.h" | |
37 #include "prefs.h" | |
38 #include "privacy.h" | |
39 #include "proxy.h" | |
40 #include "savedstatuses.h" | |
41 #include "signals.h" | |
42 #include "sslconn.h" | |
43 #include "status.h" | |
44 #include "stun.h" | |
45 #include "sound.h" | |
46 | |
47 #ifdef HAVE_DBUS | |
48 # include "dbus-server.h" | |
49 #endif | |
50 | |
51 struct GaimCore | |
52 { | |
53 char *ui; | |
54 | |
55 void *reserved; | |
56 }; | |
57 | |
58 static GaimCoreUiOps *_ops = NULL; | |
59 static GaimCore *_core = NULL; | |
60 | |
61 STATIC_PROTO_INIT | |
62 | |
63 gboolean | |
64 gaim_core_init(const char *ui) | |
65 { | |
66 GaimCoreUiOps *ops; | |
67 GaimCore *core; | |
68 | |
69 g_return_val_if_fail(ui != NULL, FALSE); | |
70 g_return_val_if_fail(gaim_get_core() == NULL, FALSE); | |
71 | |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
72 #ifdef _WIN32 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
73 wgaim_init(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
74 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
75 |
14192 | 76 _core = core = g_new0(GaimCore, 1); |
77 core->ui = g_strdup(ui); | |
78 core->reserved = NULL; | |
79 | |
80 ops = gaim_core_get_ui_ops(); | |
81 | |
82 /* The signals subsystem is important and should be first. */ | |
83 gaim_signals_init(); | |
84 | |
85 gaim_signal_register(core, "quitting", gaim_marshal_VOID, NULL, 0); | |
86 | |
87 /* The prefs subsystem needs to be initialized before static protocols | |
88 * for protocol prefs to work. */ | |
89 gaim_prefs_init(); | |
90 | |
91 gaim_debug_init(); | |
92 | |
93 if (ops != NULL) | |
94 { | |
95 if (ops->ui_prefs_init != NULL) | |
96 ops->ui_prefs_init(); | |
97 | |
98 if (ops->debug_ui_init != NULL) | |
99 ops->debug_ui_init(); | |
100 } | |
101 | |
102 #ifdef HAVE_DBUS | |
103 gaim_dbus_init(); | |
104 #endif | |
105 | |
106 /* Initialize all static protocols. */ | |
107 static_proto_init(); | |
108 | |
109 /* Since plugins get probed so early we should probably initialize their | |
110 * subsystem right away too. | |
111 */ | |
112 gaim_plugins_init(); | |
113 gaim_plugins_probe(G_MODULE_SUFFIX); | |
114 | |
115 /* Accounts use status and buddy icons, so initialize these before accounts */ | |
116 gaim_status_init(); | |
117 gaim_buddy_icons_init(); | |
118 | |
119 gaim_accounts_init(); | |
120 gaim_savedstatuses_init(); | |
121 gaim_ciphers_init(); | |
122 gaim_notify_init(); | |
123 gaim_connections_init(); | |
124 gaim_conversations_init(); | |
125 gaim_blist_init(); | |
126 gaim_log_init(); | |
127 gaim_network_init(); | |
128 gaim_privacy_init(); | |
129 gaim_pounces_init(); | |
130 gaim_proxy_init(); | |
131 gaim_sound_init(); | |
132 gaim_ssl_init(); | |
133 gaim_stun_init(); | |
134 gaim_xfers_init(); | |
135 gaim_idle_init(); | |
136 | |
137 /* Call this early on to try to auto-detect our IP address */ | |
138 gaim_network_get_my_ip(-1); | |
139 | |
140 if (ops != NULL && ops->ui_init != NULL) | |
141 ops->ui_init(); | |
142 | |
143 return TRUE; | |
144 } | |
145 | |
146 void | |
147 gaim_core_quit(void) | |
148 { | |
149 GaimCoreUiOps *ops; | |
150 GaimCore *core = gaim_get_core(); | |
151 | |
152 g_return_if_fail(core != NULL); | |
153 | |
154 /* The self destruct sequence has been initiated */ | |
155 gaim_signal_emit(gaim_get_core(), "quitting"); | |
156 | |
157 /* Transmission ends */ | |
158 gaim_connections_disconnect_all(); | |
159 | |
160 /* Save .xml files, remove signals, etc. */ | |
161 gaim_idle_uninit(); | |
162 gaim_ssl_uninit(); | |
163 gaim_pounces_uninit(); | |
164 gaim_blist_uninit(); | |
165 gaim_ciphers_uninit(); | |
166 gaim_notify_uninit(); | |
167 gaim_conversations_uninit(); | |
168 gaim_connections_uninit(); | |
169 gaim_buddy_icons_uninit(); | |
170 gaim_accounts_uninit(); | |
171 gaim_savedstatuses_uninit(); | |
172 gaim_status_uninit(); | |
173 gaim_prefs_uninit(); | |
174 gaim_xfers_uninit(); | |
175 | |
176 gaim_debug_info("main", "Unloading all plugins\n"); | |
177 gaim_plugins_destroy_all(); | |
178 | |
179 ops = gaim_core_get_ui_ops(); | |
180 if (ops != NULL && ops->quit != NULL) | |
181 ops->quit(); | |
182 | |
183 /* | |
184 * gaim_sound_uninit() should be called as close to | |
185 * shutdown as possible. This is because the call | |
186 * to ao_shutdown() can sometimes leave our | |
187 * environment variables in an unusable state, which | |
188 * can cause a crash when getenv is called (by gettext | |
189 * for example). See the complete bug report at | |
190 * http://trac.xiph.org/cgi-bin/trac.cgi/ticket/701 | |
191 * | |
192 * TODO: Eventually move this call higher up with the others. | |
193 */ | |
194 gaim_sound_uninit(); | |
195 | |
196 gaim_plugins_uninit(); | |
197 gaim_signals_uninit(); | |
198 | |
199 #ifdef HAVE_DBUS | |
200 gaim_dbus_uninit(); | |
201 #endif | |
202 | |
203 g_free(core->ui); | |
204 g_free(core); | |
205 | |
14224
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
206 #ifdef _WIN32 |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
207 wgaim_cleanup(); |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
208 #endif |
ab8a105eff62
[gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
14192
diff
changeset
|
209 |
14192 | 210 _core = NULL; |
211 } | |
212 | |
213 gboolean | |
214 gaim_core_quit_cb(gpointer unused) | |
215 { | |
216 gaim_core_quit(); | |
217 | |
218 return FALSE; | |
219 } | |
220 | |
221 const char * | |
222 gaim_core_get_version(void) | |
223 { | |
224 return VERSION; | |
225 } | |
226 | |
227 const char * | |
228 gaim_core_get_ui(void) | |
229 { | |
230 GaimCore *core = gaim_get_core(); | |
231 | |
232 g_return_val_if_fail(core != NULL, NULL); | |
233 | |
234 return core->ui; | |
235 } | |
236 | |
237 GaimCore * | |
238 gaim_get_core(void) | |
239 { | |
240 return _core; | |
241 } | |
242 | |
243 void | |
244 gaim_core_set_ui_ops(GaimCoreUiOps *ops) | |
245 { | |
246 _ops = ops; | |
247 } | |
248 | |
249 GaimCoreUiOps * | |
250 gaim_core_get_ui_ops(void) | |
251 { | |
252 return _ops; | |
253 } |