pidgin/pidgin

4951752ad038
Parents dc5d15df3a88
Children a4eb488f88ae
Split PurpleMessage into incoming, outgoing and system
--- a/finch/gntconv.c Fri May 23 00:11:01 2014 +0200
+++ b/finch/gntconv.c Fri May 23 09:20:34 2014 +0200
@@ -1093,7 +1093,7 @@
finch_write_chat(PurpleChatConversation *chat, PurpleMessage *msg)
{
purple_conversation_write(PURPLE_CONVERSATION(chat),
- purple_message_get_who(msg),
+ purple_message_get_author(msg),
purple_message_get_contents(msg),
purple_message_get_flags(msg),
purple_message_get_time(msg));
@@ -1105,7 +1105,7 @@
PurpleConversation *conv = PURPLE_CONVERSATION(im);
PurpleAccount *account = purple_conversation_get_account(conv);
PurpleMessageFlags flags = purple_message_get_flags(msg);
- const gchar *who = purple_message_get_who(msg);
+ const gchar *who = purple_message_get_author(msg);
if (flags & PURPLE_MESSAGE_SEND)
{
--- a/finch/gntpounce.c Fri May 23 00:11:01 2014 +0200
+++ b/finch/gntpounce.c Fri May 23 09:20:34 2014 +0200
@@ -875,7 +875,7 @@
if (im == NULL)
im = purple_im_conversation_new(account, pouncee);
- pmsg = purple_message_new(pouncee, message, PURPLE_MESSAGE_SEND);
+ pmsg = purple_message_new_outgoing(pouncee, message, 0);
purple_serv_send_im(purple_account_get_connection(account), pmsg);
purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
}
--- a/finch/gntsound.c Fri May 23 00:11:01 2014 +0200
+++ b/finch/gntsound.c Fri May 23 09:20:34 2014 +0200
@@ -208,7 +208,7 @@
PurpleSoundEventID event)
{
PurpleIMConversation *im = purple_conversations_find_im_with_account(
- purple_message_get_who(msg), account);
+ purple_message_get_recipient(msg), account);
play_conv_event(PURPLE_CONVERSATION(im), event);
}
--- a/libpurple/conversation.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/conversation.c Fri May 23 09:20:34 2014 +0200
@@ -134,8 +134,8 @@
msgflags |= PURPLE_MESSAGE_SEND;
if (PURPLE_IS_IM_CONVERSATION(conv)) {
- msg = purple_message_new(purple_conversation_get_name(conv),
- sent, msgflags);
+ msg = purple_message_new_outgoing(
+ purple_conversation_get_name(conv), sent, msgflags);
purple_signal_emit(purple_conversations_get_handle(), "sending-im-msg",
account, msg);
@@ -154,7 +154,7 @@
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);
+ msg = purple_message_new_outgoing(NULL, sent, msgflags);
purple_signal_emit(purple_conversations_get_handle(),
"sending-chat-msg", account, msg, id);
--- a/libpurple/conversationtypes.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/conversationtypes.c Fri May 23 09:20:34 2014 +0200
@@ -357,13 +357,15 @@
{
PurpleConversationUiOps *ops;
PurpleIMConversation *im = PURPLE_IM_CONVERSATION(conv);
+ gboolean is_recv;
g_return_if_fail(im != NULL);
g_return_if_fail(msg != NULL);
ops = purple_conversation_get_ui_ops(conv);
+ is_recv = (purple_message_get_flags(msg) & PURPLE_MESSAGE_RECV);
- if (purple_message_get_flags(msg) & PURPLE_MESSAGE_RECV)
+ if (is_recv)
purple_im_conversation_set_typing_state(im, PURPLE_IM_NOT_TYPING);
/* Pass this on to either the ops structure or the default write func. */
@@ -371,7 +373,7 @@
ops->write_im(im, msg);
else {
purple_conversation_write(conv,
- purple_message_get_who(msg),
+ purple_message_get_author(msg),
purple_message_get_contents(msg),
purple_message_get_flags(msg),
purple_message_get_time(msg));
@@ -812,7 +814,7 @@
/* Don't display this if the person who wrote it is ignored. */
if (purple_chat_conversation_is_ignored_user(
- PURPLE_CHAT_CONVERSATION(conv), purple_message_get_who(msg)))
+ PURPLE_CHAT_CONVERSATION(conv), purple_message_get_author(msg)))
{
return;
}
@@ -840,7 +842,7 @@
ops->write_chat(PURPLE_CHAT_CONVERSATION(conv), msg);
else {
purple_conversation_write(conv,
- purple_message_get_who(msg),
+ purple_message_get_author(msg),
purple_message_get_contents(msg),
purple_message_get_flags(msg),
purple_message_get_time(msg));
--- a/libpurple/message.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/message.c Fri May 23 09:20:34 2014 +0200
@@ -32,8 +32,9 @@
typedef struct {
guint id;
- gchar *who;
- gchar *alias;
+ gchar *author;
+ gchar *author_alias;
+ gchar *recipient;
gchar *contents;
guint64 msgtime;
PurpleMessageFlags flags;
@@ -43,8 +44,9 @@
{
PROP_0,
PROP_ID,
- PROP_WHO,
- PROP_ALIAS,
+ PROP_AUTHOR,
+ PROP_AUTHOR_ALIAS,
+ PROP_RECIPIENT,
PROP_CONTENTS,
PROP_TIME,
PROP_FLAGS,
@@ -61,20 +63,57 @@
******************************************************************************/
PurpleMessage *
-purple_message_new(const gchar *who, const gchar *contents,
+purple_message_new_outgoing(const gchar *who, const gchar *contents,
PurpleMessageFlags flags)
{
- if (!(flags & (PURPLE_MESSAGE_SEND |
- PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM)))
- {
- purple_debug_warning("message", "Invalid flags %#x", flags);
- }
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV));
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM));
+
+ flags |= PURPLE_MESSAGE_SEND;
+
+ /* who may be NULL for outgoing MUC messages */
+ return g_object_new(PURPLE_TYPE_MESSAGE,
+ "author-alias", _("Me"),
+ "recipient", who,
+ "contents", contents,
+ "time", (guint64)time(NULL),
+ "flags", flags,
+ NULL);
+}
+
+PurpleMessage *
+purple_message_new_incoming(const gchar *who, const gchar *contents,
+ PurpleMessageFlags flags, guint64 timestamp)
+{
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND));
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM));
+
+ flags |= PURPLE_MESSAGE_RECV;
+
+ if (timestamp == 0)
+ timestamp = time(NULL);
return g_object_new(PURPLE_TYPE_MESSAGE,
- "who", who,
+ "author", who,
+ "author-alias", who,
"contents", contents,
+ "time", timestamp,
"flags", flags,
+ NULL);
+}
+
+PurpleMessage *
+purple_message_new_system(const gchar *contents, PurpleMessageFlags flags)
+{
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND));
+ g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV));
+
+ flags |= PURPLE_MESSAGE_SYSTEM;
+
+ return g_object_new(PURPLE_TYPE_MESSAGE,
+ "contents", contents,
"time", (guint64)time(NULL),
+ "flags", flags,
NULL);
}
@@ -97,29 +136,39 @@
}
const gchar *
-purple_message_get_who(PurpleMessage *msg)
+purple_message_get_author(PurpleMessage *msg)
+{
+ PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->author;
+}
+
+const gchar *
+purple_message_get_recipient(PurpleMessage *msg)
{
PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
g_return_val_if_fail(priv != NULL, NULL);
- return priv->who;
+ return priv->recipient;
}
void
-purple_message_set_alias(PurpleMessage *msg, const gchar *alias)
+purple_message_set_author_alias(PurpleMessage *msg, const gchar *alias)
{
- g_object_set(msg, "alias", alias, NULL);
+ g_object_set(msg, "author-alias", alias, NULL);
}
const gchar *
-purple_message_get_alias(PurpleMessage *msg)
+purple_message_get_author_alias(PurpleMessage *msg)
{
PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
g_return_val_if_fail(priv != NULL, NULL);
- return priv->alias;
+ return priv->author_alias;
}
void
@@ -201,8 +250,9 @@
PurpleMessage *message = PURPLE_MESSAGE(obj);
PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(message);
- g_free(priv->who);
- g_free(priv->alias);
+ g_free(priv->author);
+ g_free(priv->author_alias);
+ g_free(priv->recipient);
g_free(priv->contents);
G_OBJECT_CLASS(parent_class)->finalize(obj);
@@ -219,11 +269,14 @@
case PROP_ID:
g_value_set_uint(value, priv->id);
break;
- case PROP_WHO:
- g_value_set_string(value, priv->who);
+ case PROP_AUTHOR:
+ g_value_set_string(value, priv->author);
break;
- case PROP_ALIAS:
- g_value_set_string(value, priv->alias);
+ case PROP_AUTHOR_ALIAS:
+ g_value_set_string(value, priv->author_alias);
+ break;
+ case PROP_RECIPIENT:
+ g_value_set_string(value, priv->recipient);
break;
case PROP_CONTENTS:
g_value_set_string(value, priv->contents);
@@ -248,13 +301,17 @@
PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(message);
switch (par_id) {
- case PROP_WHO:
- g_free(priv->who);
- priv->who = g_strdup(g_value_get_string(value));
+ case PROP_AUTHOR:
+ g_free(priv->author);
+ priv->author = g_strdup(g_value_get_string(value));
break;
- case PROP_ALIAS:
- g_free(priv->alias);
- priv->alias = g_strdup(g_value_get_string(value));
+ case PROP_AUTHOR_ALIAS:
+ g_free(priv->author_alias);
+ priv->author_alias = g_strdup(g_value_get_string(value));
+ break;
+ case PROP_RECIPIENT:
+ g_free(priv->recipient);
+ priv->recipient = g_strdup(g_value_get_string(value));
break;
case PROP_CONTENTS:
g_free(priv->contents);
@@ -288,15 +345,16 @@
properties[PROP_ID] = g_param_spec_uint("id",
"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",
- "Who", "The nick of the person, who sent the message (for "
- "incoming messages) or the recipient (for outgoing). "
- "Unused for outgoing chat messages.",
+ properties[PROP_AUTHOR] = g_param_spec_string("author",
+ "Author", "The username of the person, who sent the message.",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- properties[PROP_ALIAS] = g_param_spec_string("alias",
+ properties[PROP_AUTHOR_ALIAS] = g_param_spec_string("author-alias",
"Author's alias", "The alias of the person, who sent the "
"message. For outgoing messages, it's your alias.",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ properties[PROP_RECIPIENT] = g_param_spec_string("recipient",
+ "Recipient", "The username of the recipient.",
+ NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[PROP_CONTENTS] = g_param_spec_string("contents",
"Contents", "The message text",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
--- a/libpurple/message.h Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/message.h Fri May 23 09:20:34 2014 +0200
@@ -83,9 +83,16 @@
purple_message_get_type(void);
PurpleMessage *
-purple_message_new(const gchar *who, const gchar *contents,
+purple_message_new_outgoing(const gchar *who, const gchar *contents,
PurpleMessageFlags flags);
+PurpleMessage *
+purple_message_new_incoming(const gchar *who, const gchar *contents,
+ PurpleMessageFlags flags, guint64 timestamp);
+
+PurpleMessage *
+purple_message_new_system(const gchar *contents, PurpleMessageFlags flags);
+
guint
purple_message_get_id(PurpleMessage *msg);
@@ -93,13 +100,16 @@
purple_message_find_by_id(guint id);
const gchar *
-purple_message_get_who(PurpleMessage *msg);
+purple_message_get_author(PurpleMessage *msg);
+
+const gchar *
+purple_message_get_recipient(PurpleMessage *msg);
void
-purple_message_set_alias(PurpleMessage *msg, const gchar *alias);
+purple_message_set_author_alias(PurpleMessage *msg, const gchar *alias);
const gchar *
-purple_message_get_alias(PurpleMessage *msg);
+purple_message_get_author_alias(PurpleMessage *msg);
void
purple_message_set_contents(PurpleMessage *msg, const gchar *cont);
--- a/libpurple/plugins/offlinemsg.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/plugins/offlinemsg.c Fri May 23 09:20:34 2014 +0200
@@ -107,8 +107,8 @@
GINT_TO_POINTER(OFFLINE_MSG_YES));
/* TODO: use a reference to a PurpleMessage */
- purple_conversation_write_message(conv, purple_message_new(offline->who,
- offline->message, PURPLE_MESSAGE_SEND));
+ purple_conversation_write_message(conv,
+ purple_message_new_outgoing(offline->who, offline->message, 0));
discard_data(offline);
}
@@ -120,7 +120,7 @@
OfflineMsg *offline;
PurpleConversation *conv;
OfflineMessageSetting setting;
- const gchar *who = purple_message_get_who(msg);
+ const gchar *who = purple_message_get_recipient(msg);
if (purple_message_is_empty(msg))
return;
--- a/libpurple/plugins/signals-test.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/plugins/signals-test.c Fri May 23 09:20:34 2014 +0200
@@ -305,7 +305,7 @@
{
purple_debug_misc("signals test", "sending-im-msg (%s, %s, %s)\n",
purple_account_get_username(account),
- purple_message_get_who(msg),
+ purple_message_get_recipient(msg),
purple_message_get_contents(msg));
}
@@ -315,7 +315,7 @@
{
purple_debug_misc("signals test", "sent-im-msg (%s, %s, %s)\n",
purple_account_get_username(account),
- purple_message_get_who(msg),
+ purple_message_get_recipient(msg),
purple_message_get_contents(msg));
}
--- a/libpurple/plugins/tcl/tcl_cmds.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/plugins/tcl/tcl_cmds.c Fri May 23 09:20:34 2014 +0200
@@ -770,10 +770,11 @@
enum { CMD_CONV_NEW_CHAT, CMD_CONV_NEW_IM } newopt;
PurpleConversation *convo;
PurpleAccount *account;
+ PurpleMessage *pmsg;
gboolean is_chat = FALSE;
GList *cur;
char *opt, *from, *what;
- int error, argsused, flags = 0;
+ int error, argsused;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
@@ -865,16 +866,16 @@
switch (style) {
case CMD_CONV_WRITE_SEND:
- flags = PURPLE_MESSAGE_SEND;
+ pmsg = purple_message_new_outgoing(from, what, 0);
break;
case CMD_CONV_WRITE_RECV:
- flags = PURPLE_MESSAGE_RECV;
+ pmsg = purple_message_new_incoming(from, what, 0, 0);
break;
case CMD_CONV_WRITE_SYSTEM:
- flags = PURPLE_MESSAGE_SYSTEM;
+ pmsg = purple_message_new_system(what, 0);
break;
}
- purple_conversation_write_message(convo, purple_message_new(from, what, flags));
+ purple_conversation_write_message(convo, pmsg);
break;
case CMD_CONV_NAME:
if (objc != 3) {
@@ -1411,7 +1412,7 @@
who = Tcl_GetString(objv[2]);
text = Tcl_GetString(objv[3]);
- purple_serv_send_im(gc, purple_message_new(who, text, PURPLE_MESSAGE_SEND));
+ purple_serv_send_im(gc, purple_message_new_outgoing(who, text, 0));
return TCL_OK;
}
--- a/libpurple/protocols/bonjour/bonjour.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/bonjour/bonjour.c Fri May 23 09:20:34 2014 +0200
@@ -209,11 +209,11 @@
{
BonjourData *bd = purple_connection_get_protocol_data(connection);
- if (purple_message_is_empty(msg) || !purple_message_get_who(msg))
+ if (purple_message_is_empty(msg) || !purple_message_get_recipient(msg))
return 0;
return bonjour_jabber_send_message(bd->jabber_data,
- purple_message_get_who(msg),
+ purple_message_get_recipient(msg),
purple_message_get_contents(msg));
}
--- a/libpurple/protocols/gg/message-prpl.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/gg/message-prpl.c Fri May 23 09:20:34 2014 +0200
@@ -247,7 +247,7 @@
PurpleIMConversation *im = ggp_message_get_conv(gc, msg->user);
PurpleMessage *pmsg;
- pmsg = purple_message_new(NULL, msg->text, PURPLE_MESSAGE_SEND);
+ pmsg = purple_message_new_outgoing(NULL, msg->text, 0);
purple_message_set_time(pmsg, msg->time);
purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
@@ -643,7 +643,7 @@
ggp_buddy_data *buddy_data;
gchar *gg_msg;
gboolean succ;
- const gchar *who = purple_message_get_who(msg);
+ const gchar *rcpt = purple_message_get_recipient(msg);
/* TODO: return -ENOTCONN, if not connected */
@@ -651,13 +651,13 @@
return 0;
buddy_data = ggp_buddy_get_data(purple_blist_find_buddy(
- purple_connection_get_account(gc), who));
+ purple_connection_get_account(gc), rcpt));
if (buddy_data->blocked)
return -1;
im = purple_conversations_find_im_with_account(
- who, purple_connection_get_account(gc));
+ rcpt, purple_connection_get_account(gc));
gg_msg = ggp_message_format_to_gg(PURPLE_CONVERSATION(im),
purple_message_get_contents(msg));
@@ -670,12 +670,12 @@
#if GGP_ENABLE_GG11
succ = (gg_send_message_html(info->session, GG_CLASS_CHAT,
- ggp_str_to_uin(who), (unsigned char *)gg_msg) >= 0);
+ ggp_str_to_uin(rcpt), (unsigned char *)gg_msg) >= 0);
#else
{
gchar *plain = purple_markup_strip_html(gg_msg);
succ = (gg_send_message(info->session, GG_CLASS_CHAT,
- ggp_str_to_uin(who), (unsigned char *)plain) >= 0);
+ ggp_str_to_uin(rcpt), (unsigned char *)plain) >= 0);
g_free(plain);
}
#endif
--- a/libpurple/protocols/irc/cmds.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/irc/cmds.c Fri May 23 09:20:34 2014 +0200
@@ -108,13 +108,13 @@
/* XXX: we'd prefer to keep this in conversation.c */
if (PURPLE_IS_IM_CONVERSATION(convo)) {
- pmsg = purple_message_new(purple_conversation_get_name(convo),
- msg, PURPLE_MESSAGE_SEND);
+ pmsg = purple_message_new_outgoing(
+ purple_conversation_get_name(convo), msg, 0);
purple_signal_emit(purple_conversations_get_handle(),
"sending-im-msg", irc->account, pmsg);
} else {
- pmsg = purple_message_new(NULL, msg, PURPLE_MESSAGE_SEND);
+ pmsg = purple_message_new_outgoing(NULL, msg, 0);
purple_signal_emit(purple_conversations_get_handle(),
"sending-chat-msg", irc->account, pmsg,
@@ -189,9 +189,8 @@
purple_connection_get_display_name(gc),
PURPLE_MESSAGE_SEND, action, time(NULL));
else
- purple_conversation_write_message(convo, purple_message_new(
- purple_connection_get_display_name(gc), action,
- PURPLE_MESSAGE_SEND));
+ purple_conversation_write_message(convo, purple_message_new_outgoing(
+ purple_connection_get_display_name(gc), action, 0));
g_free(action);
}
@@ -503,8 +502,8 @@
gc = purple_account_get_connection(irc->account);
irc_cmd_privmsg(irc, cmd, target, args);
purple_conversation_write_message(PURPLE_CONVERSATION(im),
- purple_message_new(purple_connection_get_display_name(gc),
- args[1], PURPLE_MESSAGE_SEND));
+ purple_message_new_outgoing(
+ purple_connection_get_display_name(gc), args[1], 0));
}
return 0;
--- a/libpurple/protocols/irc/irc.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/irc/irc.c Fri May 23 09:20:34 2014 +0200
@@ -564,7 +564,7 @@
char *plain;
const char *args[2];
- args[0] = irc_nick_skip_mode(irc, purple_message_get_who(msg));
+ args[0] = irc_nick_skip_mode(irc, purple_message_get_recipient(msg));
purple_markup_html_to_xhtml(purple_message_get_contents(msg),
NULL, &plain);
--- a/libpurple/protocols/jabber/jabber.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/jabber/jabber.c Fri May 23 09:20:34 2014 +0200
@@ -3072,7 +3072,7 @@
who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
jabber_message_send_im(purple_conversation_get_connection(conv),
- purple_message_new(who, args[1], PURPLE_MESSAGE_SEND));
+ purple_message_new_outgoing(who, args[1], 0));
g_free(who);
return PURPLE_CMD_RET_OK;
--- a/libpurple/protocols/jabber/message.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/jabber/message.c Fri May 23 09:20:34 2014 +0200
@@ -1127,14 +1127,14 @@
char *xhtml;
char *tmp;
char *resource;
- const gchar *who = purple_message_get_who(msg);
+ const gchar *rcpt = purple_message_get_recipient(msg);
- if (!who || purple_message_is_empty(msg))
+ if (!rcpt || purple_message_is_empty(msg))
return 0;
- resource = jabber_get_resource(who);
+ resource = jabber_get_resource(rcpt);
- jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), who, TRUE);
+ jb = jabber_buddy_find(purple_connection_get_protocol_data(gc), rcpt, TRUE);
jbr = jabber_buddy_find_resource(jb, resource);
g_free(resource);
@@ -1143,7 +1143,7 @@
jm->js = purple_connection_get_protocol_data(gc);
jm->type = JABBER_MESSAGE_CHAT;
jm->chat_state = JM_STATE_ACTIVE;
- jm->to = g_strdup(who);
+ jm->to = g_strdup(rcpt);
jm->id = jabber_get_next_id(jm->js);
if(jbr) {
--- a/libpurple/protocols/msn/msn.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/msn/msn.c Fri May 23 09:20:34 2014 +0200
@@ -1540,20 +1540,20 @@
char *msgtext;
size_t msglen;
const char *username;
- const gchar *who = purple_message_get_who(pmsg);
+ const gchar *rcpt = purple_message_get_recipient(pmsg);
PurpleMessageFlags flags = purple_message_get_flags(pmsg);
- PurpleBuddy *buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who);
+ PurpleBuddy *buddy = purple_blist_find_buddy(purple_connection_get_account(gc), rcpt);
const gchar *cont = purple_message_get_contents(pmsg);
account = purple_connection_get_account(gc);
username = purple_account_get_username(account);
session = purple_connection_get_protocol_data(gc);
- swboard = msn_session_find_swboard(session, who);
-
- if (!strncmp("tel:+", who, 5)) {
+ swboard = msn_session_find_swboard(session, rcpt);
+
+ if (!strncmp("tel:+", rcpt, 5)) {
char *text = purple_markup_strip_html(cont);
- send_to_mobile(gc, who, text);
+ send_to_mobile(gc, rcpt, text);
g_free(text);
return 1;
}
@@ -1562,7 +1562,7 @@
PurplePresence *p = purple_buddy_get_presence(buddy);
if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
char *text = purple_markup_strip_html(cont);
- send_to_mobile(gc, who, text);
+ send_to_mobile(gc, rcpt, text);
g_free(text);
return 1;
}
@@ -1588,20 +1588,20 @@
}
msg = msn_message_new_plain(msgtext);
- msg->remote_user = g_strdup(who);
+ msg->remote_user = g_strdup(rcpt);
msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
g_free(msgformat);
g_free(msgtext);
purple_debug_info("msn", "prepare to send online Message\n");
- if (g_ascii_strcasecmp(who, username))
+ if (g_ascii_strcasecmp(rcpt, username))
{
if (flags & PURPLE_MESSAGE_AUTO_RESP) {
msn_message_set_flag(msg, 'U');
}
- if (msn_user_is_yahoo(account, who) || !(msn_user_is_online(account, who) || swboard != NULL)) {
+ if (msn_user_is_yahoo(account, rcpt) || !(msn_user_is_online(account, rcpt) || swboard != NULL)) {
/*we send the online and offline Message to Yahoo User via UBM*/
purple_debug_info("msn", "send to Yahoo User\n");
msn_notification_send_uum(session, msg);
@@ -1631,9 +1631,9 @@
g_free(pre);
g_free(post);
- purple_serv_got_typing_stopped(gc, who);
+ purple_serv_got_typing_stopped(gc, rcpt);
imdata->gc = g_object_ref(gc);
- imdata->who = who;
+ imdata->who = rcpt;
imdata->msg = body_str;
imdata->flags = flags & ~PURPLE_MESSAGE_SEND;
imdata->when = time(NULL);
--- a/libpurple/protocols/mxit/mxit.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/mxit/mxit.c Fri May 23 09:20:34 2014 +0200
@@ -404,7 +404,7 @@
static int mxit_send_im(PurpleConnection* gc, PurpleMessage *msg)
{
mxit_send_message(purple_connection_get_protocol_data(gc),
- purple_message_get_who(msg), purple_message_get_contents(msg),
+ purple_message_get_recipient(msg), purple_message_get_contents(msg),
TRUE, FALSE);
return 1; /* echo to conversation window */
--- a/libpurple/protocols/novell/novell.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/novell/novell.c Fri May 23 09:20:34 2014 +0200
@@ -2278,7 +2278,7 @@
char *plain;
gboolean done = TRUE, created_conf = FALSE;
NMERR_T rc = NM_OK;
- const gchar *name = purple_message_get_who(msg);
+ const gchar *name = purple_message_get_recipient(msg);
if (gc == NULL || name == NULL || purple_message_is_empty(msg))
return 0;
--- a/libpurple/protocols/null/nullprpl.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/null/nullprpl.c Fri May 23 09:20:34 2014 +0200
@@ -416,7 +416,7 @@
static int nullprpl_send_im(PurpleConnection *gc, PurpleMessage *msg)
{
const char *from_username = purple_account_get_username(purple_connection_get_account(gc));
- const gchar *who = purple_message_get_who(msg);
+ const gchar *who = purple_message_get_recipient(msg);
PurpleMessageFlags receive_flags;
PurpleAccount *to_acct = purple_accounts_find(who, NULLPRPL_ID);
PurpleConnection *to;
--- a/libpurple/protocols/oscar/oscar.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/oscar/oscar.c Fri May 23 09:20:34 2014 +0200
@@ -3087,7 +3087,7 @@
const gchar *name, *message;
PurpleMessageFlags imflags;
- name = purple_message_get_who(msg);
+ name = purple_message_get_recipient(msg);
message = purple_message_get_contents(msg);
imflags = purple_message_get_flags(msg);
od = purple_connection_get_protocol_data(gc);
--- a/libpurple/protocols/sametime/sametime.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/sametime/sametime.c Fri May 23 09:20:34 2014 +0200
@@ -3928,7 +3928,7 @@
g_return_val_if_fail(pd != NULL, 0);
- g_strlcpy(name, purple_message_get_who(msg), sizeof(name));
+ g_strlcpy(name, purple_message_get_recipient(msg), sizeof(name));
message = purple_message_get_contents(msg);
flags = purple_message_get_flags(msg);
--- a/libpurple/protocols/silc/silc.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/silc/silc.c Fri May 23 09:20:34 2014 +0200
@@ -1413,8 +1413,8 @@
silc_buffer_len(buf));
silc_mime_partial_free(list);
purple_conversation_write_message(PURPLE_CONVERSATION(convo),
- purple_message_new(conn->local_entry->nickname,
- im->message, PURPLE_MESSAGE_SEND));
+ purple_message_new_outgoing(
+ conn->local_entry->nickname, im->message, 0));
goto out;
}
}
@@ -1422,8 +1422,8 @@
/* Send the message */
silc_client_send_private_message(client, conn, client_entry, im->flags,
sg->sha1hash, (unsigned char *)im->message, im->message_len);
- purple_conversation_write_message(PURPLE_CONVERSATION(convo), purple_message_new(
- conn->local_entry->nickname, im->message, PURPLE_MESSAGE_SEND));
+ purple_conversation_write_message(PURPLE_CONVERSATION(convo),
+ purple_message_new_outgoing(conn->local_entry->nickname, im->message, 0));
goto out;
err:
@@ -1454,11 +1454,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 *rcpt = purple_message_get_recipient(pmsg);
const gchar *message = purple_message_get_contents(pmsg);
PurpleMessageFlags flags = purple_message_get_flags(pmsg);
- if (!who || purple_message_is_empty(pmsg))
+ if (!rcpt || purple_message_is_empty(pmsg))
return 0;
mflags = SILC_MESSAGE_FLAG_UTF8;
@@ -1486,7 +1486,7 @@
mflags |= SILC_MESSAGE_FLAG_SIGNED;
/* Find client entry */
- clients = silc_client_get_clients_local(client, conn, who, FALSE);
+ clients = silc_client_get_clients_local(client, conn, rcpt, FALSE);
if (!clients) {
/* Resolve unknown user */
SilcPurpleIM im = silc_calloc(1, sizeof(*im));
@@ -1494,12 +1494,12 @@
g_free(tmp);
return 0;
}
- im->nick = g_strdup(who);
+ im->nick = g_strdup(rcpt);
im->message = g_strdup(message);
im->message_len = strlen(im->message);
im->flags = mflags;
im->gflags = flags;
- silc_client_get_clients(client, conn, who, NULL,
+ silc_client_get_clients(client, conn, rcpt, NULL,
silcpurple_send_im_resolved, im);
g_free(tmp);
return 0;
@@ -1679,7 +1679,7 @@
return PURPLE_CMD_RET_FAILED;
ret = silcpurple_send_im(gc,
- purple_message_new(args[0], args[1], PURPLE_MESSAGE_SEND));
+ purple_message_new_outgoing(args[0], args[1], 0));
if (ret)
return PURPLE_CMD_RET_OK;
@@ -1710,13 +1710,11 @@
im = purple_im_conversation_new(account, args[0]);
if (args[1]) {
- PurpleMessage *msg = purple_message_new(args[0],
- args[1], PURPLE_MESSAGE_SEND);
+ PurpleMessage *msg = purple_message_new_outgoing(
+ args[0], args[1], 0);
ret = silcpurple_send_im(gc, msg);
- purple_conversation_write_message(PURPLE_CONVERSATION(im),
- purple_message_new(purple_connection_get_display_name(gc),
- args[1], PURPLE_MESSAGE_SEND));
+ purple_conversation_write_message(PURPLE_CONVERSATION(im), msg);
}
if (ret)
--- a/libpurple/protocols/simple/simple.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/simple/simple.c Fri May 23 09:20:34 2014 +0200
@@ -1032,7 +1032,7 @@
static int simple_im_send(PurpleConnection *gc, PurpleMessage *msg) {
struct simple_account_data *sip = purple_connection_get_protocol_data(gc);
- char *to = g_strdup(purple_message_get_who(msg));
+ char *to = g_strdup(purple_message_get_recipient(msg));
char *text = purple_unescape_html(purple_message_get_contents(msg));
simple_send_message(sip, to, text, NULL);
g_free(to);
--- a/libpurple/protocols/yahoo/libymsg.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/yahoo/libymsg.c Fri May 23 09:20:34 2014 +0200
@@ -4500,8 +4500,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, purple_message_new(sms_cb_data->who,
- sms_cb_data->what, PURPLE_MESSAGE_SEND));
+ yahoo_send_im(sms_cb_data->gc, purple_message_new_outgoing(
+ sms_cb_data->who, sms_cb_data->what, 0));
} else {
g_hash_table_insert(yd->sms_carrier,
g_strdup_printf("+%s", mobile_no), g_strdup("Unknown"));
@@ -4575,7 +4575,7 @@
glong lenc = 0;
struct yahoo_p2p_data *p2p_data;
YahooFederation fed = YAHOO_FEDERATION_NONE;
- const gchar *who = purple_message_get_who(pmsg);
+ const gchar *rcpt = purple_message_get_recipient(pmsg);
msg2 = yahoo_string_encode(gc, msg, TRUE);
@@ -4594,21 +4594,21 @@
}
}
- fed = yahoo_get_federation_from_name(who);
-
- if (who[0] == '+') {
+ fed = yahoo_get_federation_from_name(rcpt);
+
+ if (rcpt[0] == '+') {
/* we have an sms to be sent */
gchar *carrier = NULL;
const char *alias = NULL;
PurpleAccount *account = purple_connection_get_account(gc);
- PurpleIMConversation *im = purple_conversations_find_im_with_account(who, account);
-
- carrier = g_hash_table_lookup(yd->sms_carrier, who);
+ PurpleIMConversation *im = purple_conversations_find_im_with_account(rcpt, account);
+
+ carrier = g_hash_table_lookup(yd->sms_carrier, rcpt);
if (!carrier) {
struct yahoo_sms_carrier_cb_data *sms_cb_data;
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->who = g_strdup(rcpt);
sms_cb_data->what = g_strdup(purple_message_get_contents(pmsg));
purple_conversation_write_system_message(PURPLE_CONVERSATION(im),
@@ -4634,7 +4634,7 @@
yahoo_packet_hash(pkt, "sssss",
1, purple_connection_get_display_name(gc),
69, alias,
- 5, who + 1,
+ 5, rcpt + 1,
68, carrier,
14, msg2);
yahoo_packet_send_and_free(pkt, yd);
@@ -4646,7 +4646,7 @@
}
pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id);
- fed_who = who;
+ fed_who = rcpt;
switch (fed) {
case YAHOO_FEDERATION_MSN:
case YAHOO_FEDERATION_OCS:
@@ -4677,13 +4677,13 @@
*
* If they have not set an IMVironment, then use the default.
*/
- wb = purple_whiteboard_get_session(purple_connection_get_account(gc), who);
+ wb = purple_whiteboard_get_session(purple_connection_get_account(gc), rcpt);
if (wb)
yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY);
else
{
const char *imv;
- imv = g_hash_table_lookup(yd->imvironments, who);
+ imv = g_hash_table_lookup(yd->imvironments, rcpt);
if (imv != NULL)
yahoo_packet_hash_str(pkt, 63, imv);
else
@@ -4700,14 +4700,14 @@
/* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */
if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) {
/* if p2p link exists, send through it. To-do: key 15, time value to be sent in case of p2p */
- if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !fed) {
+ if( (p2p_data = g_hash_table_lookup(yd->peers, rcpt)) && !fed) {
yahoo_packet_hash_int(pkt, 11, p2p_data->session_id);
yahoo_p2p_write_pkt(p2p_data->source, pkt);
}
else {
yahoo_packet_send(pkt, yd);
if(!fed)
- yahoo_send_p2p_pkt(gc, who, 0); /* send p2p packet, with val_13=0 */
+ yahoo_send_p2p_pkt(gc, rcpt, 0); /* send p2p packet, with val_13=0 */
}
}
else
--- a/libpurple/protocols/zephyr/zephyr.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/protocols/zephyr/zephyr.c Fri May 23 09:20:34 2014 +0200
@@ -2090,7 +2090,7 @@
sig = zephyr_get_signature();
}
zephyr_send_message(zephyr, "MESSAGE", "PERSONAL",
- local_zephyr_normalize(zephyr, purple_message_get_who(msg)),
+ local_zephyr_normalize(zephyr, purple_message_get_recipient(msg)),
purple_message_get_contents(msg), sig, "");
return 1;
--- a/libpurple/server.c Fri May 23 00:11:01 2014 +0200
+++ b/libpurple/server.c Fri May 23 09:20:34 2014 +0200
@@ -125,7 +125,7 @@
PurplePluginProtocolInfo *prpl_info = NULL;
int val = -EINVAL;
const gchar *auto_reply_pref = NULL;
- const gchar *who;
+ const gchar *recipient;
g_return_val_if_fail(gc != NULL, val);
g_return_val_if_fail(msg != NULL, val);
@@ -138,9 +138,9 @@
account = purple_connection_get_account(gc);
presence = purple_account_get_presence(account);
- who = purple_message_get_who(msg);
+ recipient = purple_message_get_recipient(msg);
- im = purple_conversations_find_im_with_account(who, account);
+ im = purple_conversations_find_im_with_account(recipient, account);
if (prpl_info->send_im)
val = prpl_info->send_im(gc, msg);
@@ -155,7 +155,7 @@
!purple_strequal(auto_reply_pref, "never")) {
struct last_auto_response *lar;
- lar = get_last_auto_response(gc, who);
+ lar = get_last_auto_response(gc, recipient);
lar->sent = time(NULL);
}
@@ -600,9 +600,7 @@
if (im == NULL)
im = purple_im_conversation_new(account, name);
- pmsg = purple_message_new(name, message, flags);
- purple_message_set_time(pmsg, mtime);
-
+ pmsg = purple_message_new_incoming(name, message, flags, mtime);
purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
g_free(message);
@@ -672,8 +670,8 @@
{
PurpleMessage *msg;
- msg = purple_message_new(name, away_msg,
- PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP);
+ msg = purple_message_new_outgoing(name,
+ away_msg, PURPLE_MESSAGE_AUTO_RESP);
purple_serv_send_im(gc, msg);
purple_conversation_write_message(PURPLE_CONVERSATION(im), msg);
@@ -937,8 +935,7 @@
purple_signal_emit(purple_conversations_get_handle(), "received-chat-msg", purple_connection_get_account(g),
who, message, chat, flags);
- pmsg = purple_message_new(who, message, flags);
- purple_message_set_time(pmsg, mtime);
+ pmsg = purple_message_new_incoming(who, message, flags, mtime);
purple_conversation_write_message(PURPLE_CONVERSATION(chat), pmsg);
g_free(angel);
--- a/pidgin/gtkconv.c Fri May 23 00:11:01 2014 +0200
+++ b/pidgin/gtkconv.c Fri May 23 09:20:34 2014 +0200
@@ -6223,7 +6223,7 @@
return;
}
- purple_conversation_write(conv, purple_message_get_who(msg),
+ purple_conversation_write(conv, purple_message_get_author(msg),
purple_message_get_contents(msg), flags,
purple_message_get_time(msg));
}
--- a/pidgin/gtkpounce.c Fri May 23 00:11:01 2014 +0200
+++ b/pidgin/gtkpounce.c Fri May 23 09:20:34 2014 +0200
@@ -1487,7 +1487,7 @@
if (im == NULL)
im = purple_im_conversation_new(account, pouncee);
- pmsg = purple_message_new(pouncee, message, PURPLE_MESSAGE_SEND);
+ pmsg = purple_message_new_outgoing(pouncee, message, 0);
purple_serv_send_im(purple_account_get_connection(account), pmsg);
purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
}
--- a/pidgin/gtksound.c Fri May 23 00:11:01 2014 +0200
+++ b/pidgin/gtksound.c Fri May 23 09:20:34 2014 +0200
@@ -157,7 +157,7 @@
{
PurpleConversation *conv = PURPLE_CONVERSATION(
purple_conversations_find_im_with_account(
- purple_message_get_who(msg), account));
+ purple_message_get_recipient(msg), account));
play_conv_event(conv, event);
}
--- a/pidgin/plugins/musicmessaging/musicmessaging.c Fri May 23 00:11:01 2014 +0200
+++ b/pidgin/plugins/musicmessaging/musicmessaging.c Fri May 23 09:20:34 2014 +0200
@@ -489,16 +489,16 @@
{
PurpleConnection *connection = purple_conversation_get_connection(mmconv->conv);
const char *convName = purple_conversation_get_name(mmconv->conv);
- purple_serv_send_im(connection, purple_message_new(
- convName, MUSICMESSAGING_START_MSG, PURPLE_MESSAGE_SEND));
+ purple_serv_send_im(connection, purple_message_new_outgoing(
+ convName, MUSICMESSAGING_START_MSG, 0));
}
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, purple_message_new(
- convName, MUSICMESSAGING_CONFIRM_MSG, PURPLE_MESSAGE_SEND));
+ purple_serv_send_im(connection, purple_message_new_outgoing(
+ convName, MUSICMESSAGING_CONFIRM_MSG, 0));
}
--- a/pidgin/plugins/notify.c Fri May 23 00:11:01 2014 +0200
+++ b/pidgin/plugins/notify.c Fri May 23 09:20:34 2014 +0200
@@ -279,7 +279,7 @@
if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_send")) {
im = purple_conversations_find_im_with_account(
- purple_message_get_who(msg), account);
+ purple_message_get_recipient(msg), account);
unnotify(PURPLE_CONVERSATION(im), TRUE);
}
}