Commit b58b68836815b3189ad40fa43dbdcc909f427ffc

Authored by Perry Werneck
1 parent b8f2f9aa

Implementando novos métodos

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