Commit cb71f196ea8beac915b98a9f3d63598a90294b97

Authored by Perry Werneck
1 parent 9ae530d5

Implementando tratamento de LF nas capturas de conteúdo.

src/include/lib3270.h
@@ -921,11 +921,12 @@ @@ -921,11 +921,12 @@
921 * @param row Desired row. 921 * @param row Desired row.
922 * @param col Desired col. 922 * @param col Desired col.
923 * @param length Text length 923 * @param length Text length
  924 + * @param lf Line break char (0 to disable line breaks).
924 * 925 *
925 * @return Contents at position if available, or NULL. Release it with lib3270_free() 926 * @return Contents at position if available, or NULL. Release it with lib3270_free()
926 * 927 *
927 */ 928 */
928 - LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len); 929 + LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len, char lf);
929 930
930 /** 931 /**
931 * Check for text at requested position 932 * Check for text at requested position
@@ -934,11 +935,12 @@ @@ -934,11 +935,12 @@
934 * @param row Desired row. 935 * @param row Desired row.
935 * @param col Desired col. 936 * @param col Desired col.
936 * @param text Text to check. 937 * @param text Text to check.
  938 + * @param lf Line break char (0 to disable line breaks).
937 * 939 *
938 * @return Test result from strcmp 940 * @return Test result from strcmp
939 * 941 *
940 */ 942 */
941 - LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text); 943 + LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text, char lf);
942 944
943 945
944 /** 946 /**
src/include/pw3270/ipcpackets.h
@@ -141,6 +141,7 @@ struct hllapi_packet_text_at @@ -141,6 +141,7 @@ struct hllapi_packet_text_at
141 unsigned char packet_id; 141 unsigned char packet_id;
142 unsigned short row; 142 unsigned short row;
143 unsigned short col; 143 unsigned short col;
  144 + char lf;
144 char text[1]; 145 char text[1];
145 }; 146 };
146 147
@@ -150,6 +151,7 @@ struct hllapi_packet_query_at @@ -150,6 +151,7 @@ struct hllapi_packet_query_at
150 unsigned short row; 151 unsigned short row;
151 unsigned short col; 152 unsigned short col;
152 unsigned short len; 153 unsigned short len;
  154 + char lf;
153 }; 155 };
154 156
155 struct hllapi_packet_wait 157 struct hllapi_packet_wait
src/include/pw3270cpp.h
@@ -274,11 +274,11 @@ @@ -274,11 +274,11 @@
274 session(); 274 session();
275 275
276 // Get/Set/Test without charset translation 276 // Get/Set/Test without charset translation
277 - virtual string get_text(int baddr = 0, size_t len = 1, bool lf = false) = 0;  
278 - virtual string get_text_at(int row, int col, size_t sz) = 0;  
279 - virtual int set_text_at(int row, int col, const char *str) = 0;  
280 - virtual int cmp_text_at(int row, int col, const char *text) = 0;  
281 - virtual int emulate_input(const char *str) = 0; 277 + virtual string get_text(int baddr = 0, size_t len = 1, bool lf = false) = 0;
  278 + virtual string get_text_at(int row, int col, size_t sz, bool lf = false) = 0;
  279 + virtual int set_text_at(int row, int col, const char *str) = 0;
  280 + virtual int cmp_text_at(int row, int col, const char *text, bool lf = false) = 0;
  281 + virtual int emulate_input(const char *str) = 0;
282 virtual int wait_for_text_at(int row, int col, const char *key, int timeout); 282 virtual int wait_for_text_at(int row, int col, const char *key, int timeout);
283 283
284 private: 284 private:
src/lib3270/selection.c
@@ -530,19 +530,19 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf) @@ -530,19 +530,19 @@ LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len, char lf)
530 return buffer; 530 return buffer;
531 } 531 }
532 532
533 -LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len) 533 +LIB3270_EXPORT char * lib3270_get_text_at(H3270 *h, int row, int col, int len, char lf)
534 { 534 {
535 CHECK_SESSION_HANDLE(h); 535 CHECK_SESSION_HANDLE(h);
536 - return lib3270_get_text(h, ((row-1) * h->cols) + (col-1), len, '\n'); 536 + return lib3270_get_text(h, ((row-1) * h->cols) + (col-1), len, lf);
537 } 537 }
538 538
539 -LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text) 539 +LIB3270_EXPORT int lib3270_cmp_text_at(H3270 *h, int row, int col, const char *text, char lf)
540 { 540 {
541 int rc; 541 int rc;
542 size_t sz = strlen(text); 542 size_t sz = strlen(text);
543 char * contents; 543 char * contents;
544 544
545 - contents = lib3270_get_text_at(h,row,col,sz); 545 + contents = lib3270_get_text_at(h,row,col,sz,lf);
546 if(!contents) 546 if(!contents)
547 return -1; 547 return -1;
548 548
src/libpw3270cpp/local.cc
@@ -138,8 +138,8 @@ @@ -138,8 +138,8 @@
138 int (*_pakey)(H3270 *hSession, int key); 138 int (*_pakey)(H3270 *hSession, int key);
139 int (*_wait_for_ready)(H3270 *hSession, int seconds); 139 int (*_wait_for_ready)(H3270 *hSession, int seconds);
140 char * (*_get_text)(H3270 *h, int offset, int len, char lf); 140 char * (*_get_text)(H3270 *h, int offset, int len, char lf);
141 - char * (*_get_text_at)(H3270 *h, int row, int col, int len);  
142 - int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text); 141 + char * (*_get_text_at)(H3270 *h, int row, int col, int len, char lf);
  142 + int (*_cmp_text_at)(H3270 *h, int row, int col, const char *text, char lf);
143 int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str); 143 int (*_set_text_at)(H3270 *h, int row, int col, const unsigned char *str);
144 int (*_is_ready)(H3270 *h); 144 int (*_is_ready)(H3270 *h);
145 int (*_set_cursor_position)(H3270 *h, int row, int col); 145 int (*_set_cursor_position)(H3270 *h, int row, int col);
@@ -353,10 +353,10 @@ @@ -353,10 +353,10 @@
353 return 0; 353 return 0;
354 } 354 }
355 355
356 - string get_text_at(int row, int col, size_t sz) 356 + string get_text_at(int row, int col, size_t sz, bool lf)
357 { 357 {
358 string rc; 358 string rc;
359 - char * ptr = _get_text_at(hSession,row,col,sz); 359 + char * ptr = _get_text_at(hSession,row,col,sz,lf ? '\n' : 0);
360 360
361 if(ptr) 361 if(ptr)
362 { 362 {
@@ -372,9 +372,9 @@ @@ -372,9 +372,9 @@
372 return _set_text_at(hSession,row,col,(const unsigned char *) str); 372 return _set_text_at(hSession,row,col,(const unsigned char *) str);
373 } 373 }
374 374
375 - int cmp_text_at(int row, int col, const char *text) 375 + int cmp_text_at(int row, int col, const char *text, bool lf)
376 { 376 {
377 - return _cmp_text_at(hSession,row,col,text); 377 + return _cmp_text_at(hSession,row,col,text,lf ? '\n' : 0);
378 } 378 }
379 379
380 string get_text(int offset, size_t len, bool lf) 380 string get_text(int offset, size_t len, bool lf)
src/libpw3270cpp/remote.cc
@@ -1031,11 +1031,11 @@ @@ -1031,11 +1031,11 @@
1031 #endif 1031 #endif
1032 } 1032 }
1033 1033
1034 - string get_text_at(int row, int col, size_t sz) 1034 + string get_text_at(int row, int col, size_t sz, bool lf)
1035 { 1035 {
1036 #if defined(WIN32) 1036 #if defined(WIN32)
1037 1037
1038 - struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz }; 1038 + struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz, lf ? '\n' : 0 };
1039 1039
1040 return query_string(&query,sizeof(query),sz); 1040 return query_string(&query,sizeof(query),sz);
1041 1041
@@ -1044,13 +1044,14 @@ @@ -1044,13 +1044,14 @@
1044 dbus_int32_t r = (dbus_int32_t) row; 1044 dbus_int32_t r = (dbus_int32_t) row;
1045 dbus_int32_t c = (dbus_int32_t) col; 1045 dbus_int32_t c = (dbus_int32_t) col;
1046 dbus_int32_t l = (dbus_int32_t) sz; 1046 dbus_int32_t l = (dbus_int32_t) sz;
  1047 + unsigned char d = lf ? '\n' : 0;
1047 1048
1048 DBusMessage * msg = create_message("getTextAt"); 1049 DBusMessage * msg = create_message("getTextAt");
1049 if(!msg) 1050 if(!msg)
1050 return NULL; 1051 return NULL;
1051 1052
1052 trace("%s(%d,%d,%d)",__FUNCTION__,r,c,l); 1053 trace("%s(%d,%d,%d)",__FUNCTION__,r,c,l);
1053 - dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INT32, &l, DBUS_TYPE_INVALID); 1054 + dbus_message_append_args(msg, DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_INT32, &l, DBUS_TYPE_BYTE, &d, DBUS_TYPE_INVALID);
1054 1055
1055 return get_string(call(msg)); 1056 return get_string(call(msg));
1056 1057
@@ -1097,7 +1098,7 @@ @@ -1097,7 +1098,7 @@
1097 1098
1098 } 1099 }
1099 1100
1100 - int cmp_text_at(int row, int col, const char *text) 1101 + int cmp_text_at(int row, int col, const char *text, bool lf)
1101 { 1102 {
1102 debug("%s(%d,%d,\"%s\")",__FUNCTION__,row,col,text); 1103 debug("%s(%d,%d,\"%s\")",__FUNCTION__,row,col,text);
1103 1104
@@ -1110,6 +1111,7 @@ @@ -1110,6 +1111,7 @@
1110 query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT; 1111 query->packet_id = HLLAPI_PACKET_CMP_TEXT_AT;
1111 query->row = row; 1112 query->row = row;
1112 query->col = col; 1113 query->col = col;
  1114 + query->lf = lf ? '\n' : 0
1113 strcpy(query->text,text); 1115 strcpy(query->text,text);
1114 1116
1115 return query_intval((void *) query, cbSize, true); 1117 return query_intval((void *) query, cbSize, true);
@@ -1118,8 +1120,9 @@ @@ -1118,8 +1120,9 @@
1118 1120
1119 dbus_int32_t r = (dbus_int32_t) row; 1121 dbus_int32_t r = (dbus_int32_t) row;
1120 dbus_int32_t c = (dbus_int32_t) col; 1122 dbus_int32_t c = (dbus_int32_t) col;
  1123 + unsigned char d = lf ? '\n' : 0;
1121 1124
1122 - return query_intval("cmpTextAt", DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); 1125 + return query_intval("cmpTextAt", DBUS_TYPE_INT32, &r, DBUS_TYPE_INT32, &c, DBUS_TYPE_STRING, &text, DBUS_TYPE_BYTE, &d, DBUS_TYPE_INVALID);
1123 1126
1124 #endif 1127 #endif
1125 1128
@@ -1135,7 +1138,7 @@ @@ -1135,7 +1138,7 @@
1135 if(!is_connected()) 1138 if(!is_connected())
1136 return ENOTCONN; 1139 return ENOTCONN;
1137 1140
1138 - if(!cmp_text_at(row,col,key)) 1141 + if(!cmp_text_at(row,col,key,false))
1139 return 0; 1142 return 0;
1140 1143
1141 #ifdef WIN32 1144 #ifdef WIN32
src/libpw3270cpp/service.cc
@@ -213,17 +213,19 @@ @@ -213,17 +213,19 @@
213 213
214 } 214 }
215 215
216 - virtual string get_text_at(int row, int col, size_t sz) 216 + virtual string get_text_at(int row, int col, size_t sz, bool lf = true)
217 { 217 {
218 dbus_int32_t r = (dbus_int32_t) row; 218 dbus_int32_t r = (dbus_int32_t) row;
219 dbus_int32_t c = (dbus_int32_t) col; 219 dbus_int32_t c = (dbus_int32_t) col;
220 dbus_int32_t s = (dbus_int32_t) sz; 220 dbus_int32_t s = (dbus_int32_t) sz;
  221 + char l = lf ? '\n' : 0;
221 222
222 return getString( "getTextAt", 223 return getString( "getTextAt",
223 DBUS_TYPE_STRING, &this->id, 224 DBUS_TYPE_STRING, &this->id,
224 DBUS_TYPE_INT32, &r, 225 DBUS_TYPE_INT32, &r,
225 DBUS_TYPE_INT32, &c, 226 DBUS_TYPE_INT32, &c,
226 DBUS_TYPE_INT32, &s, 227 DBUS_TYPE_INT32, &s,
  228 + DBUS_TYPE_BYTE, &l,
227 DBUS_TYPE_INVALID); 229 DBUS_TYPE_INVALID);
228 230
229 } 231 }
@@ -241,16 +243,18 @@ @@ -241,16 +243,18 @@
241 DBUS_TYPE_INVALID); 243 DBUS_TYPE_INVALID);
242 } 244 }
243 245
244 - virtual int cmp_text_at(int row, int col, const char *str) 246 + virtual int cmp_text_at(int row, int col, const char *str, bool lf)
245 { 247 {
246 dbus_int32_t r = (dbus_int32_t) row; 248 dbus_int32_t r = (dbus_int32_t) row;
247 dbus_int32_t c = (dbus_int32_t) col; 249 dbus_int32_t c = (dbus_int32_t) col;
  250 + char l = lf ? '\n' : 0;
248 251
249 return getInteger( "cmpTextAt", 252 return getInteger( "cmpTextAt",
250 DBUS_TYPE_STRING, &this->id, 253 DBUS_TYPE_STRING, &this->id,
251 DBUS_TYPE_INT32, &r, 254 DBUS_TYPE_INT32, &r,
252 DBUS_TYPE_INT32, &c, 255 DBUS_TYPE_INT32, &c,
253 DBUS_TYPE_STRING, &str, 256 DBUS_TYPE_STRING, &str,
  257 + DBUS_TYPE_BYTE, &l,
254 DBUS_TYPE_INVALID); 258 DBUS_TYPE_INVALID);
255 } 259 }
256 260
src/plugins/dbus3270/gobject.c
@@ -286,7 +286,7 @@ void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvo @@ -286,7 +286,7 @@ void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvo
286 } 286 }
287 287
288 288
289 -void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context) 289 +void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context)
290 { 290 {
291 gchar * text; 291 gchar * text;
292 H3270 * hSession = pw3270_dbus_get_session_handle(object); 292 H3270 * hSession = pw3270_dbus_get_session_handle(object);
@@ -295,7 +295,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus @@ -295,7 +295,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
295 if(pw3270_dbus_check_valid_state(object,context)) 295 if(pw3270_dbus_check_valid_state(object,context))
296 return; 296 return;
297 297
298 - text = lib3270_get_text_at(hSession, row, col, len); 298 + text = lib3270_get_text_at(hSession, row, col, len, lf);
299 if(!text) 299 if(!text)
300 { 300 {
301 GError *error = pw3270_dbus_get_error_from_errno(errno); 301 GError *error = pw3270_dbus_get_error_from_errno(errno);
@@ -415,7 +415,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus @@ -415,7 +415,7 @@ void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBus
415 dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value)); 415 dbus_g_method_return(context,lib3270_set_toggle(pw3270_dbus_get_session_handle(object),id,value));
416 } 416 }
417 417
418 -void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, DBusGMethodInvocation *context) 418 +void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *utftext, char lf, DBusGMethodInvocation *context)
419 { 419 {
420 gchar * text; 420 gchar * text;
421 H3270 * hSession = pw3270_dbus_get_session_handle(object); 421 H3270 * hSession = pw3270_dbus_get_session_handle(object);
@@ -426,7 +426,7 @@ void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar * @@ -426,7 +426,7 @@ void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *
426 426
427 text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL); 427 text = g_convert_with_fallback(utftext,-1,lib3270_get_display_charset(hSession),"UTF-8","?",NULL,NULL,NULL);
428 428
429 - dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text)); 429 + dbus_g_method_return(context,lib3270_cmp_text_at(hSession,row,col,text,lf));
430 430
431 g_free(text); 431 g_free(text);
432 } 432 }
src/plugins/dbus3270/pw3270dbus.xml
@@ -73,6 +73,7 @@ @@ -73,6 +73,7 @@
73 <arg type="i" name="row" direction="in" /> 73 <arg type="i" name="row" direction="in" />
74 <arg type="i" name="col" direction="in" /> 74 <arg type="i" name="col" direction="in" />
75 <arg type="i" name="len" direction="in" /> 75 <arg type="i" name="len" direction="in" />
  76 + <arg type="y" name="lf" direction="in" />
76 <arg type="s" name="text" direction="out" /> 77 <arg type="s" name="text" direction="out" />
77 </method> 78 </method>
78 <method name="getText"> 79 <method name="getText">
@@ -162,6 +163,7 @@ @@ -162,6 +163,7 @@
162 <arg type="i" name="row" direction="in" /> 163 <arg type="i" name="row" direction="in" />
163 <arg type="i" name="col" direction="in" /> 164 <arg type="i" name="col" direction="in" />
164 <arg type="s" name="text" direction="in" /> 165 <arg type="s" name="text" direction="in" />
  166 + <arg type="y" name="lf" direction="in" />
165 <arg type="i" name="result" direction="out" /> 167 <arg type="i" name="result" direction="out" />
166 </method> 168 </method>
167 <method name="getFieldStart"> 169 <method name="getFieldStart">
src/plugins/dbus3270/service.h
@@ -112,9 +112,9 @@ @@ -112,9 +112,9 @@
112 void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); 112 void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
113 void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context); 113 void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
114 void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); 114 void pw3270_dbus_set_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context);
115 - void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, DBusGMethodInvocation *context); 115 + void pw3270_dbus_get_text_at(PW3270Dbus *object, int row, int col, int len, char lf, DBusGMethodInvocation *context);
116 void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context); 116 void pw3270_dbus_get_text(PW3270Dbus *object, int offset, int len, char lf, DBusGMethodInvocation *context);
117 - void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, DBusGMethodInvocation *context); 117 + void pw3270_dbus_cmp_text_at(PW3270Dbus *object, int row, int col, const gchar *text, char lf, DBusGMethodInvocation *context);
118 void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context); 118 void pw3270_dbus_input(PW3270Dbus *object, const gchar *utftext, DBusGMethodInvocation *context);
119 119
120 void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context); 120 void pw3270_dbus_set_clipboard(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);