Commit 854943ad97c5b1c5e34774f612a4c647245444d2

Authored by perry.werneck@gmail.com
1 parent 054cdd23

Implementando plugin dbus, adicionando funcoes para obter e testar conteudo da t…

…ela pela posição em linha/coluna, incluindo projeto codeblocks do sample no pacote devel
Makefile.in
... ... @@ -305,6 +305,7 @@ install-sdk:
305 305  
306 306 @$(MKDIR) $(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)/sample
307 307 @$(INSTALL_DATA) src/sample/Makefile $(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)/sample
  308 + @$(INSTALL_DATA) src/sample/sample.cbp $(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)/sample
308 309 @$(INSTALL_DATA) src/sample/*.c $(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)/sample
309 310  
310 311 clean:
... ...
configure.ac
... ... @@ -349,10 +349,14 @@ AC_SUBST(GLIB_CFLAGS)
349 349  
350 350 #--[ Check DBUS ]---------------------------------------------------------------------------------------------------------------------------------------------
351 351  
352   -PKG_CHECK_MODULES( [DBUS], [dbus-glib-1], AC_DEFINE(HAVE_DBUS), AC_MSG_NOTICE([No DBUS support.]) )
  352 +PKG_CHECK_MODULES( [DBUS], [dbus-glib-1], app_cv_dbus=yes, AC_MSG_NOTICE([No DBUS support.]) )
353 353 AC_SUBST(DBUS_LIBS)
354 354 AC_SUBST(DBUS_CFLAGS)
355 355  
  356 +#if test "$app_cv_dbus" == "yes"; then
  357 +# PLUGINS="$PLUGINS dbus3270"
  358 +#fi
  359 +
356 360 #--[ SSL ]----------------------------------------------------------------------------------------------------------------------------------------------------
357 361  
358 362 PKG_CHECK_MODULES( [LIBSSL], [libssl], AC_DEFINE(HAVE_LIBSSL), AC_MSG_NOTICE([libssl not present.]) )
... ...
po/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: 2013-02-19 17:42-0300\n"
  8 +"POT-Creation-Date: 2013-02-21 10:43-0300\n"
9 9 "PO-Revision-Date: 2013-01-14 09:49-0200\n"
10 10 "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n"
11 11 "Language-Team: Português <>\n"
... ... @@ -38,7 +38,7 @@ msgstr &quot;Ação %s precisa de um valor válido&quot;
38 38 msgid "%s action needs src attribute"
39 39 msgstr "Ação %s precisa do atributo src"
40 40  
41   -#: main.c:76
  41 +#: main.c:86
42 42 #, c-format
43 43 msgid "%s requires GTK version %d.%d.%d"
44 44 msgstr "%s requer GTK versão %d.%d.%d"
... ... @@ -83,7 +83,7 @@ msgstr &quot;%s: Familia %d é inválida&quot;
83 83 msgid "%s:%d"
84 84 msgstr "%s:%d"
85 85  
86   -#: main.c:259
  86 +#: main.c:318
87 87 msgid "- 3270 Emulator for Gtk"
88 88 msgstr "- Emulador 3270 para GTK"
89 89  
... ... @@ -164,7 +164,7 @@ msgstr &quot;&quot;
164 164 msgid "<b>SSL state is undefined</b>Unexpected SSL status %ld"
165 165 msgstr "<b>Estado do SSL é indefinido</b>Estado SSL inesperado %ld"
166 166  
167   -#: main.c:279
  167 +#: main.c:338
168 168 msgid ""
169 169 "<b>Valid options:</b>\n"
170 170 "\n"
... ... @@ -217,7 +217,7 @@ msgid &quot;An error occurred trying to allocate memory. This should never happen.&quot;
217 217 msgstr ""
218 218 "Ocorreu um erro ao tentar alocar memória. Isso nunca deveria acontecer."
219 219  
220   -#: main.c:246 main.c:248
  220 +#: main.c:302 main.c:304
221 221 msgid "Application name"
222 222 msgstr "Nome da aplicação"
223 223  
... ... @@ -334,7 +334,7 @@ msgstr &quot;Não foi possível conectar ao servidor&quot;
334 334 msgid "Can't convert line %d from %s to %s"
335 335 msgstr "Não foi possível converter a linha %d de %s para %s"
336 336  
337   -#: selection.c:601
  337 +#: selection.c:631
338 338 msgid "Can't cut rectangular regions"
339 339 msgstr "Recortar não permitido em seleção retangular"
340 340  
... ... @@ -723,7 +723,7 @@ msgstr &quot;Tela cheia&quot;
723 723 msgid "Function bar"
724 724 msgstr "Barra de funções"
725 725  
726   -#: main.c:80 main.c:312
  726 +#: main.c:90 main.c:379
727 727 msgid "GTK Version mismatch"
728 728 msgstr "Divergência de versão GTK"
729 729  
... ... @@ -792,11 +792,11 @@ msgstr &quot;Servidor rejeitou o tipo de dispositivo ou requisição&quot;
792 792 msgid "Host rejected resource(s)"
793 793 msgstr "Servidor rejeitou recurso(s)"
794 794  
795   -#: main.c:254
  795 +#: main.c:310
796 796 msgid "Host system type"
797 797 msgstr "Tipo do sistema no servidor"
798 798  
799   -#: main.c:252
  799 +#: main.c:308
800 800 msgid "Host to connect"
801 801 msgstr "Servidor a conectar"
802 802  
... ... @@ -855,7 +855,7 @@ msgstr &quot;Invalid CGCSGID &#39;%s&#39;, ignoring&quot;
855 855 msgid "Invalid charset entry '%s' (#%d)"
856 856 msgstr "Invalid charset entry '%s' (#%d)"
857 857  
858   -#: selection.c:601
  858 +#: selection.c:631
859 859 msgid "Invalid cut action"
860 860 msgstr "Ação recortar inválida"
861 861  
... ... @@ -961,7 +961,7 @@ msgstr &quot;Normal/Protegido&quot;
961 961 msgid "Normal/Unprotected"
962 962 msgstr "Normal/Desprotegido"
963 963  
964   -#: selection.c:601
  964 +#: selection.c:631
965 965 msgid "Not available"
966 966 msgstr "Não disponível"
967 967  
... ... @@ -1126,7 +1126,7 @@ msgstr &quot;PF8&quot;
1126 1126 msgid "PF9"
1127 1127 msgstr "PF9"
1128 1128  
1129   -#: main.c:277
  1129 +#: main.c:336
1130 1130 msgid "Parse error"
1131 1131 msgstr "Erro de interpretação"
1132 1132  
... ... @@ -1163,7 +1163,7 @@ msgstr &quot;Colar com margem esquerda&quot;
1163 1163 msgid "Path length constraint exceeded"
1164 1164 msgstr "Path length constraint exceeded"
1165 1165  
1166   -#: main.c:249
  1166 +#: main.c:305
1167 1167 msgid "Path to application data files"
1168 1168 msgstr "Path to application data files"
1169 1169  
... ... @@ -1580,11 +1580,15 @@ msgstr &quot;Enviar arquivo&quot;
1580 1580 msgid "Send file to host"
1581 1581 msgstr "Enviar arquivo para o servidor"
1582 1582  
  1583 +#: main.c:312
  1584 +msgid "Send messages to syslog"
  1585 +msgstr "Send messages to syslog"
  1586 +
1583 1587 #: ui/00default.xml:276
1584 1588 msgid "Send/Receive"
1585 1589 msgstr "Enviar/Receber"
1586 1590  
1587   -#: main.c:251
  1591 +#: main.c:307
1588 1592 msgid "Session name"
1589 1593 msgstr "Nome da sessão"
1590 1594  
... ... @@ -1592,7 +1596,7 @@ msgstr &quot;Nome da sessão&quot;
1592 1596 msgid "Set hostname"
1593 1597 msgstr "Selecione servidor"
1594 1598  
1595   -#: main.c:253
  1599 +#: main.c:309
1596 1600 msgid "Set reported colors (8/16)"
1597 1601 msgstr "Define número de cores informadas (8/16)"
1598 1602  
... ... @@ -1871,7 +1875,7 @@ msgstr &quot;&quot;
1871 1875 "programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple "
1872 1876 "Place, Suite 330, Boston, MA, 02111-1307, USA"
1873 1877  
1874   -#: main.c:308
  1878 +#: main.c:375
1875 1879 #, c-format
1876 1880 msgid "This program requires GTK version %d.%d.%d"
1877 1881 msgstr "Este programa precisa do GTK versão %d.%d.%d"
... ... @@ -2008,7 +2012,7 @@ msgstr &quot;Atributo %s inesperado ou inválido: \&quot;%s\&quot;&quot;
2008 2012 msgid "Unexpected or invalid attribute value \"%s\""
2009 2013 msgstr "Valor de attributo inesperado ou inválido: \"%s\""
2010 2014  
2011   -#: main.c:181
  2015 +#: main.c:191
2012 2016 #, c-format
2013 2017 msgid "Unexpected or invalid color value \"%s\""
2014 2018 msgstr "Valor de cor inválido ou inesperado: \"%s\""
... ...
pw3270.cbp
... ... @@ -220,16 +220,6 @@
220 220 <Unit filename="src/lib3270/winversc.h" />
221 221 <Unit filename="src/lib3270/xioc.h" />
222 222 <Unit filename="src/lib3270/xl.h" />
223   - <Unit filename="src/plugins/dbus/daemon.c">
224   - <Option compilerVar="CC" />
225   - </Unit>
226   - <Unit filename="src/plugins/dbus/gobject.c">
227   - <Option compilerVar="CC" />
228   - </Unit>
229   - <Unit filename="src/plugins/dbus/main.c">
230   - <Option compilerVar="CC" />
231   - </Unit>
232   - <Unit filename="src/plugins/dbus/service.h" />
233 223 <Unit filename="src/plugins/dbus3270/Makefile.in" />
234 224 <Unit filename="src/plugins/dbus3270/daemon.c">
235 225 <Option compilerVar="CC" />
... ...
src/include/lib3270.h
... ... @@ -806,6 +806,33 @@
806 806 LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len);
807 807  
808 808 /**
  809 + * Get text at requested position
  810 + *
  811 + * @param h Session Handle.
  812 + * @param row Desired row.
  813 + * @param col Desired col.
  814 + * @param length Text length
  815 + *
  816 + * @return Contents at position if available, or NULL. Release it with lib3270_free()
  817 + *
  818 + */
  819 + LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len);
  820 +
  821 + /**
  822 + * Check for text at requested position
  823 + *
  824 + * @param h Session Handle.
  825 + * @param row Desired row.
  826 + * @param col Desired col.
  827 + * @param text Text to check.
  828 + *
  829 + * @return Test result from strcmp
  830 + *
  831 + */
  832 + LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text);
  833 +
  834 +
  835 + /**
809 836 * Get contents of the field at position.
810 837 *
811 838 * @param h Session Handle.
... ...
src/lib3270/selection.c
... ... @@ -465,6 +465,8 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
465 465 return NULL;
466 466  
467 467 maxlen = (h->rows * (h->cols+1)) - offset;
  468 + if(maxlen <= 0)
  469 + return NULL;
468 470  
469 471 if(len < 0 || len > maxlen)
470 472 len = maxlen;
... ... @@ -500,6 +502,34 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len)
500 502 return buffer;
501 503 }
502 504  
  505 +LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len)
  506 +{
  507 + CHECK_SESSION_HANDLE(h);
  508 +
  509 + if(!lib3270_connected(h))
  510 + return NULL;
  511 +
  512 + return lib3270_get_text(h, ((row) * h->cols) + col, len);
  513 +}
  514 +
  515 +LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text)
  516 +{
  517 + int rc;
  518 + size_t sz = strlen(text);
  519 + char * contents;
  520 +
  521 + contents = lib3270_get_text_at(h,row,col,sz);
  522 + if(!contents)
  523 + return -1;
  524 +
  525 + rc = strncmp(contents,text,sz);
  526 +
  527 + lib3270_free(contents);
  528 +
  529 + return rc;
  530 +}
  531 +
  532 +
503 533 /**
504 534 * Get field contents
505 535 *
... ...
src/plugins/dbus3270/Makefile.in
... ... @@ -110,7 +110,7 @@ Release: $(BINRLS)/plugins/$(MODULE_NAME).so
110 110 $(BINRLS)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJRLS)/$(SRC).o)
111 111 @echo " CCLD `basename $@`"
112 112 @$(MKDIR) `dirname $@`
113   - @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(PW3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
  113 + @$(LD) $(DLL_FLAGS) -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(PW3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS) $(DBUS_LIBS)
114 114  
115 115 #---[ Debug targets ]----------------------------------------------------------
116 116  
... ... @@ -119,7 +119,7 @@ Debug: $(BINDBG)/plugins/$(MODULE_NAME).so
119 119 $(BINDBG)/plugins/$(MODULE_NAME).so: $(foreach SRC, $(basename $(PLUGIN_SRC)), $(OBJDBG)/$(SRC).o)
120 120 @echo " CCLD `basename $@`"
121 121 @$(MKDIR) `dirname $@`
122   - @$(LD) $(DLL_FLAGS) @DBGRPATH@ -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(PW3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
  122 + @$(LD) $(DLL_FLAGS) @DBGRPATH@ -Wl,-soname,`basename $@` $(LDFLAGS) -o $@ $^ $(LIBS) $(LIB3270_LIBS) $(PW3270_LIBS) $(GLIB_LIBS) $(GTK_LIBS) $(DBUS_LIBS)
123 123  
124 124 #---[ Misc targets ]-----------------------------------------------------------
125 125  
... ...
src/plugins/dbus3270/daemon.c
... ... @@ -41,6 +41,10 @@
41 41 #include "daemon.h"
42 42 #include "dbus-glue.h"
43 43  
  44 +#define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270"
  45 +#define PW3270_DBUS_SERVICE "br.com.bb.pw3270"
  46 +
  47 +
44 48 /*---[ Globals ]---------------------------------------------------------------------------------*/
45 49  
46 50 static DBusGConnection * connection = NULL;
... ...
src/plugins/dbus3270/main.c
... ... @@ -47,12 +47,14 @@
47 47 static DBusGConnection * connection = NULL;
48 48 static DBusGProxy * proxy = NULL;
49 49  
  50 +
