Mercurial > pidgin
comparison src/server.c @ 1252:46c09828e929
[gaim-migrate @ 1262]
still need to do buddy.c, conversation.c, dialogs.c, prefs.c.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 13 Dec 2000 22:12:02 +0000 |
| parents | b5783215b245 |
| children | f44bcae47188 |
comparison
equal
deleted
inserted
replaced
| 1251:2d12541cedb1 | 1252:46c09828e929 |
|---|---|
| 45 #include "pixmaps/cancel.xpm" | 45 #include "pixmaps/cancel.xpm" |
| 46 | 46 |
| 47 void serv_login(struct aim_user *user) | 47 void serv_login(struct aim_user *user) |
| 48 { | 48 { |
| 49 struct prpl *p = find_prpl(user->protocol); | 49 struct prpl *p = find_prpl(user->protocol); |
| 50 if (user->gc != NULL) return; | 50 if (user->gc != NULL) |
| 51 return; | |
| 51 if (p && p->login) { | 52 if (p && p->login) { |
| 52 debug_printf("Logging in using %s\n", (*p->name)()); | 53 debug_printf("Logging in using %s\n", (*p->name)()); |
| 53 (*p->login)(user); | 54 (*p->login)(user); |
| 54 } | 55 } |
| 55 } | 56 } |
| 65 bcs = gc->buddy_chats; | 66 bcs = gc->buddy_chats; |
| 66 } | 67 } |
| 67 | 68 |
| 68 if (gc->idle_timer > 0) | 69 if (gc->idle_timer > 0) |
| 69 gtk_timeout_remove(gc->idle_timer); | 70 gtk_timeout_remove(gc->idle_timer); |
| 70 gc->idle_timer = 0; | 71 gc->idle_timer = 0; |
| 71 | 72 |
| 72 if (gc->keepalive > 0) | 73 if (gc->keepalive > 0) |
| 73 gtk_timeout_remove(gc->keepalive); | 74 gtk_timeout_remove(gc->keepalive); |
| 74 gc->keepalive = 0; | 75 gc->keepalive = 0; |
| 75 | 76 |
| 84 void serv_touch_idle(struct gaim_connection *gc) | 85 void serv_touch_idle(struct gaim_connection *gc) |
| 85 { | 86 { |
| 86 /* Are we idle? If so, not anymore */ | 87 /* Are we idle? If so, not anymore */ |
| 87 if (gc->is_idle > 0) { | 88 if (gc->is_idle > 0) { |
| 88 gc->is_idle = 0; | 89 gc->is_idle = 0; |
| 89 serv_set_idle(gc, 0); | 90 serv_set_idle(gc, 0); |
| 90 } | 91 } |
| 91 time(&gc->lastsent); | 92 time(&gc->lastsent); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void serv_finish_login(struct gaim_connection *gc) | 95 void serv_finish_login(struct gaim_connection *gc) |
| 95 { | 96 { |
| 96 char *buf; | 97 char *buf; |
| 97 | 98 |
| 98 if (strlen(gc->user->user_info)) { | 99 if (strlen(gc->user->user_info)) { |
| 99 buf = g_malloc(strlen(gc->user->user_info) * 4); | 100 buf = g_malloc(strlen(gc->user->user_info) * 4); |
| 100 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); | 101 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); |
| 101 serv_set_info(gc, buf); | 102 serv_set_info(gc, buf); |
| 102 g_free(buf); | 103 g_free(buf); |
| 103 } | 104 } |
| 104 | 105 |
| 105 if (gc->idle_timer > 0) | 106 if (gc->idle_timer > 0) |
| 106 gtk_timeout_remove(gc->idle_timer); | 107 gtk_timeout_remove(gc->idle_timer); |
| 107 | 108 |
| 108 gc->idle_timer = gtk_timeout_add(20000, (GtkFunction)check_idle, gc); | 109 gc->idle_timer = gtk_timeout_add(20000, (GtkFunction)check_idle, gc); |
| 109 serv_touch_idle(gc); | 110 serv_touch_idle(gc); |
| 110 | 111 |
| 111 time(&gc->login_time); | 112 time(&gc->login_time); |
| 112 | 113 |
| 113 serv_add_buddy(gc, gc->username); | 114 serv_add_buddy(gc, gc->username); |
| 114 | 115 |
| 115 update_keepalive(gc, gc->options & OPT_USR_KEEPALV); | 116 update_keepalive(gc, gc->options & OPT_USR_KEEPALV); |
| 116 } | 117 } |
| 117 | 118 |
| 118 | 119 |
| 120 void serv_send_im(struct gaim_connection *gc, char *name, char *message, int away) | 121 void serv_send_im(struct gaim_connection *gc, char *name, char *message, int away) |
| 121 { | 122 { |
| 122 if (gc->prpl && gc->prpl->send_im) | 123 if (gc->prpl && gc->prpl->send_im) |
| 123 (*gc->prpl->send_im)(gc, name, message, away); | 124 (*gc->prpl->send_im)(gc, name, message, away); |
| 124 | 125 |
| 125 if (!away) | 126 if (!away) |
| 126 serv_touch_idle(gc); | 127 serv_touch_idle(gc); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void serv_get_info(struct gaim_connection *g, char *name) | 130 void serv_get_info(struct gaim_connection *g, char *name) |
| 130 { | 131 { |
| 131 if (g && g->prpl && g->prpl->get_info) | 132 if (g && g->prpl && g->prpl->get_info) |
| 176 { | 177 { |
| 177 if (g->prpl && g->prpl->set_info) | 178 if (g->prpl && g->prpl->set_info) |
| 178 (*g->prpl->set_info)(g, info); | 179 (*g->prpl->set_info)(g, info); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void serv_change_passwd(struct gaim_connection *g, char *orig, char *new) { | 182 void serv_change_passwd(struct gaim_connection *g, char *orig, char *new) |
| 183 { | |
| 182 if (g->prpl && g->prpl->change_passwd) | 184 if (g->prpl && g->prpl->change_passwd) |
| 183 (*g->prpl->change_passwd)(g, orig, new); | 185 (*g->prpl->change_passwd)(g, orig, new); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void serv_add_buddy(struct gaim_connection *g, char *name) | 188 void serv_add_buddy(struct gaim_connection *g, char *name) |
| 187 { | 189 { |
| 188 if (g->prpl && g->prpl->add_buddy) | 190 if (g->prpl && g->prpl->add_buddy) |
| 189 (*g->prpl->add_buddy)(g, name); | 191 (*g->prpl->add_buddy)(g, name); |
| 190 } | 192 } |
| 191 | 193 |
| 192 void serv_add_buddies(struct gaim_connection *g, GList *buddies) | 194 void serv_add_buddies(struct gaim_connection *g, GList * buddies) |
| 193 { | 195 { |
| 194 if (g->prpl && g->prpl->add_buddies) | 196 if (g->prpl && g->prpl->add_buddies) |
| 195 (*g->prpl->add_buddies)(g, buddies); | 197 (*g->prpl->add_buddies)(g, buddies); |
| 196 } | 198 } |
| 197 | 199 |
| 268 | 270 |
| 269 void serv_chat_leave(struct gaim_connection *g, int id) | 271 void serv_chat_leave(struct gaim_connection *g, int id) |
| 270 { | 272 { |
| 271 /* i think this is the only one this should be necessary for since this is the | 273 /* i think this is the only one this should be necessary for since this is the |
| 272 * only thing that could possibly get called after the connection is closed */ | 274 * only thing that could possibly get called after the connection is closed */ |
| 273 if (!g_slist_find(connections, g)) return; | 275 if (!g_slist_find(connections, g)) |
| 276 return; | |
| 274 | 277 |
| 275 if (g->prpl && g->prpl->chat_leave) | 278 if (g->prpl && g->prpl->chat_leave) |
| 276 (*g->prpl->chat_leave)(g, id); | 279 (*g->prpl->chat_leave)(g, id); |
| 277 } | 280 } |
| 278 | 281 |
| 299 | 302 |
| 300 char *buffy = g_strdup(message); | 303 char *buffy = g_strdup(message); |
| 301 char *angel = g_strdup(name); | 304 char *angel = g_strdup(name); |
| 302 int plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, 0); | 305 int plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, 0); |
| 303 if (!buffy || !angel || plugin_return) { | 306 if (!buffy || !angel || plugin_return) { |
| 304 if (buffy) g_free(buffy); | 307 if (buffy) |
| 305 if (angel) g_free(angel); | 308 g_free(buffy); |
| 309 if (angel) | |
| 310 g_free(angel); | |
| 306 return; | 311 return; |
| 307 } | 312 } |
| 308 g_snprintf(message, strlen(message) + 1, "%s", buffy); | 313 g_snprintf(message, strlen(message) + 1, "%s", buffy); |
| 309 g_free(buffy); | 314 g_free(buffy); |
| 310 g_snprintf(name, strlen(name) + 1, "%s", angel); | 315 g_snprintf(name, strlen(name) + 1, "%s", angel); |
| 311 g_free(angel); | 316 g_free(angel); |
| 312 | 317 |
| 313 if ((general_options & OPT_GEN_TIK_HACK) && awaymessage && | 318 if ((general_options & OPT_GEN_TIK_HACK) && awaymessage && |
| 314 !strcmp(message, ">>>Automated Message: Getting Away Message<<<")) | 319 !strcmp(message, ">>>Automated Message: Getting Away Message<<<")) { |
| 315 { | |
| 316 char *tmpmsg = stylize(awaymessage->message, MSG_LEN); | 320 char *tmpmsg = stylize(awaymessage->message, MSG_LEN); |
| 317 serv_send_im(gc, name, tmpmsg, 1); | 321 serv_send_im(gc, name, tmpmsg, 1); |
| 318 g_free(tmpmsg); | 322 g_free(tmpmsg); |
| 319 return; | 323 return; |
| 320 } | 324 } |
| 321 | 325 |
| 322 cnv = find_conversation(name); | 326 cnv = find_conversation(name); |
| 323 | 327 |
| 324 if (general_options & OPT_GEN_SEND_LINKS) { | 328 if (general_options & OPT_GEN_SEND_LINKS) { |
| 325 linkify_text(message); | 329 linkify_text(message); |
| 326 } | 330 } |
| 327 | 331 |
| 328 if (away) | 332 if (away) |
| 329 away = WFLAG_AUTO; | 333 away = WFLAG_AUTO; |
| 330 | 334 |
| 331 if (awaymessage != NULL) { | 335 if (awaymessage != NULL) { |
| 332 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { | 336 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { |
| 376 if (is_idle) | 380 if (is_idle) |
| 377 is_idle = -1; | 381 is_idle = -1; |
| 378 | 382 |
| 379 /* apply default fonts and colors */ | 383 /* apply default fonts and colors */ |
| 380 tmpmsg = stylize(awaymessage->message, MSG_LEN); | 384 tmpmsg = stylize(awaymessage->message, MSG_LEN); |
| 381 | 385 |
| 382 /* PRPL */ | 386 /* PRPL */ |
| 383 if (gc->protocol == PROTO_TOC) { | 387 if (gc->protocol == PROTO_TOC) { |
| 384 escape_text(tmpmsg); | 388 escape_text(tmpmsg); |
| 385 escape_message(tmpmsg); | 389 escape_message(tmpmsg); |
| 386 } | 390 } |
| 388 g_free(tmpmsg); | 392 g_free(tmpmsg); |
| 389 tmpmsg = stylize(awaymessage->message, MSG_LEN); | 393 tmpmsg = stylize(awaymessage->message, MSG_LEN); |
| 390 | 394 |
| 391 if (is_idle == -1) | 395 if (is_idle == -1) |
| 392 is_idle = 1; | 396 is_idle = 1; |
| 393 | 397 |
| 394 if (cnv != NULL) | 398 if (cnv != NULL) |
| 395 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL); | 399 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL); |
| 396 g_free(tmpmsg); | 400 g_free(tmpmsg); |
| 397 } | 401 } |
| 398 } | 402 } |
| 399 | 403 |
| 400 | 404 |
| 401 | 405 |
| 402 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, int evil, time_t signon, time_t idle, int type, gushort caps) | 406 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, int evil, time_t signon, |
| 403 { | 407 time_t idle, int type, gushort caps) |
| 404 struct buddy *b = find_buddy(gc, name); | 408 { |
| 409 struct buddy *b = find_buddy(gc, name); | |
| 405 struct gaim_connection *g = find_gaim_conn_by_name(name); | 410 struct gaim_connection *g = find_gaim_conn_by_name(name); |
| 406 | 411 |
| 407 if (g) { | 412 if (g) { |
| 408 gc->correction_time = (int)(signon - g->login_time); | 413 gc->correction_time = (int)(signon - g->login_time); |
| 409 if (!b) { | 414 if (!b) { |
| 410 return; | 415 return; |
| 411 } | 416 } |
| 412 } | 417 } |
| 413 | 418 |
| 414 if (!b) { | 419 if (!b) { |
| 415 debug_printf("Error, no such person\n"); | 420 debug_printf("Error, no such person\n"); |
| 416 return; | 421 return; |
| 417 } | 422 } |
| 418 | 423 |
| 419 /* This code will 'align' the name from the TOC */ | 424 /* This code will 'align' the name from the TOC */ |
| 420 /* server with what's in our record. We want to */ | 425 /* server with what's in our record. We want to */ |
| 421 /* store things how THEY want it... */ | 426 /* store things how THEY want it... */ |
| 422 if (strcmp(name, b->name)) { | 427 if (strcmp(name, b->name)) { |
| 423 GList *cnv = conversations; | 428 GList *cnv = conversations; |
| 424 struct conversation *cv; | 429 struct conversation *cv; |
| 425 | 430 |
| 426 char *who = g_malloc(80); | 431 char *who = g_malloc(80); |
| 427 | 432 |
| 428 strcpy(who, normalize(name)); | 433 strcpy(who, normalize(name)); |
| 429 | 434 |
| 430 while(cnv) { | 435 while (cnv) { |
| 431 cv = (struct conversation *)cnv->data; | 436 cv = (struct conversation *)cnv->data; |
| 432 if (!strcasecmp(who, normalize(cv->name))) { | 437 if (!strcasecmp(who, normalize(cv->name))) { |
| 433 g_snprintf(cv->name, sizeof(cv->name), "%s", name); | 438 g_snprintf(cv->name, sizeof(cv->name), "%s", name); |
| 434 if (find_log_info(name) || (general_options & OPT_GEN_LOG_ALL)) | 439 if (find_log_info(name) || (general_options & OPT_GEN_LOG_ALL)) |
| 435 g_snprintf(who, 63, LOG_CONVERSATION_TITLE, name); | 440 g_snprintf(who, 63, LOG_CONVERSATION_TITLE, name); |
| 436 else | 441 else |
| 437 g_snprintf(who, 63, CONVERSATION_TITLE, name); | 442 g_snprintf(who, 63, CONVERSATION_TITLE, name); |
| 438 gtk_window_set_title(GTK_WINDOW(cv->window), who); | 443 gtk_window_set_title(GTK_WINDOW(cv->window), who); |
| 439 /* was g_free(buf), but break gives us that | 444 /* was g_free(buf), but break gives us that |
| 440 * and freeing twice is not good --Sumner */ | 445 * and freeing twice is not good --Sumner */ |
| 441 break; | 446 break; |
| 442 } | 447 } |
| 443 cnv = cnv->next; | 448 cnv = cnv->next; |
| 444 } | 449 } |
| 445 g_free(who); | 450 g_free(who); |
| 446 g_snprintf(b->name, sizeof(b->name), "%s", name); | 451 g_snprintf(b->name, sizeof(b->name), "%s", name); |
| 447 /*gtk_label_set_text(GTK_LABEL(b->label), b->name);*/ | 452 /*gtk_label_set_text(GTK_LABEL(b->label), b->name); */ |
| 448 | 453 |
| 449 /* okay lets save the new config... */ | 454 /* okay lets save the new config... */ |
| 450 | 455 |
| 451 } | 456 } |
| 452 | 457 |
| 453 if (!b->idle && idle) plugin_event(event_buddy_idle, gc, b->name, 0, 0); | 458 if (!b->idle && idle) |
| 459 plugin_event(event_buddy_idle, gc, b->name, 0, 0); | |
| 454 if (b->idle && !idle) { | 460 if (b->idle && !idle) { |
| 455 do_pounce(b->name, OPT_POUNCE_UNIDLE); | 461 do_pounce(b->name, OPT_POUNCE_UNIDLE); |
| 456 plugin_event(event_buddy_unidle, gc, b->name, 0, 0); | 462 plugin_event(event_buddy_unidle, gc, b->name, 0, 0); |
| 457 } | 463 } |
| 458 | 464 |
| 459 b->idle = idle; | 465 b->idle = idle; |
| 460 b->evil = evil; | 466 b->evil = evil; |
| 461 | 467 |
| 462 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { | 468 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { |
| 463 do_pounce(b->name, OPT_POUNCE_UNAWAY); | 469 do_pounce(b->name, OPT_POUNCE_UNAWAY); |
| 464 plugin_event(event_buddy_back, gc, b->name, 0, 0); | 470 plugin_event(event_buddy_back, gc, b->name, 0, 0); |
| 465 } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) { | 471 } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) { |
| 466 plugin_event(event_buddy_away, gc, b->name, 0, 0); | 472 plugin_event(event_buddy_away, gc, b->name, 0, 0); |
| 467 } | 473 } |
| 468 | 474 |
| 469 b->uc = type; | 475 b->uc = type; |
| 470 if (caps) b->caps = caps; | 476 if (caps) |
| 471 | 477 b->caps = caps; |
| 472 b->signon = signon; | 478 |
| 473 | 479 b->signon = signon; |
| 474 if (loggedin) { | 480 |
| 475 if (!b->present) { | 481 if (loggedin) { |
| 476 b->present = 1; | 482 if (!b->present) { |
| 477 do_pounce(b->name, OPT_POUNCE_SIGNON); | 483 b->present = 1; |
| 484 do_pounce(b->name, OPT_POUNCE_SIGNON); | |
| 478 plugin_event(event_buddy_signon, gc, b->name, 0, 0); | 485 plugin_event(event_buddy_signon, gc, b->name, 0, 0); |
| 479 } | 486 } |
| 480 } else { | 487 } else { |
| 481 if (b->present) | 488 if (b->present) |
| 482 plugin_event(event_buddy_signoff, gc, b->name, 0, 0); | 489 plugin_event(event_buddy_signoff, gc, b->name, 0, 0); |
| 483 b->present = 0; | 490 b->present = 0; |
| 484 } | 491 } |
| 485 | 492 |
| 486 set_buddy(gc, b); | 493 set_buddy(gc, b); |
| 487 } | 494 } |
| 488 | 495 |
| 489 static | 496 static |
| 490 void close_warned(GtkWidget *w, GtkWidget *w2) | 497 void close_warned(GtkWidget *w, GtkWidget *w2) |
| 491 { | 498 { |
| 492 gtk_widget_destroy(w2); | 499 gtk_widget_destroy(w2); |
| 493 } | 500 } |
| 494 | 501 |
| 495 | 502 |
| 496 | 503 |
| 497 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) | 504 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) |
| 498 { | 505 { |
| 499 char *buf2 = g_malloc(1024); | 506 char *buf2 = g_malloc(1024); |
| 500 GtkWidget *d, *label, *close; | 507 GtkWidget *d, *label, *close; |
| 501 | 508 |
| 502 | 509 |
| 503 plugin_event(event_warned, gc, name, (void *)lev, 0); | 510 plugin_event(event_warned, gc, name, (void *)lev, 0); |
| 504 | 511 |
| 505 g_snprintf(buf2, 1023, "%s have just been warned by %s.\nYour new warning level is %d%%", | 512 g_snprintf(buf2, 1023, "%s have just been warned by %s.\nYour new warning level is %d%%", |
| 506 gc->username, ((name == NULL) ? "an anonymous person" : name) , lev); | 513 gc->username, ((name == NULL)? "an anonymous person" : name), lev); |
| 507 | 514 |
| 508 | 515 |
| 509 d = gtk_dialog_new(); | 516 d = gtk_dialog_new(); |
| 510 gtk_widget_realize(d); | 517 gtk_widget_realize(d); |
| 511 aol_icon(d->window); | 518 aol_icon(d->window); |
| 512 | 519 |
| 513 label = gtk_label_new(buf2); | 520 label = gtk_label_new(buf2); |
| 514 gtk_widget_show(label); | 521 gtk_widget_show(label); |
| 515 close = gtk_button_new_with_label("Close"); | 522 close = gtk_button_new_with_label("Close"); |
| 516 if (display_options & OPT_DISP_COOL_LOOK) | 523 if (display_options & OPT_DISP_COOL_LOOK) |
| 517 gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); | 524 gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); |
| 518 gtk_widget_show(close); | 525 gtk_widget_show(close); |
| 519 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | 526 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), label, FALSE, FALSE, 5); |
| 520 label, FALSE, FALSE, 5); | 527 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), close, FALSE, FALSE, 5); |
| 521 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | 528 |
| 522 close, FALSE, FALSE, 5); | 529 gtk_window_set_title(GTK_WINDOW(d), "Warned"); |
| 523 | 530 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_warned), d); |
| 524 gtk_window_set_title(GTK_WINDOW(d), "Warned"); | 531 gtk_widget_show(d); |
| 525 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_warned), d); | |
| 526 gtk_widget_show(d); | |
| 527 } | 532 } |
| 528 | 533 |
| 529 | 534 |
| 530 | 535 |
| 531 static void close_invite(GtkWidget *w, GtkWidget *w2) | 536 static void close_invite(GtkWidget *w, GtkWidget *w2) |
| 534 } | 539 } |
| 535 | 540 |
| 536 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) | 541 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) |
| 537 { | 542 { |
| 538 struct gaim_connection *g = (struct gaim_connection *) | 543 struct gaim_connection *g = (struct gaim_connection *) |
| 539 gtk_object_get_user_data(GTK_OBJECT(GTK_DIALOG(w2)->vbox)); | 544 gtk_object_get_user_data(GTK_OBJECT(GTK_DIALOG(w2)->vbox)); |
| 540 if (g->protocol == PROTO_TOC) { | 545 if (g->protocol == PROTO_TOC) { |
| 541 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); | 546 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); |
| 542 serv_accept_chat(g, i); | 547 serv_accept_chat(g, i); |
| 543 gtk_widget_destroy(w2); | 548 gtk_widget_destroy(w2); |
| 544 } else if (g->protocol == PROTO_OSCAR) { | 549 } else if (g->protocol == PROTO_OSCAR) { |
| 545 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); | 550 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); |
| 546 int id = (int)gtk_object_get_user_data(GTK_OBJECT(w)); | 551 int id = (int)gtk_object_get_user_data(GTK_OBJECT(w)); |
| 547 serv_join_chat(g, id, i); | 552 serv_join_chat(g, id, i); |
| 552 | 557 |
| 553 | 558 |
| 554 | 559 |
| 555 void serv_got_chat_invite(struct gaim_connection *g, char *name, int id, char *who, char *message) | 560 void serv_got_chat_invite(struct gaim_connection *g, char *name, int id, char *who, char *message) |
| 556 { | 561 { |
| 557 GtkWidget *d; | 562 GtkWidget *d; |
| 558 GtkWidget *label; | 563 GtkWidget *label; |
| 559 GtkWidget *yesbtn; | 564 GtkWidget *yesbtn; |
| 560 GtkWidget *nobtn; | 565 GtkWidget *nobtn; |
| 561 | 566 |
| 562 char buf2[BUF_LONG]; | 567 char buf2[BUF_LONG]; |
| 563 | 568 |
| 564 | 569 |
| 565 plugin_event(event_chat_invited, g, who, name, message); | 570 plugin_event(event_chat_invited, g, who, name, message); |
| 566 | 571 |
| 567 if (message) | 572 if (message) |
| 568 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n%s", who, g->username, name, message); | 573 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n%s", who, |
| 574 g->username, name, message); | |
| 569 else | 575 else |
| 570 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n", who, g->username, name); | 576 g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n", who, |
| 571 | 577 g->username, name); |
| 572 d = gtk_dialog_new(); | 578 |
| 573 gtk_widget_realize(d); | 579 d = gtk_dialog_new(); |
| 574 aol_icon(d->window); | 580 gtk_widget_realize(d); |
| 575 | 581 aol_icon(d->window); |
| 576 | 582 |
| 577 label = gtk_label_new(buf2); | 583 |
| 578 gtk_widget_show(label); | 584 label = gtk_label_new(buf2); |
| 579 yesbtn = picture_button(d, _("Yes"), ok_xpm); | 585 gtk_widget_show(label); |
| 580 nobtn = picture_button(d, _("No"), cancel_xpm); | 586 yesbtn = picture_button(d, _("Yes"), ok_xpm); |
| 581 gtk_widget_show(nobtn); | 587 nobtn = picture_button(d, _("No"), cancel_xpm); |
| 582 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | 588 gtk_widget_show(nobtn); |
| 583 label, FALSE, FALSE, 5); | 589 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), label, FALSE, FALSE, 5); |
| 584 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | 590 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), yesbtn, FALSE, FALSE, 5); |
| 585 yesbtn, FALSE, FALSE, 5); | 591 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), nobtn, FALSE, FALSE, 5); |
| 586 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
| 587 nobtn, FALSE, FALSE, 5); | |
| 588 | 592 |
| 589 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g); | 593 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g); |
| 590 if (g->protocol == PROTO_TOC) { | 594 if (g->protocol == PROTO_TOC) { |
| 591 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); | 595 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); |
| 592 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g); | 596 gtk_object_set_user_data(GTK_OBJECT(GTK_DIALOG(d)->vbox), g); |
| 593 } else if (g->protocol == PROTO_OSCAR) { | 597 } else if (g->protocol == PROTO_OSCAR) { |
| 594 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); | 598 gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); |
| 595 gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id); | 599 gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id); |
| 596 } | 600 } |
| 597 | 601 |
| 598 | 602 |
| 599 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); | 603 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); |
| 600 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); | 604 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); |
| 601 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); | 605 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); |
| 602 | 606 |
| 603 | 607 |
| 604 gtk_widget_show(d); | 608 gtk_widget_show(d); |
| 605 } | 609 } |
| 606 | 610 |
| 607 void serv_got_joined_chat(struct gaim_connection *gc, int id, char *name) | 611 void serv_got_joined_chat(struct gaim_connection *gc, int id, char *name) |
| 608 { | 612 { |
| 609 struct conversation *b; | 613 struct conversation *b; |
| 610 | 614 |
| 611 plugin_event(event_chat_join, gc, name, 0, 0); | 615 plugin_event(event_chat_join, gc, name, 0, 0); |
| 612 | 616 |
| 613 b = (struct conversation *)g_new0(struct conversation, 1); | 617 b = (struct conversation *)g_new0(struct conversation, 1); |
| 614 gc->buddy_chats = g_slist_append(gc->buddy_chats, b); | 618 gc->buddy_chats = g_slist_append(gc->buddy_chats, b); |
| 615 | 619 |
| 616 b->is_chat = TRUE; | 620 b->is_chat = TRUE; |
| 617 b->ignored = NULL; | 621 b->ignored = NULL; |
| 618 b->in_room = NULL; | 622 b->in_room = NULL; |
| 619 b->id = id; | 623 b->id = id; |
| 620 b->gc = gc; | 624 b->gc = gc; |
| 621 g_snprintf(b->name, 80, "%s", name); | 625 g_snprintf(b->name, 80, "%s", name); |
| 622 | 626 |
| 623 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) { | 627 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(b->name)) { |
| 624 FILE *fd; | 628 FILE *fd; |
| 625 char *filename; | 629 char *filename; |
| 626 | 630 |
| 627 filename = (char *)malloc(100); | 631 filename = (char *)malloc(100); |
| 628 g_snprintf(filename, 100, "%s.chat", b->name); | 632 g_snprintf(filename, 100, "%s.chat", b->name); |
| 629 | 633 |
| 630 fd = open_log_file(filename); | 634 fd = open_log_file(filename); |
| 631 if (!(general_options & OPT_GEN_STRIP_HTML)) | 635 if (!(general_options & OPT_GEN_STRIP_HTML)) |
| 632 fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", full_date()); | 636 fprintf(fd, |
| 637 "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", | |
| 638 full_date()); | |
| 633 else | 639 else |
| 634 fprintf(fd, "---- New Conversation @ %s ----\n", full_date()); | 640 fprintf(fd, "---- New Conversation @ %s ----\n", full_date()); |
| 635 | 641 |
| 636 fclose(fd); | 642 fclose(fd); |
| 637 free(filename); | 643 free(filename); |
| 638 } | 644 } |
| 639 | 645 |
| 640 show_new_buddy_chat(b); | 646 show_new_buddy_chat(b); |
| 641 } | 647 } |
| 642 | 648 |
| 643 void serv_got_chat_left(struct gaim_connection *g, int id) | 649 void serv_got_chat_left(struct gaim_connection *g, int id) |
| 644 { | 650 { |
| 645 GSList *bcs = g->buddy_chats; | 651 GSList *bcs = g->buddy_chats; |
| 646 struct conversation *b = NULL; | 652 struct conversation *b = NULL; |
| 647 | 653 |
| 648 | 654 |
| 649 while(bcs) { | 655 while (bcs) { |
| 650 b = (struct conversation *)bcs->data; | 656 b = (struct conversation *)bcs->data; |
| 651 if (id == b->id) { | 657 if (id == b->id) { |
| 652 break; | 658 break; |
| 653 } | 659 } |
| 654 b = NULL; | 660 b = NULL; |
| 655 bcs = bcs->next; | 661 bcs = bcs->next; |
| 656 } | 662 } |
| 657 | 663 |
| 658 if (!b) | 664 if (!b) |
| 659 return; | 665 return; |
| 660 | 666 |
| 661 plugin_event(event_chat_leave, g, b->name, 0, 0); | 667 plugin_event(event_chat_leave, g, b->name, 0, 0); |
| 662 | 668 |
| 663 debug_printf("Leaving room %s.\n", b->name); | 669 debug_printf("Leaving room %s.\n", b->name); |
| 664 | 670 |
| 665 g->buddy_chats = g_slist_remove(g->buddy_chats, b); | 671 g->buddy_chats = g_slist_remove(g->buddy_chats, b); |
| 666 | 672 |
| 667 while (b->in_room) { | 673 while (b->in_room) { |
| 668 char *tmp = b->in_room->data; | 674 char *tmp = b->in_room->data; |
| 669 b->in_room = g_list_remove(b->in_room, tmp); | 675 b->in_room = g_list_remove(b->in_room, tmp); |
| 670 g_free(tmp); | 676 g_free(tmp); |
| 671 } | 677 } |
| 672 | 678 |
| 673 g_free(b); | 679 g_free(b); |
| 674 } | 680 } |
| 675 | 681 |
| 676 void serv_got_chat_in(struct gaim_connection *g, int id, char *who, int whisper, char *message) | 682 void serv_got_chat_in(struct gaim_connection *g, int id, char *who, int whisper, char *message) |
| 677 { | 683 { |
| 678 int w; | 684 int w; |
| 679 GSList *bcs = g->buddy_chats; | 685 GSList *bcs = g->buddy_chats; |
| 680 struct conversation *b = NULL; | 686 struct conversation *b = NULL; |
| 681 | 687 |
| 682 while(bcs) { | 688 while (bcs) { |
| 683 b = (struct conversation *)bcs->data; | 689 b = (struct conversation *)bcs->data; |
| 684 if (id == b->id) | 690 if (id == b->id) |
| 685 break; | 691 break; |
| 686 bcs = bcs->next; | 692 bcs = bcs->next; |
| 687 b = NULL; | 693 b = NULL; |
| 688 | 694 |
| 689 } | 695 } |
| 690 if (!b) | 696 if (!b) |
| 691 return; | 697 return; |
| 692 | 698 |
| 693 if (plugin_event(event_chat_recv, g, b->name, who, message)) | 699 if (plugin_event(event_chat_recv, g, b->name, who, message)) |
| 694 return; | 700 return; |
| 695 | 701 |
| 696 if (whisper) | 702 if (whisper) |
| 697 w = WFLAG_WHISPER; | 703 w = WFLAG_WHISPER; |
| 698 else | 704 else |
| 699 w = 0; | 705 w = 0; |
| 700 | 706 |
| 701 chat_write(b, who, w, message); | 707 chat_write(b, who, w, message); |
| 702 } | 708 } |
| 703 | 709 |
| 704 void send_keepalive(gpointer d) { | 710 void send_keepalive(gpointer d) |
| 711 { | |
| 705 struct gaim_connection *gc = (struct gaim_connection *)d; | 712 struct gaim_connection *gc = (struct gaim_connection *)d; |
| 706 if (gc->prpl && gc->prpl->keepalive) | 713 if (gc->prpl && gc->prpl->keepalive) |
| 707 (*gc->prpl->keepalive)(gc); | 714 (*gc->prpl->keepalive)(gc); |
| 708 } | 715 } |
| 709 | 716 |
| 710 void update_keepalive(struct gaim_connection *gc, gboolean on) { | 717 void update_keepalive(struct gaim_connection *gc, gboolean on) |
| 718 { | |
| 711 if (on && !gc->keepalive && blist) { | 719 if (on && !gc->keepalive && blist) { |
| 712 debug_printf("allowing NOP\n"); | 720 debug_printf("allowing NOP\n"); |
| 713 gc->keepalive = gtk_timeout_add(60000, (GtkFunction)send_keepalive, gc); | 721 gc->keepalive = gtk_timeout_add(60000, (GtkFunction)send_keepalive, gc); |
| 714 } else if (!on && gc->keepalive > 0) { | 722 } else if (!on && gc->keepalive > 0) { |
| 715 debug_printf("removing NOP\n"); | 723 debug_printf("removing NOP\n"); |
