static void password_changed_cb (PasswdHandler *handler, GError *error, UmPasswordDialog *um) { GtkWidget *dialog; const gchar *primary_text; const gchar *secondary_text; gtk_widget_set_sensitive (um->dialog, TRUE); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), NULL); if (!error) { finish_password_change (um); return; } if (error->code == PASSWD_ERROR_REJECTED) { primary_text = error->message; secondary_text = _("Please choose another password."); gtk_entry_set_text (GTK_ENTRY (um->password_entry), ""); gtk_widget_grab_focus (um->password_entry); gtk_entry_set_text (GTK_ENTRY (um->verify_entry), ""); } else if (error->code == PASSWD_ERROR_AUTH_FAILED) { primary_text = error->message; secondary_text = _("Please type your current password again."); gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), ""); gtk_widget_grab_focus (um->old_password_entry); } else { primary_text = _("Password could not be changed"); secondary_text = error->message; } dialog = gtk_message_dialog_new (GTK_WINDOW (um->dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", primary_text); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text); g_signal_connect (dialog, "response", G_CALLBACK (dialog_closed), um); gtk_window_present (GTK_WINDOW (dialog)); }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { const gchar *password; password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); switch (um->password_mode) { act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR); case ACT_USER_PASSWORD_MODE_REGULAR: if (act_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); return; } act_user_set_password (um->user, password, ""); break; case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN: act_user_set_password_mode (um->user, um->password_mode); act_user_set_automatic_login (um->user, FALSE); break; default: g_assert_not_reached (); } finish_password_change (um); }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { GtkTreeModel *model; GtkTreeIter iter; gint mode; const gchar *hint; const gchar *password; model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter); gtk_tree_model_get (model, &iter, 1, &mode, -1); password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); hint = gtk_entry_get_text (GTK_ENTRY (um->normal_hint_entry)); if (mode == 0 && um_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); } else { um_user_set_password (um->user, mode, password, hint); finish_password_change (um); } }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { GtkTreeModel *model; GtkTreeIter iter; gint mode; const gchar *hint; const gchar *password; model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter); gtk_tree_model_get (model, &iter, 1, &mode, -1); password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); hint = NULL; switch (mode) { case UM_PASSWORD_DIALOG_MODE_NORMAL: if (act_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); return; } act_user_set_password (um->user, password, hint); break; case UM_PASSWORD_DIALOG_MODE_SET_AT_LOGIN: act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN); break; case UM_PASSWORD_DIALOG_MODE_NO_PASSWORD: act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_NONE); break; case UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT: act_user_set_locked (um->user, TRUE); break; case UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT: act_user_set_locked (um->user, FALSE); break; default: g_assert_not_reached (); } finish_password_change (um); }
static void cancel_password_dialog (GtkButton *button, UmPasswordDialog *um) { finish_password_change (um); }