pidgin: 8bbb74e3: Fix a crash when there are offline messa...
sadrul at pidgin.im
sadrul at pidgin.im
Sat Jun 27 21:05:28 EDT 2009
-----------------------------------------------------------------
Revision: 8bbb74e38dc599f8e2c385755bb9047e97785a05
Ancestor: 955e420a0acad1f07022838ed6457894f600859a
Author: sadrul at pidgin.im
Date: 2009-06-28T01:03:07
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8bbb74e38dc599f8e2c385755bb9047e97785a05
Modified files:
libpurple/protocols/yahoo/yahoo.c
ChangeLog:
Fix a crash when there are offline messages from both MSN and Yahoo
buddies.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c dd072ea72ddf9b7a722357bde645d271f489d64e
+++ libpurple/protocols/yahoo/yahoo.c a806b35f039466b2534668cc242926c6a09b44ef
@@ -834,6 +834,7 @@ struct _yahoo_im {
int buddy_icon;
char *id;
char *msg;
+ gboolean msn;
};
static void yahoo_process_sms_message(PurpleConnection *gc, struct yahoo_packet *pkt)
@@ -907,8 +908,6 @@ static void yahoo_process_message(Purple
struct _yahoo_im *im = NULL;
const char *imv = NULL;
gint val_11 = 0;
- gboolean msn = FALSE;
- char *msn_from = NULL;
account = purple_connection_get_account(gc);
@@ -938,9 +937,9 @@ static void yahoo_process_message(Purple
if (im)
im->msg = pair->value;
}
- if (pair->key == 241) {
+ if (im && pair->key == 241) {
if(strtol(pair->value, NULL, 10) == 2)
- msn = TRUE;
+ im->msn = TRUE;
}
/* peer session id */
if (pair->key == 11) {
@@ -962,9 +961,6 @@ static void yahoo_process_message(Purple
_("Your Yahoo! message did not get sent."), NULL);
}
- if(msn)
- msn_from = g_strconcat("msn/", im->from, NULL);
-
/* disconnect the peer if connected through p2p and sends wrong value for session id */
if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) {
purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im->from);
@@ -1009,6 +1005,8 @@ static void yahoo_process_message(Purple
for (l = list; l; l = l->next) {
YahooFriend *f;
char *m, *m2;
+ char *msn_from = NULL;
+ const char *from;
PurpleConversation *c;
im = l->data;
@@ -1054,24 +1052,22 @@ static void yahoo_process_message(Purple
m = m2;
purple_util_chrreplace(m, '\r', '\n');
- c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, im->from, account);
- if ((c == NULL) && msn)
- c=purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, msn_from, account);
+ if (im->msn) {
+ msn_from = g_strconcat("msn/", im->from, NULL);
+ from = msn_from;
+ } else {
+ from = im->from;
+ }
+ c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, account);
+
if (!strcmp(m, "<ding>")) {
char *username;
- if(c == NULL) {
- if(msn)
- c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, msn_from);
- else
- c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, im->from);
+ if (c == NULL) {
+ c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, from);
}
- if(msn)
- username = g_markup_escape_text(msn_from, -1);
- else
- username = g_markup_escape_text(im->from, -1);
-
+ username = g_markup_escape_text(from, -1);
purple_prpl_got_attention(gc, username, YAHOO_BUZZ);
g_free(username);
g_free(m);
@@ -1083,15 +1079,11 @@ static void yahoo_process_message(Purple
m2 = yahoo_codes_to_html(m);
g_free(m);
- if(msn)
- serv_got_im(gc, msn_from, m2, 0, im->time);
- else
- serv_got_im(gc, im->from, m2, 0, im->time);
-
+ serv_got_im(gc, from, m2, 0, im->time);
g_free(m2);
/* laters : implement buddy icon for msn friends */
- if(!msn) {
+ if (!im->msn) {
if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) {
if (yahoo_friend_get_buddy_icon_need_request(f)) {
yahoo_send_picture_request(gc, im->from);
More information about the Commits
mailing list