r2920: Support passing a handle to a SAMR pipe to a RPC Binding or Select
authorJelmer Vernooij <jelmer@samba.org>
Mon, 11 Oct 2004 20:06:42 +0000 (20:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:48 +0000 (12:59 -0500)
Host dialog so that one can select a domain from the list of known
domains.

source/gtk/common/gtk-smb.c
source/gtk/common/gtk-smb.h
source/gtk/common/select.c
source/gtk/common/select.h
source/gtk/tools/gregedit.c
source/gtk/tools/gwcrontab.c
source/gtk/tools/gwsam.c

index cb7a80486657aa160061aa735e6a8e2b34145bbd..f14977599689df3e1fbe7eba2ce1b0e897b46ccc 100644 (file)
@@ -47,7 +47,7 @@ void gtk_show_ntstatus(GtkWidget *win, NTSTATUS status)
 static void on_browse_activate  (GtkButton     *button,  gpointer         user_data)
 {
        GtkRpcBindingDialog *rbd = user_data;
-       GtkWidget *shd = gtk_select_host_dialog_new(TRUE);
+       GtkWidget *shd = gtk_select_host_dialog_new(rbd->sam_pipe, TRUE);
        if(gtk_dialog_run(GTK_DIALOG(shd)) == GTK_RESPONSE_ACCEPT) {
                gtk_entry_set_text(GTK_ENTRY(rbd->entry_host), gtk_select_host_dialog_get_host(GTK_SELECT_HOST_DIALOG(shd)));
        }
@@ -138,13 +138,16 @@ static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_di
        gtk_widget_show (gtk_rpc_binding_dialog->entry_host);
        gtk_box_pack_start (GTK_BOX (hbox1), gtk_rpc_binding_dialog->entry_host, TRUE, TRUE, 0);
 
-       btn_browse = gtk_button_new_with_label ("Browse");
-       gtk_widget_show (btn_browse);
-       gtk_box_pack_start (GTK_BOX (hbox1), btn_browse, TRUE, TRUE, 0);
+       if(gtk_rpc_binding_dialog->sam_pipe)
+       {
+               btn_browse = gtk_button_new_with_label ("Browse");
+               gtk_widget_show (btn_browse);
+               gtk_box_pack_start (GTK_BOX (hbox1), btn_browse, TRUE, TRUE, 0);
 
-    g_signal_connect ((gpointer) btn_browse, "pressed",
-               G_CALLBACK (on_browse_activate),
-               gtk_rpc_binding_dialog);
+               g_signal_connect ((gpointer) btn_browse, "pressed",
+                                                 G_CALLBACK (on_browse_activate),
+                                                 gtk_rpc_binding_dialog);
+       }
 
        label2 = gtk_label_new ("Host");
        gtk_widget_show (label2);
@@ -278,9 +281,11 @@ GType gtk_rpc_binding_dialog_get_type (void)
   return mytype;
 }
 
-GtkWidget *gtk_rpc_binding_dialog_new (BOOL nocredentials)
+GtkWidget *gtk_rpc_binding_dialog_new (BOOL nocredentials, struct sam_pipe *sam_pipe)
 {
-       return GTK_WIDGET ( gtk_type_new (gtk_rpc_binding_dialog_get_type ()));
+       GtkRpcBindingDialog *d = GTK_RPC_BINDING_DIALOG ( gtk_type_new (gtk_rpc_binding_dialog_get_type ()));
+       d->sam_pipe = sam_pipe;
+       return GTK_WIDGET(d);
 }
 
 const char *gtk_rpc_binding_dialog_get_username(GtkRpcBindingDialog *d)
index 0f34bb3249426b76dc8a5626e2bc570809deb430..09e5d0aa8d6f5fc6beaa411fcb93fe3aad077916 100644 (file)
@@ -40,6 +40,7 @@ struct _GtkRpcBindingDialog
        GtkWidget *entry_password;
        GtkWidget *krb5_chk_button;
        TALLOC_CTX *mem_ctx;
+       struct sam_pipe *sam_pipe;
 };
 
 typedef struct _GtkRpcBindingDialogClass GtkRpcBindingDialogClass;
