diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-05-03 09:11:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:05:33 -0500 |
commit | 86a2f18b964c358eb8c8d59381be5eb5962f3b4b (patch) | |
tree | f6809775428c2ee956d976d73ec8768025f236f0 /source4/gtk/common | |
parent | 37aa2c5e8ff628d8ad51497a165da8a58cb2d1f5 (diff) | |
download | samba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.tar.gz samba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.tar.bz2 samba-86a2f18b964c358eb8c8d59381be5eb5962f3b4b.zip |
r15408: Fix some small bugs in the GTK+ tools
Add utility function for connection to an interface
(This used to be commit 266f7472209e6ae4f70688cf06b8efa63d036d04)
Diffstat (limited to 'source4/gtk/common')
-rw-r--r-- | source4/gtk/common/gtk-smb.c | 18 | ||||
-rw-r--r-- | source4/gtk/common/gtk-smb.h | 1 | ||||
-rw-r--r-- | source4/gtk/common/select.c | 41 | ||||
-rw-r--r-- | source4/gtk/common/select.h | 6 |
4 files changed, 57 insertions, 9 deletions
diff --git a/source4/gtk/common/gtk-smb.c b/source4/gtk/common/gtk-smb.c index f5830cc8d7..6968ccf106 100644 --- a/source4/gtk/common/gtk-smb.c +++ b/source4/gtk/common/gtk-smb.c @@ -26,6 +26,9 @@ #include "librpc/rpc/dcerpc.h" #include "auth/credentials/credentials.h" +/** + * Dialog error showing a WERROR + */ void gtk_show_werror(GtkWidget *win, const char *message, WERROR err) { GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win), @@ -38,6 +41,9 @@ void gtk_show_werror(GtkWidget *win, const char *message, WERROR err) gtk_widget_destroy (dialog); } +/** + * GTK+ dialog showing a NTSTATUS error + */ void gtk_show_ntstatus(GtkWidget *win, const char *message, NTSTATUS status) { GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win), @@ -50,7 +56,7 @@ void gtk_show_ntstatus(GtkWidget *win, const char *message, NTSTATUS status) gtk_widget_destroy (dialog); } -static void on_browse_activate (GtkButton *button, gpointer user_data) +static void on_browse_activate (GtkButton *button, gpointer user_data) { GtkRpcBindingDialog *rbd = user_data; GtkWidget *shd = gtk_select_host_dialog_new(rbd->sam_pipe); @@ -117,8 +123,6 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip), transport_smb_group); transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip)); - - label1 = gtk_label_new ("Transport"); gtk_frame_set_label_widget (GTK_FRAME (frame_transport), label1); @@ -213,6 +217,12 @@ GType gtk_rpc_binding_dialog_get_type (void) return mytype; } +/** + * Create a new GTK+ dialog asking for binding information for + * DCE/RPC + * + * Optionally gets a sam pipe that will be used to look up users + */ GtkWidget *gtk_rpc_binding_dialog_new (struct dcerpc_pipe *sam_pipe) { GtkRpcBindingDialog *d = GTK_RPC_BINDING_DIALOG ( g_object_new (gtk_rpc_binding_dialog_get_type (), NULL)); @@ -291,7 +301,7 @@ GtkWidget *create_gtk_samba_about_dialog (const char *appname) label3 = gtk_label_new_with_mnemonic ("Part of Samba <http://www.samba.org/>"); gtk_box_pack_start (GTK_BOX (dialog_vbox1), label3, FALSE, FALSE, 0); - label4 = gtk_label_new ("\302\251 1992-2005 The Samba Team"); + label4 = gtk_label_new ("\302\251 1992-2006 The Samba Team"); gtk_box_pack_start (GTK_BOX (dialog_vbox1), label4, FALSE, FALSE, 0); dialog_action_area1 = GTK_DIALOG (samba_about_dialog)->action_area; diff --git a/source4/gtk/common/gtk-smb.h b/source4/gtk/common/gtk-smb.h index 16dbfaf5d6..ae72905272 100644 --- a/source4/gtk/common/gtk-smb.h +++ b/source4/gtk/common/gtk-smb.h @@ -22,7 +22,6 @@ #ifndef __GTK_SMB_H__ #define __GTK_SMB_H__ - #define GTK_DISABLE_DEPRECATED #include <gtk/gtk.h> diff --git a/source4/gtk/common/select.c b/source4/gtk/common/select.c index c3e73b5c13..0547525cf3 100644 --- a/source4/gtk/common/select.c +++ b/source4/gtk/common/select.c @@ -23,6 +23,7 @@ #include "librpc/gen_ndr/ndr_samr_c.h" #include "gtk/common/select.h" #include "gtk/common/gtk-smb.h" +#include "auth/credentials/credentials.h" /* GtkSelectDomainDialog */ @@ -260,3 +261,43 @@ GtkWidget *gtk_select_host_dialog_new (struct dcerpc_pipe *sam_pipe) { return GTK_WIDGET ( g_object_new (gtk_select_host_dialog_get_type (), NULL )); } + +/** + * Connect to a specific interface, but ask the user + * for information not specified + */ +struct dcerpc_pipe *gtk_connect_rpc_interface(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *table) +{ + GtkRpcBindingDialog *d; + NTSTATUS status; + struct dcerpc_pipe *pipe; + struct cli_credentials *cred; + gint result; + + d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(NULL)); + result = gtk_dialog_run(GTK_DIALOG(d)); + + if (result != GTK_RESPONSE_ACCEPT) { + gtk_widget_destroy(GTK_WIDGET(d)); + return NULL; + } + + cred = cli_credentials_init(mem_ctx); + cli_credentials_guess(cred); + cli_credentials_set_gtk_callbacks(cred); + + status = dcerpc_pipe_connect_b(mem_ctx, &pipe, + gtk_rpc_binding_dialog_get_binding(d, mem_ctx), + table, cred, NULL); + + if(!NT_STATUS_IS_OK(status)) { + gtk_show_ntstatus(NULL, "While connecting to interface", status); + gtk_widget_destroy(GTK_WIDGET(d)); + talloc_free(mem_ctx); + return NULL; + } + + gtk_widget_destroy(GTK_WIDGET(d)); + + return pipe; +} diff --git a/source4/gtk/common/select.h b/source4/gtk/common/select.h index 006d228e42..ddf9b1a5a9 100644 --- a/source4/gtk/common/select.h +++ b/source4/gtk/common/select.h @@ -22,8 +22,6 @@ #ifndef __GTK_SELECT_H__ #define __GTK_SELECT_H__ -#ifdef HAVE_GTK - #define GTK_DISABLE_DEPRECATED #include <gtk/gtk.h> @@ -80,7 +78,7 @@ GtkWidget *gtk_select_host_dialog_new (struct dcerpc_pipe *sam_pipe); const char *gtk_select_host_dialog_get_host (GtkSelectHostDialog *d); GType gtk_select_host_dialog_get_type (void); - -#endif +struct dcerpc_interface_table; +struct dcerpc_pipe *gtk_connect_rpc_interface(TALLOC_CTX *mem_ctx, const struct dcerpc_interface_table *table); #endif |