Mercurial > pidgin
comparison src/protocols/msn/notification.c @ 8646:1e211dde3cae
[gaim-migrate @ 9398]
Added a patch by shx to clean up the message-handling code and split the
command stuff from it, among a few other things. Also, I fixed a crash in
message parsing, which I think may close a couple bug reports.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 13 Apr 2004 04:08:22 +0000 |
parents | 563d47350c7e |
children | 5747e3fac25a |
comparison
equal
deleted
inserted
replaced
8645:47f647dd2ac3 | 8646:1e211dde3cae |
---|---|
197 static gboolean | 197 static gboolean |
198 unknown_cmd(MsnServConn *servconn, const char *command, const char **params, | 198 unknown_cmd(MsnServConn *servconn, const char *command, const char **params, |
199 size_t param_count) | 199 size_t param_count) |
200 { | 200 { |
201 int errnum = 0; | 201 int errnum = 0; |
202 | 202 |
203 if (isdigit(*command)) { | 203 if (isdigit(*command)) { |
204 errnum = atoi(command); | 204 errnum = atoi(command); |
205 | 205 |
206 if (errnum == 225) { | 206 if (errnum == 225) { |
207 /* | 207 /* |
210 * The user doesn't care if the old group was there or not. | 210 * The user doesn't care if the old group was there or not. |
211 */ | 211 */ |
212 return TRUE; | 212 return TRUE; |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 msn_error_handle(servconn->session, errnum); | 216 msn_error_handle(servconn->session, errnum); |
217 | 217 |
218 return TRUE; | 218 return TRUE; |
219 } | 219 } |
220 | 220 |
449 } | 449 } |
450 | 450 |
451 /************************************************************************** | 451 /************************************************************************** |
452 * Messages | 452 * Messages |
453 **************************************************************************/ | 453 **************************************************************************/ |
454 static void | |
455 msg_cmd_post(MsnServConn *servconn, char *payload, size_t len) | |
456 { | |
457 MsnMessage *msg = msn_message_new(); | |
458 | |
459 msg->passport = servconn->msg_passport; | |
460 | |
461 msn_message_parse_payload(msg, payload, len); | |
462 | |
463 msn_servconn_process_message(servconn, msg); | |
464 | |
465 msn_message_destroy(msg); | |
466 } | |
467 | |
454 static gboolean | 468 static gboolean |
455 msg_cmd(MsnServConn *servconn, const char *command, const char **params, | 469 msg_cmd(MsnServConn *servconn, const char *command, const char **params, |
456 size_t param_count) | 470 size_t param_count) |
457 { | 471 { |
458 gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n"); | 472 gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n"); |
459 | 473 |
460 servconn->parsing_multiline = TRUE; | 474 servconn->payload_cb = msg_cmd_post; |
461 servconn->multiline_type = MSN_MULTILINE_MSG; | 475 servconn->payload_len = atoi(params[2]); |
462 servconn->multiline_len = atoi(params[2]); | |
463 | 476 |
464 servconn->msg_passport = g_strdup(params[0]); | 477 servconn->msg_passport = g_strdup(params[0]); |
465 servconn->msg_friendly = g_strdup(params[1]); | |
466 | 478 |
467 return TRUE; | 479 return TRUE; |
468 } | 480 } |
469 | 481 |
470 /************************************************************************** | 482 /************************************************************************** |
744 | 756 |
745 static gboolean | 757 static gboolean |
746 ipg_cmd(MsnServConn *servconn, const char *command, const char **params, | 758 ipg_cmd(MsnServConn *servconn, const char *command, const char **params, |
747 size_t param_count) | 759 size_t param_count) |
748 { | 760 { |
749 /* GaimConnection *gc = servconn->session->account->gc; */ | 761 servconn->payload_cb = NULL; |
750 | 762 servconn->payload_len = atoi(params[2]); |
751 servconn->parsing_multiline = TRUE; | |
752 servconn->multiline_type = MSN_MULTILINE_IPG; | |
753 servconn->multiline_len = atoi(params[0]); | |
754 | |
755 servconn->msg_passport = NULL; | |
756 servconn->msg_friendly = NULL; | |
757 | 763 |
758 return TRUE; | 764 return TRUE; |
759 } | 765 } |
760 | 766 |
761 static gboolean | 767 static gboolean |
1165 | 1171 |
1166 static gboolean | 1172 static gboolean |
1167 not_cmd(MsnServConn *servconn, const char *command, const char **params, | 1173 not_cmd(MsnServConn *servconn, const char *command, const char **params, |
1168 size_t param_count) | 1174 size_t param_count) |
1169 { | 1175 { |
1170 /* GaimConnection *gc = servconn->session->account->gc; */ | 1176 servconn->payload_cb = NULL; |
1171 | 1177 servconn->payload_len = atoi(params[2]); |
1172 servconn->parsing_multiline = TRUE; | |
1173 servconn->multiline_type = MSN_MULTILINE_NOT; | |
1174 servconn->multiline_len = atoi(params[0]); | |
1175 | |
1176 servconn->msg_passport = NULL; | |
1177 servconn->msg_friendly = NULL; | |
1178 | 1178 |
1179 return TRUE; | 1179 return TRUE; |
1180 } | 1180 } |
1181 | 1181 |
1182 static gboolean | 1182 static gboolean |
1602 else if (!strcmp(params[1], "NS")) { | 1602 else if (!strcmp(params[1], "NS")) { |
1603 if (!msn_notification_connect(session->notification_conn, host, | 1603 if (!msn_notification_connect(session->notification_conn, host, |
1604 port)) | 1604 port)) |
1605 { | 1605 { |
1606 gaim_connection_error(gc, _("Unable to transfer to " | 1606 gaim_connection_error(gc, _("Unable to transfer to " |
1607 "notification server")); | 1607 "notification server")); |
1608 | |
1609 g_free(host); | |
1608 | 1610 |
1609 return FALSE; | 1611 return FALSE; |
1610 } | 1612 } |
1611 } | 1613 } |
1612 | 1614 |
1622 profile_msg(MsnServConn *servconn, MsnMessage *msg) | 1624 profile_msg(MsnServConn *servconn, MsnMessage *msg) |
1623 { | 1625 { |
1624 MsnSession *session = servconn->session; | 1626 MsnSession *session = servconn->session; |
1625 const char *value; | 1627 const char *value; |
1626 | 1628 |
1627 if (strcmp(servconn->msg_passport, "Hotmail")) { | 1629 if (strcmp(msg->passport, "Hotmail")) { |
1628 /* This isn't an official message. */ | 1630 /* This isn't an official message. */ |
1629 return TRUE; | 1631 return TRUE; |
1630 } | 1632 } |
1631 | 1633 |
1632 if ((value = msn_message_get_attr(msg, "kv")) != NULL) | 1634 if ((value = msn_message_get_attr(msg, "kv")) != NULL) |
1653 MsnSession *session = servconn->session; | 1655 MsnSession *session = servconn->session; |
1654 GaimConnection *gc = session->account->gc; | 1656 GaimConnection *gc = session->account->gc; |
1655 GHashTable *table; | 1657 GHashTable *table; |
1656 const char *unread; | 1658 const char *unread; |
1657 | 1659 |
1658 if (strcmp(servconn->msg_passport, "Hotmail")) { | 1660 if (strcmp(msg->passport, "Hotmail")) { |
1659 /* This isn't an official message. */ | 1661 /* This isn't an official message. */ |
1660 return TRUE; | 1662 return TRUE; |
1661 } | 1663 } |
1662 | 1664 |
1663 if (!gaim_account_get_check_mail(session->account)) | 1665 if (!gaim_account_get_check_mail(session->account)) |
1703 MsnSession *session = servconn->session; | 1705 MsnSession *session = servconn->session; |
1704 GaimConnection *gc = session->account->gc; | 1706 GaimConnection *gc = session->account->gc; |
1705 GHashTable *table; | 1707 GHashTable *table; |
1706 char *from, *subject; | 1708 char *from, *subject; |
1707 | 1709 |
1708 if (strcmp(servconn->msg_passport, "Hotmail")) { | 1710 if (strcmp(msg->passport, "Hotmail")) { |
1709 /* This isn't an official message. */ | 1711 /* This isn't an official message. */ |
1710 return TRUE; | 1712 return TRUE; |
1711 } | 1713 } |
1712 | 1714 |
1713 if (!gaim_account_get_check_mail(session->account)) | 1715 if (!gaim_account_get_check_mail(session->account)) |
1741 system_msg(MsnServConn *servconn, MsnMessage *msg) | 1743 system_msg(MsnServConn *servconn, MsnMessage *msg) |
1742 { | 1744 { |
1743 GHashTable *table; | 1745 GHashTable *table; |
1744 const char *type_s; | 1746 const char *type_s; |
1745 | 1747 |
1746 if (strcmp(servconn->msg_passport, "Hotmail")) { | 1748 if (strcmp(msg->passport, "Hotmail")) { |
1747 /* This isn't an official message. */ | 1749 /* This isn't an official message. */ |
1748 return TRUE; | 1750 return TRUE; |
1749 } | 1751 } |
1750 | 1752 |
1751 table = msn_message_get_hashtable_from_body(msg); | 1753 table = msn_message_get_hashtable_from_body(msg); |