Mercurial > pidgin
comparison src/server.c @ 5205:fefad67de2c7
[gaim-migrate @ 5573]
I had a damn good commit message, but it was eaten. Let's try it again.
Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short.
There are lots'a cool thingies here.
Okay now, this isn't as cool as the previous message, but:
1) There's now a single entry function for all plugin types. It returns a
detailed information structure on the plugin. This removes a lot of the
ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so
if you use it, well, you shouldn't have used it anyway, but now you
can't! bwahahaha. Use AIM/ICQ.
2) There are now 3 types of plugins: Standard, Loader, and Protocol
plugins.
Standard plugins are, well, standard, compiled plugins.
Loader plugins load other plugins. For example, the perl support is now
a loader plugin. It loads perl scripts. In the future, we'll have
Ruby and Python loader plugins.
Protocol plugins are, well, protocol plugins... yeah...
3) Plugins have unique IDs, so they can be referred to or automatically
updated from a plugin database in the future. Neat, huh?
4) Plugins will have dependency support in the future, and can be hidden,
so if you have, say, a logging core plugin, it won't have to show up,
but then you load the GTK+ logging plugin and it'll auto-load the core
plugin. Core/UI split plugins!
5) There will eventually be custom plugin signals and RPC of some sort, for
the core/ui split plugins.
So, okay, back up .gaimrc.
I'd like to thank my parents for their support, javabsp for helping convert
a bunch of protocol plugins, and Etan for helping convert a bunch of
standard plugins.
Have fun. If you have any problems, please let me know, but you probably
won't have anything major happen. You will have to convert your plugins,
though, and I'm not guaranteeing that all perl scripts will still work.
I'll end up changing the perl script API eventually, so I know they won't
down the road. Don't worry, though. It'll be mass cool.
faceprint wants me to just commit the damn code already. So, here we go!!!
..
..
I need a massage. From a young, cute girl. Are there any young, cute girls
in the audience? IM me plz k thx.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 25 Apr 2003 06:47:33 +0000 |
parents | 13ffa9ae4282 |
children | 0241d6b6702d |
comparison
equal
deleted
inserted
replaced
5204:44de70702205 | 5205:fefad67de2c7 |
---|---|
38 #include "sound.h" | 38 #include "sound.h" |
39 #include "pounce.h" | 39 #include "pounce.h" |
40 | 40 |
41 void serv_login(struct gaim_account *account) | 41 void serv_login(struct gaim_account *account) |
42 { | 42 { |
43 struct prpl *p = find_prpl(account->protocol); | 43 GaimPlugin *p = gaim_find_prpl(account->protocol); |
44 GaimPluginProtocolInfo *prpl_info = NULL; | |
44 | 45 |
45 if (account->gc != NULL || p == NULL) | 46 if (account->gc != NULL || p == NULL) |
46 return; | 47 return; |
47 | 48 |
48 if(!ref_protocol(p)) | 49 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(p); |
49 return; | 50 |
50 | 51 if (prpl_info->login) { |
51 if (p->login) { | 52 if (!strlen(account->password) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && |
52 if (!strlen(account->password) && !(p->options & OPT_PROTO_NO_PASSWORD) && | 53 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) { |
53 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL)) { | |
54 do_error_dialog(_("Please enter your password"), NULL, GAIM_ERROR); | 54 do_error_dialog(_("Please enter your password"), NULL, GAIM_ERROR); |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", account->username, p->name); | 58 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", |
59 account->username, p->info->name); | |
59 account->connecting = TRUE; | 60 account->connecting = TRUE; |
60 connecting_count++; | 61 connecting_count++; |
61 debug_printf("connecting_count: %d\n", connecting_count); | 62 debug_printf("connecting_count: %d\n", connecting_count); |
62 plugin_event(event_connecting, account); | 63 gaim_event_broadcast(event_connecting, account); |
63 p->login(account); | 64 prpl_info->login(account); |
64 } | 65 } |
65 } | 66 } |
66 | 67 |
67 static gboolean send_keepalive(gpointer d) | 68 static gboolean send_keepalive(gpointer d) |
68 { | 69 { |
69 struct gaim_connection *gc = d; | 70 struct gaim_connection *gc = d; |
70 if (gc->prpl && gc->prpl->keepalive) | 71 GaimPluginProtocolInfo *prpl_info = NULL; |
71 gc->prpl->keepalive(gc); | 72 |
73 if (gc != NULL && gc->prpl != NULL) | |
74 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
75 | |
76 if (prpl_info && prpl_info->keepalive) | |
77 prpl_info->keepalive(gc); | |
78 | |
72 return TRUE; | 79 return TRUE; |
73 } | 80 } |
74 | 81 |
75 static void update_keepalive(struct gaim_connection *gc, gboolean on) | 82 static void update_keepalive(struct gaim_connection *gc, gboolean on) |
76 { | 83 { |
84 } | 91 } |
85 } | 92 } |
86 | 93 |
87 void serv_close(struct gaim_connection *gc) | 94 void serv_close(struct gaim_connection *gc) |
88 { | 95 { |
89 struct prpl *prpl; | 96 GaimPlugin *prpl; |
97 GaimPluginProtocolInfo *prpl_info = NULL; | |
98 | |
90 while (gc->buddy_chats) { | 99 while (gc->buddy_chats) { |
91 struct gaim_conversation *b = gc->buddy_chats->data; | 100 struct gaim_conversation *b = gc->buddy_chats->data; |
92 | 101 |
93 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); | 102 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); |
94 | 103 |
101 g_source_remove(gc->idle_timer); | 110 g_source_remove(gc->idle_timer); |
102 gc->idle_timer = 0; | 111 gc->idle_timer = 0; |
103 | 112 |
104 update_keepalive(gc, FALSE); | 113 update_keepalive(gc, FALSE); |
105 | 114 |
106 if (gc->prpl && gc->prpl->close) | 115 if (gc->prpl != NULL) { |
107 gc->prpl->close(gc); | 116 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
117 | |
118 if (prpl_info->close) | |
119 prpl_info->close(gc); | |
120 } | |
108 | 121 |
109 prpl = gc->prpl; | 122 prpl = gc->prpl; |
110 account_offline(gc); | 123 account_offline(gc); |
111 destroy_gaim_conn(gc); | 124 destroy_gaim_conn(gc); |
112 | |
113 unref_protocol(prpl); | |
114 } | 125 } |
115 | 126 |
116 void serv_touch_idle(struct gaim_connection *gc) | 127 void serv_touch_idle(struct gaim_connection *gc) |
117 { | 128 { |
118 /* Are we idle? If so, not anymore */ | 129 /* Are we idle? If so, not anymore */ |
125 check_idle(gc); | 136 check_idle(gc); |
126 } | 137 } |
127 | 138 |
128 void serv_finish_login(struct gaim_connection *gc) | 139 void serv_finish_login(struct gaim_connection *gc) |
129 { | 140 { |
141 GaimPluginProtocolInfo *prpl_info = NULL; | |
142 | |
143 if (gc != NULL && gc->prpl != NULL) | |
144 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
145 | |
130 if (strlen(gc->account->user_info)) { | 146 if (strlen(gc->account->user_info)) { |
131 /* g_malloc(strlen(gc->user->user_info) * 4); | 147 /* g_malloc(strlen(gc->user->user_info) * 4); |
132 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); */ | 148 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); */ |
133 serv_set_info(gc, gc->account->user_info); | 149 serv_set_info(gc, gc->account->user_info); |
134 /* g_free(buf); */ | 150 /* g_free(buf); */ |
138 g_source_remove(gc->idle_timer); | 154 g_source_remove(gc->idle_timer); |
139 | 155 |
140 gc->idle_timer = g_timeout_add(20000, check_idle, gc); | 156 gc->idle_timer = g_timeout_add(20000, check_idle, gc); |
141 serv_touch_idle(gc); | 157 serv_touch_idle(gc); |
142 | 158 |
143 if (gc->prpl->options & OPT_PROTO_CORRECT_TIME) | 159 if (prpl_info->options & OPT_PROTO_CORRECT_TIME) |
144 serv_add_buddy(gc, gc->username); | 160 serv_add_buddy(gc, gc->username); |
145 | 161 |
146 update_keepalive(gc, TRUE); | 162 update_keepalive(gc, TRUE); |
147 } | 163 } |
148 | 164 |
149 /* This should return the elapsed time in seconds in which Gaim will not send | 165 /* This should return the elapsed time in seconds in which Gaim will not send |
150 * typing notifications. | 166 * typing notifications. |
151 * if it returns zero, it will not send any more typing notifications | 167 * if it returns zero, it will not send any more typing notifications |
152 * typing is a flag - TRUE for typing, FALSE for stopped typing */ | 168 * typing is a flag - TRUE for typing, FALSE for stopped typing */ |
153 int serv_send_typing(struct gaim_connection *g, char *name, int typing) { | 169 int serv_send_typing(struct gaim_connection *g, char *name, int typing) { |
154 if (g && g->prpl && g->prpl->send_typing) | 170 GaimPluginProtocolInfo *prpl_info = NULL; |
155 return g->prpl->send_typing(g, name, typing); | 171 |
156 else return 0; | 172 if (g != NULL && g->prpl != NULL) |
173 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
174 | |
175 if (g && prpl_info && prpl_info->send_typing) | |
176 return prpl_info->send_typing(g, name, typing); | |
177 | |
178 return 0; | |
157 } | 179 } |
158 | 180 |
159 struct queued_away_response { | 181 struct queued_away_response { |
160 char name[80]; | 182 char name[80]; |
161 time_t sent_away; | 183 time_t sent_away; |
166 int serv_send_im(struct gaim_connection *gc, char *name, char *message, | 188 int serv_send_im(struct gaim_connection *gc, char *name, char *message, |
167 int len, int flags) | 189 int len, int flags) |
168 { | 190 { |
169 struct gaim_conversation *c; | 191 struct gaim_conversation *c; |
170 int val = -EINVAL; | 192 int val = -EINVAL; |
193 GaimPluginProtocolInfo *prpl_info = NULL; | |
194 | |
195 if (gc != NULL && gc->prpl != NULL) | |
196 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
171 | 197 |
172 c = gaim_find_conversation(name); | 198 c = gaim_find_conversation(name); |
173 | 199 |
174 if (gc->prpl && gc->prpl->send_im) | 200 if (prpl_info && prpl_info->send_im) |
175 val = gc->prpl->send_im(gc, name, message, len, flags); | 201 val = prpl_info->send_im(gc, name, message, len, flags); |
176 | 202 |
177 if (!(flags & IM_FLAG_AWAY)) | 203 if (!(flags & IM_FLAG_AWAY)) |
178 serv_touch_idle(gc); | 204 serv_touch_idle(gc); |
179 | 205 |
180 if (gc->away && away_options & OPT_AWAY_DELAY_IN_USE && | 206 if (gc->away && away_options & OPT_AWAY_DELAY_IN_USE && |
198 return val; | 224 return val; |
199 } | 225 } |
200 | 226 |
201 void serv_get_info(struct gaim_connection *g, char *name) | 227 void serv_get_info(struct gaim_connection *g, char *name) |
202 { | 228 { |
203 if (g && g->prpl && g->prpl->get_info) | 229 GaimPluginProtocolInfo *prpl_info = NULL; |
204 g->prpl->get_info(g, name); | 230 |
231 if (g != NULL && g->prpl != NULL) | |
232 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
233 | |
234 if (g && prpl_info && prpl_info->get_info) | |
235 prpl_info->get_info(g, name); | |
205 } | 236 } |
206 | 237 |
207 void serv_get_away(struct gaim_connection *g, const char *name) | 238 void serv_get_away(struct gaim_connection *g, const char *name) |
208 { | 239 { |
209 if (g && g->prpl && g->prpl->get_away) | 240 GaimPluginProtocolInfo *prpl_info = NULL; |
210 g->prpl->get_away(g, name); | 241 |
242 if (g != NULL && g->prpl != NULL) | |
243 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
244 | |
245 if (g && prpl_info && prpl_info->get_away) | |
246 prpl_info->get_away(g, name); | |
211 } | 247 } |
212 | 248 |
213 void serv_get_dir(struct gaim_connection *g, char *name) | 249 void serv_get_dir(struct gaim_connection *g, char *name) |
214 { | 250 { |
215 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->get_dir) | 251 GaimPluginProtocolInfo *prpl_info = NULL; |
216 g->prpl->get_dir(g, name); | 252 |
253 if (g != NULL && g->prpl != NULL) | |
254 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
255 | |
256 if (prpl_info && g_slist_find(connections, g) && prpl_info->get_dir) | |
257 prpl_info->get_dir(g, name); | |
217 } | 258 } |
218 | 259 |
219 void serv_set_dir(struct gaim_connection *g, const char *first, | 260 void serv_set_dir(struct gaim_connection *g, const char *first, |
220 const char *middle, const char *last, const char *maiden, | 261 const char *middle, const char *last, const char *maiden, |
221 const char *city, const char *state, const char *country, | 262 const char *city, const char *state, const char *country, |
222 int web) | 263 int web) |
223 { | 264 { |
224 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_dir) | 265 GaimPluginProtocolInfo *prpl_info = NULL; |
225 g->prpl->set_dir(g, first, middle, last, maiden, city, state, | 266 |
267 if (g != NULL && g->prpl != NULL) | |
268 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
269 | |
270 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_dir) | |
271 prpl_info->set_dir(g, first, middle, last, maiden, city, state, | |
226 country, web); | 272 country, web); |
227 } | 273 } |
228 | 274 |
229 void serv_dir_search(struct gaim_connection *g, const char *first, | 275 void serv_dir_search(struct gaim_connection *g, const char *first, |
230 const char *middle, const char *last, const char *maiden, | 276 const char *middle, const char *last, const char *maiden, |
231 const char *city, const char *state, const char *country, | 277 const char *city, const char *state, const char *country, |
232 const char *email) | 278 const char *email) |
233 { | 279 { |
234 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->dir_search) | 280 GaimPluginProtocolInfo *prpl_info = NULL; |
235 g->prpl->dir_search(g, first, middle, last, maiden, city, state, | 281 |
282 if (g != NULL && g->prpl != NULL) | |
283 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
284 | |
285 if (prpl_info && g_slist_find(connections, g) && prpl_info->dir_search) | |
286 prpl_info->dir_search(g, first, middle, last, maiden, city, state, | |
236 country, email); | 287 country, email); |
237 } | 288 } |
238 | 289 |
239 | 290 |
240 void serv_set_away(struct gaim_connection *gc, char *state, char *message) | 291 void serv_set_away(struct gaim_connection *gc, char *state, char *message) |
241 { | 292 { |
242 if (gc && gc->prpl && gc->prpl->set_away) { | 293 GaimPluginProtocolInfo *prpl_info = NULL; |
294 | |
295 if (gc != NULL && gc->prpl != NULL) | |
296 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
297 | |
298 if (prpl_info && prpl_info->set_away) { | |
243 char *buf = NULL; | 299 char *buf = NULL; |
244 | 300 |
245 if (gc->away_state) { | 301 if (gc->away_state) { |
246 g_free(gc->away_state); | 302 g_free(gc->away_state); |
247 gc->away_state = NULL; | 303 gc->away_state = NULL; |
253 strncpy(buf, message, strlen(message) + 1); | 309 strncpy(buf, message, strlen(message) + 1); |
254 else | 310 else |
255 strncpy_nohtml(buf, message, strlen(message) + 1); | 311 strncpy_nohtml(buf, message, strlen(message) + 1); |
256 } | 312 } |
257 | 313 |
258 gc->prpl->set_away(gc, state, buf); | 314 prpl_info->set_away(gc, state, buf); |
259 | 315 |
260 if (gc->away && state) { | 316 if (gc->away && state) { |
261 gc->away_state = g_strdup(state); | 317 gc->away_state = g_strdup(state); |
262 } | 318 } |
263 | 319 |
264 plugin_event(event_away, gc, state, buf); | 320 gaim_event_broadcast(event_away, gc, state, buf); |
265 | 321 |
266 if (buf) | 322 if (buf) |
267 g_free(buf); | 323 g_free(buf); |
268 } | 324 } |
269 | 325 |
270 system_log(log_away, gc, NULL, OPT_LOG_BUDDY_AWAY | OPT_LOG_MY_SIGNON); | 326 system_log(log_away, gc, NULL, OPT_LOG_BUDDY_AWAY | OPT_LOG_MY_SIGNON); |
271 } | 327 } |
272 | 328 |
273 void serv_set_away_all(char *message) | 329 void serv_set_away_all(char *message) |
274 { | 330 { |
275 GSList *c = connections; | 331 GSList *c; |
276 struct gaim_connection *g; | 332 struct gaim_connection *g; |
277 | 333 |
278 while (c) { | 334 for (c = connections; c != NULL; c = c->next) { |
279 g = (struct gaim_connection *)c->data; | 335 g = (struct gaim_connection *)c->data; |
336 | |
280 serv_set_away(g, GAIM_AWAY_CUSTOM, message); | 337 serv_set_away(g, GAIM_AWAY_CUSTOM, message); |
281 c = c->next; | |
282 } | 338 } |
283 } | 339 } |
284 | 340 |
285 void serv_set_info(struct gaim_connection *g, char *info) | 341 void serv_set_info(struct gaim_connection *g, char *info) |
286 { | 342 { |
287 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_info) { | 343 GaimPluginProtocolInfo *prpl_info = NULL; |
288 if (plugin_event(event_set_info, g, info)) | 344 |
345 if (g != NULL && g->prpl != NULL) | |
346 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
347 | |
348 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_info) { | |
349 if (gaim_event_broadcast(event_set_info, g, info)) | |
289 return; | 350 return; |
290 g->prpl->set_info(g, info); | 351 |
352 prpl_info->set_info(g, info); | |
291 } | 353 } |
292 } | 354 } |
293 | 355 |
294 void serv_change_passwd(struct gaim_connection *g, const char *orig, const char *new) | 356 void serv_change_passwd(struct gaim_connection *g, const char *orig, const char *new) |
295 { | 357 { |
296 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->change_passwd) | 358 GaimPluginProtocolInfo *prpl_info = NULL; |
297 g->prpl->change_passwd(g, orig, new); | 359 |
360 if (g != NULL && g->prpl != NULL) | |
361 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
362 | |
363 if (prpl_info && g_slist_find(connections, g) && prpl_info->change_passwd) | |
364 prpl_info->change_passwd(g, orig, new); | |
298 } | 365 } |
299 | 366 |
300 void serv_add_buddy(struct gaim_connection *g, const char *name) | 367 void serv_add_buddy(struct gaim_connection *g, const char *name) |
301 { | 368 { |
302 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_buddy) | 369 GaimPluginProtocolInfo *prpl_info = NULL; |
303 g->prpl->add_buddy(g, name); | 370 |
371 if (g != NULL && g->prpl != NULL) | |
372 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
373 | |
374 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_buddy) | |
375 prpl_info->add_buddy(g, name); | |
304 } | 376 } |
305 | 377 |
306 void serv_add_buddies(struct gaim_connection *g, GList *buddies) | 378 void serv_add_buddies(struct gaim_connection *g, GList *buddies) |
307 { | 379 { |
308 if (g && g_slist_find(connections, g) && g->prpl) { | 380 GaimPluginProtocolInfo *prpl_info = NULL; |
309 if (g->prpl->add_buddies) | 381 |
310 g->prpl->add_buddies(g, buddies); | 382 if (g != NULL && g->prpl != NULL) |
311 else if (g->prpl->add_buddy) | 383 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
384 | |
385 if (prpl_info && g_slist_find(connections, g)) { | |
386 if (prpl_info->add_buddies) | |
387 prpl_info->add_buddies(g, buddies); | |
388 else if (prpl_info->add_buddy) { | |
312 while (buddies) { | 389 while (buddies) { |
313 g->prpl->add_buddy(g, buddies->data); | 390 prpl_info->add_buddy(g, buddies->data); |
314 buddies = buddies->next; | 391 buddies = buddies->next; |
315 } | 392 } |
393 } | |
316 } | 394 } |
317 } | 395 } |
318 | 396 |
319 | 397 |
320 void serv_remove_buddy(struct gaim_connection *g, char *name, char *group) | 398 void serv_remove_buddy(struct gaim_connection *g, char *name, char *group) |
321 { | 399 { |
322 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->remove_buddy) | 400 GaimPluginProtocolInfo *prpl_info = NULL; |
323 g->prpl->remove_buddy(g, name, group); | 401 |
402 if (g != NULL && g->prpl != NULL) | |
403 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
404 | |
405 if (prpl_info && g_slist_find(connections, g) && prpl_info->remove_buddy) | |
406 prpl_info->remove_buddy(g, name, group); | |
324 } | 407 } |
325 | 408 |
326 void serv_remove_buddies(struct gaim_connection *gc, GList *g, char *group) | 409 void serv_remove_buddies(struct gaim_connection *gc, GList *g, char *group) |
327 { | 410 { |
411 GaimPluginProtocolInfo *prpl_info = NULL; | |
412 | |
328 if (!g_slist_find(connections, gc)) | 413 if (!g_slist_find(connections, gc)) |
329 return; | 414 return; |
415 | |
330 if (!gc->prpl) | 416 if (!gc->prpl) |
331 return; /* how the hell did that happen? */ | 417 return; /* how the hell did that happen? */ |
332 if (gc->prpl->remove_buddies) | 418 |
333 gc->prpl->remove_buddies(gc, g, group); | 419 if (gc != NULL && gc->prpl != NULL) |
420 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
421 | |
422 if (prpl_info->remove_buddies) | |
423 prpl_info->remove_buddies(gc, g, group); | |
334 else { | 424 else { |
335 while (g) { | 425 while (g) { |
336 serv_remove_buddy(gc, g->data, group); | 426 serv_remove_buddy(gc, g->data, group); |
337 g = g->next; | 427 g = g->next; |
338 } | 428 } |
342 /* | 432 /* |
343 * Set buddy's alias on server roster/list | 433 * Set buddy's alias on server roster/list |
344 */ | 434 */ |
345 void serv_alias_buddy(struct buddy *b) | 435 void serv_alias_buddy(struct buddy *b) |
346 { | 436 { |
347 if(b && b->account->gc && b->account->gc->prpl && b->account->gc->prpl->alias_buddy) { | 437 GaimPluginProtocolInfo *prpl_info = NULL; |
348 b->account->gc->prpl->alias_buddy(b->account->gc, b->name, b->alias); | 438 |
439 if (b != NULL && b->account->gc->prpl != NULL) | |
440 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(b->account->gc->prpl); | |
441 | |
442 if (b && prpl_info && prpl_info->alias_buddy) { | |
443 prpl_info->alias_buddy(b->account->gc, b->name, b->alias); | |
349 } | 444 } |
350 } | 445 } |
351 | 446 |
352 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) { | 447 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) { |
353 struct buddy *b = gaim_find_buddy(gc->account, who); | 448 struct buddy *b = gaim_find_buddy(gc->account, who); |
371 * Note: For now we'll not deal with changing gc's at the same time, but | 466 * Note: For now we'll not deal with changing gc's at the same time, but |
372 * it should be possible. Probably needs to be done, someday. | 467 * it should be possible. Probably needs to be done, someday. |
373 */ | 468 */ |
374 void serv_move_buddy(struct buddy *b, struct group *og, struct group *ng) | 469 void serv_move_buddy(struct buddy *b, struct group *og, struct group *ng) |
375 { | 470 { |
376 if(b && b->account->gc && og && ng) { | 471 GaimPluginProtocolInfo *prpl_info = NULL; |
377 if(b->account->gc->prpl && b->account->gc->prpl->group_buddy) { | 472 |
378 b->account->gc->prpl->group_buddy(b->account->gc, b->name, og->name, ng->name); | 473 if (b->account->gc != NULL && b->account->gc->prpl != NULL) |
474 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(b->account->gc->prpl); | |
475 | |
476 if (b && b->account->gc && og && ng) { | |
477 if (prpl_info && prpl_info->group_buddy) { | |
478 prpl_info->group_buddy(b->account->gc, b->name, og->name, ng->name); | |
379 } | 479 } |
380 } | 480 } |
381 } | 481 } |
382 | 482 |
383 /* | 483 /* |
384 * Rename a group on server roster/list. | 484 * Rename a group on server roster/list. |
385 */ | 485 */ |
386 void serv_rename_group(struct gaim_connection *g, struct group *old_group, const char *new_name) | 486 void serv_rename_group(struct gaim_connection *g, struct group *old_group, |
387 { | 487 const char *new_name) |
388 if (g && g->prpl && old_group && new_name) { | 488 { |
489 GaimPluginProtocolInfo *prpl_info = NULL; | |
490 | |
491 if (g != NULL && g->prpl != NULL) | |
492 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
493 | |
494 if (prpl_info && old_group && new_name) { | |
389 GList *tobemoved = NULL; | 495 GList *tobemoved = NULL; |
390 GaimBlistNode *b = ((GaimBlistNode*)old_group)->child; | 496 GaimBlistNode *b = ((GaimBlistNode*)old_group)->child; |
391 | 497 |
392 while (b) { | 498 while (b) { |
393 struct buddy *bd = (struct buddy *)b; | 499 struct buddy *bd = (struct buddy *)b; |
394 if (bd->account == g->account) | 500 if (bd->account == g->account) |
395 tobemoved = g_list_append(tobemoved, bd->name); | 501 tobemoved = g_list_append(tobemoved, bd->name); |
396 b = b->next; | 502 b = b->next; |
397 } | 503 } |
398 | 504 |
399 if (g->prpl->rename_group) { | 505 if (prpl_info->rename_group) { |
400 /* prpl's might need to check if the group already | 506 /* prpl's might need to check if the group already |
401 * exists or not, and handle that differently */ | 507 * exists or not, and handle that differently */ |
402 g->prpl->rename_group(g, old_group->name, new_name, tobemoved); | 508 prpl_info->rename_group(g, old_group->name, new_name, tobemoved); |
403 } else { | 509 } else { |
404 serv_remove_buddies(g, tobemoved, old_group->name); | 510 serv_remove_buddies(g, tobemoved, old_group->name); |
405 serv_add_buddies(g, tobemoved); | 511 serv_add_buddies(g, tobemoved); |
406 } | 512 } |
407 | 513 |
409 } | 515 } |
410 } | 516 } |
411 | 517 |
412 void serv_add_permit(struct gaim_connection *g, const char *name) | 518 void serv_add_permit(struct gaim_connection *g, const char *name) |
413 { | 519 { |
414 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_permit) | 520 GaimPluginProtocolInfo *prpl_info = NULL; |
415 g->prpl->add_permit(g, name); | 521 |
522 if (g != NULL && g->prpl != NULL) | |
523 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
524 | |
525 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_permit) | |
526 prpl_info->add_permit(g, name); | |
416 } | 527 } |
417 | 528 |
418 void serv_add_deny(struct gaim_connection *g, const char *name) | 529 void serv_add_deny(struct gaim_connection *g, const char *name) |
419 { | 530 { |
420 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_deny) | 531 GaimPluginProtocolInfo *prpl_info = NULL; |
421 g->prpl->add_deny(g, name); | 532 |
533 if (g != NULL && g->prpl != NULL) | |
534 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
535 | |
536 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_deny) | |
537 prpl_info->add_deny(g, name); | |
422 } | 538 } |
423 | 539 |
424 void serv_rem_permit(struct gaim_connection *g, const char *name) | 540 void serv_rem_permit(struct gaim_connection *g, const char *name) |
425 { | 541 { |
426 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->rem_permit) | 542 GaimPluginProtocolInfo *prpl_info = NULL; |
427 g->prpl->rem_permit(g, name); | 543 |
544 if (g != NULL && g->prpl != NULL) | |
545 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
546 | |
547 if (prpl_info && g_slist_find(connections, g) && prpl_info->rem_permit) | |
548 prpl_info->rem_permit(g, name); | |
428 } | 549 } |
429 | 550 |
430 void serv_rem_deny(struct gaim_connection *g, const char *name) | 551 void serv_rem_deny(struct gaim_connection *g, const char *name) |
431 { | 552 { |
432 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->rem_deny) | 553 GaimPluginProtocolInfo *prpl_info = NULL; |
433 g->prpl->rem_deny(g, name); | 554 |
555 if (g != NULL && g->prpl != NULL) | |
556 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
557 | |
558 if (prpl_info && g_slist_find(connections, g) && prpl_info->rem_deny) | |
559 prpl_info->rem_deny(g, name); | |
434 } | 560 } |
435 | 561 |
436 void serv_set_permit_deny(struct gaim_connection *g) | 562 void serv_set_permit_deny(struct gaim_connection *g) |
437 { | 563 { |
438 /* this is called when either you import a buddy list, and make lots of changes that way, | 564 GaimPluginProtocolInfo *prpl_info = NULL; |
439 * or when the user toggles the permit/deny mode in the prefs. In either case you should | 565 |
440 * probably be resetting and resending the permit/deny info when you get this. */ | 566 if (g != NULL && g->prpl != NULL) |
441 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_permit_deny) | 567 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
442 g->prpl->set_permit_deny(g); | 568 |
569 /* | |
570 * this is called when either you import a buddy list, and make lots | |
571 * of changes that way, or when the user toggles the permit/deny mode | |
572 * in the prefs. In either case you should probably be resetting and | |
573 * resending the permit/deny info when you get this. | |
574 */ | |
575 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_permit_deny) | |
576 prpl_info->set_permit_deny(g); | |
443 } | 577 } |
444 | 578 |
445 | 579 |
446 void serv_set_idle(struct gaim_connection *g, int time) | 580 void serv_set_idle(struct gaim_connection *g, int time) |
447 { | 581 { |
448 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_idle) | 582 GaimPluginProtocolInfo *prpl_info = NULL; |
449 g->prpl->set_idle(g, time); | 583 |
584 if (g != NULL && g->prpl != NULL) | |
585 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
586 | |
587 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_idle) | |
588 prpl_info->set_idle(g, time); | |
450 } | 589 } |
451 | 590 |
452 void serv_warn(struct gaim_connection *g, char *name, int anon) | 591 void serv_warn(struct gaim_connection *g, char *name, int anon) |
453 { | 592 { |
454 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->warn) | 593 GaimPluginProtocolInfo *prpl_info = NULL; |
455 g->prpl->warn(g, name, anon); | 594 |
595 if (g != NULL && g->prpl != NULL) | |
596 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
597 | |
598 if (prpl_info && g_slist_find(connections, g) && prpl_info->warn) | |
599 prpl_info->warn(g, name, anon); | |
456 } | 600 } |
457 | 601 |
458 void serv_join_chat(struct gaim_connection *g, GList *data) | 602 void serv_join_chat(struct gaim_connection *g, GList *data) |
459 { | 603 { |
460 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->join_chat) | 604 GaimPluginProtocolInfo *prpl_info = NULL; |
461 g->prpl->join_chat(g, data); | 605 |
606 if (g != NULL && g->prpl != NULL) | |
607 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
608 | |
609 if (prpl_info && g_slist_find(connections, g) && prpl_info->join_chat) | |
610 prpl_info->join_chat(g, data); | |
462 } | 611 } |
463 | 612 |
464 void serv_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) | 613 void serv_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) |
465 { | 614 { |
615 GaimPluginProtocolInfo *prpl_info = NULL; | |
466 char *buffy = message && *message ? g_strdup(message) : NULL; | 616 char *buffy = message && *message ? g_strdup(message) : NULL; |
467 plugin_event(event_chat_send_invite, g, (void *)id, name, &buffy); | 617 |
468 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->chat_invite) | 618 if (g != NULL && g->prpl != NULL) |
469 g->prpl->chat_invite(g, id, buffy, name); | 619 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
620 | |
621 gaim_event_broadcast(event_chat_send_invite, g, (void *)id, name, &buffy); | |
622 | |
623 if (prpl_info && g_slist_find(connections, g) && prpl_info->chat_invite) | |
624 prpl_info->chat_invite(g, id, buffy, name); | |
625 | |
470 if (buffy) | 626 if (buffy) |
471 g_free(buffy); | 627 g_free(buffy); |
472 } | 628 } |
473 | 629 |
474 void serv_chat_leave(struct gaim_connection *g, int id) | 630 void serv_chat_leave(struct gaim_connection *g, int id) |
475 { | 631 { |
632 GaimPluginProtocolInfo *prpl_info = NULL; | |
633 | |
476 if (!g_slist_find(connections, g)) | 634 if (!g_slist_find(connections, g)) |
477 return; | 635 return; |
478 | 636 |
479 if (g->prpl && g->prpl->chat_leave) | 637 if (g->prpl != NULL) |
480 g->prpl->chat_leave(g, id); | 638 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
639 | |
640 if (prpl_info && prpl_info->chat_leave) | |
641 prpl_info->chat_leave(g, id); | |
481 } | 642 } |
482 | 643 |
483 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) | 644 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) |
484 { | 645 { |
485 if (g->prpl && g->prpl->chat_whisper) | 646 GaimPluginProtocolInfo *prpl_info = NULL; |
486 g->prpl->chat_whisper(g, id, who, message); | 647 |
648 if (g != NULL && g->prpl != NULL) | |
649 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
650 | |
651 if (prpl_info && prpl_info->chat_whisper) | |
652 prpl_info->chat_whisper(g, id, who, message); | |
487 } | 653 } |
488 | 654 |
489 int serv_chat_send(struct gaim_connection *g, int id, char *message) | 655 int serv_chat_send(struct gaim_connection *g, int id, char *message) |
490 { | 656 { |
491 int val = -EINVAL; | 657 int val = -EINVAL; |
492 if (g->prpl && g->prpl->chat_send) | 658 GaimPluginProtocolInfo *prpl_info = NULL; |
493 val = g->prpl->chat_send(g, id, message); | 659 |
660 if (g->prpl != NULL) | |
661 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
662 | |
663 if (prpl_info && prpl_info->chat_send) | |
664 val = prpl_info->chat_send(g, id, message); | |
665 | |
494 serv_touch_idle(g); | 666 serv_touch_idle(g); |
667 | |
495 return val; | 668 return val; |
496 } | 669 } |
497 | 670 |
498 int find_queue_row_by_name(char *name) | 671 int find_queue_row_by_name(char *name) |
499 { | 672 { |
598 */ | 771 */ |
599 if (len < 0) { | 772 if (len < 0) { |
600 buffy = g_malloc(MAX(strlen(msg) + 1, BUF_LONG)); | 773 buffy = g_malloc(MAX(strlen(msg) + 1, BUF_LONG)); |
601 strcpy(buffy, msg); | 774 strcpy(buffy, msg); |
602 angel = g_strdup(who); | 775 angel = g_strdup(who); |
603 plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, &flags); | 776 plugin_return = gaim_event_broadcast(event_im_recv, gc, &angel, &buffy, &flags); |
604 | 777 |
605 if (!buffy || !angel || plugin_return) { | 778 if (!buffy || !angel || plugin_return) { |
606 if (buffy) | 779 if (buffy) |
607 g_free(buffy); | 780 g_free(buffy); |
608 if (angel) | 781 if (angel) |
829 away | WFLAG_RECV, mtime); | 1002 away | WFLAG_RECV, mtime); |
830 gaim_window_flash(gaim_conversation_get_window(cnv)); | 1003 gaim_window_flash(gaim_conversation_get_window(cnv)); |
831 } | 1004 } |
832 } | 1005 } |
833 | 1006 |
834 plugin_event(event_im_displayed_rcvd, gc, name, message, flags, mtime); | 1007 gaim_event_broadcast(event_im_displayed_rcvd, gc, name, message, flags, mtime); |
835 g_free(name); | 1008 g_free(name); |
836 g_free(message); | 1009 g_free(message); |
837 } | 1010 } |
838 | 1011 |
839 | 1012 |
841 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, | 1014 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, |
842 int evil, time_t signon, time_t idle, int type) | 1015 int evil, time_t signon, time_t idle, int type) |
843 { | 1016 { |
844 struct buddy *b = gaim_find_buddy(gc->account, name); | 1017 struct buddy *b = gaim_find_buddy(gc->account, name); |
845 | 1018 |
846 if (signon && (gc->prpl->options & OPT_PROTO_CORRECT_TIME)) { | 1019 if (signon && (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->options & |
1020 OPT_PROTO_CORRECT_TIME)) { | |
1021 | |
847 char *tmp = g_strdup(normalize(name)); | 1022 char *tmp = g_strdup(normalize(name)); |
848 if (!gaim_utf8_strcasecmp(tmp, normalize(gc->username))) { | 1023 if (!gaim_utf8_strcasecmp(tmp, normalize(gc->username))) { |
849 gc->evil = evil; | 1024 gc->evil = evil; |
850 gc->login_time_official = signon; | 1025 gc->login_time_official = signon; |
851 /*update_idle_times();*/ | 1026 /*update_idle_times();*/ |
866 gaim_blist_save(); | 1041 gaim_blist_save(); |
867 } | 1042 } |
868 | 1043 |
869 if (!b->idle && idle) { | 1044 if (!b->idle && idle) { |
870 gaim_pounce_execute(gc->account, b->name, GAIM_POUNCE_IDLE); | 1045 gaim_pounce_execute(gc->account, b->name, GAIM_POUNCE_IDLE); |
871 plugin_event(event_buddy_idle, gc, b->name); | 1046 gaim_event_broadcast(event_buddy_idle, gc, b->name); |
872 system_log(log_idle, gc, b, OPT_LOG_BUDDY_IDLE); | 1047 system_log(log_idle, gc, b, OPT_LOG_BUDDY_IDLE); |
873 } | 1048 } |
874 if (b->idle && !idle) { | 1049 if (b->idle && !idle) { |
875 gaim_pounce_execute(gc->account, b->name, GAIM_POUNCE_IDLE_RETURN); | 1050 gaim_pounce_execute(gc->account, b->name, GAIM_POUNCE_IDLE_RETURN); |
876 plugin_event(event_buddy_unidle, gc, b->name); | 1051 gaim_event_broadcast(event_buddy_unidle, gc, b->name); |
877 system_log(log_unidle, gc, b, OPT_LOG_BUDDY_IDLE); | 1052 system_log(log_unidle, gc, b, OPT_LOG_BUDDY_IDLE); |
878 } | 1053 } |
879 | 1054 |
880 gaim_blist_update_buddy_idle(b, idle); | 1055 gaim_blist_update_buddy_idle(b, idle); |
881 gaim_blist_update_buddy_evil(b, evil); | 1056 gaim_blist_update_buddy_evil(b, evil); |
946 | 1121 |
947 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) | 1122 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) |
948 { | 1123 { |
949 char buf2[1024]; | 1124 char buf2[1024]; |
950 | 1125 |
951 plugin_event(event_warned, gc, name, lev); | 1126 gaim_event_broadcast(event_warned, gc, name, lev); |
952 | 1127 |
953 if (gc->evil >= lev) { | 1128 if (gc->evil >= lev) { |
954 gc->evil = lev; | 1129 gc->evil = lev; |
955 return; | 1130 return; |
956 } | 1131 } |
982 gaim_im_set_typing_state(im, state); | 1157 gaim_im_set_typing_state(im, state); |
983 gaim_im_update_typing(im); | 1158 gaim_im_update_typing(im); |
984 | 1159 |
985 b = gaim_find_buddy(gc->account, name); | 1160 b = gaim_find_buddy(gc->account, name); |
986 | 1161 |
987 plugin_event(event_got_typing, gc, name); | 1162 gaim_event_broadcast(event_got_typing, gc, name); |
988 | 1163 |
989 if (b != NULL) | 1164 if (b != NULL) |
990 gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING); | 1165 gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING); |
991 | 1166 |
992 if (timeout > 0) | 1167 if (timeout > 0) |
1046 { | 1221 { |
1047 char buf2[BUF_LONG]; | 1222 char buf2[BUF_LONG]; |
1048 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); | 1223 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); |
1049 | 1224 |
1050 | 1225 |
1051 plugin_event(event_chat_invited, gc, who, name, message); | 1226 gaim_event_broadcast(event_chat_invited, gc, who, name, message); |
1052 | 1227 |
1053 if (message) | 1228 if (message) |
1054 g_snprintf(buf2, sizeof(buf2), | 1229 g_snprintf(buf2, sizeof(buf2), |
1055 _("User '%s' invites %s to buddy chat room: '%s'\n%s"), | 1230 _("User '%s' invites %s to buddy chat room: '%s'\n%s"), |
1056 who, gc->username, name, message); | 1231 who, gc->username, name, message); |
1104 | 1279 |
1105 gaim_window_show(gaim_conversation_get_window(b)); | 1280 gaim_window_show(gaim_conversation_get_window(b)); |
1106 gaim_window_switch_conversation(gaim_conversation_get_window(b), | 1281 gaim_window_switch_conversation(gaim_conversation_get_window(b), |
1107 gaim_conversation_get_index(b)); | 1282 gaim_conversation_get_index(b)); |
1108 | 1283 |
1109 plugin_event(event_chat_join, gc, id, name); | 1284 gaim_event_broadcast(event_chat_join, gc, id, name); |
1110 | 1285 |
1111 return b; | 1286 return b; |
1112 } | 1287 } |
1113 | 1288 |
1114 void serv_got_chat_left(struct gaim_connection *g, int id) | 1289 void serv_got_chat_left(struct gaim_connection *g, int id) |
1129 } | 1304 } |
1130 | 1305 |
1131 if (!conv) | 1306 if (!conv) |
1132 return; | 1307 return; |
1133 | 1308 |
1134 plugin_event(event_chat_leave, g, gaim_chat_get_id(chat)); | 1309 gaim_event_broadcast(event_chat_leave, g, gaim_chat_get_id(chat)); |
1135 | 1310 |
1136 debug_printf("Leaving room %s.\n", gaim_conversation_get_name(conv)); | 1311 debug_printf("Leaving room %s.\n", gaim_conversation_get_name(conv)); |
1137 | 1312 |
1138 g->buddy_chats = g_slist_remove(g->buddy_chats, conv); | 1313 g->buddy_chats = g_slist_remove(g->buddy_chats, conv); |
1139 | 1314 |
1174 */ | 1349 */ |
1175 | 1350 |
1176 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); | 1351 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); |
1177 strcpy(buffy, message); | 1352 strcpy(buffy, message); |
1178 angel = g_strdup(who); | 1353 angel = g_strdup(who); |
1179 plugin_return = plugin_event(event_chat_recv, g, gaim_chat_get_id(chat), | 1354 plugin_return = gaim_event_broadcast(event_chat_recv, g, gaim_chat_get_id(chat), |
1180 &angel, &buffy); | 1355 &angel, &buffy); |
1181 | 1356 |
1182 if (!buffy || !angel || plugin_return) { | 1357 if (!buffy || !angel || plugin_return) { |
1183 if (buffy) | 1358 if (buffy) |
1184 g_free(buffy); | 1359 g_free(buffy); |