/pidgin/main: 2172bd6dad3e: Add purple_conversation_write_system...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Thu May 22 13:37:36 EDT 2014
Changeset: 2172bd6dad3e84c045a4e6d2c3aefd004a01e75a
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-05-22 18:33 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/2172bd6dad3e
Description:
Add purple_conversation_write_system_message
diffstat:
finch/gntmedia.c | 2 +-
libpurple/conversation.c | 7 +++++++
libpurple/conversation.h | 3 +++
libpurple/plugins/statenotify.c | 5 ++---
libpurple/protocols/irc/cmds.c | 2 +-
libpurple/protocols/irc/msgs.c | 31 +++++++++++++------------------
libpurple/protocols/jabber/chat.c | 14 +++++++-------
libpurple/protocols/jabber/jabber.c | 3 +--
libpurple/protocols/jabber/message.c | 9 +++++----
libpurple/protocols/mxit/multimx.c | 5 +++--
libpurple/protocols/null/nullprpl.c | 5 ++---
libpurple/protocols/silc/silc.c | 3 +--
libpurple/protocols/yahoo/yahoo_doodle.c | 4 ++--
libpurple/protocols/yahoo/yahoochat.c | 6 +++---
libpurple/prpl.c | 8 +-------
15 files changed, 52 insertions(+), 55 deletions(-)
diffs (truncated from 380 to 300 lines):
diff --git a/finch/gntmedia.c b/finch/gntmedia.c
--- a/finch/gntmedia.c
+++ b/finch/gntmedia.c
@@ -374,7 +374,7 @@ static void
gntmedia_message_cb(FinchMedia *gntmedia, const char *msg, PurpleConversation *conv)
{
if (PURPLE_IS_IM_CONVERSATION(conv)) {
- purple_conversation_write_message(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(conv, msg, 0);
}
}
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -696,6 +696,13 @@ purple_conversation_write_message(Purple
klass->write_message(conv, who, message, flags, mtime);
}
+void purple_conversation_write_system_message(PurpleConversation *conv,
+ const gchar *message, PurpleMessageFlags flags)
+{
+ purple_conversation_write(conv, NULL, message,
+ flags | PURPLE_MESSAGE_SYSTEM, time(NULL));
+}
+
void
purple_conversation_send(PurpleConversation *conv, const char *message)
{
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -517,6 +517,9 @@ void purple_conversation_write_message(P
const char *who, const char *message,
PurpleMessageFlags flags, time_t mtime);
+void purple_conversation_write_system_message(PurpleConversation *conv,
+ const gchar *message, PurpleMessageFlags flags);
+
/**
* purple_conversation_send:
* @conv: The conversation.
diff --git a/libpurple/plugins/statenotify.c b/libpurple/plugins/statenotify.c
--- a/libpurple/plugins/statenotify.c
+++ b/libpurple/plugins/statenotify.c
@@ -40,9 +40,8 @@ write_status(PurpleBuddy *buddy, const c
g_snprintf(buf, sizeof(buf), message, escaped);
g_free(escaped);
- purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, buf,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY | PURPLE_MESSAGE_NO_LINKIFY,
- time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(im), buf,
+ PURPLE_MESSAGE_ACTIVE_ONLY | PURPLE_MESSAGE_NO_LINKIFY);
}
static void
diff --git a/libpurple/protocols/irc/cmds.c b/libpurple/protocols/irc/cmds.c
--- a/libpurple/protocols/irc/cmds.c
+++ b/libpurple/protocols/irc/cmds.c
@@ -41,7 +41,7 @@ int irc_cmd_default(struct irc_conn *irc
return 1;
buf = g_strdup_printf(_("Unknown command: %s"), cmd);
- purple_conversation_write_message(convo, "", buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(convo, buf, PURPLE_MESSAGE_NO_LOG);
g_free(buf);
return 1;
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -281,9 +281,8 @@ void irc_msg_ban(struct irc_conn *irc, c
msg = g_strdup_printf(_("Ban on %s"), args[2]);
}
if (chat) {
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
- PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
- time(NULL));
+ purple_conversation_write_system_message(
+ PURPLE_CONVERSATION(chat), msg, PURPLE_MESSAGE_NO_LOG);
} else {
purple_debug_info("irc", "%s\n", msg);
}
@@ -292,10 +291,8 @@ void irc_msg_ban(struct irc_conn *irc, c
if (!chat)
return;
/* End of ban list */
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "",
- _("End of ban list"),
- PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
- time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+ _("End of ban list"), PURPLE_MESSAGE_NO_LOG);
}
}
@@ -324,9 +321,8 @@ void irc_msg_banfull(struct irc_conn *ir
nick = g_markup_escape_text(args[2], -1);
buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick);
g_free(nick);
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", buf,
- PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
- time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+ buf, PURPLE_MESSAGE_NO_LOG);
g_free(buf);
}
@@ -341,7 +337,7 @@ void irc_msg_chanmode(struct irc_conn *i
escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL;
buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : "");
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0);
g_free(escaped);
g_free(buf);
@@ -606,8 +602,7 @@ void irc_msg_topic(struct irc_conn *irc,
msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2);
g_free(chan_esc);
purple_chat_conversation_set_topic(chat, NULL, topic);
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
- PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), msg, 0);
g_free(msg);
}
g_free(tmp2);
@@ -637,8 +632,8 @@ void irc_msg_topicinfo(struct irc_conn *
timestamp = g_strdup(purple_time_format(tm));
datestamp = g_strdup(purple_date_format_short(tm));
msg = g_strdup_printf(_("Topic for %s set by %s at %s on %s"), args[1], args[2], timestamp, datestamp);
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", msg,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+ msg, PURPLE_MESSAGE_NO_LINKIFY);
g_free(timestamp);
g_free(datestamp);
g_free(msg);
@@ -676,7 +671,7 @@ void irc_msg_names(struct irc_conn *irc,
irc->names = NULL;
if (g_object_get_data(G_OBJECT(convo), IRC_NAMES_FLAG)) {
msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
- purple_conversation_write_message(convo, "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(convo, msg, PURPLE_MESSAGE_NO_LOG);
g_free(msg);
} else if (cur != NULL) {
GList *users = NULL;
@@ -859,7 +854,7 @@ void irc_msg_notop(struct irc_conn *irc,
if (!chat)
return;
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), args[2], 0);
}
void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -1269,7 +1264,7 @@ void irc_msg_pong(struct irc_conn *irc,
convo = purple_conversations_find_with_account(parts[0], irc->account);
g_strfreev(parts);
if (convo) {
- purple_conversation_write_message(convo, "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(convo, msg, PURPLE_MESSAGE_NO_LOG);
} else {
gc = purple_account_get_connection(irc->account);
if (!gc) {
diff --git a/libpurple/protocols/jabber/chat.c b/libpurple/protocols/jabber/chat.c
--- a/libpurple/protocols/jabber/chat.c
+++ b/libpurple/protocols/jabber/chat.c
@@ -766,9 +766,9 @@ gboolean jabber_chat_change_nick(JabberC
int priority;
if(!chat->muc) {
- purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "",
- _("Nick changing not supported in non-MUC chatrooms"),
- PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(
+ PURPLE_CONVERSATION(chat->conv),
+ _("Nick changing not supported in non-MUC chatrooms"), 0);
return FALSE;
}
@@ -1089,8 +1089,8 @@ jabber_chat_affiliation_list_cb(JabberSt
buf = g_string_append_len(buf, _("No users found"), -1);
}
- purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", buf->str,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv),
+ buf->str, PURPLE_MESSAGE_NO_LOG);
g_string_free(buf, TRUE);
}
@@ -1184,8 +1184,8 @@ static void jabber_chat_role_list_cb(Jab
buf = g_string_append_len(buf, _("No users found"), -1);
}
- purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", buf->str,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv),
+ buf->str, PURPLE_MESSAGE_NO_LOG);
g_string_free(buf, TRUE);
}
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2859,8 +2859,7 @@ static PurpleCmdRet jabber_cmd_chat_topi
g_free(tmp2);
} else
buf = g_strdup(_("No topic is set"));
- purple_conversation_write_message(conv, "", buf,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(conv, buf, PURPLE_MESSAGE_NO_LOG);
g_free(buf);
}
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -242,7 +242,8 @@ static void handle_groupchat(JabberMessa
msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2);
else
msg = g_strdup_printf(_("The topic is: %s"), tmp2);
- purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "", msg, messageFlags | PURPLE_MESSAGE_SYSTEM, jm->sent);
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv),
+ msg, messageFlags);
g_free(tmp);
g_free(tmp2);
g_free(msg);
@@ -255,9 +256,9 @@ static void handle_groupchat(JabberMessa
messageFlags | (jm->delayed ? PURPLE_MESSAGE_DELAYED : 0),
jm->xhtml ? jm->xhtml : jm->body, jm->sent);
else if(chat->muc)
- purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), "",
- jm->xhtml ? jm->xhtml : jm->body,
- messageFlags | PURPLE_MESSAGE_SYSTEM, jm->sent);
+ purple_conversation_write_system_message(
+ PURPLE_CONVERSATION(chat->conv),
+ jm->xhtml ? jm->xhtml : jm->body, messageFlags);
}
jabber_id_free(jid);
diff --git a/libpurple/protocols/mxit/multimx.c b/libpurple/protocols/mxit/multimx.c
--- a/libpurple/protocols/mxit/multimx.c
+++ b/libpurple/protocols/mxit/multimx.c
@@ -226,7 +226,8 @@ static void you_kicked(PurpleChatConvers
{
purple_debug_info(MXIT_PLUGIN_ID, "you_kicked\n");
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "MXit", _("You have been kicked from this MultiMX."), PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+ _("You have been kicked from this MultiMX."), 0);
purple_chat_conversation_clear_users(chat);
purple_serv_got_chat_left(session->con, multimx->chatid);
}
@@ -574,7 +575,7 @@ void mxit_chat_invite(PurpleConnection *
/* Display system message in chat window */
tmp = g_strdup_printf("%s: %s", _("You have invited"), purple_buddy_get_alias(buddy));
- purple_conversation_write_message(PURPLE_CONVERSATION(chat), "MXit", tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), tmp, 0);
g_free(tmp);
}
diff --git a/libpurple/protocols/null/nullprpl.c b/libpurple/protocols/null/nullprpl.c
--- a/libpurple/protocols/null/nullprpl.c
+++ b/libpurple/protocols/null/nullprpl.c
@@ -890,9 +890,8 @@ static void set_chat_topic_fn(PurpleChat
else
msg = g_strdup_printf(_("%s clears topic"), username);
- purple_conversation_write_message(PURPLE_CONVERSATION(to), username, msg,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG,
- time(NULL));
+ purple_conversation_write_system_message(PURPLE_CONVERSATION(to),
+ msg, PURPLE_MESSAGE_NO_LOG);
g_free(msg);
}
diff --git a/libpurple/protocols/silc/silc.c b/libpurple/protocols/silc/silc.c
--- a/libpurple/protocols/silc/silc.c
+++ b/libpurple/protocols/silc/silc.c
@@ -1808,8 +1808,7 @@ static PurpleCmdRet silcpurple_cmd_cmode
} else {
msg = g_strdup_printf(_("no channel modes are set on %s"), chname);
}
- purple_conversation_write_message(conv, "",
- msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+ purple_conversation_write_system_message(conv, msg, PURPLE_MESSAGE_NO_LOG);
g_free(msg);
return PURPLE_CMD_RET_OK;
}
diff --git a/libpurple/protocols/yahoo/yahoo_doodle.c b/libpurple/protocols/yahoo/yahoo_doodle.c
--- a/libpurple/protocols/yahoo/yahoo_doodle.c
+++ b/libpurple/protocols/yahoo/yahoo_doodle.c
@@ -93,8 +93,8 @@ PurpleCmdRet yahoo_doodle_purple_cmd_sta
/* Write a local message to this conversation showing that a request for a
* Doodle session has been made
*/
More information about the Commits
mailing list