Mercurial > pidgin
comparison libpurple/protocols/novell/novell.c @ 20123:b2c46103a5b4
Add disconnect reasons to novell.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Mon, 01 Oct 2007 14:54:31 +0000 |
parents | 44b4e8bd759b |
children | f3cfcbbac3d8 |
comparison
equal
deleted
inserted
replaced
20122:e78b4aa457a7 | 20123:b2c46103a5b4 |
---|---|
118 rc = nm_send_set_status(user, NM_STATUS_AVAILABLE, NULL, NULL, NULL, | 118 rc = nm_send_set_status(user, NM_STATUS_AVAILABLE, NULL, NULL, NULL, |
119 NULL); | 119 NULL); |
120 _check_for_disconnect(user, rc); | 120 _check_for_disconnect(user, rc); |
121 | 121 |
122 } else { | 122 } else { |
123 | 123 PurpleDisconnectReason reason; |
124 char *err = g_strdup_printf(_("Login failed (%s)."), | 124 char *err = g_strdup_printf(_("Login failed (%s)."), |
125 nm_error_to_string (ret_code)); | 125 nm_error_to_string (ret_code)); |
126 | 126 |
127 /* Don't attempt to auto-reconnect if our password | 127 switch (ret_code) { |
128 * was invalid. | 128 case NMERR_AUTHENTICATION_FAILED: |
129 */ | 129 case NMERR_CREDENTIALS_MISSING: |
130 if (ret_code == NMERR_AUTHENTICATION_FAILED || | 130 case NMERR_PASSWORD_INVALID: |
131 ret_code == NMERR_CREDENTIALS_MISSING || | 131 /* Don't attempt to auto-reconnect if our |
132 ret_code == NMERR_PASSWORD_INVALID) { | 132 * password was invalid. |
133 gc->wants_to_die = TRUE; | 133 */ |
134 } | 134 gc->wants_to_die = TRUE; |
135 purple_connection_error(gc, err); | 135 reason = PURPLE_REASON_AUTHENTICATION_FAILED; |
136 break; | |
137 default: | |
138 /* FIXME: There are other reasons login could fail */ | |
139 reason = PURPLE_REASON_NETWORK_ERROR; | |
140 } | |
141 | |
142 purple_connection_error_reason (gc, reason, err); | |
136 g_free(err); | 143 g_free(err); |
137 } | 144 } |
138 } | 145 } |
139 | 146 |
140 /* Handle getstatus response*/ | 147 /* Handle getstatus response*/ |
1116 { | 1123 { |
1117 PurpleConnection *gc = purple_account_get_connection(user->client_data); | 1124 PurpleConnection *gc = purple_account_get_connection(user->client_data); |
1118 | 1125 |
1119 if (_is_disconnect_error(err)) { | 1126 if (_is_disconnect_error(err)) { |
1120 | 1127 |
1121 purple_connection_error(gc, _("Error communicating with server." | 1128 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, |
1122 " Closing connection.")); | 1129 _("Error communicating with server. Closing connection.")); |
1123 return TRUE; | 1130 return TRUE; |
1124 | 1131 |
1125 } | 1132 } |
1126 | 1133 |
1127 return FALSE; | 1134 return FALSE; |
1663 | 1670 |
1664 gc = data; | 1671 gc = data; |
1665 user = gc->proto_data; | 1672 user = gc->proto_data; |
1666 user->conn->ssl_conn->data = NULL; | 1673 user->conn->ssl_conn->data = NULL; |
1667 | 1674 |
1668 purple_connection_error(gc, _("Unable to make SSL connection to server.")); | 1675 purple_connection_ssl_error (gc, error); |
1669 } | 1676 } |
1670 | 1677 |
1671 static void | 1678 static void |
1672 novell_ssl_recv_cb(gpointer data, PurpleSslConnection * gsc, | 1679 novell_ssl_recv_cb(gpointer data, PurpleSslConnection * gsc, |
1673 PurpleInputCondition condition) | 1680 PurpleInputCondition condition) |
1686 rc = nm_process_new_data(user); | 1693 rc = nm_process_new_data(user); |
1687 if (rc != NM_OK) { | 1694 if (rc != NM_OK) { |
1688 | 1695 |
1689 if (_is_disconnect_error(rc)) { | 1696 if (_is_disconnect_error(rc)) { |
1690 | 1697 |
1691 purple_connection_error(gc, | 1698 purple_connection_error_reason (gc, |
1692 _("Error communicating with server." | 1699 PURPLE_REASON_NETWORK_ERROR, |
1693 " Closing connection.")); | 1700 _("Error communicating with server. Closing connection.")); |
1694 } else { | 1701 } else { |
1695 purple_debug(PURPLE_DEBUG_INFO, "novell", | 1702 purple_debug(PURPLE_DEBUG_INFO, "novell", |
1696 "Error processing event or response (%d).\n", rc); | 1703 "Error processing event or response (%d).\n", rc); |
1697 } | 1704 } |
1698 } | 1705 } |
1727 rc = nm_send_login(user, pwd, my_addr, ua, _login_resp_cb, NULL); | 1734 rc = nm_send_login(user, pwd, my_addr, ua, _login_resp_cb, NULL); |
1728 if (rc == NM_OK) { | 1735 if (rc == NM_OK) { |
1729 conn->connected = TRUE; | 1736 conn->connected = TRUE; |
1730 purple_ssl_input_add(gsc, novell_ssl_recv_cb, gc); | 1737 purple_ssl_input_add(gsc, novell_ssl_recv_cb, gc); |
1731 } else { | 1738 } else { |
1732 purple_connection_error(gc, _("Unable to connect to server.")); | 1739 purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, |
1740 _("Unable to connect to server.")); | |
1733 } | 1741 } |
1734 | 1742 |
1735 purple_connection_update_progress(gc, _("Waiting for response..."), | 1743 purple_connection_update_progress(gc, _("Waiting for response..."), |
1736 3, NOVELL_CONNECT_STEPS); | 1744 3, NOVELL_CONNECT_STEPS); |
1737 | 1745 |
2007 | 2015 |
2008 gc = purple_account_get_connection((PurpleAccount *) user->client_data); | 2016 gc = purple_account_get_connection((PurpleAccount *) user->client_data); |
2009 if (gc) | 2017 if (gc) |
2010 { | 2018 { |
2011 gc->wants_to_die = TRUE; /* we don't want to reconnect in this case */ | 2019 gc->wants_to_die = TRUE; /* we don't want to reconnect in this case */ |
2012 purple_connection_error(gc, _("You have been logged out because you" | 2020 purple_connection_error_reason (gc, PURPLE_REASON_NAME_IN_USE, |
2021 _("You have been logged out because you" | |
2013 " logged in at another workstation.")); | 2022 " logged in at another workstation.")); |
2014 } | 2023 } |
2015 } | 2024 } |
2016 | 2025 |
2017 static void | 2026 static void |
2162 /* TODO: Would be nice to prompt if not set! | 2171 /* TODO: Would be nice to prompt if not set! |
2163 * purple_request_fields(gc, _("Server Address"),...); | 2172 * purple_request_fields(gc, _("Server Address"),...); |
2164 */ | 2173 */ |
2165 | 2174 |
2166 /* ...but for now just error out with a nice message. */ | 2175 /* ...but for now just error out with a nice message. */ |
2167 purple_connection_error(gc, _("Unable to connect to server." | 2176 purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR, |
2168 " Please enter the address of the server" | 2177 _("Unable to connect to server. Please enter the " |
2169 " you wish to connect to.")); | 2178 "address of the server you wish to connect to.")); |
2170 return; | 2179 return; |
2171 } | 2180 } |
2172 | 2181 |
2173 port = purple_account_get_int(account, "port", DEFAULT_PORT); | 2182 port = purple_account_get_int(account, "port", DEFAULT_PORT); |
2174 name = purple_account_get_username(account); | 2183 name = purple_account_get_username(account); |
2190 | 2199 |
2191 user->conn->ssl_conn->data = purple_ssl_connect(user->client_data, | 2200 user->conn->ssl_conn->data = purple_ssl_connect(user->client_data, |
2192 user->conn->addr, user->conn->port, | 2201 user->conn->addr, user->conn->port, |
2193 novell_ssl_connected_cb, novell_ssl_connect_error, gc); | 2202 novell_ssl_connected_cb, novell_ssl_connect_error, gc); |
2194 if (user->conn->ssl_conn->data == NULL) { | 2203 if (user->conn->ssl_conn->data == NULL) { |
2195 purple_connection_error(gc, _("Error." | 2204 purple_connection_error_reason (gc, |
2196 " SSL support is not installed.")); | 2205 PURPLE_REASON_ENCRYPTION_ERROR, |
2206 _("Error. SSL support is not installed.")); | |
2197 } | 2207 } |
2198 } | 2208 } |
2199 } | 2209 } |
2200 | 2210 |
2201 static void | 2211 static void |