Commit a7148ff49c7df704b89a394332f5035d61260798

Authored by perry.werneck@gmail.com
1 parent 0fe8634c

Migrando plugin rexx para a classe de apoio

Showing 2 changed files with 34 additions and 60 deletions   Show diff stats
pw3270.cbp
... ... @@ -291,10 +291,7 @@
291 291 <Option compilerVar="CC" />
292 292 </Unit>
293 293 <Unit filename="src/plugins/rx3270/Makefile.in" />
294   - <Unit filename="src/plugins/rx3270/exception.cc" />
295   - <Unit filename="src/plugins/rx3270/local.cc" />
296 294 <Unit filename="src/plugins/rx3270/pluginmain.cc" />
297   - <Unit filename="src/plugins/rx3270/remote.cc" />
298 295 <Unit filename="src/plugins/rx3270/rexx_methods.cc" />
299 296 <Unit filename="src/plugins/rx3270/rx3270.cc" />
300 297 <Unit filename="src/plugins/rx3270/rx3270.cls" />
... ...
src/plugins/rx3270/typed_routines.cc
... ... @@ -133,47 +133,37 @@ RexxRoutine1(int, rx3270WaitForTerminalReady, int, seconds)
133 133  
134 134 RexxRoutine4(int, rx3270WaitForStringAt, int, row, int, col, CSTRING, key, int, timeout)
135 135 {
136   - #warning REIMPLEMENTAR
137   -/*
138   - session * session = session::get_default();
139   - time_t end = time(0) + timeout;
140   - char * text = session->get_3270_string(key);
141   -
142   - while(time(0) < end)
  136 + try
143 137 {
144   - if(!session->is_connected())
145   - {
146   - return ENOTCONN;
147   - }
148   - else if( !(session->wait_for_ready(1) || session->cmp_text_at(row,col,text)) )
149   - {
150   - free(text);
151   - return 0;
152   - }
  138 + return session::get_default()->wait_for_string_at(row,col,key,timeout);
  139 + }
  140 + catch(std::exception &e)
  141 + {
  142 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
153 143 }
154 144  
155   - free(text);
156   -*/
157 145 return ETIMEDOUT;
158 146  
159 147 }
160 148  
161 149 RexxRoutine3(RexxStringObject, rx3270GetStringAt, int, row, int, col, int, sz)
162 150 {
163   - #warning REIMPLEMENTAR
164   -/*
165   - rx3270 * session = rx3270::get_default();
166   - char * str = session->get_text_at(row,col,sz);
  151 + try
  152 + {
  153 + string *str = session::get_default()->get_string_at(row,col,(int) sz);
167 154  
168   - if(str)
  155 + if(str)
  156 + {
  157 + RexxStringObject ret = context->String((CSTRING) str->c_str());
  158 + delete str;
  159 + return ret;
  160 + }
  161 + }
  162 + catch(std::exception &e)
169 163 {
170   - char * text = session->get_local_string(str);
171   - RexxStringObject ret = context->String((CSTRING) text);
172   - free(str);
173   - free(text);
174   - return ret;
  164 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
175 165 }
176   -*/
  166 +
177 167 return context->String("");
178 168 }
179 169  
... ... @@ -184,23 +174,15 @@ RexxRoutine0(int, rx3270IsTerminalReady)
184 174  
185 175 RexxRoutine3(int, rx3270queryStringAt, int, row, int, col, CSTRING, key)
186 176 {
187   - #warning Reimplementar
188   -/*
189   - int rc = 0;
190   - rx3270 * session = rx3270::get_default();
191   - char * str = session->get_text_at(row,col,strlen(key));
192   -
193   - if(str)
  177 + try
194 178 {
195   - char * text = session->get_3270_string(key);
196   - rc = strcasecmp(str,text);
197   - free(text);
  179 + return session::get_default()->cmp_string_at(row,col,key);
  180 + }
  181 + catch(std::exception &e)
  182 + {
  183 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
198 184 }
199 185  
200   - free(str);
201   -
202   - return rc;
203   -*/
204 186 return -1;
205 187 }
206 188  
... ... @@ -220,23 +202,18 @@ RexxRoutine2(int, rx3270SetCursorPosition, int, row, int, col)
220 202  
221 203 RexxRoutine3(int, rx3270SetStringAt, int, row, int, col, CSTRING, text)
222 204 {
223   - #warning Reimplementar
224   -/*
225   - rx3270 * session = rx3270::get_default();
226   - char * str = session->get_3270_string(text);
227   - int rc;
228   -
229   - rc = session->set_text_at(row,col,str);
230   -
231   - free(str);
232   -
233   - return rc;
234   -*/
  205 + try
  206 + {
  207 + return session::get_default()->set_string_at(row,col,text);
  208 + }
  209 + catch(std::exception &e)
  210 + {
  211 + context->RaiseException1(Rexx_Error_Application_error,context->NewStringFromAsciiz(e.what()));
  212 + }
235 213 return -1;
236 214 }
237 215  
238 216 RexxRoutine0(int, rx3270CloseApplication)
239 217 {
240   - session * session = session::get_default();
241   - return session->quit();
  218 + return session::get_default()->quit();
242 219 }
... ...