r21296: remove the session specific encryption from the attributes
[Samba/ekacnet.git] / source4 / gtk / tools / gwsvcctl.c
blob4fb1980f6f746374abcf1f066280d2a893a0dbfa
1 /*
2 Unix SMB/CIFS implementation.
3 GTK+ Windows services management
5 Copyright (C) Jelmer Vernooij 2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_svcctl_c.h"
24 #include "gtk/common/gtk-smb.h"
25 #include "auth/credentials/credentials.h"
26 #include "gtk/common/select.h"
28 static struct dcerpc_pipe *svcctl_pipe = NULL;
29 static GtkWidget *mainwin;
30 static GtkListStore *store_services;
31 static GtkWidget *services;
32 static GtkWidget *new_service, *delete_service, *edit_service, *start_service, *stop_service;
34 static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data)
36 TALLOC_CTX *mem_ctx = talloc_init("gwsvcctl_connect");
38 svcctl_pipe = gtk_connect_rpc_interface(mem_ctx, &dcerpc_table_svcctl);
39 if (svcctl_pipe == NULL)
40 return;
42 gtk_widget_set_sensitive (new_service, TRUE);
44 /* FIXME: Fetch list of services and display */
47 static void on_quit_activate(GtkMenuItem *menuitem, gpointer user_data)
49 talloc_free(svcctl_pipe);
50 gtk_main_quit();
53 static void on_about_activate(GtkMenuItem *menuitem, gpointer user_data)
55 GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog("gwcrontab"));
56 gtk_dialog_run(aboutwin);
57 gtk_widget_destroy(GTK_WIDGET(aboutwin));
60 static GtkWidget* create_mainwindow (void)
62 GtkWidget *mainwindow;
63 GtkWidget *vbox;
64 GtkWidget *menubar;
65 GtkWidget *menuitem4;
66 GtkWidget *menuitem4_menu;
67 GtkWidget *mnu_connect;
68 GtkWidget *separatormenuitem1;
69 GtkWidget *quit;
70 GtkWidget *service;
71 GtkWidget *service_menu;
72 GtkCellRenderer *renderer;
73 GtkTreeViewColumn *curcol;
74 GtkWidget *menuitem7;
75 GtkWidget *menuitem7_menu;
76 GtkWidget *about;
77 GtkWidget *scrolledwindow;
78 GtkWidget *statusbar;
79 GtkAccelGroup *accel_group;
81 accel_group = gtk_accel_group_new ();
83 mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
84 gtk_window_set_default_size (GTK_WINDOW (mainwindow), 642, 562);
85 gtk_window_set_title (GTK_WINDOW (mainwindow), "Service Management");
87 vbox = gtk_vbox_new (FALSE, 0);
88 gtk_container_add (GTK_CONTAINER (mainwindow), vbox);
90 menubar = gtk_menu_bar_new ();
91 gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
93 menuitem4 = gtk_menu_item_new_with_mnemonic ("_File");
94 gtk_container_add (GTK_CONTAINER (menubar), menuitem4);
96 menuitem4_menu = gtk_menu_new ();
97 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);
99 mnu_connect = gtk_menu_item_new_with_mnemonic ("_Connect");
100 gtk_container_add (GTK_CONTAINER (menuitem4_menu), mnu_connect);
101 g_signal_connect ((gpointer) mnu_connect, "activate",
102 G_CALLBACK (on_connect_activate), NULL);
104 separatormenuitem1 = gtk_separator_menu_item_new ();
105 gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1);
106 gtk_widget_set_sensitive (separatormenuitem1, FALSE);
108 quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
109 gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit);
111 service = gtk_menu_item_new_with_mnemonic ("_Service");
112 gtk_container_add (GTK_CONTAINER (menubar), service);
114 service_menu = gtk_menu_new ();
115 gtk_menu_item_set_submenu (GTK_MENU_ITEM (service), service_menu);
117 new_service = gtk_menu_item_new_with_mnemonic ("_New");
118 gtk_container_add (GTK_CONTAINER (service_menu), new_service);
119 gtk_widget_set_sensitive (new_service, FALSE);
121 start_service = gtk_menu_item_new_with_mnemonic ("_Start");
122 gtk_container_add (GTK_CONTAINER (service_menu), start_service);
123 gtk_widget_set_sensitive (start_service, FALSE);
125 stop_service = gtk_menu_item_new_with_mnemonic ("St_op");
126 gtk_container_add (GTK_CONTAINER (service_menu), stop_service);
127 gtk_widget_set_sensitive (stop_service, FALSE);
129 edit_service = gtk_menu_item_new_with_mnemonic ("_Edit");
130 gtk_container_add (GTK_CONTAINER (service_menu), edit_service);
131 gtk_widget_set_sensitive (edit_service, FALSE);
133 delete_service = gtk_menu_item_new_with_mnemonic ("_Delete");
134 gtk_widget_set_sensitive(delete_service, FALSE);
135 gtk_container_add (GTK_CONTAINER (service_menu), delete_service);
137 menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help");
138 gtk_container_add (GTK_CONTAINER (menubar), menuitem7);
140 menuitem7_menu = gtk_menu_new ();
141 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu);
143 about = gtk_menu_item_new_with_mnemonic ("_About");
144 gtk_container_add (GTK_CONTAINER (menuitem7_menu), about);
146 scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
147 gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
149 services = gtk_tree_view_new ();
151 curcol = gtk_tree_view_column_new ();
152 gtk_tree_view_column_set_title(curcol, "Status");
153 renderer = gtk_cell_renderer_text_new();
154 gtk_tree_view_column_pack_start(curcol, renderer, True);
155 gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
156 gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0);
158 curcol = gtk_tree_view_column_new ();
159 gtk_tree_view_column_set_title(curcol, "ID");
160 renderer = gtk_cell_renderer_text_new();
161 gtk_tree_view_column_pack_start(curcol, renderer, True);
162 gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
163 gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
165 curcol = gtk_tree_view_column_new ();
166 gtk_tree_view_column_set_title(curcol, "Day");
167 renderer = gtk_cell_renderer_text_new();
168 gtk_tree_view_column_pack_start(curcol, renderer, True);
169 gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
170 gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2);
172 curcol = gtk_tree_view_column_new ();
173 gtk_tree_view_column_set_title(curcol, "Time");
174 renderer = gtk_cell_renderer_text_new();
175 gtk_tree_view_column_pack_start(curcol, renderer, True);
176 gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
177 gtk_tree_view_column_add_attribute(curcol, renderer, "text", 3);
179 curcol = gtk_tree_view_column_new ();
180 gtk_tree_view_column_set_title(curcol, "Command Line");
181 renderer = gtk_cell_renderer_text_new();
182 gtk_tree_view_column_pack_start(curcol, renderer, True);
183 gtk_tree_view_append_column(GTK_TREE_VIEW(services), curcol);
184 gtk_tree_view_column_add_attribute(curcol, renderer, "text", 4);
186 store_services = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
187 gtk_tree_view_set_model(GTK_TREE_VIEW(services), GTK_TREE_MODEL(store_services));
188 g_object_unref(store_services);
190 gtk_container_add (GTK_CONTAINER (scrolledwindow), services);
192 statusbar = gtk_statusbar_new ();
193 gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
195 g_signal_connect ((gpointer) quit, "activate",
196 G_CALLBACK (on_quit_activate), NULL);
197 g_signal_connect ((gpointer) about, "activate",
198 G_CALLBACK (on_about_activate), NULL);
200 gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group);
202 return mainwindow;
205 int main(int argc, char **argv)
207 lp_load();
208 setup_logging(argv[0], DEBUG_STDERR);
210 dcerpc_init();
212 gtk_init(&argc, &argv);
213 mainwin = create_mainwindow();
214 gtk_widget_show_all(mainwin);
216 return gtk_event_loop();