Commit d892fdbb2748c29e73a5da6feb9d59320e83a817
Committed by
GitHub
Exists in
master
and in
2 other branches
Merge pull request #22 from PerryWerneck/connect-error
Fix connect error loop.
Showing
5 changed files
with
43 additions
and
32 deletions
Show diff stats
lib3270.cbp
| ... | ... | @@ -294,8 +294,6 @@ |
| 294 | 294 | <Unit filename="src/include/macos/lib3270/os.h" /> |
| 295 | 295 | <Unit filename="src/include/networking.h" /> |
| 296 | 296 | <Unit filename="src/include/popupsc.h" /> |
| 297 | - <Unit filename="src/include/proxyc.h" /> | |
| 298 | - <Unit filename="src/include/resolverc.h" /> | |
| 299 | 297 | <Unit filename="src/include/resources.h" /> |
| 300 | 298 | <Unit filename="src/include/screen.h" /> |
| 301 | 299 | <Unit filename="src/include/screenc.h" /> | ... | ... |
src/core/linux/connect.c
| ... | ... | @@ -177,8 +177,8 @@ int lib3270_network_connect(H3270 *hSession, LIB3270_NETWORK_STATE *state) { |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 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 | 183 | if(hSession->xio.write) { |
| 184 | 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 | 205 | lib3270_popup(hSession,&popup,0); |
| 206 | 206 | |
| 207 | 207 | return; |
| 208 | + | |
| 208 | 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 | 215 | _( "Can't connect to %s:%s"), |
| 213 | 216 | hSession->host.current, |
| 214 | 217 | hSession->host.srvc |
| 215 | 218 | ); |
| 216 | 219 | |
| 217 | - lib3270_autoptr(char) syserror = | |
| 220 | + lib3270_autoptr(char) body = | |
| 218 | 221 | lib3270_strdup_printf( |
| 219 | 222 | _("The system error was \"%s\" (rc=%d)"), |
| 220 | 223 | strerror(err), |
| 221 | 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 | 237 | lib3270_activate_auto_reconnect(hSession,1000); |
| 226 | 238 | |
| 227 | 239 | return; | ... | ... |
src/core/options.c
| ... | ... | @@ -37,35 +37,35 @@ |
| 37 | 37 | |
| 38 | 38 | static const LIB3270_HOST_TYPE_ENTRY host_type[] = { |
| 39 | 39 | { |
| 40 | - LIB3270_HOST_S390, | |
| 41 | - "S390", | |
| 42 | - N_( "IBM S/390" ), | |
| 43 | - NULL | |
| 40 | + .type = LIB3270_HOST_S390, | |
| 41 | + .name = "S390", | |
| 42 | + .description = N_( "IBM S/390" ), | |
| 43 | + .tooltip = NULL | |
| 44 | 44 | }, |
| 45 | 45 | { |
| 46 | - LIB3270_HOST_AS400, | |
| 47 | - "AS400", | |
| 48 | - N_( "IBM AS/400" ), | |
| 49 | - NULL | |
| 46 | + .type = LIB3270_HOST_AS400, | |
| 47 | + .name = "AS400", | |
| 48 | + .description = N_( "IBM AS/400" ), | |
| 49 | + .tooltip = NULL | |
| 50 | 50 | }, |
| 51 | 51 | { |
| 52 | - LIB3270_HOST_TSO, | |
| 53 | - "TSO", | |
| 54 | - N_( "Other (TSO)" ), | |
| 55 | - NULL | |
| 52 | + .type = LIB3270_HOST_TSO, | |
| 53 | + .name = "TSO", | |
| 54 | + .description = N_( "Other (TSO)" ), | |
| 55 | + .tooltip = NULL | |
| 56 | 56 | }, |
| 57 | 57 | { |
| 58 | - 0, | |
| 59 | - "VM/CMS", | |
| 60 | - N_( "Other (VM/CMS)" ), | |
| 61 | - NULL | |
| 58 | + .type = LIB3270_HOST_OTHER, | |
| 59 | + .name = "VM/CMS", | |
| 60 | + .description = N_( "Other (VM/CMS)" ), | |
| 61 | + .tooltip = NULL | |
| 62 | 62 | }, |
| 63 | 63 | |
| 64 | 64 | { |
| 65 | - 0, | |
| 66 | - NULL, | |
| 67 | - NULL, | |
| 68 | - NULL | |
| 65 | + .type = LIB3270_HOST_OTHER, | |
| 66 | + .name = NULL, | |
| 67 | + .description = NULL, | |
| 68 | + .tooltip = NULL | |
| 69 | 69 | } |
| 70 | 70 | }; |
| 71 | 71 | ... | ... |
src/include/lib3270.h
| ... | ... | @@ -279,10 +279,10 @@ typedef enum lib3270_field_attribute { |
| 279 | 279 | * |
| 280 | 280 | */ |
| 281 | 281 | typedef enum lib3270_host_type { |
| 282 | + LIB3270_HOST_OTHER = 0x0000, ///< @brief Other. | |
| 282 | 283 | LIB3270_HOST_AS400 = 0x0001, ///< @brief AS400 host - Prefix every PF with PA1 |
| 283 | 284 | LIB3270_HOST_TSO = 0x0002, ///< @brief Host is TSO |
| 284 | 285 | LIB3270_HOST_S390 = 0x0006, ///< @brief Host is S390 (TSO included) |
| 285 | - | |
| 286 | 286 | } LIB3270_HOST_TYPE; |
| 287 | 287 | |
| 288 | 288 | #define LIB3270_HOSTTYPE_DEFAULT LIB3270_HOST_S390 | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -110,8 +110,9 @@ int main(int argc, char *argv[]) { |
| 110 | 110 | lib3270_crl_set_preferred_protocol(h,"ldap"); |
| 111 | 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 | 117 | int long_index =0; |
| 117 | 118 | int opt; | ... | ... |