| 250 gaim_signal_emit(gaim_conversations_get_handle(), |
250 gaim_signal_emit(gaim_conversations_get_handle(), |
| 251 (type == GAIM_CONV_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
251 (type == GAIM_CONV_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
| 252 gaim_conversation_get_account(conv), conv, buffy); |
252 gaim_conversation_get_account(conv), conv, buffy); |
| 253 |
253 |
| 254 if (type == GAIM_CONV_IM) { |
254 if (type == GAIM_CONV_IM) { |
| 255 GaimIm *im = GAIM_IM(conv); |
255 GaimConvIm *im = GAIM_CONV_IM(conv); |
| 256 |
256 |
| 257 buffy = g_strdup(buf); |
257 buffy = g_strdup(buf); |
| 258 gaim_signal_emit(gaim_conversations_get_handle(), "sending-im-msg", |
258 gaim_signal_emit(gaim_conversations_get_handle(), "sending-im-msg", |
| 259 gaim_conversation_get_account(conv), |
259 gaim_conversation_get_account(conv), |
| 260 gaim_conversation_get_name(conv), &buffy); |
260 gaim_conversation_get_name(conv), &buffy); |
| 261 |
261 |
| 262 if (buffy != NULL) { |
262 if (buffy != NULL) { |
| 263 GaimImFlags imflags = 0; |
263 GaimConvImFlags imflags = 0; |
| 264 GaimMessageFlags msgflags = GAIM_MESSAGE_SEND; |
264 GaimMessageFlags msgflags = GAIM_MESSAGE_SEND; |
| 265 |
265 |
| 266 if (im->images != NULL) { |
266 if (im->images != NULL) { |
| 267 imflags |= GAIM_IM_IMAGES; |
267 imflags |= GAIM_CONV_IM_IMAGES; |
| 268 msgflags |= GAIM_MESSAGE_IMAGES; |
268 msgflags |= GAIM_MESSAGE_IMAGES; |
| 269 } |
269 } |
| 270 |
270 |
| 271 err = serv_send_im(gc, gaim_conversation_get_name(conv), |
271 err = serv_send_im(gc, gaim_conversation_get_name(conv), |
| 272 buffy, imflags); |
272 buffy, imflags); |
| 273 |
273 |
| 274 if (err > 0) |
274 if (err > 0) |
| 275 gaim_im_write(im, NULL, buf, msgflags, time(NULL)); |
275 gaim_conv_im_write(im, NULL, buf, msgflags, time(NULL)); |
| 276 |
276 |
| 277 if (im->images != NULL) { |
277 if (im->images != NULL) { |
| 278 GSList *tempy; |
278 GSList *tempy; |
| 279 int image; |
279 int image; |
| 280 |
280 |
| 378 |
378 |
| 379 return win; |
379 return win; |
| 380 } |
380 } |
| 381 |
381 |
| 382 void |
382 void |
| 383 gaim_window_destroy(GaimWindow *win) |
383 gaim_conv_window_destroy(GaimConvWindow *win) |
| 384 { |
384 { |
| 385 GaimWindowUiOps *ops; |
385 GaimConvWindowUiOps *ops; |
| 386 GList *node; |
386 GList *node; |
| 387 |
387 |
| 388 g_return_if_fail(win != NULL); |
388 g_return_if_fail(win != NULL); |
| 389 |
389 |
| 390 ops = gaim_window_get_ui_ops(win); |
390 ops = gaim_conv_window_get_ui_ops(win); |
| 391 |
391 |
| 392 /* |
392 /* |
| 393 * If there are any conversations in this, destroy them all. The last |
393 * If there are any conversations in this, destroy them all. The last |
| 394 * conversation will call gaim_window_destroy(), but this time, this |
394 * conversation will call gaim_conv_window_destroy(), but this time, this |
| 395 * check will fail and the window will actually be destroyed. |
395 * check will fail and the window will actually be destroyed. |
| 396 * |
396 * |
| 397 * This is needed because chats may not close right away. They may |
397 * This is needed because chats may not close right away. They may |
| 398 * wait for notification first. When they get that, the window is |
398 * wait for notification first. When they get that, the window is |
| 399 * already destroyed, and gaim either crashes or spits out gtk warnings. |
399 * already destroyed, and gaim either crashes or spits out gtk warnings. |
| 400 * The problem is fixed with this check. |
400 * The problem is fixed with this check. |
| 401 */ |
401 */ |
| 402 if (gaim_window_get_conversation_count(win) > 0) { |
402 if (gaim_conv_window_get_conversation_count(win) > 0) { |
| 403 |
403 |
| 404 node = g_list_first(gaim_window_get_conversations(win)); |
404 node = g_list_first(gaim_conv_window_get_conversations(win)); |
| 405 while(node != NULL) |
405 while(node != NULL) |
| 406 { |
406 { |
| 407 GaimConversation *conv = node->data; |
407 GaimConversation *conv = node->data; |
| 408 |
408 |
| 409 node = g_list_next(node); |
409 node = g_list_next(node); |
| 414 else |
414 else |
| 415 { |
415 { |
| 416 if (ops != NULL && ops->destroy_window != NULL) |
416 if (ops != NULL && ops->destroy_window != NULL) |
| 417 ops->destroy_window(win); |
417 ops->destroy_window(win); |
| 418 |
418 |
| 419 g_list_free(gaim_window_get_conversations(win)); |
419 g_list_free(gaim_conv_window_get_conversations(win)); |
| 420 |
420 |
| 421 windows = g_list_remove(windows, win); |
421 windows = g_list_remove(windows, win); |
| 422 |
422 |
| 423 g_free(win); |
423 g_free(win); |
| 424 } |
424 } |
| 425 } |
425 } |
| 426 |
426 |
| 427 void |
427 void |
| 428 gaim_window_show(GaimWindow *win) |
428 gaim_conv_window_show(GaimConvWindow *win) |
| 429 { |
429 { |
| 430 GaimWindowUiOps *ops; |
430 GaimConvWindowUiOps *ops; |
| 431 |
431 |
| 432 g_return_if_fail(win != NULL); |
432 g_return_if_fail(win != NULL); |
| 433 |
433 |
| 434 ops = gaim_window_get_ui_ops(win); |
434 ops = gaim_conv_window_get_ui_ops(win); |
| 435 |
435 |
| 436 if (ops == NULL || ops->show == NULL) |
436 if (ops == NULL || ops->show == NULL) |
| 437 return; |
437 return; |
| 438 |
438 |
| 439 ops->show(win); |
439 ops->show(win); |
| 440 } |
440 } |
| 441 |
441 |
| 442 void |
442 void |
| 443 gaim_window_hide(GaimWindow *win) |
443 gaim_conv_window_hide(GaimConvWindow *win) |
| 444 { |
444 { |
| 445 GaimWindowUiOps *ops; |
445 GaimConvWindowUiOps *ops; |
| 446 |
446 |
| 447 g_return_if_fail(win != NULL); |
447 g_return_if_fail(win != NULL); |
| 448 |
448 |
| 449 ops = gaim_window_get_ui_ops(win); |
449 ops = gaim_conv_window_get_ui_ops(win); |
| 450 |
450 |
| 451 if (ops == NULL || ops->hide == NULL) |
451 if (ops == NULL || ops->hide == NULL) |
| 452 return; |
452 return; |
| 453 |
453 |
| 454 ops->hide(win); |
454 ops->hide(win); |
| 455 } |
455 } |
| 456 |
456 |
| 457 void |
457 void |
| 458 gaim_window_raise(GaimWindow *win) |
458 gaim_conv_window_raise(GaimConvWindow *win) |
| 459 { |
459 { |
| 460 GaimWindowUiOps *ops; |
460 GaimConvWindowUiOps *ops; |
| 461 |
461 |
| 462 g_return_if_fail(win != NULL); |
462 g_return_if_fail(win != NULL); |
| 463 |
463 |
| 464 ops = gaim_window_get_ui_ops(win); |
464 ops = gaim_conv_window_get_ui_ops(win); |
| 465 |
465 |
| 466 if (ops == NULL || ops->raise == NULL) |
466 if (ops == NULL || ops->raise == NULL) |
| 467 return; |
467 return; |
| 468 |
468 |
| 469 ops->raise(win); |
469 ops->raise(win); |
| 470 } |
470 } |
| 471 |
471 |
| 472 void |
472 void |
| 473 gaim_window_flash(GaimWindow *win) |
473 gaim_conv_window_flash(GaimConvWindow *win) |
| 474 { |
474 { |
| 475 GaimWindowUiOps *ops; |
475 GaimConvWindowUiOps *ops; |
| 476 |
476 |
| 477 g_return_if_fail(win != NULL); |
477 g_return_if_fail(win != NULL); |
| 478 |
478 |
| 479 ops = gaim_window_get_ui_ops(win); |
479 ops = gaim_conv_window_get_ui_ops(win); |
| 480 |
480 |
| 481 if (ops == NULL || ops->flash == NULL) |
481 if (ops == NULL || ops->flash == NULL) |
| 482 return; |
482 return; |
| 483 |
483 |
| 484 ops->flash(win); |
484 ops->flash(win); |
| 485 } |
485 } |
| 486 |
486 |
| 487 void |
487 void |
| 488 gaim_window_set_ui_ops(GaimWindow *win, GaimWindowUiOps *ops) |
488 gaim_conv_window_set_ui_ops(GaimConvWindow *win, GaimConvWindowUiOps *ops) |
| 489 { |
489 { |
| 490 GaimConversationUiOps *conv_ops = NULL; |
490 GaimConversationUiOps *conv_ops = NULL; |
| 491 GList *l; |
491 GList *l; |
| 492 |
492 |
| 493 g_return_if_fail(win != NULL); |
493 g_return_if_fail(win != NULL); |
| 517 if (win->ui_ops != NULL && win->ui_ops->add_conversation != NULL) |
517 if (win->ui_ops != NULL && win->ui_ops->add_conversation != NULL) |
| 518 win->ui_ops->add_conversation(win, conv); |
518 win->ui_ops->add_conversation(win, conv); |
| 519 } |
519 } |
| 520 } |
520 } |
| 521 |
521 |
| 522 GaimWindowUiOps * |
522 GaimConvWindowUiOps * |
| 523 gaim_window_get_ui_ops(const GaimWindow *win) |
523 gaim_conv_window_get_ui_ops(const GaimConvWindow *win) |
| 524 { |
524 { |
| 525 g_return_val_if_fail(win != NULL, NULL); |
525 g_return_val_if_fail(win != NULL, NULL); |
| 526 |
526 |
| 527 return win->ui_ops; |
527 return win->ui_ops; |
| 528 } |
528 } |
| 529 |
529 |
| 530 int |
530 int |
| 531 gaim_window_add_conversation(GaimWindow *win, GaimConversation *conv) |
531 gaim_conv_window_add_conversation(GaimConvWindow *win, GaimConversation *conv) |
| 532 { |
532 { |
| 533 GaimWindowUiOps *ops; |
533 GaimConvWindowUiOps *ops; |
| 534 |
534 |
| 535 g_return_val_if_fail(win != NULL, -1); |
535 g_return_val_if_fail(win != NULL, -1); |
| 536 g_return_val_if_fail(conv != NULL, -1); |
536 g_return_val_if_fail(conv != NULL, -1); |
| 537 |
537 |
| 538 if (gaim_conversation_get_window(conv) != NULL) { |
538 if (gaim_conversation_get_window(conv) != NULL) { |
| 539 gaim_window_remove_conversation( |
539 gaim_conv_window_remove_conversation( |
| 540 gaim_conversation_get_window(conv), |
540 gaim_conversation_get_window(conv), |
| 541 gaim_conversation_get_index(conv)); |
541 gaim_conversation_get_index(conv)); |
| 542 } |
542 } |
| 543 |
543 |
| 544 ops = gaim_window_get_ui_ops(win); |
544 ops = gaim_conv_window_get_ui_ops(win); |
| 545 |
545 |
| 546 win->conversations = g_list_append(win->conversations, conv); |
546 win->conversations = g_list_append(win->conversations, conv); |
| 547 win->conversation_count++; |
547 win->conversation_count++; |
| 548 |
548 |
| 549 conv->conversation_pos = win->conversation_count - 1; |
549 conv->conversation_pos = win->conversation_count - 1; |
| 585 |
585 |
| 586 win->conversation_count--; |
586 win->conversation_count--; |
| 587 |
587 |
| 588 conv->window = NULL; |
588 conv->window = NULL; |
| 589 |
589 |
| 590 if (gaim_window_get_conversation_count(win) == 0) |
590 if (gaim_conv_window_get_conversation_count(win) == 0) |
| 591 gaim_window_destroy(win); |
591 gaim_conv_window_destroy(win); |
| 592 else { |
592 else { |
| 593 /* Change all the indexes. */ |
593 /* Change all the indexes. */ |
| 594 update_conv_indexes(win); |
594 update_conv_indexes(win); |
| 595 } |
595 } |
| 596 |
596 |
| 597 return conv; |
597 return conv; |
| 598 } |
598 } |
| 599 |
599 |
| 600 void |
600 void |
| 601 gaim_window_move_conversation(GaimWindow *win, unsigned int index, |
601 gaim_conv_window_move_conversation(GaimConvWindow *win, unsigned int index, |
| 602 unsigned int new_index) |
602 unsigned int new_index) |
| 603 { |
603 { |
| 604 GaimWindowUiOps *ops; |
604 GaimConvWindowUiOps *ops; |
| 605 GaimConversation *conv; |
605 GaimConversation *conv; |
| 606 GList *l; |
606 GList *l; |
| 607 |
607 |
| 608 g_return_if_fail(win != NULL); |
608 g_return_if_fail(win != NULL); |
| 609 g_return_if_fail(index < gaim_window_get_conversation_count(win)); |
609 g_return_if_fail(index < gaim_conv_window_get_conversation_count(win)); |
| 610 g_return_if_fail(index != new_index); |
610 g_return_if_fail(index != new_index); |
| 611 |
611 |
| 612 /* We can't move this past the last index. */ |
612 /* We can't move this past the last index. */ |
| 613 if (new_index > gaim_window_get_conversation_count(win)) |
613 if (new_index > gaim_conv_window_get_conversation_count(win)) |
| 614 new_index = gaim_window_get_conversation_count(win); |
614 new_index = gaim_conv_window_get_conversation_count(win); |
| 615 |
615 |
| 616 /* Get the list item for this conversation at its current index. */ |
616 /* Get the list item for this conversation at its current index. */ |
| 617 l = g_list_nth(gaim_window_get_conversations(win), index); |
617 l = g_list_nth(gaim_conv_window_get_conversations(win), index); |
| 618 |
618 |
| 619 if (l == NULL) { |
619 if (l == NULL) { |
| 620 /* Should never happen. */ |
620 /* Should never happen. */ |
| 621 gaim_debug(GAIM_DEBUG_ERROR, "conversation", |
621 gaim_debug(GAIM_DEBUG_ERROR, "conversation", |
| 622 "Misordered conversations list in window %p\n", win); |
622 "Misordered conversations list in window %p\n", win); |
| 643 |
643 |
| 644 update_conv_indexes(win); |
644 update_conv_indexes(win); |
| 645 } |
645 } |
| 646 |
646 |
| 647 GaimConversation * |
647 GaimConversation * |
| 648 gaim_window_get_conversation_at(const GaimWindow *win, unsigned int index) |
648 gaim_conv_window_get_conversation_at(const GaimConvWindow *win, unsigned int index) |
| 649 { |
649 { |
| 650 g_return_val_if_fail(win != NULL, NULL); |
650 g_return_val_if_fail(win != NULL, NULL); |
| 651 g_return_val_if_fail(index >= 0 && |
651 g_return_val_if_fail(index >= 0 && |
| 652 index < gaim_window_get_conversation_count(win), |
652 index < gaim_conv_window_get_conversation_count(win), |
| 653 NULL); |
653 NULL); |
| 654 |
654 |
| 655 return (GaimConversation *)g_list_nth_data( |
655 return (GaimConversation *)g_list_nth_data( |
| 656 gaim_window_get_conversations(win), index); |
656 gaim_conv_window_get_conversations(win), index); |
| 657 } |
657 } |
| 658 |
658 |
| 659 size_t |
659 size_t |
| 660 gaim_window_get_conversation_count(const GaimWindow *win) |
660 gaim_conv_window_get_conversation_count(const GaimConvWindow *win) |
| 661 { |
661 { |
| 662 g_return_val_if_fail(win != NULL, 0); |
662 g_return_val_if_fail(win != NULL, 0); |
| 663 |
663 |
| 664 return win->conversation_count; |
664 return win->conversation_count; |
| 665 } |
665 } |
| 666 |
666 |
| 667 void |
667 void |
| 668 gaim_window_switch_conversation(GaimWindow *win, unsigned int index) |
668 gaim_conv_window_switch_conversation(GaimConvWindow *win, unsigned int index) |
| 669 { |
669 { |
| 670 GaimWindowUiOps *ops; |
670 GaimConvWindowUiOps *ops; |
| 671 GaimConversation *old_conv, *conv; |
671 GaimConversation *old_conv, *conv; |
| 672 |
672 |
| 673 g_return_if_fail(win != NULL); |
673 g_return_if_fail(win != NULL); |
| 674 g_return_if_fail(index >= 0 && |
674 g_return_if_fail(index >= 0 && |
| 675 index < gaim_window_get_conversation_count(win)); |
675 index < gaim_conv_window_get_conversation_count(win)); |
| 676 |
676 |
| 677 old_conv = gaim_window_get_active_conversation(win); |
677 old_conv = gaim_conv_window_get_active_conversation(win); |
| 678 conv = gaim_window_get_conversation_at(win, index); |
678 conv = gaim_conv_window_get_conversation_at(win, index); |
| 679 |
679 |
| 680 gaim_signal_emit(gaim_conversations_get_handle(), |
680 gaim_signal_emit(gaim_conversations_get_handle(), |
| 681 "conversation-switching", old_conv, conv); |
681 "conversation-switching", old_conv, conv); |
| 682 |
682 |
| 683 ops = gaim_window_get_ui_ops(win); |
683 ops = gaim_conv_window_get_ui_ops(win); |
| 684 |
684 |
| 685 if (ops != NULL && ops->switch_conversation != NULL) |
685 if (ops != NULL && ops->switch_conversation != NULL) |
| 686 ops->switch_conversation(win, index); |
686 ops->switch_conversation(win, index); |
| 687 |
687 |
| 688 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); |
688 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); |
| 1491 if (im->icon != NULL) |
1491 if (im->icon != NULL) |
| 1492 gaim_buddy_icon_unref(im->icon); |
1492 gaim_buddy_icon_unref(im->icon); |
| 1493 |
1493 |
| 1494 im->icon = (icon == NULL ? NULL : gaim_buddy_icon_ref(icon)); |
1494 im->icon = (icon == NULL ? NULL : gaim_buddy_icon_ref(icon)); |
| 1495 |
1495 |
| 1496 gaim_conversation_update(gaim_im_get_conversation(im), |
1496 gaim_conversation_update(gaim_conv_im_get_conversation(im), |
| 1497 GAIM_CONV_UPDATE_ICON); |
1497 GAIM_CONV_UPDATE_ICON); |
| 1498 } |
1498 } |
| 1499 |
1499 |
| 1500 GaimBuddyIcon * |
1500 GaimBuddyIcon * |
| 1501 gaim_im_get_icon(const GaimIm *im) |
1501 gaim_conv_im_get_icon(const GaimConvIm *im) |
| 1502 { |
1502 { |
| 1503 g_return_val_if_fail(im != NULL, NULL); |
1503 g_return_val_if_fail(im != NULL, NULL); |
| 1504 |
1504 |
| 1505 return im->icon; |
1505 return im->icon; |
| 1506 } |
1506 } |
| 1507 |
1507 |
| 1508 void |
1508 void |
| 1509 gaim_im_set_typing_state(GaimIm *im, int state) |
1509 gaim_conv_im_set_typing_state(GaimConvIm *im, int state) |
| 1510 { |
1510 { |
| 1511 g_return_if_fail(im != NULL); |
1511 g_return_if_fail(im != NULL); |
| 1512 |
1512 |
| 1513 im->typing_state = state; |
1513 im->typing_state = state; |
| 1514 } |
1514 } |
| 1515 |
1515 |
| 1516 int |
1516 int |
| 1517 gaim_im_get_typing_state(const GaimIm *im) |
1517 gaim_conv_im_get_typing_state(const GaimConvIm *im) |
| 1518 { |
1518 { |
| 1519 g_return_val_if_fail(im != NULL, 0); |
1519 g_return_val_if_fail(im != NULL, 0); |
| 1520 |
1520 |
| 1521 return im->typing_state; |
1521 return im->typing_state; |
| 1522 } |
1522 } |
| 1523 |
1523 |
| 1524 void |
1524 void |
| 1525 gaim_im_start_typing_timeout(GaimIm *im, int timeout) |
1525 gaim_conv_im_start_typing_timeout(GaimConvIm *im, int timeout) |
| 1526 { |
1526 { |
| 1527 GaimConversation *conv; |
1527 GaimConversation *conv; |
| 1528 const char *name; |
1528 const char *name; |
| 1529 |
1529 |
| 1530 g_return_if_fail(im != NULL); |
1530 g_return_if_fail(im != NULL); |
| 1531 |
1531 |
| 1532 if (im->typing_timeout > 0) |
1532 if (im->typing_timeout > 0) |
| 1533 gaim_im_stop_typing_timeout(im); |
1533 gaim_conv_im_stop_typing_timeout(im); |
| 1534 |
1534 |
| 1535 conv = gaim_im_get_conversation(im); |
1535 conv = gaim_conv_im_get_conversation(im); |
| 1536 name = gaim_conversation_get_name(conv); |
1536 name = gaim_conversation_get_name(conv); |
| 1537 |
1537 |
| 1538 im->typing_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, |
1538 im->typing_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, |
| 1539 timeout * 1000, reset_typing, conv, NULL); |
1539 timeout * 1000, reset_typing, conv, NULL); |
| 1540 } |
1540 } |
| 1541 |
1541 |
| 1542 void |
1542 void |
| 1543 gaim_im_stop_typing_timeout(GaimIm *im) |
1543 gaim_conv_im_stop_typing_timeout(GaimConvIm *im) |
| 1544 { |
1544 { |
| 1545 g_return_if_fail(im != NULL); |
1545 g_return_if_fail(im != NULL); |
| 1546 |
1546 |
| 1547 if (im->typing_timeout == 0) |
1547 if (im->typing_timeout == 0) |
| 1548 return; |
1548 return; |
| 1550 g_source_remove(im->typing_timeout); |
1550 g_source_remove(im->typing_timeout); |
| 1551 im->typing_timeout = 0; |
1551 im->typing_timeout = 0; |
| 1552 } |
1552 } |
| 1553 |
1553 |
| 1554 guint |
1554 guint |
| 1555 gaim_im_get_typing_timeout(const GaimIm *im) |
1555 gaim_conv_im_get_typing_timeout(const GaimConvIm *im) |
| 1556 { |
1556 { |
| 1557 g_return_val_if_fail(im != NULL, 0); |
1557 g_return_val_if_fail(im != NULL, 0); |
| 1558 |
1558 |
| 1559 return im->typing_timeout; |
1559 return im->typing_timeout; |
| 1560 } |
1560 } |
| 1561 |
1561 |
| 1562 void |
1562 void |
| 1563 gaim_im_set_type_again(GaimIm *im, time_t val) |
1563 gaim_conv_im_set_type_again(GaimConvIm *im, time_t val) |
| 1564 { |
1564 { |
| 1565 g_return_if_fail(im != NULL); |
1565 g_return_if_fail(im != NULL); |
| 1566 |
1566 |
| 1567 im->type_again = val; |
1567 im->type_again = val; |
| 1568 } |
1568 } |
| 1569 |
1569 |
| 1570 time_t |
1570 time_t |
| 1571 gaim_im_get_type_again(const GaimIm *im) |
1571 gaim_conv_im_get_type_again(const GaimConvIm *im) |
| 1572 { |
1572 { |
| 1573 g_return_val_if_fail(im != NULL, 0); |
1573 g_return_val_if_fail(im != NULL, 0); |
| 1574 |
1574 |
| 1575 return im->type_again; |
1575 return im->type_again; |
| 1576 } |
1576 } |
| 1577 |
1577 |
| 1578 void |
1578 void |
| 1579 gaim_im_start_type_again_timeout(GaimIm *im) |
1579 gaim_conv_im_start_type_again_timeout(GaimConvIm *im) |
| 1580 { |
1580 { |
| 1581 g_return_if_fail(im != NULL); |
1581 g_return_if_fail(im != NULL); |
| 1582 |
1582 |
| 1583 im->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed, |
1583 im->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed, |
| 1584 gaim_im_get_conversation(im)); |
1584 gaim_conv_im_get_conversation(im)); |
| 1585 } |
1585 } |
| 1586 |
1586 |
| 1587 void |
1587 void |
| 1588 gaim_im_stop_type_again_timeout(GaimIm *im) |
1588 gaim_conv_im_stop_type_again_timeout(GaimConvIm *im) |
| 1589 { |
1589 { |
| 1590 g_return_if_fail(im != NULL); |
1590 g_return_if_fail(im != NULL); |
| 1591 |
1591 |
| 1592 if (im->type_again_timeout == 0) |
1592 if (im->type_again_timeout == 0) |
| 1593 return; |
1593 return; |
| 1595 g_source_remove(im->type_again_timeout); |
1595 g_source_remove(im->type_again_timeout); |
| 1596 im->type_again_timeout = 0; |
1596 im->type_again_timeout = 0; |
| 1597 } |
1597 } |
| 1598 |
1598 |
| 1599 guint |
1599 guint |
| 1600 gaim_im_get_type_again_timeout(const GaimIm *im) |
1600 gaim_conv_im_get_type_again_timeout(const GaimConvIm *im) |
| 1601 { |
1601 { |
| 1602 g_return_val_if_fail(im != NULL, 0); |
1602 g_return_val_if_fail(im != NULL, 0); |
| 1603 |
1603 |
| 1604 return im->type_again_timeout; |
1604 return im->type_again_timeout; |
| 1605 } |
1605 } |
| 1606 |
1606 |
| 1607 void |
1607 void |
| 1608 gaim_im_update_typing(GaimIm *im) |
1608 gaim_conv_im_update_typing(GaimConvIm *im) |
| 1609 { |
1609 { |
| 1610 g_return_if_fail(im != NULL); |
1610 g_return_if_fail(im != NULL); |
| 1611 |
1611 |
| 1612 gaim_conversation_update(gaim_im_get_conversation(im), |
1612 gaim_conversation_update(gaim_conv_im_get_conversation(im), |
| 1613 GAIM_CONV_UPDATE_TYPING); |
1613 GAIM_CONV_UPDATE_TYPING); |
| 1614 } |
1614 } |
| 1615 |
1615 |
| 1616 void |
1616 void |
| 1617 gaim_im_write(GaimIm *im, const char *who, const char *message, |
1617 gaim_conv_im_write(GaimConvIm *im, const char *who, const char *message, |
| 1618 GaimMessageFlags flags, time_t mtime) |
1618 GaimMessageFlags flags, time_t mtime) |
| 1619 { |
1619 { |
| 1620 GaimConversation *c; |
1620 GaimConversation *c; |
| 1621 |
1621 |
| 1622 g_return_if_fail(im != NULL); |
1622 g_return_if_fail(im != NULL); |
| 1623 g_return_if_fail(message != NULL); |
1623 g_return_if_fail(message != NULL); |
| 1624 |
1624 |
| 1625 c = gaim_im_get_conversation(im); |
1625 c = gaim_conv_im_get_conversation(im); |
| 1626 |
1626 |
| 1627 /* Raise the window, if specified in prefs. */ |
1627 /* Raise the window, if specified in prefs. */ |
| 1628 if (c->ui_ops != NULL && c->ui_ops->write_im != NULL) |
1628 if (c->ui_ops != NULL && c->ui_ops->write_im != NULL) |
| 1629 c->ui_ops->write_im(c, who, message, flags, mtime); |
1629 c->ui_ops->write_im(c, who, message, flags, mtime); |
| 1630 else |
1630 else |
| 1631 gaim_conversation_write(c, who, message, flags, mtime); |
1631 gaim_conversation_write(c, who, message, flags, mtime); |
| 1632 } |
1632 } |
| 1633 |
1633 |
| 1634 void |
1634 void |
| 1635 gaim_im_send(GaimIm *im, const char *message) |
1635 gaim_conv_im_send(GaimConvIm *im, const char *message) |
| 1636 { |
1636 { |
| 1637 g_return_if_fail(im != NULL); |
1637 g_return_if_fail(im != NULL); |
| 1638 g_return_if_fail(message != NULL); |
1638 g_return_if_fail(message != NULL); |
| 1639 |
1639 |
| 1640 common_send(gaim_im_get_conversation(im), message); |
1640 common_send(gaim_conv_im_get_conversation(im), message); |
| 1641 } |
1641 } |
| 1642 |
1642 |
| 1643 /************************************************************************** |
1643 /************************************************************************** |
| 1644 * Chat Conversation API |
1644 * Chat Conversation API |
| 1645 **************************************************************************/ |
1645 **************************************************************************/ |
| 1646 |
1646 |
| 1647 GaimConversation * |
1647 GaimConversation * |
| 1648 gaim_chat_get_conversation(const GaimChat *chat) |
1648 gaim_conv_chat_get_conversation(const GaimConvChat *chat) |
| 1649 { |
1649 { |
| 1650 g_return_val_if_fail(chat != NULL, NULL); |
1650 g_return_val_if_fail(chat != NULL, NULL); |
| 1651 |
1651 |
| 1652 return chat->conv; |
1652 return chat->conv; |
| 1653 } |
1653 } |
| 1654 |
1654 |
| 1655 GList * |
1655 GList * |
| 1656 gaim_chat_set_users(GaimChat *chat, GList *users) |
1656 gaim_conv_chat_set_users(GaimConvChat *chat, GList *users) |
| 1657 { |
1657 { |
| 1658 g_return_val_if_fail(chat != NULL, NULL); |
1658 g_return_val_if_fail(chat != NULL, NULL); |
| 1659 |
1659 |
| 1660 chat->in_room = users; |
1660 chat->in_room = users; |
| 1661 |
1661 |
| 1662 return users; |
1662 return users; |
| 1663 } |
1663 } |
| 1664 |
1664 |
| 1665 GList * |
1665 GList * |
| 1666 gaim_chat_get_users(const GaimChat *chat) |
1666 gaim_conv_chat_get_users(const GaimConvChat *chat) |
| 1667 { |
1667 { |
| 1668 g_return_val_if_fail(chat != NULL, NULL); |
1668 g_return_val_if_fail(chat != NULL, NULL); |
| 1669 |
1669 |
| 1670 return chat->in_room; |
1670 return chat->in_room; |
| 1671 } |
1671 } |
| 1672 |
1672 |
| 1673 void |
1673 void |
| 1674 gaim_chat_ignore(GaimChat *chat, const char *name) |
1674 gaim_conv_chat_ignore(GaimConvChat *chat, const char *name) |
| 1675 { |
1675 { |
| 1676 g_return_if_fail(chat != NULL); |
1676 g_return_if_fail(chat != NULL); |
| 1677 g_return_if_fail(name != NULL); |
1677 g_return_if_fail(name != NULL); |
| 1678 |
1678 |
| 1679 /* Make sure the user isn't already ignored. */ |
1679 /* Make sure the user isn't already ignored. */ |
| 1680 if (gaim_chat_is_user_ignored(chat, name)) |
1680 if (gaim_conv_chat_is_user_ignored(chat, name)) |
| 1681 return; |
1681 return; |
| 1682 |
1682 |
| 1683 gaim_chat_set_ignored(chat, |
1683 gaim_conv_chat_set_ignored(chat, |
| 1684 g_list_append(gaim_chat_get_ignored(chat), g_strdup(name))); |
1684 g_list_append(gaim_conv_chat_get_ignored(chat), g_strdup(name))); |
| 1685 } |
1685 } |
| 1686 |
1686 |
| 1687 void |
1687 void |
| 1688 gaim_chat_unignore(GaimChat *chat, const char *name) |
1688 gaim_conv_chat_unignore(GaimConvChat *chat, const char *name) |
| 1689 { |
1689 { |
| 1690 GList *item; |
1690 GList *item; |
| 1691 |
1691 |
| 1692 g_return_if_fail(chat != NULL); |
1692 g_return_if_fail(chat != NULL); |
| 1693 g_return_if_fail(name != NULL); |
1693 g_return_if_fail(name != NULL); |
| 1694 |
1694 |
| 1695 /* Make sure the user is actually ignored. */ |
1695 /* Make sure the user is actually ignored. */ |
| 1696 if (!gaim_chat_is_user_ignored(chat, name)) |
1696 if (!gaim_conv_chat_is_user_ignored(chat, name)) |
| 1697 return; |
1697 return; |
| 1698 |
1698 |
| 1699 item = g_list_find(gaim_chat_get_ignored(chat), |
1699 item = g_list_find(gaim_conv_chat_get_ignored(chat), |
| 1700 gaim_chat_get_ignored_user(chat, name)); |
1700 gaim_conv_chat_get_ignored_user(chat, name)); |
| 1701 |
1701 |
| 1702 gaim_chat_set_ignored(chat, |
1702 gaim_conv_chat_set_ignored(chat, |
| 1703 g_list_remove_link(gaim_chat_get_ignored(chat), item)); |
1703 g_list_remove_link(gaim_conv_chat_get_ignored(chat), item)); |
| 1704 |
1704 |
| 1705 g_free(item->data); |
1705 g_free(item->data); |
| 1706 g_list_free_1(item); |
1706 g_list_free_1(item); |
| 1707 } |
1707 } |
| 1708 |
1708 |
| 1709 GList * |
1709 GList * |
| 1710 gaim_chat_set_ignored(GaimChat *chat, GList *ignored) |
1710 gaim_conv_chat_set_ignored(GaimConvChat *chat, GList *ignored) |
| 1711 { |
1711 { |
| 1712 g_return_val_if_fail(chat != NULL, NULL); |
1712 g_return_val_if_fail(chat != NULL, NULL); |
| 1713 |
1713 |
| 1714 chat->ignored = ignored; |
1714 chat->ignored = ignored; |
| 1715 |
1715 |
| 1716 return ignored; |
1716 return ignored; |
| 1717 } |
1717 } |
| 1718 |
1718 |
| 1719 GList * |
1719 GList * |
| 1720 gaim_chat_get_ignored(const GaimChat *chat) |
1720 gaim_conv_chat_get_ignored(const GaimConvChat *chat) |
| 1721 { |
1721 { |
| 1722 g_return_val_if_fail(chat != NULL, NULL); |
1722 g_return_val_if_fail(chat != NULL, NULL); |
| 1723 |
1723 |
| 1724 return chat->ignored; |
1724 return chat->ignored; |
| 1725 } |
1725 } |
| 1726 |
1726 |
| 1727 const char * |
1727 const char * |
| 1728 gaim_chat_get_ignored_user(const GaimChat *chat, const char *user) |
1728 gaim_conv_chat_get_ignored_user(const GaimConvChat *chat, const char *user) |
| 1729 { |
1729 { |
| 1730 GList *ignored; |
1730 GList *ignored; |
| 1731 |
1731 |
| 1732 g_return_val_if_fail(chat != NULL, NULL); |
1732 g_return_val_if_fail(chat != NULL, NULL); |
| 1733 g_return_val_if_fail(user != NULL, NULL); |
1733 g_return_val_if_fail(user != NULL, NULL); |
| 1734 |
1734 |
| 1735 for (ignored = gaim_chat_get_ignored(chat); |
1735 for (ignored = gaim_conv_chat_get_ignored(chat); |
| 1736 ignored != NULL; |
1736 ignored != NULL; |
| 1737 ignored = ignored->next) { |
1737 ignored = ignored->next) { |
| 1738 |
1738 |
| 1739 const char *ign = (const char *)ignored->data; |
1739 const char *ign = (const char *)ignored->data; |
| 1740 |
1740 |
| 1753 |
1753 |
| 1754 return NULL; |
1754 return NULL; |
| 1755 } |
1755 } |
| 1756 |
1756 |
| 1757 gboolean |
1757 gboolean |
| 1758 gaim_chat_is_user_ignored(const GaimChat *chat, const char *user) |
1758 gaim_conv_chat_is_user_ignored(const GaimConvChat *chat, const char *user) |
| 1759 { |
1759 { |
| 1760 g_return_val_if_fail(chat != NULL, FALSE); |
1760 g_return_val_if_fail(chat != NULL, FALSE); |
| 1761 g_return_val_if_fail(user != NULL, FALSE); |
1761 g_return_val_if_fail(user != NULL, FALSE); |
| 1762 |
1762 |
| 1763 return (gaim_chat_get_ignored_user(chat, user) != NULL); |
1763 return (gaim_conv_chat_get_ignored_user(chat, user) != NULL); |
| 1764 } |
1764 } |
| 1765 |
1765 |
| 1766 void |
1766 void |
| 1767 gaim_chat_set_topic(GaimChat *chat, const char *who, const char *topic) |
1767 gaim_conv_chat_set_topic(GaimConvChat *chat, const char *who, const char *topic) |
| 1768 { |
1768 { |
| 1769 g_return_if_fail(chat != NULL); |
1769 g_return_if_fail(chat != NULL); |
| 1770 |
1770 |
| 1771 if (chat->who != NULL) free(chat->who); |
1771 if (chat->who != NULL) free(chat->who); |
| 1772 if (chat->topic != NULL) free(chat->topic); |
1772 if (chat->topic != NULL) free(chat->topic); |
| 1773 |
1773 |
| 1774 chat->who = (who == NULL ? NULL : g_strdup(who)); |
1774 chat->who = (who == NULL ? NULL : g_strdup(who)); |
| 1775 chat->topic = (topic == NULL ? NULL : g_strdup(topic)); |
1775 chat->topic = (topic == NULL ? NULL : g_strdup(topic)); |
| 1776 |
1776 |
| 1777 gaim_conversation_update(gaim_chat_get_conversation(chat), |
1777 gaim_conversation_update(gaim_conv_chat_get_conversation(chat), |
| 1778 GAIM_CONV_UPDATE_TOPIC); |
1778 GAIM_CONV_UPDATE_TOPIC); |
| 1779 } |
1779 } |
| 1780 |
1780 |
| 1781 const char * |
1781 const char * |
| 1782 gaim_chat_get_topic(const GaimChat *chat) |
1782 gaim_conv_chat_get_topic(const GaimConvChat *chat) |
| 1783 { |
1783 { |
| 1784 g_return_val_if_fail(chat != NULL, NULL); |
1784 g_return_val_if_fail(chat != NULL, NULL); |
| 1785 |
1785 |
| 1786 return chat->topic; |
1786 return chat->topic; |
| 1787 } |
1787 } |
| 1788 |
1788 |
| 1789 void |
1789 void |
| 1790 gaim_chat_set_id(GaimChat *chat, int id) |
1790 gaim_conv_chat_set_id(GaimConvChat *chat, int id) |
| 1791 { |
1791 { |
| 1792 g_return_if_fail(chat != NULL); |
1792 g_return_if_fail(chat != NULL); |
| 1793 |
1793 |
| 1794 chat->id = id; |
1794 chat->id = id; |
| 1795 } |
1795 } |
| 1796 |
1796 |
| 1797 int |
1797 int |
| 1798 gaim_chat_get_id(const GaimChat *chat) |
1798 gaim_conv_chat_get_id(const GaimConvChat *chat) |
| 1799 { |
1799 { |
| 1800 g_return_val_if_fail(chat != NULL, -1); |
1800 g_return_val_if_fail(chat != NULL, -1); |
| 1801 |
1801 |
| 1802 return chat->id; |
1802 return chat->id; |
| 1803 } |
1803 } |
| 1804 |
1804 |
| 1805 void |
1805 void |
| 1806 gaim_chat_write(GaimChat *chat, const char *who, const char *message, |
1806 gaim_conv_chat_write(GaimConvChat *chat, const char *who, const char *message, |
| 1807 GaimMessageFlags flags, time_t mtime) |
1807 GaimMessageFlags flags, time_t mtime) |
| 1808 { |
1808 { |
| 1809 GaimAccount *account; |
1809 GaimAccount *account; |
| 1810 GaimConversation *conv; |
1810 GaimConversation *conv; |
| 1811 GaimConnection *gc; |
1811 GaimConnection *gc; |
| 1812 |
1812 |
| 1813 g_return_if_fail(chat != NULL); |
1813 g_return_if_fail(chat != NULL); |
| 1814 g_return_if_fail(who != NULL); |
1814 g_return_if_fail(who != NULL); |
| 1815 g_return_if_fail(message != NULL); |
1815 g_return_if_fail(message != NULL); |
| 1816 |
1816 |
| 1817 conv = gaim_chat_get_conversation(chat); |
1817 conv = gaim_conv_chat_get_conversation(chat); |
| 1818 gc = gaim_conversation_get_gc(conv); |
1818 gc = gaim_conversation_get_gc(conv); |
| 1819 account = gaim_connection_get_account(gc); |
1819 account = gaim_connection_get_account(gc); |
| 1820 |
1820 |
| 1821 /* Don't display this if the person who wrote it is ignored. */ |
1821 /* Don't display this if the person who wrote it is ignored. */ |
| 1822 if (gaim_chat_is_user_ignored(chat, who)) |
1822 if (gaim_conv_chat_is_user_ignored(chat, who)) |
| 1823 return; |
1823 return; |
| 1824 |
1824 |
| 1825 if (!(flags & GAIM_MESSAGE_WHISPER)) { |
1825 if (!(flags & GAIM_MESSAGE_WHISPER)) { |
| 1826 char *str; |
1826 char *str; |
| 1827 const char *disp; |
1827 const char *disp; |
| 1850 else |
1850 else |
| 1851 gaim_conversation_write(conv, who, message, flags, mtime); |
1851 gaim_conversation_write(conv, who, message, flags, mtime); |
| 1852 } |
1852 } |
| 1853 |
1853 |
| 1854 void |
1854 void |
| 1855 gaim_chat_send(GaimChat *chat, const char *message) |
1855 gaim_conv_chat_send(GaimConvChat *chat, const char *message) |
| 1856 { |
1856 { |
| 1857 g_return_if_fail(chat != NULL); |
1857 g_return_if_fail(chat != NULL); |
| 1858 g_return_if_fail(message != NULL); |
1858 g_return_if_fail(message != NULL); |
| 1859 |
1859 |
| 1860 common_send(gaim_chat_get_conversation(chat), message); |
1860 common_send(gaim_conv_chat_get_conversation(chat), message); |
| 1861 } |
1861 } |
| 1862 |
1862 |
| 1863 void |
1863 void |
| 1864 gaim_chat_add_user(GaimChat *chat, const char *user, const char *extra_msg) |
1864 gaim_conv_chat_add_user(GaimConvChat *chat, const char *user, const char *extra_msg) |
| 1865 { |
1865 { |
| 1866 GaimConversation *conv; |
1866 GaimConversation *conv; |
| 1867 GaimConversationUiOps *ops; |
1867 GaimConversationUiOps *ops; |
| 1868 char tmp[BUF_LONG]; |
1868 char tmp[BUF_LONG]; |
| 1869 |
1869 |
| 1870 g_return_if_fail(chat != NULL); |
1870 g_return_if_fail(chat != NULL); |
| 1871 g_return_if_fail(user != NULL); |
1871 g_return_if_fail(user != NULL); |
| 1872 |
1872 |
| 1873 conv = gaim_chat_get_conversation(chat); |
1873 conv = gaim_conv_chat_get_conversation(chat); |
| 1874 ops = gaim_conversation_get_ui_ops(conv); |
1874 ops = gaim_conversation_get_ui_ops(conv); |
| 1875 |
1875 |
| 1876 gaim_signal_emit(gaim_conversations_get_handle(), |
1876 gaim_signal_emit(gaim_conversations_get_handle(), |
| 1877 "chat-buddy-joining", conv, user); |
1877 "chat-buddy-joining", conv, user); |
| 1878 |
1878 |
| 1879 gaim_chat_set_users(chat, |
1879 gaim_conv_chat_set_users(chat, |
| 1880 g_list_insert_sorted(gaim_chat_get_users(chat), g_strdup(user), |
1880 g_list_insert_sorted(gaim_conv_chat_get_users(chat), g_strdup(user), |
| 1881 insertname_compare)); |
1881 insertname_compare)); |
| 1882 |
1882 |
| 1883 if (ops != NULL && ops->chat_add_user != NULL) |
1883 if (ops != NULL && ops->chat_add_user != NULL) |
| 1884 ops->chat_add_user(conv, user); |
1884 ops->chat_add_user(conv, user); |
| 1885 |
1885 |
| 1897 gaim_signal_emit(gaim_conversations_get_handle(), |
1897 gaim_signal_emit(gaim_conversations_get_handle(), |
| 1898 "chat-buddy-joined", conv, user); |
1898 "chat-buddy-joined", conv, user); |
| 1899 } |
1899 } |
| 1900 |
1900 |
| 1901 void |
1901 void |
| 1902 gaim_chat_add_users(GaimChat *chat, GList *users) |
1902 gaim_conv_chat_add_users(GaimConvChat *chat, GList *users) |
| 1903 { |
1903 { |
| 1904 GaimConversation *conv; |
1904 GaimConversation *conv; |
| 1905 GaimConversationUiOps *ops; |
1905 GaimConversationUiOps *ops; |
| 1906 GList *l; |
1906 GList *l; |
| 1907 |
1907 |
| 1908 g_return_if_fail(chat != NULL); |
1908 g_return_if_fail(chat != NULL); |
| 1909 g_return_if_fail(users != NULL); |
1909 g_return_if_fail(users != NULL); |
| 1910 |
1910 |
| 1911 conv = gaim_chat_get_conversation(chat); |
1911 conv = gaim_conv_chat_get_conversation(chat); |
| 1912 ops = gaim_conversation_get_ui_ops(conv); |
1912 ops = gaim_conversation_get_ui_ops(conv); |
| 1913 |
1913 |
| 1914 for (l = users; l != NULL; l = l->next) { |
1914 for (l = users; l != NULL; l = l->next) { |
| 1915 const char *user = (const char *)l->data; |
1915 const char *user = (const char *)l->data; |
| 1916 |
1916 |
| 1917 gaim_signal_emit(gaim_conversations_get_handle(), |
1917 gaim_signal_emit(gaim_conversations_get_handle(), |
| 1918 "chat-buddy-joining", conv, user); |
1918 "chat-buddy-joining", conv, user); |
| 1919 |
1919 |
| 1920 gaim_chat_set_users(chat, |
1920 gaim_conv_chat_set_users(chat, |
| 1921 g_list_insert_sorted(gaim_chat_get_users(chat), |
1921 g_list_insert_sorted(gaim_conv_chat_get_users(chat), |
| 1922 g_strdup((char *)l->data), |
1922 g_strdup((char *)l->data), |
| 1923 insertname_compare)); |
1923 insertname_compare)); |
| 1924 |
1924 |
| 1925 gaim_signal_emit(gaim_conversations_get_handle(), |
1925 gaim_signal_emit(gaim_conversations_get_handle(), |
| 1926 "chat-buddy-joined", conv, user); |
1926 "chat-buddy-joined", conv, user); |
| 1941 |
1941 |
| 1942 g_return_if_fail(chat != NULL); |
1942 g_return_if_fail(chat != NULL); |
| 1943 g_return_if_fail(old_user != NULL); |
1943 g_return_if_fail(old_user != NULL); |
| 1944 g_return_if_fail(new_user != NULL); |
1944 g_return_if_fail(new_user != NULL); |
| 1945 |
1945 |
| 1946 conv = gaim_chat_get_conversation(chat); |
1946 conv = gaim_conv_chat_get_conversation(chat); |
| 1947 ops = gaim_conversation_get_ui_ops(conv); |
1947 ops = gaim_conversation_get_ui_ops(conv); |
| 1948 |
1948 |
| 1949 gaim_chat_set_users(chat, |
1949 gaim_conv_chat_set_users(chat, |
| 1950 g_list_insert_sorted(gaim_chat_get_users(chat), g_strdup(new_user), |
1950 g_list_insert_sorted(gaim_conv_chat_get_users(chat), g_strdup(new_user), |
| 1951 insertname_compare)); |
1951 insertname_compare)); |
| 1952 |
1952 |
| 1953 if (ops != NULL && ops->chat_rename_user != NULL) |
1953 if (ops != NULL && ops->chat_rename_user != NULL) |
| 1954 ops->chat_rename_user(conv, old_user, new_user); |
1954 ops->chat_rename_user(conv, old_user, new_user); |
| 1955 |
1955 |
| 1956 for (names = gaim_chat_get_users(chat); |
1956 for (names = gaim_conv_chat_get_users(chat); |
| 1957 names != NULL; |
1957 names != NULL; |
| 1958 names = names->next) { |
1958 names = names->next) { |
| 1959 |
1959 |
| 1960 if (!gaim_utf8_strcasecmp((char *)names->data, old_user)) { |
1960 if (!gaim_utf8_strcasecmp((char *)names->data, old_user)) { |
| 1961 gaim_chat_set_users(chat, |
1961 gaim_conv_chat_set_users(chat, |
| 1962 g_list_remove(gaim_chat_get_users(chat), names->data)); |
1962 g_list_remove(gaim_conv_chat_get_users(chat), names->data)); |
| 1963 break; |
1963 break; |
| 1964 } |
1964 } |
| 1965 } |
1965 } |
| 1966 |
1966 |
| 1967 if (gaim_chat_is_user_ignored(chat, old_user)) { |
1967 if (gaim_conv_chat_is_user_ignored(chat, old_user)) { |
| 1968 gaim_chat_unignore(chat, old_user); |
1968 gaim_conv_chat_unignore(chat, old_user); |
| 1969 gaim_chat_ignore(chat, new_user); |
1969 gaim_conv_chat_ignore(chat, new_user); |
| 1970 } |
1970 } |
| 1971 else if (gaim_chat_is_user_ignored(chat, new_user)) |
1971 else if (gaim_conv_chat_is_user_ignored(chat, new_user)) |
| 1972 gaim_chat_unignore(chat, new_user); |
1972 gaim_conv_chat_unignore(chat, new_user); |
| 1973 |
1973 |
| 1974 if (gaim_prefs_get_bool("/core/conversations/chat/show_nick_change")) { |
1974 if (gaim_prefs_get_bool("/core/conversations/chat/show_nick_change")) { |
| 1975 g_snprintf(tmp, sizeof(tmp), |
1975 g_snprintf(tmp, sizeof(tmp), |
| 1976 _("%s is now known as %s"), old_user, new_user); |
1976 _("%s is now known as %s"), old_user, new_user); |
| 1977 |
1977 |
| 1978 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
1978 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 1979 } |
1979 } |
| 1980 } |
1980 } |
| 1981 |
1981 |
| 1982 void |
1982 void |
| 1983 gaim_chat_remove_user(GaimChat *chat, const char *user, const char *reason) |
1983 gaim_conv_chat_remove_user(GaimConvChat *chat, const char *user, const char *reason) |
| 1984 { |
1984 { |
| 1985 GaimConversation *conv; |
1985 GaimConversation *conv; |
| 1986 GaimConversationUiOps *ops; |
1986 GaimConversationUiOps *ops; |
| 1987 char tmp[BUF_LONG]; |
1987 char tmp[BUF_LONG]; |
| 1988 GList *names; |
1988 GList *names; |
| 1989 |
1989 |
| 1990 g_return_if_fail(chat != NULL); |
1990 g_return_if_fail(chat != NULL); |
| 1991 g_return_if_fail(user != NULL); |
1991 g_return_if_fail(user != NULL); |
| 1992 |
1992 |
| 1993 conv = gaim_chat_get_conversation(chat); |
1993 conv = gaim_conv_chat_get_conversation(chat); |
| 1994 ops = gaim_conversation_get_ui_ops(conv); |
1994 ops = gaim_conversation_get_ui_ops(conv); |
| 1995 |
1995 |
| 1996 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", |
1996 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", |
| 1997 conv, user, reason); |
1997 conv, user, reason); |
| 1998 |
1998 |
| 1999 if (ops != NULL && ops->chat_remove_user != NULL) |
1999 if (ops != NULL && ops->chat_remove_user != NULL) |
| 2000 ops->chat_remove_user(conv, user); |
2000 ops->chat_remove_user(conv, user); |
| 2001 |
2001 |
| 2002 for (names = gaim_chat_get_users(chat); |
2002 for (names = gaim_conv_chat_get_users(chat); |
| 2003 names != NULL; |
2003 names != NULL; |
| 2004 names = names->next) { |
2004 names = names->next) { |
| 2005 |
2005 |
| 2006 if (!gaim_utf8_strcasecmp((char *)names->data, user)) { |
2006 if (!gaim_utf8_strcasecmp((char *)names->data, user)) { |
| 2007 gaim_chat_set_users(chat, |
2007 gaim_conv_chat_set_users(chat, |
| 2008 g_list_remove(gaim_chat_get_users(chat), names->data)); |
2008 g_list_remove(gaim_conv_chat_get_users(chat), names->data)); |
| 2009 break; |
2009 break; |
| 2010 } |
2010 } |
| 2011 } |
2011 } |
| 2012 |
2012 |
| 2013 /* NOTE: Don't remove them from ignored in case they re-enter. */ |
2013 /* NOTE: Don't remove them from ignored in case they re-enter. */ |
| 2157 **************************************************************************/ |
2157 **************************************************************************/ |
| 2158 /* This one places conversations in the last made window. */ |
2158 /* This one places conversations in the last made window. */ |
| 2159 static void |
2159 static void |
| 2160 conv_placement_last_created_win(GaimConversation *conv) |
2160 conv_placement_last_created_win(GaimConversation *conv) |
| 2161 { |
2161 { |
| 2162 GaimWindow *win; |
2162 GaimConvWindow *win; |
| 2163 |
2163 |
| 2164 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im")) |
2164 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im")) |
| 2165 win = g_list_last(gaim_get_windows())->data; |
2165 win = g_list_last(gaim_get_windows())->data; |
| 2166 else |
2166 else |
| 2167 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); |
2167 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); |
| 2168 |
2168 |
| 2169 if (win == NULL) { |
2169 if (win == NULL) { |
| 2170 win = gaim_window_new(); |
2170 win = gaim_conv_window_new(); |
| 2171 |
2171 |
| 2172 gaim_window_add_conversation(win, conv); |
2172 gaim_conv_window_add_conversation(win, conv); |
| 2173 gaim_window_show(win); |
2173 gaim_conv_window_show(win); |
| 2174 } |
2174 } |
| 2175 else |
2175 else |
| 2176 gaim_window_add_conversation(win, conv); |
2176 gaim_conv_window_add_conversation(win, conv); |
| 2177 } |
2177 } |
| 2178 |
2178 |
| 2179 /* This one places each conversation in its own window. */ |
2179 /* This one places each conversation in its own window. */ |
| 2180 static void |
2180 static void |
| 2181 conv_placement_new_window(GaimConversation *conv) |
2181 conv_placement_new_window(GaimConversation *conv) |
| 2182 { |
2182 { |
| 2183 GaimWindow *win; |
2183 GaimConvWindow *win; |
| 2184 |
2184 |
| 2185 win = gaim_window_new(); |
2185 win = gaim_conv_window_new(); |
| 2186 |
2186 |
| 2187 gaim_window_add_conversation(win, conv); |
2187 gaim_conv_window_add_conversation(win, conv); |
| 2188 |
2188 |
| 2189 gaim_window_show(win); |
2189 gaim_conv_window_show(win); |
| 2190 } |
2190 } |
| 2191 |
2191 |
| 2192 /* |
2192 /* |
| 2193 * This groups things by, well, group. Buddies from groups will always be |
2193 * This groups things by, well, group. Buddies from groups will always be |
| 2194 * grouped together, and a buddy from a group not belonging to any currently |
2194 * grouped together, and a buddy from a group not belonging to any currently |
| 2195 * open windows will get a new window. |
2195 * open windows will get a new window. |
| 2196 */ |
2196 */ |
| 2197 static void |
2197 static void |
| 2198 conv_placement_by_group(GaimConversation *conv) |
2198 conv_placement_by_group(GaimConversation *conv) |
| 2199 { |
2199 { |
| 2200 GaimWindow *win; |
2200 GaimConvWindow *win; |
| 2201 GaimConversationType type; |
2201 GaimConversationType type; |
| 2202 |
2202 |
| 2203 type = gaim_conversation_get_type(conv); |
2203 type = gaim_conversation_get_type(conv); |
| 2204 |
2204 |
| 2205 if (type == GAIM_CONV_IM) { |
2205 if (type == GAIM_CONV_IM) { |