pidgin/pidgin

Parents 2e4dd08b0131
Children f72e153dd417
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
--- a/finch/gntconv.c Thu Jun 12 19:03:54 2014 +0200
+++ b/finch/gntconv.c Thu Jun 12 21:00:05 2014 +0200
@@ -1090,18 +1090,13 @@
}
static void
-finch_write_conv(PurpleConversation *conv, const char *who, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime)
+finch_write_conv(PurpleConversation *conv, PurpleMessage *msg)
{
- const char *name;
- if (alias && *alias)
- name = alias;
- else if (who && *who)
- name = who;
- else
- name = NULL;
-
- finch_write_common(conv, name, message, flags, mtime);
+ finch_write_common(conv,
+ purple_message_get_author_alias(msg),
+ purple_message_get_contents(msg),
+ purple_message_get_flags(msg),
+ purple_message_get_time(msg));
}
static const char *
--- a/libpurple/conversation.c Thu Jun 12 19:03:54 2014 +0200
+++ b/libpurple/conversation.c Thu Jun 12 21:00:05 2014 +0200
@@ -644,7 +644,7 @@
purple_message_set_author_alias(pmsg, alias);
}
- else
+ else if (purple_message_get_flags(pmsg) & PURPLE_MESSAGE_RECV)
{
/* TODO: PurpleDude - folks not on the buddy list */
b = purple_blist_find_buddy(account,
@@ -672,14 +672,8 @@
}
}
- if (ops && ops->write_conv) {
- ops->write_conv(conv,
- (purple_message_get_flags(pmsg) & PURPLE_MESSAGE_SEND) ? purple_message_get_recipient(pmsg) : purple_message_get_author(pmsg),
- purple_message_get_author_alias(pmsg),
- purple_message_get_contents(pmsg),
- purple_message_get_flags(pmsg),
- purple_message_get_time(pmsg));
- }
+ if (ops && ops->write_conv)
+ ops->write_conv(conv, pmsg);
add_message_to_history(conv,
(purple_message_get_flags(pmsg) & PURPLE_MESSAGE_SEND) ? purple_message_get_recipient(pmsg) : purple_message_get_author(pmsg),
--- a/libpurple/conversation.h Thu Jun 12 19:03:54 2014 +0200
+++ b/libpurple/conversation.h Thu Jun 12 21:00:05 2014 +0200
@@ -252,13 +252,7 @@
void (*write_chat)(PurpleChatConversation *chat, PurpleMessage *msg);
void (*write_im)(PurpleIMConversation *im, PurpleMessage *msg);
-
- void (*write_conv)(PurpleConversation *conv,
- const char *name,
- const char *alias,
- const char *message,
- PurpleMessageFlags flags,
- time_t mtime);
+ void (*write_conv)(PurpleConversation *conv, PurpleMessage *msg);
void (*chat_add_users)(PurpleChatConversation *chat,
GList *cbuddies,
--- a/libpurple/example/nullclient.c Thu Jun 12 19:03:54 2014 +0200
+++ b/libpurple/example/nullclient.c Thu Jun 12 21:00:05 2014 +0200
@@ -117,20 +117,15 @@
/*** Conversation uiops ***/
static void
-null_write_conv(PurpleConversation *conv, const char *who, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime)
+null_write_conv(PurpleConversation *conv, PurpleMessage *msg)
{
- const char *name;
- if (alias && *alias)
- name = alias;
- else if (who && *who)
- name = who;
- else
- name = NULL;
+ time_t mtime = purple_message_get_time(msg);
- printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv),
- purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
- name, message);
+ printf("(%s) %s %s: %s\n",
+ purple_conversation_get_name(conv),
+ purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
+ purple_message_get_author_alias(msg),
+ purple_message_get_contents(msg));
}
static PurpleConversationUiOps null_conv_uiops =
--- a/pidgin/gtkconv.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/gtkconv.c Thu Jun 12 21:00:05 2014 +0200
@@ -6392,8 +6392,8 @@
replace_message_tokens(
const char *text,
PurpleConversation *conv,
- const char *name,
- const char *alias,
+ const char *name, /* author */
+ const char *alias, /* author's alias */
const char *message,
PurpleMessageFlags flags,
time_t mtime)
@@ -6655,9 +6655,7 @@
}
static void
-pidgin_conv_write_conv(PurpleConversation *conv, const char *name, const char *alias,
- const char *message, PurpleMessageFlags flags,
- time_t mtime)
+pidgin_conv_write_conv(PurpleConversation *conv, PurpleMessage *pmsg)
{
PidginConversation *gtkconv;
PurpleConnection *gc;
@@ -6680,17 +6678,18 @@
#endif
const char *message_html;
- char *msg;
+ char *msg_tokenized;
char *escape;
char *script;
char *smileyed;
gchar *imgized;
- PurpleMessageFlags old_flags;
+ PurpleMessageFlags flags, old_flags;
const char *func = "appendMessage";
g_return_if_fail(conv != NULL);
gtkconv = PIDGIN_CONVERSATION(conv);
g_return_if_fail(gtkconv != NULL);
+ flags = purple_message_get_flags(pmsg);
if (gtkconv->attach_timer) {
/* We are currently in the process of filling up the buffer with the message
@@ -6727,14 +6726,14 @@
/* Make sure URLs are clickable */
if(flags & PURPLE_MESSAGE_NO_LINKIFY)
- displaying = g_strdup(message);
+ displaying = g_strdup(purple_message_get_contents(pmsg));
else
- displaying = purple_markup_linkify(message);
+ displaying = purple_markup_linkify(purple_message_get_contents(pmsg));
plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1(
- pidgin_conversations_get_handle(), (PURPLE_IS_IM_CONVERSATION(conv) ?
- "displaying-im-msg" : "displaying-chat-msg"),
- account, name, &displaying, conv, flags));
+ pidgin_conversations_get_handle(),
+ (PURPLE_IS_IM_CONVERSATION(conv) ? "displaying-im-msg" : "displaying-chat-msg"),
+ conv, pmsg));
if (plugin_return)
{
g_free(displaying);
@@ -6762,7 +6761,7 @@
g_assert(last_msg != NULL);
/* If the senders are the same, use appendNextMessage */
- if (purple_strequal(purple_conversation_message_get_sender(last_msg), name)) {
+ if (purple_strequal(purple_conversation_message_get_sender(last_msg), purple_message_get_author(pmsg))) {
message_html = pidgin_conversation_theme_get_template(gtkconv->theme,
PIDGIN_CONVERSATION_THEME_TEMPLATE_INCOMING_NEXT_CONTENT);
func = "appendNextMessage";
@@ -6785,8 +6784,13 @@
(flags & PURPLE_MESSAGE_RECV), pidgin_conv_write_smiley,
(gpointer)purple_account_get_protocol_name(account));
imgized = box_remote_images(conv, smileyed);
- msg = replace_message_tokens(message_html, conv, name, alias, imgized, flags, mtime);
- escape = pidgin_webview_quote_js_string(msg ? msg : "");
+ msg_tokenized = replace_message_tokens(message_html, conv,
+ purple_message_get_author(pmsg),
+ purple_message_get_author_alias(pmsg),
+ imgized,
+ purple_message_get_flags(pmsg),
+ purple_message_get_time(pmsg));
+ escape = pidgin_webview_quote_js_string(msg_tokenized ? msg_tokenized : "");
script = g_strdup_printf("%s(%s)", func, escape);
purple_debug_info("webkit", "JS: %s\n", script);
@@ -6795,7 +6799,7 @@
g_free(script);
g_free(smileyed);
g_free(imgized);
- g_free(msg);
+ g_free(msg_tokenized);
g_free(escape);
#if 0
@@ -7004,7 +7008,7 @@
struct tm *history_since_tm;
const char *history_since_s, *prev_history_since_s;
- history_since = mtime + 1;
+ history_since = purple_message_get_time(pmsg) + 1;
prev_history_since_s = g_hash_table_lookup(comps,
"history_since");
@@ -7034,7 +7038,7 @@
purple_signal_emit(pidgin_conversations_get_handle(),
(PURPLE_IS_IM_CONVERSATION(conv) ? "displayed-im-msg" : "displayed-chat-msg"),
- account, name, displaying, conv, flags);
+ conv, pmsg);
g_free(displaying);
update_typing_message(gtkconv, NULL);
}
@@ -8493,6 +8497,8 @@
pidgin_webview_scroll_to_end(webview, TRUE);
g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL);
}
+#if 0
+ /* TODO */
pidgin_conv_write_conv(
purple_conversation_message_get_conversation(msg),
purple_conversation_message_get_sender(msg),
@@ -8500,6 +8506,7 @@
purple_conversation_message_get_message(msg),
purple_conversation_message_get_flags(msg),
purple_conversation_message_get_timestamp(msg));
+#endif
if (im) {
gtkconv->attach_current = g_list_delete_link(gtkconv->attach_current, gtkconv->attach_current);
} else {
@@ -8528,6 +8535,8 @@
}
msgs = g_list_sort(msgs, message_compare);
for (; msgs; msgs = g_list_delete_link(msgs, msgs)) {
+#if 0
+ /* TODO */
PurpleConversationMessage *msg = msgs->data;
pidgin_conv_write_conv(
purple_conversation_message_get_conversation(msg),
@@ -8536,6 +8545,7 @@
purple_conversation_message_get_message(msg),
purple_conversation_message_get_flags(msg),
purple_conversation_message_get_timestamp(msg));
+#endif
}
pidgin_webview_append_html(webview, "<BR><HR>");
pidgin_webview_scroll_to_end(webview, TRUE);
@@ -8776,26 +8786,20 @@
G_TYPE_BOOLEAN);
purple_signal_register(handle, "displaying-im-msg",
- purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
- G_TYPE_BOOLEAN, 5, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
- G_TYPE_POINTER, /* pointer to a string */
- PURPLE_TYPE_CONVERSATION, G_TYPE_INT);
+ purple_marshal_BOOLEAN__POINTER_POINTER,
+ G_TYPE_BOOLEAN, 2, PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displayed-im-msg",
- purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT,
- G_TYPE_NONE, 5, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
- G_TYPE_STRING, PURPLE_TYPE_CONVERSATION, G_TYPE_INT);
+ purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+ PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displaying-chat-msg",
- purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER,
- G_TYPE_BOOLEAN, 5, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
- G_TYPE_POINTER, /* pointer to a string */
- PURPLE_TYPE_CONVERSATION, G_TYPE_INT);
+ purple_marshal_BOOLEAN__POINTER_POINTER,
+ G_TYPE_BOOLEAN, 2, PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displayed-chat-msg",
- purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT,
- G_TYPE_NONE, 5, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
- G_TYPE_STRING, PURPLE_TYPE_CONVERSATION, G_TYPE_INT);
+ purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+ PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "conversation-switched",
purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
--- a/pidgin/plugins/crazychat/cc_pidgin_plugin.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/plugins/crazychat/cc_pidgin_plugin.c Thu Jun 12 21:00:05 2014 +0200
@@ -71,8 +71,7 @@
* @param message the message we are displaying
* @param data user data
*/
-static gboolean display_im_cb(PurpleAccount *account, const char *who, char **message,
- PurpleConnection *conv, PurpleMessageFlags flags, void *data);
+static gboolean display_im_cb(PurpleConversation *conv, PurpleMessage *pmsg, gpointer data);
/**
* Callback for CrazyChat plugin configuration frame
@@ -247,8 +246,8 @@
return FALSE;
}
-static gboolean display_im_cb(PurpleAccount *account, PurpleConversation *conv,
- char **message, void *data)
+static gboolean
+display_im_cb(PurpleConversation *conv, PurpleMessage *pmsg, gpointer data);
{
struct crazychat *cc;
--- a/pidgin/plugins/gtk-signals-test.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/plugins/gtk-signals-test.c Thu Jun 12 21:00:05 2014 +0200
@@ -62,39 +62,39 @@
}
static gboolean
-displaying_im_msg_cb(PurpleAccount *account, const char *who, char **buffer,
- PurpleConversation *conv, PurpleMessageFlags flags, void *data)
+displaying_im_msg_cb(PurpleConversation *conv, PurpleMessage *pmsg, gpointer data)
{
purple_debug_misc("gtk-signals test", "displaying-im-msg (%s, %s)\n",
- purple_conversation_get_name(conv), *buffer);
+ purple_conversation_get_name(conv),
+ purple_message_get_contents(pmsg));
return FALSE;
}
static void
-displayed_im_msg_cb(PurpleAccount *account, const char *who, const char *buffer,
- PurpleConversation *conv, PurpleMessageFlags flags, void *data)
+displayed_im_msg_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer data)
{
purple_debug_misc("gtk-signals test", "displayed-im-msg (%s, %s)\n",
- purple_conversation_get_name(conv), buffer);
+ purple_conversation_get_name(conv),
+ purple_message_get_contents(msg));
}
static gboolean
-displaying_chat_msg_cb(PurpleAccount *account, const char *who, char **buffer,
- PurpleConversation *conv, PurpleMessageFlags flags, void *data)
+displaying_chat_msg_cb(PurpleConversation *conv, PurpleMessage *pmsg, gpointer data)
{
purple_debug_misc("gtk-signals test", "displaying-chat-msg (%s, %s)\n",
- purple_conversation_get_name(conv), *buffer);
+ purple_conversation_get_name(conv),
+ purple_message_get_contents(pmsg));
return FALSE;
}
static void
-displayed_chat_msg_cb(PurpleAccount *account, const char *who, const char *buffer,
- PurpleConversation *conv, PurpleMessageFlags flags, void *data)
+displayed_chat_msg_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer data)
{
purple_debug_misc("gtk-signals test", "displayed-chat-msg (%s, %s)\n",
- purple_conversation_get_name(conv), buffer);
+ purple_conversation_get_name(conv),
+ purple_message_get_contents(msg));
}
static void
--- a/pidgin/plugins/notify.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/plugins/notify.c Thu Jun 12 21:00:05 2014 +0200
@@ -258,9 +258,10 @@
}
static gboolean
-message_displayed_cb(PurpleAccount *account, const char *who, char *message,
- PurpleConversation *conv, PurpleMessageFlags flags)
+message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused)
{
+ PurpleMessageFlags flags = purple_message_get_flags(msg);
+
if ((PURPLE_IS_CHAT_CONVERSATION(conv) &&
purple_prefs_get_bool("/plugins/gtk/X11/notify/type_chat_nick") &&
!(flags & PURPLE_MESSAGE_NICK)))
--- a/pidgin/plugins/unity.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/plugins/unity.c Thu Jun 12 21:00:05 2014 +0200
@@ -183,9 +183,10 @@
}
static gboolean
-message_displayed_cb(PurpleAccount *account, const char *who, char *message,
- PurpleConversation *conv, PurpleMessageFlags flags)
+message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused)
{
+ PurpleMessageFlags flags = purple_message_get_flags(msg);
+
if ((PURPLE_IS_CHAT_CONVERSATION(conv) && alert_chat_nick &&
!(flags & PURPLE_MESSAGE_NICK)))
return FALSE;
--- a/pidgin/win32/gtkwin32dep.c Thu Jun 12 19:03:54 2014 +0200
+++ b/pidgin/win32/gtkwin32dep.c Thu Jun 12 21:00:05 2014 +0200
@@ -377,8 +377,7 @@
}
static gboolean
-winpidgin_conv_im_blink(PurpleAccount *account, const char *who, char **message,
- PurpleConversation *conv, PurpleMessageFlags flags, void *data)
+winpidgin_conv_im_blink(PurpleConversation *conv, PurpleMessage *pmsg)
{
if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/win32/blink_im"))
winpidgin_conv_blink(conv, flags);