index 653256c37eab4feb84b571ba69fd757a5f6f8fd3..3b29d0ed312cbda5548735664efd75d04fa37729 100644 (file)
@@ -163,7 +163,6 @@ GtkWidget *gtk_select_domain_dialog_new (struct dcerpc_pipe *sam_pipe)
        } else if (r.out.sam) {
                for (i=0;i<r.out.sam->count;i++) {
                        GtkTreeIter iter;
-                       printf("- %s\n", r.out.sam->entries[i].name.name);
                        gtk_list_store_append(d->store_domains, &iter);
                        gtk_list_store_set (d->store_domains, &iter, 0, r.out.sam->entries[i].name.name, -1);
                }
@@ -271,7 +270,7 @@ GType gtk_select_host_dialog_get_type (void)
        return mytype;
 }
                                                                                                                              
-GtkWidget *gtk_select_host_dialog_new (BOOL nocredentials)
+GtkWidget *gtk_select_host_dialog_new (struct sam_pipe *sam_pipe, BOOL nocredentials)
 {
         return GTK_WIDGET ( gtk_type_new (gtk_select_host_dialog_get_type ()));
 }
index b89712ffe06b14e8dafa3c28d70ff0d088d0ad45..3b3d09a99bdf4ad625c02154069fe45c1c2666e0 100644 (file)
@@ -45,9 +45,9 @@ struct _GtkSelectDomainDialogClass
        GtkDialogClass parent_class;
 };
 
-#define GTK_SELECT_DOMAIN_DIALOG(obj)          GTK_CHECK_CAST (obj, gtk_rpc_binding_dialog_get_type (), GtkSelectDomainDialog)
-#define GTK_SELECT_DOMAIN_DIALOG_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gtk_rpc_binding_dialog_class_get_type (), GtkSelectDomainDialogClass)
-#define IS_GTK_SELECT_DOMAIN_DIALOG(obj)       GTK_CHECK_TYPE (obj, gtk_rpc_binding_dialog_get_type ())
+#define GTK_SELECT_DOMAIN_DIALOG(obj)          GTK_CHECK_CAST (obj, gtk_select_domain_dialog_get_type (), GtkSelectDomainDialog)
+#define GTK_SELECT_DOMAIN_DIALOG_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gtk_select_domain_dialog_class_get_type (), GtkSelectDomainDialogClass)
+#define IS_GTK_SELECT_DOMAIN_DIALOG(obj)       GTK_CHECK_TYPE (obj, gtk_select_domain_dialog_get_type ())
 
 typedef struct _GtkSelectHostDialog GtkSelectHostDialog;
 
@@ -68,9 +68,9 @@ struct _GtkSelectHostDialogClass
        GtkDialogClass parent_class;
 };
 
-#define GTK_SELECT_HOST_DIALOG(obj)          GTK_CHECK_CAST (obj, gtk_rpc_binding_dialog_get_type (), GtkSelectHostDialog)
-#define GTK_SELECT_HOST_DIALOG_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gtk_rpc_binding_dialog_class_get_type (), GtkSelectHostDialogClass)
-#define IS_GTK_SELECT_HOST_DIALOG(obj)       GTK_CHECK_TYPE (obj, gtk_rpc_binding_dialog_get_type ())
+#define GTK_SELECT_HOST_DIALOG(obj)          GTK_CHECK_CAST (obj, gtk_select_host_dialog_get_type (), GtkSelectHostDialog)
+#define GTK_SELECT_HOST_DIALOG_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, gtk_select_host_dialog_class_get_type (), GtkSelectHostDialogClass)
+#define IS_GTK_SELECT_HOST_DIALOG(obj)       GTK_CHECK_TYPE (obj, gtk_select_host_dialog_get_type ())
 
 #endif
 
