| 37 #include "gtkconv.h" |
37 #include "gtkconv.h" |
| 38 #include "pidginconversation.h" |
38 #include "pidginconversation.h" |
| 39 #include "pidgincore.h" |
39 #include "pidgincore.h" |
| 40 #include "pidgindisplaywindow.h" |
40 #include "pidgindisplaywindow.h" |
| 41 #include "pidgininfopane.h" |
41 #include "pidgininfopane.h" |
| 42 #include "pidginmessage.h" |
|
| 43 |
42 |
| 44 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
43 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
| 45 gboolean pidgin_conv_has_focus(PurpleConversation *conv); |
44 gboolean pidgin_conv_has_focus(PurpleConversation *conv); |
| 46 |
45 |
| 47 static void pidgin_conv_placement_place(PidginConversationOld *conv); |
46 static void pidgin_conv_placement_place(PidginConversationOld *conv); |
| 398 |
397 |
| 399 window = pidgin_display_window_get_default(); |
398 window = pidgin_display_window_get_default(); |
| 400 pidgin_display_window_add(PIDGIN_DISPLAY_WINDOW(window), conv); |
399 pidgin_display_window_add(PIDGIN_DISPLAY_WINDOW(window), conv); |
| 401 } |
400 } |
| 402 |
401 |
| 403 static void |
|
| 404 conversation_write(PurpleConversation *conv, PurpleMessage *pmsg) { |
|
| 405 GtkWidget *conversation = NULL; |
|
| 406 |
|
| 407 conversation = pidgin_conversation_from_purple_conversation(conv); |
|
| 408 if(PIDGIN_IS_CONVERSATION(conversation)) { |
|
| 409 pidgin_conversation_write_message(PIDGIN_CONVERSATION(conversation), |
|
| 410 pmsg); |
|
| 411 } |
|
| 412 } |
|
| 413 |
|
| 414 static void |
|
| 415 pidgin_conv_new(PurpleConversation *conv) |
|
| 416 { |
|
| 417 private_gtkconv_new(conv, FALSE); |
|
| 418 if (PIDGIN_IS_PIDGIN_CONVERSATION_OLD(conv)) |
|
| 419 purple_signal_emit(pidgin_conversations_get_handle(), |
|
| 420 "conversation-displayed", PIDGIN_CONVERSATION_OLD(conv)); |
|
| 421 } |
|
| 422 |
|
| 423 void |
402 void |
| 424 pidgin_conversation_detach(PurpleConversation *conv) { |
403 pidgin_conversation_detach(PurpleConversation *conv) { |
| 425 if(PIDGIN_IS_PIDGIN_CONVERSATION_OLD(conv)) { |
404 if(PIDGIN_IS_PIDGIN_CONVERSATION_OLD(conv)) { |
| 426 PidginConversationOld *gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
405 PidginConversationOld *gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
| 427 |
406 |
| 506 "Suppressing message for an inactive conversation"); |
485 "Suppressing message for an inactive conversation"); |
| 507 |
486 |
| 508 return TRUE; |
487 return TRUE; |
| 509 } |
488 } |
| 510 |
489 |
| 511 static void |
|
| 512 pidgin_conv_write_conv(PurpleConversation *conv, PurpleMessage *pmsg) |
|
| 513 { |
|
| 514 PidginMessage *pidgin_msg = NULL; |
|
| 515 PurpleMessageFlags flags; |
|
| 516 PidginConversationOld *gtkconv; |
|
| 517 PurpleConnection *gc; |
|
| 518 PurpleAccount *account; |
|
| 519 gboolean plugin_return; |
|
| 520 |
|
| 521 g_return_if_fail(conv != NULL); |
|
| 522 gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
|
| 523 g_return_if_fail(gtkconv != NULL); |
|
| 524 flags = purple_message_get_flags(pmsg); |
|
| 525 |
|
| 526 account = purple_conversation_get_account(conv); |
|
| 527 g_return_if_fail(account != NULL); |
|
| 528 gc = purple_account_get_connection(account); |
|
| 529 g_return_if_fail(gc != NULL || !(flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))); |
|
| 530 |
|
| 531 plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( |
|
| 532 pidgin_conversations_get_handle(), |
|
| 533 (PURPLE_IS_IM_CONVERSATION(conv) ? "displaying-im-msg" : "displaying-chat-msg"), |
|
| 534 conv, pmsg)); |
|
| 535 if (plugin_return) |
|
| 536 { |
|
| 537 return; |
|
| 538 } |
|
| 539 |
|
| 540 pidgin_msg = pidgin_message_new(pmsg); |
|
| 541 talkatu_history_write_message( |
|
| 542 TALKATU_HISTORY(gtkconv->history), |
|
| 543 TALKATU_MESSAGE(pidgin_msg) |
|
| 544 ); |
|
| 545 |
|
| 546 purple_signal_emit(pidgin_conversations_get_handle(), |
|
| 547 (PURPLE_IS_IM_CONVERSATION(conv) ? "displayed-im-msg" : "displayed-chat-msg"), |
|
| 548 conv, pmsg); |
|
| 549 } |
|
| 550 |
|
| 551 gboolean |
490 gboolean |
| 552 pidgin_conv_has_focus(PurpleConversation *conv) |
491 pidgin_conv_has_focus(PurpleConversation *conv) |
| 553 { |
492 { |
| 554 PidginConversationOld *gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
493 PidginConversationOld *gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
| 555 GtkRoot *win; |
494 GtkRoot *win; |
| 567 } |
506 } |
| 568 |
507 |
| 569 static PurpleConversationUiOps conversation_ui_ops = |
508 static PurpleConversationUiOps conversation_ui_ops = |
| 570 { |
509 { |
| 571 .create_conversation = conversation_create, |
510 .create_conversation = conversation_create, |
| 572 .write_conv = conversation_write, |
|
| 573 |
511 |
| 574 .destroy_conversation = pidgin_conv_destroy, |
512 .destroy_conversation = pidgin_conv_destroy, |
| 575 .has_focus = pidgin_conv_has_focus, |
513 .has_focus = pidgin_conv_has_focus, |
| 576 }; |
514 }; |
| 577 |
515 |