Commit 38784da5 authored by Andrea Schaefer's avatar Andrea Schaefer

Fix issue #60 'console warnings glut' and #59 'who spoke last'

- #60 logged system messages led to null pointer chars that messed up 
markup concatenations
- #59 while we were on it...
parent ff85c93b
Pipeline #2309 passed with stages
in 5 minutes and 43 seconds
......@@ -1593,9 +1593,12 @@ chatty_blist_chats_update_node (PurpleBuddy *buddy,
GdkPixbuf *avatar;
GtkTreePath *path;
gchar *name = NULL;
const gchar *tag;
const gchar *alias;
const gchar *b_name;
const gchar *protocol_id;
gchar *last_msg_str = NULL;
gchar *last_msg_text = NULL;
gchar *last_msg_ts = NULL;
PurpleAccount *account;
guint color;
gboolean blur;
......@@ -1637,20 +1640,41 @@ chatty_blist_chats_update_node (PurpleBuddy *buddy,
chatty_icon_do_alphashift (avatar, 77);
}
b_name = purple_buddy_get_name (buddy);
alias = purple_buddy_get_alias (buddy);
last_msg_str = g_strconcat ("<span color='#646464'><small>",
chatty_node->conv.last_msg_timestamp,
"</small></span>",
if ((g_strcmp0 (chatty_node->conv.last_message_name, b_name)) == 0) {
tag = "";
} else {
tag = _("Me: ");
}
if (chatty_node->conv.last_message == NULL) {
chatty_node->conv.last_message = "";
}
last_msg_text = g_strconcat ("<span color='#c0c0c0'>",
tag,
"</span>",
"<span color='#646464'>",
chatty_node->conv.last_message,
"</span>",
NULL);
last_msg_ts = g_strconcat ("<span color='#646464'>",
"<small>",
chatty_node->conv.last_msg_timestamp,
"</small>"
"</span>",
NULL);
if (chatty_node->conv.flags & CHATTY_BLIST_NODE_HAS_PENDING_MESSAGE) {
name = g_strconcat ("<span color='#646464'><b>",
name = g_strconcat ("<span color='#646464'>",
alias,
"</b></span>",
"</span>",
"\n",
"<small>",
chatty_node->conv.last_message,
last_msg_text,
"</small>",
NULL);
} else {
......@@ -1658,8 +1682,9 @@ chatty_blist_chats_update_node (PurpleBuddy *buddy,
alias,
"\n",
"<small>",
chatty_node->conv.last_message,
"</small></span>",
last_msg_text,
"</small>",
"</span>",
NULL);
}
......@@ -1682,7 +1707,7 @@ chatty_blist_chats_update_node (PurpleBuddy *buddy,
COLUMN_NODE, node,
COLUMN_AVATAR, avatar,
COLUMN_NAME, name,
COLUMN_LAST, last_msg_str,
COLUMN_LAST, last_msg_ts,
-1);
}
......@@ -1691,7 +1716,8 @@ chatty_blist_chats_update_node (PurpleBuddy *buddy,
}
gtk_tree_path_free (path);
g_free (last_msg_str);
g_free (last_msg_text);
g_free (last_msg_ts);
g_free (name);
}
......@@ -1722,6 +1748,7 @@ chatty_blist_update_buddy (PurpleBuddyList *list,
if (log_data != NULL && chatty_blist_buddy_is_displayable (buddy)) {
ui = node->ui_data;
ui->conv.last_message = log_data->msg;
ui->conv.last_message_name = log_data->name;
ui->conv.last_msg_timestamp = log_data->time_stamp;
chatty_blist_chats_update_node (buddy, node);
......
......@@ -46,6 +46,7 @@ typedef struct _chatty_blist_node {
guint pending_messages;
char *last_msg_timestamp;
const char *last_message;
const char *last_message_name;
ChattyBlistNodeFlags flags;
} conv;
} ChattyBlistNode;
......
......@@ -841,10 +841,12 @@ chatty_conv_add_message_history_to_conv (gpointer data)
msg_html = chatty_conv_check_for_links (log_data->msg);
chatty_msg_list_add_message (chatty_conv->msg_list,
msg_dir,
msg_html,
time_stamp);
if (msg_html[0] != '\0') {
chatty_msg_list_add_message (chatty_conv->msg_list,
msg_dir,
msg_html,
time_stamp);
}
g_free (msg_html);
}
......@@ -1639,10 +1641,12 @@ chatty_conversations_init (void)
purple_prefs_add_none (CHATTY_PREFS_ROOT "/conversations");
purple_prefs_add_bool (CHATTY_PREFS_ROOT "/conversations/im/show_buddy_icons", TRUE);
purple_prefs_add_bool (CHATTY_PREFS_ROOT "/conversations/show_timestamps", TRUE);
purple_prefs_add_bool (CHATTY_PREFS_ROOT "/conversations/tabs", FALSE);
purple_prefs_add_bool ("/purple/logging/log_system", FALSE);
purple_prefs_set_bool ("/purple/logging/log_system", FALSE);
purple_signal_register (handle, "conversation-switched",
purple_marshal_VOID__POINTER, NULL, 1,
purple_value_new (PURPLE_TYPE_SUBTYPE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment