Mercurial > pidgin
comparison finch/gntconv.c @ 22215:07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 21:39:29 +0000 |
parents | 2b426862ffbf |
children | ad357ca94de9 |
comparison
equal
deleted
inserted
replaced
22214:2b426862ffbf | 22215:07c2b8fa7bb4 |
---|---|
69 static int color_message_send; | 69 static int color_message_send; |
70 static int color_message_highlight; | 70 static int color_message_highlight; |
71 static int color_message_action; | 71 static int color_message_action; |
72 static int color_timestamp; | 72 static int color_timestamp; |
73 | 73 |
74 static PurpleBuddy * | |
75 find_buddy_for_conversation(PurpleConversation *conv) | |
76 { | |
77 return purple_find_buddy(purple_conversation_get_account(conv), | |
78 purple_conversation_get_name(conv)); | |
79 } | |
80 | |
81 static PurpleChat * | |
82 find_chat_for_conversation(PurpleConversation *conv) | |
83 { | |
84 return purple_blist_find_chat(purple_conversation_get_account(conv), | |
85 purple_conversation_get_name(conv)); | |
86 } | |
87 | |
74 static PurpleBlistNode * | 88 static PurpleBlistNode * |
75 get_conversation_blist_node(PurpleConversation *conv) | 89 get_conversation_blist_node(PurpleConversation *conv) |
76 { | 90 { |
77 PurpleBlistNode *node = NULL; | 91 PurpleBlistNode *node = NULL; |
78 | 92 |
79 switch (purple_conversation_get_type(conv)) { | 93 switch (purple_conversation_get_type(conv)) { |
80 case PURPLE_CONV_TYPE_IM: | 94 case PURPLE_CONV_TYPE_IM: |
81 node = (PurpleBlistNode*)purple_find_buddy(conv->account, conv->name); | 95 node = (PurpleBlistNode*)find_buddy_for_conversation(conv); |
82 node = node ? purple_blist_node_get_parent(node) : NULL; | 96 node = node ? purple_blist_node_get_parent(node) : NULL; |
83 break; | 97 break; |
84 case PURPLE_CONV_TYPE_CHAT: | 98 case PURPLE_CONV_TYPE_CHAT: |
85 node = (PurpleBlistNode*)purple_blist_find_chat(conv->account, conv->name); | 99 node = (PurpleBlistNode*)find_chat_for_conversation(conv); |
86 break; | 100 break; |
87 default: | 101 default: |
88 break; | 102 break; |
89 } | 103 } |
90 return node; | 104 return node; |
166 PURPLE_MESSAGE_NO_LOG, time(NULL)); | 180 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
167 break; | 181 break; |
168 } | 182 } |
169 g_free(error); | 183 g_free(error); |
170 } | 184 } |
171 else if (!purple_account_is_connected(ggconv->active_conv->account)) | 185 else if (!purple_account_is_connected(purple_conversation_get_account(ggconv->active_conv))) |
172 { | 186 { |
173 purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), | 187 purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), |
174 PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); | 188 PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
175 } | 189 } |
176 else | 190 else |
314 account_signed_on_off(PurpleConnection *gc, gpointer null) | 328 account_signed_on_off(PurpleConnection *gc, gpointer null) |
315 { | 329 { |
316 GList *list = purple_get_ims(); | 330 GList *list = purple_get_ims(); |
317 while (list) { | 331 while (list) { |
318 PurpleConversation *conv = list->data; | 332 PurpleConversation *conv = list->data; |
319 PurpleConversation *cc = find_conv_with_contact(conv->account, conv->name); | 333 PurpleConversation *cc = find_conv_with_contact( |
334 purple_conversation_get_account(conv), purple_conversation_get_name(conv)); | |
320 if (cc) | 335 if (cc) |
321 generate_send_to_menu(cc->ui_data); | 336 generate_send_to_menu(cc->ui_data); |
322 list = list->next; | 337 list = list->next; |
323 } | 338 } |
324 | 339 |
330 PurpleConversation *conv = list->data; | 345 PurpleConversation *conv = list->data; |
331 PurpleChat *chat; | 346 PurpleChat *chat; |
332 GHashTable *comps = NULL; | 347 GHashTable *comps = NULL; |
333 | 348 |
334 list = list->next; | 349 list = list->next; |
335 if (conv->account != purple_connection_get_account(gc) || | 350 if (purple_conversation_get_account(conv) != purple_connection_get_account(gc) || |
336 !purple_conversation_get_data(conv, "want-to-rejoin")) | 351 !purple_conversation_get_data(conv, "want-to-rejoin")) |
337 continue; | 352 continue; |
338 | 353 |
339 chat = purple_blist_find_chat(conv->account, conv->name); | 354 chat = find_chat_for_conversation(conv); |
340 if (chat == NULL) { | 355 if (chat == NULL) { |
341 PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); | 356 PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
342 if (info->chat_info_defaults != NULL) | 357 if (info->chat_info_defaults != NULL) |
343 comps = info->chat_info_defaults(gc, conv->name); | 358 comps = info->chat_info_defaults(gc, purple_conversation_get_name(conv)); |
344 } else { | 359 } else { |
345 comps = chat->components; | 360 comps = chat->components; |
346 } | 361 } |
347 serv_join_chat(gc, comps); | 362 serv_join_chat(gc, comps); |
348 if (chat == NULL && comps != NULL) | 363 if (chat == NULL && comps != NULL) |
413 /* Enable logging first so the message below can be logged. */ | 428 /* Enable logging first so the message below can be logged. */ |
414 purple_conversation_set_logging(conv, TRUE); | 429 purple_conversation_set_logging(conv, TRUE); |
415 | 430 |
416 purple_conversation_write(conv, NULL, | 431 purple_conversation_write(conv, NULL, |
417 _("Logging started. Future messages in this conversation will be logged."), | 432 _("Logging started. Future messages in this conversation will be logged."), |
418 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : | 433 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
419 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), | |
420 time(NULL)); | |
421 } else { | 434 } else { |
422 purple_conversation_write(conv, NULL, | 435 purple_conversation_write(conv, NULL, |
423 _("Logging stopped. Future messages in this conversation will not be logged."), | 436 _("Logging stopped. Future messages in this conversation will not be logged."), |
424 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : | 437 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
425 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), | |
426 time(NULL)); | |
427 | 438 |
428 /* Disable the logging second, so that the above message can be logged. */ | 439 /* Disable the logging second, so that the above message can be logged. */ |
429 purple_conversation_set_logging(conv, FALSE); | 440 purple_conversation_set_logging(conv, FALSE); |
430 } | 441 } |
431 | 442 |
462 GntWidget *sub, *menu = ggc->menu; | 473 GntWidget *sub, *menu = ggc->menu; |
463 GntMenuItem *item; | 474 GntMenuItem *item; |
464 GSList *buds; | 475 GSList *buds; |
465 GList *list = NULL; | 476 GList *list = NULL; |
466 | 477 |
467 buds = purple_find_buddies(ggc->active_conv->account, ggc->active_conv->name); | 478 buds = purple_find_buddies(purple_conversation_get_account(ggc->active_conv), |
479 purple_conversation_get_name(ggc->active_conv)); | |
468 if (!buds) | 480 if (!buds) |
469 return; | 481 return; |
470 | 482 |
471 if ((item = ggc->u.im->sendto) == NULL) { | 483 if ((item = ggc->u.im->sendto) == NULL) { |
472 item = gnt_menuitem_new(_("Send To")); | 484 item = gnt_menuitem_new(_("Send To")); |
606 PurpleBlistNode *convnode = NULL; | 618 PurpleBlistNode *convnode = NULL; |
607 | 619 |
608 if (ggc) | 620 if (ggc) |
609 return; | 621 return; |
610 | 622 |
611 cc = find_conv_with_contact(conv->account, conv->name); | 623 account = purple_conversation_get_account(conv); |
624 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); | |
612 if (cc && cc->ui_data) | 625 if (cc && cc->ui_data) |
613 ggc = cc->ui_data; | 626 ggc = cc->ui_data; |
614 else | 627 else |
615 ggc = g_new0(FinchConv, 1); | 628 ggc = g_new0(FinchConv, 1); |
616 | 629 |
627 if (cc && cc->ui_data) { | 640 if (cc && cc->ui_data) { |
628 finch_conversation_set_active(conv); | 641 finch_conversation_set_active(conv); |
629 return; | 642 return; |
630 } | 643 } |
631 | 644 |
632 account = purple_conversation_get_account(conv); | |
633 type = purple_conversation_get_type(conv); | 645 type = purple_conversation_get_type(conv); |
634 title = get_conversation_title(conv, account); | 646 title = get_conversation_title(conv, account); |
635 | 647 |
636 ggc->window = gnt_vwindow_new(FALSE); | 648 ggc->window = gnt_vwindow_new(FALSE); |
637 gnt_box_set_title(GNT_BOX(ggc->window), title); | 649 gnt_box_set_title(GNT_BOX(ggc->window), title); |
638 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | 650 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); |
639 gnt_box_set_pad(GNT_BOX(ggc->window), 0); | 651 gnt_box_set_pad(GNT_BOX(ggc->window), 0); |
640 | 652 |
641 switch(conv->type){ | 653 switch (purple_conversation_get_type(conv)) { |
642 case PURPLE_CONV_TYPE_UNKNOWN: | 654 case PURPLE_CONV_TYPE_UNKNOWN: |
643 gnt_widget_set_name(ggc->window, "conversation-window-unknown" ); | 655 gnt_widget_set_name(ggc->window, "conversation-window-unknown" ); |
644 break; | 656 break; |
645 case PURPLE_CONV_TYPE_IM: | 657 case PURPLE_CONV_TYPE_IM: |
646 gnt_widget_set_name(ggc->window, "conversation-window-im" ); | 658 gnt_widget_set_name(ggc->window, "conversation-window-im" ); |