diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-09-22 12:32:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:01 -0500 |
commit | 369a5d64e462e084e6c5fe4984d56da18b2c92d9 (patch) | |
tree | 815e7a10696ef40205c1e16c4e01b660a7a8f0b7 /source4/gtk/tools | |
parent | bc8ef3d1b6bfdf279d65783869b9a247c1da38aa (diff) | |
download | samba-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/tools')
-rw-r--r-- | source4/gtk/tools/gregedit.c | 97 | ||||
-rw-r--r-- | source4/gtk/tools/gwsam.c | 36 |
2 files changed, 75 insertions, 58 deletions
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, ®istry); + error = reg_open(®istry, 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, ®istry); + WERROR error = reg_open(®istry, "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, ®istry); - 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(®istry, "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, ®istry); + error = reg_open(®istry, 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); |