2010-10-30 16:14:30 -04:00
|
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2009-2010 Red Hat, Inc,
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2012-09-06 07:43:05 -04:00
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2010-10-30 16:14:30 -04:00
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-10-30 16:14:30 -04:00
|
|
|
|
*
|
|
|
|
|
* Written by: Matthias Clasen <mclasen@redhat.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <gtk/gtk.h>
|
2012-12-04 12:48:57 -05:00
|
|
|
|
#include <act/act.h>
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
#include "cc-add-user-dialog.h"
|
2012-06-07 00:58:27 +02:00
|
|
|
|
#include "um-realm-manager.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
#include "um-utils.h"
|
2013-01-15 15:36:47 +01:00
|
|
|
|
#include "pw-utils.h"
|
|
|
|
|
|
2013-07-23 16:52:03 +02:00
|
|
|
|
#define PASSWORD_CHECK_TIMEOUT 600
|
2016-05-24 10:50:30 +02:00
|
|
|
|
#define DOMAIN_DEFAULT_HINT _("Should match the web address of your login provider.")
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
typedef enum {
|
2018-11-07 11:56:00 +13:00
|
|
|
|
MODE_LOCAL,
|
|
|
|
|
MODE_ENTERPRISE,
|
|
|
|
|
MODE_OFFLINE
|
|
|
|
|
} AccountMode;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
static void mode_change (CcAddUserDialog *self,
|
|
|
|
|
AccountMode mode);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
static void dialog_validate (CcAddUserDialog *self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
static void on_join_login (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static void on_realm_joined (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data);
|
2012-06-06 23:40:32 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
static void add_button_clicked_cb (CcAddUserDialog *self);
|
2013-04-18 17:50:42 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
struct _CcAddUserDialog {
|
2018-11-10 09:28:23 +13:00
|
|
|
|
GtkDialog parent_instance;
|
|
|
|
|
|
|
|
|
|
GtkButton *add_button;
|
|
|
|
|
GtkToggleButton *enterprise_button;
|
|
|
|
|
GtkComboBox *enterprise_domain_combo;
|
|
|
|
|
GtkEntry *enterprise_domain_entry;
|
|
|
|
|
GtkLabel *enterprise_domain_hint_label;
|
2018-11-10 09:39:09 +13:00
|
|
|
|
GtkGrid *enterprise_grid;
|
2018-11-10 09:28:23 +13:00
|
|
|
|
GtkLabel *enterprise_hint_label;
|
|
|
|
|
GtkEntry *enterprise_login_entry;
|
|
|
|
|
GtkEntry *enterprise_password_entry;
|
|
|
|
|
GtkListStore *enterprise_realm_model;
|
|
|
|
|
GtkRadioButton *local_account_type_standard;
|
2018-11-10 09:39:09 +13:00
|
|
|
|
GtkGrid *local_grid;
|
2018-11-10 09:28:23 +13:00
|
|
|
|
GtkLabel *local_hint_label;
|
|
|
|
|
GtkEntry *local_name_entry;
|
|
|
|
|
GtkComboBoxText *local_username_combo;
|
|
|
|
|
GtkListStore *local_username_model;
|
|
|
|
|
GtkEntry *local_password_entry;
|
|
|
|
|
GtkRadioButton *local_password_radio;
|
|
|
|
|
GtkEntry *local_username_entry;
|
|
|
|
|
GtkLabel *local_username_hint_label;
|
|
|
|
|
GtkLevelBar *local_strength_indicator;
|
|
|
|
|
GtkEntry *local_verify_entry;
|
|
|
|
|
GtkLabel *local_verify_hint_label;
|
2018-11-10 09:39:09 +13:00
|
|
|
|
GtkGrid *offline_grid;
|
2018-11-10 09:28:23 +13:00
|
|
|
|
GtkSpinner *spinner;
|
|
|
|
|
GtkStack *stack;
|
|
|
|
|
|
|
|
|
|
GCancellable *cancellable;
|
|
|
|
|
GPermission *permission;
|
|
|
|
|
AccountMode mode;
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
|
|
|
|
gboolean has_custom_username;
|
|
|
|
|
gint local_name_timeout_id;
|
|
|
|
|
gint local_username_timeout_id;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
ActUserPasswordMode local_password_mode;
|
2018-11-10 09:28:23 +13:00
|
|
|
|
gint local_password_timeout_id;
|
2012-06-07 00:20:29 +02:00
|
|
|
|
|
2018-11-10 09:28:23 +13:00
|
|
|
|
guint realmd_watch;
|
|
|
|
|
UmRealmManager *realm_manager;
|
|
|
|
|
UmRealmObject *selected_realm;
|
|
|
|
|
gboolean enterprise_check_credentials;
|
|
|
|
|
gint enterprise_domain_timeout_id;
|
|
|
|
|
gboolean enterprise_domain_chosen;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
/* Join credential dialog */
|
2018-11-10 09:28:23 +13:00
|
|
|
|
GtkDialog *join_dialog;
|
|
|
|
|
GtkLabel *join_domain;
|
|
|
|
|
GtkEntry *join_name;
|
|
|
|
|
GtkEntry *join_password;
|
|
|
|
|
gboolean join_prompted;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
};
|
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
G_DEFINE_TYPE (CcAddUserDialog, cc_add_user_dialog, GTK_TYPE_DIALOG);
|
2012-06-06 21:43:57 +02:00
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
show_error_dialog (CcAddUserDialog *self,
|
|
|
|
|
const gchar *message,
|
|
|
|
|
GError *error)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (self),
|
2014-03-26 08:32:02 +02:00
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
|
2012-06-06 22:51:19 +02:00
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
|
GTK_BUTTONS_CLOSE,
|
2012-07-03 13:54:38 +02:00
|
|
|
|
"%s", message);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2012-07-31 09:08:04 +02:00
|
|
|
|
if (error != NULL) {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
}
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
begin_action (CcAddUserDialog *self)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Beginning action, disabling dialog controls");
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->enterprise_check_credentials) {
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->stack), FALSE);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
}
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->enterprise_button), FALSE);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), FALSE);
|
2012-06-06 23:06:05 +02:00
|
|
|
|
|
2013-07-18 18:41:35 +02:00
|
|
|
|
gtk_widget_show (GTK_WIDGET (self->spinner));
|
|
|
|
|
gtk_spinner_start (self->spinner);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
finish_action (CcAddUserDialog *self)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
2013-01-15 15:36:47 +01:00
|
|
|
|
g_debug ("Completed domain action");
|
2012-09-03 16:16:42 +02:00
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->enterprise_check_credentials) {
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->stack), TRUE);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
}
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->enterprise_button), TRUE);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), TRUE);
|
2012-06-06 23:06:05 +02:00
|
|
|
|
|
2013-07-18 18:41:35 +02:00
|
|
|
|
gtk_widget_hide (GTK_WIDGET (self->spinner));
|
|
|
|
|
gtk_spinner_stop (self->spinner);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-29 14:32:51 -03:00
|
|
|
|
static void
|
|
|
|
|
user_loaded_cb (ActUser *user,
|
|
|
|
|
GParamSpec *pspec,
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self)
|
2013-07-29 14:32:51 -03:00
|
|
|
|
{
|
|
|
|
|
const gchar *password;
|
|
|
|
|
|
|
|
|
|
finish_action (self);
|
|
|
|
|
|
|
|
|
|
/* Set a password for the user */
|
2018-11-07 14:42:23 +13:00
|
|
|
|
password = gtk_entry_get_text (self->local_password_entry);
|
2013-07-29 14:32:51 -03:00
|
|
|
|
act_user_set_password_mode (user, self->local_password_mode);
|
|
|
|
|
if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR)
|
|
|
|
|
act_user_set_password (user, password, "");
|
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
self->user = g_object_ref (user);
|
|
|
|
|
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
|
2013-07-29 14:32:51 -03:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2012-12-04 12:48:57 -05:00
|
|
|
|
create_user_done (ActUserManager *manager,
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GAsyncResult *res,
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GError *error;
|
|
|
|
|
|
2012-06-06 22:51:19 +02:00
|
|
|
|
/* Note that user is returned without an extra reference */
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-06-06 22:51:19 +02:00
|
|
|
|
error = NULL;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
user = act_user_manager_create_user_finish (manager, res, &error);
|
|
|
|
|
|
|
|
|
|
if (user == NULL) {
|
2013-07-29 14:32:51 -03:00
|
|
|
|
finish_action (self);
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Failed to create user: %s", error->message);
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!g_error_matches (error, ACT_USER_MANAGER_ERROR, ACT_USER_MANAGER_ERROR_PERMISSION_DENIED))
|
2012-06-06 23:10:53 +02:00
|
|
|
|
show_error_dialog (self, _("Failed to add account"), error);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
g_error_free (error);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->local_name_entry));
|
2012-06-06 22:51:19 +02:00
|
|
|
|
} else {
|
2012-12-04 12:48:57 -05:00
|
|
|
|
g_debug ("Created user: %s", act_user_get_user_name (user));
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2013-07-29 14:32:51 -03:00
|
|
|
|
/* Check if the returned object is fully loaded before returning it */
|
|
|
|
|
if (act_user_is_loaded (user))
|
|
|
|
|
user_loaded_cb (user, NULL, self);
|
|
|
|
|
else
|
|
|
|
|
g_signal_connect (user, "notify::is-loaded", G_CALLBACK (user_loaded_cb), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
local_create_user (CcAddUserDialog *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUserManager *manager;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
const gchar *username;
|
|
|
|
|
const gchar *name;
|
|
|
|
|
gint account_type;
|
|
|
|
|
|
2012-06-06 22:51:19 +02:00
|
|
|
|
begin_action (self);
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
name = gtk_entry_get_text (self->local_name_entry);
|
|
|
|
|
username = gtk_combo_box_text_get_active_text (self->local_username_combo);
|
|
|
|
|
account_type = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->local_account_type_standard)) ? ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Creating local user: %s", username);
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
manager = act_user_manager_get_default ();
|
|
|
|
|
act_user_manager_create_user_async (manager,
|
|
|
|
|
username,
|
|
|
|
|
name,
|
|
|
|
|
account_type,
|
|
|
|
|
self->cancellable,
|
|
|
|
|
(GAsyncReadyCallback)create_user_done,
|
|
|
|
|
self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static gint
|
2018-11-07 11:56:00 +13:00
|
|
|
|
update_password_strength (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
const gchar *password;
|
|
|
|
|
const gchar *username;
|
|
|
|
|
const gchar *hint;
|
2018-04-11 10:05:30 +02:00
|
|
|
|
const gchar *verify;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
gint strength_level;
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
password = gtk_entry_get_text (self->local_password_entry);
|
|
|
|
|
username = gtk_combo_box_text_get_active_text (self->local_username_combo);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2017-04-05 13:24:47 +02:00
|
|
|
|
pw_strength (password, NULL, username, &hint, &strength_level);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_label (self->local_hint_label, hint);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_level_bar_set_value (self->local_strength_indicator, strength_level);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2017-04-05 13:29:30 +02:00
|
|
|
|
if (strength_level > 1) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
set_entry_validation_checkmark (self->local_password_entry);
|
2013-08-06 16:12:21 +02:00
|
|
|
|
} else if (strlen (password) == 0) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
set_entry_generation_icon (self->local_password_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
} else {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->local_password_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
verify = gtk_entry_get_text (self->local_verify_entry);
|
2018-04-11 10:05:30 +02:00
|
|
|
|
if (strlen (verify) == 0) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_verify_entry), strength_level > 1);
|
2018-04-11 10:05:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
return strength_level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 23:40:32 +02:00
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
local_validate (CcAddUserDialog *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-06-06 23:40:32 +02:00
|
|
|
|
gboolean valid_login;
|
|
|
|
|
gboolean valid_name;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
gboolean valid_password;
|
2012-06-06 23:40:32 +02:00
|
|
|
|
const gchar *name;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
const gchar *password;
|
|
|
|
|
const gchar *verify;
|
2012-06-06 23:40:32 +02:00
|
|
|
|
gchar *tip;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
gint strength;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
name = gtk_combo_box_text_get_active_text (self->local_username_combo);
|
2012-06-06 23:40:32 +02:00
|
|
|
|
valid_login = is_valid_username (name, &tip);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_label (self->local_username_hint_label, tip);
|
2014-04-24 13:44:39 +02:00
|
|
|
|
g_free (tip);
|
2012-06-06 23:40:32 +02:00
|
|
|
|
|
2013-07-23 16:52:03 +02:00
|
|
|
|
if (valid_login) {
|
2018-11-07 12:19:01 +13:00
|
|
|
|
set_entry_validation_checkmark (self->local_username_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
name = gtk_entry_get_text (self->local_name_entry);
|
2012-06-06 23:40:32 +02:00
|
|
|
|
valid_name = is_valid_name (name);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
if (valid_name) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
set_entry_validation_checkmark (self->local_name_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
}
|
2012-06-06 23:40:32 +02:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
password = gtk_entry_get_text (self->local_password_entry);
|
|
|
|
|
verify = gtk_entry_get_text (self->local_verify_entry);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->local_password_mode == ACT_USER_PASSWORD_MODE_REGULAR) {
|
|
|
|
|
strength = update_password_strength (self);
|
2017-09-25 14:23:24 +02:00
|
|
|
|
valid_password = strength > 1 && strcmp (password, verify) == 0;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
} else {
|
|
|
|
|
valid_password = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return valid_name && valid_login && valid_password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
local_username_timeout (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
2014-08-09 15:12:34 +02:00
|
|
|
|
self->local_username_timeout_id = 0;
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
dialog_validate (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_username_combo_focus_out_event_cb (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
if (self->local_username_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_username_timeout_id);
|
|
|
|
|
self->local_username_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local_username_timeout (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2012-06-06 23:40:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_username_combo_changed_cb (CcAddUserDialog *self)
|
2012-06-06 23:40:32 +02:00
|
|
|
|
{
|
2017-02-14 09:13:00 +01:00
|
|
|
|
const gchar *username;
|
|
|
|
|
|
2018-11-07 12:19:01 +13:00
|
|
|
|
username = gtk_entry_get_text (self->local_username_entry);
|
2017-02-14 09:13:00 +01:00
|
|
|
|
if (*username == '\0')
|
|
|
|
|
self->has_custom_username = FALSE;
|
2018-11-07 12:19:01 +13:00
|
|
|
|
else if (gtk_widget_has_focus (GTK_WIDGET (self->local_username_entry)) ||
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_combo_box_get_active (GTK_COMBO_BOX (self->local_username_combo)) > 0)
|
2017-02-14 09:13:00 +01:00
|
|
|
|
self->has_custom_username = TRUE;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
if (self->local_username_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_username_timeout_id);
|
|
|
|
|
self->local_username_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 12:19:01 +13:00
|
|
|
|
clear_entry_validation_error (self->local_username_entry);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), FALSE);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
self->local_username_timeout_id = g_timeout_add (PASSWORD_CHECK_TIMEOUT, (GSourceFunc) local_username_timeout, self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-23 16:52:03 +02:00
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
local_name_timeout (CcAddUserDialog *self)
|
2013-07-23 16:52:03 +02:00
|
|
|
|
{
|
2017-02-15 08:58:43 +01:00
|
|
|
|
self->local_name_timeout_id = 0;
|
2014-08-09 15:12:34 +02:00
|
|
|
|
|
2013-07-23 16:52:03 +02:00
|
|
|
|
dialog_validate (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_name_entry_focus_out_event_cb (CcAddUserDialog *self)
|
2013-07-23 16:52:03 +02:00
|
|
|
|
{
|
|
|
|
|
if (self->local_name_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_name_timeout_id);
|
|
|
|
|
self->local_name_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local_name_timeout (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_name_entry_changed_cb (CcAddUserDialog *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
|
2018-11-07 14:50:58 +13:00
|
|
|
|
gtk_list_store_clear (self->local_username_model);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
name = gtk_entry_get_text (self->local_name_entry);
|
2017-02-14 09:13:00 +01:00
|
|
|
|
if ((name == NULL || strlen (name) == 0) && !self->has_custom_username) {
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_entry_set_text (self->local_username_entry, "");
|
2017-02-14 09:13:00 +01:00
|
|
|
|
} else if (name != NULL && strlen (name) != 0) {
|
2018-11-07 14:50:58 +13:00
|
|
|
|
generate_username_choices (name, self->local_username_model);
|
2017-02-14 09:13:00 +01:00
|
|
|
|
if (!self->has_custom_username)
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_combo_box_set_active (GTK_COMBO_BOX (self->local_username_combo), 0);
|
2013-07-23 16:34:44 +02:00
|
|
|
|
}
|
2012-06-06 23:40:32 +02:00
|
|
|
|
|
2017-02-15 08:58:43 +01:00
|
|
|
|
if (self->local_name_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_name_timeout_id);
|
|
|
|
|
self->local_name_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->local_name_entry);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), FALSE);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
|
2017-02-15 08:58:43 +01:00
|
|
|
|
self->local_name_timeout_id = g_timeout_add (PASSWORD_CHECK_TIMEOUT, (GSourceFunc) local_name_timeout, self);
|
2012-06-06 23:32:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
update_password_match (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
const gchar *password;
|
|
|
|
|
const gchar *verify;
|
2018-07-10 15:18:43 +02:00
|
|
|
|
const gchar *message = "";
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
password = gtk_entry_get_text (self->local_password_entry);
|
|
|
|
|
verify = gtk_entry_get_text (self->local_verify_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
if (strlen (verify) != 0) {
|
|
|
|
|
if (strcmp (password, verify) != 0) {
|
2018-07-12 09:45:13 +02:00
|
|
|
|
message = _("The passwords do not match.");
|
2013-07-23 16:52:03 +02:00
|
|
|
|
} else {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
set_entry_validation_checkmark (self->local_verify_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
}
|
2013-01-15 15:36:47 +01:00
|
|
|
|
}
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_label (self->local_verify_hint_label, message);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 16:12:21 +02:00
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_password_entry_icon_press_cb (CcAddUserDialog *self)
|
2013-08-06 16:12:21 +02:00
|
|
|
|
{
|
|
|
|
|
gchar *pwd;
|
|
|
|
|
|
|
|
|
|
pwd = pw_generate ();
|
2018-08-30 16:28:20 +02:00
|
|
|
|
if (pwd == NULL)
|
|
|
|
|
return;
|
2013-08-06 16:12:21 +02:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_entry_set_text (self->local_password_entry, pwd);
|
|
|
|
|
gtk_entry_set_text (self->local_verify_entry, pwd);
|
|
|
|
|
gtk_entry_set_visibility (self->local_password_entry, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_verify_entry), TRUE);
|
2013-08-06 16:12:21 +02:00
|
|
|
|
|
|
|
|
|
g_free (pwd);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
local_password_timeout (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
2014-08-09 15:12:34 +02:00
|
|
|
|
self->local_password_timeout_id = 0;
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
dialog_validate (self);
|
|
|
|
|
update_password_match (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-11-07 12:34:36 +13:00
|
|
|
|
password_focus_out_event_cb (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
if (self->local_password_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_password_timeout_id);
|
|
|
|
|
self->local_password_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local_password_timeout (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-11 10:01:20 +02:00
|
|
|
|
static gboolean
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_password_entry_key_press_event_cb (CcAddUserDialog *self,
|
2018-11-07 12:34:36 +13:00
|
|
|
|
GdkEvent *event)
|
2018-04-11 10:01:20 +02:00
|
|
|
|
{
|
|
|
|
|
GdkEventKey *key = (GdkEventKey *)event;
|
|
|
|
|
|
|
|
|
|
if (key->keyval == GDK_KEY_Tab)
|
|
|
|
|
local_password_timeout (self);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static void
|
2018-11-07 12:34:36 +13:00
|
|
|
|
recheck_password_match (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
2013-08-06 16:12:21 +02:00
|
|
|
|
const char *password;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
if (self->local_password_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_password_timeout_id);
|
|
|
|
|
self->local_password_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), FALSE);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
password = gtk_entry_get_text (self->local_password_entry);
|
2013-08-06 16:12:21 +02:00
|
|
|
|
if (strlen (password) == 0) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_entry_set_visibility (self->local_password_entry, FALSE);
|
2013-08-06 16:12:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
self->local_password_timeout_id = g_timeout_add (PASSWORD_CHECK_TIMEOUT, (GSourceFunc) local_password_timeout, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_password_entry_changed_cb (CcAddUserDialog *self)
|
2018-11-07 12:34:36 +13:00
|
|
|
|
{
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->local_password_entry);
|
|
|
|
|
clear_entry_validation_error (self->local_verify_entry);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
recheck_password_match (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
local_verify_entry_changed_cb (CcAddUserDialog *self)
|
2018-11-07 12:34:36 +13:00
|
|
|
|
{
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->local_verify_entry);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
recheck_password_match (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
local_password_radio_changed_cb (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
gboolean active;
|
|
|
|
|
|
2018-11-07 12:34:36 +13:00
|
|
|
|
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->local_password_radio));
|
2013-01-15 15:36:47 +01:00
|
|
|
|
self->local_password_mode = active ? ACT_USER_PASSWORD_MODE_REGULAR : ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_password_entry), active);
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_verify_entry), active);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_strength_indicator), active);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->local_hint_label), active);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
dialog_validate (self);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_validate (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
|
|
|
|
const gchar *name;
|
|
|
|
|
gboolean valid_name;
|
|
|
|
|
gboolean valid_domain;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
name = gtk_entry_get_text (self->enterprise_login_entry);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
valid_name = is_valid_name (name);
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
if (gtk_combo_box_get_active_iter (self->enterprise_domain_combo, &iter)) {
|
2018-11-07 14:50:58 +13:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (self->enterprise_realm_model),
|
2012-06-07 00:58:27 +02:00
|
|
|
|
&iter, 0, &name, -1);
|
|
|
|
|
} else {
|
|
|
|
|
name = gtk_entry_get_text (self->enterprise_domain_entry);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
valid_domain = is_valid_name (name) && self->selected_realm != NULL;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
return valid_name && valid_domain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_add_realm (CcAddUserDialog *self,
|
|
|
|
|
UmRealmObject *realm)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2012-10-18 18:37:24 +02:00
|
|
|
|
GtkTreeModel *model;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GtkTreeIter iter;
|
2012-08-17 16:58:10 +02:00
|
|
|
|
UmRealmCommon *common;
|
2012-10-18 18:37:24 +02:00
|
|
|
|
const gchar *realm_name;
|
|
|
|
|
gboolean match;
|
|
|
|
|
gboolean ret;
|
|
|
|
|
gchar *name;
|
2012-09-03 16:16:42 +02:00
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
common = um_realm_object_get_common (realm);
|
2015-02-25 14:31:28 +01:00
|
|
|
|
g_return_if_fail (common != NULL);
|
|
|
|
|
|
2012-10-18 18:37:24 +02:00
|
|
|
|
realm_name = um_realm_common_get_name (common);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Don't add a second realm if we already have one with this name.
|
|
|
|
|
* Sometimes realmd returns to realms for the same name, if it has
|
|
|
|
|
* different ways to use that realm. The first one that realmd
|
|
|
|
|
* returns is the one it prefers.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
model = GTK_TREE_MODEL (self->enterprise_realm_model);
|
2012-10-18 18:37:24 +02:00
|
|
|
|
ret = gtk_tree_model_get_iter_first (model, &iter);
|
|
|
|
|
while (ret) {
|
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &name, -1);
|
|
|
|
|
match = (g_strcmp0 (name, realm_name) == 0);
|
|
|
|
|
g_free (name);
|
|
|
|
|
if (match) {
|
|
|
|
|
g_debug ("ignoring duplicate realm: %s", realm_name);
|
2013-05-26 21:10:51 +02:00
|
|
|
|
g_object_unref (common);
|
2012-10-18 18:37:24 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ret = gtk_tree_model_iter_next (model, &iter);
|
|
|
|
|
}
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_list_store_append (self->enterprise_realm_model, &iter);
|
|
|
|
|
gtk_list_store_set (self->enterprise_realm_model, &iter,
|
2012-10-18 18:37:24 +02:00
|
|
|
|
0, realm_name,
|
2012-06-07 00:58:27 +02:00
|
|
|
|
1, realm,
|
|
|
|
|
-1);
|
|
|
|
|
|
2013-11-08 13:40:17 +01:00
|
|
|
|
/* Prefill domain entry by the existing one */
|
|
|
|
|
if (!self->enterprise_domain_chosen && um_realm_is_configured (realm)) {
|
|
|
|
|
gtk_entry_set_text (self->enterprise_domain_entry, realm_name);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-18 18:37:24 +02:00
|
|
|
|
g_debug ("added realm to drop down: %s %s", realm_name,
|
|
|
|
|
g_dbus_object_get_object_path (G_DBUS_OBJECT (realm)));
|
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
g_object_unref (common);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_manager_realm_added (UmRealmManager *manager,
|
2012-08-17 16:58:10 +02:00
|
|
|
|
UmRealmObject *realm,
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
enterprise_add_realm (self, realm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_register_user (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
user = act_user_manager_cache_user_finish (ACT_USER_MANAGER (source), result, &error);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
/* This is where we're finally done */
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (user != NULL) {
|
|
|
|
|
g_debug ("Successfully cached remote user: %s", act_user_get_user_name (user));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
finish_action (self);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
self->user = g_object_ref (user);
|
|
|
|
|
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
} else {
|
|
|
|
|
show_error_dialog (self, _("Failed to register account"), error);
|
|
|
|
|
g_message ("Couldn't cache user account: %s", error->message);
|
|
|
|
|
finish_action (self);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2012-12-04 12:48:57 -05:00
|
|
|
|
|
|
|
|
|
g_object_unref (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_permit_user_login (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-08-17 16:58:10 +02:00
|
|
|
|
UmRealmCommon *common;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUserManager *manager;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
gchar *login;
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
common = UM_REALM_COMMON (source);
|
|
|
|
|
um_realm_common_call_change_login_policy_finish (common, result, &error);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
if (error == NULL) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now tell the account service about this user. The account service
|
|
|
|
|
* should also lookup information about this via the realm and make
|
|
|
|
|
* sure all that is functional.
|
|
|
|
|
*/
|
2012-12-04 12:48:57 -05:00
|
|
|
|
manager = act_user_manager_get_default ();
|
2018-11-07 14:42:23 +13:00
|
|
|
|
login = um_realm_calculate_login (common, gtk_entry_get_text (self->enterprise_login_entry));
|
2012-08-17 16:58:10 +02:00
|
|
|
|
g_return_if_fail (login != NULL);
|
|
|
|
|
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Caching remote user: %s", login);
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
act_user_manager_cache_user_async (manager, login, self->cancellable,
|
|
|
|
|
on_register_user, g_object_ref (self));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
g_free (login);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
show_error_dialog (self, _("Failed to register account"), error);
|
|
|
|
|
g_message ("Couldn't permit logins on account: %s", error->message);
|
|
|
|
|
finish_action (self);
|
2012-10-12 16:20:53 -04:00
|
|
|
|
g_error_free (error);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_permit_user_login (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2012-08-17 16:58:10 +02:00
|
|
|
|
UmRealmCommon *common;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gchar *login;
|
|
|
|
|
const gchar *add[2];
|
|
|
|
|
const gchar *remove[1];
|
2012-07-31 09:17:34 +02:00
|
|
|
|
GVariant *options;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
common = um_realm_object_get_common (self->selected_realm);
|
2015-07-14 15:11:28 +02:00
|
|
|
|
if (common == NULL) {
|
2015-02-25 14:31:28 +01:00
|
|
|
|
g_debug ("Failed to register account: failed to get d-bus interface");
|
|
|
|
|
show_error_dialog (self, _("Failed to register account"), NULL);
|
|
|
|
|
finish_action (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-08-17 16:58:10 +02:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
login = um_realm_calculate_login (common, gtk_entry_get_text (self->enterprise_login_entry));
|
2012-08-17 16:58:10 +02:00
|
|
|
|
g_return_if_fail (login != NULL);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
add[0] = login;
|
|
|
|
|
add[1] = NULL;
|
|
|
|
|
remove[0] = NULL;
|
|
|
|
|
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Permitting login for: %s", login);
|
2012-07-31 09:17:34 +02:00
|
|
|
|
options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
um_realm_common_call_change_login_policy (common, "",
|
|
|
|
|
add, remove, options,
|
|
|
|
|
self->cancellable,
|
|
|
|
|
on_permit_user_login,
|
|
|
|
|
g_object_ref (self));
|
2012-07-31 09:17:34 +02:00
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
g_object_unref (common);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_free (login);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_join_response (GtkDialog *dialog,
|
|
|
|
|
gint response,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
|
|
|
|
if (response != GTK_RESPONSE_OK) {
|
|
|
|
|
finish_action (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Logging in as admin user: %s", gtk_entry_get_text (self->join_name));
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
/* Prompted for some admin credentials, try to use them to log in */
|
2012-08-17 16:58:10 +02:00
|
|
|
|
um_realm_login (self->selected_realm,
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gtk_entry_get_text (self->join_name),
|
|
|
|
|
gtk_entry_get_text (self->join_password),
|
|
|
|
|
self->cancellable,
|
|
|
|
|
on_join_login,
|
|
|
|
|
g_object_ref (self));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
join_show_prompt (CcAddUserDialog *self,
|
|
|
|
|
GError *error)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2012-08-17 16:58:10 +02:00
|
|
|
|
UmRealmKerberosMembership *membership;
|
|
|
|
|
UmRealmKerberos *kerberos;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
|
|
gtk_entry_set_text (self->join_password, "");
|
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->join_password));
|
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
kerberos = um_realm_object_get_kerberos (self->selected_realm);
|
|
|
|
|
membership = um_realm_object_get_kerberos_membership (self->selected_realm);
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gtk_label_set_text (self->join_domain,
|
2012-08-17 16:58:10 +02:00
|
|
|
|
um_realm_kerberos_get_domain_name (kerberos));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
clear_entry_validation_error (self->join_name);
|
|
|
|
|
clear_entry_validation_error (self->join_password);
|
|
|
|
|
|
2012-06-12 17:17:01 +02:00
|
|
|
|
if (!self->join_prompted) {
|
2012-08-17 16:58:10 +02:00
|
|
|
|
name = um_realm_kerberos_membership_get_suggested_administrator (membership);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
if (name && !g_str_equal (name, "")) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Suggesting admin user: %s", name);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gtk_entry_set_text (self->join_name, name);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->join_name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_BAD_PASSWORD)) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Bad admin password: %s", error->message);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
set_entry_validation_error (self->join_password, error->message);
|
|
|
|
|
|
|
|
|
|
} else {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Admin login failure: %s", error->message);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
set_entry_validation_error (self->join_name, error->message);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Showing admin password dialog");
|
2012-06-07 00:58:27 +02:00
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (self->join_dialog), GTK_WINDOW (self));
|
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (self->join_dialog), TRUE);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (self->join_dialog));
|
|
|
|
|
|
2012-06-12 17:17:01 +02:00
|
|
|
|
self->join_prompted = TRUE;
|
2012-08-17 16:58:10 +02:00
|
|
|
|
g_object_unref (kerberos);
|
|
|
|
|
g_object_unref (membership);
|
2012-06-12 17:17:01 +02:00
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
/* And now we wait for on_join_response() */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_join_login (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GBytes *creds;
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 15:14:08 +02:00
|
|
|
|
creds = um_realm_login_finish (result, &error);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
/* Logged in as admin successfully, use creds to join domain */
|
|
|
|
|
if (error == NULL) {
|
2012-07-31 09:17:34 +02:00
|
|
|
|
if (!um_realm_join_as_admin (self->selected_realm,
|
|
|
|
|
gtk_entry_get_text (self->join_name),
|
|
|
|
|
gtk_entry_get_text (self->join_password),
|
|
|
|
|
creds, self->cancellable, on_realm_joined,
|
|
|
|
|
g_object_ref (self))) {
|
|
|
|
|
show_error_dialog (self, _("No supported way to authenticate with this domain"), NULL);
|
|
|
|
|
g_message ("Authenticating as admin is not supported by the realm");
|
|
|
|
|
finish_action (self);
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_bytes_unref (creds);
|
|
|
|
|
|
|
|
|
|
/* Couldn't login as admin, show prompt again */
|
|
|
|
|
} else {
|
|
|
|
|
join_show_prompt (self, error);
|
|
|
|
|
g_message ("Couldn't log in as admin to join domain: %s", error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
join_init (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2016-06-10 11:46:23 +02:00
|
|
|
|
GtkBuilder *builder;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
builder = gtk_builder_new ();
|
|
|
|
|
|
|
|
|
|
if (!gtk_builder_add_from_resource (builder,
|
|
|
|
|
"/org/gnome/control-center/user-accounts/join-dialog.ui",
|
|
|
|
|
&error)) {
|
|
|
|
|
g_error ("%s", error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
self->join_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "join-dialog"));
|
|
|
|
|
self->join_domain = GTK_LABEL (gtk_builder_get_object (builder, "join-domain"));
|
|
|
|
|
self->join_name = GTK_ENTRY (gtk_builder_get_object (builder, "join-name"));
|
|
|
|
|
self->join_password = GTK_ENTRY (gtk_builder_get_object (builder, "join-password"));
|
|
|
|
|
|
|
|
|
|
g_signal_connect (self->join_dialog, "response",
|
|
|
|
|
G_CALLBACK (on_join_response), self);
|
2016-06-10 11:46:23 +02:00
|
|
|
|
|
|
|
|
|
g_object_unref (builder);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_realm_joined (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
um_realm_join_finish (self->selected_realm,
|
|
|
|
|
result, &error);
|
|
|
|
|
|
|
|
|
|
/* Yay, joined the domain, register the user locally */
|
|
|
|
|
if (error == NULL) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Joining realm completed successfully");
|
2012-06-07 00:58:27 +02:00
|
|
|
|
enterprise_permit_user_login (self);
|
|
|
|
|
|
|
|
|
|
/* Credential failure while joining domain, prompt for admin creds */
|
|
|
|
|
} else if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_BAD_LOGIN) ||
|
|
|
|
|
g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_BAD_PASSWORD)) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Joining realm failed due to credentials");
|
2012-06-07 00:58:27 +02:00
|
|
|
|
join_show_prompt (self, error);
|
|
|
|
|
|
|
|
|
|
/* Other failure */
|
|
|
|
|
} else {
|
|
|
|
|
show_error_dialog (self, _("Failed to join domain"), error);
|
|
|
|
|
g_message ("Failed to join the domain: %s", error->message);
|
|
|
|
|
finish_action (self);
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-12 16:20:53 -04:00
|
|
|
|
g_clear_error (&error);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_realm_login (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
2013-04-30 11:11:33 +02:00
|
|
|
|
GBytes *creds = NULL;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
const gchar *message;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-24 15:14:08 +02:00
|
|
|
|
creds = um_realm_login_finish (result, &error);
|
2013-04-30 11:11:33 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* User login is valid, but cannot authenticate right now (eg: user needs
|
|
|
|
|
* to change password at next login etc.)
|
|
|
|
|
*/
|
|
|
|
|
if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_CANNOT_AUTH)) {
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
creds = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
if (error == NULL) {
|
|
|
|
|
|
|
|
|
|
/* Already joined to the domain, just register this user */
|
2012-08-17 16:58:10 +02:00
|
|
|
|
if (um_realm_is_configured (self->selected_realm)) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Already joined to this realm");
|
2012-06-07 00:58:27 +02:00
|
|
|
|
enterprise_permit_user_login (self);
|
|
|
|
|
|
|
|
|
|
/* Join the domain, try using the user's creds */
|
2013-04-30 11:11:33 +02:00
|
|
|
|
} else if (creds == NULL ||
|
|
|
|
|
!um_realm_join_as_user (self->selected_realm,
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_entry_get_text (self->enterprise_login_entry),
|
|
|
|
|
gtk_entry_get_text (self->enterprise_password_entry),
|
2012-07-31 09:17:34 +02:00
|
|
|
|
creds, self->cancellable,
|
|
|
|
|
on_realm_joined,
|
|
|
|
|
g_object_ref (self))) {
|
|
|
|
|
|
2012-08-07 09:58:29 -04:00
|
|
|
|
/* If we can't do user auth, try to authenticate as admin */
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Cannot join with user credentials");
|
2012-07-31 09:17:34 +02:00
|
|
|
|
join_show_prompt (self, NULL);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_bytes_unref (creds);
|
|
|
|
|
|
|
|
|
|
/* A problem with the user's login name or password */
|
|
|
|
|
} else if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_BAD_LOGIN)) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Problem with the user's login: %s", error->message);
|
2016-10-03 14:48:16 +02:00
|
|
|
|
message = _("That login name didn’t work.\nPlease try again.");
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_hint_label, message);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
finish_action (self);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->enterprise_login_entry));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
} else if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_BAD_PASSWORD)) {
|
2012-09-03 16:16:42 +02:00
|
|
|
|
g_debug ("Problem with the user's password: %s", error->message);
|
2016-10-03 14:48:16 +02:00
|
|
|
|
message = _("That login password didn’t work.\nPlease try again.");
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_hint_label, message);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
finish_action (self);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->enterprise_password_entry));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
/* Other login failure */
|
|
|
|
|
} else {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
show_error_dialog (self, _("Failed to log into domain"), error);
|
|
|
|
|
g_message ("Couldn't log in as user: %s", error->message);
|
|
|
|
|
finish_action (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_check_login (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
|
|
|
|
g_assert (self->selected_realm);
|
|
|
|
|
|
2012-08-17 16:58:10 +02:00
|
|
|
|
um_realm_login (self->selected_realm,
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_entry_get_text (self->enterprise_login_entry),
|
|
|
|
|
gtk_entry_get_text (self->enterprise_password_entry),
|
2012-06-07 00:58:27 +02:00
|
|
|
|
self->cancellable,
|
|
|
|
|
on_realm_login,
|
|
|
|
|
g_object_ref (self));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_realm_discover_input (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GList *realms;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
gchar *message;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
realms = um_realm_manager_discover_finish (self->realm_manager,
|
|
|
|
|
result, &error);
|
|
|
|
|
|
|
|
|
|
/* Found a realm, log user into domain */
|
|
|
|
|
if (error == NULL) {
|
|
|
|
|
g_assert (realms != NULL);
|
|
|
|
|
self->selected_realm = g_object_ref (realms->data);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
if (self->enterprise_check_credentials) {
|
|
|
|
|
enterprise_check_login (self);
|
|
|
|
|
}
|
2018-11-07 12:19:01 +13:00
|
|
|
|
set_entry_validation_checkmark (self->enterprise_domain_entry);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_domain_hint_label, DOMAIN_DEFAULT_HINT);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_list_free_full (realms, g_object_unref);
|
|
|
|
|
|
|
|
|
|
/* The domain is likely invalid*/
|
|
|
|
|
} else {
|
|
|
|
|
g_message ("Couldn't discover domain: %s", error->message);
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
if (g_error_matches (error, UM_REALM_ERROR, UM_REALM_ERROR_GENERIC)) {
|
2017-04-10 14:31:53 +02:00
|
|
|
|
message = g_strdup (_("Unable to find the domain. Maybe you misspelled it?"));
|
2013-01-15 15:36:47 +01:00
|
|
|
|
} else {
|
|
|
|
|
message = g_strdup_printf ("%s.", error->message);
|
|
|
|
|
}
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_domain_hint_label, message);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
g_free (message);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_error_free (error);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
if (self->enterprise_check_credentials) {
|
|
|
|
|
finish_action (self);
|
|
|
|
|
self->enterprise_check_credentials = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!self->enterprise_check_credentials) {
|
|
|
|
|
finish_action (self);
|
|
|
|
|
dialog_validate (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_check_domain (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2013-01-15 15:36:47 +01:00
|
|
|
|
const gchar *domain;
|
|
|
|
|
|
|
|
|
|
domain = gtk_entry_get_text (self->enterprise_domain_entry);
|
|
|
|
|
if (strlen (domain) == 0) {
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_domain_hint_label, DOMAIN_DEFAULT_HINT);
|
2013-01-15 15:36:47 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
begin_action (self);
|
2012-06-12 17:17:01 +02:00
|
|
|
|
|
|
|
|
|
self->join_prompted = FALSE;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
um_realm_manager_discover (self->realm_manager,
|
|
|
|
|
domain,
|
|
|
|
|
self->cancellable,
|
|
|
|
|
on_realm_discover_input,
|
|
|
|
|
g_object_ref (self));
|
|
|
|
|
}
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_add_user (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
self->join_prompted = FALSE;
|
|
|
|
|
self->enterprise_check_credentials = TRUE;
|
|
|
|
|
begin_action (self);
|
|
|
|
|
enterprise_check_login (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
clear_realm_manager (CcAddUserDialog *self)
|
2013-05-24 14:32:51 +02:00
|
|
|
|
{
|
|
|
|
|
if (self->realm_manager) {
|
|
|
|
|
g_signal_handlers_disconnect_by_func (self->realm_manager,
|
|
|
|
|
on_manager_realm_added,
|
|
|
|
|
self);
|
|
|
|
|
g_object_unref (self->realm_manager);
|
|
|
|
|
self->realm_manager = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
static void
|
|
|
|
|
on_realm_manager_created (GObject *source,
|
2018-11-07 11:56:00 +13:00
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
GError *error = NULL;
|
|
|
|
|
GList *realms, *l;
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
clear_realm_manager (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
|
|
|
|
self->realm_manager = um_realm_manager_new_finish (result, &error);
|
|
|
|
|
if (error != NULL) {
|
|
|
|
|
g_warning ("Couldn't contact realmd service: %s", error->message);
|
2013-05-24 14:32:51 +02:00
|
|
|
|
g_object_unref (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
g_error_free (error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
if (g_cancellable_is_cancelled (self->cancellable)) {
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
/* Lookup all the realm objects */
|
|
|
|
|
realms = um_realm_manager_get_realms (self->realm_manager);
|
|
|
|
|
for (l = realms; l != NULL; l = g_list_next (l))
|
|
|
|
|
enterprise_add_realm (self, l->data);
|
|
|
|
|
g_list_free (realms);
|
|
|
|
|
g_signal_connect (self->realm_manager, "realm-added",
|
|
|
|
|
G_CALLBACK (on_manager_realm_added), self);
|
|
|
|
|
|
|
|
|
|
/* When no realms try to discover a sensible default, triggers realm-added signal */
|
|
|
|
|
um_realm_manager_discover (self->realm_manager, "", self->cancellable,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* Show the 'Enterprise Login' stuff, and update mode */
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_show (GTK_WIDGET (self->enterprise_button));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
mode_change (self, self->mode);
|
2013-05-24 14:32:51 +02:00
|
|
|
|
g_object_unref (self);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_realmd_appeared (GDBusConnection *connection,
|
|
|
|
|
const gchar *name,
|
|
|
|
|
const gchar *name_owner,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2013-05-24 14:32:51 +02:00
|
|
|
|
um_realm_manager_new (self->cancellable, on_realm_manager_created,
|
|
|
|
|
g_object_ref (self));
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_realmd_disappeared (GDBusConnection *unused1,
|
|
|
|
|
const gchar *unused2,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-05-24 14:32:51 +02:00
|
|
|
|
clear_realm_manager (self);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_list_store_clear (self->enterprise_realm_model);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_hide (GTK_WIDGET (self->enterprise_button));
|
2018-11-07 11:56:00 +13:00
|
|
|
|
mode_change (self, MODE_LOCAL);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-04 13:49:51 +02:00
|
|
|
|
static void
|
|
|
|
|
on_network_changed (GNetworkMonitor *monitor,
|
|
|
|
|
gboolean available,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2013-07-04 13:49:51 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
if (self->mode != MODE_LOCAL)
|
|
|
|
|
mode_change (self, MODE_ENTERPRISE);
|
2013-07-04 13:49:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static gboolean
|
2018-11-07 11:56:00 +13:00
|
|
|
|
enterprise_domain_timeout (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
2013-07-23 16:52:03 +02:00
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
2014-08-09 15:12:34 +02:00
|
|
|
|
self->enterprise_domain_timeout_id = 0;
|
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
if (gtk_combo_box_get_active_iter (self->enterprise_domain_combo, &iter)) {
|
2018-11-07 14:50:58 +13:00
|
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (self->enterprise_realm_model), &iter, 1, &self->selected_realm, -1);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
set_entry_validation_checkmark (self->enterprise_domain_entry);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_label_set_text (self->enterprise_domain_hint_label, DOMAIN_DEFAULT_HINT);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
enterprise_check_domain (self);
|
|
|
|
|
}
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
enterprise_domain_combo_changed_cb (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->enterprise_domain_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->enterprise_domain_timeout_id);
|
|
|
|
|
self->enterprise_domain_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_clear_object (&self->selected_realm);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
clear_entry_validation_error (self->enterprise_domain_entry);
|
2013-07-23 16:52:03 +02:00
|
|
|
|
self->enterprise_domain_timeout_id = g_timeout_add (PASSWORD_CHECK_TIMEOUT, (GSourceFunc) enterprise_domain_timeout, self);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), FALSE);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
|
2013-11-08 13:40:17 +01:00
|
|
|
|
self->enterprise_domain_chosen = TRUE;
|
2012-06-07 00:58:27 +02:00
|
|
|
|
dialog_validate (self);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
static gboolean
|
2018-11-07 14:42:23 +13:00
|
|
|
|
enterprise_domain_combo_focus_out_event_cb (CcAddUserDialog *self)
|
2013-01-15 15:36:47 +01:00
|
|
|
|
{
|
|
|
|
|
if (self->enterprise_domain_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->enterprise_domain_timeout_id);
|
|
|
|
|
self->enterprise_domain_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->selected_realm == NULL) {
|
|
|
|
|
enterprise_check_domain (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
enterprise_login_entry_changed_cb (CcAddUserDialog *self)
|
2012-06-07 00:58:27 +02:00
|
|
|
|
{
|
2018-11-07 12:34:36 +13:00
|
|
|
|
dialog_validate (self);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->enterprise_login_entry);
|
|
|
|
|
clear_entry_validation_error (self->enterprise_password_entry);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
}
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2018-11-07 12:34:36 +13:00
|
|
|
|
static void
|
2018-11-07 14:42:23 +13:00
|
|
|
|
enterprise_password_entry_changed_cb (CcAddUserDialog *self)
|
2018-11-07 12:34:36 +13:00
|
|
|
|
{
|
2012-06-07 00:58:27 +02:00
|
|
|
|
dialog_validate (self);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
clear_entry_validation_error (self->enterprise_password_entry);
|
2012-06-07 00:58:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 23:40:32 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
dialog_validate (CcAddUserDialog *self)
|
2012-06-06 23:40:32 +02:00
|
|
|
|
{
|
|
|
|
|
gboolean valid = FALSE;
|
|
|
|
|
|
2012-06-07 00:20:29 +02:00
|
|
|
|
switch (self->mode) {
|
2018-11-07 11:56:00 +13:00
|
|
|
|
case MODE_LOCAL:
|
2012-06-07 00:20:29 +02:00
|
|
|
|
valid = local_validate (self);
|
|
|
|
|
break;
|
2018-11-07 11:56:00 +13:00
|
|
|
|
case MODE_ENTERPRISE:
|
2012-06-07 00:58:27 +02:00
|
|
|
|
valid = enterprise_validate (self);
|
2012-06-07 00:20:29 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
valid = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-06-06 23:32:31 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), valid);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-07 00:20:29 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
mode_change (CcAddUserDialog *self,
|
|
|
|
|
AccountMode mode)
|
2012-06-07 00:20:29 +02:00
|
|
|
|
{
|
2018-11-10 09:39:09 +13:00
|
|
|
|
gboolean available;
|
2013-07-04 13:49:51 +02:00
|
|
|
|
GNetworkMonitor *monitor;
|
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
if (mode != MODE_LOCAL) {
|
2013-07-04 13:49:51 +02:00
|
|
|
|
monitor = g_network_monitor_get_default ();
|
|
|
|
|
available = g_network_monitor_get_network_available (monitor);
|
2018-11-07 11:56:00 +13:00
|
|
|
|
mode = available ? MODE_ENTERPRISE : MODE_OFFLINE;
|
2013-07-04 13:49:51 +02:00
|
|
|
|
}
|
2012-06-07 00:20:29 +02:00
|
|
|
|
|
2018-11-10 09:39:09 +13:00
|
|
|
|
switch (mode) {
|
|
|
|
|
default:
|
|
|
|
|
case MODE_LOCAL:
|
|
|
|
|
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->local_grid));
|
2018-11-08 12:29:17 +13:00
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->local_name_entry));
|
2018-11-10 09:39:09 +13:00
|
|
|
|
gtk_toggle_button_set_active (self->enterprise_button, FALSE);
|
|
|
|
|
break;
|
|
|
|
|
case MODE_ENTERPRISE:
|
|
|
|
|
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->enterprise_grid));
|
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->enterprise_domain_entry));
|
|
|
|
|
gtk_toggle_button_set_active (self->enterprise_button, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
case MODE_OFFLINE:
|
|
|
|
|
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->offline_grid));
|
|
|
|
|
gtk_toggle_button_set_active (self->enterprise_button, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-06-07 00:20:29 +02:00
|
|
|
|
|
|
|
|
|
self->mode = mode;
|
|
|
|
|
dialog_validate (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 12:34:36 +13:00
|
|
|
|
enterprise_button_toggled_cb (CcAddUserDialog *self)
|
2012-06-07 00:20:29 +02:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
AccountMode mode;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
|
2018-11-07 12:34:36 +13:00
|
|
|
|
mode = gtk_toggle_button_get_active (self->enterprise_button) ? MODE_ENTERPRISE : MODE_LOCAL;
|
2013-01-15 15:36:47 +01:00
|
|
|
|
mode_change (self, mode);
|
2012-06-07 00:20:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 21:43:57 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
cc_add_user_dialog_init (CcAddUserDialog *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-11-07 14:21:49 +13:00
|
|
|
|
GNetworkMonitor *monitor;
|
|
|
|
|
|
2016-06-10 11:34:05 +02:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
self->cancellable = g_cancellable_new ();
|
|
|
|
|
|
2018-11-07 14:21:49 +13:00
|
|
|
|
self->local_password_mode = ACT_USER_PASSWORD_MODE_SET_AT_LOGIN;
|
|
|
|
|
dialog_validate (self);
|
|
|
|
|
update_password_strength (self);
|
|
|
|
|
|
|
|
|
|
enterprise_check_domain (self);
|
|
|
|
|
|
|
|
|
|
self->realmd_watch = g_bus_watch_name (G_BUS_TYPE_SYSTEM, "org.freedesktop.realmd",
|
|
|
|
|
G_BUS_NAME_WATCHER_FLAGS_AUTO_START,
|
|
|
|
|
on_realmd_appeared, on_realmd_disappeared,
|
|
|
|
|
self, NULL);
|
|
|
|
|
|
|
|
|
|
monitor = g_network_monitor_get_default ();
|
|
|
|
|
g_signal_connect_object (monitor, "network-changed", G_CALLBACK (on_network_changed), self, 0);
|
|
|
|
|
|
2016-06-10 11:46:23 +02:00
|
|
|
|
join_init (self);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
|
|
|
|
|
mode_change (self, MODE_LOCAL);
|
2012-06-06 21:43:57 +02:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2013-04-18 17:50:42 +02:00
|
|
|
|
static void
|
|
|
|
|
on_permission_acquired (GObject *source_object,
|
|
|
|
|
GAsyncResult *res,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (user_data);
|
2018-11-08 12:21:36 +13:00
|
|
|
|
GError *error = NULL;
|
2013-04-18 17:50:42 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
/* Paired with begin_action in cc_add_user_dialog_response () */
|
2018-11-08 12:21:36 +13:00
|
|
|
|
finish_action (self);
|
2013-04-18 17:50:42 +02:00
|
|
|
|
|
2018-11-08 12:21:36 +13:00
|
|
|
|
if (g_permission_acquire_finish (self->permission, res, &error)) {
|
|
|
|
|
g_return_if_fail (g_permission_get_allowed (self->permission));
|
2018-11-07 16:05:32 +13:00
|
|
|
|
add_button_clicked_cb (self);
|
2018-11-08 12:21:36 +13:00
|
|
|
|
} else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
|
|
|
|
g_warning ("Failed to acquire permission: %s", error->message);
|
|
|
|
|
}
|
2013-04-18 17:50:42 +02:00
|
|
|
|
|
2018-11-08 12:21:36 +13:00
|
|
|
|
g_clear_error (&error);
|
|
|
|
|
g_object_unref (self);
|
2013-04-18 17:50:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 21:43:57 +02:00
|
|
|
|
static void
|
2018-11-07 16:05:32 +13:00
|
|
|
|
add_button_clicked_cb (CcAddUserDialog *self)
|
2012-06-06 21:43:57 +02:00
|
|
|
|
{
|
2018-11-07 16:05:32 +13:00
|
|
|
|
/* We don't (or no longer) have necessary permissions */
|
|
|
|
|
if (self->permission && !g_permission_get_allowed (self->permission)) {
|
|
|
|
|
begin_action (self);
|
|
|
|
|
g_permission_acquire_async (self->permission, self->cancellable,
|
|
|
|
|
on_permission_acquired, g_object_ref (self));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-04-18 17:50:42 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
switch (self->mode) {
|
|
|
|
|
case MODE_LOCAL:
|
|
|
|
|
local_create_user (self);
|
2012-06-06 21:43:57 +02:00
|
|
|
|
break;
|
2018-11-07 16:05:32 +13:00
|
|
|
|
case MODE_ENTERPRISE:
|
|
|
|
|
enterprise_add_user (self);
|
2012-06-06 21:43:57 +02:00
|
|
|
|
break;
|
2018-11-07 16:05:32 +13:00
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
2012-06-06 21:43:57 +02:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 22:51:19 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
cc_add_user_dialog_dispose (GObject *obj)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (obj);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
if (self->cancellable)
|
|
|
|
|
g_cancellable_cancel (self->cancellable);
|
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
g_clear_object (&self->user);
|
|
|
|
|
|
2012-06-07 00:58:27 +02:00
|
|
|
|
if (self->realmd_watch)
|
|
|
|
|
g_bus_unwatch_name (self->realmd_watch);
|
|
|
|
|
self->realmd_watch = 0;
|
|
|
|
|
|
|
|
|
|
if (self->realm_manager) {
|
|
|
|
|
g_signal_handlers_disconnect_by_func (self->realm_manager,
|
|
|
|
|
on_manager_realm_added,
|
|
|
|
|
self);
|
|
|
|
|
g_object_unref (self->realm_manager);
|
|
|
|
|
self->realm_manager = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->local_password_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_password_timeout_id);
|
|
|
|
|
self->local_password_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-23 16:52:03 +02:00
|
|
|
|
if (self->local_name_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_name_timeout_id);
|
|
|
|
|
self->local_name_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-15 15:36:47 +01:00
|
|
|
|
if (self->local_username_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->local_username_timeout_id);
|
|
|
|
|
self->local_username_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self->enterprise_domain_timeout_id != 0) {
|
|
|
|
|
g_source_remove (self->enterprise_domain_timeout_id);
|
|
|
|
|
self->enterprise_domain_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-15 15:11:09 +02:00
|
|
|
|
g_clear_pointer ((GtkWidget **)&self->join_dialog, gtk_widget_destroy);
|
2013-09-17 18:04:57 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
G_OBJECT_CLASS (cc_add_user_dialog_parent_class)->dispose (obj);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
cc_add_user_dialog_finalize (GObject *obj)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *self = CC_ADD_USER_DIALOG (obj);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
if (self->cancellable)
|
|
|
|
|
g_object_unref (self->cancellable);
|
2013-04-18 17:50:42 +02:00
|
|
|
|
g_clear_object (&self->permission);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
G_OBJECT_CLASS (cc_add_user_dialog_parent_class)->finalize (obj);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-06 21:43:57 +02:00
|
|
|
|
static void
|
2018-11-07 11:56:00 +13:00
|
|
|
|
cc_add_user_dialog_class_init (CcAddUserDialogClass *klass)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-06-06 22:51:19 +02:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2016-06-10 11:34:05 +02:00
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2012-06-06 21:43:57 +02:00
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
object_class->dispose = cc_add_user_dialog_dispose;
|
|
|
|
|
object_class->finalize = cc_add_user_dialog_finalize;
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/user-accounts/cc-add-user-dialog.ui");
|
2018-11-07 11:56:00 +13:00
|
|
|
|
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, add_button);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_button);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_domain_combo);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_domain_entry);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_domain_hint_label);
|
2018-11-10 09:39:09 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_grid);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_hint_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_login_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_password_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, enterprise_realm_model);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_account_type_standard);
|
2018-11-10 09:39:09 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_grid);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_hint_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_name_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_combo);
|
2018-11-07 14:50:58 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_model);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_entry);
|
2018-11-07 11:56:00 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_password_radio);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_entry);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_username_hint_label);
|
2018-11-07 11:56:00 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_strength_indicator);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_verify_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, local_verify_hint_label);
|
2018-11-10 09:39:09 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, offline_grid);
|
2018-11-07 11:56:00 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, spinner);
|
2018-11-07 12:19:01 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcAddUserDialog, stack);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, add_button_clicked_cb);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, dialog_validate);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, enterprise_button_toggled_cb);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, enterprise_domain_combo_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, enterprise_domain_combo_focus_out_event_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, enterprise_login_entry_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, enterprise_password_entry_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_name_entry_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_name_entry_focus_out_event_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_password_entry_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_password_entry_icon_press_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_password_entry_key_press_event_cb);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_password_radio_changed_cb);
|
2018-11-07 14:42:23 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_username_combo_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_username_combo_focus_out_event_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, local_verify_entry_changed_cb);
|
2018-11-07 12:34:36 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, password_focus_out_event_cb);
|
2018-11-07 11:56:00 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CcAddUserDialog *
|
2018-11-07 16:05:32 +13:00
|
|
|
|
cc_add_user_dialog_new (GPermission *permission)
|
2018-11-07 11:56:00 +13:00
|
|
|
|
{
|
2018-11-07 16:05:32 +13:00
|
|
|
|
CcAddUserDialog *self;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
self = g_object_new (CC_TYPE_ADD_USER_DIALOG, "use-header-bar", TRUE, NULL);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
if (permission != NULL)
|
|
|
|
|
self->permission = g_object_ref (permission);
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
return self;
|
2012-06-06 22:51:19 +02:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *
|
2018-11-07 16:05:32 +13:00
|
|
|
|
cc_add_user_dialog_get_user (CcAddUserDialog *self)
|
2012-06-06 22:51:19 +02:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
g_return_val_if_fail (CC_IS_ADD_USER_DIALOG (self), NULL);
|
2018-11-07 16:05:32 +13:00
|
|
|
|
return self->user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|