comparison libpurple/protocols/irc/irc.c @ 21358:ba41f2a60253

Rename: * PurpleDisconnectReason to PurpleConnectionError; * elements of that enum from PURPLE_REASON_* to PURPLE_CONNECTION_ERROR_*; * purple_connection_reason_is_fatal to purple_connection_error_is_fatal.
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 14 Oct 2007 21:08:42 +0000
parents efa448405f3d
children 38cc722159ff
comparison
equal deleted inserted replaced
21357:5a3242b676ad 21358:ba41f2a60253
122 122
123 if (ret < 0 && errno == EAGAIN) 123 if (ret < 0 && errno == EAGAIN)
124 return; 124 return;
125 else if (ret <= 0) { 125 else if (ret <= 0) {
126 PurpleConnection *gc = purple_account_get_connection(irc->account); 126 PurpleConnection *gc = purple_account_get_connection(irc->account);
127 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 127 purple_connection_error_reason (gc,
128 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
128 _("Server has disconnected")); 129 _("Server has disconnected"));
129 return; 130 return;
130 } 131 }
131 132
132 purple_circ_buffer_mark_read(irc->outbuf, ret); 133 purple_circ_buffer_mark_read(irc->outbuf, ret);
161 162
162 /* purple_debug(PURPLE_DEBUG_MISC, "irc", "sent%s: %s", 163 /* purple_debug(PURPLE_DEBUG_MISC, "irc", "sent%s: %s",
163 irc->gsc ? " (ssl)" : "", tosend); */ 164 irc->gsc ? " (ssl)" : "", tosend); */
164 if (ret <= 0 && errno != EAGAIN) { 165 if (ret <= 0 && errno != EAGAIN) {
165 PurpleConnection *gc = purple_account_get_connection(irc->account); 166 PurpleConnection *gc = purple_account_get_connection(irc->account);
166 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 167 purple_connection_error_reason (gc,
168 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
167 _("Server has disconnected")); 169 _("Server has disconnected"));
168 } else if (ret < buflen) { 170 } else if (ret < buflen) {
169 if (ret < 0) 171 if (ret < 0)
170 ret = 0; 172 ret = 0;
171 if (!irc->writeh) 173 if (!irc->writeh)
295 297
296 gc = purple_account_get_connection(account); 298 gc = purple_account_get_connection(account);
297 gc->flags |= PURPLE_CONNECTION_NO_NEWLINES; 299 gc->flags |= PURPLE_CONNECTION_NO_NEWLINES;
298 300
299 if (strpbrk(username, " \t\v\r\n") != NULL) { 301 if (strpbrk(username, " \t\v\r\n") != NULL) {
300 purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS, 302 purple_connection_error_reason (gc,
303 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
301 _("IRC nicks may not contain whitespace")); 304 _("IRC nicks may not contain whitespace"));
302 return; 305 return;
303 } 306 }
304 307
305 gc->proto_data = irc = g_new0(struct irc_conn, 1); 308 gc->proto_data = irc = g_new0(struct irc_conn, 1);
325 if (purple_ssl_is_supported()) { 328 if (purple_ssl_is_supported()) {
326 irc->gsc = purple_ssl_connect(account, irc->server, 329 irc->gsc = purple_ssl_connect(account, irc->server,
327 purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), 330 purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
328 irc_login_cb_ssl, irc_ssl_connect_failure, gc); 331 irc_login_cb_ssl, irc_ssl_connect_failure, gc);
329 } else { 332 } else {
330 purple_connection_error_reason (gc, PURPLE_REASON_NO_SSL_SUPPORT, 333 purple_connection_error_reason (gc,
334 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
331 _("SSL support unavailable")); 335 _("SSL support unavailable"));
332 return; 336 return;
333 } 337 }
334 } 338 }
335 339
337 341
338 if (purple_proxy_connect(gc, account, irc->server, 342 if (purple_proxy_connect(gc, account, irc->server,
339 purple_account_get_int(account, "port", IRC_DEFAULT_PORT), 343 purple_account_get_int(account, "port", IRC_DEFAULT_PORT),
340 irc_login_cb, gc) == NULL) 344 irc_login_cb, gc) == NULL)
341 { 345 {
342 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 346 purple_connection_error_reason (gc,
347 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
343 _("Couldn't create socket")); 348 _("Couldn't create socket"));
344 return; 349 return;
345 } 350 }
346 } 351 }
347 } 352 }
418 { 423 {
419 PurpleConnection *gc = data; 424 PurpleConnection *gc = data;
420 struct irc_conn *irc = gc->proto_data; 425 struct irc_conn *irc = gc->proto_data;
421 426
422 if (source < 0) { 427 if (source < 0) {
423 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 428 purple_connection_error_reason (gc,
429 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
424 _("Couldn't connect to host")); 430 _("Couldn't connect to host"));
425 return; 431 return;
426 } 432 }
427 433
428 irc->fd = source; 434 irc->fd = source;
607 613
608 if (len < 0 && errno == EAGAIN) { 614 if (len < 0 && errno == EAGAIN) {
609 /* Try again later */ 615 /* Try again later */
610 return; 616 return;
611 } else if (len < 0) { 617 } else if (len < 0) {
612 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 618 purple_connection_error_reason (gc,
619 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
613 _("Read error")); 620 _("Read error"));
614 return; 621 return;
615 } else if (len == 0) { 622 } else if (len == 0) {
616 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 623 purple_connection_error_reason (gc,
624 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
617 _("Server has disconnected")); 625 _("Server has disconnected"));
618 return; 626 return;
619 } 627 }
620 628
621 read_input(irc, len); 629 read_input(irc, len);
634 642
635 len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1); 643 len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);
636 if (len < 0 && errno == EAGAIN) { 644 if (len < 0 && errno == EAGAIN) {
637 return; 645 return;
638 } else if (len < 0) { 646 } else if (len < 0) {
639 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 647 purple_connection_error_reason (gc,
648 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
640 _("Read error")); 649 _("Read error"));
641 return; 650 return;
642 } else if (len == 0) { 651 } else if (len == 0) {
643 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, 652 purple_connection_error_reason (gc,
653 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
644 _("Server has disconnected")); 654 _("Server has disconnected"));
645 return; 655 return;
646 } 656 }
647 657
648 read_input(irc, len); 658 read_input(irc, len);