index f7f5b3528aa3e1b753a4de0cb738559a20f86aa9..1c81d8643cce9e29a881ff6ec914ba71c912ce62 100644 (file)
@@ -158,7 +158,7 @@ static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data)
        char *credentials;
        const char *location;
        char *tmp;
-       GtkWidget *rpcwin = GTK_WIDGET(gtk_rpc_binding_dialog_new(TRUE));
+       GtkWidget *rpcwin = GTK_WIDGET(gtk_rpc_binding_dialog_new(TRUE, NULL));
        gint result = gtk_dialog_run(GTK_DIALOG(rpcwin));
        WERROR error;
        
index c742edf7e998a5d0a354e7d78c8f98142250e66e..b3137a9a192a8a6f22e538ce5df1e049bd7b8d19 100644 (file)
@@ -86,7 +86,7 @@ on_connect_activate                    (GtkMenuItem     *menuitem,
        NTSTATUS status;
        gint result;
 
-       d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(FALSE));
+       d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(FALSE, NULL));
     result = gtk_dialog_run(GTK_DIALOG(d));
        switch(result) {
                case GTK_RESPONSE_ACCEPT:
index 951096ddefd9e67f54a249dae2f624fd59558947..a085c49897d164db4b8bbc8751641c61e3ea55fa 100644 (file)
@@ -27,6 +27,7 @@ struct dcerpc_pipe *sam_pipe = NULL;
 struct policy_handle domain_handle;
 GtkWidget *mainwin;
 GtkWidget *seldomain;
+GtkWidget *mnu_disconnect;
 
 void update_grouplist(void)
 {
@@ -112,7 +113,7 @@ void on_connect_activate (GtkMenuItem *menuitem, gpointer user_data)
        TALLOC_CTX *mem_ctx;
        gint result;
 
-       d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(FALSE));
+       d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(FALSE, NULL));
        result = gtk_dialog_run(GTK_DIALOG(d));
        switch(result) {
        case GTK_RESPONSE_ACCEPT:
@@ -137,16 +138,25 @@ void on_connect_activate (GtkMenuItem *menuitem, gpointer user_data)
 
        mem_ctx = talloc_init("connect");                                                                                                 
        status = dcerpc_samr_Connect(sam_pipe, mem_ctx, &r);
-       talloc_destroy(mem_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                gtk_show_ntstatus(mainwin, status);
                sam_pipe = NULL;
                gtk_widget_destroy(GTK_WIDGET(d));
+               talloc_destroy(mem_ctx);
                return;
        }
 
        gtk_widget_set_sensitive (seldomain, TRUE);
+       gtk_widget_set_sensitive (mnu_disconnect, TRUE);
+       gtk_window_set_title (GTK_WINDOW (mainwin), talloc_asprintf(mem_ctx, "User Manager - Connected to %s", gtk_rpc_binding_dialog_get_host(d)));
        gtk_widget_destroy(GTK_WIDGET(d));
+       talloc_destroy(mem_ctx);
+}
+
+void on_disconnect_activate (GtkMenuItem *menuitem, gpointer user_data)
+{
+       gtk_widget_set_sensitive (mnu_disconnect, FALSE);
+       gtk_window_set_title (GTK_WINDOW (mainwin), "User Manager");
 }
 
 void
@@ -265,6 +275,11 @@ create_mainwindow (void)
        gtk_widget_show (mnu_connect);
        gtk_container_add (GTK_CONTAINER (menuitem1_menu), mnu_connect);
 
+       mnu_disconnect = gtk_menu_item_new_with_mnemonic ("_Disconnect");
+       gtk_widget_show (mnu_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_show(seldomain);
        gtk_widget_set_sensitive (seldomain, FALSE);
@@ -378,6 +393,9 @@ create_mainwindow (void)
        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);