libpurple/protocols/irc/parse.c

branch
cpw.resiak.disconnectreason
changeset 20440
42e5e5445a2f
parent 19859
71d37b57eff2
child 20855
d263076a39f8
equal deleted inserted replaced
20439:63ea8fe29f17 20440:42e5e5445a2f
555 void irc_parse_msg(struct irc_conn *irc, char *input) 555 void irc_parse_msg(struct irc_conn *irc, char *input)
556 { 556 {
557 struct _irc_msg *msgent; 557 struct _irc_msg *msgent;
558 char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg; 558 char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg;
559 guint i; 559 guint i;
560 PurpleConnection *gc = purple_account_get_connection(irc->account);
560 561
561 irc->recv_time = time(NULL); 562 irc->recv_time = time(NULL);
562 563
563 /* 564 /*
564 * The data passed to irc-receiving-text is the raw protocol data. 565 * The data passed to irc-receiving-text is the raw protocol data.
565 * TODO: It should be passed as an array of bytes and a length 566 * TODO: It should be passed as an array of bytes and a length
566 * instead of a null terminated string. 567 * instead of a null terminated string.
567 */ 568 */
568 purple_signal_emit(_irc_plugin, "irc-receiving-text", purple_account_get_connection(irc->account), &input); 569 purple_signal_emit(_irc_plugin, "irc-receiving-text", gc, &input);
569 570
570 if (!strncmp(input, "PING ", 5)) { 571 if (!strncmp(input, "PING ", 5)) {
571 msg = irc_format(irc, "vv", "PONG", input + 5); 572 msg = irc_format(irc, "vv", "PONG", input + 5);
572 irc_send(irc, msg); 573 irc_send(irc, msg);
573 g_free(msg); 574 g_free(msg);
574 return; 575 return;
575 } else if (!strncmp(input, "ERROR ", 6)) { 576 } else if (!strncmp(input, "ERROR ", 6)) {
576 if (g_utf8_validate(input, -1, NULL)) { 577 if (g_utf8_validate(input, -1, NULL)) {
577 char *tmp = g_strdup_printf("%s\n%s", _("Disconnected."), input); 578 char *tmp = g_strdup_printf("%s\n%s", _("Disconnected."), input);
578 purple_connection_error(purple_account_get_connection(irc->account), tmp); 579 purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR, tmp);
579 g_free(tmp); 580 g_free(tmp);
580 } else 581 } else
581 purple_connection_error(purple_account_get_connection(irc->account), _("Disconnected.")); 582 purple_connection_error_reason (gc,
583 PURPLE_REASON_OTHER_ERROR, _("Disconnected."));
582 return; 584 return;
583 } 585 }
584 586
585 if (input[0] != ':' || (cur = strchr(input, ' ')) == NULL) { 587 if (input[0] != ':' || (cur = strchr(input, ' ')) == NULL) {
586 irc_parse_error_cb(irc, input); 588 irc_parse_error_cb(irc, input);

mercurial