Mercurial > pidgin
comparison libpurple/protocols/qq/qq_network.c @ 27381:f541583e31bd
More uniformity among disconnect error messages
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 06 Jul 2009 09:07:42 +0000 |
parents | 7da3cf2530b7 |
children | 73a30365c293 33921125348d |
comparison
equal
deleted
inserted
replaced
27380:1bbed9fd046b | 27381:f541583e31bd |
---|---|
206 | 206 |
207 if (qd->curr_server == NULL || strlen (qd->curr_server) == 0 || qd->connect_retry <= 0) { | 207 if (qd->curr_server == NULL || strlen (qd->curr_server) == 0 || qd->connect_retry <= 0) { |
208 if ( set_new_server(qd) != TRUE) { | 208 if ( set_new_server(qd) != TRUE) { |
209 purple_connection_error_reason(gc, | 209 purple_connection_error_reason(gc, |
210 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 210 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
211 _("Unable to connect.")); | 211 _("Unable to connect")); |
212 return FALSE; | 212 return FALSE; |
213 } | 213 } |
214 qd->connect_retry = QQ_CONNECT_MAX; | 214 qd->connect_retry = QQ_CONNECT_MAX; |
215 } | 215 } |
216 | 216 |
231 | 231 |
232 qd->connect_retry--; | 232 qd->connect_retry--; |
233 if ( !connect_to_server(gc, tmp_server, port) ) { | 233 if ( !connect_to_server(gc, tmp_server, port) ) { |
234 purple_connection_error_reason(gc, | 234 purple_connection_error_reason(gc, |
235 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 235 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
236 _("Unable to connect.")); | 236 _("Unable to connect")); |
237 } | 237 } |
238 | 238 |
239 g_free(tmp_server); | 239 g_free(tmp_server); |
240 tmp_server = NULL; | 240 tmp_server = NULL; |
241 | 241 |
387 if (buf_len < 0) { | 387 if (buf_len < 0) { |
388 if (errno == EAGAIN) | 388 if (errno == EAGAIN) |
389 /* No worries */ | 389 /* No worries */ |
390 return; | 390 return; |
391 | 391 |
392 error_msg = g_strdup_printf(_("Lost connection with server:\n%s"), g_strerror(errno)); | 392 error_msg = g_strdup_printf(_("Lost connection with server: %s"), g_strerror(errno)); |
393 purple_connection_error_reason(gc, | 393 purple_connection_error_reason(gc, |
394 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 394 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
395 error_msg); | 395 error_msg); |
396 g_free(error_msg); | 396 g_free(error_msg); |
397 return; | 397 return; |
398 } else if (buf_len == 0) { | 398 } else if (buf_len == 0) { |
399 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 399 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
400 _("Server closed the connection.")); | 400 _("Server closed the connection")); |
401 return; | 401 return; |
402 } | 402 } |
403 | 403 |
404 /* keep alive will be sent in 30 seconds since last_receive | 404 /* keep alive will be sent in 30 seconds since last_receive |
405 * QQ need a keep alive packet in every 60 seconds | 405 * QQ need a keep alive packet in every 60 seconds |
583 | 583 |
584 if (ret < 0 && errno == EAGAIN) | 584 if (ret < 0 && errno == EAGAIN) |
585 return; | 585 return; |
586 else if (ret < 0) { | 586 else if (ret < 0) { |
587 /* TODO: what to do here - do we really have to disconnect? */ | 587 /* TODO: what to do here - do we really have to disconnect? */ |
588 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), | |
589 g_strerror(errno)); | |
588 purple_connection_error_reason(gc, | 590 purple_connection_error_reason(gc, |
589 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 591 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
590 _("Write Error")); | 592 g_free(tmp); |
591 return; | 593 return; |
592 } | 594 } |
593 | 595 |
594 purple_circ_buffer_mark_read(conn->tcp_txbuf, ret); | 596 purple_circ_buffer_mark_read(conn->tcp_txbuf, ret); |
595 } | 597 } |
627 /* socket is busy, send later */ | 629 /* socket is busy, send later */ |
628 purple_debug_info("TCP_SEND_OUT", "Socket is busy and send later\n"); | 630 purple_debug_info("TCP_SEND_OUT", "Socket is busy and send later\n"); |
629 ret = 0; | 631 ret = 0; |
630 } else if (ret <= 0) { | 632 } else if (ret <= 0) { |
631 /* TODO: what to do here - do we really have to disconnect? */ | 633 /* TODO: what to do here - do we really have to disconnect? */ |
634 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), | |
635 g_strerror(errno)); | |
632 purple_debug_error("TCP_SEND_OUT", | 636 purple_debug_error("TCP_SEND_OUT", |
633 "Send to socket %d failed: %d, %s\n", qd->fd, errno, g_strerror(errno)); | 637 "Send to socket %d failed: %d, %s\n", qd->fd, errno, g_strerror(errno)); |
634 purple_connection_error_reason(gc, | 638 purple_connection_error_reason(gc, |
635 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 639 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
636 g_strerror(errno)); | 640 g_free(tmp); |
637 return ret; | 641 return ret; |
638 } | 642 } |
639 | 643 |
640 if (ret < data_len) { | 644 if (ret < data_len) { |
641 purple_debug_info("TCP_SEND_OUT", "Add %d bytes to buffer\n", data_len - ret); | 645 purple_debug_info("TCP_SEND_OUT", "Add %d bytes to buffer\n", data_len - ret); |
661 | 665 |
662 is_lost_conn = qq_trans_scan(gc); | 666 is_lost_conn = qq_trans_scan(gc); |
663 if (is_lost_conn) { | 667 if (is_lost_conn) { |
664 purple_connection_error_reason(gc, | 668 purple_connection_error_reason(gc, |
665 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 669 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
666 _("Connection lost")); | 670 _("Lost connection with server")); |
667 return TRUE; | 671 return TRUE; |
668 } | 672 } |
669 | 673 |
670 if ( !qd->is_login ) { | 674 if ( !qd->is_login ) { |
671 return TRUE; | 675 return TRUE; |
862 qd->udp_query_data = NULL; | 866 qd->udp_query_data = NULL; |
863 | 867 |
864 if (!hosts || !hosts->data) { | 868 if (!hosts || !hosts->data) { |
865 purple_connection_error_reason(gc, | 869 purple_connection_error_reason(gc, |
866 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 870 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
867 _("Couldn't resolve host")); | 871 _("Unable to resolve hostname")); |
868 return; | 872 return; |
869 } | 873 } |
870 | 874 |
871 addr_size = GPOINTER_TO_INT(hosts->data); | 875 addr_size = GPOINTER_TO_INT(hosts->data); |
872 hosts = g_slist_remove(hosts, hosts->data); | 876 hosts = g_slist_remove(hosts, hosts->data); |
939 | 943 |
940 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, FALSE); | 944 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, FALSE); |
941 account = purple_connection_get_account(gc); | 945 account = purple_connection_get_account(gc); |
942 qd = (qq_data *) gc->proto_data; | 946 qd = (qq_data *) gc->proto_data; |
943 | 947 |
944 if (server == NULL || strlen(server) == 0 || port == 0) { | 948 if (server == NULL || server[0] == '\0' || port == 0) { |
945 purple_connection_error_reason(gc, | 949 purple_connection_error_reason(gc, |
946 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 950 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
947 _("Invalid server or port")); | 951 _("Invalid server or port")); |
948 return FALSE; | 952 return FALSE; |
949 } | 953 } |