/pidgin/main: b7328f4317c7: Switch purple_serv_chat_send to Purp...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Thu May 22 13:37:35 EDT 2014
Changeset: b7328f4317c736cf443f411a866505072ade5bcc
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-05-22 15:53 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/b7328f4317c7
Description:
Switch purple_serv_chat_send to PurpleMessage
diffstat:
libpurple/conversation.c | 12 ++++++++----
libpurple/message.c | 3 ---
libpurple/protocols/irc/irc.c | 11 +++++++----
libpurple/protocols/jabber/message.c | 6 +++---
libpurple/protocols/jabber/message.h | 2 +-
libpurple/protocols/msn/msn.c | 7 ++++---
libpurple/protocols/mxit/multimx.c | 13 ++++++-------
libpurple/protocols/mxit/multimx.h | 2 +-
libpurple/protocols/novell/novell.c | 10 ++++++----
libpurple/protocols/null/nullprpl.c | 4 ++--
libpurple/protocols/oscar/oscar.c | 3 ++-
libpurple/protocols/oscar/oscarcommon.h | 2 +-
libpurple/protocols/sametime/sametime.c | 9 +++------
libpurple/protocols/silc/chat.c | 5 +++--
libpurple/protocols/silc/silcpurple.h | 2 +-
libpurple/protocols/yahoo/yahoochat.c | 4 +++-
libpurple/protocols/yahoo/yahoochat.h | 2 +-
libpurple/protocols/zephyr/zephyr.c | 5 +++--
libpurple/prpl.h | 6 ++----
libpurple/server.c | 6 ++++--
libpurple/server.h | 2 +-
21 files changed, 62 insertions(+), 54 deletions(-)
diffs (truncated from 482 to 300 lines):
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -101,6 +101,7 @@ common_send(PurpleConversation *conv, co
PurpleAccount *account;
PurpleConnection *gc;
PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
+ PurpleMessage *msg;
char *displayed = NULL, *sent = NULL;
int err = 0;
@@ -133,8 +134,6 @@ common_send(PurpleConversation *conv, co
msgflags |= PURPLE_MESSAGE_SEND;
if (PURPLE_IS_IM_CONVERSATION(conv)) {
- PurpleMessage *msg;
-
msg = purple_message_new(purple_conversation_get_name(conv),
sent, msgflags);
@@ -158,12 +157,17 @@ common_send(PurpleConversation *conv, co
}
else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
int id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv));
+
+ msg = purple_message_new(NULL, sent, msgflags);
+
+ /* TODO: use msg! */
purple_signal_emit(purple_conversations_get_handle(), "sending-chat-msg",
account, &sent, id);
- if (sent != NULL && sent[0] != '\0') {
- err = purple_serv_chat_send(gc, id, sent, msgflags);
+ if (!purple_message_is_empty(msg)) {
+ err = purple_serv_chat_send(gc, id, msg);
+ /* TODO: use msg! */
purple_signal_emit(purple_conversations_get_handle(), "sent-chat-msg",
account, sent, id);
}
diff --git a/libpurple/message.c b/libpurple/message.c
--- a/libpurple/message.c
+++ b/libpurple/message.c
@@ -59,9 +59,6 @@ PurpleMessage *
purple_message_new(const gchar *who, const gchar *contents,
PurpleMessageFlags flags)
{
- g_return_val_if_fail(who != NULL, NULL);
- g_return_val_if_fail(contents != NULL, NULL);
-
return g_object_new(PURPLE_TYPE_MESSAGE,
"who", who,
"contents", contents,
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -51,7 +51,7 @@ static void irc_login_cb(gpointer data,
static void irc_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, gpointer data);
static void irc_close(PurpleConnection *gc);
static int irc_im_send(PurpleConnection *gc, PurpleMessage *msg);
-static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags);
+static int irc_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg);
static void irc_chat_join (PurpleConnection *gc, GHashTable *data);
static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond);
static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond);
@@ -793,7 +793,7 @@ static void irc_chat_leave (PurpleConnec
purple_serv_got_chat_left(gc, id);
}
-static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags)
+static int irc_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
struct irc_conn *irc = purple_connection_get_protocol_data(gc);
PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id));
@@ -809,13 +809,16 @@ static int irc_chat_send(PurpleConnectio
return irc_parse_cmd(irc, convo->name, what + 1);
}
#endif
- purple_markup_html_to_xhtml(what, NULL, &tmp);
+ purple_markup_html_to_xhtml(purple_message_get_contents(msg), NULL, &tmp);
args[0] = purple_conversation_get_name(convo);
args[1] = tmp;
irc_cmd_privmsg(irc, "msg", NULL, args);
- purple_serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), flags, what, time(NULL));
+ /* TODO: use msg */
+ purple_serv_got_chat_in(gc, id, purple_connection_get_display_name(gc),
+ purple_message_get_flags(msg),
+ purple_message_get_contents(msg), time(NULL));
g_free(tmp);
return 0;
}
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
@@ -1185,7 +1185,7 @@ int jabber_message_send_im(PurpleConnect
return 1;
}
-int jabber_message_send_chat(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags)
+int jabber_message_send_chat(PurpleConnection *gc, int id, PurpleMessage *msg)
{
JabberChat *chat;
JabberMessage *jm;
@@ -1193,7 +1193,7 @@ int jabber_message_send_chat(PurpleConne
char *xhtml;
char *tmp;
- if(!msg || !gc)
+ if (!gc || purple_message_is_empty(msg))
return 0;
js = purple_connection_get_protocol_data(gc);
@@ -1208,7 +1208,7 @@ int jabber_message_send_chat(PurpleConne
jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
jm->id = jabber_get_next_id(jm->js);
- tmp = purple_utf8_strip_unprintables(msg);
+ tmp = purple_utf8_strip_unprintables(purple_message_get_contents(msg));
purple_markup_html_to_xhtml(tmp, &xhtml, &jm->body);
g_free(tmp);
tmp = jabber_message_smileyfy_xhtml(jm, xhtml);
diff --git a/libpurple/protocols/jabber/message.h b/libpurple/protocols/jabber/message.h
--- a/libpurple/protocols/jabber/message.h
+++ b/libpurple/protocols/jabber/message.h
@@ -70,7 +70,7 @@ void jabber_message_send(JabberMessage *
void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet);
int jabber_message_send_im(PurpleConnection *gc, PurpleMessage *msg);
-int jabber_message_send_chat(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags);
+int jabber_message_send_chat(PurpleConnection *gc, int id, PurpleMessage *msg);
unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleIMTypingState state);
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2016,7 +2016,7 @@ msn_chat_leave(PurpleConnection *gc, int
}
static int
-msn_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
+msn_chat_send(PurpleConnection *gc, int id, PurpleMessage *pmsg)
{
PurpleAccount *account;
MsnSession *session;
@@ -2040,7 +2040,7 @@ msn_chat_send(PurpleConnection *gc, int
swboard->flag |= MSN_SB_FLAG_IM;
- msn_import_html(message, &msgformat, &msgtext);
+ msn_import_html(purple_message_get_contents(pmsg), &msgformat, &msgtext);
msglen = strlen(msgtext);
if ((msglen == 0) || (msglen + strlen(msgformat) + strlen(VERSION) > 1564))
@@ -2060,7 +2060,8 @@ msn_chat_send(PurpleConnection *gc, int
g_free(msgformat);
g_free(msgtext);
- purple_serv_got_chat_in(gc, id, username, flags, message, time(NULL));
+ purple_serv_got_chat_in(gc, id, username, purple_message_get_flags(pmsg),
+ purple_message_get_contents(pmsg), time(NULL));
return 0;
}
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
@@ -612,18 +612,15 @@ void mxit_chat_leave(PurpleConnection *g
*
* @param gc The connection object
* @param id The chat room ID
- * @param message The sent message data
- * @param flags The message flags
+ * @param msg The sent message data
* @return Indicates success / failure
*/
-int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
+int mxit_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
struct MXitSession* session = purple_connection_get_protocol_data(gc);
struct multimx* multimx = NULL;
const char* nickname;
- purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i message send: '%s'\n", id, message);
-
/* Find matching MultiMX group */
multimx = find_room_by_id(session, id);
if (multimx == NULL) {
@@ -632,7 +629,8 @@ int mxit_chat_send(PurpleConnection *gc,
}
/* Send packet to MXit */
- mxit_send_message(session, multimx->roomid, message, TRUE, FALSE);
+ mxit_send_message(session, multimx->roomid,
+ purple_message_get_contents(msg), TRUE, FALSE);
/* Determine our nickname to display */
if (multimx->nickname)
@@ -641,7 +639,8 @@ int mxit_chat_send(PurpleConnection *gc,
nickname = purple_account_get_private_alias(purple_connection_get_account(gc)); /* local alias */
/* Display message in chat window */
- purple_serv_got_chat_in(gc, id, nickname, flags, message, time(NULL));
+ purple_serv_got_chat_in(gc, id, nickname, purple_message_get_flags(msg),
+ purple_message_get_contents(msg), time(NULL));
return 0;
}
diff --git a/libpurple/protocols/mxit/multimx.h b/libpurple/protocols/mxit/multimx.h
--- a/libpurple/protocols/mxit/multimx.h
+++ b/libpurple/protocols/mxit/multimx.h
@@ -99,7 +99,7 @@ void mxit_chat_leave(PurpleConnection *g
/*
* User has entered a message in a chatroom window, send it to the MXit server.
*/
-int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags);
+int mxit_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg);
#endif /* _MXIT_MULTIMX_H_ */
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -2484,7 +2484,7 @@ novell_chat_invite(PurpleConnection *gc,
}
static int
-novell_chat_send(PurpleConnection * gc, int id, const char *text, PurpleMessageFlags flags)
+novell_chat_send(PurpleConnection * gc, int id, PurpleMessage *msg)
{
NMConference *conference;
PurpleChatConversation *chat;
@@ -2495,14 +2495,14 @@ novell_chat_send(PurpleConnection * gc,
const char *name;
char *str, *plain;
- if (gc == NULL || text == NULL)
+ if (gc == NULL || purple_message_is_empty(msg))
return -1;
user = purple_connection_get_protocol_data(gc);
if (user == NULL)
return -1;
- plain = purple_unescape_html(text);
+ plain = purple_unescape_html(purple_message_get_contents(msg));
message = nm_create_message(plain);
g_free(plain);
@@ -2538,7 +2538,9 @@ novell_chat_send(PurpleConnection * gc,
}
}
- purple_serv_got_chat_in(gc, id, name, flags, text, time(NULL));
+ purple_serv_got_chat_in(gc, id, name,
+ purple_message_get_flags(msg),
+ purple_message_get_contents(msg), time(NULL));
return 0;
} else
return -1;
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
@@ -858,10 +858,10 @@ static void receive_chat_message(PurpleC
time(NULL));
}
-static int nullprpl_chat_send(PurpleConnection *gc, int id, const char *message,
- PurpleMessageFlags flags) {
+static int nullprpl_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg) {
const char *username = purple_account_get_username(purple_connection_get_account(gc));
PurpleChatConversation *chat = purple_conversations_find_chat(gc, id);
+ const gchar *message = purple_message_get_contents(msg);
if (chat) {
purple_debug_info("nullprpl",
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -4322,7 +4322,7 @@ oscar_chat_leave(PurpleConnection *gc, i
oscar_chat_kill(gc, cc);
}
-int oscar_send_chat(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
+int oscar_send_chat(PurpleConnection *gc, int id, PurpleMessage *msg)
{
OscarData *od = purple_connection_get_protocol_data(gc);
PurpleChatConversation *conv = NULL;
@@ -4331,6 +4331,7 @@ int oscar_send_chat(PurpleConnection *gc
guint16 charset;
char *charsetstr;
gsize len;
+ const gchar *message = purple_message_get_contents(msg);
if (!(conv = purple_conversations_find_chat(gc, id)))
return -EINVAL;
diff --git a/libpurple/protocols/oscar/oscarcommon.h b/libpurple/protocols/oscar/oscarcommon.h
--- a/libpurple/protocols/oscar/oscarcommon.h
More information about the Commits
mailing list