diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-12 12:12:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:48:04 -0500 |
commit | 97416e6b011a3c733d07f83073bf12796c7ecc6b (patch) | |
tree | 5784111269a848f62b86fc131aeee06aeae94b92 /source4/gtk | |
parent | 42598ada226c2411451a2d9fdae2834e7f6a1e9f (diff) | |
download | samba-97416e6b011a3c733d07f83073bf12796c7ecc6b.tar.gz samba-97416e6b011a3c733d07f83073bf12796c7ecc6b.tar.bz2 samba-97416e6b011a3c733d07f83073bf12796c7ecc6b.zip |
r21297: Remove the GTK+ tools and library from the main repository. They are now maintained separately in bzr at http://people.samba.org/bzr/jelmer/samba-gtk
This also adds some more headers to the list that is installed and a couple of extra #include lines so these
headers can be used externally without problems.
(This used to be commit 07652f65ce7a5b19130f1a27cbf0e1e5fae13454)
Diffstat (limited to 'source4/gtk')
-rw-r--r-- | source4/gtk/README | 19 | ||||
-rw-r--r-- | source4/gtk/common/credentials.c | 132 | ||||
-rw-r--r-- | source4/gtk/common/gtk-smb.c | 316 | ||||
-rw-r--r-- | source4/gtk/common/gtk-smb.h | 76 | ||||
-rw-r--r-- | source4/gtk/common/gtk_events.c | 361 | ||||
-rw-r--r-- | source4/gtk/common/select.c | 305 | ||||
-rw-r--r-- | source4/gtk/common/select.h | 84 | ||||
-rw-r--r-- | source4/gtk/config.m4 | 21 | ||||
-rw-r--r-- | source4/gtk/config.mk | 49 | ||||
-rw-r--r-- | source4/gtk/man/gepdump.1.xml | 54 | ||||
-rw-r--r-- | source4/gtk/man/gregedit.1.xml | 86 | ||||
-rw-r--r-- | source4/gtk/man/gwcrontab.1.xml | 47 | ||||
-rw-r--r-- | source4/gtk/man/gwsvcctl.1.xml | 47 | ||||
-rw-r--r-- | source4/gtk/meta/gepdump.desktop | 10 | ||||
-rw-r--r-- | source4/gtk/meta/gregedit.desktop | 10 | ||||
-rw-r--r-- | source4/gtk/meta/gwcrontab.desktop | 10 | ||||
-rw-r--r-- | source4/gtk/tools/gepdump.c | 443 | ||||
-rw-r--r-- | source4/gtk/tools/gregedit.c | 989 | ||||
-rw-r--r-- | source4/gtk/tools/gwcrontab.c | 462 | ||||
-rw-r--r-- | source4/gtk/tools/gwsam.c | 443 | ||||
-rw-r--r-- | source4/gtk/tools/gwsam_user.c | 291 | ||||
-rw-r--r-- | source4/gtk/tools/gwsvcctl.c | 217 |
22 files changed, 0 insertions, 4472 deletions
diff --git a/source4/gtk/README b/source4/gtk/README deleted file mode 100644 index 729334ab82..0000000000 --- a/source4/gtk/README +++ /dev/null @@ -1,19 +0,0 @@ -This directory contains files for SMB-related Gtk Widgets -and helper functions and utilities (frontends) for various SMB -things. - -Common code at the moment: -GtkRpcBindingDialog - Gtk Dialog Window for obtaining user credentials and a RPC binding string -GtkSelectDomainDialog - Gtk Dialog for selecting a domain -GtkSelectHostDialog - Gtk Dialog for selecting a SMB host -gtk_show_werror() - Show dialog box with a WERROR -gtk_show_ntstatus() - Show dialog box with a NTSTATUS -create_gtk_samba_about() - Shows about Window - -Utilities: -gregedit - Gtk+ Registry Editor (RPC, NT4 files, W95 files, GConf) -gwcrontab - View and edit 'cron/at'-like jobs using the atsvc service (needs a better name) - -Ideas for future utilities: -- SAM editor -- Eventlog viewer diff --git a/source4/gtk/common/credentials.c b/source4/gtk/common/credentials.c deleted file mode 100644 index 97e71c329c..0000000000 --- a/source4/gtk/common/credentials.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Copyright (C) Jelmer Vernooij 2005 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "gtk/common/gtk-smb.h" -#include "auth/credentials/credentials.h" - -static void gtk_get_credentials(struct cli_credentials *credentials) -{ - const char *ret; - GtkWidget *dialog; - GtkWidget *label; - GtkWidget *table; - GtkWidget *entry_username; - GtkWidget *entry_password; - GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; - GtkWidget *okbutton1; - GtkWidget *anonymous; - const char *username; - - dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (dialog), "Credentials"); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - table = gtk_table_new(4, 2, FALSE); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); - - label = gtk_label_new ("Username:"); - - gtk_table_attach(GTK_TABLE(table),label,0,1,1,2,GTK_FILL,0,0,0); - - entry_username = gtk_entry_new (); - gtk_table_attach(GTK_TABLE(table),entry_username,1,2,1,2,GTK_FILL,0,0,0); - gtk_entry_set_activates_default (GTK_ENTRY (entry_username), TRUE); - - username = cli_credentials_get_unparsed_name(credentials, credentials); - - if (credentials->username_obtained != CRED_UNINITIALISED && - username) { - gtk_entry_set_text(GTK_ENTRY(entry_username), username); - } - - label = gtk_label_new ("Password:"); - - gtk_table_attach(GTK_TABLE(table),label,0,1,3,4,GTK_FILL,0,0,0); - - entry_password = gtk_entry_new (); - gtk_table_attach(GTK_TABLE(table),entry_password,1,2,3,4,GTK_FILL,0,0,0); - gtk_entry_set_visibility (GTK_ENTRY (entry_password), FALSE); - gtk_entry_set_activates_default (GTK_ENTRY (entry_password), TRUE); - if (credentials->password_obtained != CRED_UNINITIALISED && - credentials->password_obtained != CRED_CALLBACK && - credentials->password) { - gtk_entry_set_text(GTK_ENTRY(entry_password), credentials->password); - } - - anonymous = gtk_check_button_new_with_mnemonic("_Anonymous"); - gtk_table_attach(GTK_TABLE(table),anonymous,0,2,4,5,GTK_FILL,0,0,0); - - dialog_action_area1 = GTK_DIALOG (dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancelbutton1, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), okbutton1, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); - - gtk_widget_show_all (dialog); - - switch (gtk_dialog_run (GTK_DIALOG (dialog))) { - case GTK_RESPONSE_OK: - cli_credentials_parse_string(credentials, gtk_entry_get_text(GTK_ENTRY(entry_username)), CRED_CALLBACK_RESULT); - cli_credentials_set_password(credentials, gtk_entry_get_text(GTK_ENTRY(entry_password)), CRED_CALLBACK_RESULT); - - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anonymous))) { - cli_credentials_set_anonymous(credentials); - } - break; - default: - ret = NULL; - break; - } - - gtk_widget_destroy (dialog); -} - -static const char *gtk_get_username(struct cli_credentials *credentials) -{ - gtk_get_credentials(credentials); - return credentials->username; -} - -static const char *gtk_get_userpassword(struct cli_credentials *credentials) -{ - gtk_get_credentials(credentials); - return credentials->password; -} - -static const char *gtk_get_domain(struct cli_credentials *credentials) -{ - gtk_get_credentials(credentials); - return credentials->domain; -} - -void cli_credentials_set_gtk_callbacks(struct cli_credentials *cred) -{ - cli_credentials_set_username_callback(cred, gtk_get_username); - cli_credentials_set_domain_callback(cred, gtk_get_domain); - cli_credentials_set_password_callback(cred, gtk_get_userpassword); -} diff --git a/source4/gtk/common/gtk-smb.c b/source4/gtk/common/gtk-smb.c deleted file mode 100644 index cb445d8268..0000000000 --- a/source4/gtk/common/gtk-smb.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB-related GTK+ functions - - Copyright (C) Jelmer Vernooij 2004-2005 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "gtk/common/gtk-smb.h" -#include "gtk/common/select.h" -#include "version.h" -#include "librpc/rpc/dcerpc.h" -#include "auth/credentials/credentials.h" - -/** - * Dialog error showing a WERROR - */ -void gtk_show_werror(GtkWidget *win, const char *message, WERROR err) -{ - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s: %s\n", message?message: "Windows error", - win_errstr(err)); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -/** - * GTK+ dialog showing a NTSTATUS error - */ -void gtk_show_ntstatus(GtkWidget *win, const char *message, NTSTATUS status) -{ - GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s: %s\n", message?message:"Windows error", - nt_errstr(status)); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -static void on_browse_activate (GtkButton *button, gpointer user_data) -{ - GtkRpcBindingDialog *rbd = user_data; - GtkWidget *shd = gtk_select_host_dialog_new(rbd->sam_pipe); - if(gtk_dialog_run(GTK_DIALOG(shd)) == GTK_RESPONSE_ACCEPT) { - gtk_entry_set_text(GTK_ENTRY(rbd->entry_host), gtk_select_host_dialog_get_host(GTK_SELECT_HOST_DIALOG(shd))); - } - - gtk_widget_destroy(GTK_WIDGET(shd)); -} - -static void on_ncalrpc_toggled(GtkToggleButton *tb, GtkRpcBindingDialog *d) -{ - gtk_widget_set_sensitive(d->frame_host, !gtk_toggle_button_get_active(tb)); -} - -static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_dialog) -{ - GtkWidget *dialog_vbox1; - GtkWidget *vbox1; - GtkWidget *vbox6; - GtkWidget *frame_transport; - GtkWidget *label1; - GtkWidget *hbox1; - GtkWidget *lbl_name; - GtkWidget *label2; - GtkWidget *label3; - GtkWidget *frame_security; - GtkWidget *vbox2; - GtkWidget *btn_browse; - GtkWidget *dialog_action_area1; - GtkWidget *btn_cancel; - GtkWidget *btn_connect; - GSList *transport_smb_group = NULL; - - gtk_rpc_binding_dialog->mem_ctx = talloc_init("gtk_rcp_binding_dialog"); - - gtk_window_set_title (GTK_WINDOW (gtk_rpc_binding_dialog), "Connect"); - - dialog_vbox1 = GTK_DIALOG (gtk_rpc_binding_dialog)->vbox; - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0); - - frame_transport = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox1), frame_transport, TRUE, TRUE, 0); - - vbox6 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame_transport), vbox6); - - gtk_rpc_binding_dialog->transport_ncalrpc = gtk_radio_button_new_with_mnemonic (NULL, "Local Host"); - gtk_box_pack_start (GTK_BOX (vbox6), gtk_rpc_binding_dialog->transport_ncalrpc, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_ncalrpc), transport_smb_group); - transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_ncalrpc)); - - - gtk_rpc_binding_dialog->transport_smb = gtk_radio_button_new_with_mnemonic (NULL, "RPC over SMB over TCP/IP"); - gtk_box_pack_start (GTK_BOX (vbox6), gtk_rpc_binding_dialog->transport_smb, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_smb), transport_smb_group); - transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_smb)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_rpc_binding_dialog->transport_smb), TRUE); - - gtk_rpc_binding_dialog->transport_tcp_ip = gtk_radio_button_new_with_mnemonic (NULL, "RPC over TCP/IP"); - gtk_box_pack_start (GTK_BOX (vbox6), gtk_rpc_binding_dialog->transport_tcp_ip, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip), transport_smb_group); - transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip)); - - label1 = gtk_label_new ("Transport"); - gtk_frame_set_label_widget (GTK_FRAME (frame_transport), label1); - - gtk_rpc_binding_dialog->frame_host = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox1), gtk_rpc_binding_dialog->frame_host, TRUE, TRUE, 0); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (gtk_rpc_binding_dialog->frame_host), hbox1); - - lbl_name = gtk_label_new ("Name"); - gtk_box_pack_start (GTK_BOX (hbox1), lbl_name, TRUE, TRUE, 0); - - gtk_rpc_binding_dialog->entry_host = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox1), gtk_rpc_binding_dialog->entry_host, TRUE, TRUE, 0); - - if(gtk_rpc_binding_dialog->sam_pipe) - { - btn_browse = gtk_button_new_with_label ("Browse"); - gtk_box_pack_start (GTK_BOX (hbox1), btn_browse, TRUE, TRUE, 0); - - g_signal_connect ((gpointer) btn_browse, "pressed", - G_CALLBACK (on_browse_activate), - gtk_rpc_binding_dialog); - } - - label2 = gtk_label_new ("Host"); - gtk_frame_set_label_widget (GTK_FRAME (gtk_rpc_binding_dialog->frame_host), label2); - - frame_security = gtk_frame_new (NULL); - - label3 = gtk_label_new ("Security"); - gtk_frame_set_label_widget (GTK_FRAME (frame_security), label3); - - gtk_box_pack_start (GTK_BOX (vbox1), frame_security, TRUE, TRUE, 0); - - vbox2 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame_security), vbox2); - - gtk_rpc_binding_dialog->chk_sign = gtk_check_button_new_with_mnemonic ("S_ign"); - gtk_box_pack_start (GTK_BOX (vbox2), gtk_rpc_binding_dialog->chk_sign, FALSE, FALSE, 0); - - gtk_rpc_binding_dialog->chk_seal = gtk_check_button_new_with_mnemonic ("_Seal"); - gtk_box_pack_start (GTK_BOX (vbox2), gtk_rpc_binding_dialog->chk_seal, FALSE, FALSE, 0); - - dialog_action_area1 = GTK_DIALOG (gtk_rpc_binding_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - btn_cancel = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_cancel, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (btn_cancel, GTK_CAN_DEFAULT); - - btn_connect = gtk_button_new_with_mnemonic ("C_onnect"); - gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_connect, GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width (GTK_CONTAINER (btn_connect), 1); - GTK_WIDGET_SET_FLAGS (btn_connect, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) gtk_rpc_binding_dialog->transport_ncalrpc, "toggled", - G_CALLBACK (on_ncalrpc_toggled), - gtk_rpc_binding_dialog); - - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gtk_rpc_binding_dialog->transport_ncalrpc), TRUE); - gtk_widget_show_all(dialog_vbox1); - - gtk_widget_grab_focus (btn_connect); - gtk_widget_grab_default (btn_connect); -} - -GType gtk_rpc_binding_dialog_get_type (void) -{ - static GType mytype = 0; - - if (!mytype) - { - static const GTypeInfo myinfo = - { - sizeof (GtkRpcBindingDialogClass), - NULL, - NULL, - NULL, - NULL, - NULL, - sizeof(GtkRpcBindingDialog), - 0, - (GInstanceInitFunc) gtk_rpc_binding_dialog_init, - }; - - mytype = g_type_register_static (GTK_TYPE_DIALOG, - "GtkRpcBindingDialog", &myinfo, 0); - } - - return mytype; -} - -/** - * Create a new GTK+ dialog asking for binding information for - * DCE/RPC - * - * Optionally gets a sam pipe that will be used to look up users - */ -GtkWidget *gtk_rpc_binding_dialog_new (struct dcerpc_pipe *sam_pipe) -{ - GtkRpcBindingDialog *d = GTK_RPC_BINDING_DIALOG ( g_object_new (gtk_rpc_binding_dialog_get_type (), NULL)); - d->sam_pipe = sam_pipe; - return GTK_WIDGET(d); -} - -const char *gtk_rpc_binding_dialog_get_host(GtkRpcBindingDialog *d) -{ - return gtk_entry_get_text(GTK_ENTRY(d->entry_host)); -} - -struct dcerpc_binding *gtk_rpc_binding_dialog_get_binding(GtkRpcBindingDialog *d, TALLOC_CTX *mem_ctx) -{ - struct dcerpc_binding *binding = talloc(mem_ctx, struct dcerpc_binding); - - ZERO_STRUCT(binding->object); - - /* Format: TRANSPORT:host[\pipe\foo,foo,foo] */ - - binding->host = talloc_strdup(mem_ctx, gtk_entry_get_text(GTK_ENTRY(d->entry_host))); - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->transport_tcp_ip))) { - binding->transport = NCACN_IP_TCP; - } else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->transport_ncalrpc))) { - binding->transport = NCALRPC; - binding->host = NULL; - } else { - binding->transport = NCACN_NP; - } - - binding->options = NULL; - binding->flags = 0; - binding->endpoint = NULL; - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->chk_seal))) { - binding->flags |= DCERPC_SEAL; - } - - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->chk_sign))) { - binding->flags |= DCERPC_SIGN; - } - - return binding; -} - -const char *gtk_rpc_binding_dialog_get_binding_string(GtkRpcBindingDialog *d, TALLOC_CTX *mem_ctx) -{ - return dcerpc_binding_string(mem_ctx, gtk_rpc_binding_dialog_get_binding(d, mem_ctx)); -} - -GtkWidget *create_gtk_samba_about_dialog (const char *appname) -{ - GtkWidget *samba_about_dialog; - GtkWidget *dialog_vbox1; - GtkWidget *label1; - GtkWidget *label2; - GtkWidget *label3; - GtkWidget *label4; - GtkWidget *dialog_action_area1; - GtkWidget *okbutton1; - - samba_about_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (samba_about_dialog), "About"); - - dialog_vbox1 = GTK_DIALOG (samba_about_dialog)->vbox; - - /* FIXME image1 = create_pixmap (samba_about_dialog, "slmed.png"); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), image1, TRUE, TRUE, 0);*/ - - label1 = gtk_label_new (appname); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), label1, FALSE, FALSE, 0); - - label2 = gtk_label_new (SAMBA_VERSION_STRING); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), label2, FALSE, FALSE, 0); - - label3 = gtk_label_new_with_mnemonic ("Part of Samba <http://www.samba.org/>"); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), label3, FALSE, FALSE, 0); - - label4 = gtk_label_new ("\302\251 1992-2006 The Samba Team"); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), label4, FALSE, FALSE, 0); - - dialog_action_area1 = GTK_DIALOG (samba_about_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (samba_about_dialog), okbutton1, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); - gtk_widget_show_all(dialog_vbox1); - - return samba_about_dialog; -} diff --git a/source4/gtk/common/gtk-smb.h b/source4/gtk/common/gtk-smb.h deleted file mode 100644 index ae72905272..0000000000 --- a/source4/gtk/common/gtk-smb.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB-related GTK+ functions - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __GTK_SMB_H__ -#define __GTK_SMB_H__ - -#define GTK_DISABLE_DEPRECATED -#include <gtk/gtk.h> - -typedef struct _GtkRpcBindingDialog GtkRpcBindingDialog; - -struct _GtkRpcBindingDialog -{ - GtkDialog dialog; - GtkWidget *chk_sign; - GtkWidget *chk_seal; - GtkWidget *transport_tcp_ip; - GtkWidget *transport_ncalrpc; - GtkWidget *transport_smb; - GtkWidget *frame_host; - GtkWidget *entry_host; - GtkWidget *entry_username; - GtkWidget *entry_userdomain; - GtkWidget *entry_password; - GtkWidget *krb5_chk_button; - TALLOC_CTX *mem_ctx; - struct dcerpc_pipe *sam_pipe; -}; - -typedef struct _GtkRpcBindingDialogClass GtkRpcBindingDialogClass; - -struct _GtkRpcBindingDialogClass -{ - GtkDialogClass parent_class; -}; - -#define GTK_RPC_BINDING_DIALOG(obj) GTK_CHECK_CAST (obj, gtk_rpc_binding_dialog_get_type (), GtkRpcBindingDialog) -#define GTK_RPC_BINDING_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_rpc_binding_dialog_class_get_type (), GtkRpcBindingDialogClass) -#define IS_GTK_RPC_BINDING_DIALOG(obj) GTK_CHECK_TYPE (obj, gtk_rpc_binding_dialog_get_type ()) - -/* subsystem prototypes */ -GtkWidget *create_gtk_samba_about_dialog (const char *appname); -void gtk_show_ntstatus(GtkWidget *win, const char *, NTSTATUS status); -GtkWidget *gtk_rpc_binding_dialog_new (struct dcerpc_pipe *sam_pipe); -GType gtk_rpc_binding_dialog_get_type (void); -struct dcerpc_binding *gtk_rpc_binding_dialog_get_binding(GtkRpcBindingDialog *d, TALLOC_CTX *mem_ctx); -void gtk_show_werror(GtkWidget *win, const char *, WERROR err); -const char *gtk_rpc_binding_dialog_get_binding_string(GtkRpcBindingDialog *d, TALLOC_CTX *mem_ctx); -const char *gtk_rpc_binding_dialog_get_host(GtkRpcBindingDialog *d); - -int gtk_event_loop(void); -struct event_context; -struct event_context *gtk_event_context(void); - -struct cli_credentials; -void cli_credentials_set_gtk_callbacks(struct cli_credentials *creds); - -#endif diff --git a/source4/gtk/common/gtk_events.c b/source4/gtk/common/gtk_events.c deleted file mode 100644 index 45e1031093..0000000000 --- a/source4/gtk/common/gtk_events.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - main select loop and event handling - - plugin for using a gtk application's event loop - - Copyright (C) Stefan Metzmacher 2005 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "lib/events/events.h" -#include "lib/events/events_internal.h" - -#include "gtk/common/select.h" - -/* as gtk_main() doesn't take a parameter nor return one, - we need to have a global event context structure for our - gtk-bases tools - */ -static struct event_context *gtk_event_context_global; - -static int gtk_event_context_destructor(struct event_context *ev) -{ - gtk_event_context_global = NULL; - return 0; -} - -/* - create a gtk_event_context structure. -*/ -static int gtk_event_context_init(struct event_context *ev) -{ - talloc_set_destructor(ev, gtk_event_context_destructor); - return 0; -} - -struct gtk_fd_event { - BOOL running; - BOOL free_after_run; - GIOChannel *channel; - guint fd_id; -}; - -static gboolean gtk_event_fd_handler(GIOChannel *source, GIOCondition condition, gpointer data) -{ - struct fd_event *fde = talloc_get_type(data, struct fd_event); - struct gtk_fd_event *gtk_fd = talloc_get_type(fde->additional_data, - struct gtk_fd_event); - int flags = 0; - - if (condition & (G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP)) - flags |= EVENT_FD_READ; - if (condition & G_IO_OUT) - flags |= EVENT_FD_WRITE; - - gtk_fd->running = True; - fde->handler(fde->event_ctx, fde, flags, fde->private_data); - gtk_fd->running = False; - - if (gtk_fd->free_after_run) { - talloc_free(fde); - return gtk_false(); - } - - return gtk_true(); -} - -/* - destroy an fd_event -*/ -static int gtk_event_fd_destructor(struct fd_event *fde) -{ - struct gtk_fd_event *gtk_fd = talloc_get_type(fde->additional_data, - struct gtk_fd_event); - - if (gtk_fd->running) { - /* the event is running reject the talloc_free() - as it's done by the gtk_event_timed_handler() - */ - gtk_fd->free_after_run = True; - return -1; - } - - if (fde->flags) { - /* only if any flag is set we have really registered an event */ - g_source_remove(gtk_fd->fd_id); - } - g_io_channel_unref(gtk_fd->channel); - - return 0; -} - -/* - add a fd based event - return NULL on failure (memory allocation error) -*/ -static struct fd_event *gtk_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx, - int fd, uint16_t flags, - event_fd_handler_t handler, - void *private_data) -{ - struct fd_event *fde; - struct gtk_fd_event *gtk_fd; - GIOChannel *channel; - guint fd_id = 0; - GIOCondition condition = 0; - - fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event); - if (!fde) return NULL; - - gtk_fd = talloc(fde, struct gtk_fd_event); - if (gtk_fd == NULL) { - talloc_free(fde); - return NULL; - } - - fde->event_ctx = ev; - fde->fd = fd; - fde->flags = flags; - fde->handler = handler; - fde->private_data = private_data; - fde->additional_flags = 0; - fde->additional_data = gtk_fd; - - channel = g_io_channel_unix_new(fde->fd); - if (channel == NULL) { - talloc_free(fde); - return NULL; - } - - if (fde->flags & EVENT_FD_READ) - condition |= (G_IO_IN | G_IO_ERR | G_IO_HUP); - if (fde->flags & EVENT_FD_WRITE) - condition |= G_IO_OUT; - - if (condition) { - /* only register the event when at least one flag is set - as condition == 0 means wait for any event and is not the same - as fde->flags == 0 ! - */ - fd_id = g_io_add_watch(channel, condition, gtk_event_fd_handler, fde); - } - - gtk_fd->running = False; - gtk_fd->free_after_run = False; - gtk_fd->channel = channel; - gtk_fd->fd_id = fd_id; - - talloc_set_destructor(fde, gtk_event_fd_destructor); - - return fde; -} - -/* - return the fd event flags -*/ -static uint16_t gtk_event_get_fd_flags(struct fd_event *fde) -{ - return fde->flags; -} - -/* - set the fd event flags -*/ -static void gtk_event_set_fd_flags(struct fd_event *fde, uint16_t flags) -{ - struct gtk_fd_event *gtk_fd = talloc_get_type(fde->additional_data, - struct gtk_fd_event); - GIOCondition condition = 0; - - if (fde->flags == flags) return; - - if (flags & EVENT_FD_READ) - condition |= (G_IO_IN | G_IO_ERR | G_IO_HUP); - if (flags & EVENT_FD_WRITE) - condition |= G_IO_OUT; - - /* only register the event when at least one flag is set - as condition == 0 means wait for any event and is not the same - as fde->flags == 0 ! - */ - if (fde->flags) { - g_source_remove(gtk_fd->fd_id); - } - if (condition) { - gtk_fd->fd_id = g_io_add_watch(gtk_fd->channel, condition, gtk_event_fd_handler, fde); - } - - fde->flags = flags; -} - -struct gtk_timed_event { - guint te_id; -}; - -/* - destroy a timed event -*/ -static int gtk_event_timed_destructor(struct timed_event *te) -{ - struct gtk_timed_event *gtk_te = talloc_get_type(te->additional_data, - struct gtk_timed_event); - - g_source_remove(gtk_te->te_id); - - return 0; -} - -static int gtk_event_timed_deny_destructor(struct timed_event *te) -{ - return -1; -} - -static gboolean gtk_event_timed_handler(gpointer data) -{ - struct timed_event *te = talloc_get_type(data, struct timed_event); - struct timeval t = timeval_current(); - - /* deny the handler to free the event */ - talloc_set_destructor(te, gtk_event_timed_deny_destructor); - te->handler(te->event_ctx, te, t, te->private_data); - - talloc_set_destructor(te, gtk_event_timed_destructor); - talloc_free(te); - - /* return FALSE mean this event should be removed */ - return gtk_false(); -} - -/* - add a timed event - return NULL on failure (memory allocation error) -*/ -static struct timed_event *gtk_event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx, - struct timeval next_event, - event_timed_handler_t handler, - void *private_data) -{ - struct timed_event *te; - struct gtk_timed_event *gtk_te; - struct timeval cur_tv, diff_tv; - guint timeout; - - te = talloc(mem_ctx?mem_ctx:ev, struct timed_event); - if (te == NULL) return NULL; - - gtk_te = talloc(te, struct gtk_timed_event); - if (gtk_te == NULL) { - talloc_free(te); - return NULL; - } - - te->event_ctx = ev; - te->next_event = next_event; - te->handler = handler; - te->private_data = private_data; - te->additional_data = gtk_te; - - cur_tv = timeval_current(); - diff_tv = timeval_until(&cur_tv, &next_event); - timeout = ((diff_tv.tv_usec+999)/1000)+(diff_tv.tv_sec*1000); - - gtk_te->te_id = g_timeout_add(timeout, gtk_event_timed_handler, te); - - talloc_set_destructor(te, gtk_event_timed_destructor); - - return te; -} - -/* - do a single event loop -*/ -static int gtk_event_loop_once(struct event_context *ev) -{ - /* - * gtk_main_iteration () - * - * gboolean gtk_main_iteration (void); - * - * Runs a single iteration of the mainloop. If no events - * are waiting to be processed GTK+ will block until the - * next event is noticed. If you don't want to block look - * at gtk_main_iteration_do() or check if any events are - * pending with gtk_events_pending() first. - * - * Returns : TRUE if gtk_main_quit() has been called for the innermost mainloop. - */ - gboolean ret; - - ret = gtk_main_iteration(); - if (ret == gtk_true()) { - return -1; - } - - return 0; -} - -/* - return with 0 -*/ -static int gtk_event_loop_wait(struct event_context *ev) -{ - /* - * gtk_main () - * - * void gtk_main (void); - * - * Runs the main loop until gtk_main_quit() is called. - * You can nest calls to gtk_main(). In that case - * gtk_main_quit() will make the innermost invocation - * of the main loop return. - */ - gtk_main(); - return 0; -} - -static const struct event_ops gtk_event_ops = { - .context_init = gtk_event_context_init, - .add_fd = gtk_event_add_fd, - .get_fd_flags = gtk_event_get_fd_flags, - .set_fd_flags = gtk_event_set_fd_flags, - .add_timed = gtk_event_add_timed, - .loop_once = gtk_event_loop_once, - .loop_wait = gtk_event_loop_wait, -}; - -int gtk_event_loop(void) -{ - int ret; - - event_register_backend("gtk", >k_event_ops); - - gtk_event_context_global = event_context_init_byname(NULL, "gtk"); - if (!gtk_event_context_global) return -1; - - ret = event_loop_wait(gtk_event_context_global); - - talloc_free(gtk_event_context_global); - - return ret; -} - -struct event_context *gtk_event_context(void) -{ - return gtk_event_context_global; -} diff --git a/source4/gtk/common/select.c b/source4/gtk/common/select.c deleted file mode 100644 index 5a0480ab28..0000000000 --- a/source4/gtk/common/select.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB-related GTK+ functions - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_samr_c.h" -#include "gtk/common/select.h" -#include "gtk/common/gtk-smb.h" -#include "auth/credentials/credentials.h" - -/* GtkSelectDomainDialog */ - -const char *gtk_select_domain_dialog_get_domain(GtkSelectDomainDialog *d) -{ - return gtk_entry_get_text(GTK_ENTRY(d->entry_domain)); -} - -static void gtk_select_domain_dialog_init (GtkSelectDomainDialog *select_domain_dialog) -{ - GtkWidget *dialog_vbox1; - GtkWidget *hbox1; - GtkWidget *label1; - GtkWidget *scrolledwindow1; - GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; - GtkWidget *okbutton1; - GtkCellRenderer *renderer; - GtkTreeViewColumn *curcol; - - gtk_window_set_title (GTK_WINDOW (select_domain_dialog), "Select Domain"); - - dialog_vbox1 = GTK_DIALOG (select_domain_dialog)->vbox; - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox1, TRUE, TRUE, 0); - - label1 = gtk_label_new ("Domain:"); - gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 0); - - select_domain_dialog->entry_domain = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox1), select_domain_dialog->entry_domain, TRUE, TRUE, 0); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), scrolledwindow1, TRUE, TRUE, 0); - - select_domain_dialog->list_domains = gtk_tree_view_new (); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), select_domain_dialog->list_domains); - - 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(select_domain_dialog->list_domains), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - select_domain_dialog->store_domains = gtk_list_store_new(1, G_TYPE_STRING); - gtk_tree_view_set_model(GTK_TREE_VIEW(select_domain_dialog->list_domains), GTK_TREE_MODEL(select_domain_dialog->store_domains)); - g_object_unref(select_domain_dialog->store_domains); - - dialog_action_area1 = GTK_DIALOG (select_domain_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (select_domain_dialog), cancelbutton1, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (select_domain_dialog), okbutton1, GTK_RESPONSE_OK); - gtk_widget_show_all(dialog_vbox1); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); -} - -struct policy_handle gtk_select_domain_dialog_get_handle(GtkSelectDomainDialog *d) -{ - struct policy_handle h; - - - /* FIXME */ - return h; -} - -GType gtk_select_domain_dialog_get_type (void) -{ - static GType mytype = 0; - - if (!mytype) - { - static const GTypeInfo myinfo = - { - sizeof (GtkSelectDomainDialogClass), - NULL, - NULL, - NULL, - NULL, - NULL, - sizeof(GtkSelectDomainDialog), - 0, - (GInstanceInitFunc) gtk_select_domain_dialog_init, - }; - - mytype = g_type_register_static (GTK_TYPE_DIALOG, - "GtkSelectDomainDialog", &myinfo, 0); - } - - return mytype; -} - -GtkWidget *gtk_select_domain_dialog_new (struct dcerpc_pipe *sam_pipe) -{ - GtkSelectDomainDialog *d = g_object_new(gtk_select_domain_dialog_get_type (), NULL); - NTSTATUS status; - struct samr_EnumDomains r; - struct samr_Connect cr; - struct samr_Close dr; - struct policy_handle handle; - uint32_t resume_handle = 0; - int i; - TALLOC_CTX *mem_ctx = talloc_init("gtk_select_domain_dialog_new"); - - d->sam_pipe = sam_pipe; - - cr.in.system_name = 0; - cr.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - cr.out.connect_handle = &handle; - - status = dcerpc_samr_Connect(sam_pipe, mem_ctx, &cr); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(NULL, "Running Connect on SAMR", status); - talloc_free(mem_ctx); - return GTK_WIDGET(d); - } - - r.in.connect_handle = &handle; - r.in.resume_handle = &resume_handle; - r.in.buf_size = (uint32_t)-1; - r.out.resume_handle = &resume_handle; - - status = dcerpc_samr_EnumDomains(sam_pipe, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(NULL, "Enumerating domains", status); - } else if (r.out.sam) { - for (i=0;i<r.out.sam->count;i++) { - GtkTreeIter iter; - gtk_list_store_append(d->store_domains, &iter); - gtk_list_store_set (d->store_domains, &iter, 0, r.out.sam->entries[i].name.string, -1); - } - } - - dr.in.handle = &handle; - dr.out.handle = &handle; - - status = dcerpc_samr_Close(sam_pipe, mem_ctx, &dr); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(NULL, "Closing SAMR connection", status); - talloc_free(mem_ctx); - return GTK_WIDGET ( d ); - } - - talloc_free(mem_ctx); - - return GTK_WIDGET ( d ); -} - - -/* GtkSelectHostDialog */ -const char *gtk_select_host_dialog_get_host (GtkSelectHostDialog *d) -{ - return gtk_entry_get_text(GTK_ENTRY(d->entry_host)); -} - -static void gtk_select_host_dialog_init (GtkSelectHostDialog *select_host_dialog) -{ - GtkWidget *dialog_vbox2; - GtkWidget *hbox2; - GtkWidget *label2; - GtkWidget *scrolledwindow2; - GtkWidget *dialog_action_area2; - GtkWidget *cancelbutton2; - GtkWidget *okbutton2; - - gtk_window_set_title (GTK_WINDOW (select_host_dialog), "Select Host"); - - dialog_vbox2 = GTK_DIALOG (select_host_dialog)->vbox; - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (dialog_vbox2), hbox2, TRUE, TRUE, 0); - - label2 = gtk_label_new ("Host"); - gtk_box_pack_start (GTK_BOX (hbox2), label2, FALSE, FALSE, 0); - - select_host_dialog->entry_host = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox2), select_host_dialog->entry_host, TRUE, TRUE, 0); - - scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (dialog_vbox2), scrolledwindow2, TRUE, TRUE, 0); - - select_host_dialog->tree_host = gtk_tree_view_new (); - gtk_container_add (GTK_CONTAINER (scrolledwindow2), select_host_dialog->tree_host); - - select_host_dialog->store_host = gtk_tree_store_new(1, G_TYPE_STRING); - gtk_tree_view_set_model(GTK_TREE_VIEW(select_host_dialog->tree_host), GTK_TREE_MODEL(select_host_dialog->store_host)); - g_object_unref(select_host_dialog->store_host); - - dialog_action_area2 = GTK_DIALOG (select_host_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); - - cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (select_host_dialog), cancelbutton2, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT); - - okbutton2 = gtk_button_new_from_stock ("gtk-ok"); - gtk_widget_show_all (dialog_vbox2); - gtk_dialog_add_action_widget (GTK_DIALOG (select_host_dialog), okbutton2, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT); -} - -GType gtk_select_host_dialog_get_type (void) -{ - static GType mytype = 0; - - if (!mytype) - { - static const GTypeInfo myinfo = - { - sizeof (GtkSelectHostDialogClass), - NULL, - NULL, - NULL, - NULL, - NULL, - sizeof(GtkSelectHostDialog), - 0, - (GInstanceInitFunc) gtk_select_host_dialog_init, - }; - - mytype = g_type_register_static (GTK_TYPE_DIALOG, - "GtkSelectHostDialog", &myinfo, 0); - } - - return mytype; -} - -GtkWidget *gtk_select_host_dialog_new (struct dcerpc_pipe *sam_pipe) -{ - return GTK_WIDGET ( g_object_new (gtk_select_host_dialog_get_type (), NULL )); -} - -/** - * Connect to a specific interface, but ask the user - * for information not specified - */ -struct dcerpc_pipe *gtk_connect_rpc_interface(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *table) -{ - GtkRpcBindingDialog *d; - NTSTATUS status; - struct dcerpc_pipe *pipe; - struct cli_credentials *cred; - gint result; - - d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(NULL)); - result = gtk_dialog_run(GTK_DIALOG(d)); - - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(GTK_WIDGET(d)); - return NULL; - } - - cred = cli_credentials_init(mem_ctx); - cli_credentials_guess(cred); - cli_credentials_set_gtk_callbacks(cred); - - status = dcerpc_pipe_connect_b(mem_ctx, &pipe, - gtk_rpc_binding_dialog_get_binding(d, mem_ctx), - table, cred, NULL); - - if(!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(NULL, "While connecting to interface", status); - gtk_widget_destroy(GTK_WIDGET(d)); - talloc_free(cred); - return NULL; - } - - gtk_widget_destroy(GTK_WIDGET(d)); - - talloc_free(cred); - - return pipe; -} diff --git a/source4/gtk/common/select.h b/source4/gtk/common/select.h deleted file mode 100644 index ddf9b1a5a9..0000000000 --- a/source4/gtk/common/select.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB-related GTK+ functions - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __GTK_SELECT_H__ -#define __GTK_SELECT_H__ - -#define GTK_DISABLE_DEPRECATED -#include <gtk/gtk.h> - -typedef struct _GtkSelectDomainDialog GtkSelectDomainDialog; - -struct _GtkSelectDomainDialog -{ - GtkDialog dialog; - GtkWidget *entry_domain; - GtkWidget *list_domains; - GtkListStore *store_domains; - TALLOC_CTX *mem_ctx; - struct dcerpc_pipe *sam_pipe; -}; - -typedef struct _GtkSelectDomainDialogClass GtkSelectDomainDialogClass; - -struct _GtkSelectDomainDialogClass -{ - GtkDialogClass parent_class; -}; - -#define GTK_SELECT_DOMAIN_DIALOG(obj) GTK_CHECK_CAST (obj, gtk_select_domain_dialog_get_type (), GtkSelectDomainDialog) -#define GTK_SELECT_DOMAIN_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_select_domain_dialog_class_get_type (), GtkSelectDomainDialogClass) -#define IS_GTK_SELECT_DOMAIN_DIALOG(obj) GTK_CHECK_TYPE (obj, gtk_select_domain_dialog_get_type ()) - -typedef struct _GtkSelectHostDialog GtkSelectHostDialog; - -struct _GtkSelectHostDialog -{ - GtkDialog dialog; - GtkWidget *entry_host; - GtkWidget *tree_host; - GtkTreeStore *store_host; - struct dcerpc_pipe *sam_pipe; - TALLOC_CTX *mem_ctx; -}; - -typedef struct _GtkSelectHostDialogClass GtkSelectHostDialogClass; - -struct _GtkSelectHostDialogClass -{ - GtkDialogClass parent_class; -}; - -#define GTK_SELECT_HOST_DIALOG(obj) GTK_CHECK_CAST (obj, gtk_select_host_dialog_get_type (), GtkSelectHostDialog) -#define GTK_SELECT_HOST_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_select_host_dialog_class_get_type (), GtkSelectHostDialogClass) -#define IS_GTK_SELECT_HOST_DIALOG(obj) GTK_CHECK_TYPE (obj, gtk_select_host_dialog_get_type ()) - -GtkWidget *gtk_select_domain_dialog_new (struct dcerpc_pipe *sam_pipe); -GType gtk_select_domain_dialog_get_type (void); -struct policy_handle gtk_select_domain_dialog_get_handle(GtkSelectDomainDialog *d); -GtkWidget *gtk_select_host_dialog_new (struct dcerpc_pipe *sam_pipe); -const char *gtk_select_host_dialog_get_host (GtkSelectHostDialog *d); -GType gtk_select_host_dialog_get_type (void); - -struct dcerpc_interface_table; -struct dcerpc_pipe *gtk_connect_rpc_interface(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *table); - -#endif diff --git a/source4/gtk/config.m4 b/source4/gtk/config.m4 deleted file mode 100644 index 4e23593c67..0000000000 --- a/source4/gtk/config.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl # LIB GTK SMB subsystem - -SMB_EXT_LIB_FROM_PKGCONFIG(gtk, [glib-2.0 gtk+-2.0 >= 2.4]) -SMB_ENABLE(gtksamba, NO) -SMB_ENABLE(gregedit, NO) -SMB_ENABLE(gwcrontab, NO) -SMB_ENABLE(gwsam, NO) -SMB_ENABLE(gepdump, NO) -SMB_ENABLE(gwsvcctl, NO) -SMB_ENABLE(EVENTS_GTK, NO) - -if test t$SMB_ENABLE_gtk = tYES; then - SMB_ENABLE(gtksamba, YES) - SMB_ENABLE(gregedit, YES) - SMB_ENABLE(gwcrontab, YES) - SMB_ENABLE(gwsam, YES) - SMB_ENABLE(gwsvcctl, YES) - SMB_ENABLE(gepdump, YES) - SMB_ENABLE(EVENTS_GTK, YES) - AC_DEFINE(HAVE_GTK, 1, [Whether GTK+ is available]) -fi diff --git a/source4/gtk/config.mk b/source4/gtk/config.mk deleted file mode 100644 index 51b9b0febd..0000000000 --- a/source4/gtk/config.mk +++ /dev/null @@ -1,49 +0,0 @@ -# LIB GTK SMB subsystem - -############################## -[MODULE::EVENTS_GTK] -OBJ_FILES = common/gtk_events.o -SUBSYSTEM = gtksamba -INIT_FUNCTION = events_gtk_init -PRIVATE_DEPENDENCIES = gtk -############################## - -[LIBRARY::gtksamba] -VERSION = 0.0.1 -SO_VERSION = 0 -DESCRIPTION = Common Samba-related widgets for GTK+ applications -PUBLIC_HEADERS = common/gtk-smb.h common/select.h -OBJ_FILES = common/gtk-smb.o \ - common/select.o \ - common/credentials.o -PRIVATE_DEPENDENCIES = CHARSET LIBSAMBA-UTIL gtk RPC_NDR_SAMR EVENTS_GTK - -[BINARY::gregedit] -INSTALLDIR = BINDIR -OBJ_FILES = tools/gregedit.o -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG registry gtksamba -MANPAGE = man/gregedit.1 - -[BINARY::gepdump] -INSTALLDIR = BINDIR -MANPAGE = man/gepdump.1 -OBJ_FILES = tools/gepdump.o -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG gtksamba RPC_NDR_EPMAPPER RPC_NDR_MGMT - -[BINARY::gwcrontab] -INSTALLDIR = BINDIR -MANPAGE = man/gwcrontab.1 -OBJ_FILES = tools/gwcrontab.o -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG gtksamba RPC_NDR_ATSVC - -[BINARY::gwsvcctl] -INSTALLDIR = BINDIR -MANPAGE = man/gwsvcctl.1 -OBJ_FILES = tools/gwsvcctl.o -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG gtksamba RPC_NDR_SVCCTL - -# This binary is disabled for now as it doesn't do anything useful yet... -[BINARY::gwsam] -#INSTALLDIR = BINDIR -OBJ_FILES = tools/gwsam.o tools/gwsam_user.o -PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG RPC_NDR_SAMR gtksamba diff --git a/source4/gtk/man/gepdump.1.xml b/source4/gtk/man/gepdump.1.xml deleted file mode 100644 index 253b3623dc..0000000000 --- a/source4/gtk/man/gepdump.1.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> - -<refentry id="gepdump.1"> - -<refmeta> - <refentrytitle>gepdump</refentrytitle> - <manvolnum>1</manvolnum> -</refmeta> - - -<refnamediv> - <refname>gepdump</refname> - <refpurpose>Endpoint mapper viewer in GTK+</refpurpose> -</refnamediv> - -<refsynopsisdiv> - <cmdsynopsis> - <command>gepdump</command> - </cmdsynopsis> -</refsynopsisdiv> - -<refsect1> - <title>DESCRIPTION</title> - - <para>gepdump is a simple Gtk+-based DCE/RPC analysis tool that is -capable of showing the endpoints on a remote host and which interfaces are -available over those endpoints. It also features the ability to look up statistics for each interface.</para> - -</refsect1> - -<refsect1> - <title>VERSION</title> - - <para>This man page is correct for version 4.0 of the Samba suite.</para> -</refsect1> - -<refsect1> - <title>SEE ALSO</title> - - <para>gregedit</para> - -</refsect1> - -<refsect1> - <title>AUTHOR</title> - - <para>This utility is part of the <ulink url="http://www.samba.org/">Samba</ulink> suite, which is developed by the global <ulink url="http://www.samba.org/samba/team/">Samba Team</ulink>.</para> - - <para>This manpage and gepdump were written by Jelmer Vernooij. </para> - -</refsect1> - -</refentry> diff --git a/source4/gtk/man/gregedit.1.xml b/source4/gtk/man/gregedit.1.xml deleted file mode 100644 index 1729c4ac63..0000000000 --- a/source4/gtk/man/gregedit.1.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> - -<refentry id="gregedit.1"> - -<refmeta> - <refentrytitle>gregedit</refentrytitle> - <manvolnum>1</manvolnum> -</refmeta> - - -<refnamediv> - <refname>gregedit</refname> - <refpurpose>Windows registry file viewer for GTK+</refpurpose> -</refnamediv> - -<refsynopsisdiv> - <cmdsynopsis> - <command>gregedit</command> - <arg choice="opt">--help</arg> - <arg choice="opt">--backend=BACKEND</arg> - <arg choice="opt">--credentials=CREDENTIALS</arg> - <arg choice="opt">location</arg> - </cmdsynopsis> -</refsynopsisdiv> - -<refsect1> - <title>DESCRIPTION</title> - - <para>gregedit is a GTK+ frontend to the Windows registry file support - in Samba4. It currently supports NT4 file, 9x file, gconf, remote - Windows registries and a file system backend. - </para> - - <para>gregedit tries to imitate the Windows regedit.exe program as much - as possible.</para> - -</refsect1> - - -<refsect1> - <title>OPTIONS</title> - - <variablelist> - <varlistentry> - <term>--help</term> - <listitem><para> - Show list of available options.</para></listitem> - </varlistentry> - - <varlistentry> - <term>--backend BACKEND</term> - <listitem><para>Name of backend to load. Possible values are: - w95, nt4, gconf, dir and rpc. The default is <emphasis>dir</emphasis>. - </para></listitem> - </varlistentry> - - <varlistentry> - <term>--credentials=CREDENTIALS</term> - <listitem><para> - Credentials to use, if any. Password should be separated from user name by a percent sign.</para></listitem> - </varlistentry> - </variablelist> -</refsect1> - -<refsect1> - <title>VERSION</title> - - <para>This man page is correct for version 4.0 of the Samba suite.</para> -</refsect1> - -<refsect1> - <title>SEE ALSO</title> - -</refsect1> - -<refsect1> - <title>AUTHOR</title> - - <para>This utility is part of the <ulink url="http://www.samba.org/">Samba</ulink> suite, which is developed by the global <ulink url="http://www.samba.org/samba/team/">Samba Team</ulink>.</para> - - <para>This manpage and gregedit were written by Jelmer Vernooij. </para> - -</refsect1> - -</refentry> diff --git a/source4/gtk/man/gwcrontab.1.xml b/source4/gtk/man/gwcrontab.1.xml deleted file mode 100644 index 73137ca07e..0000000000 --- a/source4/gtk/man/gwcrontab.1.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> - -<refentry id="gwcrontab.1"> - -<refmeta> - <refentrytitle>gwcrontab</refentrytitle> - <manvolnum>1</manvolnum> -</refmeta> - - -<refnamediv> - <refname>gwcrontab</refname> - <refpurpose>Task planning frontend for DCE/RPC</refpurpose> -</refnamediv> - -<refsynopsisdiv> - <cmdsynopsis> - <command>gwcrontab</command> - </cmdsynopsis> -</refsynopsisdiv> - -<refsect1> - <title>DESCRIPTION</title> - - <para>gwcrontab is a simple remote frontend to the Windows atsvc service. This service performs the same tasks as <emphasis>at</emphasis> and <emphasis>cron</emphasis> do on POSIX systems. </para> - - <para>The GUI is aimed to look similar to the "Planning Tasks" application in Windows.</para> - -</refsect1> - -<refsect1> - <title>VERSION</title> - - <para>This man page is correct for version 4.0 of the Samba suite.</para> -</refsect1> - -<refsect1> - <title>AUTHOR</title> - - <para>This utility is part of the <ulink url="http://www.samba.org/">Samba</ulink> suite, which is developed by the global <ulink url="http://www.samba.org/samba/team/">Samba Team</ulink>.</para> - - <para>This manpage and gwcrontab were written by Jelmer Vernooij. </para> - -</refsect1> - -</refentry> diff --git a/source4/gtk/man/gwsvcctl.1.xml b/source4/gtk/man/gwsvcctl.1.xml deleted file mode 100644 index 01b99b750a..0000000000 --- a/source4/gtk/man/gwsvcctl.1.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> - -<refentry id="gwsvcctl.1"> - -<refmeta> - <refentrytitle>gwsvcctl</refentrytitle> - <manvolnum>1</manvolnum> -</refmeta> - - -<refnamediv> - <refname>gwsvcctl</refname> - <refpurpose>Task planning frontend for DCE/RPC</refpurpose> -</refnamediv> - -<refsynopsisdiv> - <cmdsynopsis> - <command>gwsvcctl</command> - </cmdsynopsis> -</refsynopsisdiv> - -<refsect1> - <title>DESCRIPTION</title> - - <para>gwsvcctl is a simple remote frontend to the Windows srvsvc service. - This service allows restarting, stop and starting remote services. - </para> - -</refsect1> - -<refsect1> - <title>VERSION</title> - - <para>This man page is correct for version 4.0 of the Samba suite.</para> -</refsect1> - -<refsect1> - <title>AUTHOR</title> - - <para>This utility is part of the <ulink url="http://www.samba.org/">Samba</ulink> suite, which is developed by the global <ulink url="http://www.samba.org/samba/team/">Samba Team</ulink>.</para> - - <para>This manpage and gwsvcctl were written by Jelmer Vernooij. </para> - -</refsect1> - -</refentry> diff --git a/source4/gtk/meta/gepdump.desktop b/source4/gtk/meta/gepdump.desktop deleted file mode 100644 index 4d3fab8209..0000000000 --- a/source4/gtk/meta/gepdump.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Endpoint Dumper -Comment=Show DCE/RPC endpoint mapper -Exec=gepdump -#Icon=media-player-48.png -Terminal=false -Type=Application -Categories=GNOME;GTK;Application;DCE/RPC;Endpoint;Samba; -StartupNotify=true diff --git a/source4/gtk/meta/gregedit.desktop b/source4/gtk/meta/gregedit.desktop deleted file mode 100644 index d00bd678cb..0000000000 --- a/source4/gtk/meta/gregedit.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Registry Editor -Comment=Edit Windows-Style Registry files -Exec=gregedit -#Icon=media-player-48.png -Terminal=false -Type=Application -Categories=GNOME;GTK;Application;Registry;Samba; -StartupNotify=true diff --git a/source4/gtk/meta/gwcrontab.desktop b/source4/gtk/meta/gwcrontab.desktop deleted file mode 100644 index d23106ee0c..0000000000 --- a/source4/gtk/meta/gwcrontab.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Windows Job Scheduler -Comment=Windows Job Scheduler -Exec=gwcrontab -#Icon=media-player-48.png -Terminal=false -Type=Application -Categories=GNOME;GTK;Application;Crontab;At;Samba; -StartupNotify=true diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c deleted file mode 100644 index e8986f453a..0000000000 --- a/source4/gtk/tools/gepdump.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ Endpoint Mapper frontend - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#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" - -/* - * Show: - * - RPC statistics - * - Available interfaces - * - Per interface: available endpoints - * - Per interface auth details - */ - -static GtkWidget *mainwin; -static GtkTreeStore *store_eps; -static GtkWidget *table_statistics; -static GtkWidget *lbl_calls_in, *lbl_calls_out, *lbl_pkts_in, *lbl_pkts_out; -static GtkWidget *lbl_iface_version, *lbl_iface_uuid, *lbl_iface_name; -static GtkListStore *store_princ_names; -static GtkWidget *mnu_refresh; -TALLOC_CTX *eps_ctx = NULL; -TALLOC_CTX *conn_ctx = NULL; - -static struct dcerpc_pipe *epmapper_pipe; -static struct dcerpc_pipe *mgmt_pipe; - -static void on_quit1_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - gtk_main_quit(); -} - - -static void on_about1_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gepdump")); - gtk_dialog_run(aboutwin); - gtk_widget_destroy(GTK_WIDGET(aboutwin)); -} - -static const char *get_protocol_name(enum epm_protocol protocol) -{ - switch (protocol) { - case EPM_PROTOCOL_UUID: return "UUID"; - case EPM_PROTOCOL_NCACN: return "NCACN"; - case EPM_PROTOCOL_NCALRPC: return "NCALRPC"; - case EPM_PROTOCOL_NCADG: return "NCADG"; - case EPM_PROTOCOL_IP: return "IP"; - case EPM_PROTOCOL_TCP: return "TCP"; - case EPM_PROTOCOL_NETBIOS: return "NetBIOS"; - case EPM_PROTOCOL_SMB: return "SMB"; - case EPM_PROTOCOL_PIPE: return "PIPE"; - case EPM_PROTOCOL_UNIX_DS: return "Unix"; - default: return "Unknown"; - } -} - -static void add_epm_entry(TALLOC_CTX *mem_ctx, const char *annotation, struct epm_tower *t) -{ - struct dcerpc_binding *bd; - int i; - NTSTATUS status; - GtkTreeIter toweriter; - - status = dcerpc_binding_from_tower(mem_ctx, t, &bd); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "Error creating binding from tower", status); - return; - } - - /* Don't show UUID's */ - ZERO_STRUCT(bd->object); - - gtk_tree_store_append(store_eps, &toweriter, NULL); - gtk_tree_store_set(store_eps, &toweriter, 0, strdup(annotation), 1, strdup(dcerpc_binding_string(mem_ctx, bd)), 2, t, -1); - - for (i = 0; i < t->num_floors; i++) { - const char *data; - struct dcerpc_syntax_id syntax; - GtkTreeIter iter; - gtk_tree_store_append(store_eps, &iter, &toweriter); - - dcerpc_floor_get_lhs_data(&t->floors[i], &syntax); - if (t->floors[i].lhs.protocol == EPM_PROTOCOL_UUID) { - data = GUID_string(mem_ctx, &syntax.uuid); - } else { - data = dcerpc_floor_get_rhs_data(mem_ctx, &t->floors[i]); - } - - gtk_tree_store_set(store_eps, &iter, 0, get_protocol_name(t->floors[i].lhs.protocol), 1, data, -1); - } -} - -static void refresh_eps(void) -{ - NTSTATUS status; - struct epm_Lookup r; - struct GUID uuid; - struct rpc_if_id_t iface; - struct policy_handle handle; - TALLOC_CTX *mem_ctx = talloc_init("dump"); - - talloc_free(eps_ctx); - - ZERO_STRUCT(handle); - - r.in.inquiry_type = 0; - r.in.object = &uuid; - r.in.interface_id = &iface; - r.in.vers_option = 0; - r.in.entry_handle = r.out.entry_handle = &handle; - r.in.max_ents = 10; - - gtk_tree_store_clear(store_eps); - - eps_ctx = talloc_init("current endpoint list data"); - - do { - int i; - ZERO_STRUCT(uuid); - ZERO_STRUCT(iface); - - status = dcerpc_epm_Lookup(epmapper_pipe, eps_ctx, &r); - if (!NT_STATUS_IS_OK(status) || r.out.result != 0) { - break; - } - for (i=0;i<*r.out.num_ents;i++) { - add_epm_entry(mem_ctx, r.out.entries[i].annotation, &r.out.entries[i].tower->tower); - } - - } while (NT_STATUS_IS_OK(status) && - r.out.result == 0 && - *r.out.num_ents == r.in.max_ents); - - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "Error adding endpoint mapper entry", status); - talloc_free(mem_ctx); - return; - } - talloc_free(mem_ctx); -} - -static void on_refresh_clicked (GtkButton *btn, gpointer user_data) -{ - refresh_eps(); -} - -static void on_connect_clicked(GtkButton *btn, gpointer user_data) -{ - NTSTATUS status; - TALLOC_CTX *mem_ctx = talloc_init("connect"); - - epmapper_pipe = gtk_connect_rpc_interface(mem_ctx, &dcerpc_table_epmapper); - if (epmapper_pipe == NULL) - return; - - gtk_widget_set_sensitive( mnu_refresh, True ); - - refresh_eps(); - - status = dcerpc_secondary_context(epmapper_pipe, &mgmt_pipe, &dcerpc_table_mgmt); - - if (NT_STATUS_IS_ERR(status)) { - mgmt_pipe = NULL; - gtk_show_ntstatus(NULL, "Error connecting to mgmt interface over secondary connection", status); - } -} - -static gboolean on_eps_select(GtkTreeSelection *selection, - GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data) -{ - NTSTATUS status; - TALLOC_CTX *mem_ctx; - - if (mgmt_pipe == NULL) - return FALSE; - - mem_ctx = talloc_init("eps"); - - { - /* Do an InqStats call */ - struct mgmt_inq_stats r; - - r.in.max_count = MGMT_STATS_ARRAY_MAX_SIZE; - r.in.unknown = 0; - - status = dcerpc_mgmt_inq_stats(mgmt_pipe, mem_ctx, &r); - if (NT_STATUS_IS_ERR(status)) { - gtk_show_ntstatus(NULL, "Error inquiring statistics", status); - return TRUE; - } - - if (r.out.statistics->count != MGMT_STATS_ARRAY_MAX_SIZE) { - printf("Unexpected array size %d\n", r.out.statistics->count); - return False; - } - - gtk_label_set_text(GTK_LABEL(lbl_calls_in), talloc_asprintf(mem_ctx, "%6d", r.out.statistics->statistics[MGMT_STATS_CALLS_IN])); - gtk_label_set_text(GTK_LABEL(lbl_calls_out), talloc_asprintf(mem_ctx, "%6d", r.out.statistics->statistics[MGMT_STATS_CALLS_OUT])); - gtk_label_set_text(GTK_LABEL(lbl_pkts_in), talloc_asprintf(mem_ctx, "%6d", r.out.statistics->statistics[MGMT_STATS_PKTS_IN])); - gtk_label_set_text(GTK_LABEL(lbl_pkts_out), talloc_asprintf(mem_ctx, "%6d", r.out.statistics->statistics[MGMT_STATS_PKTS_OUT])); - } - - { - struct mgmt_inq_princ_name r; - int i; - - gtk_list_store_clear(store_princ_names); - - for (i=0;i<100;i++) { - r.in.authn_proto = i; /* DCERPC_AUTH_TYPE_* */ - r.in.princ_name_size = 100; - - status = dcerpc_mgmt_inq_princ_name(mgmt_pipe, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - continue; - } - if (W_ERROR_IS_OK(r.out.result)) { - GtkTreeIter iter; - const char *name = gensec_get_name_by_authtype(i); - char *protocol; - if (name) { - protocol = talloc_asprintf(mem_ctx, "%u (%s)", i, name); - } else { - protocol = talloc_asprintf(mem_ctx, "%u", i); - } - gtk_list_store_append(store_princ_names, &iter); - gtk_list_store_set(store_princ_names, &iter, - 0, protocol, - 1, r.out.princ_name, - -1); - - } - } - } - - return TRUE; -} - - -static GtkWidget* create_mainwindow (void) -{ - GtkWidget *mainwindow; - GtkWidget *vbox1, *vbox2, *vbox3; - GtkWidget *menubar1; - GtkWidget *menuitem1; - GtkWidget *menuitem1_menu; - GtkWidget *quit1; - GtkWidget *menuitem4; - GtkWidget *menuitem4_menu; - GtkWidget *mnu_connect; - GtkWidget *treeview_princ_names; - GtkWidget *about1; - GtkWidget *hbox2; - GtkWidget *scrolledwindow1; - GtkWidget *frame1; - GtkWidget *tree_eps; - GtkTreeViewColumn *curcol; - GtkCellRenderer *renderer; - GtkWidget *statusbar; - GtkAccelGroup *accel_group; - - accel_group = gtk_accel_group_new (); - - mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (mainwindow), "Gtk+ Endpoint Mapper Viewer"); - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - gtk_container_add (GTK_CONTAINER (mainwindow), vbox1); - - menubar1 = gtk_menu_bar_new (); - gtk_widget_show (menubar1); - gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); - - menuitem1 = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_widget_show (menuitem1); - gtk_container_add (GTK_CONTAINER (menubar1), menuitem1); - - menuitem1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu); - - mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect"); - gtk_container_add(GTK_CONTAINER(menuitem1_menu), mnu_connect); - - mnu_refresh = gtk_menu_item_new_with_mnemonic ("_Refresh"); - gtk_container_add(GTK_CONTAINER(menuitem1_menu), mnu_refresh); - gtk_widget_set_sensitive( mnu_refresh, False ); - - quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit1); - - menuitem4 = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_container_add (GTK_CONTAINER (menubar1), menuitem4); - - menuitem4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); - - about1 = gtk_menu_item_new_with_mnemonic ("_About"); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), about1); - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (vbox1), hbox2); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX(hbox2), scrolledwindow1, TRUE, TRUE, 0); - - tree_eps = gtk_tree_view_new (); - - 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(tree_eps), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Binding String"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1); - - - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_eps), curcol); - - store_eps = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_eps), GTK_TREE_MODEL(store_eps)); - g_object_unref(store_eps); - - gtk_container_add (GTK_CONTAINER (scrolledwindow1), tree_eps); - - gtk_tree_selection_set_select_function (gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_eps)), on_eps_select, NULL, NULL); - - vbox2 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (hbox2), vbox2); - - frame1 = gtk_frame_new("Interface"); - gtk_container_add (GTK_CONTAINER(vbox2), frame1); - - vbox3 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame1), vbox3); - gtk_container_add (GTK_CONTAINER (vbox3), lbl_iface_uuid = gtk_label_new("")); - gtk_container_add (GTK_CONTAINER (vbox3), lbl_iface_version = gtk_label_new("")); - gtk_container_add (GTK_CONTAINER (vbox3), lbl_iface_name = gtk_label_new("")); - - frame1 = gtk_frame_new("Statistics"); - gtk_container_add (GTK_CONTAINER(vbox2), frame1); - - table_statistics = gtk_table_new(4, 2, TRUE); - gtk_container_add (GTK_CONTAINER(frame1), table_statistics); - - gtk_table_attach_defaults (GTK_TABLE(table_statistics), gtk_label_new("Calls In: "), 0, 1, 0, 1); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), lbl_calls_in = gtk_label_new(""), 1, 2, 0, 1); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), gtk_label_new("Calls Out: "), 0, 1, 1, 2); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), lbl_calls_out = gtk_label_new(""), 1, 2, 1, 2); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), gtk_label_new("Packets In: "), 0, 1, 2, 3); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), lbl_pkts_in = gtk_label_new(""), 1, 2, 2, 3); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), gtk_label_new("Packets Out: "), 0, 1, 3, 4); - gtk_table_attach_defaults (GTK_TABLE(table_statistics), lbl_pkts_out = gtk_label_new(""), 1, 2, 3, 4); - - frame1 = gtk_frame_new("Authentication"); - gtk_container_add (GTK_CONTAINER(vbox2), frame1); - - treeview_princ_names = gtk_tree_view_new(); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Protocol"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview_princ_names), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Principal Name"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview_princ_names), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1); - - gtk_container_add (GTK_CONTAINER(frame1), treeview_princ_names); - - store_princ_names = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(treeview_princ_names), GTK_TREE_MODEL(store_princ_names)); - g_object_unref(store_princ_names); - - statusbar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0); - - g_signal_connect ((gpointer) quit1, "activate", - G_CALLBACK (on_quit1_activate), - NULL); - g_signal_connect ((gpointer) about1, "activate", - G_CALLBACK (on_about1_activate), - NULL); - g_signal_connect ((gpointer) mnu_connect, "activate", - G_CALLBACK (on_connect_clicked), - NULL); - g_signal_connect ((gpointer) mnu_refresh, "activate", - G_CALLBACK (on_refresh_clicked), - NULL); - - gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group); - - return mainwindow; -} - - -int main(int argc, char **argv) -{ - lp_load(); - setup_logging(argv[0], DEBUG_STDERR); - - dcerpc_init(); - - gtk_init(&argc, &argv); - mainwin = create_mainwindow(); - gtk_widget_show_all(mainwin); - - return gtk_event_loop(); -} diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c deleted file mode 100644 index cf03eebec8..0000000000 --- a/source4/gtk/tools/gregedit.c +++ /dev/null @@ -1,989 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ registry frontend - - Copyright (C) Jelmer Vernooij 2004-2005 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "lib/registry/registry.h" -#include "gtk/common/gtk-smb.h" -#include "lib/events/events.h" -#include "lib/registry/reg_backend_rpc.h" -#include "auth/credentials/credentials.h" - -static GtkTreeStore *store_keys; -static GtkListStore *store_vals; -static GtkWidget *tree_keys; -static GtkWidget *tree_vals; -static GtkWidget *mainwin; -static GtkWidget *mnu_add_key, *mnu_set_value, *mnu_del_key, *mnu_del_value, *mnu_find; -static TALLOC_CTX *mem_ctx; /* FIXME: Split up */ - -static GtkWidget *save; -static GtkWidget *save_as; -static GtkWidget* create_openfilewin (void); -static GtkWidget* create_savefilewin (void); -struct registry_context *registry = NULL; -struct registry_key *current_key = NULL; - -static GtkWidget* create_FindDialog (void) -{ - GtkWidget *FindDialog; - GtkWidget *dialog_vbox2; - GtkWidget *vbox1; - GtkWidget *hbox1; - GtkWidget *label6; - GtkWidget *entry_pattern; - GtkWidget *frame3; - GtkWidget *alignment3; - GtkWidget *vbox2; - GtkWidget *checkbutton1; - GtkWidget *checkbutton2; - GtkWidget *checkbutton3; - GtkWidget *label7; - GtkWidget *dialog_action_area2; - GtkWidget *cancelbutton2; - GtkWidget *okbutton2; - - FindDialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (FindDialog), "Find Key or Value"); - gtk_window_set_resizable (GTK_WINDOW (FindDialog), FALSE); - gtk_window_set_type_hint (GTK_WINDOW (FindDialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox2 = GTK_DIALOG (FindDialog)->vbox; - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (dialog_vbox2), vbox1, TRUE, TRUE, 0); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); - - label6 = gtk_label_new ("Find String"); - gtk_box_pack_start (GTK_BOX (hbox1), label6, FALSE, FALSE, 0); - - entry_pattern = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox1), entry_pattern, TRUE, TRUE, 0); - - frame3 = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox1), frame3, TRUE, TRUE, 0); - gtk_frame_set_shadow_type (GTK_FRAME (frame3), GTK_SHADOW_NONE); - - alignment3 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_container_add (GTK_CONTAINER (frame3), alignment3); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment3), 0, 0, 12, 0); - - vbox2 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment3), vbox2); - - checkbutton1 = gtk_check_button_new_with_mnemonic ("_Key Names"); - gtk_box_pack_start (GTK_BOX (vbox2), checkbutton1, FALSE, FALSE, 0); - - checkbutton2 = gtk_check_button_new_with_mnemonic ("_Value Names"); - gtk_box_pack_start (GTK_BOX (vbox2), checkbutton2, FALSE, FALSE, 0); - - checkbutton3 = gtk_check_button_new_with_mnemonic ("Value _Data"); - gtk_box_pack_start (GTK_BOX (vbox2), checkbutton3, FALSE, FALSE, 0); - - label7 = gtk_label_new ("<b>Search in</b>"); - gtk_frame_set_label_widget (GTK_FRAME (frame3), label7); - gtk_label_set_use_markup (GTK_LABEL (label7), TRUE); - - dialog_action_area2 = GTK_DIALOG (FindDialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); - - cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (FindDialog), cancelbutton2, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT); - - okbutton2 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (FindDialog), okbutton2, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT); - - gtk_widget_show_all (dialog_vbox2); - - return FindDialog; -} - -static GtkWidget* create_SetValueDialog (GtkWidget **entry_name, GtkWidget **entry_type, GtkWidget **entry_data) -{ - GtkWidget *SetValueDialog; - GtkWidget *dialog_vbox1; - GtkWidget *table1; - GtkWidget *label3; - GtkWidget *label4; - GtkWidget *label5; - GtkWidget *entry_value_name; - GtkWidget *value_data; - GtkWidget *combo_data_type; - GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; - GtkWidget *okbutton1; - - SetValueDialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (SetValueDialog), "Set Registry Value"); - gtk_window_set_position (GTK_WINDOW (SetValueDialog), GTK_WIN_POS_CENTER); - gtk_window_set_resizable (GTK_WINDOW (SetValueDialog), FALSE); - gtk_window_set_type_hint (GTK_WINDOW (SetValueDialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox1 = GTK_DIALOG (SetValueDialog)->vbox; - - table1 = gtk_table_new (3, 2, FALSE); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0); - - label3 = gtk_label_new ("Value name:"); - gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5); - - label4 = gtk_label_new ("Data Type:"); - gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5); - - label5 = gtk_label_new ("Data:"); - gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5); - - *entry_name = entry_value_name = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_value_name, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - *entry_data = value_data = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), value_data, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - *entry_type = combo_data_type = gtk_combo_box_new_text (); - - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_NONE"); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_SZ"); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_EXPAND_SZ"); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_BINARY"); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_DWORD_LE"); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo_data_type), "REG_DWORD_BE"); - - gtk_table_attach (GTK_TABLE (table1), combo_data_type, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - dialog_action_area1 = GTK_DIALOG (SetValueDialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (SetValueDialog), cancelbutton1, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (SetValueDialog), okbutton1, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); - - gtk_widget_show_all (dialog_vbox1); - - return SetValueDialog; -} - -static GtkWidget* create_NewKeyDialog (GtkWidget **name_entry) -{ - GtkWidget *NewKeyDialog; - GtkWidget *dialog_vbox2; - GtkWidget *hbox1; - GtkWidget *label6; - GtkWidget *entry_key_name; - GtkWidget *dialog_action_area2; - GtkWidget *cancelbutton2; - GtkWidget *okbutton2; - - NewKeyDialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (NewKeyDialog), "New Registry Key"); - gtk_window_set_position (GTK_WINDOW (NewKeyDialog), GTK_WIN_POS_CENTER); - gtk_window_set_resizable (GTK_WINDOW (NewKeyDialog), FALSE); - gtk_window_set_type_hint (GTK_WINDOW (NewKeyDialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox2 = GTK_DIALOG (NewKeyDialog)->vbox; - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (dialog_vbox2), hbox1, TRUE, TRUE, 0); - - label6 = gtk_label_new ("Name:"); - gtk_box_pack_start (GTK_BOX (hbox1), label6, FALSE, FALSE, 0); - - entry_key_name = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox1), entry_key_name, TRUE, TRUE, 0); - - dialog_action_area2 = GTK_DIALOG (NewKeyDialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); - - *name_entry = entry_key_name; - - cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (NewKeyDialog), cancelbutton2, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT); - - okbutton2 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (NewKeyDialog), okbutton2, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT); - - gtk_widget_show_all (dialog_vbox2); - - return NewKeyDialog; -} - -static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *arg2) -{ - GtkTreeIter firstiter, iter, tmpiter; - struct registry_key *k, *sub; - char *name; - WERROR error; - int i; - - gtk_tree_model_iter_children(GTK_TREE_MODEL(store_keys), &firstiter, parent); - - /* See if this row has ever had a name gtk_tree_store_set()'ed to it. - If not, read the directory contents */ - gtk_tree_model_get(GTK_TREE_MODEL(store_keys), &firstiter, 0, &name, -1); - - if(name) return; - - gtk_tree_model_get(GTK_TREE_MODEL(store_keys), parent, 1, &k, -1); - - g_assert(k); - - for(i = 0; W_ERROR_IS_OK(error = reg_key_get_subkey_by_index(mem_ctx, k, i, &sub)); i++) { - uint32_t count; - /* Replace the blank child with the first directory entry - You may be tempted to remove the blank child node and then - append a new one. Don't. If you remove the blank child - node GTK gets confused and won't expand the parent row. */ - - if(i == 0) { - iter = firstiter; - } else { - gtk_tree_store_append(store_keys, &iter, parent); - } - gtk_tree_store_set (store_keys, - &iter, - 0, - sub->name, - 1, - sub, - -1); - - if(W_ERROR_IS_OK(reg_key_num_subkeys(sub, &count)) && count > 0) - gtk_tree_store_append(store_keys, &tmpiter, &iter); - } - - if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - gtk_show_werror(mainwin, "While enumerating subkeys", error); - } -} - -static void registry_load_hive(struct registry_key *root) -{ - GtkTreeIter iter, tmpiter; - gtk_list_store_clear(store_vals); - /* Add the root */ - gtk_tree_store_append(store_keys, &iter, NULL); - gtk_tree_store_set (store_keys, - &iter, - 0, - root->name?root->name:"", - 1, - root, - -1); - - gtk_tree_store_append(store_keys, &tmpiter, &iter); - - gtk_widget_set_sensitive( save, True ); - gtk_widget_set_sensitive( save_as, True ); -} - -static void registry_load_root(void) -{ - struct registry_key *root; - uint32_t i = 0; - if(!registry) return; - - gtk_list_store_clear(store_vals); - gtk_tree_store_clear(store_keys); - - for(i = HKEY_CLASSES_ROOT; i <= HKEY_PERFORMANCE_NLSTEXT; i++) - { - if (!W_ERROR_IS_OK(reg_get_predefined_key(registry, i, &root))) { continue; } - - registry_load_hive(root); - } -} - -static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - GtkWidget *openfilewin; - gint result; - char *filename, *tmp; - struct registry_key *root; - WERROR error; - - openfilewin = create_openfilewin(); - - result = gtk_dialog_run(GTK_DIALOG(openfilewin)); - - switch(result) { - case GTK_RESPONSE_OK: - filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(openfilewin))); - error = reg_open_hive(NULL, user_data, filename, NULL, NULL, &root); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while opening hive", error); - break; - } - - tmp = g_strdup_printf("Registry Editor - %s", filename); - gtk_window_set_title (GTK_WINDOW (mainwin), tmp); - g_free(tmp); - gtk_tree_store_clear(store_keys); - registry_load_hive(root); - break; - default: - break; - } - - gtk_widget_destroy(openfilewin); -} - -static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - struct registry_key *root; - WERROR error = reg_open_hive(NULL, "gconf", NULL, NULL, NULL, &root); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while opening GConf", error); - return; - } - - gtk_window_set_title (GTK_WINDOW (mainwin), "Registry Editor - GConf"); - - gtk_tree_store_clear(store_keys); - registry_load_hive(root); -} - -static void on_open_local_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - WERROR error = reg_open_local(NULL, ®istry, NULL, NULL); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while opening local registry", error); - return; - } - registry_load_root(); -} - -static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - char *tmp; - GtkWidget *rpcwin = GTK_WIDGET(gtk_rpc_binding_dialog_new(NULL)); - gint result = gtk_dialog_run(GTK_DIALOG(rpcwin)); - WERROR error; - struct cli_credentials *creds; - - if(result != GTK_RESPONSE_ACCEPT) - { - gtk_widget_destroy(rpcwin); - return; - } - - creds = cli_credentials_init(mem_ctx); - cli_credentials_guess(creds); - cli_credentials_set_gtk_callbacks(creds); - - error = reg_open_remote(®istry, - NULL, - creds, - gtk_rpc_binding_dialog_get_binding_string(GTK_RPC_BINDING_DIALOG(rpcwin), mem_ctx), - NULL); - - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while opening remote registry", error); - gtk_widget_destroy(rpcwin); - return; - } - - 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_as_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - gint result; - WERROR error = WERR_OK; - GtkWidget *savefilewin = create_savefilewin(); - result = gtk_dialog_run(GTK_DIALOG(savefilewin)); - switch(result) { - case GTK_RESPONSE_OK: - /* FIXME: error = reg_dump(registry, gtk_file_selection_get_filename(GTK_FILE_SELECTION(savefilewin))); */ - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while saving as", error); - } - break; - - default: - break; - - } - gtk_widget_destroy(savefilewin); -} - - -static void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - gtk_main_quit(); -} - - -static void on_delete_value_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - WERROR error; - GtkTreeIter iter; - const char *value; - - if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_vals)), NULL, &iter)) { - return; - } - - gtk_tree_model_get(GTK_TREE_MODEL(store_vals), &iter, 0, &value, -1); - - error = reg_del_value(current_key, value); - - if (!W_ERROR_IS_OK(error)) { - gtk_show_werror(NULL, "Error while deleting value", error); - return; - } -} - -static void on_delete_key_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - WERROR error; - GtkTreeIter iter, parentiter; - struct registry_key *parent_key; - - if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_keys)), NULL, &iter)) { - return; - } - - if (!gtk_tree_model_iter_parent(GTK_TREE_MODEL(store_keys), &parentiter, &iter)) { - return; - } - - gtk_tree_model_get(GTK_TREE_MODEL(store_keys), &parentiter, 1, &parent_key, -1); - - error = reg_key_del(parent_key, current_key->name); - - if (!W_ERROR_IS_OK(error)) { - gtk_show_werror(NULL, "Error while deleting key", error); - return; - } -} - -static void on_add_key_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkWidget *entry; - GtkDialog *addwin = GTK_DIALOG(create_NewKeyDialog(&entry)); - gint result = gtk_dialog_run(addwin); - - if (result == GTK_RESPONSE_OK) - { - struct registry_key *newkey; - WERROR error = reg_key_add_name(mem_ctx, current_key, gtk_entry_get_text(GTK_ENTRY(entry)), 0, NULL, &newkey); - - if (!W_ERROR_IS_OK(error)) { - gtk_show_werror(NULL, "Error while adding key", error); - } - } - - gtk_widget_destroy(GTK_WIDGET(addwin)); -} - -static void on_value_activate(GtkTreeView *treeview, GtkTreePath *arg1, - GtkTreeViewColumn *arg2, gpointer user_data) -{ - GtkWidget *entry_name, *entry_type, *entry_value; - GtkDialog *addwin = GTK_DIALOG(create_SetValueDialog(&entry_name, &entry_type, &entry_value)); - GtkTreeIter iter; - struct registry_value *value; - gint result; - - gtk_tree_model_get_iter(GTK_TREE_MODEL(store_vals), &iter, arg1); - - gtk_tree_model_get(GTK_TREE_MODEL(store_vals), &iter, 3, &value, -1); - - gtk_widget_set_sensitive(entry_name, FALSE); - gtk_entry_set_text(GTK_ENTRY(entry_name), value->name); - gtk_entry_set_text(GTK_ENTRY(entry_value), reg_val_data_string(mem_ctx, value->data_type, &value->data)); - gtk_combo_box_set_active(GTK_COMBO_BOX(entry_type), value->data_type); - - result = gtk_dialog_run(addwin); - if (result == GTK_RESPONSE_OK) - { - WERROR error; - DATA_BLOB data; - uint32_t data_type; - - reg_string_to_val(mem_ctx,str_regtype(gtk_combo_box_get_active(GTK_COMBO_BOX(entry_type))), gtk_entry_get_text(GTK_ENTRY(entry_value)), &data_type, &data); - - error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), data_type, data); - - if (!W_ERROR_IS_OK(error)) { - gtk_show_werror(NULL, "Error while setting value", error); - } - } - gtk_widget_destroy(GTK_WIDGET(addwin)); -} - -static void on_set_value_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkWidget *entry_name, *entry_type, *entry_value; - GtkDialog *addwin = GTK_DIALOG(create_SetValueDialog(&entry_name, &entry_type, &entry_value)); - gint result = gtk_dialog_run(addwin); - if (result == GTK_RESPONSE_OK) - { - WERROR error; - uint32_t data_type; - DATA_BLOB data; - - reg_string_to_val(mem_ctx,str_regtype(gtk_combo_box_get_active(GTK_COMBO_BOX(entry_type))), gtk_entry_get_text(GTK_ENTRY(entry_value)), &data_type, &data); - - error = reg_val_set(current_key, gtk_entry_get_text(GTK_ENTRY(entry_name)), data_type, data); - - if (!W_ERROR_IS_OK(error)) { - gtk_show_werror(NULL, "Error while setting value", error); - } - } - gtk_widget_destroy(GTK_WIDGET(addwin)); -} - -static void on_find_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *findwin = GTK_DIALOG(create_FindDialog()); - /*gint result = gtk_dialog_run(findwin); - FIXME */ - gtk_widget_destroy(GTK_WIDGET(findwin)); -} - -static void on_about_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gregedit")); - gtk_dialog_run(aboutwin); - gtk_widget_destroy(GTK_WIDGET(aboutwin)); -} - -static gboolean on_key_activate(GtkTreeSelection *selection, - GtkTreeModel *model, - GtkTreePath *path, - gboolean path_currently_selected, - gpointer data) -{ - int i; - struct registry_key *k; - struct registry_value *val; - WERROR error; - GtkTreeIter parent; - - gtk_widget_set_sensitive(mnu_add_key, !path_currently_selected); - gtk_widget_set_sensitive(mnu_set_value, !path_currently_selected); - gtk_widget_set_sensitive(mnu_del_key, !path_currently_selected); - gtk_widget_set_sensitive(mnu_del_value, !path_currently_selected); - gtk_widget_set_sensitive(mnu_find, !path_currently_selected); - - if(path_currently_selected) { - current_key = NULL; - return TRUE; - } - - gtk_tree_model_get_iter(GTK_TREE_MODEL(store_keys), &parent, path); - gtk_tree_model_get(GTK_TREE_MODEL(store_keys), &parent, 1, &k, -1); - - current_key = k; - - if (!k) return FALSE; - - gtk_list_store_clear(store_vals); - - 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, - val->name, - 1, - str_regtype(val->data_type), - 2, - reg_val_data_string(mem_ctx, val->data_type, &val->data), - 3, - val, - -1); - } - - if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) { - gtk_show_werror(mainwin, "Error while enumerating values", error); - return FALSE; - } - return TRUE; -} - -static GtkWidget* create_mainwindow(void) -{ - GtkWidget *vbox1; - GtkWidget *menubar; - GtkWidget *menu_file; - GtkWidget *menu_file_menu; - GtkWidget *open_nt4; - GtkWidget *open_ldb; - GtkWidget *open_w95; - GtkWidget *open_gconf; - GtkWidget *open_remote; - GtkWidget *open_local; - GtkWidget *separatormenuitem1; - GtkWidget *quit; - GtkWidget *men_key; - GtkWidget *men_key_menu; - GtkCellRenderer *renderer; - GtkTreeViewColumn *curcol; - GtkWidget *help; - GtkWidget *help_menu; - GtkWidget *about; - GtkWidget *hbox1; - GtkWidget *scrolledwindow1; - GtkWidget *scrolledwindow2; - GtkWidget *statusbar; - GtkAccelGroup *accel_group; - - accel_group = gtk_accel_group_new (); - - mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (mainwin), "Registry editor"); - gtk_window_set_default_size (GTK_WINDOW (mainwin), 642, 562); - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (mainwin), vbox1); - - menubar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 0); - - menu_file = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_container_add (GTK_CONTAINER (menubar), menu_file); - - menu_file_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_file), menu_file_menu); - - open_local = gtk_menu_item_new_with_mnemonic ("Open _Local"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_local); - g_signal_connect ((gpointer) open_local, "activate", - G_CALLBACK (on_open_local_activate), NULL); - - if(reg_has_backend("rpc")) { - open_remote = gtk_menu_item_new_with_mnemonic ("Open _Remote"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_remote); - - g_signal_connect ((gpointer) open_remote, "activate", - G_CALLBACK (on_open_remote_activate), - NULL); - } - - separatormenuitem1 = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menu_file_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - - if(reg_has_backend("nt4")) { - open_nt4 = gtk_image_menu_item_new_with_mnemonic("Open _NT4 file"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_nt4); - - g_signal_connect(open_nt4, "activate", - G_CALLBACK (on_open_file_activate), - discard_const_p(char, "nt4")); - } - - if(reg_has_backend("w95")) { - open_w95 = gtk_image_menu_item_new_with_mnemonic("Open Win_9x file"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_w95); - - g_signal_connect (open_w95, "activate", - G_CALLBACK (on_open_file_activate), - discard_const_p(char, "w95")); - } - - if(reg_has_backend("gconf")) { - open_gconf = gtk_image_menu_item_new_with_mnemonic ("Open _GConf"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_gconf); - - g_signal_connect ((gpointer) open_gconf, "activate", - G_CALLBACK (on_open_gconf_activate), - NULL); - } - - if(reg_has_backend("ldb")) { - open_ldb = gtk_image_menu_item_new_with_mnemonic("Open _LDB file"); - gtk_container_add (GTK_CONTAINER (menu_file_menu), open_ldb); - - g_signal_connect(open_ldb, "activate", - G_CALLBACK (on_open_file_activate), - discard_const_p(char, "ldb")); - } - - separatormenuitem1 = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menu_file_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group); - gtk_widget_set_sensitive( save, False ); - gtk_container_add (GTK_CONTAINER (menu_file_menu), save); - - save_as = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group); - gtk_widget_set_sensitive( save_as, False ); - gtk_container_add (GTK_CONTAINER (menu_file_menu), save_as); - - separatormenuitem1 = gtk_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menu_file_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); - gtk_container_add (GTK_CONTAINER (menu_file_menu), quit); - - men_key = gtk_menu_item_new_with_mnemonic ("_Key"); - gtk_container_add (GTK_CONTAINER (menubar), men_key); - - men_key_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (men_key), men_key_menu); - - mnu_add_key = gtk_image_menu_item_new_with_mnemonic("Add _Subkey"); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mnu_add_key), gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU)); - - gtk_widget_set_sensitive(mnu_add_key, False); - gtk_container_add (GTK_CONTAINER (men_key_menu), mnu_add_key); - - mnu_set_value = gtk_image_menu_item_new_with_mnemonic("Set _Value"); - gtk_widget_set_sensitive(mnu_set_value, False); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mnu_set_value), gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU)); - gtk_container_add (GTK_CONTAINER (men_key_menu), mnu_set_value); - - mnu_find = gtk_image_menu_item_new_from_stock ("gtk-find", accel_group); - gtk_widget_set_sensitive(mnu_find, False); - gtk_container_add (GTK_CONTAINER (men_key_menu), mnu_find); - - mnu_del_key = gtk_image_menu_item_new_with_mnemonic ("Delete Key"); - gtk_widget_set_sensitive(mnu_del_key, False); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mnu_del_value), gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU)); - gtk_container_add (GTK_CONTAINER (men_key_menu), mnu_del_key); - - mnu_del_value = gtk_image_menu_item_new_with_mnemonic ("Delete Value"); - gtk_widget_set_sensitive(mnu_del_value, False); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mnu_del_value), gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_MENU)); - gtk_container_add (GTK_CONTAINER (men_key_menu), mnu_del_value); - - - help = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_container_add (GTK_CONTAINER (menubar), help); - - help_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (help), help_menu); - - about = gtk_menu_item_new_with_mnemonic ("_About"); - gtk_container_add (GTK_CONTAINER (help_menu), about); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow1, TRUE, TRUE, 0); - - tree_keys = gtk_tree_view_new (); - - /* Column names */ - 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(tree_keys), curcol); - - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), tree_keys); - store_keys = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_keys), GTK_TREE_MODEL(store_keys)); - g_object_unref(store_keys); - - gtk_tree_selection_set_select_function (gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_keys)), on_key_activate, NULL, NULL); - - g_signal_connect ((gpointer) tree_keys, "row-expanded", - G_CALLBACK (expand_key), - NULL); - - - scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow2, TRUE, TRUE, 0); - - tree_vals = gtk_tree_view_new (); - /* Column names */ - - 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(tree_vals), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Type"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_vals), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Value"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree_vals), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2); - - - gtk_container_add (GTK_CONTAINER (scrolledwindow2), tree_vals); - - store_vals = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(tree_vals), GTK_TREE_MODEL(store_vals)); - g_object_unref(store_vals); - - statusbar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox1), statusbar, FALSE, FALSE, 0); - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE); - - g_signal_connect ((gpointer) save_as, "activate", - G_CALLBACK (on_save_as_activate), - NULL); - g_signal_connect ((gpointer) quit, "activate", - G_CALLBACK (on_quit_activate), - NULL); - g_signal_connect ((gpointer) mnu_add_key, "activate", - G_CALLBACK (on_add_key_activate), - NULL); - g_signal_connect ((gpointer) mnu_set_value, "activate", - G_CALLBACK (on_set_value_activate), - NULL); - g_signal_connect ((gpointer) mnu_find, "activate", - G_CALLBACK (on_find_activate), - NULL); - g_signal_connect ((gpointer) mnu_del_key, "activate", - G_CALLBACK (on_delete_key_activate), - NULL); - g_signal_connect ((gpointer) mnu_del_value, "activate", - G_CALLBACK (on_delete_value_activate), - NULL); - g_signal_connect ((gpointer) about, "activate", - G_CALLBACK (on_about_activate), - NULL); - - g_signal_connect ((gpointer) tree_vals, "row-activated", - G_CALLBACK (on_value_activate), - NULL); - - - gtk_window_add_accel_group (GTK_WINDOW (mainwin), accel_group); - - return mainwin; -} - -static GtkWidget* create_openfilewin (void) -{ - GtkWidget *openfilewin; - GtkWidget *ok_button; - GtkWidget *cancel_button; - - openfilewin = gtk_file_selection_new ("Select File"); - gtk_container_set_border_width (GTK_CONTAINER (openfilewin), 10); - - ok_button = GTK_FILE_SELECTION (openfilewin)->ok_button; - GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT); - - cancel_button = GTK_FILE_SELECTION (openfilewin)->cancel_button; - GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT); - - return openfilewin; -} - -static GtkWidget* create_savefilewin (void) -{ - GtkWidget *savefilewin; - GtkWidget *ok_button; - GtkWidget *cancel_button; - - savefilewin = gtk_file_selection_new ("Select File"); - gtk_container_set_border_width (GTK_CONTAINER (savefilewin), 10); - - ok_button = GTK_FILE_SELECTION (savefilewin)->ok_button; - GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT); - - cancel_button = GTK_FILE_SELECTION (savefilewin)->cancel_button; - GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT); - - return savefilewin; -} - -static int gregedit_load_defaults(void) -{ - WERROR error = reg_open_local(NULL, ®istry, NULL, NULL); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, "Error while loading local registry", error); - return -1; - } - registry_load_root(); - - return 0; -} - -int main(int argc, char *argv[]) -{ - int ret; - - lp_load(); - setup_logging(argv[0], DEBUG_STDERR); - - mem_ctx = talloc_init("gregedit"); - - registry_init(); - - gtk_init(&argc, &argv); - mainwin = create_mainwindow(); - gtk_widget_show_all(mainwin); - - ret = gregedit_load_defaults(); - if (ret != 0) goto failed; - - ret = gtk_event_loop(); - -failed: - talloc_free(mem_ctx); - return ret; -} diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c deleted file mode 100644 index 8b31ea12bf..0000000000 --- a/source4/gtk/tools/gwcrontab.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ Windows crontab frontend - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#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; -static GtkWidget *delete; - -static void update_joblist(void) -{ - TALLOC_CTX *mem_ctx = talloc_init("update_joblist"); - NTSTATUS status; - struct atsvc_JobEnum r; - struct atsvc_enum_ctr ctr; - int i; - uint32_t resume_handle = 0; - - gtk_list_store_clear(store_jobs); - - ctr.entries_read = 0; - ctr.first_entry = NULL; - r.in.servername = dcerpc_server_name(at_pipe); - r.in.ctr = r.out.ctr = &ctr; - r.in.preferred_max_len = 0xffffffff; - r.in.resume_handle = r.out.resume_handle = &resume_handle; - - status = dcerpc_atsvc_JobEnum(at_pipe, mem_ctx, &r); - if(!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "Error while enumerating first job", status); - return; - } - - for (i = 0; i < r.out.ctr->entries_read; i++) { - GtkTreeIter iter; - gtk_list_store_append(store_jobs, &iter); - gtk_list_store_set (store_jobs, &iter, - 0, r.out.ctr->first_entry[i].flags, - 1, r.out.ctr->first_entry[i].job_id, - 2, r.out.ctr->first_entry[i].days_of_week, /*FIXME: Nicer format */ - 3, r.out.ctr->first_entry[i].job_time, /* FIXME: Nicer format */ - 4, r.out.ctr->first_entry[i].command, - -1); - - } - talloc_free(mem_ctx); -} - -static void on_job_select(GtkTreeSelection *sel, gpointer data) -{ - gtk_widget_set_sensitive(delete, gtk_tree_selection_get_selected(sel, NULL, NULL)); -} - - -static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - at_pipe = gtk_connect_rpc_interface(talloc_autofree_context(), &dcerpc_table_atsvc); - - if (!at_pipe) - return; - - gtk_widget_set_sensitive (new_task, TRUE); - update_joblist(); -} - -static void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - talloc_free(at_pipe); - gtk_main_quit(); -} - -static GtkWidget* create_new_job_dialog (void); - -void on_new_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - GtkWidget *d = create_new_job_dialog(); - gint result = gtk_dialog_run(GTK_DIALOG(d)); - struct atsvc_JobAdd r; - struct atsvc_JobInfo job; - NTSTATUS status; - TALLOC_CTX *mem_ctx; - switch(result) { - case GTK_RESPONSE_OK: - break; - default: - gtk_widget_destroy(d); - return; - } - mem_ctx = talloc_init("add_job"); - - job.job_time = 0; /* FIXME */ - job.days_of_month = 0; /* FIXME */ - job.days_of_week = 0; /* FIXME */ - job.flags = 0; /* FIXME */ - job.command = gtk_entry_get_text(GTK_ENTRY(entry_cmd)); - r.in.servername = dcerpc_server_name(at_pipe); - r.in.job_info = &job; - - status = dcerpc_atsvc_JobAdd(at_pipe, mem_ctx, &r); - if(!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - gtk_show_ntstatus(mainwin, "Error while adding job", status); - return; - } - - talloc_free(mem_ctx); - gtk_widget_destroy(d); - - d = gtk_message_dialog_new (GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Job Id: %d", *r.out.job_id); - gtk_dialog_run(GTK_DIALOG(d)); - gtk_widget_destroy(d); - update_joblist(); -} - - -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); - GtkTreeIter iter; - gint id; - - if (gtk_tree_selection_get_selected (sel, &model, &iter)) - { - struct atsvc_JobDel r; - TALLOC_CTX *mem_ctx; - NTSTATUS status; - gtk_tree_model_get (model, &iter, 1, &id, -1); - - r.in.servername = dcerpc_server_name(at_pipe); - r.in.min_job_id = r.in.max_job_id = id; - - mem_ctx = talloc_init("del_job"); - status = dcerpc_atsvc_JobDel(at_pipe, mem_ctx, &r); - talloc_free(mem_ctx); - if(!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "Error deleting job", status); - return; - } - - update_joblist(); - } -} - - -static void on_about_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gwcrontab")); - gtk_dialog_run(aboutwin); - gtk_widget_destroy(GTK_WIDGET(aboutwin)); -} - -static GtkWidget* create_mainwindow (void) -{ - GtkWidget *mainwindow; - GtkWidget *vbox; - GtkWidget *menubar; - GtkWidget *menuitem4; - GtkWidget *menuitem4_menu; - GtkWidget *mnu_connect; - GtkWidget *separatormenuitem1; - GtkWidget *quit; - GtkWidget *task; - GtkWidget *task_menu; - GtkCellRenderer *renderer; - GtkTreeViewColumn *curcol; - GtkWidget *menuitem7; - GtkWidget *menuitem7_menu; - GtkWidget *about; - GtkWidget *scrolledwindow; - GtkWidget *statusbar; - GtkAccelGroup *accel_group; - - accel_group = gtk_accel_group_new (); - - mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (mainwindow), 642, 562); - gtk_window_set_title (GTK_WINDOW (mainwindow), "Task Scheduler"); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (mainwindow), vbox); - - menubar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); - - menuitem4 = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem4); - - menuitem4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); - - mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect"); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), mnu_connect); - g_signal_connect ((gpointer) mnu_connect, "activate", - G_CALLBACK (on_connect_activate), NULL); - - separatormenuitem1 = gtk_separator_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit); - - task = gtk_menu_item_new_with_mnemonic ("_Task"); - gtk_container_add (GTK_CONTAINER (menubar), task); - - task_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (task), task_menu); - - 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); - gtk_container_add (GTK_CONTAINER (task_menu), delete); - - menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem7); - - menuitem7_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu); - - about = gtk_menu_item_new_with_mnemonic ("_About"); - gtk_container_add (GTK_CONTAINER (menuitem7_menu), about); - - scrolledwindow = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0); - - tasks = gtk_tree_view_new (); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Status"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "ID"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Day"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Time"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 3); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Command Line"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 4); - - store_jobs = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); - gtk_tree_view_set_model(GTK_TREE_VIEW(tasks), GTK_TREE_MODEL(store_jobs)); - g_object_unref(store_jobs); - - gtk_container_add (GTK_CONTAINER (scrolledwindow), tasks); - - g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(tasks)) , "changed", G_CALLBACK (on_job_select), NULL); - - statusbar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); - - - g_signal_connect ((gpointer) quit, "activate", - G_CALLBACK (on_quit_activate), NULL); - 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); - g_signal_connect ((gpointer) about, "activate", - G_CALLBACK (on_about_activate), NULL); - - gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group); - - return mainwindow; -} - -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) -{ - gtk_widget_set_sensitive(entry_repeat_monthly, gtk_toggle_button_get_active(togglebutton)); -} - - -static GtkWidget *create_new_job_dialog (void) -{ - GtkWidget *new_job_dialog; - GtkWidget *dialog_vbox1; - GtkWidget *frame1; - GtkWidget *table1; - GtkWidget *label4; - GtkWidget *cal_day; - GtkWidget *label3; - GtkWidget *entry_time; - GtkWidget *chk_weekly; - GtkWidget *chk_monthly; - GtkWidget *label1; - GtkWidget *frame2; - GtkWidget *hbox1; - GtkWidget *label5; - GtkWidget *label2; - GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; - GtkWidget *okbutton1; - - new_job_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (new_job_dialog), "New job"); - - dialog_vbox1 = GTK_DIALOG (new_job_dialog)->vbox; - - frame1 = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame1, TRUE, TRUE, 0); - - table1 = gtk_table_new (4, 2, FALSE); - gtk_container_add (GTK_CONTAINER (frame1), table1); - - label4 = gtk_label_new ("Time:"); - gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5); - - cal_day = gtk_calendar_new (); - gtk_table_attach (GTK_TABLE (table1), cal_day, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - gtk_calendar_set_display_options (GTK_CALENDAR (cal_day), - GTK_CALENDAR_SHOW_HEADING - | GTK_CALENDAR_SHOW_DAY_NAMES); - - label3 = gtk_label_new ("Date"); - gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5); - - entry_time = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_time, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_weekly = gtk_check_button_new_with_mnemonic ("Repeat weekly"); - gtk_table_attach (GTK_TABLE (table1), chk_weekly, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_repeat_weekly = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_repeat_weekly, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_monthly = gtk_check_button_new_with_mnemonic ("Repeat monthly"); - gtk_table_attach (GTK_TABLE (table1), chk_monthly, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_repeat_monthly = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_repeat_monthly, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label1 = gtk_label_new ("Moment"); - gtk_frame_set_label_widget (GTK_FRAME (frame1), label1); - - frame2 = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame2, TRUE, TRUE, 0); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame2), hbox1); - - label5 = gtk_label_new ("Command to execute"); - gtk_box_pack_start (GTK_BOX (hbox1), label5, TRUE, TRUE, 0); - - entry_cmd = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox1), entry_cmd, TRUE, TRUE, 0); - - label2 = gtk_label_new ("Command"); - gtk_frame_set_label_widget (GTK_FRAME (frame2), label2); - - dialog_action_area1 = GTK_DIALOG (new_job_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (new_job_dialog), cancelbutton1, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (new_job_dialog), okbutton1, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) chk_weekly, "toggled", - G_CALLBACK (on_chk_weekly_toggled), - NULL); - g_signal_connect ((gpointer) chk_monthly, "toggled", - G_CALLBACK (on_chk_monthly_toggled), - NULL); - - return new_job_dialog; -} - - -int main(int argc, char **argv) -{ - lp_load(); - setup_logging(argv[0], DEBUG_STDERR); - - dcerpc_init(); - - gtk_init(&argc, &argv); - mainwin = create_mainwindow(); - gtk_widget_show_all(mainwin); - - return gtk_event_loop(); -} diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c deleted file mode 100644 index 214ab04935..0000000000 --- a/source4/gtk/tools/gwsam.c +++ /dev/null @@ -1,443 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ SAM frontend - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_samr_c.h" -#include "gtk/common/select.h" -#include "gtk/common/gtk-smb.h" -#include "auth/credentials/credentials.h" - -struct policy_handle sam_handle; -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) -{ - if(!sam_pipe) return; - //FIXME -} - -static void update_userlist(void) -{ - NTSTATUS status; - struct samr_EnumDomainUsers r; - uint32_t resume_handle=0; - int i; - TALLOC_CTX *mem_ctx; - - 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)100; - r.out.resume_handle = &resume_handle; - - status = dcerpc_samr_EnumDomainUsers(sam_pipe, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "While enumerating domain users", status); - talloc_free(mem_ctx); - return; - } - - if (!r.out.sam || r.out.sam->count == 0) { - talloc_free(mem_ctx); - return; - } - - for (i=0;i<r.out.sam->count;i++) { - 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)) { - // ret = False; - // } - } - talloc_free(mem_ctx); -} - -static void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - /* FIXME */ -} - -static void on_select_domain_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkSelectDomainDialog *d; - gint result; - d = GTK_SELECT_DOMAIN_DIALOG(gtk_select_domain_dialog_new(sam_pipe)); - result = gtk_dialog_run(GTK_DIALOG(d)); - switch(result) { - case GTK_RESPONSE_OK: - break; - default: - gtk_widget_destroy(GTK_WIDGET(d)); - return; - } - domain_handle = gtk_select_domain_dialog_get_handle(d); - - update_userlist(); - update_grouplist(); - - gtk_widget_destroy(GTK_WIDGET(d)); -} - -static void connect_sam(void) -{ - struct samr_Connect r; - TALLOC_CTX *mem_ctx; - NTSTATUS status; - - mem_ctx = talloc_init("gwsam_connect"); - - sam_pipe = gtk_connect_rpc_interface(talloc_autofree_context(), &dcerpc_table_samr); - - if (!sam_pipe) - return; - - r.in.system_name = 0; - r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r.out.connect_handle = &sam_handle; - - status = dcerpc_samr_Connect(sam_pipe, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - gtk_show_ntstatus(mainwin, "While running connect on SAMR", status); - sam_pipe = NULL; - talloc_free(mem_ctx); - return; - } - - gtk_widget_set_sensitive (seldomain, TRUE); - gtk_widget_set_sensitive (mnu_disconnect, TRUE); - - 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); -} - -static void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data) -{ - talloc_free(sam_pipe); - - gtk_main_quit(); -} - -static void on_account_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - //FIXME -} - - -static void on_user_rights_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - //FIXME -} - - -static void on_audit_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - //FIXME -} - - -static void on_trust_relations_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - //FIXME -} - - -static void on_refresh_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - update_userlist(); - update_grouplist(); -} - - -static void on_about_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gwsam")); - gtk_dialog_run(aboutwin); - gtk_widget_destroy(GTK_WIDGET(aboutwin)); -} - -static GtkWidget* create_mainwindow (void) -{ - GtkWidget *vbox1; - GtkWidget *mnu_connect; - GtkWidget *menubar; - GtkWidget *menuitem1; - GtkWidget *menuitem1_menu; - GtkWidget *new1; - GtkWidget *separatormenuitem1; - GtkWidget *quit; - GtkCellRenderer *renderer; - GtkTreeViewColumn *curcol; - GtkWidget *policies; - GtkWidget *policies_menu; - GtkWidget *account; - GtkWidget *user_rights; - GtkWidget *audit; - GtkWidget *separator1; - GtkWidget *trust_relations; - GtkWidget *menuitem3; - GtkWidget *menuitem3_menu; - GtkWidget *refresh; - GtkWidget *menuitem4; - GtkWidget *menuitem4_menu; - GtkWidget *about; - GtkWidget *vpaned; - GtkWidget *scrolledwindow1; - GtkWidget *user_list; - GtkWidget *scrolledwindow2; - GtkWidget *group_list; - GtkWidget *statusbar; - GtkAccelGroup *accel_group; - - accel_group = gtk_accel_group_new (); - - mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (mainwin), 642, 562); - gtk_window_set_title (GTK_WINDOW (mainwin), "User Manager"); - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (mainwin), vbox1); - - menubar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (vbox1), menubar, FALSE, FALSE, 0); - - menuitem1 = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem1); - - menuitem1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu); - - mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect"); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), mnu_connect); - - mnu_disconnect = gtk_menu_item_new_with_mnemonic ("_Disconnect"); - gtk_widget_set_sensitive (mnu_disconnect, FALSE); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), mnu_disconnect); - - seldomain = gtk_menu_item_new_with_mnemonic("_Select Domain"); - gtk_widget_set_sensitive (seldomain, FALSE); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), seldomain); - - separatormenuitem1 = gtk_separator_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit); - - menuitem1 = gtk_menu_item_new_with_mnemonic ("_User"); - 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_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); - - policies_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (policies), policies_menu); - - account = gtk_menu_item_new_with_mnemonic ("_Account..."); - gtk_container_add (GTK_CONTAINER (policies_menu), account); - - user_rights = gtk_menu_item_new_with_mnemonic ("_User Rights..."); - gtk_container_add (GTK_CONTAINER (policies_menu), user_rights); - - audit = gtk_menu_item_new_with_mnemonic ("A_udit..."); - gtk_container_add (GTK_CONTAINER (policies_menu), audit); - - separator1 = gtk_separator_menu_item_new (); - gtk_container_add (GTK_CONTAINER (policies_menu), separator1); - gtk_widget_set_sensitive (separator1, FALSE); - - trust_relations = gtk_menu_item_new_with_mnemonic ("_Trust relations"); - gtk_container_add (GTK_CONTAINER (policies_menu), trust_relations); - - menuitem3 = gtk_menu_item_new_with_mnemonic ("_View"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem3); - - menuitem3_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menuitem3_menu); - - refresh = gtk_image_menu_item_new_from_stock ("gtk-refresh", accel_group); - gtk_container_add (GTK_CONTAINER (menuitem3_menu), refresh); - gtk_widget_set_sensitive (refresh, FALSE); - - menuitem4 = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem4); - - menuitem4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); - - about = gtk_menu_item_new_with_mnemonic ("_About"); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), about); - - vpaned = gtk_vpaned_new (); - gtk_box_pack_start (GTK_BOX (vbox1), vpaned, TRUE, TRUE, 0); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_paned_pack1 (GTK_PANED (vpaned), scrolledwindow1, FALSE, TRUE); - - 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); - - g_signal_connect ((gpointer) new1, "activate", - G_CALLBACK (on_new1_activate), - NULL); - g_signal_connect ((gpointer) seldomain, "activate", - G_CALLBACK (on_select_domain_activate), - NULL); - g_signal_connect ((gpointer) mnu_connect, "activate", - G_CALLBACK (on_connect_activate), - NULL); - g_signal_connect ((gpointer) mnu_disconnect, "activate", - G_CALLBACK (on_disconnect_activate), - NULL); - g_signal_connect ((gpointer) quit, "activate", - G_CALLBACK (on_quit_activate), - NULL); - g_signal_connect ((gpointer) account, "activate", - G_CALLBACK (on_account_activate), - NULL); - g_signal_connect ((gpointer) user_rights, "activate", - G_CALLBACK (on_user_rights_activate), - NULL); - g_signal_connect ((gpointer) audit, "activate", - G_CALLBACK (on_audit_activate), - NULL); - g_signal_connect ((gpointer) trust_relations, "activate", - G_CALLBACK (on_trust_relations_activate), - NULL); - g_signal_connect ((gpointer) refresh, "activate", - G_CALLBACK (on_refresh_activate), - NULL); - g_signal_connect ((gpointer) about, "activate", - G_CALLBACK (on_about_activate), - NULL); - - gtk_window_add_accel_group (GTK_WINDOW (mainwin), accel_group); - - return mainwin; -} - -int main(int argc, char **argv) -{ - lp_load(); - setup_logging(argv[0], DEBUG_STDERR); - - dcerpc_init(); - - gtk_init(&argc, &argv); - mainwin = create_mainwindow(); - gtk_widget_show_all(mainwin); - - return gtk_event_loop(); -} diff --git a/source4/gtk/tools/gwsam_user.c b/source4/gtk/tools/gwsam_user.c deleted file mode 100644 index 81580f8b19..0000000000 --- a/source4/gtk/tools/gwsam_user.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ SAM frontend - - Copyright (C) Jelmer Vernooij 2004 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "gtk/common/gtk-smb.h" - -GtkWidget* create_user_edit_dialog (void) -{ - GtkWidget *user_edit_dialog; - GtkWidget *dialog_vbox1; - GtkWidget *notebook; - GtkWidget *table1; - GtkWidget *label4; - GtkWidget *label5; - GtkWidget *label6; - GtkWidget *label7; - int i; - GtkWidget *label8; - GtkWidget *chk_mustchange; - GtkWidget *entry_fullname; - GtkWidget *entry_description; - GtkWidget *lbl_username; - GtkWidget *entry_password; - GtkWidget *entry_confirm_password; - GtkWidget *chk_cannotchange; - GtkWidget *chk_cannotexpire; - GtkWidget *chk_disabled; - GtkWidget *chk_lockedout; - GtkWidget *label1; - GtkWidget *hbox1; - GtkWidget *scrolledwindow3; - GtkWidget *treeview3; - GtkWidget *vbox2; - GtkWidget *btn_groupadd; - GtkWidget *btn_groupdel; - GtkWidget *scrolledwindow4; - GtkWidget *treeview4; - GtkWidget *label2; - GtkWidget *vbox3; - GtkWidget *frame1; - GtkWidget *table2; - GtkWidget *label12; - GtkWidget *label13; - GtkWidget *entry_profilepath; - GtkWidget *entry_scriptname; - GtkWidget *label10; - GtkWidget *frame2; - GtkWidget *table3; - GtkWidget *label14; - GtkWidget *entry_homedir; - GtkWidget *chk_mapdrive; - GtkWidget *combo_homedrive; - GtkWidget *label11; - GtkWidget *label3; - GtkWidget *dialog_action_area1; - GtkWidget *cancelbutton1; - GtkWidget *applybutton1; - GtkWidget *okbutton1; - - user_edit_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (user_edit_dialog), "Edit User"); - - dialog_vbox1 = GTK_DIALOG (user_edit_dialog)->vbox; - - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX (dialog_vbox1), notebook, TRUE, TRUE, 0); - - table1 = gtk_table_new (10, 2, FALSE); - gtk_container_add (GTK_CONTAINER (notebook), table1); - - label4 = gtk_label_new ("Username"); - gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5); - - label5 = gtk_label_new ("Full name"); - gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5); - - label6 = gtk_label_new ("Description"); - gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5); - - label7 = gtk_label_new ("Password"); - gtk_table_attach (GTK_TABLE (table1), label7, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label7), 0, 0.5); - - label8 = gtk_label_new ("Confirm password"); - gtk_table_attach (GTK_TABLE (table1), label8, 0, 1, 4, 5, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5); - - chk_mustchange = gtk_check_button_new_with_mnemonic ("_User Must Change Password at Next Logon"); - gtk_table_attach (GTK_TABLE (table1), chk_mustchange, 1, 2, 5, 6, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_fullname = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_fullname, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_description = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_description, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - lbl_username = gtk_label_new (""); - gtk_table_attach (GTK_TABLE (table1), lbl_username, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (lbl_username), 0, 0.5); - - entry_password = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_password, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_confirm_password = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table1), entry_confirm_password, 1, 2, 4, 5, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_cannotchange = gtk_check_button_new_with_mnemonic ("User Cannot Change Password"); - gtk_table_attach (GTK_TABLE (table1), chk_cannotchange, 1, 2, 6, 7, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_cannotexpire = gtk_check_button_new_with_mnemonic ("Password Never Expires"); - gtk_table_attach (GTK_TABLE (table1), chk_cannotexpire, 1, 2, 7, 8, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_disabled = gtk_check_button_new_with_mnemonic ("Account Disabled"); - gtk_table_attach (GTK_TABLE (table1), chk_disabled, 1, 2, 8, 9, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_lockedout = gtk_check_button_new_with_mnemonic ("Account Locked Out"); - gtk_table_attach (GTK_TABLE (table1), chk_lockedout, 1, 2, 9, 10, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label1 = gtk_label_new ("Main"); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0), label1); - - hbox1 = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (notebook), hbox1); - - scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow3, TRUE, TRUE, 0); - - treeview3 = gtk_tree_view_new (); - gtk_container_add (GTK_CONTAINER (scrolledwindow3), treeview3); - - vbox2 = gtk_vbox_new (TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox1), vbox2, TRUE, TRUE, 0); - - btn_groupadd = gtk_button_new_from_stock ("gtk-add"); - gtk_box_pack_start (GTK_BOX (vbox2), btn_groupadd, FALSE, FALSE, 0); - - btn_groupdel = gtk_button_new_from_stock ("gtk-remove"); - gtk_box_pack_start (GTK_BOX (vbox2), btn_groupdel, FALSE, FALSE, 0); - - scrolledwindow4 = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (hbox1), scrolledwindow4, TRUE, TRUE, 0); - - treeview4 = gtk_tree_view_new (); - gtk_container_add (GTK_CONTAINER (scrolledwindow4), treeview4); - - label2 = gtk_label_new ("Groups"); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 1), label2); - - vbox3 = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (notebook), vbox3); - - frame1 = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox3), frame1, TRUE, TRUE, 0); - - table2 = gtk_table_new (2, 2, FALSE); - gtk_container_add (GTK_CONTAINER (frame1), table2); - - label12 = gtk_label_new ("User Profile Path:"); - gtk_table_attach (GTK_TABLE (table2), label12, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label12), 0, 0.5); - - label13 = gtk_label_new ("Logon Script Name:"); - gtk_table_attach (GTK_TABLE (table2), label13, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label13), 0, 0.5); - - entry_profilepath = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table2), entry_profilepath, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - entry_scriptname = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table2), entry_scriptname, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label10 = gtk_label_new ("User Profiles"); - gtk_frame_set_label_widget (GTK_FRAME (frame1), label10); - - frame2 = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox3), frame2, TRUE, TRUE, 0); - - table3 = gtk_table_new (2, 2, FALSE); - gtk_container_add (GTK_CONTAINER (frame2), table3); - - label14 = gtk_label_new ("Path"); - gtk_table_attach (GTK_TABLE (table3), label14, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label14), 0, 0.5); - - entry_homedir = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table3), entry_homedir, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - chk_mapdrive = gtk_check_button_new_with_mnemonic ("Map homedir to drive"); - gtk_table_attach (GTK_TABLE (table3), chk_mapdrive, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - combo_homedrive = gtk_combo_box_new(); - gtk_table_attach (GTK_TABLE (table3), combo_homedrive, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - for(i = 'C'; i <= 'Z'; i++) - { - char drive[3]; - snprintf(drive, 3, "%c:", i); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_homedrive), drive); - } - - label11 = gtk_label_new ("Home Directory"); - gtk_frame_set_label_widget (GTK_FRAME (frame2), label11); - - label3 = gtk_label_new ("Profile"); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 2), label3); - - dialog_action_area1 = GTK_DIALOG (user_edit_dialog)->action_area; - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); - - cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_dialog_add_action_widget (GTK_DIALOG (user_edit_dialog), cancelbutton1, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); - - applybutton1 = gtk_button_new_from_stock ("gtk-apply"); - gtk_dialog_add_action_widget (GTK_DIALOG (user_edit_dialog), applybutton1, GTK_RESPONSE_APPLY); - GTK_WIDGET_SET_FLAGS (applybutton1, GTK_CAN_DEFAULT); - - okbutton1 = gtk_button_new_from_stock ("gtk-ok"); - gtk_dialog_add_action_widget (GTK_DIALOG (user_edit_dialog), okbutton1, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); - - gtk_widget_show_all(dialog_vbox1); - - return user_edit_dialog; -} diff --git a/source4/gtk/tools/gwsvcctl.c b/source4/gtk/tools/gwsvcctl.c deleted file mode 100644 index 4fb1980f6f..0000000000 --- a/source4/gtk/tools/gwsvcctl.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - Unix SMB/CIFS implementation. - GTK+ Windows services management - - Copyright (C) Jelmer Vernooij 2006 - - 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 - the Free Software Foundation; either version 2 of the License, or - (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 - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/ndr_svcctl_c.h" -#include "gtk/common/gtk-smb.h" -#include "auth/credentials/credentials.h" -#include "gtk/common/select.h" - -static struct dcerpc_pipe *svcctl_pipe = NULL; -static GtkWidget *mainwin; -static GtkListStore *store_services; -static GtkWidget *services; -static GtkWidget *new_service, *delete_service, *edit_service, *start_service, *stop_service; - -static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - TALLOC_CTX *mem_ctx = talloc_init("gwsvcctl_connect"); - - svcctl_pipe = gtk_connect_rpc_interface(mem_ctx, &dcerpc_table_svcctl); - if (svcctl_pipe == NULL) - return; - - gtk_widget_set_sensitive (new_service, TRUE); - - /* FIXME: Fetch list of services and display */ -} - -static void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - talloc_free(svcctl_pipe); - gtk_main_quit(); -} - -static void on_about_activate(GtkMenuItem *menuitem, gpointer user_data) -{ - GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gwcrontab")); - gtk_dialog_run(aboutwin); - gtk_widget_destroy(GTK_WIDGET(aboutwin)); -} - -static GtkWidget* create_mainwindow (void) -{ - GtkWidget *mainwindow; - GtkWidget *vbox; - GtkWidget *menubar; - GtkWidget *menuitem4; - GtkWidget *menuitem4_menu; - GtkWidget *mnu_connect; - GtkWidget *separatormenuitem1; - GtkWidget *quit; - GtkWidget *service; - GtkWidget *service_menu; - GtkCellRenderer *renderer; - GtkTreeViewColumn *curcol; - GtkWidget *menuitem7; - GtkWidget *menuitem7_menu; - GtkWidget *about; - GtkWidget *scrolledwindow; - GtkWidget *statusbar; - GtkAccelGroup *accel_group; - - accel_group = gtk_accel_group_new (); - - mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (mainwindow), 642, 562); - gtk_window_set_title (GTK_WINDOW (mainwindow), "Service Management"); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (mainwindow), vbox); - - menubar = gtk_menu_bar_new (); - gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); - - menuitem4 = gtk_menu_item_new_with_mnemonic ("_File"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem4); - - menuitem4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); - - mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect"); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), mnu_connect); - g_signal_connect ((gpointer) mnu_connect, "activate", - G_CALLBACK (on_connect_activate), NULL); - - separatormenuitem1 = gtk_separator_menu_item_new (); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1); - gtk_widget_set_sensitive (separatormenuitem1, FALSE); - - quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit); - - service = gtk_menu_item_new_with_mnemonic ("_Service"); - gtk_container_add (GTK_CONTAINER (menubar), service); - - service_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (service), service_menu); - - new_service = gtk_menu_item_new_with_mnemonic ("_New"); - gtk_container_add (GTK_CONTAINER (service_menu), new_service); - gtk_widget_set_sensitive (new_service, FALSE); - - start_service = gtk_menu_item_new_with_mnemonic ("_Start"); - gtk_container_add (GTK_CONTAINER (service_menu), start_service); - gtk_widget_set_sensitive (start_service, FALSE); - - stop_service = gtk_menu_item_new_with_mnemonic ("St_op"); - gtk_container_add (GTK_CONTAINER (service_menu), stop_service); - gtk_widget_set_sensitive (stop_service, FALSE); - - edit_service = gtk_menu_item_new_with_mnemonic ("_Edit"); - gtk_container_add (GTK_CONTAINER (service_menu), edit_service); - gtk_widget_set_sensitive (edit_service, FALSE); - - delete_service = gtk_menu_item_new_with_mnemonic ("_Delete"); - gtk_widget_set_sensitive(delete_service, FALSE); - gtk_container_add (GTK_CONTAINER (service_menu), delete_service); - - menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help"); - gtk_container_add (GTK_CONTAINER (menubar), menuitem7); - - menuitem7_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu); - - about = gtk_menu_item_new_with_mnemonic ("_About"); - gtk_container_add (GTK_CONTAINER (menuitem7_menu), about); - - scrolledwindow = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0); - - services = gtk_tree_view_new (); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Status"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "ID"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Day"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Time"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 3); - - curcol = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title(curcol, "Command Line"); - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(curcol, renderer, True); - gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol); - gtk_tree_view_column_add_attribute(curcol, renderer, "text", 4); - - store_services = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); - gtk_tree_view_set_model(GTK_TREE_VIEW(services), GTK_TREE_MODEL(store_services)); - g_object_unref(store_services); - - gtk_container_add (GTK_CONTAINER (scrolledwindow), services); - - statusbar = gtk_statusbar_new (); - gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); - - g_signal_connect ((gpointer) quit, "activate", - G_CALLBACK (on_quit_activate), NULL); - g_signal_connect ((gpointer) about, "activate", - G_CALLBACK (on_about_activate), NULL); - - gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group); - - return mainwindow; -} - -int main(int argc, char **argv) -{ - lp_load(); - setup_logging(argv[0], DEBUG_STDERR); - - dcerpc_init(); - - gtk_init(&argc, &argv); - mainwin = create_mainwindow(); - gtk_widget_show_all(mainwin); - - return gtk_event_loop(); -} |