Mercurial > pidgin.yaz
comparison libpurple/core.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | b0471b2a1de9 |
children | fa8aeab4ca5a |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file core.c Gaim Core API | 2 * @file core.c Purple Core API |
3 * @ingroup core | 3 * @ingroup core |
4 * | 4 * |
5 * gaim | 5 * purple |
6 * | 6 * |
7 * Gaim is the legal property of its developers, whose names are too numerous | 7 * Purple 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 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | 9 * source distribution. |
10 * | 10 * |
11 * This program is free software; you can redistribute it and/or modify | 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 | 12 * it under the terms of the GNU General Public License as published by |
47 | 47 |
48 #ifdef HAVE_DBUS | 48 #ifdef HAVE_DBUS |
49 # include "dbus-server.h" | 49 # include "dbus-server.h" |
50 #endif | 50 #endif |
51 | 51 |
52 struct GaimCore | 52 struct PurpleCore |
53 { | 53 { |
54 char *ui; | 54 char *ui; |
55 | 55 |
56 void *reserved; | 56 void *reserved; |
57 }; | 57 }; |
58 | 58 |
59 static GaimCoreUiOps *_ops = NULL; | 59 static PurpleCoreUiOps *_ops = NULL; |
60 static GaimCore *_core = NULL; | 60 static PurpleCore *_core = NULL; |
61 | 61 |
62 STATIC_PROTO_INIT | 62 STATIC_PROTO_INIT |
63 | 63 |
64 gboolean | 64 gboolean |
65 gaim_core_init(const char *ui) | 65 purple_core_init(const char *ui) |
66 { | 66 { |
67 GaimCoreUiOps *ops; | 67 PurpleCoreUiOps *ops; |
68 GaimCore *core; | 68 PurpleCore *core; |
69 | 69 |
70 g_return_val_if_fail(ui != NULL, FALSE); | 70 g_return_val_if_fail(ui != NULL, FALSE); |
71 g_return_val_if_fail(gaim_get_core() == NULL, FALSE); | 71 g_return_val_if_fail(purple_get_core() == NULL, FALSE); |
72 | 72 |
73 #ifdef _WIN32 | 73 #ifdef _WIN32 |
74 wgaim_init(); | 74 wpurple_init(); |
75 #endif | 75 #endif |
76 | 76 |
77 _core = core = g_new0(GaimCore, 1); | 77 _core = core = g_new0(PurpleCore, 1); |
78 core->ui = g_strdup(ui); | 78 core->ui = g_strdup(ui); |
79 core->reserved = NULL; | 79 core->reserved = NULL; |
80 | 80 |
81 ops = gaim_core_get_ui_ops(); | 81 ops = purple_core_get_ui_ops(); |
82 | 82 |
83 /* The signals subsystem is important and should be first. */ | 83 /* The signals subsystem is important and should be first. */ |
84 gaim_signals_init(); | 84 purple_signals_init(); |
85 | 85 |
86 gaim_signal_register(core, "uri-handler", | 86 purple_signal_register(core, "uri-handler", |
87 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER, | 87 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER, |
88 gaim_value_new(GAIM_TYPE_BOOLEAN), 3, | 88 purple_value_new(PURPLE_TYPE_BOOLEAN), 3, |
89 gaim_value_new(GAIM_TYPE_STRING), /* Protocol */ | 89 purple_value_new(PURPLE_TYPE_STRING), /* Protocol */ |
90 gaim_value_new(GAIM_TYPE_STRING), /* Command */ | 90 purple_value_new(PURPLE_TYPE_STRING), /* Command */ |
91 gaim_value_new(GAIM_TYPE_BOXED, "GHashTable *")); /* Parameters */ | 91 purple_value_new(PURPLE_TYPE_BOXED, "GHashTable *")); /* Parameters */ |
92 | 92 |
93 gaim_signal_register(core, "quitting", gaim_marshal_VOID, NULL, 0); | 93 purple_signal_register(core, "quitting", purple_marshal_VOID, NULL, 0); |
94 | 94 |
95 /* The prefs subsystem needs to be initialized before static protocols | 95 /* The prefs subsystem needs to be initialized before static protocols |
96 * for protocol prefs to work. */ | 96 * for protocol prefs to work. */ |
97 gaim_prefs_init(); | 97 purple_prefs_init(); |
98 | 98 |
99 gaim_debug_init(); | 99 purple_debug_init(); |
100 | 100 |
101 if (ops != NULL) | 101 if (ops != NULL) |
102 { | 102 { |
103 if (ops->ui_prefs_init != NULL) | 103 if (ops->ui_prefs_init != NULL) |
104 ops->ui_prefs_init(); | 104 ops->ui_prefs_init(); |
106 if (ops->debug_ui_init != NULL) | 106 if (ops->debug_ui_init != NULL) |
107 ops->debug_ui_init(); | 107 ops->debug_ui_init(); |
108 } | 108 } |
109 | 109 |
110 #ifdef HAVE_DBUS | 110 #ifdef HAVE_DBUS |
111 gaim_dbus_init(); | 111 purple_dbus_init(); |
112 #endif | 112 #endif |
113 | 113 |
114 /* Initialize all static protocols. */ | 114 /* Initialize all static protocols. */ |
115 static_proto_init(); | 115 static_proto_init(); |
116 | 116 |
117 /* Since plugins get probed so early we should probably initialize their | 117 /* Since plugins get probed so early we should probably initialize their |
118 * subsystem right away too. | 118 * subsystem right away too. |
119 */ | 119 */ |
120 gaim_plugins_init(); | 120 purple_plugins_init(); |
121 gaim_plugins_probe(G_MODULE_SUFFIX); | 121 purple_plugins_probe(G_MODULE_SUFFIX); |
122 | 122 |
123 /* Accounts use status and buddy icons, so initialize these before accounts */ | 123 /* Accounts use status and buddy icons, so initialize these before accounts */ |
124 gaim_status_init(); | 124 purple_status_init(); |
125 gaim_buddy_icons_init(); | 125 purple_buddy_icons_init(); |
126 | 126 |
127 gaim_accounts_init(); | 127 purple_accounts_init(); |
128 gaim_savedstatuses_init(); | 128 purple_savedstatuses_init(); |
129 gaim_ciphers_init(); | 129 purple_ciphers_init(); |
130 gaim_notify_init(); | 130 purple_notify_init(); |
131 gaim_connections_init(); | 131 purple_connections_init(); |
132 gaim_conversations_init(); | 132 purple_conversations_init(); |
133 gaim_blist_init(); | 133 purple_blist_init(); |
134 gaim_log_init(); | 134 purple_log_init(); |
135 gaim_network_init(); | 135 purple_network_init(); |
136 gaim_privacy_init(); | 136 purple_privacy_init(); |
137 gaim_pounces_init(); | 137 purple_pounces_init(); |
138 gaim_proxy_init(); | 138 purple_proxy_init(); |
139 gaim_dnsquery_init(); | 139 purple_dnsquery_init(); |
140 gaim_sound_init(); | 140 purple_sound_init(); |
141 gaim_ssl_init(); | 141 purple_ssl_init(); |
142 gaim_stun_init(); | 142 purple_stun_init(); |
143 gaim_xfers_init(); | 143 purple_xfers_init(); |
144 gaim_idle_init(); | 144 purple_idle_init(); |
145 | 145 |
146 /* | 146 /* |
147 * Call this early on to try to auto-detect our IP address and | 147 * Call this early on to try to auto-detect our IP address and |
148 * hopefully save some time later. | 148 * hopefully save some time later. |
149 */ | 149 */ |
150 gaim_network_get_my_ip(-1); | 150 purple_network_get_my_ip(-1); |
151 | 151 |
152 if (ops != NULL && ops->ui_init != NULL) | 152 if (ops != NULL && ops->ui_init != NULL) |
153 ops->ui_init(); | 153 ops->ui_init(); |
154 | 154 |
155 return TRUE; | 155 return TRUE; |
156 } | 156 } |
157 | 157 |
158 void | 158 void |
159 gaim_core_quit(void) | 159 purple_core_quit(void) |
160 { | 160 { |
161 GaimCoreUiOps *ops; | 161 PurpleCoreUiOps *ops; |
162 GaimCore *core = gaim_get_core(); | 162 PurpleCore *core = purple_get_core(); |
163 | 163 |
164 g_return_if_fail(core != NULL); | 164 g_return_if_fail(core != NULL); |
165 | 165 |
166 /* The self destruct sequence has been initiated */ | 166 /* The self destruct sequence has been initiated */ |
167 gaim_signal_emit(gaim_get_core(), "quitting"); | 167 purple_signal_emit(purple_get_core(), "quitting"); |
168 | 168 |
169 /* Transmission ends */ | 169 /* Transmission ends */ |
170 gaim_connections_disconnect_all(); | 170 purple_connections_disconnect_all(); |
171 | 171 |
172 /* Save .xml files, remove signals, etc. */ | 172 /* Save .xml files, remove signals, etc. */ |
173 gaim_idle_uninit(); | 173 purple_idle_uninit(); |
174 gaim_ssl_uninit(); | 174 purple_ssl_uninit(); |
175 gaim_pounces_uninit(); | 175 purple_pounces_uninit(); |
176 gaim_blist_uninit(); | 176 purple_blist_uninit(); |
177 gaim_ciphers_uninit(); | 177 purple_ciphers_uninit(); |
178 gaim_notify_uninit(); | 178 purple_notify_uninit(); |
179 gaim_conversations_uninit(); | 179 purple_conversations_uninit(); |
180 gaim_connections_uninit(); | 180 purple_connections_uninit(); |
181 gaim_buddy_icons_uninit(); | 181 purple_buddy_icons_uninit(); |
182 gaim_accounts_uninit(); | 182 purple_accounts_uninit(); |
183 gaim_savedstatuses_uninit(); | 183 purple_savedstatuses_uninit(); |
184 gaim_status_uninit(); | 184 purple_status_uninit(); |
185 gaim_prefs_uninit(); | 185 purple_prefs_uninit(); |
186 gaim_xfers_uninit(); | 186 purple_xfers_uninit(); |
187 gaim_proxy_uninit(); | 187 purple_proxy_uninit(); |
188 gaim_dnsquery_uninit(); | 188 purple_dnsquery_uninit(); |
189 | 189 |
190 gaim_debug_info("main", "Unloading all plugins\n"); | 190 purple_debug_info("main", "Unloading all plugins\n"); |
191 gaim_plugins_destroy_all(); | 191 purple_plugins_destroy_all(); |
192 | 192 |
193 ops = gaim_core_get_ui_ops(); | 193 ops = purple_core_get_ui_ops(); |
194 if (ops != NULL && ops->quit != NULL) | 194 if (ops != NULL && ops->quit != NULL) |
195 ops->quit(); | 195 ops->quit(); |
196 | 196 |
197 /* | 197 /* |
198 * gaim_sound_uninit() should be called as close to | 198 * purple_sound_uninit() should be called as close to |
199 * shutdown as possible. This is because the call | 199 * shutdown as possible. This is because the call |
200 * to ao_shutdown() can sometimes leave our | 200 * to ao_shutdown() can sometimes leave our |
201 * environment variables in an unusable state, which | 201 * environment variables in an unusable state, which |
202 * can cause a crash when getenv is called (by gettext | 202 * can cause a crash when getenv is called (by gettext |
203 * for example). See the complete bug report at | 203 * for example). See the complete bug report at |
204 * http://trac.xiph.org/cgi-bin/trac.cgi/ticket/701 | 204 * http://trac.xiph.org/cgi-bin/trac.cgi/ticket/701 |
205 * | 205 * |
206 * TODO: Eventually move this call higher up with the others. | 206 * TODO: Eventually move this call higher up with the others. |
207 */ | 207 */ |
208 gaim_sound_uninit(); | 208 purple_sound_uninit(); |
209 | 209 |
210 gaim_plugins_uninit(); | 210 purple_plugins_uninit(); |
211 gaim_signals_uninit(); | 211 purple_signals_uninit(); |
212 | 212 |
213 #ifdef HAVE_DBUS | 213 #ifdef HAVE_DBUS |
214 gaim_dbus_uninit(); | 214 purple_dbus_uninit(); |
215 #endif | 215 #endif |
216 | 216 |
217 g_free(core->ui); | 217 g_free(core->ui); |
218 g_free(core); | 218 g_free(core); |
219 | 219 |
220 #ifdef _WIN32 | 220 #ifdef _WIN32 |
221 wgaim_cleanup(); | 221 wpurple_cleanup(); |
222 #endif | 222 #endif |
223 | 223 |
224 _core = NULL; | 224 _core = NULL; |
225 } | 225 } |
226 | 226 |
227 gboolean | 227 gboolean |
228 gaim_core_quit_cb(gpointer unused) | 228 purple_core_quit_cb(gpointer unused) |
229 { | 229 { |
230 gaim_core_quit(); | 230 purple_core_quit(); |
231 | 231 |
232 return FALSE; | 232 return FALSE; |
233 } | 233 } |
234 | 234 |
235 const char * | 235 const char * |
236 gaim_core_get_version(void) | 236 purple_core_get_version(void) |
237 { | 237 { |
238 return VERSION; | 238 return VERSION; |
239 } | 239 } |
240 | 240 |
241 const char * | 241 const char * |
242 gaim_core_get_ui(void) | 242 purple_core_get_ui(void) |
243 { | 243 { |
244 GaimCore *core = gaim_get_core(); | 244 PurpleCore *core = purple_get_core(); |
245 | 245 |
246 g_return_val_if_fail(core != NULL, NULL); | 246 g_return_val_if_fail(core != NULL, NULL); |
247 | 247 |
248 return core->ui; | 248 return core->ui; |
249 } | 249 } |
250 | 250 |
251 GaimCore * | 251 PurpleCore * |
252 gaim_get_core(void) | 252 purple_get_core(void) |
253 { | 253 { |
254 return _core; | 254 return _core; |
255 } | 255 } |
256 | 256 |
257 void | 257 void |
258 gaim_core_set_ui_ops(GaimCoreUiOps *ops) | 258 purple_core_set_ui_ops(PurpleCoreUiOps *ops) |
259 { | 259 { |
260 _ops = ops; | 260 _ops = ops; |
261 } | 261 } |
262 | 262 |
263 GaimCoreUiOps * | 263 PurpleCoreUiOps * |
264 gaim_core_get_ui_ops(void) | 264 purple_core_get_ui_ops(void) |
265 { | 265 { |
266 return _ops; | 266 return _ops; |
267 } | 267 } |