Commit b58b68836815b3189ad40fa43dbdcc909f427ffc

Authored by Perry Werneck
1 parent b8f2f9aa

Implementando novos métodos

src/libpw3270cpp/service.cc
... ... @@ -155,7 +155,6 @@
155 155  
156 156 dbus_message_unref(msg);
157 157 throw e;
158   - return -1;
159 158 }
160 159 dbus_message_unref(msg);
161 160 }
... ... @@ -211,7 +210,7 @@
211 210 dbus_int32_t s = (dbus_int32_t) sz;
212 211  
213 212 return getString( "getTextAt",
214   - DBUS_TYPE_STRING, this->id,
  213 + DBUS_TYPE_STRING, &this->id,
215 214 DBUS_TYPE_INT32, &r,
216 215 DBUS_TYPE_INT32, &c,
217 216 DBUS_TYPE_INT32, &s,
... ... @@ -225,7 +224,7 @@
225 224 dbus_int32_t c = (dbus_int32_t) col;
226 225  
227 226 return getInteger( "setTextAt",
228   - DBUS_TYPE_STRING, this->id,
  227 + DBUS_TYPE_STRING, &this->id,
229 228 DBUS_TYPE_INT32, &r,
230 229 DBUS_TYPE_INT32, &c,
231 230 DBUS_TYPE_STRING, str,
... ... @@ -238,7 +237,7 @@
238 237 dbus_int32_t c = (dbus_int32_t) col;
239 238  
240 239 return getInteger( "cmpTextAt",
241   - DBUS_TYPE_STRING, this->id,
  240 + DBUS_TYPE_STRING, &this->id,
242 241 DBUS_TYPE_INT32, &r,
243 242 DBUS_TYPE_INT32, &c,
244 243 DBUS_TYPE_STRING, str,
... ... @@ -274,6 +273,10 @@
274 273 {
275 274 // Já tem sessão definida, usa.
276 275 this->name = session;
  276 + int rc = getInteger("chkId");
  277 + if(rc) {
  278 + throw exception("%s",strerror(rc));
  279 + }
277 280 }
278 281 else
279 282 {
... ... @@ -356,10 +359,20 @@
356 359 {
357 360 int rc = getInteger("connect", DBUS_TYPE_STRING, &this->id, DBUS_TYPE_STRING, &url, DBUS_TYPE_INVALID);
358 361  
  362 + debug("connect rc=%d (%s)",rc,strerror(rc));;
  363 +
359 364 if(!rc && wait) {
360   - rc = wait_for_ready(wait);
  365 + time_t end = time(0) + wait;
  366 + while(!is_connected()) {
  367 + if(time(0) > end) {
  368 + debug("%s: Timeout",__FUNCTION__);
  369 + return ETIMEDOUT;
  370 + }
  371 + usleep(500);
  372 + }
361 373 }
362 374  
  375 + debug("connect rc=%d (%s)",rc,strerror(rc));;
363 376 return rc;
364 377  
365 378 }
... ... @@ -383,10 +396,13 @@
383 396 {
384 397 time_t end = time(0)+seconds;
385 398  
  399 + debug("%s(%d)",__FUNCTION__,seconds);
386 400 while(time(0) < end)
387 401 {
388   - if(!is_connected())
  402 + if(!is_connected()) {
  403 + debug("%s: %s",__FUNCTION__,strerror(ENOTCONN));
389 404 return ENOTCONN;
  405 + }
390 406  
391 407 if(is_ready())
392 408 return 0;
... ... @@ -394,6 +410,7 @@
394 410 usleep(500);
395 411 }
396 412  
  413 + debug("%s: Timeout",__FUNCTION__);
397 414 return ETIMEDOUT;
398 415 }
399 416  
... ...
src/libpw3270cpp/testprogram.cc
... ... @@ -56,13 +56,11 @@
56 56  
57 57 cout << "\tSession state: " << session->get_cstate() << endl;
58 58  
59   - s = session->get_display_charset();
60   - cout << "\tDisplay charset: " << s.c_str() << endl;
  59 + // s = session->get_display_charset();
  60 + // cout << "\tDisplay charset: " << s.c_str() << endl;
61 61  
62   - s = session->get_host_charset();
63   - cout << "\tHost charset: " << s.c_str() << endl;
64   -
65   - return 0;
  62 + // s = session->get_host_charset();
  63 + // cout << "\tHost charset: " << s.c_str() << endl;
66 64  
67 65 cout << "Connect: " << session->connect("fandezhi.efglobe.com:23",60) << endl << endl;
68 66  
... ...