1 /*
2  * Copyright (c) 1993-2015 Paul Mattes.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the names of Paul Mattes nor the names of his contributors
13  *       may be used to endorse or promote products derived from this software
14  *       without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY PAUL MATTES "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL PAUL MATTES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  *	host_gui.c
30  *		GUI-specific functions called from the host connect/disconnect
31  *		logic.
32  */
33 
34 #include "globals.h"
35 #include "appres.h"
36 
37 #include "host_gui.h"
38 #include "xio.h"
39 #include "xpopups.h"
40 
41 bool
host_gui_connect(void)42 host_gui_connect(void)
43 {
44     if (appres.once) {
45 	/* Exit when the error pop-up pops down. */
46 	exiting = true;
47 	return true;
48     } else {
49 	return false;
50     }
51 }
52 
53 void
host_gui_connect_initial(void)54 host_gui_connect_initial(void)
55 {
56     if (appres.interactive.reconnect && error_popup_visible()) {
57 	popdown_an_error();
58     }
59 }
60 
61 bool
host_gui_disconnect(void)62 host_gui_disconnect(void)
63 {
64     if (appres.once) {
65 	if (error_popup_visible()) {
66 	    /* If there is an error pop-up, exit when it pops down. */
67 	    exiting = true;
68 	} else {
69 	    /* Exit now. */
70 	    x3270_exit(0);
71 	    return true;
72 	}
73 	return true;
74     } else {
75 	return false;
76     }
77 }
78 
79 void
host_gui_connected(void)80 host_gui_connected(void)
81 {
82     if (appres.interactive.reconnect && error_popup_visible()) {
83 	popdown_an_error();
84     }
85 }
86