summaryrefslogtreecommitdiff
path: root/source4/gtk/tools
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-05-03 09:11:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:05:33 -0500
commit86a2f18b964c358eb8c8d59381be5eb5962f3b4b (patch)
treef6809775428c2ee956d976d73ec8768025f236f0 /source4/gtk/tools
parent37aa2c5e8ff628d8ad51497a165da8a58cb2d1f5 (diff)
downloadsamba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.tar.gz
samba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.tar.bz2
samba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.zip
r15408: Fix some small bugs in the GTK+ tools
Add utility function for connection to an interface (This used to be commit 266f7472209e6ae4f70688cf06b8efa63d036d04)
Diffstat (limited to 'source4/gtk/tools')
-rw-r--r--source4/gtk/tools/gepdump.c41
-rw-r--r--source4/gtk/tools/gwcrontab.c70
-rw-r--r--source4/gtk/tools/gwsam.c104
-rw-r--r--source4/gtk/tools/gwsam_user.c4
4 files changed, 88 insertions, 131 deletions
diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c
index 5f7f346838..ccfcf1f5a6 100644
--- a/source4/gtk/tools/gepdump.c
+++ b/source4/gtk/tools/gepdump.c
@@ -23,6 +23,7 @@
#include "librpc/gen_ndr/ndr_epmapper_c.h"
#include "librpc/gen_ndr/ndr_mgmt_c.h"
#include "gtk/common/gtk-smb.h"
+#include "gtk/common/select.h"
#include "auth/gensec/gensec.h"
/*
@@ -166,40 +167,14 @@ static void on_refresh_clicked (GtkButton *btn, gpointer user_data)
refresh_eps();
}
-static void on_connect_clicked(GtkButton *btn, gpointer user_data)
+static void on_connect_clicked(GtkButton *btn, gpointer user_data)
{
- GtkRpcBindingDialog *d;
- const char *bs;
- TALLOC_CTX *mem_ctx;
NTSTATUS status;
- gint result;
- struct cli_credentials *credentials;
-
- d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(NULL));
- result = gtk_dialog_run(GTK_DIALOG(d));
- switch(result) {
- case GTK_RESPONSE_ACCEPT:
- break;
- default:
- gtk_widget_destroy(GTK_WIDGET(d));
- return;
- }
-
- mem_ctx = talloc_init("connect");
- bs = gtk_rpc_binding_dialog_get_binding_string (d, mem_ctx);
-
- credentials = cli_credentials_init(mem_ctx);
- cli_credentials_guess(credentials);
- cli_credentials_set_gtk_callbacks(credentials);
+ TALLOC_CTX *mem_ctx = talloc_init("connect");
- status = dcerpc_pipe_connect(talloc_autofree_context(), &epmapper_pipe, bs,
- &dcerpc_table_epmapper,
- credentials, NULL);
-
- if (NT_STATUS_IS_ERR(status)) {
- gtk_show_ntstatus(mainwin, "Error connecting to endpoint mapper", status);
- goto fail;
- }
+ epmapper_pipe = gtk_connect_rpc_interface(mem_ctx, &dcerpc_table_epmapper);
+ if (epmapper_pipe == NULL)
+ return;
gtk_widget_set_sensitive( mnu_refresh, True );
@@ -210,11 +185,7 @@ static void on_connect_clicked(GtkButton *btn, gpointer user_data)
if (NT_STATUS_IS_ERR(status)) {
mgmt_pipe = NULL;
gtk_show_ntstatus(NULL, "Error connecting to mgmt interface over secondary connection", status);
- goto fail;
}
-
-fail:
- gtk_widget_destroy(GTK_WIDGET(d));
}
static gboolean on_eps_select(GtkTreeSelection *selection,
diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c
index 821787e5e3..fe21248363 100644
--- a/source4/gtk/tools/gwcrontab.c
+++ b/source4/gtk/tools/gwcrontab.c
@@ -22,12 +22,14 @@
#include "includes.h"
#include "librpc/gen_ndr/ndr_atsvc_c.h"
#include "gtk/common/gtk-smb.h"
+#include "gtk/common/select.h"
#include "auth/credentials/credentials.h"
static struct dcerpc_pipe *at_pipe = NULL;
static GtkWidget *mainwin;
static GtkListStore *store_jobs;
static GtkWidget *tasks;
+static GtkWidget *new_task;
static GtkWidget *entry_cmd;
static GtkWidget *entry_repeat_weekly;
static GtkWidget *entry_repeat_monthly;
@@ -70,7 +72,6 @@ static void update_joblist(void)
}
talloc_free(mem_ctx);
- gtk_widget_set_sensitive(tasks, TRUE);
}
static void on_job_select(GtkTreeSelection *sel, gpointer data)
@@ -81,45 +82,12 @@ static void on_job_select(GtkTreeSelection *sel, gpointer data)
static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- GtkRpcBindingDialog *d;
- NTSTATUS status;
- struct cli_credentials *credentials;
- gint result;
- TALLOC_CTX *mem_ctx;
+ at_pipe = gtk_connect_rpc_interface(talloc_autofree_context(), &dcerpc_table_atsvc);
- d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(NULL));
- result = gtk_dialog_run(GTK_DIALOG(d));
- switch(result) {
- case GTK_RESPONSE_ACCEPT:
- break;
- default:
- gtk_widget_destroy(GTK_WIDGET(d));
+ if (!at_pipe)
return;
- }
-
- mem_ctx = talloc_init("gwcrontab_connect");
- /* If connected, get list of jobs */
-
- credentials = cli_credentials_init(mem_ctx);
- cli_credentials_guess(credentials);
- cli_credentials_set_gtk_callbacks(credentials);
-
- status = dcerpc_pipe_connect_b(mem_ctx, &at_pipe,
- gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
- &dcerpc_table_atsvc,
- credentials, NULL);
- if(!NT_STATUS_IS_OK(status)) {
- gtk_show_ntstatus(mainwin, "Error while connecting to at service", status);
- at_pipe = NULL;
- gtk_widget_destroy(GTK_WIDGET(d));
- talloc_free(mem_ctx);
- return;
- }
- gtk_widget_destroy(GTK_WIDGET(d));
-
- at_pipe = talloc_reference(talloc_autofree_context(), at_pipe);
- talloc_free(mem_ctx);
+ gtk_widget_set_sensitive (new_task, TRUE);
update_joblist();
}
@@ -129,12 +97,9 @@ static void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data)
gtk_main_quit();
}
-
static GtkWidget* create_new_job_dialog (void);
-void
-on_new_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void on_new_activate (GtkMenuItem *menuitem, gpointer user_data)
{
GtkWidget *d = create_new_job_dialog();
gint result = gtk_dialog_run(GTK_DIALOG(d));
@@ -176,9 +141,7 @@ on_new_activate (GtkMenuItem *menuitem,
}
-void
-on_delete_activate (GtkMenuItem *menuitem,
- gpointer user_data)
+void on_delete_activate(GtkMenuItem *menuitem, gpointer user_data)
{
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tasks));
GtkTreeModel *model = GTK_TREE_MODEL(store_jobs);
@@ -227,7 +190,6 @@ static GtkWidget* create_mainwindow (void)
GtkWidget *quit;
GtkWidget *task;
GtkWidget *task_menu;
- GtkWidget *new;
GtkCellRenderer *renderer;
GtkTreeViewColumn *curcol;
GtkWidget *menuitem7;
@@ -273,8 +235,9 @@ static GtkWidget* create_mainwindow (void)
task_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (task), task_menu);
- new = gtk_menu_item_new_with_mnemonic ("_New");
- gtk_container_add (GTK_CONTAINER (task_menu), new);
+ new_task = gtk_menu_item_new_with_mnemonic ("_New");
+ gtk_container_add (GTK_CONTAINER (task_menu), new_task);
+ gtk_widget_set_sensitive (new_task, FALSE);
delete = gtk_menu_item_new_with_mnemonic ("_Delete");
gtk_widget_set_sensitive(delete, FALSE);
@@ -343,7 +306,7 @@ static GtkWidget* create_mainwindow (void)
g_signal_connect ((gpointer) quit, "activate",
G_CALLBACK (on_quit_activate), NULL);
- g_signal_connect ((gpointer) new, "activate",
+ g_signal_connect ((gpointer) new_task, "activate",
G_CALLBACK (on_new_activate), NULL);
g_signal_connect ((gpointer) delete, "activate",
G_CALLBACK (on_delete_activate), NULL);
@@ -351,28 +314,23 @@ static GtkWidget* create_mainwindow (void)
G_CALLBACK (on_about_activate), NULL);
gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group);
- gtk_widget_set_sensitive(tasks, FALSE);
return mainwindow;
}
-void
-on_chk_weekly_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+void on_chk_weekly_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
gtk_widget_set_sensitive(entry_repeat_weekly, gtk_toggle_button_get_active(togglebutton));
}
-void
-on_chk_monthly_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
+void on_chk_monthly_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
gtk_widget_set_sensitive(entry_repeat_monthly, gtk_toggle_button_get_active(togglebutton));
}
-static GtkWidget*create_new_job_dialog (void)
+static GtkWidget *create_new_job_dialog (void)
{
GtkWidget *new_job_dialog;
GtkWidget *dialog_vbox1;
diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c
index d788dfd459..40331bfd09 100644
--- a/source4/gtk/tools/gwsam.c
+++ b/source4/gtk/tools/gwsam.c
@@ -30,6 +30,8 @@ struct dcerpc_pipe *sam_pipe = NULL;
static struct policy_handle domain_handle;
GtkWidget *mainwin;
GtkWidget *seldomain;
+GtkListStore *store_users;
+GtkListStore *store_groups;
static GtkWidget *mnu_disconnect;
static void update_grouplist(void)
@@ -48,11 +50,13 @@ static void update_userlist(void)
if(!sam_pipe) return;
+ gtk_list_store_clear(store_users);
+
mem_ctx = talloc_init("update_userlist");
r.in.domain_handle = &domain_handle;
r.in.resume_handle = &resume_handle;
r.in.acct_flags = 0;
- r.in.max_size = (uint32_t)-1;
+ r.in.max_size = (uint32_t)100;
r.out.resume_handle = &resume_handle;
status = dcerpc_samr_EnumDomainUsers(sam_pipe, mem_ctx, &r);
@@ -68,7 +72,13 @@ static void update_userlist(void)
}
for (i=0;i<r.out.sam->count;i++) {
- printf("Found: %s\n", r.out.sam->entries[i].name.string);
+ GtkTreeIter iter;
+ gtk_list_store_append(store_users, &iter);
+ gtk_list_store_set (store_users, &iter,
+ 0, r.out.sam->entries[i].name.string,
+ 1, r.out.sam->entries[i].name.string,
+ 2, 0, -1);
+
/* FIXME: Query user info */
// if (!test_OpenUser(sam_pipe, mem_ctx, &sam_handle, r.out.sam->entries[i].idx)) {
@@ -80,7 +90,7 @@ static void update_userlist(void)
static void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
-
+ /* FIXME */
}
static void on_select_domain_activate(GtkMenuItem *menuitem, gpointer user_data)
@@ -106,40 +116,16 @@ static void on_select_domain_activate(GtkMenuItem *menuitem, gpointer user_data)
static void connect_sam(void)
{
- GtkRpcBindingDialog *d;
- NTSTATUS status;
struct samr_Connect r;
- struct cli_credentials *cred;
TALLOC_CTX *mem_ctx;
- gint result;
-
- d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(NULL));
- result = gtk_dialog_run(GTK_DIALOG(d));
- switch(result) {
- case GTK_RESPONSE_ACCEPT:
- break;
- default:
- gtk_widget_destroy(GTK_WIDGET(d));
- return;
- }
+ NTSTATUS status;
mem_ctx = talloc_init("gwsam_connect");
- cred = cli_credentials_init(mem_ctx);
- cli_credentials_guess(cred);
- cli_credentials_set_gtk_callbacks(cred);
- /* If connected, get list of jobs */
- status = dcerpc_pipe_connect_b(mem_ctx, &sam_pipe,
- gtk_rpc_binding_dialog_get_binding(d, mem_ctx),
- &dcerpc_table_samr, cred, NULL);
+ sam_pipe = gtk_connect_rpc_interface(talloc_autofree_context(), &dcerpc_table_samr);
- if(!NT_STATUS_IS_OK(status)) {
- gtk_show_ntstatus(mainwin, "While connecting to SAMR interface", status);
- sam_pipe = NULL;
- gtk_widget_destroy(GTK_WIDGET(d));
- talloc_free(mem_ctx);
+ if (!sam_pipe)
return;
- }
r.in.system_name = 0;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -149,30 +135,26 @@ static void connect_sam(void)
if (!NT_STATUS_IS_OK(status)) {
gtk_show_ntstatus(mainwin, "While running connect on SAMR", status);
sam_pipe = NULL;
- gtk_widget_destroy(GTK_WIDGET(d));
talloc_free(mem_ctx);
return;
}
gtk_widget_set_sensitive (seldomain, TRUE);
gtk_widget_set_sensitive (mnu_disconnect, TRUE);
- gtk_window_set_title (GTK_WINDOW (mainwin), talloc_asprintf(mem_ctx, "User Manager - Connected to %s", gtk_rpc_binding_dialog_get_host(d)));
- gtk_widget_destroy(GTK_WIDGET(d));
sam_pipe = talloc_reference(talloc_autofree_context(), sam_pipe);
talloc_free(mem_ctx);
-
}
static void on_connect_activate (GtkMenuItem *menuitem, gpointer user_data)
{
connect_sam();
+ /* FIXME: Connect to default domain */
}
static void on_disconnect_activate (GtkMenuItem *menuitem, gpointer user_data)
{
gtk_widget_set_sensitive (mnu_disconnect, FALSE);
- gtk_window_set_title (GTK_WINDOW (mainwin), "User Manager");
}
static void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data)
@@ -230,6 +212,8 @@ static GtkWidget* create_mainwindow (void)
GtkWidget *new1;
GtkWidget *separatormenuitem1;
GtkWidget *quit;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *curcol;
GtkWidget *policies;
GtkWidget *policies_menu;
GtkWidget *account;
@@ -297,8 +281,6 @@ static GtkWidget* create_mainwindow (void)
new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), new1);
-
-
policies = gtk_menu_item_new_with_mnemonic ("_Policies");
gtk_container_add (GTK_CONTAINER (menubar), policies);
gtk_widget_set_sensitive (policies, FALSE);
@@ -350,12 +332,60 @@ static GtkWidget* create_mainwindow (void)
user_list = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (scrolledwindow1), user_list);
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "Name");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(user_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0);
+
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "Description");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(user_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
+
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "RID");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(user_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
+
+ store_users = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(user_list), GTK_TREE_MODEL(store_users));
+
scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
gtk_paned_pack2 (GTK_PANED (vpaned), scrolledwindow2, TRUE, TRUE);
group_list = gtk_tree_view_new ();
gtk_container_add (GTK_CONTAINER (scrolledwindow2), group_list);
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "Name");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(group_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0);
+
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "Description");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(group_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
+
+ curcol = gtk_tree_view_column_new();
+ gtk_tree_view_column_set_title(curcol, "RID");
+ renderer = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(curcol, renderer, True);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(group_list), curcol);
+ gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
+
+ store_groups = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(group_list), GTK_TREE_MODEL(store_groups));
+
statusbar = gtk_statusbar_new ();
gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0);
diff --git a/source4/gtk/tools/gwsam_user.c b/source4/gtk/tools/gwsam_user.c
index ffd8ae28eb..81580f8b19 100644
--- a/source4/gtk/tools/gwsam_user.c
+++ b/source4/gtk/tools/gwsam_user.c
@@ -22,9 +22,7 @@
#include "includes.h"
#include "gtk/common/gtk-smb.h"
-
-GtkWidget*
-create_user_edit_dialog (void)
+GtkWidget* create_user_edit_dialog (void)
{
GtkWidget *user_edit_dialog;
GtkWidget *dialog_vbox1;