Commit 9619e426 authored by Rob Smits's avatar Rob Smits
Browse files

Fixes from code review.

parent 8caae1fc
......@@ -302,7 +302,7 @@ The Off-the-Record Messaging plugin for pidgin is covered by the following
Off-the-Record Messaging plugin for pidgin
Copyright (C) 2004-2012 Ian Goldberg, Rob Smits,
Chris Alexander, Willy Lew,
Lisa Du, Nikita Borisov
Lisa Du, Nikita Borisov
<otr@cypherpunks.ca>
......
......@@ -35,6 +35,8 @@
#define SESSIONID_HELPURL BASE_HELPURL "sessionid.php"
#define UNVERIFIED_HELPURL BASE_HELPURL "unverified.php"
#define LEVELS_HELPURL BASE_HELPURL "levels.php"
#define SESSIONS_HELPURL BASE_HELPURL "sessions.php"
typedef struct s_OtrgDialogWait *OtrgDialogWaitHandle;
......@@ -119,7 +121,7 @@ void otrg_dialog_notify_info(const char *accountname, const char *protocol,
/* Display an OTR control message for the given accountname / protocol /
* username conversation. Return 0 on success, non-0 on error (in which
* case the message will be displayed inline as a received message). */
int otrg_dialog_display_otr_message( const char *accountname,
int otrg_dialog_display_otr_message(const char *accountname,
const char *protocol, const char *username, const char *msg,
int force_create);
......
......@@ -113,27 +113,26 @@ typedef struct {
ConnContext *context;
} ConvOrContext;
gint get_new_instance_index(PurpleConversation *conv) {
static gint get_new_instance_index(PurpleConversation *conv) {
gint * max_index = (gint *)
purple_conversation_get_data(conv, "otr-max_idx");
*max_index = (*max_index) + 1;
return *max_index;
}
gint get_context_instance_to_index(PurpleConversation *conv,
static gint get_context_instance_to_index(PurpleConversation *conv,
ConnContext *context) {
GHashTable * conv_to_idx_map =
purple_conversation_get_data(conv, "otr-conv_to_idx");
gint * index = 0;
gpointer index = NULL;
if (!g_hash_table_lookup_extended(conv_to_idx_map, context, NULL,
(gpointer *)&index)) {
if (!g_hash_table_lookup_extended(conv_to_idx_map, context, NULL, &index)) {
index = g_malloc(sizeof(gint));
*index = get_new_instance_index(conv);
g_hash_table_replace(conv_to_idx_map, context, (gpointer)index);
*(gint *)index = get_new_instance_index(conv);
g_hash_table_replace(conv_to_idx_map, context, index);
}
return *index;
return *(gint *)index;
}
static void close_progress_window(SMPData *smp_data)
......@@ -771,6 +770,8 @@ static GtkWidget *create_smp_dialog(const char *title, const char *primary,
close_progress_window(smp_data);
/* If you start SMP authentication on a different context, it
* will kill any existing SMP */
if (smp_data->their_instance != context->their_instance) {
otrg_gtk_dialog_free_smp_data(conv);
otrg_gtk_dialog_add_smp_data(conv);
......@@ -1612,7 +1613,7 @@ static void otrg_gtk_dialog_connected(ConnContext *context)
context->protocol_version == 1 ? _(" Warning: using old "
"protocol version 1.") : "", conv->logging ?
_(" Your client is logging this conversation.") :
_(" Your client is not logging this conversation."));
_(" Your client is not logging this conversation."));
purple_conversation_write(conv, NULL, buf, PURPLE_MESSAGE_SYSTEM,
time(NULL));
......@@ -1631,11 +1632,13 @@ static void otrg_gtk_dialog_connected(ConnContext *context)
if (!*have_warned_instances) {
*have_warned_instances = TRUE;
buf = g_strdup_printf(_("Your buddy is logged in multiple times and"
" OTR has established <a href=\"%s%s\">multiple sessions"
"</a>. Use the icon menu above if you wish to select the "
"outgoing session."), SESSIONS_HELPURL, _("?lang=en"));
otrg_gtk_dialog_display_otr_message(context->accountname,
context->protocol, context->username,
_("Your buddy is logged in multiple times and OTR has "
"established multiple sessions. Use the icon menu above if "
"you wish to select the outgoing session."), 0);
context->protocol, context->username, buf, 0);
g_free(buf);
}
}
}
......@@ -1874,7 +1877,7 @@ static void otr_refresh_otr_buttons(PurpleConversation *conv) {
}
/* Menu has been destroyed -- let's remove it from the menu_list
so that it won't be destroyed again */
* so that it won't be destroyed again. */
static void otr_menu_destroy(GtkWidget *widget, gpointer pdata) {
PidginWindow *win = (PidginWindow *) pdata ;
GtkWidget *top_menu = widget;
......@@ -2286,25 +2289,29 @@ static void select_meta_ctx(GtkWidget *widget, gpointer data) {
if (!context) context = (ConnContext *)
otrg_plugin_conv_to_selected_context(conv, 1);
dialog_update_label(context);
}
static void select_menu_ctx(GtkWidget *widget, gpointer data) {
ConnContext *context = (ConnContext *) data;
PurpleConversation * conv = otrg_plugin_context_to_conv(context, 1);
PurpleConversation *conv = otrg_plugin_context_to_conv(context, 1);
ConnContext *recent_context = (ConnContext *) otrg_plugin_conv_to_context(
conv, (otrl_instag_t)OTRL_INSTAG_RECENT_RECEIVED, 0);
otrl_instag_t * selected_instance = (otrl_instag_t *)
otrl_instag_t *selected_instance = (otrl_instag_t *)
purple_conversation_get_data(conv, "otr-ui_selected_ctx");
gboolean *is_multi_instance = purple_conversation_get_data(conv,
"otr-conv_multi_instances");
*selected_instance = context->their_instance;
unselect_meta_ctx(conv);
if (*is_multi_instance) {
*selected_instance = context->their_instance;
unselect_meta_ctx(conv);
}
pidgin_conv_switch_active_conversation(conv);
dialog_update_label(context);
if (context != recent_context) {
if (*is_multi_instance && context != recent_context) {
gchar *buf = g_strdup_printf(_("Warning: The selected outgoing OTR "
"session (%u) is not the most recently active one (%u). "
"Your buddy may not receive your messages. Use the icon menu "
......@@ -2324,25 +2331,18 @@ static void build_meta_instance_submenu( PurpleConversation *conv,
_("Send to most secure"));
GtkWidget *select_recent = gtk_check_menu_item_new_with_label(
_("Send to most recent"));
otrl_instag_t * selected_instance;
gboolean selected_existed = g_hash_table_lookup_extended(conv->data,
"otr-ui_selected_ctx", NULL, (gpointer*)&selected_instance);
if (selected_existed) {
if (*selected_instance == OTRL_INSTAG_BEST) {
GTK_CHECK_MENU_ITEM(select_recent)->active = 0;
GTK_CHECK_MENU_ITEM(select_best)->active = 1;
} else if (*selected_instance == OTRL_INSTAG_RECENT_RECEIVED) {
GTK_CHECK_MENU_ITEM(select_recent)->active = 1;
GTK_CHECK_MENU_ITEM(select_best)->active = 0;
} else {
GTK_CHECK_MENU_ITEM(select_recent)->active = 0;
GTK_CHECK_MENU_ITEM(select_best)->active = 0;
}
} else {
otrl_instag_t * selected_instance = purple_conversation_get_data(conv,
"otr-ui_selected_ctx");
if (*selected_instance == OTRL_INSTAG_BEST) {
GTK_CHECK_MENU_ITEM(select_recent)->active = 0;
GTK_CHECK_MENU_ITEM(select_best)->active = 1;
} else if (*selected_instance == OTRL_INSTAG_RECENT_RECEIVED) {
GTK_CHECK_MENU_ITEM(select_recent)->active = 1;
GTK_CHECK_MENU_ITEM(select_best)->active = 0;
} else {
GTK_CHECK_MENU_ITEM(select_recent)->active = 0;
GTK_CHECK_MENU_ITEM(select_best)->active = 0;
}
purple_conversation_set_data(conv, "otr-select_best", select_best);
......@@ -2361,9 +2361,16 @@ static void build_meta_instance_submenu( PurpleConversation *conv,
gtk_menu_shell_append(GTK_MENU_SHELL(menu), select_recent);
}
static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
*instances, gboolean active_conv, char *username, const char
*accountname, int *pos) {
/* Build an OTR buddy menu (where the root menu item is an icon corresponding
* to the conversation status) for a conversation that has multiple instances.
* The ConnContexts are given in the GList "instances." Keep track of the
* position this menu was inserted in the "pos" argument. "active_conv"
* corresponds to whether this conversation is the active PurpleConversation
* for this PidginConversation pane.
*/
static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv,
GList *instances, gboolean active_conv, const char *username,
const char *accountname, int *pos) {
PidginWindow *win = pidgin_conv_get_window ( gtkconv );
GtkWidget *menu_bar = win->menu.menubar;
GtkWidget *menu;
......@@ -2403,7 +2410,7 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
for (; instances; instances = instances->next) {
GtkWidget *instance_menu_item;
GtkWidget *instance_submenu;
gchar text[35] ;
gchar* text;
ConnContext *curr_context = instances->data;
ConvOrContext * curr_convctx = g_hash_table_lookup(conv_or_ctx_map,
curr_context);
......@@ -2411,7 +2418,7 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
context->their_instance);
gint instance_i = -1;
if (curr_context->their_instance == OTRL_INSTAG_MASTER &&
if (curr_context->m_context == curr_context &&
curr_context->msgstate == OTRL_MSGSTATE_PLAINTEXT) {
continue;
}
......@@ -2427,7 +2434,7 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
instance_i = get_context_instance_to_index(conv, curr_context);
g_snprintf(text, 35, _("Session %u"), instance_i);
text = g_strdup_printf(_("Session %u"), instance_i);
instance_menu_item = gtk_image_menu_item_new_with_label(text);
instance_submenu = gtk_menu_new();
......@@ -2442,6 +2449,8 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
build_otr_menu(curr_convctx, instance_submenu, level);
g_free(text);
if (!selection_exists || *instance != curr_context->their_instance) {
GtkWidget *select_ctx = gtk_menu_item_new_with_label(_("Select"));
GtkWidget *menusep = gtk_separator_menu_item_new();
......@@ -2513,9 +2522,16 @@ static void otr_add_buddy_instances_top_menu(PidginConversation *gtkconv, GList
g_hash_table_replace ( otr_win_menus, win, menu_list );
}
static void otr_add_buddy_top_menu(PidginConversation *gtkconv, ConvOrContext
*convctx, gboolean active_conv, char *username, const char
*accountname, int *pos) {
/* Build an OTR buddy menu (where the root menu item is an icon corresponding
* to the conversation status) for a conversation that does not have multiple
* instances. A pre-allocated ConvOrContext is given. Keep track of the
* position this menu was inserted in the "pos" argument. "active_conv"
* corresponds to whether this conversation is the active PurpleConversation
* for this PidginConversation pane.
*/
static void otr_add_buddy_top_menu(PidginConversation *gtkconv,
ConvOrContext *convctx, gboolean active_conv, const char *username,
const char *accountname, int *pos) {
PidginWindow *win = pidgin_conv_get_window ( gtkconv );
GtkWidget *menu_bar = win->menu.menubar;
GtkWidget *menu;
......@@ -2710,7 +2726,7 @@ static void otr_add_buddy_top_menus(PurpleConversation *conv) {
contexts_iter = contexts;
currentContext = contexts_iter->data;
while (currentContext->their_instance == OTRL_INSTAG_MASTER &&
while (currentContext->m_context == currentContext &&
contexts_iter->next != NULL) {
contexts_iter = contexts_iter->next;
currentContext = contexts_iter->data;
......@@ -2868,7 +2884,6 @@ static void conversation_destroyed(PurpleConversation *conv, void *data)
g_hash_table_remove(conv->data, "otr-max_idx");
g_hash_table_remove(conv->data, "otr-conv_multi_instances");
g_hash_table_remove(conv->data, "otr-warned_instances");
g_hash_table_remove(conv->data, "otr-last_msg_event");
g_hash_table_remove(conv->data, "otr-last_received_ctx");
#ifdef OLD_OTR_BUTTON
......@@ -3294,8 +3309,7 @@ static gboolean check_incoming_instance_change(PurpleAccount *account,
last_received_instance = g_hash_table_lookup(conv->data,
"otr-last_received_ctx");
if (last_received_instance &&
(*last_received_instance == OTRL_INSTAG_MASTER ||
if ((*last_received_instance == OTRL_INSTAG_MASTER ||
*last_received_instance >= OTRL_MIN_VALID_INSTAG)) {
have_received = TRUE;
}
......
......@@ -165,7 +165,7 @@ static void otrg_gtk_ui_update_keylist(void)
PurplePlugin *p;
char *proto_name;
if (context->their_instance != OTRL_INSTAG_MASTER) continue;
if (context->m_context != context) continue;
fingerprint = context->fingerprint_root.next;
/* If there's no fingerprint, don't add it to the known
......@@ -291,6 +291,7 @@ static void clist_selected(GtkWidget *widget, gint row, gint column,
forget_sensitive = 0;
}
else if (context_iter->msgstate == OTRL_MSGSTATE_FINISHED) {
disconnect_sensitive = 1;
connect_sensitive = 1;
}
else if (context_iter->msgstate == OTRL_MSGSTATE_PLAINTEXT) {
......@@ -315,6 +316,11 @@ static void clist_unselected(GtkWidget *widget, gint row, gint column,
clist_all_unselected();
}
/* For a given fingerprint, find the master context that the fingerprint is
* pointing to, iterate through it and all its childdren.
* Of the contexts that are using this fingerprint, return a value that
* corresponds to the "best" trust level among these.
*/
static int fngsortval(Fingerprint *f)
{
int result = 200;
......
......@@ -77,7 +77,9 @@
#include "gtk-ui.h"
#include "gtk-dialog.h"
#if defined WIN32 && defined USING_GTK /* Only for win32 beta */
#define BETA_DIALOG 1
#if defined BETA_DIALOG && defined USING_GTK /* Only for beta */
#include "gtkblist.h"
#endif
......@@ -158,13 +160,19 @@ static void notify(void *opdata, OtrlNotifyLevel level,
* protocol / username conversation. If force_create is non-zero and
* if the corresponding conversation window is not present, a new
* conversation window will be created and the message will be displayed
* there. Returns 0 if message is successfully displayed. */
static int display_otr_message(void *opdata, const char *accountname,
* there. If the message cannot be displayed, try notify() instead and
* return 1. Otherwise return 0 if message is successfully displayed. */
static int display_otr_message_or_notify(void *opdata, const char *accountname,
const char *protocol, const char *username, const char *msg,
int force_create)
int force_create, OtrlNotifyLevel level, const char *title,
const char *primary, const char *secondary)
{
return otrg_dialog_display_otr_message(accountname, protocol,
username, msg, force_create);
if (otrg_dialog_display_otr_message(accountname, protocol,
username, msg, force_create)) {
notify(opdata, level, accountname, protocol, username, title, primary,
secondary);
return 1;
} else return 0;
}
static void log_message(void *opdata, const char *message)
......@@ -417,7 +425,9 @@ static void handle_smp_event_cb(void *opdata, OtrlSMPEvent smp_event,
}
}
void otrg_emit_msg_received(ConnContext *context, const char* message) {
/* Treat this event like other incoming messages. This allows message
* notification events to get properly triggered. */
static void emit_msg_received(ConnContext *context, const char* message) {
PurpleConversation *conv = otrg_plugin_userinfo_to_conv(
context->accountname, context->protocol, context->username, 1);
PurpleMessageFlags flags = PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM
......@@ -432,11 +442,11 @@ static void handle_msg_event_cb(void *opdata, OtrlMessageEvent msg_event,
ConnContext *context, const char* message, gcry_error_t err)
{
PurpleConversation *conv = NULL;
if (!context) return;
char *buf;
const char *format;
gchar *buf;
OtrlMessageEvent * last_msg_event;
if (!context) return;
conv = otrg_plugin_context_to_conv(context, 1);
last_msg_event = g_hash_table_lookup(conv->data, "otr-last_msg_event");
......@@ -445,219 +455,149 @@ static void handle_msg_event_cb(void *opdata, OtrlMessageEvent msg_event,
case OTRL_MSGEVENT_NONE:
break;
case OTRL_MSGEVENT_ENCRYPTION_REQUIRED:
if (display_otr_message(opdata, context->accountname,
buf = g_strdup_printf(_("You attempted to send an "
"unencrypted message to %s"), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, _("Attempting to"
" start a private conversation..."), 1)) {
format = _("You attempted to send an "
"unencrypted message to %s");
buf = malloc(strlen(format) +
strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
notify(opdata, OTRL_NOTIFY_WARNING, context->accountname,
context->protocol, context->username, _("OTR Policy"
" Violation"), buf,
_("Unencrypted messages to this recipient are "
"not allowed. Attempting to start a private "
"conversation.\n\nYour message will be "
"retransmitted when the private conversation "
"starts."));
free(buf);
}
}
" start a private conversation..."), 1, OTRL_NOTIFY_WARNING,
_("OTR Policy Violation"), buf,
_("Unencrypted messages to this recipient are "
"not allowed. Attempting to start a private "
"conversation.\n\nYour message will be "
"retransmitted when the private conversation "
"starts."));
g_free(buf);
break;
case OTRL_MSGEVENT_ENCRYPTION_ERROR:
if (display_otr_message(opdata, context->accountname,
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, _("An error occurred "
"when encrypting your message. The message was not sent."
), 1)) {
notify(opdata, OTRL_NOTIFY_ERROR,
context->accountname, context->protocol,
context->username,
_("Error encrypting message"),
_("An error occurred when encrypting your message"),
_("The message was not sent."));
}
"when encrypting your message. The message was not sent.")
, 1, OTRL_NOTIFY_ERROR, _("Error encrypting message"),
_("An error occurred when encrypting your message"),
_("The message was not sent."));
break;
case OTRL_MSGEVENT_CONNECTION_ENDED:
if (display_otr_message(opdata, context->accountname,
buf = g_strdup_printf(_("%s has already closed his/her private "
"connection to you"), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, _("Your message"
"was not sent. Either end your private conversation, "
"or restart it."), 1)) {
format = _("%s has already closed his/her private "
"connection to you");
buf = malloc(strlen(format) + strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
notify(opdata, OTRL_NOTIFY_ERROR,
context->accountname, context->protocol,
context->username,
_("Private connection closed"), buf,
_("Your message was not sent. Either close your "
"private connection to him, or refresh it."));
free(buf);
}
}
"or restart it."), 1, OTRL_NOTIFY_ERROR,
_("Private connection closed"), buf,
_("Your message was not sent. Either close your "
"private connection to him, or refresh it."));
g_free(buf);
break;
case OTRL_MSGEVENT_SETUP_ERROR:
if (!err) {
err = GPG_ERR_INV_VALUE;
}
format = _("Error setting up private conversation: %s");
const char *strerr;
switch(gcry_err_code(err)) {
case GPG_ERR_INV_VALUE:
strerr = _("Malformed message received");
buf = g_strdup(_("Error setting up private "
"conversation: Malformed message received"));
break;
default:
strerr = gcry_strerror(err);
buf = g_strdup_printf(_("Error setting up private "
"conversation: %s"), gcry_strerror(err));
break;
}
buf = malloc(strlen(format) + strlen(strerr) - 1);
if (buf) {
sprintf(buf, format, strerr);
}
if (display_otr_message(opdata, context->accountname,
context->protocol, context->username, buf, 1)) {
notify(opdata, OTRL_NOTIFY_ERROR, context->accountname,
context->protocol, context->username, "OTR error",
buf, NULL);
}
free(buf);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, buf, 1,
OTRL_NOTIFY_ERROR, "OTR Error", buf, NULL);
g_free(buf);
break;
case OTRL_MSGEVENT_MSG_REFLECTED:
if (display_otr_message(opdata,
display_otr_message_or_notify(opdata,
context->accountname, context->protocol,
context->username,
_("We are receiving our own OTR messages. "
"You are either trying to talk to yourself, "
"or someone is reflecting your messages back "
"at you."), 1)) {
notify(opdata, OTRL_NOTIFY_ERROR,
context->accountname, context->protocol,
context->username, "OTR Error",
_("We are receiving our own OTR messages."),
_("You are either trying to talk to yourself, "
"or someone is reflecting your messages back "
"at you."));
}
"at you."), 1, OTRL_NOTIFY_ERROR,
"OTR Error", _("We are receiving our own OTR messages."),
_("You are either trying to talk to yourself, "
"or someone is reflecting your messages back "
"at you."));
break;
case OTRL_MSGEVENT_MSG_RESENT:
format = _("<b>The last message to %s was resent.</b>");
buf = malloc(strlen(format) +
strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
display_otr_message(opdata, context->accountname,
context->protocol, context->username, buf, 1);
free(buf);
}
buf = g_strdup_printf(_("<b>The last message to %s was resent."
"</b>"), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, buf, 1,
OTRL_NOTIFY_INFO, _("Message resent"), buf, NULL);
g_free(buf);
break;
case OTRL_MSGEVENT_RCVDMSG_NOT_IN_PRIVATE:
format = _("<b>The encrypted message received from %s is "
"unreadable, as you are not currently communicating "
"privately.</b>");
buf = malloc(strlen(format) +
strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
display_otr_message(opdata, context->accountname,
context->protocol, context->username, buf, 1);
free(buf);
}
buf = g_strdup_printf(_("<b>The encrypted message received from "
"%s is unreadable, as you are not currently communicating "
"privately.</b>"), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, buf, 1,
OTRL_NOTIFY_INFO, _("Unreadable message"), buf, NULL);
g_free(buf);
break;
case OTRL_MSGEVENT_RCVDMSG_UNREADABLE:
format = _("We received an unreadable "
"encrypted message from %s.");
buf = malloc(strlen(format) + strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
if (display_otr_message(opdata,
context->accountname, context->protocol,
context->username, buf, 1)) {
notify(opdata, OTRL_NOTIFY_ERROR,
context->accountname, context->protocol,
context->username, "OTR Error", buf, NULL);
}
free(buf);
}
buf = g_strdup_printf(_("We received an unreadable "
"encrypted message from %s."), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, buf, 1,
OTRL_NOTIFY_ERROR, "OTR Error", buf, NULL);
g_free(buf);
break;
case OTRL_MSGEVENT_RCVDMSG_MALFORMED:
format = _("We received a malformed data "
"message from %s.");
buf = malloc(strlen(format) + strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
if (display_otr_message(opdata,
context->accountname, context->protocol,
context->username, buf, 1)) {
notify(opdata, OTRL_NOTIFY_ERROR,
context->accountname, context->protocol,
context->username, "OTR Error", buf, NULL);
}
free(buf);
}
buf = g_strdup_printf(_("We received a malformed data "
"message from %s."), context->username);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, buf, 1,
OTRL_NOTIFY_ERROR, "OTR Error", buf, NULL);
g_free(buf);
break;
case OTRL_MSGEVENT_LOG_HEARTBEAT_RCVD:
format = _("Heartbeat received from %s.\n");
buf = malloc(strlen(format) + strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
log_message(opdata, buf);
free(buf);
}
buf = g_strdup_printf(_("Heartbeat received from %s.\n"),
context->username);
log_message(opdata, buf);
g_free(buf);
break;
case OTRL_MSGEVENT_LOG_HEARTBEAT_SENT:
format = _("Heartbeat sent to %s.\n");
buf = malloc(strlen(format) + strlen(context->username) - 1);
if (buf) {
sprintf(buf, format, context->username);
log_message(opdata, buf);
free(buf);
}
buf = g_strdup_printf(_("Heartbeat sent to %s.\n"),
context->username);
log_message(opdata, buf);
g_free(buf);
break;
case OTRL_MSGEVENT_RCVDMSG_GENERAL_ERR:
display_otr_message(opdata, context->accountname,
context->protocol, context->username, message, 1);
display_otr_message_or_notify(opdata, context->accountname,
context->protocol, context->username, message, 1,
OTRL_NOTIFY_ERROR, "OTR Error", message, NULL);
break;
case OTRL_MSGEVENT_RCVDMSG_UNENCRYPTED:
format = _("<b>The following message received "