The branch, v3-devel has been updated
       via  8d541a3579637bb48c04ebb2b18844509c1f43e8 (commit)
       via  af25bd95d24de8e9fac8f86b18e03a09902b0b78 (commit)
       via  74031b0b4ac1301cff6ca551c3264c4137a43294 (commit)
       via  c979b96eb4b0df94e9d736a9473d00c28a52ed07 (commit)
       via  56d353b406ef77808b9cb968fcba387f301cf2de (commit)
       via  1760c4ce79ae15f9a2ea92293d823afe3af9b3ee (commit)
      from  b7a2f27c1cae9abed2f821177fca425012222632 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-devel


- Log -----------------------------------------------------------------
commit 8d541a3579637bb48c04ebb2b18844509c1f43e8
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Sep 2 02:02:20 2008 +0200

    netdomjoin-gui: fix some widget closing callbacks.
    
    Guenther

commit af25bd95d24de8e9fac8f86b18e03a09902b0b78
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Sep 2 01:06:25 2008 +0200

    netdomjoin-gui: always center new windows.
    
    Guenther

commit 74031b0b4ac1301cff6ca551c3264c4137a43294
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Sep 2 00:49:33 2008 +0200

    netdomjoin-gui: fix some small errors in callbacks.
    
    Guenther

commit c979b96eb4b0df94e9d736a9473d00c28a52ed07
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Sep 2 00:36:31 2008 +0200

    netdomjoin-gui: add gtk set_transient flags.
    
    Guenther

commit 56d353b406ef77808b9cb968fcba387f301cf2de
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Tue Sep 2 16:14:14 2008 +0200

    netdomjoin-gui: test all NetServerGetInfo levels until we get comment.

commit 1760c4ce79ae15f9a2ea92293d823afe3af9b3ee
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Mon Sep 1 18:59:59 2008 +0200

    netdomjoin-gui: add support to remotely join/unjoin workstations.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 .../examples/netdomjoin-gui/netdomjoin-gui.c       |  192 ++++++++++++++------
 1 files changed, 136 insertions(+), 56 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c 
b/source/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
index 4e0488e..98994b6 100644
--- a/source/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
+++ b/source/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
@@ -80,6 +80,7 @@ typedef struct join_state {
        gboolean settings_changed;
        gboolean hostname_changed;
        uint32_t stored_num_ous;
+       char *target_hostname;
 } join_state;
 
 static void debug(const char *format, ...)
@@ -103,14 +104,23 @@ static gboolean callback_delete_event(GtkWidget *widget,
        return FALSE;
 }
 
-static void callback_do_close(GtkWidget *widget,
-                             gpointer data)
+static void callback_do_close_data(GtkWidget *widget,
+                                  gpointer data)
 {
-       debug("callback_do_close called\n");
+       debug("callback_do_close_data called\n");
 
        if (data) {
                gtk_widget_destroy(GTK_WIDGET(data));
-               data = NULL;
+       }
+}
+
+static void callback_do_close_widget(GtkWidget *widget,
+                                    gpointer data)
+{
+       debug("callback_do_close_widget called\n");
+
+       if (widget) {
+               gtk_widget_destroy(widget);
        }
 }
 
