[telepathy-gabble/master] connect.c: connector_error_disconnect use switch/case
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 11 07:56:22 PDT 2009
---
src/connection.c | 70 +++++++++++++++++++++++++++++++----------------------
1 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index 90b6edd..db24699 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1378,38 +1378,50 @@ connector_error_disconnect (GabbleConnection *self,
DEBUG ("connection failed: %s", error->message);
- if (g_error_matches (error, WOCKY_CONNECTOR_ERROR,
- WOCKY_CONNECTOR_ERROR_SESSION_DENIED))
- {
- reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
- }
- else if (g_error_matches (error, WOCKY_XMPP_STREAM_ERROR,
- WOCKY_XMPP_STREAM_ERROR_HOST_UNKNOWN))
- {
- /* If we get this while we're logging in, it's because we're trying to
- * connect to foo at bar.com but the server doesn't know about bar.com,
- * probably because the user entered a non-GTalk JID into a GTalk
- * profile that forces the server.
- */
- DEBUG ("got <host-unknown> while connecting");
- reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
- }
- else if (g_error_matches (error, WOCKY_CONNECTOR_ERROR,
- WOCKY_CONNECTOR_ERROR_REGISTRATION_CONFLICT))
- {
- DEBUG ("Registration failed; jid is already used");
- reason = TP_CONNECTION_STATUS_REASON_NAME_IN_USE;
- }
- else if (
- g_error_matches (error, WOCKY_CONNECTOR_ERROR,
- WOCKY_CONNECTOR_ERROR_REGISTRATION_REJECTED) ||
- g_error_matches (error, WOCKY_CONNECTOR_ERROR,
- WOCKY_CONNECTOR_ERROR_REGISTRATION_UNSUPPORTED))
- {
- /* AuthenticationFailed is the closest ConnectionStatusReason to
- * "I tried but couldn't register you an account." */
- DEBUG ("Registration rejected");
- reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
+ if (error->domain == WOCKY_CONNECTOR_ERROR)
+ {
+ /* Connector error */
+ switch (error->code)
+ {
+ case WOCKY_CONNECTOR_ERROR_SESSION_DENIED:
+ reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
+ break;
+
+ case WOCKY_CONNECTOR_ERROR_REGISTRATION_CONFLICT:
+ DEBUG ("Registration failed; jid is already used");
+ reason = TP_CONNECTION_STATUS_REASON_NAME_IN_USE;
+ break;
+
+ case WOCKY_CONNECTOR_ERROR_REGISTRATION_REJECTED:
+ case WOCKY_CONNECTOR_ERROR_REGISTRATION_UNSUPPORTED:
+ /* AuthenticationFailed is the closest ConnectionStatusReason to
+ * "I tried but couldn't register you an account." */
+ DEBUG ("Registration rejected");
+ reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ else if (error->domain == WOCKY_XMPP_STREAM_ERROR)
+ {
+ /* Stream error */
+ switch (error->code)
+ {
+ case WOCKY_XMPP_STREAM_ERROR_HOST_UNKNOWN:
+ /* If we get this while we're logging in, it's because we're trying
+ * to connect to foo at bar.com but the server doesn't know about
+ * bar.com, probably because the user entered a non-GTalk JID into
+ * a GTalk profile that forces the server. */
+ DEBUG ("got <host-unknown> while connecting");
+ reason = TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED;
+ break;
+
+ default:
+ break;
+ }
}
/* FIXME: check SSL errors */
--
1.5.6.5
More information about the telepathy-commits
mailing list