static void
update_sensitivity (UmPasswordDialog *um)
{
        const gchar *password, *verify;
        const gchar *old_password;
        const gchar *tooltip;
        gboolean can_change;

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
        verify = gtk_entry_get_text (GTK_ENTRY (um->verify_entry));
        old_password = gtk_entry_get_text (GTK_ENTRY (um->old_password_entry));

        if (strlen (password) < pw_min_length ()) {
                can_change = FALSE;
                if (password[0] == '\0') {
                        tooltip = _("You need to enter a new password");
                }
                else {
                        tooltip = _("The new password is too short");
                }
        }
        else if (strcmp (password, verify) != 0) {
                can_change = FALSE;
                if (verify[0] == '\0') {
                        tooltip = _("You need to confirm the password");
                }
                else {
                        tooltip = _("The passwords do not match");
                }
        }
        else if (!um->old_password_ok) {
                can_change = FALSE;
                if (old_password[0] == '\0') {
                        tooltip = _("You need to enter your current password");
                }
                else {
                        tooltip = _("The current password is not correct");
                }
        }
        else {
                can_change = TRUE;
                tooltip = NULL;
        }

        gtk_widget_set_sensitive (um->ok_button, can_change);
        gtk_widget_set_tooltip_text (um->ok_button, tooltip);
}
gdouble
pw_strength (const gchar  *password,
             const gchar  *old_password,
             const gchar  *username,
             const gchar **hint,
             gint         *strength_level)
{
        gint rv, level, length = 0;
        gdouble strength = 0.0;
        void *auxerror;

        rv = pwquality_check (get_pwq (),
                              password, old_password, username,
                              &auxerror);

        if (password != NULL)
                length = strlen (password);

        strength = CLAMP (0.01 * rv, 0.0, 1.0);
        if (rv < 0) {
                level = (length > 0) ? 1 : 0;
        }
        else if (strength < 0.50) {
                level = 2;
        } else if (strength < 0.75) {
                level = 3;
        } else if (strength < 0.90) {
                level = 4;
        } else {
                level = 5;
        }

        if (length && length < pw_min_length())
                *hint = pw_error_hint (PWQ_ERROR_MIN_LENGTH);
        else
                *hint = pw_error_hint (rv);

        if (strength_level)
                *strength_level = level;

        return strength;
}