pidgin/pidgin

b7328f4317c7
Parents a0e5b68ff4ef
Children ad2b7d9cc0c3
Switch purple_serv_chat_send to PurpleMessage
--- a/libpurple/conversation.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/conversation.c Thu May 22 15:53:54 2014 +0200
@@ -101,6 +101,7 @@
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 @@
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 @@
}
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);
}
--- a/libpurple/message.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/message.c Thu May 22 15:53:54 2014 +0200
@@ -59,9 +59,6 @@
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,
--- a/libpurple/protocols/irc/irc.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/irc/irc.c Thu May 22 15:53:54 2014 +0200
@@ -51,7 +51,7 @@
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 @@
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 @@
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;
}
--- a/libpurple/protocols/jabber/message.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/jabber/message.c Thu May 22 15:53:54 2014 +0200
@@ -1185,7 +1185,7 @@
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 @@
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 @@
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);
--- a/libpurple/protocols/jabber/message.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/jabber/message.h Thu May 22 15:53:54 2014 +0200
@@ -70,7 +70,7 @@
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);
--- a/libpurple/protocols/msn/msn.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/msn/msn.c Thu May 22 15:53:54 2014 +0200
@@ -2016,7 +2016,7 @@
}
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 @@
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 @@
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;
}
--- a/libpurple/protocols/mxit/multimx.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/mxit/multimx.c Thu May 22 15:53:54 2014 +0200
@@ -612,18 +612,15 @@
*
* @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 @@
}
/* 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 @@
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;
}
--- a/libpurple/protocols/mxit/multimx.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/mxit/multimx.h Thu May 22 15:53:54 2014 +0200
@@ -99,7 +99,7 @@
/*
* 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_ */
--- a/libpurple/protocols/novell/novell.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/novell/novell.c Thu May 22 15:53:54 2014 +0200
@@ -2484,7 +2484,7 @@
}
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 @@
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 @@
}
}
- 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;
--- a/libpurple/protocols/null/nullprpl.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/null/nullprpl.c Thu May 22 15:53:54 2014 +0200
@@ -858,10 +858,10 @@
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",
--- a/libpurple/protocols/oscar/oscar.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/oscar/oscar.c Thu May 22 15:53:54 2014 +0200
@@ -4322,7 +4322,7 @@
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 @@
guint16 charset;
char *charsetstr;
gsize len;
+ const gchar *message = purple_message_get_contents(msg);
if (!(conv = purple_conversations_find_chat(gc, id)))
return -EINVAL;
--- a/libpurple/protocols/oscar/oscarcommon.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/oscar/oscarcommon.h Thu May 22 15:53:54 2014 +0200
@@ -89,7 +89,7 @@
char *oscar_get_chat_name(GHashTable *data);
void oscar_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name);
void oscar_chat_leave(PurpleConnection *gc, int id);
-int oscar_send_chat(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags);
+int oscar_send_chat(PurpleConnection *gc, int id, PurpleMessage *msg);
void oscar_keepalive(PurpleConnection *gc);
void oscar_alias_buddy(PurpleConnection *gc, const char *name, const char *alias);
void oscar_move_buddy(PurpleConnection *gc, const char *name, const char *old_group, const char *new_group);
--- a/libpurple/protocols/sametime/sametime.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/sametime/sametime.c Thu May 22 15:53:54 2014 +0200
@@ -4779,11 +4779,8 @@
}
-static int mw_prpl_chat_send(PurpleConnection *gc,
- int id,
- const char *message,
- PurpleMessageFlags flags) {
-
+static int mw_prpl_chat_send(PurpleConnection *gc, int id, PurpleMessage *pmsg)
+{
struct mwPurplePluginData *pd;
struct mwConference *conf;
char *msg;
@@ -4794,7 +4791,7 @@
g_return_val_if_fail(pd != NULL, 0);
conf = ID_TO_CONF(pd, id);
- msg = purple_markup_strip_html(message);
+ msg = purple_markup_strip_html(purple_message_get_contents(pmsg));
if(conf) {
ret = ! mwConference_sendText(conf, msg);
--- a/libpurple/protocols/silc/chat.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/silc/chat.c Thu May 22 15:53:54 2014 +0200
@@ -1219,8 +1219,7 @@
}
}
-int silcpurple_chat_send(PurpleConnection *gc, int id, const char *msg,
- PurpleMessageFlags msgflags)
+int silcpurple_chat_send(PurpleConnection *gc, int id, PurpleMessage *pmsg)
{
SilcPurple sg = purple_connection_get_protocol_data(gc);
SilcClient client = sg->client;
@@ -1231,10 +1230,12 @@
SilcChannelPrivateKey key = NULL;
SilcMessageFlags flags;
int ret = 0;
+ const gchar *msg = purple_message_get_contents(pmsg);
char *msg2, *tmp;
gboolean found = FALSE;
gboolean sign = purple_account_get_bool(sg->account, "sign-verify", FALSE);
SilcDList list;
+ PurpleMessageFlags msgflags = purple_message_get_flags(pmsg);
if (!msg || !conn)
return 0;
--- a/libpurple/protocols/silc/silcpurple.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/silc/silcpurple.h Thu May 22 15:53:54 2014 +0200
@@ -142,7 +142,7 @@
void silcpurple_chat_invite(PurpleConnection *gc, int id, const char *msg,
const char *name);
void silcpurple_chat_leave(PurpleConnection *gc, int id);
-int silcpurple_chat_send(PurpleConnection *gc, int id, const char *msg, PurpleMessageFlags flags);
+int silcpurple_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg);
void silcpurple_chat_set_topic(PurpleConnection *gc, int id, const char *topic);
PurpleRoomlist *silcpurple_roomlist_get_list(PurpleConnection *gc);
void silcpurple_roomlist_cancel(PurpleRoomlist *list);
--- a/libpurple/protocols/yahoo/yahoochat.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/yahoo/yahoochat.c Thu May 22 15:53:54 2014 +0200
@@ -1111,11 +1111,13 @@
purple_serv_got_chat_left(gc, id);
}
-int yahoo_c_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags)
+int yahoo_c_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
PurpleChatConversation *c;
int ret;
YahooData *yd;
+ const gchar *what = purple_message_get_contents(msg);
+ PurpleMessageFlags flags = purple_message_get_flags(msg);
yd = purple_connection_get_protocol_data(gc);
if (!yd)
--- a/libpurple/protocols/yahoo/yahoochat.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/yahoo/yahoochat.h Thu May 22 15:53:54 2014 +0200
@@ -43,7 +43,7 @@
void yahoo_process_chat_goto(PurpleConnection *gc, struct yahoo_packet *pkt);
void yahoo_c_leave(PurpleConnection *gc, int id);
-int yahoo_c_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags);
+int yahoo_c_send(PurpleConnection *gc, int id, PurpleMessage *msg);
GList *yahoo_c_info(PurpleConnection *gc);
GHashTable *yahoo_c_info_defaults(PurpleConnection *gc, const char *chat_name);
void yahoo_c_join(PurpleConnection *gc, GHashTable *data);
--- a/libpurple/protocols/zephyr/zephyr.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/protocols/zephyr/zephyr.c Thu May 22 15:53:54 2014 +0200
@@ -2045,7 +2045,7 @@
return sig;
}
-static int zephyr_chat_send(PurpleConnection * gc, int id, const char *im, PurpleMessageFlags flags)
+static int zephyr_chat_send(PurpleConnection * gc, int id, PurpleMessage *msg)
{
zephyr_triple *zt;
const char *sig;
@@ -2072,7 +2072,8 @@
else
recipient = local_zephyr_normalize(zephyr,zt->recipient);
- zephyr_send_message(zephyr,zt->class,inst,recipient,im,sig,"");
+ zephyr_send_message(zephyr, zt->class, inst, recipient,
+ purple_message_get_contents(msg), sig, "");
return 0;
}
--- a/libpurple/prpl.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/prpl.h Thu May 22 15:53:54 2014 +0200
@@ -428,14 +428,12 @@
* errno values, or just big something.
*
* @id: The id of the chat to send the message to.
- * @message: The message to send to the chat.
- * @flags: A bitwise OR of #PurpleMessageFlags representing
- * message flags.
+ * @msg: The message to send to the chat.
*
* Returns: A positive number or 0 in case of success,
* a negative error number in case of failure.
*/
- int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags);
+ int (*chat_send)(PurpleConnection *, int id, PurpleMessage *msg);
/* If implemented, this will be called regularly for this prpl's
* active connections. You'd want to do this if you need to repeatedly
--- a/libpurple/server.c Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/server.c Thu May 22 15:53:54 2014 +0200
@@ -524,7 +524,7 @@
}
}
-int purple_serv_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
+int purple_serv_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
PurplePlugin *prpl;
PurplePluginProtocolInfo *prpl_info;
@@ -532,8 +532,10 @@
prpl = purple_connection_get_prpl(gc);
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+ g_return_val_if_fail(msg != NULL, -EINVAL);
+
if (prpl_info->chat_send)
- return prpl_info->chat_send(gc, id, message, flags);
+ return prpl_info->chat_send(gc, id, msg);
return -EINVAL;
}
--- a/libpurple/server.h Thu May 22 15:15:16 2014 +0200
+++ b/libpurple/server.h Thu May 22 15:53:54 2014 +0200
@@ -77,7 +77,7 @@
void purple_serv_chat_invite(PurpleConnection *, int, const char *, const char *);
void purple_serv_chat_leave(PurpleConnection *, int);
void purple_serv_chat_whisper(PurpleConnection *, int, const char *, const char *);
-int purple_serv_chat_send(PurpleConnection *, int, const char *, PurpleMessageFlags flags);
+int purple_serv_chat_send(PurpleConnection *, int, PurpleMessage *);
void purple_serv_alias_buddy(PurpleBuddy *);
void purple_serv_got_alias(PurpleConnection *gc, const char *who, const char *alias);