Mercurial > pidgin.yaz
comparison libpurple/protocols/mxit/protocol.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 | c80ac2d937b7 |
children | 2346336008f5 |
comparison
equal
deleted
inserted
replaced
32329:5105d0306b2a | 32330:a5b556ac1de5 |
---|---|
406 datalen = packet->headerlen + packet->datalen; | 406 datalen = packet->headerlen + packet->datalen; |
407 | 407 |
408 res = mxit_write_sock_packet( session->fd, data, datalen ); | 408 res = mxit_write_sock_packet( session->fd, data, datalen ); |
409 if ( res < 0 ) { | 409 if ( res < 0 ) { |
410 /* we must have lost the connection, so terminate it so that we can reconnect */ | 410 /* we must have lost the connection, so terminate it so that we can reconnect */ |
411 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "We have lost the connection to MXit. Please reconnect." ) ); | 411 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "We have lost the connection to MXit. Please reconnect." ) ); |
412 } | 412 } |
413 } | 413 } |
414 else { | 414 else { |
415 /* http connection */ | 415 /* http connection */ |
416 | 416 |
528 else if ( session->outack > 0 ) { | 528 else if ( session->outack > 0 ) { |
529 /* we are still waiting for an outstanding ACK from the MXit server */ | 529 /* we are still waiting for an outstanding ACK from the MXit server */ |
530 if ( session->last_tx <= mxit_now_milli() - ( MXIT_ACK_TIMEOUT * 1000 ) ) { | 530 if ( session->last_tx <= mxit_now_milli() - ( MXIT_ACK_TIMEOUT * 1000 ) ) { |
531 /* ack timeout! so we close the connection here */ | 531 /* ack timeout! so we close the connection here */ |
532 purple_debug_info( MXIT_PLUGIN_ID, "mxit_manage_queue: Timeout awaiting ACK for command '%i'\n", session->outack ); | 532 purple_debug_info( MXIT_PLUGIN_ID, "mxit_manage_queue: Timeout awaiting ACK for command '%i'\n", session->outack ); |
533 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Timeout while waiting for a response from the MXit server." ) ); | 533 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Timeout while waiting for a response from the MXit server." ) ); |
534 } | 534 } |
535 return; | 535 return; |
536 } | 536 } |
537 | 537 |
538 /* | 538 /* |
2190 /* redirect to a MXit socket proxy */ | 2190 /* redirect to a MXit socket proxy */ |
2191 g_strlcpy( session->server, &host[1][2], sizeof( session->server ) ); | 2191 g_strlcpy( session->server, &host[1][2], sizeof( session->server ) ); |
2192 session->port = atoi( host[2] ); | 2192 session->port = atoi( host[2] ); |
2193 } | 2193 } |
2194 else { | 2194 else { |
2195 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Cannot perform redirect using the specified protocol" ) ); | 2195 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Cannot perform redirect using the specified protocol" ) ); |
2196 goto redirect_fail; | 2196 goto redirect_fail; |
2197 } | 2197 } |
2198 | 2198 |
2199 /* Part 2: type of redirect */ | 2199 /* Part 2: type of redirect */ |
2200 type = atoi( parts[1] ); | 2200 type = atoi( parts[1] ); |
2359 | 2359 |
2360 purple_debug_info( MXIT_PLUGIN_ID, "Error Reply %i:%s\n", packet->errcode, errdesc ); | 2360 purple_debug_info( MXIT_PLUGIN_ID, "Error Reply %i:%s\n", packet->errcode, errdesc ); |
2361 | 2361 |
2362 if ( packet->errcode == MXIT_ERRCODE_LOGGEDOUT ) { | 2362 if ( packet->errcode == MXIT_ERRCODE_LOGGEDOUT ) { |
2363 /* we are not currently logged in, so we need to reconnect */ | 2363 /* we are not currently logged in, so we need to reconnect */ |
2364 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( errdesc ) ); | 2364 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( errdesc ) ); |
2365 } | 2365 } |
2366 | 2366 |
2367 /* packet command */ | 2367 /* packet command */ |
2368 switch ( packet->cmd ) { | 2368 switch ( packet->cmd ) { |
2369 | 2369 |
2373 mxit_perform_redirect( session, packet->errmsg ); | 2373 mxit_perform_redirect( session, packet->errmsg ); |
2374 return 0; | 2374 return 0; |
2375 } | 2375 } |
2376 else { | 2376 else { |
2377 snprintf( errmsg, sizeof( errmsg ), _( "Login error: %s (%i)" ), errdesc, packet->errcode ); | 2377 snprintf( errmsg, sizeof( errmsg ), _( "Login error: %s (%i)" ), errdesc, packet->errcode ); |
2378 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, errmsg ); | 2378 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, errmsg ); |
2379 return -1; | 2379 return -1; |
2380 } | 2380 } |
2381 case CP_CMD_LOGOUT : | 2381 case CP_CMD_LOGOUT : |
2382 snprintf( errmsg, sizeof( errmsg ), _( "Logout error: %s (%i)" ), errdesc, packet->errcode ); | 2382 snprintf( errmsg, sizeof( errmsg ), _( "Logout error: %s (%i)" ), errdesc, packet->errcode ); |
2383 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NAME_IN_USE, _( errmsg ) ); | 2383 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NAME_IN_USE, _( errmsg ) ); |
2384 return -1; | 2384 return -1; |
2385 case CP_CMD_CONTACT : | 2385 case CP_CMD_CONTACT : |
2386 mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Contact Error" ), _( errdesc ) ); | 2386 mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Contact Error" ), _( errdesc ) ); |
2387 break; | 2387 break; |
2388 case CP_CMD_RX_MSG : | 2388 case CP_CMD_RX_MSG : |
2641 i++; | 2641 i++; |
2642 } | 2642 } |
2643 | 2643 |
2644 if ( packet.rcount < 2 ) { | 2644 if ( packet.rcount < 2 ) { |
2645 /* bad packet */ | 2645 /* bad packet */ |
2646 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Invalid packet received from MXit." ) ); | 2646 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Invalid packet received from MXit." ) ); |
2647 free_rx_packet( &packet ); | 2647 free_rx_packet( &packet ); |
2648 continue; | 2648 continue; |
2649 } | 2649 } |
2650 | 2650 |
2651 session->rx_dbuf[session->rx_i] = '\0'; | 2651 session->rx_dbuf[session->rx_i] = '\0'; |
2706 if ( session->rx_state == RX_STATE_RLEN ) { | 2706 if ( session->rx_state == RX_STATE_RLEN ) { |
2707 /* we are reading in the packet length */ | 2707 /* we are reading in the packet length */ |
2708 len = read( session->fd, &ch, 1 ); | 2708 len = read( session->fd, &ch, 1 ); |
2709 if ( len < 0 ) { | 2709 if ( len < 0 ) { |
2710 /* connection error */ | 2710 /* connection error */ |
2711 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x01)" ) ); | 2711 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x01)" ) ); |
2712 return; | 2712 return; |
2713 } | 2713 } |
2714 else if ( len == 0 ) { | 2714 else if ( len == 0 ) { |
2715 /* connection closed */ | 2715 /* connection closed */ |
2716 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x02)" ) ); | 2716 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x02)" ) ); |
2717 return; | 2717 return; |
2718 } | 2718 } |
2719 else { | 2719 else { |
2720 /* byte read */ | 2720 /* byte read */ |
2721 if ( ch == CP_REC_TERM ) { | 2721 if ( ch == CP_REC_TERM ) { |
2722 /* the end of the length record found */ | 2722 /* the end of the length record found */ |
2723 session->rx_lbuf[session->rx_i] = '\0'; | 2723 session->rx_lbuf[session->rx_i] = '\0'; |
2724 session->rx_res = atoi( &session->rx_lbuf[3] ); | 2724 session->rx_res = atoi( &session->rx_lbuf[3] ); |
2725 if ( session->rx_res > CP_MAX_PACKET ) { | 2725 if ( session->rx_res > CP_MAX_PACKET ) { |
2726 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x03)" ) ); | 2726 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x03)" ) ); |
2727 } | 2727 } |
2728 session->rx_state = RX_STATE_DATA; | 2728 session->rx_state = RX_STATE_DATA; |
2729 session->rx_i = 0; | 2729 session->rx_i = 0; |
2730 } | 2730 } |
2731 else { | 2731 else { |
2732 /* still part of the packet length record */ | 2732 /* still part of the packet length record */ |
2733 session->rx_lbuf[session->rx_i] = ch; | 2733 session->rx_lbuf[session->rx_i] = ch; |
2734 session->rx_i++; | 2734 session->rx_i++; |
2735 if ( session->rx_i >= sizeof( session->rx_lbuf ) ) { | 2735 if ( session->rx_i >= sizeof( session->rx_lbuf ) ) { |
2736 /* malformed packet length record (too long) */ | 2736 /* malformed packet length record (too long) */ |
2737 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x04)" ) ); | 2737 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x04)" ) ); |
2738 return; | 2738 return; |
2739 } | 2739 } |
2740 } | 2740 } |
2741 } | 2741 } |
2742 } | 2742 } |
2743 else if ( session->rx_state == RX_STATE_DATA ) { | 2743 else if ( session->rx_state == RX_STATE_DATA ) { |
2744 /* we are reading in the packet data */ | 2744 /* we are reading in the packet data */ |
2745 len = read( session->fd, &session->rx_dbuf[session->rx_i], session->rx_res ); | 2745 len = read( session->fd, &session->rx_dbuf[session->rx_i], session->rx_res ); |
2746 if ( len < 0 ) { | 2746 if ( len < 0 ) { |
2747 /* connection error */ | 2747 /* connection error */ |
2748 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x05)" ) ); | 2748 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x05)" ) ); |
2749 return; | 2749 return; |
2750 } | 2750 } |
2751 else if ( len == 0 ) { | 2751 else if ( len == 0 ) { |
2752 /* connection closed */ | 2752 /* connection closed */ |
2753 purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x06)" ) ); | 2753 purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x06)" ) ); |
2754 return; | 2754 return; |
2755 } | 2755 } |
2756 else { | 2756 else { |
2757 /* data read */ | 2757 /* data read */ |
2758 session->rx_i += len; | 2758 session->rx_i += len; |