comparison libpurple/protocols/jabber/jabber.c @ 32330:a5b556ac1de5

Rename purple_connection_error_reason to purple_connection_error
author Mark Doliner <mark@kingant.net>
date Sun, 21 Aug 2011 08:00:53 +0000
parents ac43f26c7f61
children dc3ea8f6381a
comparison
equal deleted inserted replaced
32329:5105d0306b2a 32330:a5b556ac1de5
117 if (type == JABBER_IQ_RESULT) { 117 if (type == JABBER_IQ_RESULT) {
118 jabber_disco_items_server(js); 118 jabber_disco_items_server(js);
119 if(js->unregistration) 119 if(js->unregistration)
120 jabber_unregister_account_cb(js); 120 jabber_unregister_account_cb(js);
121 } else { 121 } else {
122 purple_connection_error_reason(js->gc, 122 purple_connection_error(js->gc,
123 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 123 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
124 ("Error initializing session")); 124 ("Error initializing session"));
125 } 125 }
126 } 126 }
127 127
151 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { 151 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
152 jabber_id_free(js->user); 152 jabber_id_free(js->user);
153 153
154 js->user = jabber_id_new(full_jid); 154 js->user = jabber_id_new(full_jid);
155 if (js->user == NULL) { 155 if (js->user == NULL) {
156 purple_connection_error_reason(js->gc, 156 purple_connection_error(js->gc,
157 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 157 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
158 _("Invalid response from server")); 158 _("Invalid response from server"));
159 g_free(full_jid); 159 g_free(full_jid);
160 return; 160 return;
161 } 161 }
168 g_free(full_jid); 168 g_free(full_jid);
169 } 169 }
170 } else { 170 } else {
171 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 171 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
172 char *msg = jabber_parse_error(js, packet, &reason); 172 char *msg = jabber_parse_error(js, packet, &reason);
173 purple_connection_error_reason(js->gc, reason, msg); 173 purple_connection_error(js->gc, reason, msg);
174 g_free(msg); 174 g_free(msg);
175 175
176 return; 176 return;
177 } 177 }
178 178
245 } 245 }
246 #endif 246 #endif
247 247
248 starttls = xmlnode_get_child(packet, "starttls"); 248 starttls = xmlnode_get_child(packet, "starttls");
249 if(xmlnode_get_child(starttls, "required")) { 249 if(xmlnode_get_child(starttls, "required")) {
250 purple_connection_error_reason(js->gc, 250 purple_connection_error(js->gc,
251 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 251 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
252 _("Server requires TLS/SSL, but no TLS/SSL support was found.")); 252 _("Server requires TLS/SSL, but no TLS/SSL support was found."));
253 return TRUE; 253 return TRUE;
254 } 254 }
255 255
256 if (g_str_equal("require_tls", purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) { 256 if (g_str_equal("require_tls", purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
257 purple_connection_error_reason(js->gc, 257 purple_connection_error(js->gc,
258 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 258 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
259 _("You require encryption, but no TLS/SSL support was found.")); 259 _("You require encryption, but no TLS/SSL support was found."));
260 return TRUE; 260 return TRUE;
261 } 261 }
262 262
273 if (jabber_process_starttls(js, packet)) { 273 if (jabber_process_starttls(js, packet)) {
274 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION); 274 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
275 return; 275 return;
276 } 276 }
277 } else if (g_str_equal(connection_security, "require_tls") && !jabber_stream_is_ssl(js)) { 277 } else if (g_str_equal(connection_security, "require_tls") && !jabber_stream_is_ssl(js)) {
278 purple_connection_error_reason(js->gc, 278 purple_connection_error(js->gc,
279 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, 279 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
280 _("You require encryption, but it is not available on this server.")); 280 _("You require encryption, but it is not available on this server."));
281 return; 281 return;
282 } 282 }
283 283
318 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) 318 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
319 { 319 {
320 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 320 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
321 char *msg = jabber_parse_error(js, packet, &reason); 321 char *msg = jabber_parse_error(js, packet, &reason);
322 322
323 purple_connection_error_reason(js->gc, reason, msg); 323 purple_connection_error(js->gc, reason, msg);
324 324
325 g_free(msg); 325 g_free(msg);
326 } 326 }
327 327
328 static void tls_init(JabberStream *js); 328 static void tls_init(JabberStream *js);
405 if (ret < 0 && errno == EAGAIN) 405 if (ret < 0 && errno == EAGAIN)
406 return; 406 return;
407 else if (ret <= 0) { 407 else if (ret <= 0) {
408 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), 408 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
409 g_strerror(errno)); 409 g_strerror(errno));
410 purple_connection_error_reason(js->gc, 410 purple_connection_error(js->gc,
411 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 411 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
412 g_free(tmp); 412 g_free(tmp);
413 return; 413 return;
414 } 414 }
415 415
441 * (for some UIs) would mask the first. 441 * (for some UIs) would mask the first.
442 */ 442 */
443 if (!account->disconnecting) { 443 if (!account->disconnecting) {
444 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), 444 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
445 g_strerror(errno)); 445 g_strerror(errno));
446 purple_connection_error_reason(js->gc, 446 purple_connection_error(js->gc,
447 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 447 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
448 g_free(tmp); 448 g_free(tmp);
449 } 449 }
450 450
451 success = FALSE; 451 success = FALSE;
542 g_strdup_printf(_("SASL error: %s"), 542 g_strdup_printf(_("SASL error: %s"),
543 sasl_errdetail(js->sasl)); 543 sasl_errdetail(js->sasl));
544 purple_debug_error("jabber", 544 purple_debug_error("jabber",
545 "sasl_encode error %d: %s\n", rc, 545 "sasl_encode error %d: %s\n", rc,
546 sasl_errdetail(js->sasl)); 546 sasl_errdetail(js->sasl));
547 purple_connection_error_reason(gc, 547 purple_connection_error(gc,
548 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 548 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
549 error); 549 error);
550 g_free(error); 550 g_free(error);
551 return; 551 return;
552 } 552 }
615 } 615 }
616 616
617 static gboolean jabber_keepalive_timeout(PurpleConnection *gc) 617 static gboolean jabber_keepalive_timeout(PurpleConnection *gc)
618 { 618 {
619 JabberStream *js = gc->proto_data; 619 JabberStream *js = gc->proto_data;
620 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 620 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
621 _("Ping timed out")); 621 _("Ping timed out"));
622 js->keepalive_timeout = 0; 622 js->keepalive_timeout = 0;
623 return FALSE; 623 return FALSE;
624 } 624 }
625 625
668 if (len == 0) 668 if (len == 0)
669 tmp = g_strdup_printf(_("Server closed the connection")); 669 tmp = g_strdup_printf(_("Server closed the connection"));
670 else 670 else
671 tmp = g_strdup_printf(_("Lost connection with server: %s"), 671 tmp = g_strdup_printf(_("Lost connection with server: %s"),
672 g_strerror(errno)); 672 g_strerror(errno));
673 purple_connection_error_reason(js->gc, 673 purple_connection_error(js->gc,
674 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 674 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
675 g_free(tmp); 675 g_free(tmp);
676 } 676 }
677 } 677 }
678 678
700 g_strdup_printf(_("SASL error: %s"), 700 g_strdup_printf(_("SASL error: %s"),
701 sasl_errdetail(js->sasl)); 701 sasl_errdetail(js->sasl));
702 purple_debug_error("jabber", 702 purple_debug_error("jabber",
703 "sasl_decode_error %d: %s\n", rc, 703 "sasl_decode_error %d: %s\n", rc,
704 sasl_errdetail(js->sasl)); 704 sasl_errdetail(js->sasl));
705 purple_connection_error_reason(gc, 705 purple_connection_error(gc,
706 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 706 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
707 error); 707 error);
708 } else if (olen > 0) { 708 } else if (olen > 0) {
709 purple_debug_info("jabber", "RecvSASL (%u): %s\n", olen, out); 709 purple_debug_info("jabber", "RecvSASL (%u): %s\n", olen, out);
710 jabber_parser_process(js, out, olen); 710 jabber_parser_process(js, out, olen);
726 if (len == 0) 726 if (len == 0)
727 tmp = g_strdup_printf(_("Server closed the connection")); 727 tmp = g_strdup_printf(_("Server closed the connection"));
728 else 728 else
729 tmp = g_strdup_printf(_("Lost connection with server: %s"), 729 tmp = g_strdup_printf(_("Lost connection with server: %s"),
730 g_strerror(errno)); 730 g_strerror(errno));
731 purple_connection_error_reason(js->gc, 731 purple_connection_error(js->gc,
732 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); 732 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
733 g_free(tmp); 733 g_free(tmp);
734 } 734 }
735 } 735 }
736 736
787 } 787 }
788 788
789 if (!found) { 789 if (!found) {
790 purple_debug_warning("jabber", "Unable to find alternative XMPP connection " 790 purple_debug_warning("jabber", "Unable to find alternative XMPP connection "
791 "methods after failing to connect directly.\n"); 791 "methods after failing to connect directly.\n");
792 purple_connection_error_reason(js->gc, 792 purple_connection_error(js->gc,
793 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 793 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
794 _("Unable to connect")); 794 _("Unable to connect"));
795 return; 795 return;
796 } 796 }
797 797
872 js->serverFQDN = g_strdup(host); 872 js->serverFQDN = g_strdup(host);
873 873
874 if (purple_proxy_connect(js->gc, purple_connection_get_account(js->gc), 874 if (purple_proxy_connect(js->gc, purple_connection_get_account(js->gc),
875 host, port, jabber_login_callback, js->gc) == NULL) { 875 host, port, jabber_login_callback, js->gc) == NULL) {
876 if (fatal_failure) { 876 if (fatal_failure) {
877 purple_connection_error_reason(js->gc, 877 purple_connection_error(js->gc,
878 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 878 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
879 _("Unable to connect")); 879 _("Unable to connect"));
880 } 880 }
881 881
882 return FALSE; 882 return FALSE;
938 if (slash && *(slash + 1) == '\0') 938 if (slash && *(slash + 1) == '\0')
939 *slash = '\0'; 939 *slash = '\0';
940 js->user = jabber_id_new(user); 940 js->user = jabber_id_new(user);
941 941
942 if (!js->user) { 942 if (!js->user) {
943 purple_connection_error_reason(gc, 943 purple_connection_error(gc,
944 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 944 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
945 _("Invalid XMPP ID")); 945 _("Invalid XMPP ID"));
946 g_free(user); 946 g_free(user);
947 /* Destroying the connection will free the JabberStream */ 947 /* Destroying the connection will free the JabberStream */
948 return NULL; 948 return NULL;
949 } 949 }
950 950
951 if (!js->user->node || *(js->user->node) == '\0') { 951 if (!js->user->node || *(js->user->node) == '\0') {
952 purple_connection_error_reason(gc, 952 purple_connection_error(gc,
953 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 953 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
954 _("Invalid XMPP ID. Username portion must be set.")); 954 _("Invalid XMPP ID. Username portion must be set."));
955 g_free(user); 955 g_free(user);
956 /* Destroying the connection will free the JabberStream */ 956 /* Destroying the connection will free the JabberStream */
957 return NULL; 957 return NULL;
958 } 958 }
959 959
960 if (!js->user->domain || *(js->user->domain) == '\0') { 960 if (!js->user->domain || *(js->user->domain) == '\0') {
961 purple_connection_error_reason(gc, 961 purple_connection_error(gc,
962 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 962 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
963 _("Invalid XMPP ID. Domain must be set.")); 963 _("Invalid XMPP ID. Domain must be set."));
964 g_free(user); 964 g_free(user);
965 /* Destroying the connection will free the JabberStream */ 965 /* Destroying the connection will free the JabberStream */
966 return NULL; 966 return NULL;
976 976
977 js->user_jb = jabber_buddy_find(js, user, TRUE); 977 js->user_jb = jabber_buddy_find(js, user, TRUE);
978 g_free(user); 978 g_free(user);
979 if (!js->user_jb) { 979 if (!js->user_jb) {
980 /* This basically *can't* fail, but for good measure... */ 980 /* This basically *can't* fail, but for good measure... */
981 purple_connection_error_reason(gc, 981 purple_connection_error(gc,
982 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 982 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
983 _("Invalid XMPP ID")); 983 _("Invalid XMPP ID"));
984 /* Destroying the connection will free the JabberStream */ 984 /* Destroying the connection will free the JabberStream */
985 g_return_val_if_reached(NULL); 985 g_return_val_if_reached(NULL);
986 } 986 }
1035 if (*bosh_url) { 1035 if (*bosh_url) {
1036 js->bosh = jabber_bosh_connection_init(js, bosh_url); 1036 js->bosh = jabber_bosh_connection_init(js, bosh_url);
1037 if (js->bosh) 1037 if (js->bosh)
1038 jabber_bosh_connection_connect(js->bosh); 1038 jabber_bosh_connection_connect(js->bosh);
1039 else { 1039 else {
1040 purple_connection_error_reason(gc, 1040 purple_connection_error(gc,
1041 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, 1041 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
1042 _("Malformed BOSH URL")); 1042 _("Malformed BOSH URL"));
1043 } 1043 }
1044 1044
1045 return; 1045 return;
1052 if(purple_ssl_is_supported()) { 1052 if(purple_ssl_is_supported()) {
1053 js->gsc = purple_ssl_connect(account, js->certificate_CN, 1053 js->gsc = purple_ssl_connect(account, js->certificate_CN,
1054 purple_account_get_int(account, "port", 5223), 1054 purple_account_get_int(account, "port", 5223),
1055 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); 1055 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
1056 if (!js->gsc) { 1056 if (!js->gsc) {
1057 purple_connection_error_reason(gc, 1057 purple_connection_error(gc,
1058 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 1058 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
1059 _("Unable to establish SSL connection")); 1059 _("Unable to establish SSL connection"));
1060 } 1060 }
1061 } else { 1061 } else {
1062 purple_connection_error_reason(gc, 1062 purple_connection_error(gc,
1063 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, 1063 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
1064 _("SSL support unavailable")); 1064 _("SSL support unavailable"));
1065 } 1065 }
1066 1066
1067 return; 1067 return;