diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/accept_drop.c afd-1.3.6/src/UI/Motif/edit_hc/accept_drop.c --- afd-1.3.6.old/src/UI/Motif/edit_hc/accept_drop.c 2000-01-24 10:09:22.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/accept_drop.c 2008-09-20 19:07:02.000000000 +0200 @@ -55,7 +55,8 @@ extern Display *display; extern Widget host_list_w; extern Atom compound_text; -extern int host_alias_order_change; +extern int host_alias_order_change, + last_selected; extern char last_selected_host[]; /* Local global variables */ @@ -171,7 +172,8 @@ /* Select the host that was selected last. */ str = XmStringCreateLocalized(last_selected_host); - XmListSelectItem(host_list_w, str, False); + last_selected = -1; + XmListSelectItem(host_list_w, str, True); XmStringFree(str); XtFree((char *)select_list); diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc.c afd-1.3.6/src/UI/Motif/edit_hc/edit_hc.c --- afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc.c 2007-11-18 09:29:26.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/edit_hc.c 2008-09-20 19:24:53.000000000 +0200 @@ -199,6 +199,7 @@ fsa_id, host_alias_order_change = NO, in_drop_site = -2, + last_selected = -1, no_of_dirs, no_of_hosts, sys_log_fd = STDERR_FILENO; @@ -214,7 +215,7 @@ struct filetransfer_status *fsa; struct afd_status *p_afd_status; struct host_list *hl = NULL; /* required by change_alias_order() */ -struct changed_entry *ce; +struct changed_entry *ce = NULL; struct parallel_transfers pt; struct no_of_no_bursts nob; struct transfer_blocksize tb; @@ -1982,14 +1983,6 @@ } } - /* Allocate memory to store all changes. */ - if ((ce = malloc(no_of_hosts * sizeof(struct changed_entry))) == NULL) - { - (void)fprintf(stderr, "malloc() error : %s (%s %d)\n", - strerror(errno), __FILE__, __LINE__); - exit(INCORRECT); - } - /* Get display pointer. */ if ((display = XOpenDisplay(NULL)) == NULL) { @@ -2299,75 +2292,12 @@ static void init_widget_data(void) { - int i; - Arg args[MAXARGS]; - Cardinal argcount; - Pixmap icon, - iconmask; - Display *sdisplay = XtDisplay(host_list_w); - Window win = XtWindow(host_list_w); - XmStringTable item_list; - - item_list = (XmStringTable)XtMalloc(no_of_hosts * sizeof(XmString)); - - for (i = 0; i < no_of_hosts; i++) - { - item_list[i] = XmStringCreateLocalized(fsa[i].host_alias); - - /* Initialize array holding all changed entries. */ - ce[i].value_changed = 0; - ce[i].value_changed2 = 0; - ce[i].real_hostname[0][0] = -1; - ce[i].real_hostname[1][0] = -1; - ce[i].proxy_name[0] = -1; - ce[i].transfer_timeout = -1L; - ce[i].retry_interval = -1; - ce[i].max_errors = -1; - ce[i].max_successful_retries = -1; - ce[i].allowed_transfers = -1; - ce[i].block_size = -1; - ce[i].file_size_offset = -3; - ce[i].transfer_rate_limit = -1; - ce[i].sndbuf_size = 0; - ce[i].rcvbuf_size = 0; - ce[i].keep_connected = 0; -#ifdef WITH_DUP_CHECK - ce[i].dup_check_flag = 0; - ce[i].dup_check_timeout = 0L; -#endif - if (fsa[i].host_toggle_str[0] == '\0') - { - ce[i].host_toggle[0][0] = '1'; - ce[i].host_toggle[1][0] = '2'; - ce[i].host_switch_toggle = OFF; - ce[i].auto_toggle = OFF; - } - else - { - ce[i].host_toggle[0][0] = fsa[i].host_toggle_str[HOST_ONE]; - ce[i].host_toggle[1][0] = fsa[i].host_toggle_str[HOST_TWO]; - ce[i].host_switch_toggle = ON; - if (fsa[i].auto_toggle == ON) - { - ce[i].auto_toggle = ON; - } - else - { - ce[i].auto_toggle = OFF; - } - } - } - - XtVaSetValues(host_list_w, - XmNitems, item_list, - XmNitemCount, no_of_hosts, - NULL); - - for (i = 0; i < no_of_hosts; i++) - { - XmStringFree(item_list[i]); - } - XtFree((char *)item_list); + Arg args[MAXARGS]; + Cardinal argcount; + Pixmap icon, + iconmask; + Display *sdisplay = XtDisplay(host_list_w); + Window win = XtWindow(host_list_w); /* * Create source cursor for drag & drop. @@ -2413,33 +2343,9 @@ XtSetArg(args[argcount], XmNmask, iconmask); argcount++; no_source_icon_w = XmCreateDragIcon(host_list_w, "no_source_icon", - args, argcount); - - /* Select the first host. */ - if (no_of_hosts > 0) - { - int top, - visible; + args, argcount); - XmListSelectPos(host_list_w, seleted_host_no + 1, True); - - /* - * This code was taken from the book Motif Programming Manual - * Volume 6A by Dan Heller & Paula M. Ferguson. - */ - XtVaGetValues(host_list_w, - XmNtopItemPosition, &top, - XmNvisibleItemCount, &visible, - NULL); - if ((seleted_host_no + 1) < top) - { - XmListSetPos(host_list_w, (seleted_host_no + 1)); - } - else if ((seleted_host_no + 1) >= (top + visible)) - { - XmListSetBottomPos(host_list_w, (seleted_host_no + 1)); - } - } + init_host_list(seleted_host_no); return; } diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc_callbacks.c afd-1.3.6/src/UI/Motif/edit_hc/edit_hc_callbacks.c --- afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc_callbacks.c 2007-11-18 09:32:17.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/edit_hc_callbacks.c 2008-09-20 19:30:02.000000000 +0200 @@ -138,6 +138,7 @@ extern int fsa_id, host_alias_order_change, in_drop_site, + last_selected, sys_log_fd, no_of_hosts; extern char fake_user[], @@ -1104,7 +1105,6 @@ void selected(Widget w, XtPointer client_data, XtPointer call_data) { - static int last_select = -1; char *host_selected; XmListCallbackStruct *cbs = (XmListCallbackStruct *)call_data; @@ -1126,14 +1126,14 @@ /* * Don't always show the same data!!!! */ - if (cur_pos != last_select) + if (cur_pos != last_selected) { int choice; char *tmp_ptr, numeric_str[MAX_LONG_LENGTH]; XmString xstr; - last_select = cur_pos; + last_selected = cur_pos; if ((fsa[cur_pos].protocol & FTP_FLAG) || (fsa[cur_pos].protocol & SFTP_FLAG) || @@ -1956,7 +1956,7 @@ { XtSetSensitive(rm_button_w, True); } - } /* if (cur_pos != last_select) */ + } /* if (cur_pos != last_selected) */ return; } @@ -2622,7 +2622,6 @@ db_update_fd; char db_update_fifo[MAX_PATH_LENGTH]; - host_alias_order_change = NO; (void)strcpy(db_update_fifo, p_work_dir); (void)strcat(db_update_fifo, FIFO_DIR); (void)strcat(db_update_fifo, DB_UPDATE_FIFO); @@ -2656,6 +2655,26 @@ "close() error : %s", strerror(errno)); } } + + /* + * If the order changes we created a new FSA and we must reflect + * this is struct changed_entry! Otherwise if user continues using + * this dialog it will base it changes on a wrong FSA and thus, + * update wrong host(s). + * NOTE: We do not need detach and attach to the FSA because + * function change_alias_order() did this for us. + */ + if (host_alias_order_change == YES) + { + if ((cur_pos = get_host_position(fsa, last_selected_host, no_of_hosts)) < 0) + { + (void)xrec(FATAL_DIALOG, + "AAAaaaarrrrghhhh!!! Could not find host %s in FSA. (%s %d)", + last_selected_host, __FILE__, __LINE__); + return; + } + } + host_alias_order_change = NO; } if (host_list != NULL) diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc.h afd-1.3.6/src/UI/Motif/edit_hc/edit_hc.h --- afd-1.3.6.old/src/UI/Motif/edit_hc/edit_hc.h 2007-11-03 19:32:38.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/edit_hc.h 2008-09-20 19:32:51.000000000 +0200 @@ -193,6 +193,7 @@ fso_option_changed(Widget, XtPointer, XtPointer), ftp_mode_radio_button(Widget, XtPointer, XtPointer), host_switch_toggle(Widget, XtPointer, XtPointer), + init_host_list(int), kc_radio_button(Widget, XtPointer, XtPointer), leave_notify(Widget, XtPointer, XtPointer), nob_option_changed(Widget, XtPointer, XtPointer), diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/init_host_list.c afd-1.3.6/src/UI/Motif/edit_hc/init_host_list.c --- afd-1.3.6.old/src/UI/Motif/edit_hc/init_host_list.c 1970-01-01 01:00:00.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/init_host_list.c 2008-09-20 19:30:46.000000000 +0200 @@ -0,0 +1,166 @@ +/* + * init_host_list.c - Part of AFD, an automatic file distribution program. + * Copyright (c) 2008 Holger Kiehl + * + * 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 "afddefs.h" + +DESCR__S_M3 +/* + ** NAME + ** init_host_list - initialiaze host list in list widget + ** + ** SYNOPSIS + ** void init_host_list(int seleted_host_no) + ** + ** DESCRIPTION + ** + ** RETURN VALUES + ** + ** AUTHOR + ** H.Kiehl + ** + ** HISTORY + ** 20.09.2008 H.Kiehl Created + ** + */ +DESCR__E_M3 + +#include +#include +#include +#include +#include +#include "edit_hc.h" + +/* External global variables. */ +extern Widget host_list_w; +extern int no_of_hosts; +extern struct changed_entry *ce; +extern struct filetransfer_status *fsa; + + +/*########################### init_host_list() ##########################*/ +void +init_host_list(int seleted_host_no) +{ + int i; + XmStringTable item_list; + + if (ce != NULL) + { + free(ce); + XmListDeleteAllItems(host_list_w); + } + + /* Allocate memory to store all changes. */ + if ((ce = malloc(no_of_hosts * sizeof(struct changed_entry))) == NULL) + { + (void)fprintf(stderr, "malloc() error : %s (%s %d)\n", + strerror(errno), __FILE__, __LINE__); + exit(INCORRECT); + } + + item_list = (XmStringTable)XtMalloc(no_of_hosts * sizeof(XmString)); + + for (i = 0; i < no_of_hosts; i++) + { + item_list[i] = XmStringCreateLocalized(fsa[i].host_alias); + + /* Initialize array holding all changed entries. */ + ce[i].value_changed = 0; + ce[i].value_changed2 = 0; + ce[i].real_hostname[0][0] = -1; + ce[i].real_hostname[1][0] = -1; + ce[i].proxy_name[0] = -1; + ce[i].transfer_timeout = -1L; + ce[i].retry_interval = -1; + ce[i].max_errors = -1; + ce[i].max_successful_retries = -1; + ce[i].allowed_transfers = -1; + ce[i].block_size = -1; + ce[i].file_size_offset = -3; + ce[i].transfer_rate_limit = -1; + ce[i].sndbuf_size = 0; + ce[i].rcvbuf_size = 0; + ce[i].keep_connected = 0; +#ifdef WITH_DUP_CHECK + ce[i].dup_check_flag = 0; + ce[i].dup_check_timeout = 0L; +#endif + if (fsa[i].host_toggle_str[0] == '\0') + { + ce[i].host_toggle[0][0] = '1'; + ce[i].host_toggle[1][0] = '2'; + ce[i].host_switch_toggle = OFF; + ce[i].auto_toggle = OFF; + } + else + { + ce[i].host_toggle[0][0] = fsa[i].host_toggle_str[HOST_ONE]; + ce[i].host_toggle[1][0] = fsa[i].host_toggle_str[HOST_TWO]; + ce[i].host_switch_toggle = ON; + if (fsa[i].auto_toggle == ON) + { + ce[i].auto_toggle = ON; + } + else + { + ce[i].auto_toggle = OFF; + } + } + } + + XtVaSetValues(host_list_w, + XmNitems, item_list, + XmNitemCount, no_of_hosts, + NULL); + + for (i = 0; i < no_of_hosts; i++) + { + XmStringFree(item_list[i]); + } + XtFree((char *)item_list); + + /* Select the given host. */ + if (no_of_hosts > 0) + { + int top, + visible; + + XmListSelectPos(host_list_w, seleted_host_no + 1, True); + + /* + * This code was taken from the book Motif Programming Manual + * Volume 6A by Dan Heller & Paula M. Ferguson. + */ + XtVaGetValues(host_list_w, + XmNtopItemPosition, &top, + XmNvisibleItemCount, &visible, + NULL); + if ((seleted_host_no + 1) < top) + { + XmListSetPos(host_list_w, (seleted_host_no + 1)); + } + else if ((seleted_host_no + 1) >= (top + visible)) + { + XmListSetBottomPos(host_list_w, (seleted_host_no + 1)); + } + } + + return; +} diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/Makefile.am afd-1.3.6/src/UI/Motif/edit_hc/Makefile.am --- afd-1.3.6.old/src/UI/Motif/edit_hc/Makefile.am 2007-09-05 12:33:30.000000000 +0200 +++ afd-1.3.6/src/UI/Motif/edit_hc/Makefile.am 2008-09-20 19:33:19.000000000 +0200 @@ -27,6 +27,7 @@ edit_hc_SOURCES = accept_drop.c\ edit_hc.c\ edit_hc_callbacks.c\ + init_host_list.c\ remove_host.c\ start_drag.c edit_hc_LDADD = ../common/libmotifafd.a\ diff -u --recursive --new-file afd-1.3.6.old/src/UI/Motif/edit_hc/Makefile.in afd-1.3.6/src/UI/Motif/edit_hc/Makefile.in --- afd-1.3.6.old/src/UI/Motif/edit_hc/Makefile.in 2007-11-29 14:15:18.000000000 +0100 +++ afd-1.3.6/src/UI/Motif/edit_hc/Makefile.in 2008-09-20 20:04:43.000000000 +0200 @@ -62,8 +62,8 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_edit_hc_OBJECTS = accept_drop.$(OBJEXT) edit_hc.$(OBJEXT) \ - edit_hc_callbacks.$(OBJEXT) remove_host.$(OBJEXT) \ - start_drag.$(OBJEXT) + edit_hc_callbacks.$(OBJEXT) init_host_list.$(OBJEXT) \ + remove_host.$(OBJEXT) start_drag.$(OBJEXT) edit_hc_OBJECTS = $(am_edit_hc_OBJECTS) edit_hc_DEPENDENCIES = ../common/libmotifafd.a \ ../../../common/libafd.a @@ -245,6 +245,7 @@ edit_hc_SOURCES = accept_drop.c\ edit_hc.c\ edit_hc_callbacks.c\ + init_host_list.c\ remove_host.c\ start_drag.c @@ -320,6 +321,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/accept_drop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit_hc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit_hc_callbacks.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init_host_list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove_host.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/start_drag.Po@am__quote@