From 97416e6b011a3c733d07f83073bf12796c7ecc6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Feb 2007 12:12:12 +0000 Subject: 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) --- source4/gtk/tools/gepdump.c | 443 ------------------ source4/gtk/tools/gregedit.c | 989 ----------------------------------------- source4/gtk/tools/gwcrontab.c | 462 ------------------- source4/gtk/tools/gwsam.c | 443 ------------------ source4/gtk/tools/gwsam_user.c | 291 ------------ source4/gtk/tools/gwsvcctl.c | 217 --------- 6 files changed, 2845 deletions(-) delete mode 100644 source4/gtk/tools/gepdump.c delete mode 100644 source4/gtk/tools/gregedit.c delete mode 100644 source4/gtk/tools/gwcrontab.c delete mode 100644 source4/gtk/tools/gwsam.c delete mode 100644 source4/gtk/tools/gwsam_user.c delete mode 100644 source4/gtk/tools/gwsvcctl.c (limited to 'source4/gtk/tools') 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 ("Search in"); - 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;icount;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(); -} -- cgit