50 51 /*---[ Implement ]-------------------------------------------------------------------------------*/
51 52  
52 53 LIB3270_EXPORT int pw3270_plugin_init(GtkWidget *window)
53 54 {
54 55  
55   - GError * error = NULL;
  56 + GError * error = NULL;
  57 + gchar * service_path = NULL;
56 58 guint result;
57 59  
58 60 connection = dbus_g_bus_get_private(DBUS_BUS_SESSION, g_main_context_default(), &error);
... ... @@ -77,10 +79,22 @@
77 79 return -1;
78 80 }
79 81  
80   -
81 82 proxy = dbus_g_proxy_new_for_name(connection,DBUS_SERVICE_DBUS,DBUS_PATH_DBUS,DBUS_INTERFACE_DBUS);
82 83  
83   - org_freedesktop_DBus_request_name(proxy, PW3270_DBUS_SERVICE, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
  84 + {
  85 + gchar * service_name = g_strdup_printf("br.com.bb.%s",pw3270_get_session_name(window));
  86 +
  87 + service_path = g_strdup_printf("/br/com/bb/%s",pw3270_get_session_name(window));
  88 +
  89 + trace("DBUS service path is %s",service_path);
  90 + trace("DBUS service name is %s",service_name);
  91 +
  92 + org_freedesktop_DBus_request_name(proxy, service_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
  93 +
  94 + g_free(service_name);
  95 +
  96 + }
  97 +
84 98 if(error)
85 99 {
86 100 GtkWidget *dialog = gtk_message_dialog_new(
... ... @@ -102,13 +116,25 @@
102 116 return -1;
103 117 }
104 118  
105   - pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,PW3270_DBUS_SERVICE_PATH);
  119 + pw3270_dbus_register_object(connection,proxy,PW3270_TYPE_DBUS,&dbus_glib_pw3270_dbus_object_info,service_path);
  120 +
  121 + g_free(service_path);
106 122  
107 123 return 0;
108 124 }
109 125  
110 126 LIB3270_EXPORT int pw3270_plugin_deinit(GtkWidget *window)
111 127 {
112   -
113 128 return 0;
114 129 }
  130 +
  131 + void pw3270_dbus_quit(PW3270Dbus *object, DBusGMethodInvocation *context)
  132 + {
  133 + gtk_main_quit();
  134 + dbus_g_method_return(context,0);
  135 + }
  136 +
  137 +H3270 * pw3270_dbus_get_session_handle(PW3270Dbus *object)
  138 +{
  139 + return lib3270_get_default_session_handle();
  140 +}
... ...
src/plugins/dbus3270/service.h
... ... @@ -38,9 +38,6 @@
38 38  
39 39 #include "globals.h"
40 40  
41   - #define PW3270_DBUS_SERVICE_PATH "/br/com/bb/pw3270"
42   - #define PW3270_DBUS_SERVICE "br.com.bb.pw3270"
43   -
44 41 #define PW3270_TYPE_DBUS (pw3270_dbus_get_type ())
45 42 #define PW3270_DBUS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PW3270_TYPE_DBUS, PW3270Dbus))
46 43 #define PW3270_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DBUS, PW3270DbusClass))
... ...
src/pw3270/print.c
... ... @@ -437,7 +437,7 @@ static gchar * enum_to_string(GType type, guint enum_value)
437 437 gtk_list_store_append((GtkListStore *) model,&iter);
438 438 gtk_list_store_set((GtkListStore *) model, &iter,0, name, -1);
439 439  
440   - if(!g_strcasecmp(name,info->font))
  440 + if(!g_ascii_strcasecmp(name,info->font))
441 441 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widget),&iter);
442 442 }
443 443 }
... ...
src/sample/connect.c
... ... @@ -33,6 +33,7 @@
33 33 #include <stdlib.h>
34 34 #include <string.h>
35 35 #include <lib3270.h>
  36 + #include <lib3270/actions.h>
