Commit e8cf13fc8285d59db34842393ae4ae38df3e852e

Authored by Perry Werneck
1 parent 80670b46

Incluindo teste de conexão ativa nas chamadas hllapi.

Makefile.in
... ... @@ -265,8 +265,15 @@ install-branding:
265 265 Debug: \
266 266 $(BINDBG)/lib3270@DLLEXT@ \
267 267 $(BINDBG)/$(PACKAGE_TARNAME)@EXEEXT@ \
  268 + $(BINDBG)/libpw3270cpp.a \
268 269 $(foreach PLG, $(PLUGINS), $(BINDBG)/plugins/$(PLG)@DLLEXT@)
269 270  
  271 +$(BINDBG)/libpw3270cpp.a: \
  272 + src/libpw3270cpp/*
  273 +
  274 + @$(MAKE) -C src/libpw3270cpp Debug
  275 +
  276 +
270 277 run: \
271 278 $(BINDBG)/lib3270@DLLEXT@ \
272 279 $(BINDBG)/$(PACKAGE_TARNAME)@EXEEXT@ \
... ...
locale/pt_BR.po
... ... @@ -5,7 +5,7 @@ msgid ""
5 5 msgstr ""
6 6 "Project-Id-Version: pw3270 5.0\n"
7 7 "Report-Msgid-Bugs-To: \n"
8   -"POT-Creation-Date: 2017-08-21 09:51-0300\n"
  8 +"POT-Creation-Date: 2017-08-21 10:15-0300\n"
9 9 "PO-Revision-Date: 2017-02-15 17:08-0200\n"
10 10 "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n"
11 11 "Language-Team: Português <perry.werneck@gmail.com>\n"
... ... @@ -119,7 +119,7 @@ msgstr &quot;Alerta 3270&quot;
119 119 msgid "3270 screen"
120 120 msgstr "Tela 3270"
121 121  
122   -#: dialog.c:531
  122 +#: dialog.c:550
123 123 #, c-format
124 124 msgid "3270 terminal emulator for GTK %d.%d"
125 125 msgstr "Emulador 3270 para GTK+ %d.%d"
... ... @@ -363,7 +363,7 @@ msgstr &quot;Azul&quot;
363 363 msgid "Bold"
364 364 msgstr "Negrito"
365 365  
366   -#: dialog.c:538
  366 +#: dialog.c:557
367 367 msgid "Brazilian Public Software Portal"
368 368 msgstr "Portal do Software Público Brasileiro"
369 369  
... ... @@ -419,11 +419,6 @@ msgstr &quot;Não foi possível conectar a %s&quot;
419 419 msgid "Can't connect to %s:%s"
420 420 msgstr "Não foi possível conectar a %s:%s"
421 421  
422   -#: main.c:70
423   -#, fuzzy
424   -msgid "Can't connect to DBUS server"
425   -msgstr "Não foi possível conectar a %s"
426   -
427 422 #: selection.c:425
428 423 #, c-format
429 424 msgid "Can't convert line %d from %s to %s"
... ... @@ -438,10 +433,6 @@ msgstr &quot;Recortar não permitido em seleção retangular&quot;
438 433 msgid "Can't determine value for environment variable \"%s\" "
439 434 msgstr "Não consigo determinar o valor da variável de ambiente \"%s\" "
440 435  
441   -#: main.c:115
442   -msgid "Can't get DBUS object name"
443   -msgstr ""
444   -
445 436 #: ft.c:413
446 437 msgid "Can't get file size"
447 438 msgstr "Não foi possível obter o tamanho do arquivo"
... ... @@ -663,11 +654,6 @@ msgstr &quot;Configurar host&quot;
663 654 msgid "Connect on startup"
664 655 msgstr "Conectar ao iniciar"
665 656  
666   -#: gobject.c:205
667   -#, fuzzy
668   -msgid "Connecting to host"
669   -msgstr "Não foi possível conectar ao servidor"
670   -
671 657 #: connect.c:215 connect.c:311 connect.c:320 connect.c:382 connect.c:397
672 658 #: connect.c:413 connect.c:427 connect.c:447 connect.c:461 connect.c:477
673 659 #: connect.c:573
... ... @@ -1923,11 +1909,6 @@ msgstr &quot;Iniciar transferência de arquivo&quot;
1923 1909 msgid "Starting"
1924 1910 msgstr "Iniciando"
1925 1911  
1926   -#: gobject.c:193
1927   -#, c-format
1928   -msgid "State %04d can't accept requests"
1929   -msgstr ""
1930   -
1931 1912 #: security.c:237
1932 1913 msgid "Subject issuer mismatch"
1933 1914 msgstr "Divergência na identidade do emissor"
... ... @@ -2190,7 +2171,7 @@ msgstr &quot;Não encontrei configuração para a tabela de caracteres \&quot;%s\&quot;&quot;
2190 2171 msgid "This is a host program error."
2191 2172 msgstr "Este é um erro no programa do host."
2192 2173  
2193   -#: dialog.c:480
  2174 +#: dialog.c:499
2194 2175 msgid ""
2195 2176 "This program is free software; you can redistribute it and/or modify it "
2196 2177 "under the terms of the GNU General Public License as published by the Free "
... ... @@ -2413,11 +2394,6 @@ msgstr &quot;Valor de cor inválido ou inesperado: \&quot;%s\&quot;&quot;
2413 2394 msgid "Unexpected or unknown security status"
2414 2395 msgstr "Estado de segurança inesperado ou desconhecido."
2415 2396  
2416   -#: gobject.c:208
2417   -#, fuzzy, c-format
2418   -msgid "Unexpected state %04d"
2419   -msgstr "Alvo inesperado \"%s\""
2420   -
2421 2397 #: actions.c:391
2422 2398 #, c-format
2423 2399 msgid "Unexpected target \"%s\""
... ... @@ -2480,7 +2456,7 @@ msgstr &quot;Use the keys +/- from keypad to select editable fields&quot;
2480 2456 msgid "Variable"
2481 2457 msgstr "Variável"
2482 2458  
2483   -#: dialog.c:521 dialog.c:523
  2459 +#: dialog.c:540 dialog.c:542
2484 2460 #, c-format
2485 2461 msgid "Version %s-%s"
2486 2462 msgstr "Versão %s-%s"
... ... @@ -2762,7 +2738,7 @@ msgstr &quot;ioctlsocket(FIONBIO) failed.&quot;
2762 2738 msgid "setsockopt(SO_OOBINLINE) has failed"
2763 2739 msgstr "setsockopt(SO_OOBINLINE) has failed"
2764 2740  
2765   -#: dialog.c:541
  2741 +#: dialog.c:560
2766 2742 msgid "translator-credits"
2767 2743 msgstr "translator-credits"
2768 2744  
... ... @@ -2822,6 +2798,10 @@ msgstr &quot;translator-credits&quot;
2822 2798 #~ "32768. Valores maiores trazem maior performance, porem, nem todos os "
2823 2799 #~ "hosts podem suportá-los."
2824 2800  
  2801 +#, fuzzy
  2802 +#~ msgid "Can't connect to DBUS server"
  2803 +#~ msgstr "Não foi possível conectar a %s"
  2804 +
2825 2805 #~ msgid "Can't start download."
2826 2806 #~ msgstr "Não foi possível iniciar o download."
2827 2807  
... ... @@ -2858,6 +2838,10 @@ msgstr &quot;translator-credits&quot;
2858 2838 #~ msgid "Complete"
2859 2839 #~ msgstr "Completo"
2860 2840  
  2841 +#, fuzzy
  2842 +#~ msgid "Connecting to host"
  2843 +#~ msgstr "Não foi possível conectar ao servidor"
  2844 +
2861 2845 #~ msgid "Copiar tudo"
2862 2846 #~ msgstr "Copiar tudo"
2863 2847  
... ... @@ -3223,6 +3207,10 @@ msgstr &quot;translator-credits&quot;
3223 3207 #~ msgid "Unexpected element <%s>"
3224 3208 #~ msgstr "Elemento <%s> inesperado"
3225 3209  
  3210 +#, fuzzy
  3211 +#~ msgid "Unexpected state %04d"
  3212 +#~ msgstr "Alvo inesperado \"%s\""
  3213 +
3226 3214 #~ msgid ""
3227 3215 #~ "Unknown host:\n"
3228 3216 #~ "%s"
... ...
locale/pw3270.pot
... ... @@ -9,7 +9,7 @@ msgstr &quot;&quot;
9 9 "#-#-#-#-# lib3270.pot (PACKAGE VERSION) #-#-#-#-#\n"
10 10 "Project-Id-Version: PACKAGE VERSION\n"
11 11 "Report-Msgid-Bugs-To: \n"
12   -"POT-Creation-Date: 2017-08-21 09:51-0300\n"
  12 +"POT-Creation-Date: 2017-08-21 10:23-0300\n"
13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14 14 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15 15 "Language-Team: LANGUAGE <LL@li.org>\n"
... ... @@ -20,7 +20,7 @@ msgstr &quot;&quot;
20 20 "#-#-#-#-# pw3270.pot (PACKAGE VERSION) #-#-#-#-#\n"
21 21 "Project-Id-Version: PACKAGE VERSION\n"
22 22 "Report-Msgid-Bugs-To: \n"
23   -"POT-Creation-Date: 2017-08-21 09:51-0300\n"
  23 +"POT-Creation-Date: 2017-08-21 10:23-0300\n"
24 24 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
25 25 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
26 26 "Language-Team: LANGUAGE <LL@li.org>\n"
... ... @@ -39,17 +39,6 @@ msgstr &quot;&quot;
39 39 "MIME-Version: 1.0\n"
40 40 "Content-Type: text/plain; charset=CHARSET\n"
41 41 "Content-Transfer-Encoding: 8bit\n"
42   -"#-#-#-#-# dbus3270.pot (PACKAGE VERSION) #-#-#-#-#\n"
43   -"Project-Id-Version: PACKAGE VERSION\n"
44   -"Report-Msgid-Bugs-To: \n"
45   -"POT-Creation-Date: 2017-08-21 09:51-0300\n"
46   -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
47   -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
48   -"Language-Team: LANGUAGE <LL@li.org>\n"
49   -"Language: \n"
50   -"MIME-Version: 1.0\n"
51   -"Content-Type: text/plain; charset=CHARSET\n"
52   -"Content-Transfer-Encoding: 8bit\n"
53 42  
54 43 #: window.c:329
55 44 #, c-format
... ... @@ -151,7 +140,7 @@ msgstr &quot;&quot;
151 140 msgid "3270 screen"
152 141 msgstr ""
153 142  
154   -#: dialog.c:531
  143 +#: dialog.c:550
155 144 #, c-format
156 145 msgid "3270 terminal emulator for GTK %d.%d"
157 146 msgstr ""
... ... @@ -379,7 +368,7 @@ msgstr &quot;&quot;
379 368 msgid "Bold"
380 369 msgstr ""
381 370  
382   -#: dialog.c:538
  371 +#: dialog.c:557
383 372 msgid "Brazilian Public Software Portal"
384 373 msgstr ""
385 374  
... ... @@ -435,10 +424,6 @@ msgstr &quot;&quot;
435 424 msgid "Can't connect to %s:%s"
436 425 msgstr ""
437 426  
438   -#: main.c:70
439   -msgid "Can't connect to DBUS server"
440   -msgstr ""
441   -
442 427 #: selection.c:425
443 428 #, c-format
444 429 msgid "Can't convert line %d from %s to %s"
... ... @@ -453,10 +438,6 @@ msgstr &quot;&quot;
453 438 msgid "Can't determine value for environment variable \"%s\" "
454 439 msgstr ""
455 440  
456   -#: main.c:115
457   -msgid "Can't get DBUS object name"
458   -msgstr ""
459   -
460 441 #: ft.c:413
461 442 msgid "Can't get file size"
462 443 msgstr ""
... ... @@ -666,10 +647,6 @@ msgstr &quot;&quot;
666 647 msgid "Connect on startup"
667 648 msgstr ""
668 649  
669   -#: gobject.c:205
670   -msgid "Connecting to host"
671   -msgstr ""
672   -
673 650 #: connect.c:215 connect.c:311 connect.c:320 connect.c:382 connect.c:397
674 651 #: connect.c:413 connect.c:427 connect.c:447 connect.c:461 connect.c:477
675 652 #: connect.c:573
... ... @@ -1880,11 +1857,6 @@ msgstr &quot;&quot;
1880 1857 msgid "Starting"
1881 1858 msgstr ""
1882 1859  
1883   -#: gobject.c:193
1884   -#, c-format
1885   -msgid "State %04d can't accept requests"
1886   -msgstr ""
1887   -
1888 1860 #: security.c:237
1889 1861 msgid "Subject issuer mismatch"
1890 1862 msgstr ""
... ... @@ -2106,7 +2078,7 @@ msgstr &quot;&quot;
2106 2078 msgid "This is a host program error."
2107 2079 msgstr ""
2108 2080  
2109   -#: dialog.c:480
  2081 +#: dialog.c:499
2110 2082 msgid ""
2111 2083 "This program is free software; you can redistribute it and/or modify it "
2112 2084 "under the terms of the GNU General Public License as published by the Free "
... ... @@ -2316,11 +2288,6 @@ msgstr &quot;&quot;
2316 2288 msgid "Unexpected or unknown security status"
2317 2289 msgstr ""
2318 2290  
2319   -#: gobject.c:208
2320   -#, c-format
2321   -msgid "Unexpected state %04d"
2322   -msgstr ""
2323   -
2324 2291 #: actions.c:391
2325 2292 #, c-format
2326 2293 msgid "Unexpected target \"%s\""
... ... @@ -2383,7 +2350,7 @@ msgstr &quot;&quot;
2383 2350 msgid "Variable"
2384 2351 msgstr ""
2385 2352  
2386   -#: dialog.c:521 dialog.c:523
  2353 +#: dialog.c:540 dialog.c:542
2387 2354 #, c-format
2388 2355 msgid "Version %s-%s"
2389 2356 msgstr ""
... ... @@ -2647,6 +2614,6 @@ msgstr &quot;&quot;
2647 2614 msgid "setsockopt(SO_OOBINLINE) has failed"
2648 2615 msgstr ""
2649 2616  
2650   -#: dialog.c:541
  2617 +#: dialog.c:560
2651 2618 msgid "translator-credits"
2652 2619 msgstr ""
... ...
src/include/pw3270/hllapi.h
... ... @@ -196,7 +196,6 @@ extern &quot;C&quot; {
196 196 HLLAPI_API_CALL hllapi_get_message_id(void);
197 197 HLLAPI_API_CALL hllapi_is_connected(void);
198 198 HLLAPI_API_CALL hllapi_get_state(void);
199   - HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
200 199 HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
201 200 HLLAPI_API_CALL hllapi_enter(void);
202 201 HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
... ...
src/libpw3270cpp/Makefile.in
... ... @@ -148,9 +148,9 @@ $(SRCDIR): \
148 148 #---[ Debug Targets ]--------------------------------------------------------------------
149 149  
150 150 Debug: \
151   - .bin/Debug/$(MODULE_NAME)@EXEEXT@
  151 + $(BASEDIR)/.bin/Debug/$(MODULE_NAME).a
152 152  
153   -$(BASEDIR)/.obj/Debug/$(MODULE_NAME).a: \
  153 +$(BASEDIR)/.bin/Debug/$(MODULE_NAME).a: \
154 154 $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o)
155 155  
156 156 @echo $@ ...
... ... @@ -159,7 +159,7 @@ $(BASEDIR)/.obj/Debug/$(MODULE_NAME).a: \
159 159  
160 160 .bin/Debug/$(MODULE_NAME)@EXEEXT@: \
161 161 $(OBJDBG)/testprogram.o \
162   - $(BASEDIR)/.obj/Debug/$(MODULE_NAME).a
  162 + $(BASEDIR)/.bin/Debug/$(MODULE_NAME).a
163 163  
164 164 @$(MKDIR) `dirname $@`
165 165 @$(LD) $(APP_LDFLAGS) -o $@ $^ $(LIBS)
... ...
src/plugins/hllapi/calls.cc
... ... @@ -129,11 +129,11 @@
129 129 {
130 130 switch(hllapi_get_message_id())
131 131 {
132   - case LIB3270_MESSAGE_NONE: // 0 - No message
133   - return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input.
  132 + case LIB3270_MESSAGE_NONE: // 0 - No message
  133 + return HLLAPI_STATUS_SUCCESS; // keyboard was unlocked and ready for input.
134 134  
135   - case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host
136   - return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session.
  135 + case LIB3270_MESSAGE_DISCONNECTED: // 4 - Disconnected from host
  136 + return HLLAPI_STATUS_DISCONNECTED; // Your application program was not connected to a valid session.
137 137  
138 138 case LIB3270_MESSAGE_MINUS:
139 139 case LIB3270_MESSAGE_PROTECTED:
... ... @@ -163,23 +163,37 @@
163 163  
164 164 HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds)
165 165 {
  166 + if(!hllapi_is_connected())
  167 + return HLLAPI_STATUS_DISCONNECTED;
  168 +
166 169 session::get_default()->wait_for_ready(seconds);
  170 +
167 171 return hllapi_get_state();
168 172 }
169 173  
170 174 HLLAPI_API_CALL hllapi_wait(WORD seconds)
171 175 {
  176 + if(!hllapi_is_connected())
  177 + return HLLAPI_STATUS_DISCONNECTED;
  178 +
172 179 session::get_default()->wait(seconds);
  180 +
173 181 return hllapi_get_state();
174 182 }
175 183  
176 184 HLLAPI_API_CALL hllapi_get_message_id(void)
177 185 {
  186 + if(!hllapi_is_connected())
  187 + return HLLAPI_STATUS_DISCONNECTED;
  188 +
178 189 return session::get_default()->get_program_message();
179 190 }
180 191  
181 192 HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer)
182 193 {
  194 + if(!hllapi_is_connected())
  195 + return HLLAPI_STATUS_DISCONNECTED;
  196 +
183 197 if(!(buffer && *buffer))
184 198 return HLLAPI_STATUS_SYSTEM_ERROR;
185 199  
... ... @@ -199,11 +213,17 @@
199 213  
200 214 HLLAPI_API_CALL hllapi_enter(void)
201 215 {
  216 + if(!hllapi_is_connected())
  217 + return HLLAPI_STATUS_DISCONNECTED;
  218 +
202 219 return session::get_default()->enter();
203 220 }
204 221  
205 222 HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text)
206 223 {
  224 + if(!hllapi_is_connected())
  225 + return HLLAPI_STATUS_DISCONNECTED;
  226 +
207 227 try
208 228 {
209 229 session::get_default()->set_string_at(row,col,text);
... ... @@ -218,7 +238,12 @@
218 238  
219 239 HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text)
220 240 {
  241 +
  242 + if(!hllapi_is_connected())
  243 + return HLLAPI_STATUS_DISCONNECTED;
  244 +
221 245 int rc = HLLAPI_STATUS_SYSTEM_ERROR;
  246 +
222 247 try
223 248 {
224 249 rc = session::get_default()->cmp_string_at(row,col,text);
... ... @@ -233,6 +258,9 @@
233 258  
234 259 HLLAPI_API_CALL hllapi_find_text(LPSTR text)
235 260 {
  261 + if(!hllapi_is_connected())
  262 + return HLLAPI_STATUS_DISCONNECTED;
  263 +
236 264 return (int) session::get_default()->find_string((const char *) text, false);
237 265 }
238 266  
... ... @@ -260,11 +288,17 @@
260 288  
261 289 HLLAPI_API_CALL hllapi_pfkey(WORD key)
262 290 {
  291 + if(!hllapi_is_connected())
  292 + return HLLAPI_STATUS_DISCONNECTED;
  293 +
263 294 return session::get_default()->pfkey(key);
264 295 }
265 296  
266 297 HLLAPI_API_CALL hllapi_pakey(WORD key)
267 298 {
  299 + if(!hllapi_is_connected())
  300 + return HLLAPI_STATUS_DISCONNECTED;
  301 +
268 302 return session::get_default()->pakey(key);
269 303 }
270 304  
... ... @@ -322,6 +356,9 @@
322 356  
323 357 HLLAPI_API_CALL hllapi_get_screen(WORD offset, LPSTR buffer, WORD len)
324 358 {
  359 + if(!hllapi_is_connected())
  360 + return HLLAPI_STATUS_DISCONNECTED;
  361 +
325 362 int rc = HLLAPI_STATUS_SYSTEM_ERROR;
326 363  
327 364 if(offset < 1)
... ... @@ -369,6 +406,9 @@
369 406  
370 407 HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting)
371 408 {
  409 + if(!hllapi_is_connected())
  410 + return HLLAPI_STATUS_DISCONNECTED;
  411 +
372 412 try
373 413 {
374 414 session::get_default()->input_string(buffer);
... ... @@ -396,6 +436,9 @@
396 436  
397 437 HLLAPI_API_CALL hllapi_erase_eof(void)
398 438 {
  439 + if(!hllapi_is_connected())
  440 + return HLLAPI_STATUS_DISCONNECTED;
  441 +
399 442 try
400 443 {
401 444 session::get_default()->erase_eof();
... ... @@ -409,6 +452,9 @@
409 452  
410 453 HLLAPI_API_CALL hllapi_erase_eol(void)
411 454 {
  455 + if(!hllapi_is_connected())
  456 + return HLLAPI_STATUS_DISCONNECTED;
  457 +
412 458 try
413 459 {
414 460 session::get_default()->erase_eol();
... ... @@ -422,6 +468,9 @@
422 468  
423 469 HLLAPI_API_CALL hllapi_erase_input(void)
424 470 {
  471 + if(!hllapi_is_connected())
  472 + return HLLAPI_STATUS_DISCONNECTED;
  473 +
425 474 try
426 475 {
427 476 session::get_default()->erase_input();
... ...