pidgin/pidgin

Switch purple_serv_send_im to PurpleMessage

2014-05-22, Tomasz Wasilczyk
a0e5b68ff4ef
Parents dfb5988e053b
Children b7328f4317c7
Switch purple_serv_send_im to PurpleMessage
--- a/finch/gntpounce.c Thu May 22 14:08:33 2014 +0200
+++ b/finch/gntpounce.c Thu May 22 15:15:16 2014 +0200
@@ -868,15 +868,19 @@
if (message != NULL)
{
+ PurpleMessage *pmsg;
+
im = purple_conversations_find_im_with_account(pouncee, account);
if (im == NULL)
im = purple_im_conversation_new(account, pouncee);
+ pmsg = purple_message_new(pouncee, message, 0);
+
purple_conversation_write(PURPLE_CONVERSATION(im), NULL, message,
PURPLE_MESSAGE_SEND, time(NULL));
- purple_serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
+ purple_serv_send_im(purple_account_get_connection(account), pmsg);
}
}
--- a/libpurple/conversation.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/conversation.c Thu May 22 15:15:16 2014 +0200
@@ -133,18 +133,24 @@
msgflags |= PURPLE_MESSAGE_SEND;
if (PURPLE_IS_IM_CONVERSATION(conv)) {
+ PurpleMessage *msg;
+
+ msg = purple_message_new(purple_conversation_get_name(conv),
+ sent, msgflags);
+
+ /* TODO: use msg! */
purple_signal_emit(purple_conversations_get_handle(), "sending-im-msg",
account,
purple_conversation_get_name(conv), &sent);
- if (sent != NULL && sent[0] != '\0') {
+ if (!purple_message_is_empty(msg)) {
- err = purple_serv_send_im(gc, purple_conversation_get_name(conv),
- sent, msgflags);
+ err = purple_serv_send_im(gc, msg);
if ((err > 0) && (displayed != NULL))
purple_conversation_write_message(conv, NULL, displayed, msgflags, time(NULL));
+ /* TODO: use msg! */
purple_signal_emit(purple_conversations_get_handle(), "sent-im-msg",
account,
purple_conversation_get_name(conv), sent);
--- a/libpurple/message.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/message.c Thu May 22 15:15:16 2014 +0200
@@ -87,6 +87,44 @@
return g_hash_table_lookup(messages, GINT_TO_POINTER(id));
}
+const gchar *
+purple_message_get_who(PurpleMessage *msg)
+{
+ PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->who;
+}
+
+const gchar *
+purple_message_get_contents(PurpleMessage *msg)
+{
+ PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->contents;
+}
+
+gboolean
+purple_message_is_empty(PurpleMessage *msg)
+{
+ const gchar *cont = purple_message_get_contents(msg);
+
+ return (cont == NULL || cont[0] == '\0');
+}
+
+PurpleMessageFlags
+purple_message_get_flags(PurpleMessage *msg)
+{
+ PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+ g_return_val_if_fail(priv != NULL, 0);
+
+ return priv->flags;
+}
+
/******************************************************************************
* Object stuff
******************************************************************************/
@@ -184,7 +222,9 @@
"ID", "The session-unique message id",
0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_WHO] = g_param_spec_string("who",
- "Author", "The nick of the person, who sent the message",
+ "Who", "The nick of the person, who sent the message (for "
+ "incoming messages) or the recipient (for outgoing). "
+ "Unused for outgoing chat messages.",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[PROP_CONTENTS] = g_param_spec_string("contents",
"Contents", "The message text",
--- a/libpurple/message.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/message.h Thu May 22 15:15:16 2014 +0200
@@ -92,6 +92,18 @@
PurpleMessage *
purple_message_find_by_id(guint id);
+const gchar *
+purple_message_get_who(PurpleMessage *msg);
+
+const gchar *
+purple_message_get_contents(PurpleMessage *msg);
+
+gboolean
+purple_message_is_empty(PurpleMessage *msg);
+
+PurpleMessageFlags
+purple_message_get_flags(PurpleMessage *msg);
+
void
_purple_message_init(void);
--- a/libpurple/plugins/tcl/tcl_cmds.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/plugins/tcl/tcl_cmds.c Thu May 22 15:15:16 2014 +0200
@@ -1411,7 +1411,7 @@
who = Tcl_GetString(objv[2]);
text = Tcl_GetString(objv[3]);
- purple_serv_send_im(gc, who, text, 0);
+ purple_serv_send_im(gc, purple_message_new(who, text, 0));
return TCL_OK;
}
--- a/libpurple/protocols/bonjour/bonjour.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/bonjour/bonjour.c Thu May 22 15:15:16 2014 +0200
@@ -205,14 +205,16 @@
}
static int
-bonjour_send_im(PurpleConnection *connection, const char *to, const char *msg, PurpleMessageFlags flags)
+bonjour_send_im(PurpleConnection *connection, PurpleMessage *msg)
{
BonjourData *bd = purple_connection_get_protocol_data(connection);
- if(!to || !msg)
+ if (purple_message_is_empty(msg) || !purple_message_get_who(msg))
return 0;
- return bonjour_jabber_send_message(bd->jabber_data, to, msg);
+ return bonjour_jabber_send_message(bd->jabber_data,
+ purple_message_get_who(msg),
+ purple_message_get_contents(msg));
}
static void
--- a/libpurple/protocols/gg/message-prpl.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/gg/message-prpl.c Thu May 22 15:15:16 2014 +0200
@@ -636,18 +636,18 @@
return text_new;
}
-int ggp_message_send_im(PurpleConnection *gc, const char *who,
- const char *message, PurpleMessageFlags flags)
+int ggp_message_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
GGPInfo *info = purple_connection_get_protocol_data(gc);
PurpleIMConversation *im;
ggp_buddy_data *buddy_data;
gchar *gg_msg;
gboolean succ;
+ const gchar *who = purple_message_get_who(msg);
/* TODO: return -ENOTCONN, if not connected */
- if (message == NULL || message[0] == '\0')
+ if (purple_message_is_empty(msg))
return 0;
buddy_data = ggp_buddy_get_data(purple_blist_find_buddy(
@@ -659,7 +659,8 @@
im = purple_conversations_find_im_with_account(
who, purple_connection_get_account(gc));
- gg_msg = ggp_message_format_to_gg(PURPLE_CONVERSATION(im), message);
+ gg_msg = ggp_message_format_to_gg(PURPLE_CONVERSATION(im),
+ purple_message_get_contents(msg));
/* TODO: splitting messages */
if (strlen(gg_msg) > GG_MSG_MAXSIZE) {
--- a/libpurple/protocols/gg/message-prpl.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/gg/message-prpl.h Thu May 22 15:15:16 2014 +0200
@@ -42,8 +42,7 @@
void ggp_message_got_multilogon(PurpleConnection *gc,
const struct gg_event_msg *ev);
-int ggp_message_send_im(PurpleConnection *gc, const char *who,
- const char *message, PurpleMessageFlags flags);
+int ggp_message_send_im(PurpleConnection *gc, PurpleMessage *msg);
gchar * ggp_message_format_to_gg(PurpleConversation *conv, const gchar *text);
#endif /* _GGP_MESSAGE_PRPL_H */
--- a/libpurple/protocols/irc/irc.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/irc/irc.c Thu May 22 15:15:16 2014 +0200
@@ -50,7 +50,7 @@
static void irc_login_cb(gpointer data, gint source, const gchar *error_message);
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, const char *who, const char *what, PurpleMessageFlags flags);
+static int irc_im_send(PurpleConnection *gc, PurpleMessage *msg);
static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags);
static void irc_chat_join (PurpleConnection *gc, GHashTable *data);
static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond);
@@ -558,15 +558,16 @@
g_free(irc);
}
-static int irc_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
+static int irc_im_send(PurpleConnection *gc, PurpleMessage *msg)
{
struct irc_conn *irc = purple_connection_get_protocol_data(gc);
char *plain;
const char *args[2];
- args[0] = irc_nick_skip_mode(irc, who);
+ args[0] = irc_nick_skip_mode(irc, purple_message_get_who(msg));
- purple_markup_html_to_xhtml(what, NULL, &plain);
+ purple_markup_html_to_xhtml(purple_message_get_contents(msg),
+ NULL, &plain);
args[1] = plain;
irc_cmd_privmsg(irc, "msg", NULL, args);
--- a/libpurple/protocols/jabber/jabber.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/jabber/jabber.c Thu May 22 15:15:16 2014 +0200
@@ -3072,7 +3072,8 @@
who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
- jabber_message_send_im(purple_conversation_get_connection(conv), who, args[1], 0);
+ jabber_message_send_im(purple_conversation_get_connection(conv),
+ purple_message_new(who, args[1], 0));
g_free(who);
return PURPLE_CMD_RET_OK;
--- a/libpurple/protocols/jabber/message.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/jabber/message.c Thu May 22 15:15:16 2014 +0200
@@ -1118,8 +1118,7 @@
return ret;
}
-int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg,
- PurpleMessageFlags flags)
+int jabber_message_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
JabberMessage *jm;
JabberBuddy *jb;
@@ -1127,15 +1126,10 @@
char *xhtml;
char *tmp;
char *resource;
-
- if(!who || !msg)
- return 0;
+ const gchar *who = purple_message_get_who(msg);
- if (purple_debug_is_verbose()) {
- /* TODO: Maybe we need purple_debug_is_really_verbose? :) */
- purple_debug_misc("jabber", "jabber_message_send_im: who='%s'\n"
- "\tmsg='%s'\n", who, msg);
- }
+ if (!who || purple_message_is_empty(msg))
+ return 0;
resource = jabber_get_resource(who);
@@ -1163,7 +1157,7 @@
}
}
- 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);
--- a/libpurple/protocols/jabber/message.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/jabber/message.h Thu May 22 15:15:16 2014 +0200
@@ -69,8 +69,7 @@
void jabber_message_send(JabberMessage *jm);
void jabber_message_parse(JabberStream *js, PurpleXmlNode *packet);
-int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg,
- PurpleMessageFlags flags);
+int jabber_message_send_im(PurpleConnection *gc, PurpleMessage *msg);
int jabber_message_send_chat(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags);
unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleIMTypingState state);
--- a/libpurple/protocols/msn/msn.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/msn/msn.c Thu May 22 15:15:16 2014 +0200
@@ -1530,11 +1530,9 @@
}
static int
-msn_send_im(PurpleConnection *gc, const char *who, const char *message,
- PurpleMessageFlags flags)
+msn_send_im(PurpleConnection *gc, PurpleMessage *pmsg)
{
PurpleAccount *account;
- PurpleBuddy *buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who);
MsnSession *session;
MsnSwitchBoard *swboard;
MsnMessage *msg;
@@ -1542,8 +1540,11 @@
char *msgtext;
size_t msglen;
const char *username;
-
- purple_debug_info("msn", "send IM {%s} to %s\n", message, who);
+ const gchar *who = purple_message_get_who(pmsg);
+ PurpleMessageFlags flags = purple_message_get_flags(pmsg);
+ PurpleBuddy *buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who);
+ const gchar *cont = purple_message_get_contents(pmsg);
+
account = purple_connection_get_account(gc);
username = purple_account_get_username(account);
@@ -1551,7 +1552,7 @@
swboard = msn_session_find_swboard(session, who);
if (!strncmp("tel:+", who, 5)) {
- char *text = purple_markup_strip_html(message);
+ char *text = purple_markup_strip_html(cont);
send_to_mobile(gc, who, text);
g_free(text);
return 1;
@@ -1560,14 +1561,14 @@
if (buddy) {
PurplePresence *p = purple_buddy_get_presence(buddy);
if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
- char *text = purple_markup_strip_html(message);
+ char *text = purple_markup_strip_html(cont);
send_to_mobile(gc, who, text);
g_free(text);
return 1;
}
}
- msn_import_html(message, &msgformat, &msgtext);
+ msn_import_html(cont, &msgformat, &msgtext);
msglen = strlen(msgtext);
if (msglen == 0) {
/* Stuff like <hr> will be ignored. Don't send an empty message
--- a/libpurple/protocols/mxit/mxit.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/mxit/mxit.c Thu May 22 15:15:16 2014 +0200
@@ -401,11 +401,11 @@
Zero (success, no echo)
Negative value (error)
*/
-static int mxit_send_im( PurpleConnection* gc, const char* who, const char* message, PurpleMessageFlags flags )
+static int mxit_send_im(PurpleConnection* gc, PurpleMessage *msg)
{
- purple_debug_info( MXIT_PLUGIN_ID, "Sending message '%s' to buddy '%s'\n", message, who );
-
- mxit_send_message( purple_connection_get_protocol_data( gc ), who, message, TRUE, FALSE );
+ mxit_send_message(purple_connection_get_protocol_data(gc),
+ purple_message_get_who(msg), purple_message_get_contents(msg),
+ TRUE, FALSE);
return 1; /* echo to conversation window */
}
--- a/libpurple/protocols/novell/novell.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/novell/novell.c Thu May 22 15:15:16 2014 +0200
@@ -2270,8 +2270,7 @@
}
static int
-novell_send_im(PurpleConnection * gc, const char *name,
- const char *message_body, PurpleMessageFlags flags)
+novell_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
NMUserRecord *user_record = NULL;
NMConference *conf = NULL;
@@ -2281,9 +2280,9 @@
char *plain;
gboolean done = TRUE, created_conf = FALSE;
NMERR_T rc = NM_OK;
-
- if (gc == NULL || name == NULL ||
- message_body == NULL || *message_body == '\0')
+ const gchar *name = purple_message_get_who(msg);
+
+ if (gc == NULL || name == NULL || purple_message_is_empty(msg))
return 0;
user = purple_connection_get_protocol_data(gc);
@@ -2291,7 +2290,7 @@
return 0;
/* Create a new message */
- plain = purple_unescape_html(message_body);
+ plain = purple_unescape_html(purple_message_get_contents(msg));
message = nm_create_message(plain);
g_free(plain);
--- a/libpurple/protocols/null/nullprpl.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/null/nullprpl.c Thu May 22 15:15:16 2014 +0200
@@ -413,14 +413,16 @@
foreach_nullprpl_gc(report_status_change, gc, NULL);
}
-static int nullprpl_send_im(PurpleConnection *gc, const char *who,
- const char *message, PurpleMessageFlags flags)
+static int nullprpl_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
const char *from_username = purple_account_get_username(purple_connection_get_account(gc));
- PurpleMessageFlags receive_flags = ((flags & ~PURPLE_MESSAGE_SEND)
- | PURPLE_MESSAGE_RECV);
+ const gchar *who = purple_message_get_who(msg);
+ PurpleMessageFlags receive_flags;
PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
PurpleConnection *to;
+ const gchar *message = purple_message_get_contents(msg);
+
+ receive_flags = ((purple_message_get_flags(msg) & ~PURPLE_MESSAGE_SEND) | PURPLE_MESSAGE_RECV);
purple_debug_info("nullprpl", "sending message from %s to %s: %s\n",
from_username, who, message);
--- a/libpurple/protocols/oscar/oscar.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/oscar/oscar.c Thu May 22 15:15:16 2014 +0200
@@ -3074,7 +3074,7 @@
}
int
-oscar_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags imflags)
+oscar_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
OscarData *od;
PurpleAccount *account;
@@ -3082,7 +3082,12 @@
int ret;
char *tmp1, *tmp2;
gboolean is_sms, is_html;
-
+ const gchar *name, *message;
+ PurpleMessageFlags imflags;
+
+ name = purple_message_get_who(msg);
+ message = purple_message_get_contents(msg);
+ imflags = purple_message_get_flags(msg);
od = purple_connection_get_protocol_data(gc);
account = purple_connection_get_account(gc);
ret = 0;
--- a/libpurple/protocols/oscar/oscarcommon.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/oscar/oscarcommon.h Thu May 22 15:15:16 2014 +0200
@@ -72,7 +72,7 @@
GHashTable *oscar_chat_info_defaults(PurpleConnection *gc, const char *chat_name);
void oscar_login(PurpleAccount *account);
void oscar_close(PurpleConnection *gc);
-int oscar_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags imflags);
+int oscar_send_im(PurpleConnection *gc, PurpleMessage *msg);
void oscar_set_info(PurpleConnection *gc, const char *rawinfo);
unsigned int oscar_send_typing(PurpleConnection *gc, const char *name, PurpleIMTypingState state);
void oscar_get_info(PurpleConnection *gc, const char *name);
--- a/libpurple/protocols/sametime/sametime.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/sametime/sametime.c Thu May 22 15:15:16 2014 +0200
@@ -3909,20 +3909,24 @@
}
-static int mw_prpl_send_im(PurpleConnection *gc,
- const char *name,
- const char *message,
- PurpleMessageFlags flags) {
-
+static int mw_prpl_send_im(PurpleConnection *gc, PurpleMessage *msg) {
+
+ gchar name[1000];
struct mwPurplePluginData *pd;
- struct mwIdBlock who = { (char *) name, NULL };
+ struct mwIdBlock who = { name, NULL };
struct mwConversation *conv;
+ const gchar *message;
+ PurpleMessageFlags flags;
g_return_val_if_fail(gc != NULL, 0);
pd = purple_connection_get_protocol_data(gc);
g_return_val_if_fail(pd != NULL, 0);
+ g_strlcpy(name, purple_message_get_who(msg), sizeof(name));
+ message = purple_message_get_contents(msg);
+ flags = purple_message_get_flags(msg);
+
conv = mwServiceIm_getConversation(pd->srvc_im, &who);
/* this detection of features to determine how to send the message
@@ -4771,7 +4775,7 @@
const char *who,
const char *message) {
- mw_prpl_send_im(gc, who, message, 0);
+ mw_prpl_send_im(gc, purple_message_new(who, message, 0));
}
--- a/libpurple/protocols/silc/silc.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/silc/silc.c Thu May 22 15:15:16 2014 +0200
@@ -1440,8 +1440,7 @@
}
static int
-silcpurple_send_im(PurpleConnection *gc, const char *who, const char *message,
- PurpleMessageFlags flags)
+silcpurple_send_im(PurpleConnection *gc, PurpleMessage *pmsg)
{
SilcPurple sg = purple_connection_get_protocol_data(gc);
SilcClient client = sg->client;
@@ -1453,8 +1452,11 @@
int ret = 0;
gboolean sign = purple_account_get_bool(sg->account, "sign-verify", FALSE);
SilcDList list;
+ const gchar *who = purple_message_get_who(pmsg);
+ const gchar *message = purple_message_get_contents(pmsg);
+ PurpleMessageFlags flags = purple_message_get_flags(pmsg);
- if (!who || !message)
+ if (!who || purple_message_is_empty(pmsg))
return 0;
mflags = SILC_MESSAGE_FLAG_UTF8;
@@ -1674,7 +1676,8 @@
if (gc == NULL)
return PURPLE_CMD_RET_FAILED;
- ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND);
+ ret = silcpurple_send_im(gc,
+ purple_message_new(args[0], args[1], PURPLE_MESSAGE_SEND));
if (ret)
return PURPLE_CMD_RET_OK;
@@ -1705,7 +1708,10 @@
im = purple_im_conversation_new(account, args[0]);
if (args[1]) {
- ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND);
+ PurpleMessage *msg = purple_message_new(args[0],
+ args[1], PURPLE_MESSAGE_SEND);
+
+ ret = silcpurple_send_im(gc, msg);
purple_conversation_write_message(PURPLE_CONVERSATION(im), purple_connection_get_display_name(gc),
args[1], PURPLE_MESSAGE_SEND, time(NULL));
}
--- a/libpurple/protocols/simple/simple.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/simple/simple.c Thu May 22 15:15:16 2014 +0200
@@ -1030,10 +1030,10 @@
g_free(fullto);
}
-static int simple_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) {
+static int simple_im_send(PurpleConnection *gc, PurpleMessage *msg) {
struct simple_account_data *sip = purple_connection_get_protocol_data(gc);
- char *to = g_strdup(who);
- char *text = purple_unescape_html(what);
+ char *to = g_strdup(purple_message_get_who(msg));
+ char *text = purple_unescape_html(purple_message_get_contents(msg));
simple_send_message(sip, to, text, NULL);
g_free(to);
g_free(text);
--- a/libpurple/protocols/yahoo/libymsg.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/yahoo/libymsg.c Thu May 22 15:15:16 2014 +0200
@@ -4498,8 +4498,8 @@
if (status && g_str_equal(status, "Valid")) {
g_hash_table_insert(yd->sms_carrier,
g_strdup_printf("+%s", mobile_no), g_strdup(carrier));
- yahoo_send_im(sms_cb_data->gc, sms_cb_data->who,
- sms_cb_data->what, PURPLE_MESSAGE_SEND);
+ yahoo_send_im(sms_cb_data->gc, purple_message_new(sms_cb_data->who,
+ sms_cb_data->what, PURPLE_MESSAGE_SEND));
} else {
g_hash_table_insert(yd->sms_carrier,
g_strdup_printf("+%s", mobile_no), g_strdup("Unknown"));
@@ -4561,11 +4561,11 @@
g_free(validate_request_str);
}
-int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
+int yahoo_send_im(PurpleConnection *gc, PurpleMessage *pmsg)
{
YahooData *yd = purple_connection_get_protocol_data(gc);
struct yahoo_packet *pkt = NULL;
- char *msg = yahoo_html_to_codes(what);
+ char *msg = yahoo_html_to_codes(purple_message_get_contents(pmsg));
char *msg2;
PurpleWhiteboard *wb;
int ret = 1;
@@ -4574,6 +4574,8 @@
glong lenc = 0;
struct yahoo_p2p_data *p2p_data;
YahooFederation fed = YAHOO_FEDERATION_NONE;
+ const gchar *who = purple_message_get_who(pmsg);
+
msg2 = yahoo_string_encode(gc, msg, TRUE);
if(msg2) {
@@ -4606,7 +4608,7 @@
sms_cb_data = g_malloc(sizeof(struct yahoo_sms_carrier_cb_data));
sms_cb_data->gc = gc;
sms_cb_data->who = g_strdup(who);
- sms_cb_data->what = g_strdup(what);
+ sms_cb_data->what = g_strdup(purple_message_get_contents(pmsg));
purple_conversation_write(PURPLE_CONVERSATION(im), NULL, _("Getting mobile carrier to send the SMS."), PURPLE_MESSAGE_SYSTEM, time(NULL));
--- a/libpurple/protocols/yahoo/libymsg.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/yahoo/libymsg.h Thu May 22 15:15:16 2014 +0200
@@ -364,7 +364,7 @@
GList *yahoo_blist_node_menu(PurpleBlistNode *node);
void yahoo_login(PurpleAccount *account);
void yahoo_close(PurpleConnection *gc);
-int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags);
+int yahoo_send_im(PurpleConnection *gc, PurpleMessage *msg);
unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleIMTypingState state);
void yahoo_set_status(PurpleAccount *account, PurpleStatus *status);
void yahoo_set_idle(PurpleConnection *gc, int idle);
--- a/libpurple/protocols/zephyr/zephyr.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/protocols/zephyr/zephyr.c Thu May 22 15:15:16 2014 +0200
@@ -2077,16 +2077,19 @@
}
-static int zephyr_send_im(PurpleConnection * gc, const char *who, const char *im, PurpleMessageFlags flags)
+static int zephyr_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
const char *sig;
zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
- if (flags & PURPLE_MESSAGE_AUTO_RESP)
+
+ if (purple_message_get_flags(msg) & PURPLE_MESSAGE_AUTO_RESP) {
sig = "Automated reply:";
- else {
+ } else {
sig = zephyr_get_signature();
}
- zephyr_send_message(zephyr,"MESSAGE","PERSONAL",local_zephyr_normalize(zephyr,who),im,sig,"");
+ zephyr_send_message(zephyr, "MESSAGE", "PERSONAL",
+ local_zephyr_normalize(zephyr, purple_message_get_who(msg)),
+ purple_message_get_contents(msg), sig, "");
return 1;
}
--- a/libpurple/prpl.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/prpl.h Thu May 22 15:15:16 2014 +0200
@@ -84,6 +84,7 @@
#include "xfer.h"
#include "image.h"
#include "media.h"
+#include "message.h"
#include "notify.h"
#include "proxy.h"
#include "plugin.h"
@@ -317,9 +318,7 @@
* errno values, or just big something. If the message should
* not be echoed to the conversation window, return 0.
*/
- int (*send_im)(PurpleConnection *, const char *who,
- const char *message,
- PurpleMessageFlags flags);
+ int (*send_im)(PurpleConnection *, PurpleMessage *msg);
void (*set_info)(PurpleConnection *, const char *info);
--- a/libpurple/server.c Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/server.c Thu May 22 15:15:16 2014 +0200
@@ -116,8 +116,7 @@
return lar;
}
-int purple_serv_send_im(PurpleConnection *gc, const char *name, const char *message,
- PurpleMessageFlags flags)
+int purple_serv_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
PurpleIMConversation *im = NULL;
PurpleAccount *account = NULL;
@@ -126,8 +125,10 @@
PurplePluginProtocolInfo *prpl_info = NULL;
int val = -EINVAL;
const gchar *auto_reply_pref = NULL;
+ const gchar *who;
g_return_val_if_fail(gc != NULL, val);
+ g_return_val_if_fail(msg != NULL, val);
prpl = purple_connection_get_prpl(gc);
@@ -137,11 +138,12 @@
account = purple_connection_get_account(gc);
presence = purple_account_get_presence(account);
+ who = purple_message_get_who(msg);
- im = purple_conversations_find_im_with_account(name, account);
+ im = purple_conversations_find_im_with_account(who, account);
if (prpl_info->send_im)
- val = prpl_info->send_im(gc, name, message, flags);
+ val = prpl_info->send_im(gc, msg);
/*
* XXX - If "only auto-reply when away & idle" is set, then shouldn't
@@ -153,7 +155,7 @@
!purple_strequal(auto_reply_pref, "never")) {
struct last_auto_response *lar;
- lar = get_last_auto_response(gc, name);
+ lar = get_last_auto_response(gc, who);
lar->sent = time(NULL);
}
@@ -676,7 +678,12 @@
if (!(flags & PURPLE_MESSAGE_AUTO_RESP))
{
- purple_serv_send_im(gc, name, away_msg, PURPLE_MESSAGE_AUTO_RESP);
+ PurpleMessage *msg;
+
+ msg = purple_message_new(name, away_msg,
+ PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP);
+
+ purple_serv_send_im(gc, msg);
purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, away_msg,
PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP,
--- a/libpurple/server.h Thu May 22 14:08:33 2014 +0200
+++ b/libpurple/server.h Thu May 22 15:15:16 2014 +0200
@@ -30,6 +30,7 @@
#include "accounts.h"
#include "conversations.h"
+#include "message.h"
#include "prpl.h"
G_BEGIN_DECLS
@@ -54,7 +55,7 @@
unsigned int purple_serv_send_typing(PurpleConnection *gc, const char *name, PurpleIMTypingState state);
void purple_serv_move_buddy(PurpleBuddy *, PurpleGroup *, PurpleGroup *);
-int purple_serv_send_im(PurpleConnection *, const char *, const char *, PurpleMessageFlags flags);
+int purple_serv_send_im(PurpleConnection *, PurpleMessage *msg);
/**
* purple_get_attention_type_from_code:
--- a/pidgin/gtkpounce.c Thu May 22 14:08:33 2014 +0200
+++ b/pidgin/gtkpounce.c Thu May 22 15:15:16 2014 +0200
@@ -1480,15 +1480,19 @@
if (message != NULL)
{
+ PurpleMessage *pmsg;
+
im = purple_conversations_find_im_with_account(pouncee, account);
if (im == NULL)
im = purple_im_conversation_new(account, pouncee);
+ pmsg = purple_message_new(pouncee, message, 0);
+
purple_conversation_write(PURPLE_CONVERSATION(im), NULL, message,
PURPLE_MESSAGE_SEND, time(NULL));
- purple_serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
+ purple_serv_send_im(purple_account_get_connection(account), pmsg);
}
}
--- a/pidgin/plugins/musicmessaging/musicmessaging.c Thu May 22 14:08:33 2014 +0200
+++ b/pidgin/plugins/musicmessaging/musicmessaging.c Thu May 22 15:15:16 2014 +0200
@@ -488,14 +488,16 @@
{
PurpleConnection *connection = purple_conversation_get_connection(mmconv->conv);
const char *convName = purple_conversation_get_name(mmconv->conv);
- purple_serv_send_im(connection, convName, MUSICMESSAGING_START_MSG, PURPLE_MESSAGE_SEND);
+ purple_serv_send_im(connection, purple_message_new(
+ convName, MUSICMESSAGING_START_MSG, PURPLE_MESSAGE_SEND));
}
static void send_request_confirmed(MMConversation *mmconv)
{
PurpleConnection *connection = purple_conversation_get_connection(mmconv->conv);
const char *convName = purple_conversation_get_name(mmconv->conv);
- purple_serv_send_im(connection, convName, MUSICMESSAGING_CONFIRM_MSG, PURPLE_MESSAGE_SEND);
+ purple_serv_send_im(connection, purple_message_new(
+ convName, MUSICMESSAGING_CONFIRM_MSG, PURPLE_MESSAGE_SEND));
}