1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
|
/*
* Copyright (c) 1993-2009, Paul Mattes.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the names of Paul Mattes nor the names of his contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* idle.c
* This module handles the idle command.
*/
#include "globals.h"
#if defined(X3270_DISPLAY) || defined(C3270) /*[*/
#if defined(X3270_DISPLAY) /*[*/
#include <X11/StringDefs.h>
#include <X11/Xaw/Toggle.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Form.h>
#include <X11/Shell.h>
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/TextSrc.h>
#include <X11/Xaw/TextSink.h>
#include <X11/Xaw/AsciiSrc.h>
#include <X11/Xaw/AsciiSink.h>
#endif /*]*/
#include <errno.h>
#include "appres.h"
#include "dialogc.h"
#include "hostc.h"
#include "idlec.h"
#include "macrosc.h"
#include "objects.h"
#include "popupsc.h"
#include "resources.h"
#include "trace_dsc.h"
#include "utilc.h"
/* Macros. */
#define MSEC_PER_SEC 1000L
#define IDLE_SEC 1L
#define IDLE_MIN 60L
#define IDLE_HR (60L * 60L)
#define IDLE_MS (7L * IDLE_MIN * MSEC_PER_SEC)
#if defined(X3270_DISPLAY) /*[*/
#define FILE_WIDTH 300 /* width of file name widgets */
#define MARGIN 3 /* distance from margins to widgets */
#define CLOSE_VGAP 0 /* distance between paired toggles */
#define FAR_VGAP 10 /* distance between single toggles and groups */
#define BUTTON_GAP 5 /* horizontal distance between buttons */
#endif /*]*/
#define BN (Boolean *)NULL
/* Externals. */
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
extern Pixmap diamond;
extern Pixmap no_diamond;
extern Pixmap dot;
extern Pixmap no_dot;
#endif /*]*/
/* Globals. */
Boolean idle_changed = False;
char *idle_command = CN;
char *idle_timeout_string = CN;
enum idle_enum idle_user_enabled = IDLE_DISABLED;
/* Statics. */
static Boolean idle_enabled = False; /* validated and user-enabled */
static unsigned long idle_n = 0L;
static unsigned long idle_multiplier = IDLE_SEC;
static unsigned long idle_id;
static unsigned long idle_ms;
static Boolean idle_randomize = False;
static Boolean idle_ticking = False;
static void idle_in3270(Boolean in3270);
static int process_timeout_value(char *t);
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
static enum idle_enum s_disabled = IDLE_DISABLED;
static enum idle_enum s_session = IDLE_SESSION;
static enum idle_enum s_perm = IDLE_PERM;
static char hms = 'm';
static Boolean fuzz = False;
static char s_hours = 'h';
static char s_minutes = 'm';
static char s_seconds = 's';
static Widget idle_dialog, idle_shell, command_value, timeout_value;
static Widget enable_toggle, enable_perm_toggle, disable_toggle;
static Widget hours_toggle, minutes_toggle, seconds_toggle, fuzz_toggle;
static sr_t *idle_sr = (sr_t *)NULL;
static void idle_cancel(Widget w, XtPointer client_data, XtPointer call_data);
static void idle_popup_callback(Widget w, XtPointer client_data,
XtPointer call_data);
static void idle_popup_init(void);
static int idle_start(void);
static void okay_callback(Widget w, XtPointer call_parms,
XtPointer call_data);
static void toggle_enable(Widget w, XtPointer client_data,
XtPointer call_data);
static void mark_toggle(Widget w, Pixmap p);
static void toggle_hms(Widget w, XtPointer client_data,
XtPointer call_data);
static void toggle_fuzz(Widget w, XtPointer client_data,
XtPointer call_data);
#endif /*]*/
/* Initialization. */
void
idle_init(void)
{
char *cmd, *tmo;
/* Register for state changes. */
register_schange(ST_3270_MODE, idle_in3270);
register_schange(ST_CONNECT, idle_in3270);
/* Get values from resources. */
cmd = appres.idle_command;
idle_command = cmd? NewString(cmd): CN;
tmo = appres.idle_timeout;
idle_timeout_string = tmo? NewString(tmo): CN;
if (appres.idle_command_enabled)
idle_user_enabled = IDLE_PERM;
else
idle_user_enabled = IDLE_DISABLED;
if (idle_user_enabled &&
idle_command != CN &&
process_timeout_value(idle_timeout_string) == 0)
idle_enabled = True;
/* Seed the random number generator (we seem to be the only user). */
#if defined(_WIN32) /*[*/
srand(time(NULL));
#else /*][*/
srandom(time(NULL));
#endif /*]*/
}
/*
* Process a timeout value: <empty> or ~?[0-9]+[HhMmSs]
* Returns 0 for success, -1 for failure.
* Sets idle_ms and idle_randomize as side-effects.
*/
static int
process_timeout_value(char *t)
{
char *s = t;
char *ptr;
if (s == CN || *s == '\0') {
idle_ms = IDLE_MS;
idle_randomize = True;
return 0;
}
if (*s == '~') {
idle_randomize = True;
s++;
}
idle_n = strtoul(s, &ptr, 0);
if (idle_n <= 0)
goto bad_idle;
switch (*ptr) {
case 'H':
case 'h':
idle_multiplier = IDLE_HR;
break;
case 'M':
case 'm':
idle_multiplier = IDLE_MIN;
break;
case 'S':
case 's':
case '\0':
idle_multiplier = IDLE_SEC;
break;
default:
goto bad_idle;
}
idle_ms = idle_n * idle_multiplier * MSEC_PER_SEC;
return 0;
bad_idle:
popup_an_error("Invalid idle timeout value '%s'", t);
idle_ms = 0L;
idle_randomize = False;
return -1;
}
/* Called when a host connects or disconnects. */
static void
idle_in3270(Boolean in3270 _is_unused)
{
if (IN_3270) {
reset_idle_timer();
} else {
/* Not in 3270 mode any more, turn off the timeout. */
if (idle_ticking) {
RemoveTimeOut(idle_id);
idle_ticking = False;
}
/* If the user didn't want it to be permanent, disable it. */
if (idle_user_enabled != IDLE_PERM)
idle_user_enabled = IDLE_DISABLED;
}
}
/*
* Idle timeout.
*/
static void
idle_timeout(void)
{
trace_event("Idle timeout\n");
idle_ticking = False;
push_idle(idle_command);
reset_idle_timer();
}
/*
* Reset (and re-enable) the idle timer. Called when the user presses a key or
* clicks with the mouse.
*/
void
reset_idle_timer(void)
{
if (idle_enabled) {
unsigned long idle_ms_now;
if (idle_ticking) {
RemoveTimeOut(idle_id);
idle_ticking = False;
}
idle_ms_now = idle_ms;
if (idle_randomize) {
idle_ms_now = idle_ms;
#if defined(_WIN32) /*[*/
idle_ms_now -= rand() % (idle_ms / 10L);
#else /*][*/
idle_ms_now -= random() % (idle_ms / 10L);
#endif /*]*/
}
#if defined(DEBUG_IDLE_TIMEOUT) /*[*/
trace_event("Setting idle timeout to %lu\n", idle_ms_now);
#endif /*]*/
idle_id = AddTimeOut(idle_ms_now, idle_timeout);
idle_ticking = True;
}
}
/*
* Cancel the idle timer. This is called when there is an error in
* processing the idle command.
*/
void
cancel_idle_timer(void)
{
if (idle_ticking) {
RemoveTimeOut(idle_id);
idle_ticking = False;
}
idle_enabled = False;
}
char *
get_idle_command(void)
{
return idle_command;
}
char *
get_idle_timeout(void)
{
return idle_timeout_string;
}
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
/* "Idle Command" dialog. */
/*
* Pop up the "Idle" menu.
* Called back from the "Configure Idle Command" option on the Options menu.
*/
void
popup_idle(void)
{
char *its;
char *s;
/* Initialize it. */
if (idle_shell == (Widget)NULL)
idle_popup_init();
/*
* Split the idle_timeout_string (the raw resource value) into fuzz,
* a number, and h/m/s.
*/
its = NewString(idle_timeout_string);
if (its != CN) {
if (*its == '~') {
fuzz = True;
its++;
} else {
fuzz = False;
}
s = its;
while (isdigit(*s))
s++;
switch (*s) {
case 'h':
case 'H':
hms = 'h';
break;
case 'm':
case 'M':
hms = 'm';
break;
case 's':
case 'S':
hms = 's';
break;
default:
break;
}
*s = '\0';
}
/* Set the resource values. */
dialog_set(&idle_sr, idle_dialog);
XtVaSetValues(command_value,
XtNstring, idle_command,
NULL);
XtVaSetValues(timeout_value, XtNstring, its, NULL);
mark_toggle(enable_toggle, (idle_user_enabled == IDLE_SESSION)?
diamond : no_diamond);
mark_toggle(enable_perm_toggle, (idle_user_enabled == IDLE_PERM)?
diamond : no_diamond);
mark_toggle(disable_toggle, (idle_user_enabled == IDLE_DISABLED)?
diamond : no_diamond);
mark_toggle(hours_toggle, (hms == 'h') ? diamond : no_diamond);
mark_toggle(minutes_toggle, (hms == 'm') ? diamond : no_diamond);
mark_toggle(seconds_toggle, (hms == 's') ? diamond : no_diamond);
mark_toggle(fuzz_toggle, fuzz ? dot : no_dot);
/* Pop it up. */
popup_popup(idle_shell, XtGrabNone);
}
/* Initialize the idle pop-up. */
static void
idle_popup_init(void)
{
Widget w;
Widget cancel_button;
Widget command_label, timeout_label;
Widget okay_button;
/* Prime the dialog functions. */
dialog_set(&idle_sr, idle_dialog);
/* Create the menu shell. */
idle_shell = XtVaCreatePopupShell(
"idlePopup", transientShellWidgetClass, toplevel,
NULL);
XtAddCallback(idle_shell, XtNpopupCallback, place_popup,
(XtPointer)CenterP);
XtAddCallback(idle_shell, XtNpopupCallback, idle_popup_callback,
(XtPointer)NULL);
/* Create the form within the shell. */
idle_dialog = XtVaCreateManagedWidget(
ObjDialog, formWidgetClass, idle_shell,
NULL);
/* Create the file name widgets. */
command_label = XtVaCreateManagedWidget(
"command", labelWidgetClass, idle_dialog,
XtNvertDistance, FAR_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
NULL);
command_value = XtVaCreateManagedWidget(
"value", asciiTextWidgetClass, idle_dialog,
XtNeditType, XawtextEdit,
XtNwidth, FILE_WIDTH,
XtNvertDistance, FAR_VGAP,
XtNfromHoriz, command_label,
XtNhorizDistance, 0,
NULL);
dialog_match_dimension(command_label, command_value, XtNheight);
w = XawTextGetSource(command_value);
if (w == NULL)
XtWarning("Cannot find text source in dialog");
else
XtAddCallback(w, XtNcallback, dialog_text_callback,
(XtPointer)&t_command);
dialog_register_sensitivity(command_value,
BN, False,
BN, False,
BN, False);
timeout_label = XtVaCreateManagedWidget(
"timeout", labelWidgetClass, idle_dialog,
XtNfromVert, command_label,
XtNvertDistance, 3,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
NULL);
timeout_value = XtVaCreateManagedWidget(
"value", asciiTextWidgetClass, idle_dialog,
XtNeditType, XawtextEdit,
XtNwidth, FILE_WIDTH,
XtNdisplayCaret, False,
XtNfromVert, command_label,
XtNvertDistance, 3,
XtNfromHoriz, timeout_label,
XtNhorizDistance, 0,
NULL);
dialog_match_dimension(timeout_label, timeout_value, XtNheight);
dialog_match_dimension(command_label, timeout_label, XtNwidth);
w = XawTextGetSource(timeout_value);
if (w == NULL)
XtWarning("Cannot find text source in dialog");
else
XtAddCallback(w, XtNcallback, dialog_text_callback,
(XtPointer)&t_numeric);
dialog_register_sensitivity(timeout_value,
BN, False,
BN, False,
BN, False);
/* Create the hour/minute/seconds radio buttons. */
hours_toggle = XtVaCreateManagedWidget(
"hours", commandWidgetClass, idle_dialog,
XtNfromVert, timeout_value,
XtNvertDistance, CLOSE_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
XtNsensitive, True,
NULL);
dialog_apply_bitmap(hours_toggle, no_diamond);
XtAddCallback(hours_toggle, XtNcallback, toggle_hms,
(XtPointer)&s_hours);
minutes_toggle = XtVaCreateManagedWidget(
"minutes", commandWidgetClass, idle_dialog,
XtNfromVert, timeout_value,
XtNvertDistance, CLOSE_VGAP,
XtNfromHoriz, hours_toggle,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
XtNsensitive, True,
NULL);
dialog_apply_bitmap(minutes_toggle, diamond);
XtAddCallback(minutes_toggle, XtNcallback, toggle_hms,
(XtPointer)&s_minutes);
seconds_toggle = XtVaCreateManagedWidget(
"seconds", commandWidgetClass, idle_dialog,
XtNfromVert, timeout_value,
XtNvertDistance, CLOSE_VGAP,
XtNfromHoriz, minutes_toggle,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
XtNsensitive, True,
NULL);
dialog_apply_bitmap(seconds_toggle, no_diamond);
XtAddCallback(seconds_toggle, XtNcallback, toggle_hms,
(XtPointer)&s_seconds);
/* Create the fuzz toggle. */
fuzz_toggle = XtVaCreateManagedWidget(
"fuzz", commandWidgetClass, idle_dialog,
XtNfromVert, hours_toggle,
XtNvertDistance, CLOSE_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
XtNsensitive, True,
NULL);
dialog_apply_bitmap(fuzz_toggle, no_dot);
XtAddCallback(fuzz_toggle, XtNcallback, toggle_fuzz, (XtPointer)NULL);
/* Create enable/disable toggles. */
enable_toggle = XtVaCreateManagedWidget(
"enable", commandWidgetClass, idle_dialog,
XtNfromVert, fuzz_toggle,
XtNvertDistance, FAR_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
NULL);
dialog_apply_bitmap(enable_toggle,
(idle_user_enabled == IDLE_SESSION)?
diamond : no_diamond);
XtAddCallback(enable_toggle, XtNcallback, toggle_enable,
(XtPointer)&s_session);
enable_perm_toggle = XtVaCreateManagedWidget(
"enablePerm", commandWidgetClass, idle_dialog,
XtNfromVert, enable_toggle,
XtNvertDistance, CLOSE_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
NULL);
dialog_apply_bitmap(enable_perm_toggle,
(idle_user_enabled == IDLE_PERM)?
diamond : no_diamond);
XtAddCallback(enable_perm_toggle, XtNcallback, toggle_enable,
(XtPointer)&s_perm);
disable_toggle = XtVaCreateManagedWidget(
"disable", commandWidgetClass, idle_dialog,
XtNfromVert, enable_perm_toggle,
XtNvertDistance, CLOSE_VGAP,
XtNhorizDistance, MARGIN,
XtNborderWidth, 0,
NULL);
dialog_apply_bitmap(disable_toggle,
(idle_user_enabled == IDLE_DISABLED)?
diamond : no_diamond);
XtAddCallback(disable_toggle, XtNcallback, toggle_enable,
(XtPointer)&s_disabled);
/* Set up the buttons at the bottom. */
okay_button = XtVaCreateManagedWidget(
ObjConfirmButton, commandWidgetClass, idle_dialog,
XtNfromVert, disable_toggle,
XtNvertDistance, FAR_VGAP,
XtNhorizDistance, MARGIN,
NULL);
XtAddCallback(okay_button, XtNcallback, okay_callback,
(XtPointer)NULL);
cancel_button = XtVaCreateManagedWidget(
ObjCancelButton, commandWidgetClass, idle_dialog,
XtNfromVert, disable_toggle,
XtNvertDistance, FAR_VGAP,
XtNfromHoriz, okay_button,
XtNhorizDistance, BUTTON_GAP,
NULL);
XtAddCallback(cancel_button, XtNcallback, idle_cancel, 0);
}
/* Callbacks for all the idle widgets. */
/* Idle pop-up popping up. */
static void
idle_popup_callback(Widget w _is_unused, XtPointer client_data _is_unused,
XtPointer call_data _is_unused)
{
/* Set the focus to the command widget. */
PA_dialog_focus_action(command_value, (XEvent *)NULL, (String *)NULL,
(Cardinal *)NULL);
}
/* Cancel button pushed. */
static void
idle_cancel(Widget w _is_unused, XtPointer client_data _is_unused,
XtPointer call_data _is_unused)
{
XtPopdown(idle_shell);
}
/* OK button pushed. */
static void
okay_callback(Widget w _is_unused, XtPointer call_parms _is_unused,
XtPointer call_data _is_unused)
{
if (idle_start() == 0) {
idle_changed = True;
XtPopdown(idle_shell);
}
}
/* Mark a toggle. */
static void
mark_toggle(Widget w, Pixmap p)
{
XtVaSetValues(w, XtNleftBitmap, p, NULL);
}
/* Hour/minute/second options. */
static void
toggle_hms(Widget w _is_unused, XtPointer client_data,
XtPointer call_data _is_unused)
{
/* Toggle the flag */
hms = *(char *)client_data;
/* Change the widget states. */
mark_toggle(hours_toggle, (hms == 'h') ? diamond : no_diamond);
mark_toggle(minutes_toggle, (hms == 'm') ? diamond : no_diamond);
mark_toggle(seconds_toggle, (hms == 's') ? diamond : no_diamond);
}
/* Fuzz option. */
static void
toggle_fuzz(Widget w _is_unused, XtPointer client_data,
XtPointer call_data _is_unused)
{
/* Toggle the flag */
fuzz = !fuzz;
/* Change the widget state. */
mark_toggle(fuzz_toggle, fuzz ? dot : no_dot);
}
/* Enable/disable options. */
static void
toggle_enable(Widget w _is_unused, XtPointer client_data,
XtPointer call_data _is_unused)
{
/* Toggle the flag */
idle_user_enabled = *(enum idle_enum *)client_data;
/* Change the widget states. */
mark_toggle(enable_toggle,
(idle_user_enabled == IDLE_SESSION)?
diamond: no_diamond);
mark_toggle(enable_perm_toggle,
(idle_user_enabled == IDLE_PERM)?
diamond: no_diamond);
mark_toggle(disable_toggle,
(idle_user_enabled == IDLE_DISABLED)?
diamond: no_diamond);
}
/*
* Called when the user presses the OK button on the idle command dialog.
* Returns 0 for success, -1 otherwise.
*/
static int
idle_start(void)
{
char *cmd, *tmo, *its;
/* Update the globals, so the dialog has the same values next time. */
XtVaGetValues(command_value, XtNstring, &cmd, NULL);
Replace(idle_command, NewString(cmd));
XtVaGetValues(timeout_value, XtNstring, &tmo, NULL);
its = Malloc(strlen(tmo) + 3);
(void) sprintf(its, "%s%s%c", fuzz? "~": "", tmo, hms);
Replace(idle_timeout_string, its);
/* See if they've turned it off. */
if (!idle_user_enabled) {
/* If they're turned it off, cancel the timer. */
idle_enabled = False;
if (idle_ticking) {
RemoveTimeOut(idle_id);
idle_ticking = False;
}
return 0;
}
/* They've turned it on, and possibly reconfigured it. */
/* Validate the timeout. It should work, yes? */
if (process_timeout_value(its) < 0) {
return -1;
}
/* Seems okay. Reset to the new interval and command. */
idle_enabled = True;
if (IN_3270) {
reset_idle_timer();
}
return 0;
}
#endif /*]*/
#endif /*]*/
|