Commit caaa78db896cb3c37ef09e71ebca6d9e578cee91

Authored by Perry Werneck
1 parent 95b1dada

Modificando apresentação de mensagem em caso de erro ao iniciar transferência de…

… arquivos para compatibilizar com o novo diálogo.
Showing 1 changed file with 18 additions and 33 deletions   Show diff stats
ft.c
... ... @@ -178,8 +178,21 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
178 178  
179 179 }
180 180  
  181 + static H3270FT * ft_creation_failed(H3270 *session, int rc, const char **dest, const char *message) {
181 182  
182   - LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft)
  183 + errno = rc;
  184 +
  185 + if(!dest) {
  186 + // Não tem destino para a mensagem, apresenta
  187 + lib3270_popup_dialog(session, LIB3270_NOTIFY_ERROR, _( "Request failed" ), _( "Can't start file transfer." ), "%s", message);
  188 + } else {
  189 + *dest = message;
  190 + }
  191 +
  192 + return NULL;
  193 + }
  194 +
  195 + LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **message)
183 196 {
184 197 static const unsigned short asc2ft[256] =
185 198 {
... ... @@ -229,40 +242,18 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
229 242 // trace("%s(%s)",__FUNCTION__,local);
230 243 if(!lib3270_connected(session))
231 244 {
232   - lib3270_popup_dialog( session,
233   - LIB3270_NOTIFY_ERROR,
234   - _( "Request failed" ),
235   - _( "Can't start file transfer." ),
236   - "%s",
237   - _( "Disconnected from host." ));
238   - errno = ENOTCONN;
239   - return NULL;
  245 + return ft_creation_failed(session,ENOTCONN,message,_( "Disconnected from host." ));
240 246 }
241 247  
242 248 if(ftHandle)
243 249 {
244   - lib3270_popup_dialog( session,
245   - LIB3270_NOTIFY_ERROR,
246   - _( "Request failed" ),
247   - _( "Can't start file transfer." ),
248   - "%s",
249   - _( "File transfer is already active in this session." ));
250   -
251   - errno = EBUSY;
252   - return NULL;
  250 + return ft_creation_failed(session,EBUSY,message,_( "File transfer is already active in this session." ));
253 251 }
254 252  
255 253 // Check remote file
256 254 if(!*remote)
257 255 {
258   - lib3270_popup_dialog( session,
259   - LIB3270_NOTIFY_ERROR,
260   - _( "Request failed" ),
261   - _( "Can't start file transfer." ),
262   - "%s",
263   - _( "The remote file name is invalid." ));
264   - errno = EINVAL;
265   - return NULL;
  256 + return ft_creation_failed(session,EINVAL,message,_( "The remote file name is invalid." ));
266 257 }
267 258  
268 259 // Open local file
... ... @@ -274,13 +265,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state);
274 265  
275 266 if(!ft_local_file)
276 267 {
277   - lib3270_popup_dialog( session,
278   - LIB3270_NOTIFY_ERROR,
279   - _( "Request failed" ),
280   - _( "Can't open local file." ),
281   - "%s",
282   - strerror(errno));
283   - return NULL;
  268 + return ft_creation_failed(session,errno,message,strerror(errno));
284 269 }
285 270  
286 271 // Set options
... ...