Commit 579ad177500e6b9c572e73c49351384cc620dbce

Authored by perry.werneck@gmail.com
1 parent 5447289d

Implementando metodos rexx iguais aos da API antiga

src/plugins/rx3270/remote.cc
... ... @@ -65,6 +65,8 @@
65 65 int cmp_text_at(int row, int col, const char *text);
66 66 int set_text_at(int row, int col, const char *str);
67 67  
  68 + int wait_for_text_at(int row, int col, const char *key, int timeout);
  69 +
68 70 int set_cursor_position(int row, int col);
69 71  
70 72 void set_toggle(LIB3270_TOGGLE ix, bool value);
... ... @@ -934,3 +936,24 @@ void remote::set_toggle(LIB3270_TOGGLE ix, bool value)
934 936  
935 937 }
936 938  
  939 +int remote::wait_for_text_at(int row, int col, const char *key, int timeout)
  940 +{
  941 + time_t end = time(0)+timeout;
  942 +
  943 + while(time(0) < end)
  944 + {
  945 + if(!is_connected())
  946 + return ENOTCONN;
  947 +
  948 + if(!cmp_text_at(row,col,key))
  949 + return 0;
  950 +
  951 +#ifdef WIN32
  952 + Sleep(500);
  953 +#else
  954 + usleep(500);
  955 +#endif
  956 + }
  957 +
  958 + return ETIMEDOUT;
  959 +}
... ...
src/plugins/rx3270/rexx_methods.cc
... ... @@ -327,3 +327,14 @@ RexxMethod4(logical_t, rx3270_method_test, CSELF, sessionPtr, CSTRING, key, int,
327 327  
328 328 return false;
329 329 }
  330 +
  331 +RexxMethod5(int, rx3270_method_wait_for_text_at, CSELF, sessionPtr, int, row, int, col, CSTRING, key, int, timeout)
  332 +{
  333 + rx3270 * hSession = (rx3270 *) sessionPtr;
  334 +
  335 + if(hSession)
  336 + return hSession->wait_for_text_at(row,col,key,timeout);
  337 +
  338 + return -1;
  339 +}
  340 +
... ...
src/plugins/rx3270/rx3270.cls
... ... @@ -64,5 +64,58 @@
64 64 ::METHOD GETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_get_text_at"
65 65 ::METHOD SETTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_set_text_at"
66 66 ::METHOD CMPTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_cmp_text_at"
  67 +::METHOD WAITFORTEXTAT EXTERNAL "LIBRARY rx3270 rx3270_method_wait_for_text_at"
67 68 ::METHOD TEST EXTERNAL "LIBRARY rx3270 rx3270_method_test"
68 69  
  70 +/*
  71 +getConnectionState
  72 +waitForEvents
  73 +getScreenContent
  74 +RunMode
  75 +
  76 +::method isConnected
  77 +return self~getConnectionState() = "CONNECTED_TN3270E"
  78 +
  79 +::method waitForStringAt
  80 + use arg row, col, key, timeout
  81 + if datatype(timeout) <> "NUM"
  82 + then timeout = 60
  83 +return self~WaitForTextAt(row,col,key,timeout)
  84 +
  85 +*/
  86 +
  87 +::method queryStringAt
  88 + use arg row, col, key
  89 +return self~GetTextAt(row,col,length(key)) == key
  90 +
  91 +::method waitForTerminalReady
  92 + use arg timeout
  93 +return self~WaitForReady(timeout)
  94 +
  95 +::method isTerminalReady
  96 +return self~ready()
  97 +
  98 +::method setStringAt
  99 + use arg row, col, str
  100 +return self~SetTextAt(row,col,str)
  101 +
  102 +::method getStringAt
  103 + use arg row, col, size
  104 +return self~GetTextAt(row,col,size)
  105 +
  106 +::method sendEnterKey
  107 +return self~Enter()
  108 +
  109 +::method sendPFKey
  110 + use arg key
  111 +return self~pfKey(key)
  112 +
  113 +::method setCursorPosition
  114 + use arg row, col
  115 +return self~SetCursor(row,col)
  116 +
  117 +::method getScreenContentAt
  118 + use arg row, col, size
  119 +return self~GetTextAt(row,col,size)
  120 +
  121 +
... ...
src/plugins/rx3270/rx3270.h
... ... @@ -104,6 +104,7 @@
104 104 REXX_METHOD_PROTOTYPE(rx3270_method_ds_trace);
105 105 REXX_METHOD_PROTOTYPE(rx3270_method_set_option);
106 106 REXX_METHOD_PROTOTYPE(rx3270_method_test);
  107 + REXX_METHOD_PROTOTYPE(rx3270_method_wait_for_text_at);
107 108  
108 109 /*---[ Globals ]---------------------------------------------------------------------------------------------*/
109 110  
... ... @@ -154,6 +155,7 @@
154 155 virtual int iterate(bool wait = true) = 0;
155 156 virtual int wait(int seconds) = 0;
156 157 virtual int wait_for_ready(int seconds) = 0;
  158 + virtual int wait_for_text_at(int row, int col, const char *key, int timeout);
157 159 virtual int set_cursor_position(int row, int col) = 0;
158 160 virtual void set_toggle(LIB3270_TOGGLE ix, bool value) = 0;
159 161  
... ...
src/plugins/rx3270/rxapimain.cc
... ... @@ -110,6 +110,8 @@ RexxRoutineEntry rx3270_functions[] =
110 110 REXX_TYPED_ROUTINE(rx3270queryStringAt, rx3270queryStringAt),
111 111 REXX_TYPED_ROUTINE(rx3270SetStringAt, rx3270SetStringAt),
112 112  
  113 + // rx3270Popup
  114 +
113 115 REXX_LAST_METHOD()
114 116 };
115 117  
... ... @@ -137,6 +139,7 @@ RexxMethodEntry rx3270_methods[] =
137 139 REXX_METHOD(rx3270_method_ds_trace, rx3270_method_ds_trace ),
138 140 REXX_METHOD(rx3270_method_set_option, rx3270_method_set_option ),
139 141 REXX_METHOD(rx3270_method_test, rx3270_method_test ),
  142 + REXX_METHOD(rx3270_method_wait_for_text_at, rx3270_method_wait_for_text_at ),
140 143  
141 144 REXX_LAST_METHOD()
142 145 };
... ... @@ -184,3 +187,21 @@ void rx3270::logva(const char *fmt, va_list args)
184 187 vfprintf(stderr,fmt,args);
185 188 #endif
186 189 }
  190 +
  191 +int rx3270::wait_for_text_at(int row, int col, const char *key, int timeout)
  192 +{
  193 + time_t end = time(0)+timeout;
  194 +
  195 + while(time(0) < end)
  196 + {
  197 + if(!is_connected())
  198 + return ENOTCONN;
  199 +
  200 + if(!cmp_text_at(row,col,key))
  201 + return 0;
  202 +
  203 + iterate();
  204 + }
  205 +
  206 + return ETIMEDOUT;
  207 +}
... ...