summaryrefslogtreecommitdiff
path: root/source4/gtk
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-09-22 12:32:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:01 -0500
commit369a5d64e462e084e6c5fe4984d56da18b2c92d9 (patch)
tree815e7a10696ef40205c1e16c4e01b660a7a8f0b7 /source4/gtk
parentbc8ef3d1b6bfdf279d65783869b9a247c1da38aa (diff)
downloadsamba-369a5d64e462e084e6c5fe4984d56da18b2c92d9.tar.gz
samba-369a5d64e462e084e6c5fe4984d56da18b2c92d9.tar.bz2
samba-369a5d64e462e084e6c5fe4984d56da18b2c92d9.zip
r2518: Some long overdue changes:
- Samba4-style code in lib/registry (struct registry_key instead of REG_KEY, etc) - Use hives (like Windows has drives) instead of one root key (like a Unix FS) - usability fixes in the GTK utilities (autodetect the username, enable/disable options, etc) - fix gwsam compile - several bugfixes in the registry rpc code - do charset conversion in nt4 registry backend (This used to be commit 2762ed3b9bf1d67dd54d63e02cddbfd71ea89892)
Diffstat (limited to 'source4/gtk')
-rw-r--r--source4/gtk/common/gtk-smb.c30
-rw-r--r--source4/gtk/common/gtk-smb.h1
-rw-r--r--source4/gtk/config.m43
-rw-r--r--source4/gtk/tools/gregedit.c97
-rw-r--r--source4/gtk/tools/gwsam.c36
5 files changed, 102 insertions, 65 deletions
diff --git a/source4/gtk/common/gtk-smb.c b/source4/gtk/common/gtk-smb.c
index cc7013edc7..2348661cb7 100644
--- a/source4/gtk/common/gtk-smb.c
+++ b/source4/gtk/common/gtk-smb.c
@@ -55,6 +55,11 @@ static void on_browse_activate (GtkButton *button, gpointer user_d
gtk_widget_destroy(GTK_WIDGET(shd));
}
+static void on_krb5_toggled(GtkToggleButton *togglebutton, GtkRpcBindingDialog *d)
+{
+ gtk_widget_set_sensitive(d->entry_password, !gtk_toggle_button_get_active(togglebutton));
+}
+
static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_dialog)
{
GtkWidget *dialog_vbox1;
@@ -75,7 +80,6 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di
GtkWidget *lbl_password;
GtkWidget *btn_browse;
GtkWidget *label9;
- GtkWidget *chk_button;
GtkWidget *lbl_credentials;
GtkWidget *dialog_action_area1;
GtkWidget *btn_cancel;
@@ -138,7 +142,7 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di
gtk_widget_show (btn_browse);
gtk_box_pack_start (GTK_BOX (hbox1), btn_browse, TRUE, TRUE, 0);
- g_signal_connect ((gpointer) btn_browse, "pressed",
+ g_signal_connect ((gpointer) btn_browse, "pressed",
G_CALLBACK (on_browse_activate),
gtk_rpc_binding_dialog);
@@ -208,12 +212,23 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
- chk_button = gtk_check_button_new_with_mnemonic ("_Use kerberos");
- gtk_widget_show (chk_button);
- gtk_table_attach (GTK_TABLE (table1), chk_button, 1, 2, 2, 3,
+ gtk_entry_set_text(GTK_ENTRY(gtk_rpc_binding_dialog->entry_username), getenv("LOGNAME"));
+
+ gtk_rpc_binding_dialog->krb5_chk_button = gtk_check_button_new_with_mnemonic ("_Use kerberos");
+ gtk_widget_show (gtk_rpc_binding_dialog->krb5_chk_button);
+ gtk_table_attach (GTK_TABLE (table1), gtk_rpc_binding_dialog->krb5_chk_button, 1, 2, 2, 3,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
+ g_signal_connect ((gpointer) gtk_rpc_binding_dialog->krb5_chk_button, "toggled",
+ G_CALLBACK (on_krb5_toggled),
+ gtk_rpc_binding_dialog);
+
+ /* Poor man's autodetection */
+ if(getenv("KRB5CCNAME")) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_rpc_binding_dialog->krb5_chk_button), TRUE);
+ }
+
lbl_credentials = gtk_label_new ("Credentials");
gtk_widget_show (lbl_credentials);
gtk_frame_set_label_widget (GTK_FRAME (frame_credentials), lbl_credentials);
@@ -278,6 +293,11 @@ const char *gtk_rpc_binding_dialog_get_password(GtkRpcBindingDialog *d)
return gtk_entry_get_text(GTK_ENTRY(d->entry_password));
}
+const char *gtk_rpc_binding_dialog_get_host(GtkRpcBindingDialog *d)
+{
+ return gtk_entry_get_text(GTK_ENTRY(d->entry_host));
+}
+
const char *gtk_rpc_binding_dialog_get_binding(GtkRpcBindingDialog *d, char *pipe_name)
{
const char *transport;
diff --git a/source4/gtk/common/gtk-smb.h b/source4/gtk/common/gtk-smb.h
index e9b62d94da..0f34bb3249 100644
--- a/source4/gtk/common/gtk-smb.h
+++ b/source4/gtk/common/gtk-smb.h
@@ -38,6 +38,7 @@ struct _GtkRpcBindingDialog
GtkWidget *entry_host;
GtkWidget *entry_username;
GtkWidget *entry_password;
+ GtkWidget *krb5_chk_button;
TALLOC_CTX *mem_ctx;
};
diff --git a/source4/gtk/config.m4 b/source4/gtk/config.m4
index 05e7377860..757ce59c07 100644
--- a/source4/gtk/config.m4
+++ b/source4/gtk/config.m4
@@ -10,8 +10,7 @@ if test t$SMB_EXT_LIB_ENABLE_gtk = tYES; then
SMB_SUBSYSTEM_ENABLE(GTKSMB, YES)
SMB_BINARY_ENABLE(gregedit, YES)
SMB_BINARY_ENABLE(gwcrontab, YES)
- # this break the build on my SuSE 9.1 --metze
- #SMB_BINARY_ENABLE(gwsam, YES)
+ SMB_BINARY_ENABLE(gwsam, YES)
AC_DEFINE(HAVE_GTK, 1, [Whether GTK+ is available])
fi
diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c
index 3297399b67..8938e634fa 100644
--- a/source4/gtk/tools/gregedit.c
+++ b/source4/gtk/tools/gregedit.c
@@ -28,17 +28,18 @@ GtkTreeStore *store_keys;
GtkListStore *store_vals;
GtkWidget *tree_keys;
GtkWidget *mainwin;
+TALLOC_CTX *mem_ctx; /* FIXME: Split up */
GtkWidget *save;
GtkWidget *save_as;
static GtkWidget* create_openfilewin (void);
static GtkWidget* create_savefilewin (void);
-REG_HANDLE *registry = NULL;
+struct registry_context *registry = NULL;
static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *arg2)
{
GtkTreeIter firstiter, iter, tmpiter;
- REG_KEY *k, *sub;
+ struct registry_key *k, *sub;
char *name;
WERROR error;
int i;
@@ -55,7 +56,7 @@ static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *
g_assert(k);
- for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(k, i, &sub)); i++) {
+ for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(mem_ctx, k, i, &sub)); i++) {
int count;
/* Replace the blank child with the first directory entry
You may be tempted to remove the blank child node and then
@@ -70,7 +71,7 @@ static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *
gtk_tree_store_set (store_keys,
&iter,
0,
- reg_key_name(sub),
+ sub->name,
1,
sub,
-1);
@@ -84,36 +85,28 @@ static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *
static void registry_load_root()
{
- REG_KEY *root;
+ struct registry_key *root;
GtkTreeIter iter, tmpiter;
- WERROR error = WERR_OK;
int i = 0;
if(!registry) return;
gtk_tree_store_clear(store_keys);
- while(1) {
- error = reg_get_hive(registry, i, &root);
- if(W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) {
- return;
- }
- if(!W_ERROR_IS_OK(error)) {
- gtk_show_werror(mainwin, error);
- return;
- }
+ for(i = 0; i < registry->num_hives; i++)
+ {
+ root = registry->hives[i]->root;
/* Add the root */
gtk_tree_store_append(store_keys, &iter, NULL);
gtk_tree_store_set (store_keys,
&iter,
0,
- reg_key_name(root),
+ root->hive->name,
1,
root,
-1);
gtk_tree_store_append(store_keys, &tmpiter, &iter);
- i++;
}
gtk_widget_set_sensitive( save, True );
@@ -123,16 +116,20 @@ static void registry_load_root()
static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
{
gint result = gtk_dialog_run(GTK_DIALOG(create_openfilewin()));
- char *filename;
+ char *filename, *tmp;
WERROR error;
switch(result) {
case GTK_RESPONSE_OK:
filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(openfilewin)));
- error = reg_open(user_data, filename, NULL, &registry);
+ error = reg_open(&registry, user_data, filename, NULL);
if(!W_ERROR_IS_OK(error)) {
gtk_show_werror(mainwin, error);
break;
}
+
+ tmp = g_strdup_printf("Registry Editor - %s", filename);
+ gtk_window_set_title (GTK_WINDOW (mainwin), tmp);
+ g_free(tmp);
registry_load_root();
break;
default:
@@ -145,12 +142,14 @@ static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
static void on_open_gconf_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
- WERROR error = reg_open("gconf", NULL, NULL, &registry);
+ WERROR error = reg_open(&registry, "gconf", NULL, NULL);
if(!W_ERROR_IS_OK(error)) {
gtk_show_werror(mainwin, error);
return;
}
+ gtk_window_set_title (GTK_WINDOW (mainwin), "Registry Editor - GConf");
+
registry_load_root();
}
@@ -158,31 +157,41 @@ static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data)
{
char *credentials;
const char *location;
+ char *tmp;
GtkWidget *rpcwin = GTK_WIDGET(gtk_rpc_binding_dialog_new(TRUE));
gint result = gtk_dialog_run(GTK_DIALOG(rpcwin));
WERROR error;
- switch(result) {
- case GTK_RESPONSE_ACCEPT:
- location = gtk_rpc_binding_dialog_get_binding(GTK_RPC_BINDING_DIALOG(rpcwin), NULL);
- asprintf(&credentials, "%s%%%s", gtk_rpc_binding_dialog_get_username(GTK_RPC_BINDING_DIALOG(rpcwin)), gtk_rpc_binding_dialog_get_password(GTK_RPC_BINDING_DIALOG(rpcwin)));
- error = reg_open("rpc", location, credentials, &registry);
- if(!W_ERROR_IS_OK(error)) {
- gtk_show_werror(mainwin, error);
- break;
- }
- free(credentials);
- registry_load_root();
- break;
- default:
- break;
+
+ if(result != GTK_RESPONSE_ACCEPT)
+ {
+ gtk_widget_destroy(rpcwin);
+ return;
+ }
+
+ location = gtk_rpc_binding_dialog_get_binding(GTK_RPC_BINDING_DIALOG(rpcwin), NULL);
+ asprintf(&credentials, "%s%%%s", gtk_rpc_binding_dialog_get_username(GTK_RPC_BINDING_DIALOG(rpcwin)), gtk_rpc_binding_dialog_get_password(GTK_RPC_BINDING_DIALOG(rpcwin)));
+ error = reg_open(&registry, "rpc", location, credentials);
+
+ if(!W_ERROR_IS_OK(error)) {
+ gtk_show_werror(mainwin, error);
+ gtk_widget_destroy(rpcwin);
+ return;
}
+ free(credentials);
+
+ tmp = g_strdup_printf("Registry Editor - Remote Registry at %s", gtk_rpc_binding_dialog_get_host(GTK_RPC_BINDING_DIALOG(rpcwin)));
+ gtk_window_set_title (GTK_WINDOW (mainwin), tmp);
+ g_free(tmp);
+
+ registry_load_root();
+
gtk_widget_destroy(rpcwin);
}
static void on_save_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+ gpointer user_data)
{
WERROR error = reg_save(registry, NULL);
if(!W_ERROR_IS_OK(error)) {
@@ -264,8 +273,8 @@ gboolean on_key_activate(GtkTreeSelection *selection,
gpointer data)
{
int i;
- REG_KEY *k;
- REG_VAL *val;
+ struct registry_key *k;
+ struct registry_value *val;
WERROR error;
GtkTreeIter parent;
if(path_currently_selected)return TRUE;
@@ -277,17 +286,17 @@ gboolean on_key_activate(GtkTreeSelection *selection,
gtk_list_store_clear(store_vals);
- for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(k, i, &val)); i++) {
+ for(i = 0; W_ERROR_IS_OK(error = reg_key_get_value_by_index(mem_ctx, k, i, &val)); i++) {
GtkTreeIter iter;
gtk_list_store_append(store_vals, &iter);
gtk_list_store_set (store_vals,
&iter,
0,
- reg_val_name(val),
+ val->name,
1,
- str_regtype(reg_val_type(val)),
+ str_regtype(val->data_type),
2,
- reg_val_data_string(val),
+ reg_val_data_string(mem_ctx, val),
3,
val,
-1);
@@ -607,6 +616,7 @@ static GtkWidget* create_savefilewin (void)
load_interfaces();
gtk_init (&argc, &argv);
+ mem_ctx = talloc_init("gregedit");
pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0);
@@ -623,7 +633,7 @@ static GtkWidget* create_savefilewin (void)
else backend = "nt4";
}
- error = reg_open(backend, location, credentials, &registry);
+ error = reg_open(&registry, backend, location, credentials);
if(!W_ERROR_IS_OK(error)) {
gtk_show_werror(mainwin, error);
return -1;
@@ -638,6 +648,7 @@ static GtkWidget* create_savefilewin (void)
gtk_main ();
- if(registry)reg_free(registry);
+ if(registry)talloc_destroy(registry->mem_ctx);
+ talloc_destroy(mem_ctx);
return 0;
}
diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c
index 31bbf002de..2f0a8e300c 100644
--- a/source4/gtk/tools/gwsam.c
+++ b/source4/gtk/tools/gwsam.c
@@ -39,13 +39,12 @@ void update_userlist(void)
struct samr_EnumDomainUsers r;
uint32_t resume_handle=0;
int i;
- BOOL ret = True;
TALLOC_CTX *mem_ctx;
if(!sam_pipe) return;
mem_ctx = talloc_init("update_userlist");
- r.in.handle = &domain_handle;
+ r.in.domain_handle = &domain_handle;
r.in.resume_handle = &resume_handle;
r.in.acct_flags = 0;
r.in.max_size = (uint32_t)-1;
@@ -87,7 +86,7 @@ on_select_domain_activate (GtkMenuItem *menuitem,
{
GtkSelectDomainDialog *d;
gint result;
- d = gtk_select_domain_dialog_new(sam_pipe);
+ d = GTK_SELECT_DOMAIN_DIALOG(gtk_select_domain_dialog_new(sam_pipe));
result = gtk_dialog_run(GTK_DIALOG(d));
switch(result) {
case GTK_RESPONSE_ACCEPT:
@@ -129,7 +128,7 @@ void on_connect_activate (GtkMenuItem *menuitem, gpointer user_data)
r.in.system_name = 0;
r.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
- r.out.handle = &sam_handle;
+ r.out.connect_handle = &sam_handle;
mem_ctx = talloc_init("connect");
status = dcerpc_samr_Connect(sam_pipe, mem_ctx, &r);
@@ -218,13 +217,7 @@ create_mainwindow (void)
GtkWidget *new1;
GtkWidget *separatormenuitem1;
GtkWidget *quit;
- GtkWidget *menuitem2;
GtkWidget *seldomain;
- GtkWidget *menuitem2_menu;
- GtkWidget *cut1;
- GtkWidget *copy1;
- GtkWidget *paste1;
- GtkWidget *delete1;
GtkWidget *policies;
GtkWidget *policies_menu;
GtkWidget *account;
@@ -260,23 +253,20 @@ create_mainwindow (void)
gtk_widget_show (menubar);
gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 0);
- menuitem1 = gtk_menu_item_new_with_mnemonic ("_User");
+ menuitem1 = gtk_menu_item_new_with_mnemonic ("_File");
gtk_widget_show (menuitem1);
gtk_container_add (GTK_CONTAINER (menubar), menuitem1);
menuitem1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);
- new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
- gtk_widget_show (new1);
- gtk_container_add (GTK_CONTAINER (menuitem1_menu), new1);
-
connect = gtk_menu_item_new_with_mnemonic ("_Connect");
gtk_widget_show (connect);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), connect);
seldomain = gtk_menu_item_new_with_mnemonic("_Select Domain");
gtk_widget_show(seldomain);
+ gtk_widget_set_sensitive (seldomain, FALSE);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), seldomain);
separatormenuitem1 = gtk_separator_menu_item_new ();
@@ -288,9 +278,24 @@ create_mainwindow (void)
gtk_widget_show (quit);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit);
+ menuitem1 = gtk_menu_item_new_with_mnemonic ("_User");
+ gtk_widget_show (menuitem1);
+ gtk_container_add (GTK_CONTAINER (menubar), menuitem1);
+ gtk_widget_set_sensitive (menuitem1, FALSE);
+
+ menuitem1_menu = gtk_menu_new ();
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);
+
+ new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
+ gtk_widget_show (new1);
+ gtk_container_add (GTK_CONTAINER (menuitem1_menu), new1);
+
+
+
policies = gtk_menu_item_new_with_mnemonic ("_Policies");
gtk_widget_show (policies);
gtk_container_add (GTK_CONTAINER (menubar), policies);
+ gtk_widget_set_sensitive (policies, FALSE);
policies_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (policies), policies_menu);
@@ -326,6 +331,7 @@ create_mainwindow (void)
refresh = gtk_image_menu_item_new_from_stock ("gtk-refresh", accel_group);
gtk_widget_show (refresh);
gtk_container_add (GTK_CONTAINER (menuitem3_menu), refresh);
+ gtk_widget_set_sensitive (refresh, FALSE);
menuitem4 = gtk_menu_item_new_with_mnemonic ("_Help");
gtk_widget_show (menuitem4);