comparison src/server.c @ 5563:9eb5b13fd412

[gaim-migrate @ 5965] Just a taste of what's coming. Standard "This won't compile" thing. Plugin authors, you're going to hate me, but that's okay, because I have friends too! It's really late. My brain resembles that of fish swimming in jello pudding with neon lights flying around chanting musicals. I'm not on drugs. I'm just that tired. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 30 May 2003 09:38:29 +0000
parents b7319c094153
children 5e7de337a053
comparison
equal deleted inserted replaced
5562:3c8d34574601 5563:9eb5b13fd412
38 #include "sound.h" 38 #include "sound.h"
39 #include "pounce.h" 39 #include "pounce.h"
40 #include "notify.h" 40 #include "notify.h"
41 #include "prefs.h" 41 #include "prefs.h"
42 42
43 void serv_login(struct gaim_account *account) 43 void serv_login(GaimAccount *account)
44 { 44 {
45 GaimPlugin *p = gaim_find_prpl(account->protocol); 45 GaimPlugin *p = gaim_find_prpl(account->protocol);
46 GaimPluginProtocolInfo *prpl_info = NULL; 46 GaimPluginProtocolInfo *prpl_info = NULL;
47 47
48 if (account->gc != NULL || p == NULL) 48 if (account->gc != NULL || p == NULL)
59 } 59 }
60 60
61 gaim_debug(GAIM_DEBUG_INFO, "server", 61 gaim_debug(GAIM_DEBUG_INFO, "server",
62 PACKAGE " " VERSION " logging in %s using %s\n", 62 PACKAGE " " VERSION " logging in %s using %s\n",
63 account->username, p->info->name); 63 account->username, p->info->name);
64 account->connecting = TRUE; 64
65 connecting_count++;
66 gaim_debug(GAIM_DEBUG_MISC, "server",
67 "connection count: %d\n", connecting_count);
68 gaim_event_broadcast(event_connecting, account); 65 gaim_event_broadcast(event_connecting, account);
69 prpl_info->login(account); 66 prpl_info->login(account);
70 } 67 }
71 } 68 }
72 69
73 static gboolean send_keepalive(gpointer d) 70 static gboolean send_keepalive(gpointer d)
74 { 71 {
75 struct gaim_connection *gc = d; 72 GaimConnection *gc = d;
76 GaimPluginProtocolInfo *prpl_info = NULL; 73 GaimPluginProtocolInfo *prpl_info = NULL;
77 74
78 if (gc != NULL && gc->prpl != NULL) 75 if (gc != NULL && gc->prpl != NULL)
79 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 76 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
80 77
82 prpl_info->keepalive(gc); 79 prpl_info->keepalive(gc);
83 80
84 return TRUE; 81 return TRUE;
85 } 82 }
86 83
87 static void update_keepalive(struct gaim_connection *gc, gboolean on) 84 static void update_keepalive(GaimConnection *gc, gboolean on)
88 { 85 {
89 if (on && !gc->keepalive) { 86 if (on && !gc->keep_alive) {
90 gaim_debug(GAIM_DEBUG_INFO, "server", "allowing NOP\n"); 87 gaim_debug(GAIM_DEBUG_INFO, "server", "allowing NOP\n");
91 gc->keepalive = g_timeout_add(60000, send_keepalive, gc); 88 gc->keep_alive = g_timeout_add(60000, send_keepalive, gc);
92 } else if (!on && gc->keepalive > 0) { 89 } else if (!on && gc->keep_alive > 0) {
93 gaim_debug(GAIM_DEBUG_INFO, "server", "removing NOP\n"); 90 gaim_debug(GAIM_DEBUG_INFO, "server", "removing NOP\n");
94 g_source_remove(gc->keepalive); 91 g_source_remove(gc->keep_alive);
95 gc->keepalive = 0; 92 gc->keep_alive = 0;
96 } 93 }
97 } 94 }
98 95
99 void serv_close(struct gaim_connection *gc) 96 void serv_close(GaimConnection *gc)
100 { 97 {
101 GaimPlugin *prpl; 98 GaimPlugin *prpl;
102 GaimPluginProtocolInfo *prpl_info = NULL; 99 GaimPluginProtocolInfo *prpl_info = NULL;
103 100
104 while (gc->buddy_chats) { 101 while (gc->buddy_chats) {
123 if (prpl_info->close) 120 if (prpl_info->close)
124 prpl_info->close(gc); 121 prpl_info->close(gc);
125 } 122 }
126 123
127 prpl = gc->prpl; 124 prpl = gc->prpl;
128 account_offline(gc); 125
129 destroy_gaim_conn(gc); 126 gaim_account_disconnect(gaim_connection_get_account(gc));
130 } 127 }
131 128
132 void serv_touch_idle(struct gaim_connection *gc) 129 void serv_touch_idle(GaimConnection *gc)
133 { 130 {
134 /* Are we idle? If so, not anymore */ 131 /* Are we idle? If so, not anymore */
135 if (gc->is_idle > 0) { 132 if (gc->is_idle > 0) {
136 gc->is_idle = 0; 133 gc->is_idle = 0;
137 serv_set_idle(gc, 0); 134 serv_set_idle(gc, 0);
138 } 135 }
139 time(&gc->lastsent); 136 time(&gc->last_sent_time);
140 if (gc->is_auto_away) 137 if (gc->is_auto_away)
141 check_idle(gc); 138 check_idle(gc);
142 } 139 }
143 140
144 void serv_finish_login(struct gaim_connection *gc) 141 void serv_finish_login(GaimConnection *gc)
145 { 142 {
146 GaimPluginProtocolInfo *prpl_info = NULL; 143 GaimPluginProtocolInfo *prpl_info = NULL;
147 144
148 if (gc != NULL && gc->prpl != NULL) 145 if (gc != NULL && gc->prpl != NULL)
149 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 146 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
160 157
161 gc->idle_timer = g_timeout_add(20000, check_idle, gc); 158 gc->idle_timer = g_timeout_add(20000, check_idle, gc);
162 serv_touch_idle(gc); 159 serv_touch_idle(gc);
163 160
164 if (prpl_info->options & OPT_PROTO_CORRECT_TIME) 161 if (prpl_info->options & OPT_PROTO_CORRECT_TIME)
165 serv_add_buddy(gc, gc->username); 162 serv_add_buddy(gc,
163 gaim_account_get_username(gaim_connection_get_account(gc)));
166 164
167 update_keepalive(gc, TRUE); 165 update_keepalive(gc, TRUE);
168 } 166 }
169 167
170 /* This should return the elapsed time in seconds in which Gaim will not send 168 /* This should return the elapsed time in seconds in which Gaim will not send
171 * typing notifications. 169 * typing notifications.
172 * if it returns zero, it will not send any more typing notifications 170 * if it returns zero, it will not send any more typing notifications
173 * typing is a flag - TRUE for typing, FALSE for stopped typing */ 171 * typing is a flag - TRUE for typing, FALSE for stopped typing */
174 int serv_send_typing(struct gaim_connection *g, char *name, int typing) { 172 int serv_send_typing(GaimConnection *g, char *name, int typing) {
175 GaimPluginProtocolInfo *prpl_info = NULL; 173 GaimPluginProtocolInfo *prpl_info = NULL;
176 174
177 if (g != NULL && g->prpl != NULL) 175 if (g != NULL && g->prpl != NULL)
178 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 176 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
179 177
188 time_t sent_away; 186 time_t sent_away;
189 }; 187 };
190 188
191 struct queued_away_response *find_queued_away_response_by_name(char *name); 189 struct queued_away_response *find_queued_away_response_by_name(char *name);
192 190
193 int serv_send_im(struct gaim_connection *gc, char *name, char *message, 191 int serv_send_im(GaimConnection *gc, char *name, char *message,
194 int len, int flags) 192 int len, int flags)
195 { 193 {
196 struct gaim_conversation *c; 194 struct gaim_conversation *c;
197 int val = -EINVAL; 195 int val = -EINVAL;
198 GaimPluginProtocolInfo *prpl_info = NULL; 196 GaimPluginProtocolInfo *prpl_info = NULL;
229 gaim_im_stop_type_again_timeout(GAIM_IM(c)); 227 gaim_im_stop_type_again_timeout(GAIM_IM(c));
230 228
231 return val; 229 return val;
232 } 230 }
233 231
234 void serv_get_info(struct gaim_connection *g, char *name) 232 void serv_get_info(GaimConnection *g, char *name)
235 { 233 {
236 GaimPluginProtocolInfo *prpl_info = NULL; 234 GaimPluginProtocolInfo *prpl_info = NULL;
237 235
238 if (g != NULL && g->prpl != NULL) 236 if (g != NULL && g->prpl != NULL)
239 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 237 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
240 238
241 if (g && prpl_info && prpl_info->get_info) 239 if (g && prpl_info && prpl_info->get_info)
242 prpl_info->get_info(g, name); 240 prpl_info->get_info(g, name);
243 } 241 }
244 242
245 void serv_get_away(struct gaim_connection *g, const char *name) 243 void serv_get_away(GaimConnection *g, const char *name)
246 { 244 {
247 GaimPluginProtocolInfo *prpl_info = NULL; 245 GaimPluginProtocolInfo *prpl_info = NULL;
248 246
249 if (g != NULL && g->prpl != NULL) 247 if (g != NULL && g->prpl != NULL)
250 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 248 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
251 249
252 if (g && prpl_info && prpl_info->get_away) 250 if (g && prpl_info && prpl_info->get_away)
253 prpl_info->get_away(g, name); 251 prpl_info->get_away(g, name);
254 } 252 }
255 253
256 void serv_get_dir(struct gaim_connection *g, char *name) 254 void serv_get_dir(GaimConnection *g, char *name)
257 { 255 {
258 GaimPluginProtocolInfo *prpl_info = NULL; 256 GaimPluginProtocolInfo *prpl_info = NULL;
259 257
260 if (g != NULL && g->prpl != NULL) 258 if (g != NULL && g->prpl != NULL)
261 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 259 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
262 260
263 if (prpl_info && g_slist_find(connections, g) && prpl_info->get_dir) 261 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->get_dir)
264 prpl_info->get_dir(g, name); 262 prpl_info->get_dir(g, name);
265 } 263 }
266 264
267 void serv_set_dir(struct gaim_connection *g, const char *first, 265 void serv_set_dir(GaimConnection *g, const char *first,
268 const char *middle, const char *last, const char *maiden, 266 const char *middle, const char *last, const char *maiden,
269 const char *city, const char *state, const char *country, 267 const char *city, const char *state, const char *country,
270 int web) 268 int web)
271 { 269 {
272 GaimPluginProtocolInfo *prpl_info = NULL; 270 GaimPluginProtocolInfo *prpl_info = NULL;
273 271
274 if (g != NULL && g->prpl != NULL) 272 if (g != NULL && g->prpl != NULL)
275 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 273 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
276 274
277 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_dir) 275 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_dir)
278 prpl_info->set_dir(g, first, middle, last, maiden, city, state, 276 prpl_info->set_dir(g, first, middle, last, maiden, city, state,
279 country, web); 277 country, web);
280 } 278 }
281 279
282 void serv_dir_search(struct gaim_connection *g, const char *first, 280 void serv_dir_search(GaimConnection *g, const char *first,
283 const char *middle, const char *last, const char *maiden, 281 const char *middle, const char *last, const char *maiden,
284 const char *city, const char *state, const char *country, 282 const char *city, const char *state, const char *country,
285 const char *email) 283 const char *email)
286 { 284 {
287 GaimPluginProtocolInfo *prpl_info = NULL; 285 GaimPluginProtocolInfo *prpl_info = NULL;
288 286
289 if (g != NULL && g->prpl != NULL) 287 if (g != NULL && g->prpl != NULL)
290 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 288 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
291 289
292 if (prpl_info && g_slist_find(connections, g) && prpl_info->dir_search) 290 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->dir_search)
293 prpl_info->dir_search(g, first, middle, last, maiden, city, state, 291 prpl_info->dir_search(g, first, middle, last, maiden, city, state,
294 country, email); 292 country, email);
295 } 293 }
296 294
297 295
298 void serv_set_away(struct gaim_connection *gc, char *state, char *message) 296 void serv_set_away(GaimConnection *gc, char *state, char *message)
299 { 297 {
300 GaimPluginProtocolInfo *prpl_info = NULL; 298 GaimPluginProtocolInfo *prpl_info = NULL;
301 299
302 if (gc->away_state == NULL && state == NULL && 300 if (gc->away_state == NULL && state == NULL &&
303 gc->away == NULL && message == NULL) { 301 gc->away == NULL && message == NULL) {
347 system_log(log_away, gc, NULL, OPT_LOG_BUDDY_AWAY | OPT_LOG_MY_SIGNON); 345 system_log(log_away, gc, NULL, OPT_LOG_BUDDY_AWAY | OPT_LOG_MY_SIGNON);
348 } 346 }
349 347
350 void serv_set_away_all(char *message) 348 void serv_set_away_all(char *message)
351 { 349 {
352 GSList *c; 350 GList *c;
353 struct gaim_connection *g; 351 GaimConnection *g;
354 352
355 for (c = connections; c != NULL; c = c->next) { 353 for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
356 g = (struct gaim_connection *)c->data; 354 g = (GaimConnection *)c->data;
357 355
358 serv_set_away(g, GAIM_AWAY_CUSTOM, message); 356 serv_set_away(g, GAIM_AWAY_CUSTOM, message);
359 } 357 }
360 } 358 }
361 359
362 void serv_set_info(struct gaim_connection *g, char *info) 360 void serv_set_info(GaimConnection *g, char *info)
363 { 361 {
364 GaimPluginProtocolInfo *prpl_info = NULL; 362 GaimPluginProtocolInfo *prpl_info = NULL;
365 363
366 if (g != NULL && g->prpl != NULL) 364 if (g != NULL && g->prpl != NULL)
367 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 365 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
368 366
369 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_info) { 367 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_info) {
370 if (gaim_event_broadcast(event_set_info, g, info)) 368 if (gaim_event_broadcast(event_set_info, g, info))
371 return; 369 return;
372 370
373 prpl_info->set_info(g, info); 371 prpl_info->set_info(g, info);
374 } 372 }
375 } 373 }
376 374
377 void serv_change_passwd(struct gaim_connection *g, const char *orig, const char *new) 375 void serv_change_passwd(GaimConnection *g, const char *orig, const char *new)
378 { 376 {
379 GaimPluginProtocolInfo *prpl_info = NULL; 377 GaimPluginProtocolInfo *prpl_info = NULL;
380 378
381 if (g != NULL && g->prpl != NULL) 379 if (g != NULL && g->prpl != NULL)
382 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 380 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
383 381
384 if (prpl_info && g_slist_find(connections, g) && prpl_info->change_passwd) 382 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->change_passwd)
385 prpl_info->change_passwd(g, orig, new); 383 prpl_info->change_passwd(g, orig, new);
386 } 384 }
387 385
388 void serv_add_buddy(struct gaim_connection *g, const char *name) 386 void serv_add_buddy(GaimConnection *g, const char *name)
389 { 387 {
390 GaimPluginProtocolInfo *prpl_info = NULL; 388 GaimPluginProtocolInfo *prpl_info = NULL;
391 389
392 if (g != NULL && g->prpl != NULL) 390 if (g != NULL && g->prpl != NULL)
393 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 391 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
394 392
395 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_buddy) 393 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->add_buddy)
396 prpl_info->add_buddy(g, name); 394 prpl_info->add_buddy(g, name);
397 } 395 }
398 396
399 void serv_add_buddies(struct gaim_connection *g, GList *buddies) 397 void serv_add_buddies(GaimConnection *g, GList *buddies)
400 { 398 {
401 GaimPluginProtocolInfo *prpl_info = NULL; 399 GaimPluginProtocolInfo *prpl_info = NULL;
402 400
403 if (g != NULL && g->prpl != NULL) 401 if (g != NULL && g->prpl != NULL)
404 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 402 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
405 403
406 if (prpl_info && g_slist_find(connections, g)) { 404 if (prpl_info && g_list_find(gaim_connections_get_all(), g)) {
407 if (prpl_info->add_buddies) 405 if (prpl_info->add_buddies)
408 prpl_info->add_buddies(g, buddies); 406 prpl_info->add_buddies(g, buddies);
409 else if (prpl_info->add_buddy) { 407 else if (prpl_info->add_buddy) {
410 while (buddies) { 408 while (buddies) {
411 prpl_info->add_buddy(g, buddies->data); 409 prpl_info->add_buddy(g, buddies->data);
414 } 412 }
415 } 413 }
416 } 414 }
417 415
418 416
419 void serv_remove_buddy(struct gaim_connection *g, char *name, char *group) 417 void serv_remove_buddy(GaimConnection *g, char *name, char *group)
420 { 418 {
421 GaimPluginProtocolInfo *prpl_info = NULL; 419 GaimPluginProtocolInfo *prpl_info = NULL;
422 420
423 if (g != NULL && g->prpl != NULL) 421 if (g != NULL && g->prpl != NULL)
424 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 422 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
425 423
426 if (prpl_info && g_slist_find(connections, g) && prpl_info->remove_buddy) 424 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->remove_buddy)
427 prpl_info->remove_buddy(g, name, group); 425 prpl_info->remove_buddy(g, name, group);
428 } 426 }
429 427
430 void serv_remove_buddies(struct gaim_connection *gc, GList *g, char *group) 428 void serv_remove_buddies(GaimConnection *gc, GList *g, char *group)
431 { 429 {
432 GaimPluginProtocolInfo *prpl_info = NULL; 430 GaimPluginProtocolInfo *prpl_info = NULL;
433 431
434 if (!g_slist_find(connections, gc)) 432 if (!g_list_find(gaim_connections_get_all(), gc))
435 return; 433 return;
436 434
437 if (!gc->prpl) 435 if (!gc->prpl)
438 return; /* how the hell did that happen? */ 436 return; /* how the hell did that happen? */
439 437
463 if (b && prpl_info && prpl_info->alias_buddy) { 461 if (b && prpl_info && prpl_info->alias_buddy) {
464 prpl_info->alias_buddy(b->account->gc, b->name, b->alias); 462 prpl_info->alias_buddy(b->account->gc, b->name, b->alias);
465 } 463 }
466 } 464 }
467 465
468 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) { 466 void serv_got_alias(GaimConnection *gc, char *who, char *alias) {
469 struct buddy *b = gaim_find_buddy(gc->account, who); 467 struct buddy *b = gaim_find_buddy(gc->account, who);
470 if(!b) 468 if(!b)
471 return; 469 return;
472 470
473 if (b->server_alias) 471 if (b->server_alias)
502 } 500 }
503 501
504 /* 502 /*
505 * Rename a group on server roster/list. 503 * Rename a group on server roster/list.
506 */ 504 */
507 void serv_rename_group(struct gaim_connection *g, struct group *old_group, 505 void serv_rename_group(GaimConnection *g, struct group *old_group,
508 const char *new_name) 506 const char *new_name)
509 { 507 {
510 GaimPluginProtocolInfo *prpl_info = NULL; 508 GaimPluginProtocolInfo *prpl_info = NULL;
511 509
512 if (g != NULL && g->prpl != NULL) 510 if (g != NULL && g->prpl != NULL)
536 534
537 g_list_free(tobemoved); 535 g_list_free(tobemoved);
538 } 536 }
539 } 537 }
540 538
541 void serv_add_permit(struct gaim_connection *g, const char *name) 539 void serv_add_permit(GaimConnection *g, const char *name)
542 { 540 {
543 GaimPluginProtocolInfo *prpl_info = NULL; 541 GaimPluginProtocolInfo *prpl_info = NULL;
544 542
545 if (g != NULL && g->prpl != NULL) 543 if (g != NULL && g->prpl != NULL)
546 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 544 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
547 545
548 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_permit) 546 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->add_permit)
549 prpl_info->add_permit(g, name); 547 prpl_info->add_permit(g, name);
550 } 548 }
551 549
552 void serv_add_deny(struct gaim_connection *g, const char *name) 550 void serv_add_deny(GaimConnection *g, const char *name)
553 { 551 {
554 GaimPluginProtocolInfo *prpl_info = NULL; 552 GaimPluginProtocolInfo *prpl_info = NULL;
555 553
556 if (g != NULL && g->prpl != NULL) 554 if (g != NULL && g->prpl != NULL)
557 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 555 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
558 556
559 if (prpl_info && g_slist_find(connections, g) && prpl_info->add_deny) 557 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->add_deny)
560 prpl_info->add_deny(g, name); 558 prpl_info->add_deny(g, name);
561 } 559 }
562 560
563 void serv_rem_permit(struct gaim_connection *g, const char *name) 561 void serv_rem_permit(GaimConnection *g, const char *name)
564 { 562 {
565 GaimPluginProtocolInfo *prpl_info = NULL; 563 GaimPluginProtocolInfo *prpl_info = NULL;
566 564
567 if (g != NULL && g->prpl != NULL) 565 if (g != NULL && g->prpl != NULL)
568 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 566 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
569 567
570 if (prpl_info && g_slist_find(connections, g) && prpl_info->rem_permit) 568 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->rem_permit)
571 prpl_info->rem_permit(g, name); 569 prpl_info->rem_permit(g, name);
572 } 570 }
573 571
574 void serv_rem_deny(struct gaim_connection *g, const char *name) 572 void serv_rem_deny(GaimConnection *g, const char *name)
575 { 573 {
576 GaimPluginProtocolInfo *prpl_info = NULL; 574 GaimPluginProtocolInfo *prpl_info = NULL;
577 575
578 if (g != NULL && g->prpl != NULL) 576 if (g != NULL && g->prpl != NULL)
579 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 577 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
580 578
581 if (prpl_info && g_slist_find(connections, g) && prpl_info->rem_deny) 579 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->rem_deny)
582 prpl_info->rem_deny(g, name); 580 prpl_info->rem_deny(g, name);
583 } 581 }
584 582
585 void serv_set_permit_deny(struct gaim_connection *g) 583 void serv_set_permit_deny(GaimConnection *g)
586 { 584 {
587 GaimPluginProtocolInfo *prpl_info = NULL; 585 GaimPluginProtocolInfo *prpl_info = NULL;
588 586
589 if (g != NULL && g->prpl != NULL) 587 if (g != NULL && g->prpl != NULL)
590 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 588 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
593 * this is called when either you import a buddy list, and make lots 591 * this is called when either you import a buddy list, and make lots
594 * of changes that way, or when the user toggles the permit/deny mode 592 * of changes that way, or when the user toggles the permit/deny mode
595 * in the prefs. In either case you should probably be resetting and 593 * in the prefs. In either case you should probably be resetting and
596 * resending the permit/deny info when you get this. 594 * resending the permit/deny info when you get this.
597 */ 595 */
598 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_permit_deny) 596 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_permit_deny)
599 prpl_info->set_permit_deny(g); 597 prpl_info->set_permit_deny(g);
600 } 598 }
601 599
602 600
603 void serv_set_idle(struct gaim_connection *g, int time) 601 void serv_set_idle(GaimConnection *g, int time)
604 { 602 {
605 GaimPluginProtocolInfo *prpl_info = NULL; 603 GaimPluginProtocolInfo *prpl_info = NULL;
606 604
607 if (g != NULL && g->prpl != NULL) 605 if (g != NULL && g->prpl != NULL)
608 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 606 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
609 607
610 if (prpl_info && g_slist_find(connections, g) && prpl_info->set_idle) 608 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_idle)
611 prpl_info->set_idle(g, time); 609 prpl_info->set_idle(g, time);
612 } 610 }
613 611
614 void serv_warn(struct gaim_connection *g, char *name, int anon) 612 void serv_warn(GaimConnection *g, char *name, int anon)
615 { 613 {
616 GaimPluginProtocolInfo *prpl_info = NULL; 614 GaimPluginProtocolInfo *prpl_info = NULL;
617 615
618 if (g != NULL && g->prpl != NULL) 616 if (g != NULL && g->prpl != NULL)
619 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 617 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
620 618
621 if (prpl_info && g_slist_find(connections, g) && prpl_info->warn) 619 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->warn)
622 prpl_info->warn(g, name, anon); 620 prpl_info->warn(g, name, anon);
623 } 621 }
624 622
625 void serv_join_chat(struct gaim_connection *g, GHashTable *data) 623 void serv_join_chat(GaimConnection *g, GHashTable *data)
626 { 624 {
627 GaimPluginProtocolInfo *prpl_info = NULL; 625 GaimPluginProtocolInfo *prpl_info = NULL;
628 626
629 if (g != NULL && g->prpl != NULL) 627 if (g != NULL && g->prpl != NULL)
630 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 628 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
631 629
632 if (prpl_info && g_slist_find(connections, g) && prpl_info->join_chat) 630 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->join_chat)
633 prpl_info->join_chat(g, data); 631 prpl_info->join_chat(g, data);
634 } 632 }
635 633
636 void serv_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) 634 void serv_chat_invite(GaimConnection *g, int id, const char *message, const char *name)
637 { 635 {
638 GaimPluginProtocolInfo *prpl_info = NULL; 636 GaimPluginProtocolInfo *prpl_info = NULL;
639 char *buffy = message && *message ? g_strdup(message) : NULL; 637 char *buffy = message && *message ? g_strdup(message) : NULL;
640 638
641 if (g != NULL && g->prpl != NULL) 639 if (g != NULL && g->prpl != NULL)
642 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 640 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
643 641
644 gaim_event_broadcast(event_chat_send_invite, g, (void *)id, name, &buffy); 642 gaim_event_broadcast(event_chat_send_invite, g, (void *)id, name, &buffy);
645 643
646 if (prpl_info && g_slist_find(connections, g) && prpl_info->chat_invite) 644 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->chat_invite)
647 prpl_info->chat_invite(g, id, buffy, name); 645 prpl_info->chat_invite(g, id, buffy, name);
648 646
649 if (buffy) 647 if (buffy)
650 g_free(buffy); 648 g_free(buffy);
651 } 649 }
652 650
653 void serv_chat_leave(struct gaim_connection *g, int id) 651 void serv_chat_leave(GaimConnection *g, int id)
654 { 652 {
655 GaimPluginProtocolInfo *prpl_info = NULL; 653 GaimPluginProtocolInfo *prpl_info = NULL;
656 654
657 if (!g_slist_find(connections, g)) 655 if (!g_list_find(gaim_connections_get_all(), g))
658 return; 656 return;
659 657
660 if (g->prpl != NULL) 658 if (g->prpl != NULL)
661 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 659 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
662 660
663 if (prpl_info && prpl_info->chat_leave) 661 if (prpl_info && prpl_info->chat_leave)
664 prpl_info->chat_leave(g, id); 662 prpl_info->chat_leave(g, id);
665 } 663 }
666 664
667 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) 665 void serv_chat_whisper(GaimConnection *g, int id, char *who, char *message)
668 { 666 {
669 GaimPluginProtocolInfo *prpl_info = NULL; 667 GaimPluginProtocolInfo *prpl_info = NULL;
670 668
671 if (g != NULL && g->prpl != NULL) 669 if (g != NULL && g->prpl != NULL)
672 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); 670 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
673 671
674 if (prpl_info && prpl_info->chat_whisper) 672 if (prpl_info && prpl_info->chat_whisper)
675 prpl_info->chat_whisper(g, id, who, message); 673 prpl_info->chat_whisper(g, id, who, message);
676 } 674 }
677 675
678 int serv_chat_send(struct gaim_connection *g, int id, char *message) 676 int serv_chat_send(GaimConnection *g, int id, char *message)
679 { 677 {
680 int val = -EINVAL; 678 int val = -EINVAL;
681 GaimPluginProtocolInfo *prpl_info = NULL; 679 GaimPluginProtocolInfo *prpl_info = NULL;
682 680
683 if (g->prpl != NULL) 681 if (g->prpl != NULL)
751 749
752 /* 750 /*
753 * woo. i'm actually going to comment this function. isn't that fun. make 751 * woo. i'm actually going to comment this function. isn't that fun. make
754 * sure to follow along, kids 752 * sure to follow along, kids
755 */ 753 */
756 void serv_got_im(struct gaim_connection *gc, const char *who, const char *msg, 754 void serv_got_im(GaimConnection *gc, const char *who, const char *msg,
757 guint32 flags, time_t mtime, gint len) 755 guint32 flags, time_t mtime, gint len)
758 { 756 {
759 char *buffy; 757 char *buffy;
760 char *angel; 758 char *angel;
761 int plugin_return; 759 int plugin_return;
1025 g_free(message); 1023 g_free(message);
1026 } 1024 }
1027 1025
1028 1026
1029 1027
1030 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, 1028 void serv_got_update(GaimConnection *gc, char *name, int loggedin,
1031 int evil, time_t signon, time_t idle, int type) 1029 int evil, time_t signon, time_t idle, int type)
1032 { 1030 {
1033 struct buddy *b = gaim_find_buddy(gc->account, name); 1031 GaimAccount *account;
1032 struct buddy *b;
1033
1034 account = gaim_connection_get_account(gc);
1035 b = gaim_find_buddy(account, name);
1034 1036
1035 if (signon && (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->options & 1037 if (signon && (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->options &
1036 OPT_PROTO_CORRECT_TIME)) { 1038 OPT_PROTO_CORRECT_TIME)) {
1037 1039
1038 char *tmp = g_strdup(normalize(name)); 1040 char *tmp = g_strdup(normalize(name));
1039 if (!gaim_utf8_strcasecmp(tmp, normalize(gc->username))) { 1041 if (!gaim_utf8_strcasecmp(tmp,
1042 normalize(gaim_account_get_username(account)))) {
1043
1040 gc->evil = evil; 1044 gc->evil = evil;
1041 gc->login_time_official = signon; 1045 gc->login_time_official = signon;
1042 /*update_idle_times();*/ 1046 /*update_idle_times();*/
1043 } 1047 }
1044 g_free(tmp); 1048 g_free(tmp);
1143 gaim_blist_update_buddy_presence(b, loggedin); 1147 gaim_blist_update_buddy_presence(b, loggedin);
1144 1148
1145 } 1149 }
1146 1150
1147 1151
1148 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) 1152 void serv_got_eviled(GaimConnection *gc, char *name, int lev)
1149 { 1153 {
1150 char buf2[1024]; 1154 char buf2[1024];
1151 1155
1152 gaim_event_broadcast(event_warned, gc, name, lev); 1156 gaim_event_broadcast(event_warned, gc, name, lev);
1153 1157
1159 gc->evil = lev; 1163 gc->evil = lev;
1160 1164
1161 g_snprintf(buf2, sizeof(buf2), 1165 g_snprintf(buf2, sizeof(buf2),
1162 _("%s has just been warned by %s.\n" 1166 _("%s has just been warned by %s.\n"
1163 "Your new warning level is %d%%"), 1167 "Your new warning level is %d%%"),
1164 gc->username, 1168 gaim_account_get_username(gaim_connection_get_account(gc)),
1165 ((name == NULL)? _("an anonymous person") : name), lev); 1169 ((name == NULL) ? _("an anonymous person") : name), lev);
1166 1170
1167 gaim_notify_info(NULL, NULL, buf2, NULL); 1171 gaim_notify_info(NULL, NULL, buf2, NULL);
1168 } 1172 }
1169 1173
1170 void serv_got_typing(struct gaim_connection *gc, char *name, int timeout, 1174 void serv_got_typing(GaimConnection *gc, char *name, int timeout,
1171 int state) { 1175 int state) {
1172 1176
1173 struct buddy *b; 1177 struct buddy *b;
1174 struct gaim_conversation *cnv = gaim_find_conversation(name); 1178 struct gaim_conversation *cnv = gaim_find_conversation(name);
1175 struct gaim_im *im; 1179 struct gaim_im *im;
1192 1196
1193 if (timeout > 0) 1197 if (timeout > 0)
1194 gaim_im_start_typing_timeout(im, timeout); 1198 gaim_im_start_typing_timeout(im, timeout);
1195 } 1199 }
1196 1200
1197 void serv_got_typing_stopped(struct gaim_connection *gc, char *name) { 1201 void serv_got_typing_stopped(GaimConnection *gc, char *name) {
1198 1202
1199 struct gaim_conversation *c = gaim_find_conversation(name); 1203 struct gaim_conversation *c = gaim_find_conversation(name);
1200 struct gaim_im *im; 1204 struct gaim_im *im;
1201 struct buddy *b; 1205 struct buddy *b;
1202 1206
1217 if (b != NULL) 1221 if (b != NULL)
1218 gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING_STOPPED); 1222 gaim_pounce_execute(gc->account, name, GAIM_POUNCE_TYPING_STOPPED);
1219 } 1223 }
1220 1224
1221 struct chat_invite_data { 1225 struct chat_invite_data {
1222 struct gaim_connection *gc; 1226 GaimConnection *gc;
1223 GHashTable *components; 1227 GHashTable *components;
1224 }; 1228 };
1225 1229
1226 static void chat_invite_data_free(struct chat_invite_data *cid) 1230 static void chat_invite_data_free(struct chat_invite_data *cid)
1227 { 1231 {
1237 chat_invite_data_free(cid); 1241 chat_invite_data_free(cid);
1238 } 1242 }
1239 1243
1240 1244
1241 1245
1242 void serv_got_chat_invite(struct gaim_connection *gc, char *name, 1246 void serv_got_chat_invite(GaimConnection *gc, char *name,
1243 char *who, char *message, GHashTable *data) 1247 char *who, char *message, GHashTable *data)
1244 { 1248 {
1249 GaimAccount *account;
1245 char buf2[BUF_LONG]; 1250 char buf2[BUF_LONG];
1246 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); 1251 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1);
1247 1252
1253 account = gaim_connection_get_account(gc);
1248 1254
1249 gaim_event_broadcast(event_chat_invited, gc, who, name, message); 1255 gaim_event_broadcast(event_chat_invited, gc, who, name, message);
1250 1256
1251 if (message) 1257 if (message)
1252 g_snprintf(buf2, sizeof(buf2), 1258 g_snprintf(buf2, sizeof(buf2),
1253 _("User '%s' invites %s to buddy chat room: '%s'\n%s"), 1259 _("User '%s' invites %s to buddy chat room: '%s'\n%s"),
1254 who, gc->username, name, message); 1260 who, gaim_account_get_username(account), name, message);
1255 else 1261 else
1256 g_snprintf(buf2, sizeof(buf2), 1262 g_snprintf(buf2, sizeof(buf2),
1257 _("User '%s' invites %s to buddy chat room: '%s'\n"), 1263 _("User '%s' invites %s to buddy chat room: '%s'\n"),
1258 who, gc->username, name); 1264 who, gaim_account_get_username(account), name);
1259 1265
1260 cid->gc = gc; 1266 cid->gc = gc;
1261 cid->components = data; 1267 cid->components = data;
1262 1268
1263 gaim_request_accept_cancel(gc, NULL, _("Accept chat invitation?"), 1269 gaim_request_accept_cancel(gc, NULL, _("Accept chat invitation?"),
1264 buf2, 0, cid, 1270 buf2, 0, cid,
1265 G_CALLBACK(chat_invite_accept), 1271 G_CALLBACK(chat_invite_accept),
1266 G_CALLBACK(chat_invite_data_free)); 1272 G_CALLBACK(chat_invite_data_free));
1267 } 1273 }
1268 1274
1269 struct gaim_conversation *serv_got_joined_chat(struct gaim_connection *gc, 1275 struct gaim_conversation *serv_got_joined_chat(GaimConnection *gc,
1270 int id, char *name) 1276 int id, char *name)
1271 { 1277 {
1272 struct gaim_conversation *b; 1278 struct gaim_conversation *b;
1273 struct gaim_chat *chat; 1279 struct gaim_chat *chat;
1274 1280
1311 gaim_event_broadcast(event_chat_join, gc, id, name); 1317 gaim_event_broadcast(event_chat_join, gc, id, name);
1312 1318
1313 return b; 1319 return b;
1314 } 1320 }
1315 1321
1316 void serv_got_chat_left(struct gaim_connection *g, int id) 1322 void serv_got_chat_left(GaimConnection *g, int id)
1317 { 1323 {
1318 GSList *bcs; 1324 GSList *bcs;
1319 struct gaim_conversation *conv = NULL; 1325 struct gaim_conversation *conv = NULL;
1320 struct gaim_chat *chat = NULL; 1326 struct gaim_chat *chat = NULL;
1321 1327
1341 g->buddy_chats = g_slist_remove(g->buddy_chats, conv); 1347 g->buddy_chats = g_slist_remove(g->buddy_chats, conv);
1342 1348
1343 gaim_conversation_destroy(conv); 1349 gaim_conversation_destroy(conv);
1344 } 1350 }
1345 1351
1346 void serv_got_chat_in(struct gaim_connection *g, int id, char *who, 1352 void serv_got_chat_in(GaimConnection *g, int id, char *who,
1347 int whisper, char *message, time_t mtime) 1353 int whisper, char *message, time_t mtime)
1348 { 1354 {
1349 int w; 1355 int w;
1350 GSList *bcs; 1356 GSList *bcs;
1351 struct gaim_conversation *conv = NULL; 1357 struct gaim_conversation *conv = NULL;