Commit ac7c7d403370f7068fb998c001bcc6240994f10f
1 parent
65ab9b11
Exists in
master
and in
2 other branches
Fixing popup on connection error.
Showing
2 changed files
with
22 additions
and
9 deletions
Show diff stats
src/core/linux/connect.c
@@ -177,8 +177,8 @@ int lib3270_network_connect(H3270 *hSession, LIB3270_NETWORK_STATE *state) { | @@ -177,8 +177,8 @@ int lib3270_network_connect(H3270 *hSession, LIB3270_NETWORK_STATE *state) { | ||
177 | } | 177 | } |
178 | 178 | ||
179 | static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED(flag), void GNUC_UNUSED(*dunno)) { | 179 | static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED(flag), void GNUC_UNUSED(*dunno)) { |
180 | - int err; | ||
181 | - socklen_t len = sizeof(err); | 180 | + int err = 0; |
181 | + socklen_t len = sizeof(err); | ||
182 | 182 | ||
183 | if(hSession->xio.write) { | 183 | if(hSession->xio.write) { |
184 | trace("%s write=%p",__FUNCTION__,hSession->xio.write); | 184 | trace("%s write=%p",__FUNCTION__,hSession->xio.write); |
@@ -205,23 +205,35 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | @@ -205,23 +205,35 @@ static void net_connected(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG | ||
205 | lib3270_popup(hSession,&popup,0); | 205 | lib3270_popup(hSession,&popup,0); |
206 | 206 | ||
207 | return; | 207 | return; |
208 | + | ||
208 | } else if(err) { | 209 | } else if(err) { |
209 | - lib3270_autoptr(LIB3270_POPUP) popup = | ||
210 | - lib3270_popup_clone_printf( | ||
211 | - NULL, | 210 | + |
211 | + lib3270_disconnect(hSession); | ||
212 | + | ||
213 | + lib3270_autoptr(char) summary = | ||
214 | + lib3270_strdup_printf( | ||
212 | _( "Can't connect to %s:%s"), | 215 | _( "Can't connect to %s:%s"), |
213 | hSession->host.current, | 216 | hSession->host.current, |
214 | hSession->host.srvc | 217 | hSession->host.srvc |
215 | ); | 218 | ); |
216 | 219 | ||
217 | - lib3270_autoptr(char) syserror = | 220 | + lib3270_autoptr(char) body = |
218 | lib3270_strdup_printf( | 221 | lib3270_strdup_printf( |
219 | _("The system error was \"%s\" (rc=%d)"), | 222 | _("The system error was \"%s\" (rc=%d)"), |
220 | strerror(err), | 223 | strerror(err), |
221 | err | 224 | err |
222 | ); | 225 | ); |
223 | 226 | ||
224 | - if(hSession->cbk.popup(hSession,popup,!hSession->auto_reconnect_inprogress) == 0) | 227 | + |
228 | + LIB3270_POPUP popup = { | ||
229 | + .type = LIB3270_NOTIFY_ERROR, | ||
230 | + .title = _( "Connection error" ), | ||
231 | + .summary = summary, | ||
232 | + .body = body, | ||
233 | + .label = _("_Retry") | ||
234 | + }; | ||
235 | + | ||
236 | + if(lib3270_popup(hSession,&popup,!hSession->auto_reconnect_inprogress) == 0) | ||
225 | lib3270_activate_auto_reconnect(hSession,1000); | 237 | lib3270_activate_auto_reconnect(hSession,1000); |
226 | 238 | ||
227 | return; | 239 | return; |
src/testprogram/testprogram.c
@@ -110,8 +110,9 @@ int main(int argc, char *argv[]) { | @@ -110,8 +110,9 @@ int main(int argc, char *argv[]) { | ||
110 | lib3270_crl_set_preferred_protocol(h,"ldap"); | 110 | lib3270_crl_set_preferred_protocol(h,"ldap"); |
111 | #endif // HAVE_LDAP | 111 | #endif // HAVE_LDAP |
112 | 112 | ||
113 | - if(lib3270_set_url(h,NULL)) | ||
114 | - lib3270_set_url(h,"tn3270://127.0.0.1"); | 113 | + //if(lib3270_set_url(h,NULL)) |
114 | + // lib3270_set_url(h,"tn3270://127.0.0.1"); | ||
115 | + lib3270_set_url(h,"tn3270://localhost:3270"); | ||
115 | 116 | ||
116 | int long_index =0; | 117 | int long_index =0; |
117 | int opt; | 118 | int opt; |