diff options
-rw-r--r-- | src/sip-connection.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/sip-connection.c b/src/sip-connection.c index d38caae..5eb671c 100644 --- a/src/sip-connection.c +++ b/src/sip-connection.c @@ -598,6 +598,7 @@ typedef struct { gchar *method; gchar *realm; gchar *user; + gboolean connection_auth; } PrivHandleAuthData; static PrivHandleAuthData * @@ -605,7 +606,8 @@ priv_handle_auth_data_new (RakiaConnection* self, nua_handle_t *nh, const gchar *method, const gchar *realm, - const gchar *user) + const gchar *user, + gboolean connection_auth) { PrivHandleAuthData *data = g_slice_new (PrivHandleAuthData); @@ -614,6 +616,7 @@ priv_handle_auth_data_new (RakiaConnection* self, data->method = g_strdup (method); data->realm = g_strdup (realm); data->user = g_strdup (user); + data->connection_auth = connection_auth; return data; } @@ -645,7 +648,7 @@ priv_handle_auth (RakiaConnection* self, int status, nua_handle_t *nh, const sip_t *sip, - gboolean home_realm) + gboolean connection_auth) { RakiaConnectionPrivate *priv = RAKIA_CONNECTION_GET_PRIVATE (self); sip_www_authenticate_t const *wa; @@ -654,6 +657,7 @@ priv_handle_auth (RakiaConnection* self, const char *realm = NULL; const char *user = NULL; const char *password = NULL; + gboolean home_realm; if (status != 401 && status != 407) return FALSE; @@ -688,7 +692,8 @@ priv_handle_auth (RakiaConnection* self, } /* step: determine which set of credentials to use */ - if (home_realm) + home_realm = connection_auth; + if (connection_auth) { /* Save the realm presented by the registrar */ if (priv->registrar_realm == NULL) @@ -702,7 +707,7 @@ priv_handle_auth (RakiaConnection* self, } else if (priv->registrar_realm != NULL && strcmp(priv->registrar_realm, realm) == 0) - home_realm = TRUE; + home_realm = TRUE; if (home_realm) { @@ -743,11 +748,9 @@ priv_handle_auth (RakiaConnection* self, DEBUG("asking the user for a password."); data = priv_handle_auth_data_new (self, nh, method, realm, - user); + user, connection_auth); tp_simple_password_manager_prompt_async (priv->password_manager, priv_password_manager_prompt_cb, data); - /* Promise that we'll handle it eventually, even if we end up just - * handling it with a blank password. */ return TRUE; } @@ -771,15 +774,14 @@ priv_password_manager_prompt_cb (GObject *source_object, if (error != NULL) { - /* we promised to handle the auth challenge in priv_handle_auth() by - * returning TRUE, so we need to handle it anyway, even if it means - * doing it with a blank password. - */ - DEBUG ("Auth channel failed: %s. Using blank password.", error->message); - - password = ""; - + DEBUG ("Auth channel failed: %s", error->message); g_error_free (error); + + if (data->connection_auth) + tp_base_connection_change_status (TP_BASE_CONNECTION (data->self), + TP_CONNECTION_STATUS_DISCONNECTED, + TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED); + /* FIXME: if a channel is pending auth, it should close */ } else { @@ -790,10 +792,10 @@ priv_password_manager_prompt_cb (GObject *source_object, /* also save it for later. */ g_free (priv->password); priv->password = g_strdup (password); - } - priv_handle_auth_continue (data->self, data->nh, data->method, data->realm, - data->user, password); + priv_handle_auth_continue (data->self, data->nh, data->method, + data->realm, data->user, password); + } priv_handle_auth_data_free (data); } @@ -958,6 +960,7 @@ rakia_connection_dispose (GObject *object) /* the base class owns channel factories/managers, * here we just nullify the references */ priv->media_manager = NULL; + priv->password_manager = NULL; if (G_OBJECT_CLASS (rakia_connection_parent_class)->dispose) G_OBJECT_CLASS (rakia_connection_parent_class)->dispose (object); |