@@ -180,7 +190,10 @@ static void callback_apply_description_change(GtkWidget 
*widget,
 
        info1005.sv1005_comment = state->comment_new;
 
-       status = NetServerSetInfo(NULL, 1005, (uint8_t *)&info1005, &parm_err); 
+       status = NetServerSetInfo(state->target_hostname,
+                                 1005,
+                                 (uint8_t *)&info1005,
+                                 &parm_err);
        if (status) {
                debug("NetServerSetInfo failed with: %s\n",
                        libnetapi_errstr(status));
@@ -191,6 +204,7 @@ static void callback_apply_description_change(GtkWidget 
*widget,
                                                "Failed to change computer 
description: %s.",
                                                
libnetapi_get_error_string(state->ctx, status));
                gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+               gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_main));
 
                g_signal_connect_swapped(dialog, "response",
                                         G_CALLBACK(gtk_widget_destroy),
@@ -262,6 +276,7 @@ static void callback_do_reboot(GtkWidget *widget,
                                        GTK_BUTTONS_OK,
                                        "You must restart this computer for the 
changes to take effect.");
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
 #if 0
        g_signal_connect_swapped(dialog, "response",
                                 G_CALLBACK(gtk_widget_destroy),
@@ -285,7 +300,9 @@ static void callback_do_reboot(GtkWidget *widget,
                const char *buffer;
                uint16_t type;
 
-               status = NetGetJoinInformation(NULL, &buffer, &type);
+               status = NetGetJoinInformation(state->target_hostname,
+                                              &buffer,
+                                              &type);
                if (status != 0) {
                        g_print("failed to query status\n");
                        return;
@@ -461,6 +478,7 @@ static void callback_do_hostname_change(GtkWidget *widget,
                                        str);
 
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_main));
        g_signal_connect_swapped(dialog, "response",
                                 G_CALLBACK(gtk_widget_destroy),
                                 dialog);
@@ -490,9 +508,11 @@ static void callback_creds_prompt(GtkWidget *widget,
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
        gtk_widget_set_size_request(GTK_WIDGET(window), 380, 280);
        gtk_window_set_icon_from_file(GTK_WINDOW(window), SAMBA_ICON_PATH, 
NULL);
+       gtk_window_set_transient_for(GTK_WINDOW(window), 
GTK_WINDOW(state->window_do_change));
+       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
 
        g_signal_connect(G_OBJECT(window), "delete_event",
-                        G_CALLBACK(callback_do_close), window);
+                        G_CALLBACK(callback_do_close_widget), NULL);
 
        state->window_creds_prompt = window;
        gtk_container_set_border_width(GTK_CONTAINER(window), 10);
@@ -658,7 +678,7 @@ static void callback_do_join(GtkWidget *widget,
                        }
                }
 
-               status = NetUnjoinDomain(NULL,
+               status = NetUnjoinDomain(state->target_hostname,
                                         state->account,
                                         state->password,
                                         unjoin_flags);
@@ -712,6 +732,7 @@ static void callback_do_join(GtkWidget *widget,
                                                        err_str);
 
                        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+                       gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
                        g_signal_connect_swapped(dialog, "response",
                                                 G_CALLBACK(gtk_widget_destroy),
                                                 dialog);
@@ -748,7 +769,7 @@ static void callback_do_join(GtkWidget *widget,
        }
        debug("\n");
 
-       status = NetJoinDomain(NULL,
+       status = NetJoinDomain(state->target_hostname,
                               state->name_buffer_new,
                               account_ou,
                               state->account,
@@ -769,6 +790,7 @@ static void callback_do_join(GtkWidget *widget,
                                                err_str);
 
                gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+               gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
                g_signal_connect_swapped(dialog, "response",
                                         G_CALLBACK(gtk_widget_destroy),
                                         dialog);
@@ -791,6 +813,7 @@ static void callback_do_join(GtkWidget *widget,
                                        new_workgroup_type);
 
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
 
@@ -814,9 +837,11 @@ static void callback_enter_hostname_and_unlock(GtkWidget 
*widget,
        if (strcasecmp(state->my_hostname, entry_text) == 0) {
                state->hostname_changed = FALSE;
                gtk_widget_set_sensitive(GTK_WIDGET(state->button_ok), FALSE);
-               return;
+               /* return; */
+       } else {
+               state->hostname_changed = TRUE;
        }
-       state->hostname_changed = TRUE;
+
        if (state->name_type_initial == NetSetupDomainName) {
                if (asprintf(&str, "%s.%s", entry_text, state->my_dnsdomain) == 
-1) {
                        return;
@@ -839,7 +864,7 @@ static void 
callback_enter_computer_description_and_unlock(GtkWidget *widget,
 {
        const gchar *entry_text = NULL;
        struct join_state *state = (struct join_state *)data;
-       int string_unchanged = 0;
+       int string_unchanged = FALSE;
 
        entry_text = gtk_entry_get_text(GTK_ENTRY(widget));
        debug("callback_enter_computer_description_and_unlock: %s\n",
@@ -852,8 +877,8 @@ static void 
callback_enter_computer_description_and_unlock(GtkWidget *widget,
                return;
        }
 #endif
-       if (entry_text && strcasecmp(state->comment, entry_text) == 0) {
-               string_unchanged = 1;
+       if (entry_text && state->comment && strcasecmp(state->comment, 
entry_text) == 0) {
+               string_unchanged = TRUE;
                gtk_widget_set_sensitive(GTK_WIDGET(state->button_apply),
                                         FALSE);
                return;
@@ -982,6 +1007,7 @@ static void callback_do_getous(GtkWidget *widget,
                                                err_str);
 
                gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+               gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
                g_signal_connect_swapped(dialog, "response",
                                         G_CALLBACK(gtk_widget_destroy),
                                         dialog);
@@ -1003,7 +1029,8 @@ static void callback_do_getous(GtkWidget *widget,
                return;
        }
 
-       status = NetGetJoinableOUs(NULL, domain,
+       status = NetGetJoinableOUs(state->target_hostname,
+                                  domain,
                                   state->account,
                                   state->password,
                                   &num_ous, &ous);
@@ -1018,6 +1045,7 @@ static void callback_do_getous(GtkWidget *widget,
                                                "Failed to query joinable OUs: 
%s",
                                                
libnetapi_get_error_string(state->ctx, status));
                gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+               gtk_window_set_transient_for(GTK_WINDOW(dialog), 
GTK_WINDOW(state->window_do_change));
                gtk_dialog_run(GTK_DIALOG(dialog));
                gtk_widget_destroy(dialog);
                return;
@@ -1083,9 +1111,11 @@ static void callback_do_change(GtkWidget *widget,
        gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
        gtk_widget_set_size_request(GTK_WIDGET(window), 480, 650);
        gtk_window_set_icon_from_file(GTK_WINDOW(window), SAMBA_ICON_PATH, 
NULL);
+       gtk_window_set_transient_for(GTK_WINDOW(window), 
GTK_WINDOW(state->window_main));
+       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
 
        g_signal_connect(G_OBJECT(window), "delete_event",
-                        G_CALLBACK(callback_do_close), window);
+                        G_CALLBACK(callback_do_close_widget), NULL);
 
        gtk_container_set_border_width(GTK_CONTAINER(window), 10);
 
@@ -1283,6 +1313,8 @@ static void callback_do_about(GtkWidget *widget,
        GError    *error = NULL;
        GtkWidget *about;
 
+       struct join_state *state = (struct join_state *)data;
+
        debug("callback_do_about called\n");
 
        logo = gdk_pixbuf_new_from_file(SAMBA_IMAGE_PATH,
@@ -1306,6 +1338,7 @@ static void callback_do_about(GtkWidget *widget,
        }
        gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about), "Samba gtk 
domain join utility");
        gtk_window_set_modal(GTK_WINDOW(about), TRUE);
+       gtk_window_set_transient_for(GTK_WINDOW(about), 
GTK_WINDOW(state->window_main));
        g_signal_connect_swapped(about, "response",
                                 G_CALLBACK(gtk_widget_destroy),
                                 about);
@@ -1352,6 +1385,7 @@ static int draw_main_window(struct join_state *state)
        gtk_widget_set_size_request(GTK_WIDGET(window), 600, 600);
        gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
        gtk_window_set_icon_from_file(GTK_WINDOW(window), SAMBA_ICON_PATH, 
NULL);
+       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
 
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(callback_delete_event), NULL);
@@ -1546,7 +1580,7 @@ static int draw_main_window(struct join_state *state)
                gtk_container_add(GTK_CONTAINER(bbox2), button2);
                g_signal_connect(G_OBJECT(button2), "clicked",
                                 G_CALLBACK(callback_do_about),
-                                window);
+                                state);
 #if 0
                button2 = gtk_button_new_from_stock(GTK_STOCK_HELP);
                gtk_container_add(GTK_CONTAINER(bbox2), button2);
@@ -1578,8 +1612,55 @@ static int init_join_state(struct join_state **state)
        return 0;
 }
 
+static NET_API_STATUS get_server_comment(struct join_state *state)
+{
+       struct SERVER_INFO_101 *info101 = NULL;
+       struct SERVER_INFO_1005 *info1005 = NULL;
+       NET_API_STATUS status;
+
+       status = NetServerGetInfo(state->target_hostname,
+                                 101,
+                                 (uint8_t **)&info101);
+       if (status == 0) {
+               state->comment = strdup(info101->sv101_comment);
+               if (!state->comment) {
+                       return -1;
+               }
+               NetApiBufferFree(info101);
+               return NET_API_STATUS_SUCCESS;
+       }
+
+       switch (status) {
+               case 124: /* WERR_UNKNOWN_LEVEL */
+               case 50: /* WERR_NOT_SUPPORTED */
+                       break;
+               default:
+                       goto failed;
+       }
+
+       status = NetServerGetInfo(state->target_hostname,
+                                 1005,
+                                 (uint8_t **)&info1005);
+       if (status == 0) {
+               state->comment = strdup(info1005->sv1005_comment);
+               if (!state->comment) {
+                       return -1;
+               }
+               NetApiBufferFree(info1005);
+               return NET_API_STATUS_SUCCESS;
+       }
+
+ failed:
+       printf("NetServerGetInfo failed with: %s\n",
+               libnetapi_get_error_string(state->ctx, status));
+
+       return status;
+}
+
 static int initialize_join_state(struct join_state *state,
-                                const char *debug_level)
+                                const char *debug_level,
+                                const char *target_hostname,
+                                const char *target_username)
 {
        struct libnetapi_ctx *ctx = NULL;
        NET_API_STATUS status = 0;
@@ -1593,6 +1674,30 @@ static int initialize_join_state(struct join_state 
*state,
                libnetapi_set_debuglevel(ctx, debug_level);
        }
 
+       if (target_hostname) {
+               state->target_hostname = strdup(target_hostname);
+               if (!state->target_hostname) {
+                       return -1;
+               }
+       }
+
+       if (target_username) {
+               char *puser = strdup(target_username);
+               char *p = NULL;
+
+               if ((p = strchr(puser,'%'))) {
+                       size_t len;
+                       *p = 0;
+                       libnetapi_set_username(ctx, puser);
+                       libnetapi_set_password(ctx, p+1);
+                       len = strlen(p+1);
+                       memset(strchr(target_username,'%')+1,'X',len);
+               } else {
+                       libnetapi_set_username(ctx, puser);
+               }
+               free(puser);
+       }
+
        {
                char my_hostname[HOST_NAME_MAX];
                const char *p = NULL;
@@ -1639,7 +1744,9 @@ static int initialize_join_state(struct join_state *state,
        {
                const char *buffer = NULL;
                uint16_t type = 0;
-               status = NetGetJoinInformation(NULL, &buffer, &type);
+               status = NetGetJoinInformation(state->target_hostname,
+                                              &buffer,
+                                              &type);
                if (status != 0) {
                        printf("NetGetJoinInformation failed with: %s\n",
                                libnetapi_get_error_string(state->ctx, status));
@@ -1654,43 +1761,10 @@ static int initialize_join_state(struct join_state 
*state,
                NetApiBufferFree((void *)buffer);
        }
 
-       {
-               struct SERVER_INFO_1005 *info1005 = NULL;
-               uint8_t *buffer = NULL;
-
-               status = NetServerGetInfo(NULL, 1005, &buffer);
-               if (status != 0) {
-                       printf("NetServerGetInfo failed with: %s\n",
-                               libnetapi_get_error_string(state->ctx, status));
-                       return status;
-               }
-
-               info1005 = (struct SERVER_INFO_1005 *)buffer;
-
-               state->comment = strdup(info1005->sv1005_comment);
-               if (!state->comment) {
-                       return -1;
-               }
-               NetApiBufferFree(buffer);
-       }
-#if 0
-       {
-               struct srvsvc_NetSrvInfo100 *info100 = NULL;
-               uint8_t *buffer = NULL;
-
-               status = NetServerGetInfo(NULL, 100, &buffer);
-               if (status) {
-                       return status;
-               }
-
-               info100 = (struct srvsvc_NetSrvInfo100 *)buffer;
-
-               state->comment = strdup(info100->comment);
-               if (!state->comment) {
-                       return -1;
-               }
+       status = get_server_comment(state);
+       if (status != 0) {
+               return -1;
        }
-#endif
 
        state->ctx = ctx;
 
@@ -1701,6 +1775,8 @@ int main(int argc, char **argv)
 {
        GOptionContext *context = NULL;
        static const char *debug_level = NULL;
+       static const char *target_hostname = NULL;
+       static const char *target_username = NULL;
        struct join_state *state = NULL;
        GError *error = NULL;
        int ret = 0;
@@ -1708,6 +1784,8 @@ int main(int argc, char **argv)
        static GOptionEntry entries[] = {
                { "debug", 'd', 0, G_OPTION_ARG_STRING, &debug_level, "Debug 
level (for samba)", "N" },
                { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Verbose 
output", 0 },
+               { "target", 'S', 0, G_OPTION_ARG_STRING, &target_hostname, 
"Target hostname", 0 },
+               { "username", 'U', 0, G_OPTION_ARG_STRING, &target_username, 
"Target hostname", 0 },
                { NULL }
        };
 
@@ -1725,7 +1803,9 @@ int main(int argc, char **argv)
                return ret;
        }
 
-       ret = initialize_join_state(state, debug_level);
+       ret = initialize_join_state(state, debug_level,
+                                   target_hostname,
+                                   target_username);
        if (ret) {
                return ret;
        }


-- 
Samba Shared Repository

Reply via email to