36 37  
37 38 /*--[ Implement ]------------------------------------------------------------------------------------*/
38 39  
... ... @@ -60,24 +61,67 @@
60 61  
61 62 printf("Connected to LU %s\n",lib3270_get_luname(hSession));
62 63  
63   - /* Wait until the host is ready for commands */
  64 + // Wait until the host is ready for commands
64 65 rc = lib3270_wait_for_ready(hSession,60);
65 66 if(rc)
66 67 {
67 68 fprintf(stderr,"Error waiting for session negotiation: %s\n",strerror(rc));
68 69 return rc;
69 70 }
70   - else
  71 +
  72 + while(lib3270_wait_for_ready(hSession,60))
  73 + {
  74 + char * screen_id = lib3270_get_text(hSession,1,9);
  75 +
  76 + printf("Screen-id: [%s]",screen_id);
  77 +
  78 + if(!strcasecmp(screen_id)," ")
  79 + {
  80 +/*
  81 + select
  82 + when host~queryStringAt(16,34,"Tecle ENTER")
  83 + then host~sendEnterKey()
  84 +
  85 + when host~queryStringAt(2,24,"Conexoes Externas ao SISBB")
  86 + then host~sendEnterKey()
  87 +
  88 + when host~queryStringAt(15,2,"Aplicativo :") then
  89 + do
  90 + if host~queryStringAt(15,21,app) = 0 then
  91 + do
  92 + host~setStringAt(15,21,aplic)
  93 + host~setCursorPosition(13,21)
  94 + end
  95 + end
  96 +
  97 + otherwise
  98 + end
  99 +*/
  100 + }
  101 + else
  102 + {
  103 + fprintf(stderr,"Tela desconhecida [%s], abortando\n",screen_id);
  104 + break;
  105 + }
  106 +
  107 +
  108 + lib3270_free(screen_id);
  109 +
  110 + }
  111 +
  112 +/*
  113 +
  114 + rc = lib3270_enter(hSession);
  115 + rc = lib3270_wait_for_ready(hSession,60);
  116 +
71 117 {
72   - /* Host is ready, get screen contents */
73 118 char *text = lib3270_get_text(hSession,0,-1);
74 119  
75 120 printf("\nScreen contents:\n%s\n",text);
76 121  
77 122 lib3270_free(text);
78 123 }
79   -
80   -
  124 +*/
81 125  
82 126  
83 127 /* Release session handle */
... ...