Mercurial > pidgin
comparison src/conversation.c @ 7118:bf630f7dfdcd
[gaim-migrate @ 7685]
Here's a commit that I think will make faceprint happy. GaimWindow ->
GaimConvWindow, GaimIm -> GaimConvIm, GaimChat -> GaimConvChat,
GaimBlistChat -> GaimChat, and updated the API functions as well. Plugin
authors are going to hunt me down and murder me. I can feel it..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 02 Oct 2003 02:54:07 +0000 |
parents | 9220c7490cd1 |
children | 208cb260d7a7 |
comparison
equal
deleted
inserted
replaced
7117:943085b0ff8b | 7118:bf630f7dfdcd |
---|---|
40 | 40 |
41 } ConvPlacementData; | 41 } ConvPlacementData; |
42 | 42 |
43 #define SEND_TYPED_TIMEOUT 5000 | 43 #define SEND_TYPED_TIMEOUT 5000 |
44 | 44 |
45 static GaimWindowUiOps *win_ui_ops = NULL; | 45 static GaimConvWindowUiOps *win_ui_ops = NULL; |
46 | 46 |
47 static GList *conversations = NULL; | 47 static GList *conversations = NULL; |
48 static GList *ims = NULL; | 48 static GList *ims = NULL; |
49 static GList *chats = NULL; | 49 static GList *chats = NULL; |
50 static GList *windows = NULL; | 50 static GList *windows = NULL; |
137 | 137 |
138 static gboolean | 138 static gboolean |
139 reset_typing(gpointer data) | 139 reset_typing(gpointer data) |
140 { | 140 { |
141 GaimConversation *c = (GaimConversation *)data; | 141 GaimConversation *c = (GaimConversation *)data; |
142 GaimIm *im; | 142 GaimConvIm *im; |
143 | 143 |
144 if (!g_list_find(conversations, c)) | 144 if (!g_list_find(conversations, c)) |
145 return FALSE; | 145 return FALSE; |
146 | 146 |
147 im = GAIM_IM(c); | 147 im = GAIM_CONV_IM(c); |
148 | 148 |
149 gaim_im_set_typing_state(im, GAIM_NOT_TYPING); | 149 gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING); |
150 gaim_im_update_typing(im); | 150 gaim_conv_im_update_typing(im); |
151 gaim_im_stop_typing_timeout(im); | 151 gaim_conv_im_stop_typing_timeout(im); |
152 | 152 |
153 return FALSE; | 153 return FALSE; |
154 } | 154 } |
155 | 155 |
156 static gboolean | 156 static gboolean |
162 | 162 |
163 gc = gaim_conversation_get_gc(conv); | 163 gc = gaim_conversation_get_gc(conv); |
164 name = gaim_conversation_get_name(conv); | 164 name = gaim_conversation_get_name(conv); |
165 | 165 |
166 if (conv != NULL && gc != NULL && name != NULL) { | 166 if (conv != NULL && gc != NULL && name != NULL) { |
167 gaim_im_set_type_again(GAIM_IM(conv), TRUE); | 167 gaim_conv_im_set_type_again(GAIM_CONV_IM(conv), TRUE); |
168 | 168 |
169 serv_send_typing(gc, name, GAIM_TYPED); | 169 serv_send_typing(gc, name, GAIM_TYPED); |
170 | 170 |
171 gaim_debug(GAIM_DEBUG_MISC, "conversation", "typed...\n"); | 171 gaim_debug(GAIM_DEBUG_MISC, "conversation", "typed...\n"); |
172 } | 172 } |
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 |
300 else { | 300 else { |
301 buffy = g_strdup(buf); | 301 buffy = g_strdup(buf); |
302 | 302 |
303 gaim_signal_emit(gaim_conversations_get_handle(), "sending-chat-msg", | 303 gaim_signal_emit(gaim_conversations_get_handle(), "sending-chat-msg", |
304 gaim_conversation_get_account(conv), &buffy, | 304 gaim_conversation_get_account(conv), &buffy, |
305 gaim_chat_get_id(GAIM_CHAT(conv))); | 305 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); |
306 | 306 |
307 if (buffy != NULL) { | 307 if (buffy != NULL) { |
308 err = serv_chat_send(gc, gaim_chat_get_id(GAIM_CHAT(conv)), buffy); | 308 err = serv_chat_send(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), buffy); |
309 | 309 |
310 gaim_signal_emit(gaim_conversations_get_handle(), "sent-chat-msg", | 310 gaim_signal_emit(gaim_conversations_get_handle(), "sent-chat-msg", |
311 gaim_conversation_get_account(conv), buf, | 311 gaim_conversation_get_account(conv), buf, |
312 gaim_chat_get_id(GAIM_CHAT(conv))); | 312 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); |
313 | 313 |
314 g_free(buffy); | 314 g_free(buffy); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
345 } | 345 } |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 static void | 349 static void |
350 update_conv_indexes(GaimWindow *win) | 350 update_conv_indexes(GaimConvWindow *win) |
351 { | 351 { |
352 GList *l; | 352 GList *l; |
353 int i; | 353 int i; |
354 | 354 |
355 for (l = gaim_window_get_conversations(win), i = 0; | 355 for (l = gaim_conv_window_get_conversations(win), i = 0; |
356 l != NULL; | 356 l != NULL; |
357 l = l->next, i++) { | 357 l = l->next, i++) { |
358 | 358 |
359 GaimConversation *conv = (GaimConversation *)l->data; | 359 GaimConversation *conv = (GaimConversation *)l->data; |
360 | 360 |
361 conv->conversation_pos = i; | 361 conv->conversation_pos = i; |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 GaimWindow * | 365 GaimConvWindow * |
366 gaim_window_new(void) | 366 gaim_conv_window_new(void) |
367 { | 367 { |
368 GaimWindow *win; | 368 GaimConvWindow *win; |
369 | 369 |
370 win = g_new0(GaimWindow, 1); | 370 win = g_new0(GaimConvWindow, 1); |
371 | 371 |
372 windows = g_list_append(windows, win); | 372 windows = g_list_append(windows, win); |
373 | 373 |
374 win->ui_ops = gaim_conversations_get_win_ui_ops(); | 374 win->ui_ops = gaim_conversations_get_win_ui_ops(); |
375 | 375 |
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); |
504 win->ui_ops = ops; | 504 win->ui_ops = ops; |
505 | 505 |
506 if (win->ui_ops != NULL && win->ui_ops->new_window != NULL) | 506 if (win->ui_ops != NULL && win->ui_ops->new_window != NULL) |
507 win->ui_ops->new_window(win); | 507 win->ui_ops->new_window(win); |
508 | 508 |
509 for (l = gaim_window_get_conversations(win); | 509 for (l = gaim_conv_window_get_conversations(win); |
510 l != NULL; | 510 l != NULL; |
511 l = l->next) { | 511 l = l->next) { |
512 | 512 |
513 GaimConversation *conv = (GaimConversation *)l; | 513 GaimConversation *conv = (GaimConversation *)l; |
514 | 514 |
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; |
560 | 560 |
561 return win->conversation_count - 1; | 561 return win->conversation_count - 1; |
562 } | 562 } |
563 | 563 |
564 GaimConversation * | 564 GaimConversation * |
565 gaim_window_remove_conversation(GaimWindow *win, unsigned int index) | 565 gaim_conv_window_remove_conversation(GaimConvWindow *win, unsigned int index) |
566 { | 566 { |
567 GaimWindowUiOps *ops; | 567 GaimConvWindowUiOps *ops; |
568 GaimConversation *conv; | 568 GaimConversation *conv; |
569 GList *node; | 569 GList *node; |
570 | 570 |
571 g_return_val_if_fail(win != NULL, NULL); | 571 g_return_val_if_fail(win != NULL, NULL); |
572 g_return_val_if_fail(index < gaim_window_get_conversation_count(win), NULL); | 572 g_return_val_if_fail(index < gaim_conv_window_get_conversation_count(win), NULL); |
573 | 573 |
574 ops = gaim_window_get_ui_ops(win); | 574 ops = gaim_conv_window_get_ui_ops(win); |
575 | 575 |
576 node = g_list_nth(gaim_window_get_conversations(win), index); | 576 node = g_list_nth(gaim_conv_window_get_conversations(win), index); |
577 conv = (GaimConversation *)node->data; | 577 conv = (GaimConversation *)node->data; |
578 | 578 |
579 if (ops != NULL && ops->remove_conversation != NULL) | 579 if (ops != NULL && ops->remove_conversation != NULL) |
580 ops->remove_conversation(win, conv); | 580 ops->remove_conversation(win, conv); |
581 | 581 |
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); |
625 } | 625 } |
626 | 626 |
627 conv = (GaimConversation *)l->data; | 627 conv = (GaimConversation *)l->data; |
628 | 628 |
629 /* Update the UI part of this. */ | 629 /* Update the UI part of this. */ |
630 ops = gaim_window_get_ui_ops(win); | 630 ops = gaim_conv_window_get_ui_ops(win); |
631 | 631 |
632 if (ops != NULL && ops->move_conversation != NULL) | 632 if (ops != NULL && ops->move_conversation != NULL) |
633 ops->move_conversation(win, conv, new_index); | 633 ops->move_conversation(win, conv, new_index); |
634 | 634 |
635 if (new_index > index) | 635 if (new_index > index) |
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); |
690 gaim_signal_emit(gaim_conversations_get_handle(), | 690 gaim_signal_emit(gaim_conversations_get_handle(), |
691 "conversation-switched", old_conv, conv); | 691 "conversation-switched", old_conv, conv); |
692 } | 692 } |
693 | 693 |
694 GaimConversation * | 694 GaimConversation * |
695 gaim_window_get_active_conversation(const GaimWindow *win) | 695 gaim_conv_window_get_active_conversation(const GaimConvWindow *win) |
696 { | 696 { |
697 GaimWindowUiOps *ops; | 697 GaimConvWindowUiOps *ops; |
698 | 698 |
699 g_return_val_if_fail(win != NULL, NULL); | 699 g_return_val_if_fail(win != NULL, NULL); |
700 | 700 |
701 if (gaim_window_get_conversation_count(win) == 0) | 701 if (gaim_conv_window_get_conversation_count(win) == 0) |
702 return NULL; | 702 return NULL; |
703 | 703 |
704 ops = gaim_window_get_ui_ops(win); | 704 ops = gaim_conv_window_get_ui_ops(win); |
705 | 705 |
706 if (ops != NULL && ops->get_active_index != NULL) | 706 if (ops != NULL && ops->get_active_index != NULL) |
707 return gaim_window_get_conversation_at(win, ops->get_active_index(win)); | 707 return gaim_conv_window_get_conversation_at(win, ops->get_active_index(win)); |
708 | 708 |
709 return NULL; | 709 return NULL; |
710 } | 710 } |
711 | 711 |
712 GList * | 712 GList * |
713 gaim_window_get_conversations(const GaimWindow *win) | 713 gaim_conv_window_get_conversations(const GaimConvWindow *win) |
714 { | 714 { |
715 g_return_val_if_fail(win != NULL, NULL); | 715 g_return_val_if_fail(win != NULL, NULL); |
716 | 716 |
717 return win->conversations; | 717 return win->conversations; |
718 } | 718 } |
721 gaim_get_windows(void) | 721 gaim_get_windows(void) |
722 { | 722 { |
723 return windows; | 723 return windows; |
724 } | 724 } |
725 | 725 |
726 GaimWindow * | 726 GaimConvWindow * |
727 gaim_get_first_window_with_type(GaimConversationType type) | 727 gaim_get_first_window_with_type(GaimConversationType type) |
728 { | 728 { |
729 GList *wins, *convs; | 729 GList *wins, *convs; |
730 GaimWindow *win; | 730 GaimConvWindow *win; |
731 GaimConversation *conv; | 731 GaimConversation *conv; |
732 | 732 |
733 if (type == GAIM_CONV_UNKNOWN) | 733 if (type == GAIM_CONV_UNKNOWN) |
734 return NULL; | 734 return NULL; |
735 | 735 |
736 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { | 736 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
737 win = (GaimWindow *)wins->data; | 737 win = (GaimConvWindow *)wins->data; |
738 | 738 |
739 for (convs = gaim_window_get_conversations(win); | 739 for (convs = gaim_conv_window_get_conversations(win); |
740 convs != NULL; | 740 convs != NULL; |
741 convs = convs->next) { | 741 convs = convs->next) { |
742 | 742 |
743 conv = (GaimConversation *)convs->data; | 743 conv = (GaimConversation *)convs->data; |
744 | 744 |
748 } | 748 } |
749 | 749 |
750 return NULL; | 750 return NULL; |
751 } | 751 } |
752 | 752 |
753 GaimWindow * | 753 GaimConvWindow * |
754 gaim_get_last_window_with_type(GaimConversationType type) | 754 gaim_get_last_window_with_type(GaimConversationType type) |
755 { | 755 { |
756 GList *wins, *convs; | 756 GList *wins, *convs; |
757 GaimWindow *win; | 757 GaimConvWindow *win; |
758 GaimConversation *conv; | 758 GaimConversation *conv; |
759 | 759 |
760 if (type == GAIM_CONV_UNKNOWN) | 760 if (type == GAIM_CONV_UNKNOWN) |
761 return NULL; | 761 return NULL; |
762 | 762 |
763 for (wins = g_list_last(gaim_get_windows()); | 763 for (wins = g_list_last(gaim_get_windows()); |
764 wins != NULL; | 764 wins != NULL; |
765 wins = wins->prev) { | 765 wins = wins->prev) { |
766 | 766 |
767 win = (GaimWindow *)wins->data; | 767 win = (GaimConvWindow *)wins->data; |
768 | 768 |
769 for (convs = gaim_window_get_conversations(win); | 769 for (convs = gaim_conv_window_get_conversations(win); |
770 convs != NULL; | 770 convs != NULL; |
771 convs = convs->next) { | 771 convs = convs->next) { |
772 | 772 |
773 conv = (GaimConversation *)convs->data; | 773 conv = (GaimConversation *)convs->data; |
774 | 774 |
808 conv->data = g_hash_table_new_full(g_str_hash, g_str_equal, | 808 conv->data = g_hash_table_new_full(g_str_hash, g_str_equal, |
809 g_free, NULL); | 809 g_free, NULL); |
810 | 810 |
811 if (type == GAIM_CONV_IM) | 811 if (type == GAIM_CONV_IM) |
812 { | 812 { |
813 conv->u.im = g_new0(GaimIm, 1); | 813 conv->u.im = g_new0(GaimConvIm, 1); |
814 conv->u.im->conv = conv; | 814 conv->u.im->conv = conv; |
815 | 815 |
816 ims = g_list_append(ims, conv); | 816 ims = g_list_append(ims, conv); |
817 | 817 |
818 gaim_conversation_set_logging(conv, | 818 gaim_conversation_set_logging(conv, |
819 gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); | 819 gaim_prefs_get_bool("/gaim/gtk/logging/log_ims")); |
820 } | 820 } |
821 else if (type == GAIM_CONV_CHAT) | 821 else if (type == GAIM_CONV_CHAT) |
822 { | 822 { |
823 conv->u.chat = g_new0(GaimChat, 1); | 823 conv->u.chat = g_new0(GaimConvChat, 1); |
824 conv->u.chat->conv = conv; | 824 conv->u.chat->conv = conv; |
825 | 825 |
826 chats = g_list_append(chats, conv); | 826 chats = g_list_append(chats, conv); |
827 | 827 |
828 gaim_conversation_set_logging(conv, | 828 gaim_conversation_set_logging(conv, |
837 /* | 837 /* |
838 * Create a window if one does not exist. If it does, use the last | 838 * Create a window if one does not exist. If it does, use the last |
839 * created window. | 839 * created window. |
840 */ | 840 */ |
841 if (windows == NULL) { | 841 if (windows == NULL) { |
842 GaimWindow *win; | 842 GaimConvWindow *win; |
843 | 843 |
844 win = gaim_window_new(); | 844 win = gaim_conv_window_new(); |
845 gaim_window_add_conversation(win, conv); | 845 gaim_conv_window_add_conversation(win, conv); |
846 | 846 |
847 /* Ensure the window is visible. */ | 847 /* Ensure the window is visible. */ |
848 gaim_window_show(win); | 848 gaim_conv_window_show(win); |
849 } | 849 } |
850 else { | 850 else { |
851 if (place_conv == NULL) | 851 if (place_conv == NULL) |
852 gaim_prefs_set_string("/core/conversations/placement", "last"); | 852 gaim_prefs_set_string("/core/conversations/placement", "last"); |
853 | 853 |
866 | 866 |
867 void | 867 void |
868 gaim_conversation_destroy(GaimConversation *conv) | 868 gaim_conversation_destroy(GaimConversation *conv) |
869 { | 869 { |
870 GaimPluginProtocolInfo *prpl_info = NULL; | 870 GaimPluginProtocolInfo *prpl_info = NULL; |
871 GaimWindow *win; | 871 GaimConvWindow *win; |
872 GaimConversationUiOps *ops; | 872 GaimConversationUiOps *ops; |
873 GaimConnection *gc; | 873 GaimConnection *gc; |
874 const char *name; | 874 const char *name; |
875 GList *node; | 875 GList *node; |
876 | 876 |
910 * | 910 * |
911 * -- ChipX86 | 911 * -- ChipX86 |
912 */ | 912 */ |
913 | 913 |
914 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) { | 914 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) { |
915 serv_chat_leave(gc, gaim_chat_get_id(GAIM_CHAT(conv))); | 915 serv_chat_leave(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); |
916 | 916 |
917 return; | 917 return; |
918 } | 918 } |
919 } | 919 } |
920 } | 920 } |
942 | 942 |
943 if (conv->type == GAIM_CONV_IM) { | 943 if (conv->type == GAIM_CONV_IM) { |
944 GSList *tempy; | 944 GSList *tempy; |
945 int image; | 945 int image; |
946 | 946 |
947 gaim_im_stop_typing_timeout(conv->u.im); | 947 gaim_conv_im_stop_typing_timeout(conv->u.im); |
948 gaim_im_stop_type_again_timeout(conv->u.im); | 948 gaim_conv_im_stop_type_again_timeout(conv->u.im); |
949 | 949 |
950 for (tempy = conv->u.im->images; | 950 for (tempy = conv->u.im->images; |
951 tempy != NULL; | 951 tempy != NULL; |
952 tempy = tempy->next) { | 952 tempy = tempy->next) { |
953 | 953 |
991 } | 991 } |
992 | 992 |
993 g_hash_table_destroy(conv->data); | 993 g_hash_table_destroy(conv->data); |
994 | 994 |
995 if (win != NULL) { | 995 if (win != NULL) { |
996 gaim_window_remove_conversation(win, | 996 gaim_conv_window_remove_conversation(win, |
997 gaim_conversation_get_index(conv)); | 997 gaim_conversation_get_index(conv)); |
998 } | 998 } |
999 | 999 |
1000 if (ops != NULL && ops->destroy_conversation != NULL) | 1000 if (ops != NULL && ops->destroy_conversation != NULL) |
1001 ops->destroy_conversation(conv); | 1001 ops->destroy_conversation(conv); |
1211 g_return_val_if_fail(conv != NULL, NULL); | 1211 g_return_val_if_fail(conv != NULL, NULL); |
1212 | 1212 |
1213 return conv->history; | 1213 return conv->history; |
1214 } | 1214 } |
1215 | 1215 |
1216 GaimWindow * | 1216 GaimConvWindow * |
1217 gaim_conversation_get_window(const GaimConversation *conv) | 1217 gaim_conversation_get_window(const GaimConversation *conv) |
1218 { | 1218 { |
1219 g_return_val_if_fail(conv != NULL, NULL); | 1219 g_return_val_if_fail(conv != NULL, NULL); |
1220 | 1220 |
1221 return conv->window; | 1221 return conv->window; |
1222 } | 1222 } |
1223 | 1223 |
1224 GaimIm * | 1224 GaimConvIm * |
1225 gaim_conversation_get_im_data(const GaimConversation *conv) | 1225 gaim_conversation_get_im_data(const GaimConversation *conv) |
1226 { | 1226 { |
1227 g_return_val_if_fail(conv != NULL, NULL); | 1227 g_return_val_if_fail(conv != NULL, NULL); |
1228 | 1228 |
1229 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) | 1229 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
1230 return NULL; | 1230 return NULL; |
1231 | 1231 |
1232 return conv->u.im; | 1232 return conv->u.im; |
1233 } | 1233 } |
1234 | 1234 |
1235 GaimChat * | 1235 GaimConvChat * |
1236 gaim_conversation_get_chat_data(const GaimConversation *conv) | 1236 gaim_conversation_get_chat_data(const GaimConversation *conv) |
1237 { | 1237 { |
1238 g_return_val_if_fail(conv != NULL, NULL); | 1238 g_return_val_if_fail(conv != NULL, NULL); |
1239 | 1239 |
1240 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) | 1240 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) |
1342 { | 1342 { |
1343 GaimPluginProtocolInfo *prpl_info = NULL; | 1343 GaimPluginProtocolInfo *prpl_info = NULL; |
1344 GaimConnection *gc = NULL; | 1344 GaimConnection *gc = NULL; |
1345 GaimAccount *account; | 1345 GaimAccount *account; |
1346 GaimConversationUiOps *ops; | 1346 GaimConversationUiOps *ops; |
1347 GaimWindow *win; | 1347 GaimConvWindow *win; |
1348 GaimBuddy *b; | 1348 GaimBuddy *b; |
1349 GaimUnseenState unseen; | 1349 GaimUnseenState unseen; |
1350 /* int logging_font_options = 0; */ | 1350 /* int logging_font_options = 0; */ |
1351 | 1351 |
1352 g_return_if_fail(conv != NULL); | 1352 g_return_if_fail(conv != NULL); |
1417 if (!(flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_SYSTEM)) | 1417 if (!(flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_SYSTEM)) |
1418 return; | 1418 return; |
1419 | 1419 |
1420 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | 1420 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
1421 if ((flags & GAIM_MESSAGE_RECV) == GAIM_MESSAGE_RECV) | 1421 if ((flags & GAIM_MESSAGE_RECV) == GAIM_MESSAGE_RECV) |
1422 gaim_im_set_typing_state(GAIM_IM(conv), GAIM_NOT_TYPING); | 1422 gaim_conv_im_set_typing_state(GAIM_CONV_IM(conv), GAIM_NOT_TYPING); |
1423 } | 1423 } |
1424 | 1424 |
1425 if (gaim_window_get_active_conversation(win) != conv) { | 1425 if (gaim_conv_window_get_active_conversation(win) != conv) { |
1426 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK || | 1426 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK || |
1427 gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) | 1427 gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) |
1428 unseen = GAIM_UNSEEN_NICK; | 1428 unseen = GAIM_UNSEEN_NICK; |
1429 else if ((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM && | 1429 else if ((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM && |
1430 gaim_conversation_get_unseen(conv) != GAIM_UNSEEN_TEXT) | 1430 gaim_conversation_get_unseen(conv) != GAIM_UNSEEN_TEXT) |
1471 | 1471 |
1472 /************************************************************************** | 1472 /************************************************************************** |
1473 * IM Conversation API | 1473 * IM Conversation API |
1474 **************************************************************************/ | 1474 **************************************************************************/ |
1475 GaimConversation * | 1475 GaimConversation * |
1476 gaim_im_get_conversation(const GaimIm *im) | 1476 gaim_conv_im_get_conversation(const GaimConvIm *im) |
1477 { | 1477 { |
1478 g_return_val_if_fail(im != NULL, NULL); | 1478 g_return_val_if_fail(im != NULL, NULL); |
1479 | 1479 |
1480 return im->conv; | 1480 return im->conv; |
1481 } | 1481 } |
1482 | 1482 |
1483 void | 1483 void |
1484 gaim_im_set_icon(GaimIm *im, GaimBuddyIcon *icon) | 1484 gaim_conv_im_set_icon(GaimConvIm *im, GaimBuddyIcon *icon) |
1485 { | 1485 { |
1486 g_return_if_fail(im != NULL); | 1486 g_return_if_fail(im != NULL); |
1487 | 1487 |
1488 if (im->icon == icon) | 1488 if (im->icon == icon) |
1489 return; | 1489 return; |
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); |
1929 if (ops != NULL && ops->chat_add_users != NULL) | 1929 if (ops != NULL && ops->chat_add_users != NULL) |
1930 ops->chat_add_users(conv, users); | 1930 ops->chat_add_users(conv, users); |
1931 } | 1931 } |
1932 | 1932 |
1933 void | 1933 void |
1934 gaim_chat_rename_user(GaimChat *chat, const char *old_user, | 1934 gaim_conv_chat_rename_user(GaimConvChat *chat, const char *old_user, |
1935 const char *new_user) | 1935 const char *new_user) |
1936 { | 1936 { |
1937 GaimConversation *conv; | 1937 GaimConversation *conv; |
1938 GaimConversationUiOps *ops; | 1938 GaimConversationUiOps *ops; |
1939 char tmp[BUF_LONG]; | 1939 char tmp[BUF_LONG]; |
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. */ |
2025 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-left", | 2025 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-left", |
2026 conv, user, reason); | 2026 conv, user, reason); |
2027 } | 2027 } |
2028 | 2028 |
2029 void | 2029 void |
2030 gaim_chat_remove_users(GaimChat *chat, GList *users, const char *reason) | 2030 gaim_conv_chat_remove_users(GaimConvChat *chat, GList *users, const char *reason) |
2031 { | 2031 { |
2032 GaimConversation *conv; | 2032 GaimConversation *conv; |
2033 GaimConversationUiOps *ops; | 2033 GaimConversationUiOps *ops; |
2034 char tmp[BUF_LONG]; | 2034 char tmp[BUF_LONG]; |
2035 GList *names, *l; | 2035 GList *names, *l; |
2036 | 2036 |
2037 g_return_if_fail(chat != NULL); | 2037 g_return_if_fail(chat != NULL); |
2038 g_return_if_fail(users != NULL); | 2038 g_return_if_fail(users != NULL); |
2039 | 2039 |
2040 conv = gaim_chat_get_conversation(chat); | 2040 conv = gaim_conv_chat_get_conversation(chat); |
2041 ops = gaim_conversation_get_ui_ops(conv); | 2041 ops = gaim_conversation_get_ui_ops(conv); |
2042 | 2042 |
2043 for (l = users; l != NULL; l = l->next) { | 2043 for (l = users; l != NULL; l = l->next) { |
2044 const char *user = (const char *)l->data; | 2044 const char *user = (const char *)l->data; |
2045 | 2045 |
2051 ops->chat_remove_users(conv, users); | 2051 ops->chat_remove_users(conv, users); |
2052 | 2052 |
2053 for (l = users; l != NULL; l = l->next) { | 2053 for (l = users; l != NULL; l = l->next) { |
2054 const char *user = (const char *)l->data; | 2054 const char *user = (const char *)l->data; |
2055 | 2055 |
2056 for (names = gaim_chat_get_users(chat); | 2056 for (names = gaim_conv_chat_get_users(chat); |
2057 names != NULL; | 2057 names != NULL; |
2058 names = names->next) { | 2058 names = names->next) { |
2059 | 2059 |
2060 if (!gaim_utf8_strcasecmp((char *)names->data, user)) | 2060 if (!gaim_utf8_strcasecmp((char *)names->data, user)) |
2061 { | 2061 { |
2062 gaim_chat_set_users(chat, | 2062 gaim_conv_chat_set_users(chat, |
2063 g_list_remove(gaim_chat_get_users(chat), names->data)); | 2063 g_list_remove(gaim_conv_chat_get_users(chat), names->data)); |
2064 | 2064 |
2065 break; | 2065 break; |
2066 } | 2066 } |
2067 } | 2067 } |
2068 | 2068 |
2099 } | 2099 } |
2100 } | 2100 } |
2101 } | 2101 } |
2102 | 2102 |
2103 void | 2103 void |
2104 gaim_chat_clear_users(GaimChat *chat) | 2104 gaim_conv_chat_clear_users(GaimConvChat *chat) |
2105 { | 2105 { |
2106 GaimConversation *conv; | 2106 GaimConversation *conv; |
2107 GaimConversationUiOps *ops; | 2107 GaimConversationUiOps *ops; |
2108 GList *users; | 2108 GList *users; |
2109 GList *l, *l_next; | 2109 GList *l, *l_next; |
2110 | 2110 |
2111 g_return_if_fail(chat != NULL); | 2111 g_return_if_fail(chat != NULL); |
2112 | 2112 |
2113 conv = gaim_chat_get_conversation(chat); | 2113 conv = gaim_conv_chat_get_conversation(chat); |
2114 ops = gaim_conversation_get_ui_ops(conv); | 2114 ops = gaim_conversation_get_ui_ops(conv); |
2115 users = gaim_chat_get_users(chat); | 2115 users = gaim_conv_chat_get_users(chat); |
2116 | 2116 |
2117 if (ops != NULL && ops->chat_remove_users != NULL) | 2117 if (ops != NULL && ops->chat_remove_users != NULL) |
2118 ops->chat_remove_users(conv, users); | 2118 ops->chat_remove_users(conv, users); |
2119 | 2119 |
2120 for (l = users; l != NULL; l = l_next) | 2120 for (l = users; l != NULL; l = l_next) |
2130 | 2130 |
2131 g_free(user); | 2131 g_free(user); |
2132 } | 2132 } |
2133 | 2133 |
2134 g_list_free(users); | 2134 g_list_free(users); |
2135 gaim_chat_set_users(chat, NULL); | 2135 gaim_conv_chat_set_users(chat, NULL); |
2136 } | 2136 } |
2137 | 2137 |
2138 GaimConversation * | 2138 GaimConversation * |
2139 gaim_find_chat(const GaimConnection *gc, int id) | 2139 gaim_find_chat(const GaimConnection *gc, int id) |
2140 { | 2140 { |
2142 GaimConversation *conv; | 2142 GaimConversation *conv; |
2143 | 2143 |
2144 for (l = gaim_get_chats(); l != NULL; l = l->next) { | 2144 for (l = gaim_get_chats(); l != NULL; l = l->next) { |
2145 conv = (GaimConversation *)l->data; | 2145 conv = (GaimConversation *)l->data; |
2146 | 2146 |
2147 if (gaim_chat_get_id(GAIM_CHAT(conv)) == id && | 2147 if (gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)) == id && |
2148 gaim_conversation_get_gc(conv) == gc) | 2148 gaim_conversation_get_gc(conv) == gc) |
2149 return conv; | 2149 return conv; |
2150 } | 2150 } |
2151 | 2151 |
2152 return NULL; | 2152 return NULL; |
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) { |
2213 if (b != NULL) | 2213 if (b != NULL) |
2214 grp = gaim_find_buddys_group(b); | 2214 grp = gaim_find_buddys_group(b); |
2215 | 2215 |
2216 /* Go through the list of IMs and find one with this group. */ | 2216 /* Go through the list of IMs and find one with this group. */ |
2217 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { | 2217 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
2218 GaimWindow *win2; | 2218 GaimConvWindow *win2; |
2219 GaimConversation *conv2; | 2219 GaimConversation *conv2; |
2220 GaimBuddy *b2; | 2220 GaimBuddy *b2; |
2221 GaimGroup *g2 = NULL; | 2221 GaimGroup *g2 = NULL; |
2222 | 2222 |
2223 win2 = (GaimWindow *)wins->data; | 2223 win2 = (GaimConvWindow *)wins->data; |
2224 | 2224 |
2225 for (convs = gaim_window_get_conversations(win2); | 2225 for (convs = gaim_conv_window_get_conversations(win2); |
2226 convs != NULL; | 2226 convs != NULL; |
2227 convs = convs->next) { | 2227 convs = convs->next) { |
2228 | 2228 |
2229 conv2 = (GaimConversation *)convs->data; | 2229 conv2 = (GaimConversation *)convs->data; |
2230 | 2230 |
2233 | 2233 |
2234 if (b2 != NULL) | 2234 if (b2 != NULL) |
2235 g2 = gaim_find_buddys_group(b2); | 2235 g2 = gaim_find_buddys_group(b2); |
2236 | 2236 |
2237 if (grp == g2) { | 2237 if (grp == g2) { |
2238 gaim_window_add_conversation(win2, conv); | 2238 gaim_conv_window_add_conversation(win2, conv); |
2239 | 2239 |
2240 return; | 2240 return; |
2241 } | 2241 } |
2242 } | 2242 } |
2243 } | 2243 } |
2244 | 2244 |
2245 /* Make a new window. */ | 2245 /* Make a new window. */ |
2246 conv_placement_new_window(conv); | 2246 conv_placement_new_window(conv); |
2247 } | 2247 } |
2248 else if (type == GAIM_CONV_CHAT) { | 2248 else if (type == GAIM_CONV_CHAT) { |
2249 GaimBlistChat *chat; | 2249 GaimChat *chat; |
2250 GaimGroup *group = NULL; | 2250 GaimGroup *group = NULL; |
2251 GList *wins, *convs; | 2251 GList *wins, *convs; |
2252 | 2252 |
2253 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv), | 2253 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv), |
2254 gaim_conversation_get_name(conv)); | 2254 gaim_conversation_get_name(conv)); |
2256 if (chat != NULL) | 2256 if (chat != NULL) |
2257 group = gaim_blist_chat_get_group(chat); | 2257 group = gaim_blist_chat_get_group(chat); |
2258 | 2258 |
2259 /* Go through the list of chats and find one with this group. */ | 2259 /* Go through the list of chats and find one with this group. */ |
2260 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { | 2260 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
2261 GaimWindow *win2; | 2261 GaimConvWindow *win2; |
2262 GaimConversation *conv2; | 2262 GaimConversation *conv2; |
2263 GaimBlistChat *chat2; | 2263 GaimChat *chat2; |
2264 GaimGroup *group2 = NULL; | 2264 GaimGroup *group2 = NULL; |
2265 | 2265 |
2266 win2 = (GaimWindow *)wins->data; | 2266 win2 = (GaimConvWindow *)wins->data; |
2267 | 2267 |
2268 for (convs = gaim_window_get_conversations(win2); | 2268 for (convs = gaim_conv_window_get_conversations(win2); |
2269 convs != NULL; | 2269 convs != NULL; |
2270 convs = convs->next) { | 2270 convs = convs->next) { |
2271 | 2271 |
2272 conv2 = (GaimConversation *)convs->data; | 2272 conv2 = (GaimConversation *)convs->data; |
2273 | 2273 |
2277 | 2277 |
2278 if (chat2 != NULL) | 2278 if (chat2 != NULL) |
2279 group2 = gaim_blist_chat_get_group(chat2); | 2279 group2 = gaim_blist_chat_get_group(chat2); |
2280 | 2280 |
2281 if (group == group2) { | 2281 if (group == group2) { |
2282 gaim_window_add_conversation(win2, conv); | 2282 gaim_conv_window_add_conversation(win2, conv); |
2283 | 2283 |
2284 return; | 2284 return; |
2285 } | 2285 } |
2286 } | 2286 } |
2287 } | 2287 } |
2293 win = gaim_get_last_window_with_type(type); | 2293 win = gaim_get_last_window_with_type(type); |
2294 | 2294 |
2295 if (win == NULL) | 2295 if (win == NULL) |
2296 conv_placement_new_window(conv); | 2296 conv_placement_new_window(conv); |
2297 else | 2297 else |
2298 gaim_window_add_conversation(win, conv); | 2298 gaim_conv_window_add_conversation(win, conv); |
2299 } | 2299 } |
2300 } | 2300 } |
2301 | 2301 |
2302 /* This groups things by account. Otherwise, the same semantics as above */ | 2302 /* This groups things by account. Otherwise, the same semantics as above */ |
2303 static void | 2303 static void |
2312 type = gaim_conversation_get_type(conv); | 2312 type = gaim_conversation_get_type(conv); |
2313 | 2313 |
2314 | 2314 |
2315 /* Go through the list of IMs and find one with this group. */ | 2315 /* Go through the list of IMs and find one with this group. */ |
2316 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { | 2316 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
2317 GaimWindow *win2; | 2317 GaimConvWindow *win2; |
2318 GaimConversation *conv2; | 2318 GaimConversation *conv2; |
2319 | 2319 |
2320 win2 = (GaimWindow *)wins->data; | 2320 win2 = (GaimConvWindow *)wins->data; |
2321 | 2321 |
2322 for (convs = gaim_window_get_conversations(win2); | 2322 for (convs = gaim_conv_window_get_conversations(win2); |
2323 convs != NULL; | 2323 convs != NULL; |
2324 convs = convs->next) { | 2324 convs = convs->next) { |
2325 | 2325 |
2326 conv2 = (GaimConversation *)convs->data; | 2326 conv2 = (GaimConversation *)convs->data; |
2327 | 2327 |
2328 if ((gaim_prefs_get_bool("/core/conversations/combine_chat_im") || | 2328 if ((gaim_prefs_get_bool("/core/conversations/combine_chat_im") || |
2329 type == gaim_conversation_get_type(conv2)) && | 2329 type == gaim_conversation_get_type(conv2)) && |
2330 account == gaim_conversation_get_account(conv2)) { | 2330 account == gaim_conversation_get_account(conv2)) { |
2331 | 2331 |
2332 gaim_window_add_conversation(win2, conv); | 2332 gaim_conv_window_add_conversation(win2, conv); |
2333 return; | 2333 return; |
2334 } | 2334 } |
2335 | 2335 |
2336 } | 2336 } |
2337 } | 2337 } |
2494 | 2494 |
2495 gaim_conversation_foreach(gaim_conversation_autoset_title); | 2495 gaim_conversation_foreach(gaim_conversation_autoset_title); |
2496 } | 2496 } |
2497 | 2497 |
2498 void | 2498 void |
2499 gaim_conversations_set_win_ui_ops(GaimWindowUiOps *ops) | 2499 gaim_conversations_set_win_ui_ops(GaimConvWindowUiOps *ops) |
2500 { | 2500 { |
2501 win_ui_ops = ops; | 2501 win_ui_ops = ops; |
2502 } | 2502 } |
2503 | 2503 |
2504 GaimWindowUiOps * | 2504 GaimConvWindowUiOps * |
2505 gaim_conversations_get_win_ui_ops(void) | 2505 gaim_conversations_get_win_ui_ops(void) |
2506 { | 2506 { |
2507 return win_ui_ops; | 2507 return win_ui_ops; |
2508 } | 2508 } |
2509 | 2509 |