view finch/gntconn.c @ 16569:99bf55ec6ca4

Fix an invalid read that occurs because we were accessing IM data when the conversation was a chat. Here's the relevant valgrind output. ==18344== Invalid read of size 4 ==18344== at 0x8089DA1: update_typing_icon (gtkconv.c:3138) ==18344== by 0x8090742: pidgin_conv_update_fields (gtkconv.c:6081) ... ==18344== Address 0x107EADD0 is 12 bytes after a block of size 12 alloc'd ==18344== at 0x40056D5: calloc (vg_replace_malloc.c:279) ==18344== by 0x4D48EC4D: g_malloc0 (in /usr/lib/libglib-2.0.so.0.1200.4) ==18344== by 0x809149B: private_gtkconv_new (gtkconv.c:4608) ==18344== by 0x4056637: purple_conversation_new (conversation.c:324) ==18344== by 0x40785EB: serv_got_joined_chat (server.c:699) ==18344== by 0x493C813: irc_msg_join (msgs.c:722) ...
author Richard Laager <rlaager@wiktel.com>
date Sat, 28 Apr 2007 05:37:56 +0000
parents 08db93bbd798
children 46f2f86e08e4
line wrap: on
line source

/**
 * @file gntconn.c GNT Connection API
 * @ingroup finch
 *
 * finch
 *
 * 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
 * source distribution.
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include "account.h"
#include "core.h"
#include "request.h"

#include "gntconn.h"
#include "finch.h"

static void
finch_connection_report_disconnect(PurpleConnection *gc, const char *text)
{
	char *act, *primary, *secondary;
	PurpleAccount *account = purple_connection_get_account(gc);

	act = g_strdup_printf(_("%s (%s)"), purple_account_get_username(account),
			purple_account_get_protocol_name(account));

	primary = g_strdup_printf(_("%s disconnected."), act);
	secondary = g_strdup_printf(_("%s was disconnected due to the following error:\n%s"),
			act, text);

	purple_request_action(account, _("Connection Error"), primary, secondary, 1,
						account, NULL, NULL,
						account, 2,
						_("OK"), NULL,
						_("Connect"),
						PURPLE_CALLBACK(purple_account_connect));

	g_free(act);
	g_free(primary);
	g_free(secondary);
}

static PurpleConnectionUiOps ops = 
{
	.connect_progress = NULL,
	.connected = NULL,
	.disconnected = NULL,
	.notice = NULL,
	.report_disconnect = finch_connection_report_disconnect
};

PurpleConnectionUiOps *finch_connections_get_ui_ops()
{
	return &ops;
}

void finch_connections_init()
{}

void finch_connections_uninit()
{}