* @file gntconv.c GNT Conversation API * Finch is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA #include "gntmenuitemcheck.h" #define PREF_ROOT "/finch/conversations" #define PREF_CHAT PREF_ROOT "/chats" #define PREF_USERLIST PREF_CHAT "/userlist" static void finch_write_common(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime); static void generate_send_to_menu(FinchConv *ggc); static int color_message_receive; static int color_message_send; static int color_message_highlight; static int color_message_action; static int color_timestamp; find_buddy_for_conversation(PurpleConversation *conv) return purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); find_chat_for_conversation(PurpleConversation *conv) return purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); get_conversation_blist_node(PurpleConversation *conv) PurpleBlistNode *node = NULL; switch (purple_conversation_get_type(conv)) { case PURPLE_CONV_TYPE_IM: node = (PurpleBlistNode*)find_buddy_for_conversation(conv); node = node ? purple_blist_node_get_parent(node) : NULL; case PURPLE_CONV_TYPE_CHAT: node = (PurpleBlistNode*)find_chat_for_conversation(conv); send_typing_notification(GntWidget *w, FinchConv *ggconv) const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); gboolean empty = (!text || !*text || (*text == '/')); if (purple_prefs_get_bool("/finch/conversations/notify_typing")) { PurpleConversation *conv = ggconv->active_conv; PurpleConvIm *im = PURPLE_CONV_IM(conv); gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0); purple_conv_im_stop_send_typed_timeout(im); purple_conv_im_start_send_typed_timeout(im); if (send || (purple_conv_im_get_type_again(im) != 0 && time(NULL) > purple_conv_im_get_type_again(im))) { timeout = serv_send_typing(purple_conversation_get_gc(conv), purple_conversation_get_name(conv), purple_conv_im_set_type_again(im, timeout); purple_conv_im_stop_send_typed_timeout(im); serv_send_typing(purple_conversation_get_gc(conv), purple_conversation_get_name(conv), entry_key_pressed(GntWidget *w, FinchConv *ggconv) const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); if (*text == '/' && *(text + 1) != '/') PurpleConversation *conv = ggconv->active_conv; const char *cmdline = text + 1; char *error = NULL, *escape; escape = g_markup_escape_text(cmdline, -1); status = purple_cmd_do_command(conv, cmdline, escape, &error); case PURPLE_CMD_STATUS_OK: case PURPLE_CMD_STATUS_NOT_FOUND: purple_conversation_write(conv, "", _("No such command."), PURPLE_MESSAGE_NO_LOG, time(NULL)); case PURPLE_CMD_STATUS_WRONG_ARGS: purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " PURPLE_MESSAGE_NO_LOG, time(NULL)); case PURPLE_CMD_STATUS_FAILED: purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), PURPLE_MESSAGE_NO_LOG, time(NULL)); case PURPLE_CMD_STATUS_WRONG_TYPE: if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), PURPLE_MESSAGE_NO_LOG, time(NULL)); purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), PURPLE_MESSAGE_NO_LOG, time(NULL)); case PURPLE_CMD_STATUS_WRONG_PRPL: purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), PURPLE_MESSAGE_NO_LOG, time(NULL)); else if (!purple_account_is_connected(purple_conversation_get_account(ggconv->active_conv))) purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); char *escape = purple_markup_escape_text((*text == '/' ? text + 1 : text), -1); switch (purple_conversation_get_type(ggconv->active_conv)) case PURPLE_CONV_TYPE_IM: purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND); case PURPLE_CONV_TYPE_CHAT: purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape); gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); gnt_entry_clear(GNT_ENTRY(ggconv->entry)); closing_window(GntWidget *window, FinchConv *ggconv) GList *list = ggconv->list; PurpleConversation *conv = list->data; purple_conversation_destroy(conv); size_changed_cb(GntWidget *widget, int width, int height) gnt_widget_get_size(widget, &w, &h); purple_prefs_set_int(PREF_ROOT "/size/width", w); purple_prefs_set_int(PREF_ROOT "/size/height", h); save_position_cb(GntWidget *w, int x, int y) purple_prefs_set_int(PREF_ROOT "/position/x", x); purple_prefs_set_int(PREF_ROOT "/position/y", y); static PurpleConversation * find_conv_with_contact(PurpleAccount *account, const char *name) PurpleBuddy *buddy = purple_find_buddy(account, name); PurpleConversation *ret = NULL; for (node = purple_blist_node_get_first_child(purple_blist_node_get_parent((PurpleBlistNode*)buddy)); node; node = purple_blist_node_get_sibling_next(node)) { if (node == (PurpleBlistNode*)buddy) if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name((PurpleBuddy*)node), purple_buddy_get_account((PurpleBuddy*)node))) != NULL) get_conversation_title(PurpleConversation *conv, PurpleAccount *account) return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv), purple_account_get_username(account), purple_account_get_protocol_name(account)); update_buddy_typing(PurpleAccount *account, const char *who, gpointer null) PurpleConversation *conv; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account); im = PURPLE_CONV_IM(conv); ggc = FINCH_GET_DATA(conv); if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { str = get_conversation_title(conv, account); title = g_strdup_printf(_("%s [%s]"), str, gnt_ascii_only() ? "T" : "\342\243\277"); scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv)); str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); /* Updating is a little buggy. So just remove and add a new one */ gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv), str, GNT_TEXT_FLAG_DIM, "typing"); gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0); title = get_conversation_title(conv, account); gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", " ", TRUE); gnt_screen_rename_widget(ggc->window, title); chat_left_cb(PurpleConversation *conv, gpointer null) finch_write_common(conv, NULL, _("You have left this chat."), PURPLE_MESSAGE_SYSTEM, time(NULL)); buddy_signed_on_off(PurpleBuddy *buddy, gpointer null) PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); generate_send_to_menu(FINCH_GET_DATA(conv)); account_signed_on_off(PurpleConnection *gc, gpointer null) GList *list = purple_get_ims(); PurpleConversation *conv = list->data; PurpleConversation *cc = find_conv_with_contact( purple_conversation_get_account(conv), purple_conversation_get_name(conv)); generate_send_to_menu(FINCH_GET_DATA(cc)); if (PURPLE_CONNECTION_IS_CONNECTED(gc)) { /* We just signed on. Let's see if there's any chat that we have open, * and hadn't left before the disconnect. */ list = purple_get_chats(); PurpleConversation *conv = list->data; GHashTable *comps = NULL; if (purple_conversation_get_account(conv) != purple_connection_get_account(gc) || !purple_conversation_get_data(conv, "want-to-rejoin")) chat = find_chat_for_conversation(conv); PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); if (info->chat_info_defaults != NULL) comps = info->chat_info_defaults(gc, purple_conversation_get_name(conv)); comps = purple_chat_get_components(chat); serv_join_chat(gc, comps); if (chat == NULL && comps != NULL) g_hash_table_destroy(comps); account_signing_off(PurpleConnection *gc) GList *list = purple_get_chats(); PurpleAccount *account = purple_connection_get_account(gc); /* We are about to sign off. See which chats we are currently in, and mark * them for rejoin on reconnect. */ PurpleConversation *conv = list->data; if (!purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)) && purple_conversation_get_account(conv) == account) { purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " "longer in this chat. You will be automatically rejoined in the chat when " "the account reconnects."), PURPLE_MESSAGE_SYSTEM, time(NULL)); finch_conv_get_handle(void) cleared_message_history_cb(PurpleConversation *conv, gpointer data) FinchConv *ggc = FINCH_GET_DATA(conv); gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); clear_scrollback_cb(GntMenuItem *item, gpointer ggconv) purple_conversation_clear_message_history(ggc->active_conv); send_file_cb(GntMenuItem *item, gpointer ggconv) serv_send_file(purple_conversation_get_gc(ggc->active_conv), purple_conversation_get_name(ggc->active_conv), NULL); add_pounce_cb(GntMenuItem *item, gpointer ggconv) finch_pounce_editor_show( purple_conversation_get_account(ggc->active_conv), purple_conversation_get_name(ggc->active_conv), NULL); get_info_cb(GntMenuItem *item, gpointer ggconv) finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv), purple_conversation_get_name(ggc->active_conv)); toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv) purple_prefs_set_bool(PREF_ROOT "/timestamps", !purple_prefs_get_bool(PREF_ROOT "/timestamps")); toggle_logging_cb(GntMenuItem *item, gpointer ggconv) PurpleConversation *conv = fc->active_conv; gboolean logging = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item)); if (logging == purple_conversation_is_logging(conv)) /* Enable logging first so the message below can be logged. */ purple_conversation_set_logging(conv, TRUE); purple_conversation_write(conv, NULL, _("Logging started. Future messages in this conversation will be logged."), PURPLE_MESSAGE_SYSTEM, time(NULL)); purple_conversation_write(conv, NULL, _("Logging stopped. Future messages in this conversation will not be logged."), PURPLE_MESSAGE_SYSTEM, time(NULL)); /* Disable the logging second, so that the above message can be logged. */ purple_conversation_set_logging(conv, FALSE); /* Each conversation with the same person will have the same logging setting */ for (iter = fc->list; iter; iter = iter->next) { purple_conversation_set_logging(iter->data, logging); toggle_sound_cb(GntMenuItem *item, gpointer ggconv) PurpleBlistNode *node = get_conversation_blist_node(fc->active_conv); fc->flags ^= FINCH_CONV_NO_SOUND; purple_blist_node_set_bool(node, "gnt-mute-sound", !!(fc->flags & FINCH_CONV_NO_SOUND)); send_to_cb(GntMenuItem *m, gpointer n) PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account"); gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name"); PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); finch_conversation_set_active(conv); view_log_cb(GntMenuItem *n, gpointer ggc) PurpleConversation *conv; if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) name = purple_conversation_get_name(conv); account = purple_conversation_get_account(conv); buddies = purple_find_buddies(account, name); for (cur = buddies; cur != NULL; cur = cur->next) { PurpleBlistNode *node = cur->data; (purple_blist_node_get_sibling_prev(node) || purple_blist_node_get_sibling_next(node))) { finch_log_show_contact((PurpleContact *)purple_blist_node_get_parent(node)); finch_log_show(type, name, account); generate_send_to_menu(FinchConv *ggc) GntWidget *sub, *menu = ggc->menu; buds = purple_find_buddies(purple_conversation_get_account(ggc->active_conv), purple_conversation_get_name(ggc->active_conv)); if ((item = ggc->u.im->sendto) == NULL) { item = gnt_menuitem_new(_("Send To")); gnt_menu_add_item(GNT_MENU(menu), item); ggc->u.im->sendto = item; sub = gnt_menu_new(GNT_MENU_POPUP); gnt_menuitem_set_submenu(item, GNT_MENU(sub)); for (; buds; buds = g_slist_delete_link(buds, buds)) { PurpleBlistNode *node = PURPLE_BLIST_NODE(purple_buddy_get_contact(PURPLE_BUDDY(buds->data))); for (node = purple_blist_node_get_first_child(node); node != NULL; node = purple_blist_node_get_sibling_next(node)) { PurpleBuddy *buddy = (PurpleBuddy *)node; PurpleAccount *account = purple_buddy_get_account(buddy); if (purple_account_is_connected(account)) { /* Use the PurplePresence to get unique buddies. */ PurplePresence *presence = purple_buddy_get_presence(buddy); if (!g_list_find(list, presence)) list = g_list_prepend(list, presence); for (list = g_list_reverse(list); list != NULL; list = g_list_delete_link(list, list)) { PurplePresence *pre = list->data; PurpleBuddy *buddy = purple_presence_get_buddy(pre); PurpleAccount *account = purple_buddy_get_account(buddy); gchar *name = g_strdup(purple_buddy_get_name(buddy)); gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account)); item = gnt_menuitem_new(text); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, send_to_cb, NULL); g_object_set_data(G_OBJECT(item), "purple_account", account); g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free); invite_cb(GntMenuItem *item, gpointer ggconv) PurpleConversation *conv = fc->active_conv; purple_conv_chat_invite_user(PURPLE_CONV_CHAT(conv), NULL, NULL, TRUE); gg_create_menu(FinchConv *ggc) ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu)); item = gnt_menuitem_new(_("Conversation")); gnt_menu_add_item(GNT_MENU(menu), item); sub = gnt_menu_new(GNT_MENU_POPUP); gnt_menuitem_set_submenu(item, GNT_MENU(sub)); item = gnt_menuitem_new(_("Clear Scrollback")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc); item = gnt_menuitem_check_new(_("Show Timestamps")); gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_prefs_get_bool(PREF_ROOT "/timestamps")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc); if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_IM) { PurpleAccount *account = purple_conversation_get_account(ggc->active_conv); PurpleConnection *gc = purple_account_get_connection(account); PurplePluginProtocolInfo *pinfo = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; if (pinfo && pinfo->get_info) { item = gnt_menuitem_new(_("Get Info")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, get_info_cb, ggc); item = gnt_menuitem_new(_("Add Buddy Pounce...")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, add_pounce_cb, ggc); if (pinfo && pinfo->send_file && (!pinfo->can_receive_file || pinfo->can_receive_file(gc, purple_conversation_get_name(ggc->active_conv)))) { item = gnt_menuitem_new(_("Send File")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, send_file_cb, ggc); generate_send_to_menu(ggc); } else if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_CHAT) { item = gnt_menuitem_new(_("Invite...")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, invite_cb, ggc); item = gnt_menuitem_new(_("View Log...")); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, view_log_cb, ggc); item = gnt_menuitem_check_new(_("Enable Logging")); gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_conversation_is_logging(ggc->active_conv)); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, toggle_logging_cb, ggc); item = gnt_menuitem_check_new(_("Enable Sounds")); gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !(ggc->flags & FINCH_CONV_NO_SOUND)); gnt_menu_add_item(GNT_MENU(sub), item); gnt_menuitem_set_callback(item, toggle_sound_cb, ggc); create_conv_from_userlist(GntWidget *widget, FinchConv *fc) PurpleAccount *account = purple_conversation_get_account(fc->active_conv); PurpleConnection *gc = purple_account_get_connection(account); PurplePluginProtocolInfo *prpl_info = NULL; purple_conversation_write(fc->active_conv, NULL, _("You are not connected."), PURPLE_MESSAGE_SYSTEM, time(NULL)); name = gnt_tree_get_selection_data(GNT_TREE(widget)); prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_cb_real_name)) realname = prpl_info->get_cb_real_name(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(fc->active_conv)), name); purple_conversation_new(PURPLE_CONV_TYPE_IM, account, realname ? realname : name); gained_focus_cb(GntWindow *window, FinchConv *fc) for (iter = fc->list; iter; iter = iter->next) { purple_conversation_set_data(iter->data, "unseen-count", 0); purple_conversation_update(iter->data, PURPLE_CONV_UPDATE_UNSEEN); completion_cb(GntEntry *entry, const char *start, const char *end) if (start == entry->start && *start != '/') gnt_widget_key_pressed(GNT_WIDGET(entry), ": "); gg_setup_commands(FinchConv *fconv, gboolean remove_first) commands = purple_cmd_list(NULL); for (; commands; commands = g_list_delete_link(commands, commands)) { g_strlcpy(command + 1, commands->data, sizeof(command) - 1); gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command); commands = purple_cmd_list(fconv->active_conv); for (; commands; commands = g_list_delete_link(commands, commands)) { g_strlcpy(command + 1, commands->data, sizeof(command) - 1); gnt_entry_add_suggest(GNT_ENTRY(fconv->entry), command); cmd_added_cb(const char *cmd, PurpleCmdPriority prior, PurpleCmdFlag flags, gg_setup_commands(fconv, TRUE); cmd_removed_cb(const char *cmd, FinchConv *fconv) g_strlcpy(command + 1, cmd, sizeof(command) - 1); gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command); gg_setup_commands(fconv, TRUE); finch_create_conversation(PurpleConversation *conv) FinchConv *ggc = FINCH_GET_DATA(conv); PurpleConversationType type; PurpleBlistNode *convnode = NULL; gnt_window_present(ggc->window); account = purple_conversation_get_account(conv); cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); if (cc && FINCH_GET_DATA(cc)) ggc = FINCH_GET_DATA(cc); ggc = g_new0(FinchConv, 1); /* Each conversation with the same person will have the same logging setting */ purple_conversation_set_logging(conv, purple_conversation_is_logging(ggc->list->data)); ggc->list = g_list_prepend(ggc->list, conv); FINCH_SET_DATA(conv, ggc); if (cc && FINCH_GET_DATA(cc) && cc != conv) { finch_conversation_set_active(conv); type = purple_conversation_get_type(conv); title = get_conversation_title(conv, account); ggc->window = gnt_vwindow_new(FALSE); gnt_box_set_title(GNT_BOX(ggc->window), title); gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); gnt_box_set_pad(GNT_BOX(ggc->window), 0); switch (purple_conversation_get_type(conv)) { case PURPLE_CONV_TYPE_UNKNOWN: gnt_widget_set_name(ggc->window, "conversation-window-unknown" ); case PURPLE_CONV_TYPE_IM: gnt_widget_set_name(ggc->window, "conversation-window-im" ); case PURPLE_CONV_TYPE_CHAT: gnt_widget_set_name(ggc->window, "conversation-window-chat" ); case PURPLE_CONV_TYPE_MISC: gnt_widget_set_name(ggc->window, "conversation-window-misc" ); case PURPLE_CONV_TYPE_ANY: gnt_widget_set_name(ggc->window, "conversation-window-any" ); ggc->tv = gnt_text_view_new(); gnt_widget_set_name(ggc->tv, "conversation-window-textview"); gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"), purple_prefs_get_int(PREF_ROOT "/size/height")); if (type == PURPLE_CONV_TYPE_CHAT) { FinchConvChat *fc = ggc->u.chat = g_new0(FinchConvChat, 1); hbox = gnt_hbox_new(FALSE); gnt_box_set_pad(GNT_BOX(hbox), 0); tree = fc->userlist = gnt_tree_new_with_columns(2); gnt_tree_set_col_width(GNT_TREE(tree), 0, 1); /* The flag column */ gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)g_utf8_collate); gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); gnt_tree_set_search_column(GNT_TREE(tree), 1); GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); gnt_box_add_widget(GNT_BOX(hbox), ggc->tv); gnt_box_add_widget(GNT_BOX(hbox), tree); gnt_box_add_widget(GNT_BOX(ggc->window), hbox); g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(create_conv_from_userlist), ggc); gnt_widget_set_visible(tree, purple_prefs_get_bool(PREF_USERLIST)); ggc->u.im = g_new0(FinchConvIm, 1); gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv); ggc->info = gnt_vbox_new(FALSE); gnt_box_add_widget(GNT_BOX(ggc->window), ggc->info); ggc->entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); gnt_widget_set_name(ggc->entry, "conversation-window-entry"); gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry); gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry); g_signal_connect_after(G_OBJECT(ggc->entry), "activate", G_CALLBACK(entry_key_pressed), ggc); g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL); g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"), purple_prefs_get_int(PREF_ROOT "/position/y")); gnt_widget_show(ggc->window); g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); if (type == PURPLE_CONV_TYPE_IM) { g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); convnode = get_conversation_blist_node(conv); if ((convnode && purple_blist_node_get_bool(convnode, "gnt-mute-sound")) || !finch_sound_is_enabled()) ggc->flags |= FINCH_CONV_NO_SOUND; gg_setup_commands(ggc, FALSE); purple_signal_connect(purple_cmds_get_handle(), "cmd-added", ggc, G_CALLBACK(cmd_added_cb), ggc); purple_signal_connect(purple_cmds_get_handle(), "cmd-removed", ggc, G_CALLBACK(cmd_removed_cb), ggc); gnt_box_give_focus_to_child(GNT_BOX(ggc->window), ggc->entry); g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc); finch_destroy_conversation(PurpleConversation *conv) FinchConv *ggc = FINCH_GET_DATA(conv); ggc->list = g_list_remove(ggc->list, conv); if (ggc->list && conv == ggc->active_conv) { ggc->active_conv = ggc->list->data; gg_setup_commands(ggc, TRUE); purple_signals_disconnect_by_handle(ggc); gnt_widget_destroy(ggc->window); finch_write_common(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime) FinchConv *ggconv = FINCH_GET_DATA(conv); GntTextFormatFlags fl = 0; g_return_if_fail(ggconv != NULL); if ((flags & PURPLE_MESSAGE_SYSTEM) && !(flags & PURPLE_MESSAGE_NOTIFY)) { flags &= ~(PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV); if (ggconv->active_conv != conv) { if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) finch_conversation_set_active(conv); pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv)); gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE); gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); /* Unnecessary to print the timestamp for delayed message */ if (purple_prefs_get_bool("/finch/conversations/timestamps")) { gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), gnt_color_pair(color_timestamp)); gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL); if (flags & PURPLE_MESSAGE_AUTO_RESP) gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) && !(flags & PURPLE_MESSAGE_NOTIFY)) GntTextFormatFlags msgflags = GNT_TEXT_FLAG_NORMAL; if (purple_message_meify((char*)message, -1)) { name = g_strdup_printf("*** %s", who); if (!(flags & PURPLE_MESSAGE_SEND) && (flags & PURPLE_MESSAGE_NICK)) msgflags = gnt_color_pair(color_message_highlight); msgflags = gnt_color_pair(color_message_action); name = g_strdup_printf("%s", who); if (flags & PURPLE_MESSAGE_SEND) msgflags = gnt_color_pair(color_message_send); else if (flags & PURPLE_MESSAGE_NICK) msgflags = gnt_color_pair(color_message_highlight); msgflags = gnt_color_pair(color_message_receive); gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), me ? " " : ": ", GNT_TEXT_FLAG_NORMAL); if (flags & PURPLE_MESSAGE_ERROR) fl |= GNT_TEXT_FLAG_BOLD; /* XXX: Remove this workaround when textview can parse messages. */ newline = purple_strdup_withhtml(message); strip = purple_markup_strip_html(newline); gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM && purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv)) == PURPLE_TYPING) { strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv), strip, GNT_TEXT_FLAG_DIM, "typing"); gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) gnt_widget_set_urgent(ggconv->tv); if (flags & PURPLE_MESSAGE_RECV && !gnt_widget_has_focus(ggconv->window)) { int count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count")); purple_conversation_set_data(conv, "unseen-count", GINT_TO_POINTER(count + 1)); purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN); finch_write_chat(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime) purple_conversation_write(conv, who, message, flags, mtime); finch_write_im(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime) PurpleAccount *account = purple_conversation_get_account(conv); if (flags & PURPLE_MESSAGE_SEND) who = purple_connection_get_display_name(purple_account_get_connection(account)); who = purple_account_get_alias(account); who = purple_account_get_username(account); else if (flags & PURPLE_MESSAGE_RECV) who = purple_conversation_get_name(conv); buddy = purple_find_buddy(account, who); who = purple_buddy_get_contact_alias(buddy); purple_conversation_write(conv, who, message, flags, mtime); finch_write_conv(PurpleConversation *conv, const char *who, const char *alias, const char *message, PurpleMessageFlags flags, time_t mtime) finch_write_common(conv, name, message, flags, mtime); chat_flag_text(PurpleConvChatBuddyFlags flags) if (flags & PURPLE_CBFLAGS_FOUNDER) if (flags & PURPLE_CBFLAGS_OP) if (flags & PURPLE_CBFLAGS_HALFOP) if (flags & PURPLE_CBFLAGS_VOICE) finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) FinchConv *ggc = FINCH_GET_DATA(conv); GntEntry *entry = GNT_ENTRY(ggc->entry); /* Print the list of users in the room */ GString *string = g_string_new(NULL); int count = g_list_length(users); ngettext("List of %d user:\n", "List of %d users:\n", count), count); for (iter = users; iter; iter = iter->next) PurpleConvChatBuddy *cbuddy = iter->data; if ((str = cbuddy->alias) == NULL) g_string_append_printf(string, "[ %s ]", str); purple_conversation_write(conv, NULL, string->str, PURPLE_MESSAGE_SYSTEM, time(NULL)); g_string_free(string, TRUE); for (; users; users = users->next) PurpleConvChatBuddy *cbuddy = users->data; GntTree *tree = GNT_TREE(ggc->u.chat->userlist); gnt_entry_add_suggest(entry, cbuddy->name); gnt_entry_add_suggest(entry, cbuddy->alias); gnt_tree_add_row_after(tree, g_strdup(cbuddy->name), gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL); finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) /* Update the name for string completion */ FinchConv *ggc = FINCH_GET_DATA(conv); GntEntry *entry = GNT_ENTRY(ggc->entry); GntTree *tree = GNT_TREE(ggc->u.chat->userlist); PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n); gnt_entry_remove_suggest(entry, old); gnt_tree_remove(tree, (gpointer)old); gnt_entry_add_suggest(entry, new_n); gnt_entry_add_suggest(entry, new_a); gnt_tree_add_row_after(tree, g_strdup(new_n), gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL); finch_chat_remove_users(PurpleConversation *conv, GList *list) /* Remove the name from string completion */ FinchConv *ggc = FINCH_GET_DATA(conv); GntEntry *entry = GNT_ENTRY(ggc->entry); for (; list; list = list->next) { GntTree *tree = GNT_TREE(ggc->u.chat->userlist); gnt_entry_remove_suggest(entry, list->data); gnt_tree_remove(tree, list->data); finch_chat_update_user(PurpleConversation *conv, const char *user) PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); FinchConv *ggc = FINCH_GET_DATA(conv); gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); finch_conv_present(PurpleConversation *conv) FinchConv *fc = FINCH_CONV(conv); gnt_window_present(fc->window); finch_conv_has_focus(PurpleConversation *conv) FinchConv *fc = FINCH_CONV(conv); return gnt_widget_has_focus(fc->window); static PurpleConversationUiOps conv_ui_ops = finch_create_conversation, finch_destroy_conversation, finch_conv_present, /* present */ finch_conv_has_focus, /* has_focus */ NULL, /* custom_smiley_add */ NULL, /* custom_smiley_write */ NULL, /* custom_smiley_close */ PurpleConversationUiOps *finch_conv_get_ui_ops() say_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data) if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]); else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]); return PURPLE_CMD_RET_OK; me_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data) tmp = g_strdup_printf("/me %s", args[0]); if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) purple_conv_im_send(PURPLE_CONV_IM(conv), tmp); else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp); return PURPLE_CMD_RET_OK; debug_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data) if (!g_ascii_strcasecmp(args[0], "version")) { tmp = g_strdup_printf("Using Finch v%s with libpurple v%s.", DISPLAY_VERSION, purple_core_get_version()); } else if (!g_ascii_strcasecmp(args[0], "plugins")) { /* Show all the loaded plugins, including the protocol plugins and plugin loaders. * This is intentional, since third party prpls are often sources of bugs, and some * plugin loaders (e.g. mono) can also be buggy. GString *str = g_string_new("Loaded Plugins: "); const GList *plugins = purple_plugins_get_loaded(); for (; plugins; plugins = plugins->next) { str = g_string_append(str, purple_plugin_get_name(plugins->data)); str = g_string_append(str, ", "); str = g_string_append(str, "(none)"); tmp = g_string_free(str, FALSE); purple_conversation_write(conv, NULL, _("Supported debug options are: plugins version"), PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); return PURPLE_CMD_RET_OK; markup = g_markup_escape_text(tmp, -1); if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) purple_conv_im_send(PURPLE_CONV_IM(conv), markup); else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) purple_conv_chat_send(PURPLE_CONV_CHAT(conv), markup); return PURPLE_CMD_RET_OK; clear_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data) purple_conversation_clear_message_history(conv); return PURPLE_CMD_RET_OK; help_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data) text = purple_cmd_help(conv, args[0]); for (l = text; l; l = l->next) g_string_append_printf(s, "%s\n", (char *)l->data); g_string_append_printf(s, "%s", (char *)l->data); g_string_append(s, _("No such command (in this context).")); s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" "The following commands are available in this context:\n")); text = purple_cmd_list(conv); for (l = text; l; l = l->next) g_string_append_printf(s, "%s, ", (char *)l->data); g_string_append_printf(s, "%s.", (char *)l->data); purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); return PURPLE_CMD_RET_OK; cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) void (*callback)(void) = data; return PURPLE_CMD_RET_OK; cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) if (strcmp(args[0], "receive") == 0) msgclass = &color_message_receive; else if (strcmp(args[0], "send") == 0) msgclass = &color_message_send; else if (strcmp(args[0], "highlight") == 0) msgclass = &color_message_highlight; else if (strcmp(args[0], "action") == 0) msgclass = &color_message_action; else if (strcmp(args[0], "timestamp") == 0) msgclass = &color_timestamp; *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]); return PURPLE_CMD_RET_FAILED; fg = gnt_colors_get_color(args[1]); *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]); return PURPLE_CMD_RET_FAILED; bg = gnt_colors_get_color(args[2]); *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]); return PURPLE_CMD_RET_FAILED; init_pair(*msgclass, fg, bg); return PURPLE_CMD_RET_OK; users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) FinchConv *fc = FINCH_GET_DATA(conv); return PURPLE_CMD_RET_FAILED; gnt_widget_set_visible(ch->userlist, (GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE))); gnt_box_readjust(GNT_BOX(fc->window)); gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry); purple_prefs_set_bool(PREF_USERLIST, !(GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE))); return PURPLE_CMD_RET_OK; void finch_conversation_init() color_message_send = gnt_style_get_color(NULL, "color-message-sent"); color_message_send = gnt_color_add_pair(COLOR_CYAN, -1); color_message_receive = gnt_style_get_color(NULL, "color-message-received"); if (!color_message_receive) color_message_receive = gnt_color_add_pair(COLOR_RED, -1); color_message_highlight = gnt_style_get_color(NULL, "color-message-highlight"); if (!color_message_highlight) color_message_highlight = gnt_color_add_pair(COLOR_GREEN, -1); color_timestamp = gnt_style_get_color(NULL, "color-timestamp"); color_timestamp = gnt_color_add_pair(COLOR_BLUE, -1); color_message_action = gnt_style_get_color(NULL, "color-message-action"); if (!color_message_action) color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1); purple_prefs_add_none(PREF_ROOT); purple_prefs_add_none(PREF_ROOT "/size"); purple_prefs_add_int(PREF_ROOT "/size/width", 70); purple_prefs_add_int(PREF_ROOT "/size/height", 20); purple_prefs_add_none(PREF_ROOT "/position"); purple_prefs_add_int(PREF_ROOT "/position/x", 0); purple_prefs_add_int(PREF_ROOT "/position/y", 0); purple_prefs_add_none(PREF_CHAT); purple_prefs_add_bool(PREF_USERLIST, FALSE); purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, help_command_cb, _("help <command>: Help on a specific command."), NULL); purple_cmd_register("users", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, users_command_cb, _("users: Show the list of users in the chat."), NULL); /* Now some commands to bring up some other windows */ purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all); purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show); purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all); purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show); purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all); purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_show_window, _("statuses: Show the savedstatuses window."), finch_savedstatus_show_all); /* Allow customizing the message colors using a command during run-time */ purple_cmd_register("msgcolor", "www", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_message_color, _("msgcolor <class> <foreground> <background>: " "Set the color for different classes of messages in the conversation window.<br>" " <class>: receive, send, highlight, action, timestamp<br>" " <foreground/background>: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>" "EXAMPLE:<br> msgcolor send cyan default"), purple_cmd_register("msgcolour", "www", PURPLE_CMD_P_DEFAULT, PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, cmd_message_color, _("msgcolor <class> <foreground> <background>: " "Set the color for different classes of messages in the conversation window.<br>" " <class>: receive, send, highlight, action, timestamp<br>" " <foreground/background>: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>" "EXAMPLE:<br> msgcolor send cyan default"), purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", finch_conv_get_handle(), PURPLE_CALLBACK(update_buddy_typing), NULL); purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped", finch_conv_get_handle(), PURPLE_CALLBACK(update_buddy_typing), NULL); purple_signal_connect(purple_conversations_get_handle(), "chat-left", finch_conv_get_handle(), PURPLE_CALLBACK(chat_left_cb), NULL); purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history", finch_conv_get_handle(), PURPLE_CALLBACK(cleared_message_history_cb), NULL); purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", finch_conv_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off), NULL); purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_conv_get_handle(), PURPLE_CALLBACK(buddy_signed_on_off), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-on", finch_conv_get_handle(), PURPLE_CALLBACK(account_signed_on_off), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_conv_get_handle(), PURPLE_CALLBACK(account_signed_on_off), NULL); purple_signal_connect(purple_connections_get_handle(), "signing-off", finch_conv_get_handle(), PURPLE_CALLBACK(account_signing_off), NULL); void finch_conversation_uninit() purple_signals_disconnect_by_handle(finch_conv_get_handle()); void finch_conversation_set_active(PurpleConversation *conv) FinchConv *ggconv = FINCH_GET_DATA(conv); g_return_if_fail(ggconv); g_return_if_fail(g_list_find(ggconv->list, conv)); if (ggconv->active_conv == conv) ggconv->active_conv = conv; gg_setup_commands(ggconv, TRUE); account = purple_conversation_get_account(conv); title = get_conversation_title(conv, account); gnt_screen_rename_widget(ggconv->window, title); void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget) FinchConv *fc = FINCH_GET_DATA(conv); gnt_box_remove_all(GNT_BOX(fc->info)); gnt_box_add_widget(GNT_BOX(fc->info), widget); gnt_box_readjust(GNT_BOX(fc->info)); gnt_widget_get_size(fc->window, &width, &height); gnt_box_readjust(GNT_BOX(fc->window)); gnt_screen_resize_widget(fc->window, width, height); gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry);