Commit a2c1ad411ef19f26fe7ea28a947aab63c7abaca1

Authored by perry.werneck@gmail.com
1 parent 2a9b22c1

Android - Iniciando implementação de suporte para script de autostart

android/jni/main.cpp
@@ -126,11 +126,6 @@ static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, con @@ -126,11 +126,6 @@ static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, con
126 } 126 }
127 } 127 }
128 128
129 -static void ctlr_done(H3270 *session)  
130 -{  
131 - pw3270_jni_post_message(4);  
132 -}  
133 -  
134 void update_status(H3270 *session, LIB3270_MESSAGE id) 129 void update_status(H3270 *session, LIB3270_MESSAGE id)
135 { 130 {
136 pw3270_jni_post_message(1,(int) id); 131 pw3270_jni_post_message(1,(int) id);
@@ -255,6 +250,26 @@ static void tracehandler(H3270 *session, const char *fmt, va_list args) @@ -255,6 +250,26 @@ static void tracehandler(H3270 *session, const char *fmt, va_list args)
255 } 250 }
256 #endif // X3270_TRACE 251 #endif // X3270_TRACE
257 252
  253 +static void ctlr_done(H3270 *session)
  254 +{
  255 + __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "%s",__FUNCTION__);
  256 + pw3270_jni_post_message(5);
  257 +}
  258 +
  259 +static void autostart(H3270 *session)
  260 +{
  261 + // pw3270_jni_post_message(10);
  262 +
  263 + {
  264 + char *text = lib3270_get_text(PW3270_SESSION,0,-1);
  265 + if(text)
  266 + {
  267 + __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "Contents:\n%s\n",text);
  268 + lib3270_free(text);
  269 + }
  270 + }
  271 +}
  272 +
258 jint JNI_OnLoad(JavaVM *vm, void *reserved) 273 jint JNI_OnLoad(JavaVM *vm, void *reserved)
259 { 274 {
260 H3270 * session = lib3270_session_new(""); 275 H3270 * session = lib3270_session_new("");
@@ -270,11 +285,12 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) @@ -270,11 +285,12 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
270 lib3270_set_popup_handler(popuphandler); 285 lib3270_set_popup_handler(popuphandler);
271 lib3270_register_time_handlers(add_timer,remove_timer); 286 lib3270_register_time_handlers(add_timer,remove_timer);
272 287
273 - session->write = write_buffer;  
274 - session->changed = changed;  
275 - session->erase = erase;  
276 - session->ctlr_done = ctlr_done;  
277 - session->update_status = update_status; 288 + session->write = write_buffer;
  289 + session->changed = changed;
  290 + session->erase = erase;
  291 + session->ctlr_done = ctlr_done;
  292 + session->update_status = update_status;
  293 + session->autostart = autostart;
278 294
279 return JNI_VERSION_1_4; 295 return JNI_VERSION_1_4;
280 } 296 }
android/jni/misc.cpp
@@ -58,3 +58,13 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setToggle(JNIEnv *env, jobj @@ -58,3 +58,13 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setToggle(JNIEnv *env, jobj
58 58
59 } 59 }
60 60
  61 +JNIEXPORT jboolean JNICALL Java_br_com_bb_pw3270_lib3270_in3270 (JNIEnv *env, jobject obj)
  62 +{
  63 + jboolean rc;
  64 +
  65 + PW3270_JNI_BEGIN
  66 + rc = lib3270_in_3270(PW3270_SESSION) ? JNI_TRUE : JNI_FALSE;
  67 + PW3270_JNI_END
  68 +
  69 + return rc;
  70 +}
android/jni/text.cpp
@@ -68,44 +68,33 @@ JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env, @@ -68,44 +68,33 @@ JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env,
68 return ret; 68 return ret;
69 } 69 }
70 70
71 -  
72 -/*  
73 JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, jobject obj) 71 JNIEXPORT jbyteArray JNICALL Java_br_com_bb_pw3270_lib3270_getText(JNIEnv *env, jobject obj)
74 { 72 {
75 jbyteArray ret; 73 jbyteArray ret;
76 74
77 PW3270_JNI_BEGIN 75 PW3270_JNI_BEGIN
78 76
79 - trace("%s starts",__FUNCTION__);  
80 -  
81 - if(session)  
82 - {  
83 - char *text = lib3270_get_text(session,0,-1); 77 +// trace("%s starts",__FUNCTION__);
84 78
85 - trace("%s will return \"%s\"",__FUNCTION__,text ? text : ""); 79 + char *text = lib3270_get_text(PW3270_SESSION,0,-1);
86 80
87 - if(text)  
88 - {  
89 - ret = retString(env,text);  
90 - lib3270_free(text);  
91 - }  
92 - else  
93 - {  
94 - ret = retString(env, "");  
95 - } 81 + if(text)
  82 + {
  83 + ret = retString(text);
  84 + lib3270_free(text);
96 } 85 }
97 else 86 else
98 { 87 {
99 - ret = retString(env, "<b>Invalid Session ID</b>"); 88 + ret = retString("");
100 } 89 }
101 90
102 - trace("%s ends",__FUNCTION__); 91 +// trace("%s ends",__FUNCTION__);
103 92
104 PW3270_JNI_END 93 PW3270_JNI_END
105 94
106 return ret; 95 return ret;
107 } 96 }
108 -*/ 97 +
109 98
110 JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobject obj, jint pos, jbyteArray inText, jint szText) 99 JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobject obj, jint pos, jbyteArray inText, jint szText)
111 { 100 {
@@ -149,3 +138,17 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobj @@ -149,3 +138,17 @@ JNIEXPORT void JNICALL Java_br_com_bb_pw3270_lib3270_setTextAt(JNIEnv *env, jobj
149 138
150 PW3270_JNI_END 139 PW3270_JNI_END
151 } 140 }
  141 +
  142 +JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_input(JNIEnv *env, jobject obj, jstring str, jint pasting)
  143 +{
  144 + int rc = -1;
  145 +
  146 + PW3270_JNI_BEGIN
  147 +
  148 + if(lib3270_connected(PW3270_SESSION))
  149 + rc = lib3270_emulate_input(PW3270_SESSION, env->GetStringUTFChars(str, 0), -1, (int) pasting);
  150 +
  151 + PW3270_JNI_END
  152 +
  153 + return rc;
  154 +}
android/res/layout/menu.xml
@@ -7,8 +7,6 @@ @@ -7,8 +7,6 @@
7 android:title="Conectar" /> 7 android:title="Conectar" />
8 <item android:id="@+id/disconnect" 8 <item android:id="@+id/disconnect"
9 android:title="Desconectar" /> 9 android:title="Desconectar" />
10 - <item android:id="@+id/reload"  
11 - android:title="Recarregar" />  
12 <item android:id="@+id/settings" 10 <item android:id="@+id/settings"
13 android:title="Configurar" /> 11 android:title="Configurar" />
14 <item android:id="@+id/about" 12 <item android:id="@+id/about"
android/res/xml/preferences.xml
@@ -46,6 +46,13 @@ @@ -46,6 +46,13 @@
46 android:defaultValue="false" 46 android:defaultValue="false"
47 /> 47 />
48 48
  49 + <EditTextPreference
  50 + android:key="logonstring"
  51 + android:title="String de conexão"
  52 + android:summary="Define texto a enviar ao conectar"
  53 + android:dialogTitle="String de conexão"
  54 + android:dialogMessage="Informe texto a enviar logo após a conexão"
  55 + android:defaultValue="" />
49 56
50 </PreferenceCategory> 57 </PreferenceCategory>
51 58
android/src/br/com/bb/pw3270/PW3270Activity.java
@@ -165,10 +165,6 @@ public class PW3270Activity extends Activity @@ -165,10 +165,6 @@ public class PW3270Activity extends Activity
165 startActivityForResult(myIntent, 0); 165 startActivityForResult(myIntent, 0);
166 break; 166 break;
167 167
168 - case R.id.reload:  
169 - host.view.reload();  
170 - break;  
171 -  
172 case R.id.about: 168 case R.id.about:
173 showAboutDialog(); 169 showAboutDialog();
174 break; 170 break;
android/src/br/com/bb/pw3270/SettingsActivity.java
@@ -70,6 +70,7 @@ public class SettingsActivity extends Activity @@ -70,6 +70,7 @@ public class SettingsActivity extends Activity
70 // Update summary from settings 70 // Update summary from settings
71 new stringSetting(findPreference("hostname")); 71 new stringSetting(findPreference("hostname"));
72 new stringSetting(findPreference("port")); 72 new stringSetting(findPreference("port"));
  73 + new stringSetting(findPreference("logonstring"));
73 74
74 } 75 }
75 76
android/src/br/com/bb/pw3270/lib3270.java
@@ -59,12 +59,12 @@ public abstract class lib3270 @@ -59,12 +59,12 @@ public abstract class lib3270
59 protected int screenState = -1; 59 protected int screenState = -1;
60 60
61 private lib3270 hSession = this; 61 private lib3270 hSession = this;
62 - 62 +
63 public ProgressDialog dlgSysMessage = null; 63 public ProgressDialog dlgSysMessage = null;
64 public WebView view = null; 64 public WebView view = null;
65 public Resources res = null; 65 public Resources res = null;
66 public Activity mainact = null; 66 public Activity mainact = null;
67 - 67 +
68 private static boolean initialized = false; 68 private static boolean initialized = false;
69 private static NetworkThread mainloop = null; 69 private static NetworkThread mainloop = null;
70 private static boolean connected = false; 70 private static boolean connected = false;
@@ -139,6 +139,25 @@ public abstract class lib3270 @@ -139,6 +139,25 @@ public abstract class lib3270
139 new timer(((Long) msg.obj).longValue(), msg.arg1); 139 new timer(((Long) msg.obj).longValue(), msg.arg1);
140 break; 140 break;
141 141
  142 + case 10: // Run autostart
  143 + Log.v(TAG, "AAA---------------------------------------------------------------");
  144 + Log.v(TAG, "In3270="+(in3270() ? "Yes" : "No"));
  145 +
  146 + /*
  147 + String str = settings.getString("logonstring","");
  148 + Log.v(TAG, "Logon string is \"" + str + "\"");
  149 + if( str != "")
  150 + {
  151 + int sz = input(str,0);
  152 + Log.v(TAG, "Input exits with "+sz);
  153 + }
  154 + */
  155 +
  156 + Log.v(TAG, "Contents:\n" + getText() + "\n");
  157 +
  158 + Log.v(TAG, "AAA---------------------------------------------------------------");
  159 + break;
  160 +
142 } 161 }
143 } 162 }
144 }; 163 };
@@ -157,7 +176,7 @@ public abstract class lib3270 @@ -157,7 +176,7 @@ public abstract class lib3270
157 this.screenState = -1; 176 this.screenState = -1;
158 177
159 for(int f = 0; f < toggle.length; f++) 178 for(int f = 0; f < toggle.length; f++)
160 - setToggle(toggle[f],settings.getBoolean(toggle[f],false)); 179 + setToggle(toggle[f],settings.getBoolean(toggle[f],true));
161 180
162 } 181 }
163 182
@@ -301,12 +320,12 @@ public abstract class lib3270 @@ -301,12 +320,12 @@ public abstract class lib3270
301 320
302 while (connected) 321 while (connected)
303 { 322 {
304 - byte[] in = new byte[4096]; 323 + byte[] in = new byte[16384];
305 int sz = -1; 324 int sz = -1;
306 325
307 try 326 try
308 { 327 {
309 - sz = inData.read(in, 0, 4096); 328 + sz = inData.read(in, 0, 16384);
310 329
311 } catch (Exception e) 330 } catch (Exception e)
312 { 331 {
@@ -365,18 +384,18 @@ public abstract class lib3270 @@ -365,18 +384,18 @@ public abstract class lib3270
365 msg.obj = new popupMessageInfo(title, text, info); 384 msg.obj = new popupMessageInfo(title, text, info);
366 mHandler.sendMessage(msg); 385 mHandler.sendMessage(msg);
367 } 386 }
368 - 387 +
369 void setActivity(Activity act) 388 void setActivity(Activity act)
370 { 389 {
371 this.mainact = act; 390 this.mainact = act;
372 this.settings = PreferenceManager.getDefaultSharedPreferences(act); 391 this.settings = PreferenceManager.getDefaultSharedPreferences(act);
373 this.res = act.getResources(); 392 this.res = act.getResources();
374 } 393 }
375 - 394 +
376 WebView setView(WebView v) 395 WebView setView(WebView v)
377 { 396 {
378 this.view = v; 397 this.view = v;
379 - 398 +
380 view.addJavascriptInterface(this, "pw3270"); 399 view.addJavascriptInterface(this, "pw3270");
381 400
382 view.setWebChromeClient(new WebChromeClient()); 401 view.setWebChromeClient(new WebChromeClient());
@@ -388,11 +407,11 @@ public abstract class lib3270 @@ -388,11 +407,11 @@ public abstract class lib3270
388 view.getSettings().setJavaScriptEnabled(true); 407 view.getSettings().setJavaScriptEnabled(true);
389 408
390 return view; 409 return view;
391 - 410 +
392 } 411 }
393 - 412 +
394 public abstract String getProgramMessageText(int id); 413 public abstract String getProgramMessageText(int id);
395 - 414 +
396 /*---[ Signal methods ]--------------------------------------------------*/ 415 /*---[ Signal methods ]--------------------------------------------------*/
397 416
398 protected void showProgramMessage(int id) 417 protected void showProgramMessage(int id)
@@ -403,7 +422,6 @@ public abstract class lib3270 @@ -403,7 +422,6 @@ public abstract class lib3270
403 if(screenState != 0) 422 if(screenState != 0)
404 { 423 {
405 screenState = 0; 424 screenState = 0;
406 -// Log.v(TAG, "Status changed to NONE");  
407 reload(); 425 reload();
408 } 426 }
409 break; 427 break;
@@ -558,8 +576,8 @@ public abstract class lib3270 @@ -558,8 +576,8 @@ public abstract class lib3270
558 576
559 return text; 577 return text;
560 } 578 }
561 -  
562 - 579 +
  580 +
563 /*---[ Native calls ]----------------------------------------------------*/ 581 /*---[ Native calls ]----------------------------------------------------*/
564 private native int processEvents(); 582 private native int processEvents();
565 583
@@ -614,4 +632,7 @@ public abstract class lib3270 @@ -614,4 +632,7 @@ public abstract class lib3270
614 632
615 public native void setTextAt(int offset, byte[] str, int len); 633 public native void setTextAt(int offset, byte[] str, int len);
616 634
  635 + public native int input(String text, int pasting);
  636 +
  637 + public native boolean in3270();
617 } 638 }
@@ -356,7 +356,6 @@ AC_CONFIG_FILES([ @@ -356,7 +356,6 @@ AC_CONFIG_FILES([
356 src/lib3270/mkversion.sh 356 src/lib3270/mkversion.sh
357 src/pw3270/Makefile 357 src/pw3270/Makefile
358 src/pw3270/uiparser/Makefile 358 src/pw3270/uiparser/Makefile
359 - src/pw3270/common/common.h  
360 src/tools/Makefile 359 src/tools/Makefile
361 man/Makefile 360 man/Makefile
362 makegtkruntime.sh 361 makegtkruntime.sh
@@ -219,7 +219,7 @@ @@ -219,7 +219,7 @@
219 <Unit filename="src/pw3270/colors.c"> 219 <Unit filename="src/pw3270/colors.c">
220 <Option compilerVar="CC" /> 220 <Option compilerVar="CC" />
221 </Unit> 221 </Unit>
222 - <Unit filename="src/pw3270/common/common.h.in" /> 222 + <Unit filename="src/pw3270/common/common.h" />
223 <Unit filename="src/pw3270/common/config.c"> 223 <Unit filename="src/pw3270/common/config.c">
224 <Option compilerVar="CC" /> 224 <Option compilerVar="CC" />
225 </Unit> 225 </Unit>
src/include/lib3270.h
@@ -172,7 +172,7 @@ @@ -172,7 +172,7 @@
172 LIB3270_MESSAGE_NONE, /**< No message */ 172 LIB3270_MESSAGE_NONE, /**< No message */
173 LIB3270_MESSAGE_SYSWAIT, 173 LIB3270_MESSAGE_SYSWAIT,
174 LIB3270_MESSAGE_TWAIT, 174 LIB3270_MESSAGE_TWAIT,
175 - LIB3270_MESSAGE_CONNECTED, 175 + LIB3270_MESSAGE_CONNECTED, /**< Connected */
176 LIB3270_MESSAGE_DISCONNECTED, /**< Disconnected from host */ 176 LIB3270_MESSAGE_DISCONNECTED, /**< Disconnected from host */
177 LIB3270_MESSAGE_AWAITING_FIRST, 177 LIB3270_MESSAGE_AWAITING_FIRST,
178 LIB3270_MESSAGE_MINUS, 178 LIB3270_MESSAGE_MINUS,
@@ -443,7 +443,7 @@ @@ -443,7 +443,7 @@
443 * 443 *
444 * @return The number of unprocessed characters. 444 * @return The number of unprocessed characters.
445 */ 445 */
446 - LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting); 446 + LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, const char *s, int len, int pasting);
447 447
448 /** 448 /**
449 * Set string at current cursor position. 449 * Set string at current cursor position.
src/include/lib3270/log.h
@@ -39,10 +39,14 @@ @@ -39,10 +39,14 @@
39 39
40 #include <android/log.h> 40 #include <android/log.h>
41 41
  42 + #define DEBUG 1
  43 +
42 #define lib3270_write_log(s,m,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ ) 44 #define lib3270_write_log(s,m,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ )
43 #define lib3270_write_rc(s,m,r,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ ) 45 #define lib3270_write_rc(s,m,r,f,...) __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", __VA_ARGS__ )
44 #define lib3270_write_va_log(s,m,f,a) __android_log_vprint(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", a) 46 #define lib3270_write_va_log(s,m,f,a) __android_log_vprint(ANDROID_LOG_VERBOSE, PACKAGE_NAME, f "\n", a)
45 47
  48 + #define trace( fmt, ... ) __android_log_print(ANDROID_LOG_DEBUG, PACKAGE_NAME, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ );
  49 +
46 #else 50 #else
47 51
48 LIB3270_EXPORT void lib3270_set_log_handler(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); 52 LIB3270_EXPORT void lib3270_set_log_handler(void (*loghandler)(H3270 *, const char *, int, const char *, va_list));
@@ -50,13 +54,14 @@ @@ -50,13 +54,14 @@
50 LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, const char *fmt, ...) LIB3270_GNUC_FORMAT(4,5); 54 LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, const char *fmt, ...) LIB3270_GNUC_FORMAT(4,5);
51 LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg); 55 LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg);
52 56
  57 + #ifdef DEBUG
  58 + #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);
  59 + #else
  60 + #define trace(x, ...) // __VA_ARGS__
  61 + #endif
  62 +
53 #endif // ANDROID 63 #endif // ANDROID
54 64
55 - #ifdef DEBUG  
56 - #define trace( fmt, ... ) fprintf(stderr, "%s(%d) " fmt "\n", __FILE__, __LINE__, __VA_ARGS__ ); fflush(stderr);  
57 - #else  
58 - #define trace(x, ...) // __VA_ARGS__  
59 - #endif  
60 65
61 #endif // LIB3270_LOG_H_INCLUDED 66 #endif // LIB3270_LOG_H_INCLUDED
62 67
src/include/lib3270/session.h
@@ -110,6 +110,8 @@ @@ -110,6 +110,8 @@
110 int need_tls_follows : 1; 110 int need_tls_follows : 1;
111 int cut_xfer_in_progress : 1; 111 int cut_xfer_in_progress : 1;
112 int auto_keymap : 1; 112 int auto_keymap : 1;
  113 + int formatted : 1; /**< Formatted screen flag */
  114 + int starting : 1; /**< Is starting (no first screen)? */
113 115
114 char * oversize; 116 char * oversize;
115 117
@@ -162,8 +164,6 @@ @@ -162,8 +164,6 @@
162 int screen_alt; /**< alternate screen? */ 164 int screen_alt; /**< alternate screen? */
163 int is_altbuffer; 165 int is_altbuffer;
164 166
165 - int formatted; /**< set in screen_disp */  
166 -  
167 // Screen contents 167 // Screen contents
168 void * buffer[2]; /**< Internal buffers */ 168 void * buffer[2]; /**< Internal buffers */
169 struct lib3270_ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */ 169 struct lib3270_ea * ea_buf; /**< 3270 device buffer. ea_buf[-1] is the dummy default field attribute */
@@ -401,6 +401,7 @@ @@ -401,6 +401,7 @@
401 void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); 401 void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols);
402 void (*update_selection)(H3270 *session, int start, int end); 402 void (*update_selection)(H3270 *session, int start, int end);
403 void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state); 403 void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state);
  404 +// void (*update_formatted)(H3270 *session,int state);
404 405
405 void (*set_timer)(H3270 *session, unsigned char on); 406 void (*set_timer)(H3270 *session, unsigned char on);
406 void (*erase)(H3270 *session); 407 void (*erase)(H3270 *session);
@@ -409,6 +410,7 @@ @@ -409,6 +410,7 @@
409 void (*cursor)(H3270 *session, LIB3270_CURSOR id); 410 void (*cursor)(H3270 *session, LIB3270_CURSOR id);
410 void (*set_selection)(H3270 *session, unsigned char on); 411 void (*set_selection)(H3270 *session, unsigned char on);
411 void (*ctlr_done)(H3270 *session); 412 void (*ctlr_done)(H3270 *session);
  413 + void (*autostart)(H3270 *session);
412 414
413 void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); 415 void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text);
414 416
src/include/pw3270.h
@@ -61,6 +61,12 @@ @@ -61,6 +61,12 @@
61 LIB3270_EXPORT void pw3270_save_window_state(GtkWidget *widget, const gchar *name); 61 LIB3270_EXPORT void pw3270_save_window_state(GtkWidget *widget, const gchar *name);
62 LIB3270_EXPORT void pw3270_restore_window_state(GtkWidget *widget, const gchar *name); 62 LIB3270_EXPORT void pw3270_restore_window_state(GtkWidget *widget, const gchar *name);
63 63
  64 +#ifdef HAVE_GTKMAC
  65 + LIB3270_EXPORT GtkMacBundle * pw3270_get_bundle(void);
  66 +#endif
  67 +
  68 +
  69 +
64 G_END_DECLS 70 G_END_DECLS
65 71
66 #endif // PW3270_H_INCLUDED 72 #endif // PW3270_H_INCLUDED
src/lib3270/ctlr.c
@@ -67,7 +67,8 @@ @@ -67,7 +67,8 @@
67 // Boolean dbcs = False; 67 // Boolean dbcs = False;
68 68
69 /* Statics */ 69 /* Statics */
70 -static void set_formatted(H3270 *session); 70 +static void update_formatted(H3270 *session);
  71 +static void set_formatted(H3270 *hSession, int state);
71 static void ctlr_blanks(H3270 *session); 72 static void ctlr_blanks(H3270 *session);
72 static void ctlr_half_connect(H3270 *session, int ignored, void *dunno); 73 static void ctlr_half_connect(H3270 *session, int ignored, void *dunno);
73 static void ctlr_connect(H3270 *session, int ignored, void *dunno); 74 static void ctlr_connect(H3270 *session, int ignored, void *dunno);
@@ -224,37 +225,50 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) @@ -224,37 +225,50 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr)
224 225
225 set_viewsize(session,sz[idx].rows,sz[idx].cols); 226 set_viewsize(session,sz[idx].rows,sz[idx].cols);
226 227
227 - /*  
228 - // Make sure that the current rows/cols are still 24x80.  
229 - session->cols = 80;  
230 - session->rows = 24;  
231 - session->screen_alt = 0;  
232 - */  
233 -  
234 } 228 }
235 229
236 - 230 +static void set_formatted(H3270 *hSession, int state)
  231 +{
  232 + hSession->formatted = state;
237 /* 233 /*
238 - * Set the formatted screen flag. A formatted screen is a screen that  
239 - * has at least one field somewhere on it. 234 + int last = (int) hSession->formatted;
  235 + hSession->formatted = state;
  236 +
  237 + if( ((int) hSession->formatted) != last)
  238 + {
  239 + trace("Screen is now %s",hSession->formatted ? "formatted" : "unformatted");
  240 + hSession->update_formatted(hSession,hSession->formatted);
  241 + }
  242 +*/
  243 + trace("Screen is now %s",hSession->formatted ? "formatted" : "unformatted");
  244 +}
  245 +
  246 +/**
  247 + * Update the formatted screen flag.
  248 + *
  249 + * A formatted screen is a screen that has at least one field somewhere on it.
  250 + *
  251 + * @param hSession Session Handle
240 */ 252 */
241 -static void set_formatted(H3270 *hSession) 253 +static void update_formatted(H3270 *hSession)
242 { 254 {
243 register int baddr; 255 register int baddr;
244 256
245 CHECK_SESSION_HANDLE(hSession); 257 CHECK_SESSION_HANDLE(hSession);
246 258
247 - hSession->formatted = False;  
248 baddr = 0; 259 baddr = 0;
249 do 260 do
250 { 261 {
251 if(hSession->ea_buf[baddr].fa) 262 if(hSession->ea_buf[baddr].fa)
252 { 263 {
253 - hSession->formatted = True;  
254 - break; 264 + set_formatted(hSession,1);
  265 + return;
255 } 266 }
256 INC_BA(baddr); 267 INC_BA(baddr);
257 } while (baddr != 0); 268 } while (baddr != 0);
  269 +
  270 + set_formatted(hSession,0);
  271 +
258 } 272 }
259 273
260 /* 274 /*
@@ -277,6 +291,7 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) @@ -277,6 +291,7 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno)
277 hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; 291 hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY;
278 else 292 else
279 hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT; 293 hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT;
  294 +
280 if (!IN_3270 || (IN_SSCP && (hSession->kybdlock & KL_OIA_TWAIT))) 295 if (!IN_3270 || (IN_SSCP && (hSession->kybdlock & KL_OIA_TWAIT)))
281 { 296 {
282 lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT); 297 lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT);
@@ -292,8 +307,6 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) @@ -292,8 +307,6 @@ static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno)
292 hSession->crm_nattr = 0; 307 hSession->crm_nattr = 0;
293 } 308 }
294 309
295 -  
296 -  
297 LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) 310 LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr)
298 { 311 {
299 int sbaddr; 312 int sbaddr;
@@ -886,7 +899,8 @@ void ctlr_erase_all_unprotected(H3270 *hSession) @@ -886,7 +899,8 @@ void ctlr_erase_all_unprotected(H3270 *hSession)
886 899
887 kybd_inhibit(hSession,False); 900 kybd_inhibit(hSession,False);
888 901
889 - if (hSession->formatted) { 902 + if (hSession->formatted)
  903 + {
890 /* find first field attribute */ 904 /* find first field attribute */
891 baddr = 0; 905 baddr = 0;
892 do { 906 do {
@@ -975,7 +989,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er @@ -975,7 +989,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
975 ctlr_add_gr(hSession,hSession->buffer_addr, 0); \ 989 ctlr_add_gr(hSession,hSession->buffer_addr, 0); \
976 ctlr_add_ic(hSession,hSession->buffer_addr, 0); \ 990 ctlr_add_ic(hSession,hSession->buffer_addr, 0); \
977 trace_ds(hSession,"%s",see_attr(fa)); \ 991 trace_ds(hSession,"%s",see_attr(fa)); \
978 - hSession->formatted = True; \ 992 + set_formatted(hSession,1); \
979 } 993 }
980 994
981 kybd_inhibit(hSession,False); 995 kybd_inhibit(hSession,False);
@@ -1721,7 +1735,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er @@ -1721,7 +1735,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er
1721 break; 1735 break;
1722 } 1736 }
1723 } 1737 }
1724 - set_formatted(hSession); 1738 + update_formatted(hSession);
1725 END_TEXT0; 1739 END_TEXT0;
1726 trace_ds(hSession,"\n"); 1740 trace_ds(hSession,"\n");
1727 if (wcc_keyboard_restore) { 1741 if (wcc_keyboard_restore) {
@@ -2196,7 +2210,7 @@ ctlr_clear(H3270 *session, Boolean can_snap) @@ -2196,7 +2210,7 @@ ctlr_clear(H3270 *session, Boolean can_snap)
2196 cursor_move(session,0); 2210 cursor_move(session,0);
2197 session->buffer_addr = 0; 2211 session->buffer_addr = 0;
2198 lib3270_unselect(session); 2212 lib3270_unselect(session);
2199 - session->formatted = False; 2213 + set_formatted(session,0);
2200 session->default_fg = 0; 2214 session->default_fg = 0;
2201 session->default_bg = 0; 2215 session->default_bg = 0;
2202 session->default_gr = 0; 2216 session->default_gr = 0;
@@ -2225,7 +2239,7 @@ static void ctlr_blanks(H3270 *session) @@ -2225,7 +2239,7 @@ static void ctlr_blanks(H3270 *session)
2225 cursor_move(session,0); 2239 cursor_move(session,0);
2226 session->buffer_addr = 0; 2240 session->buffer_addr = 0;
2227 lib3270_unselect(session); 2241 lib3270_unselect(session);
2228 - session->formatted = False; 2242 + set_formatted(session,0);
2229 ALL_CHANGED(session); 2243 ALL_CHANGED(session);
2230 } 2244 }
2231 2245
src/lib3270/host.c
@@ -706,7 +706,9 @@ void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate) @@ -706,7 +706,9 @@ void host_in3270(H3270 *hSession, LIB3270_CSTATE new_cstate)
706 706
707 void lib3270_set_connected(H3270 *hSession) 707 void lib3270_set_connected(H3270 *hSession)
708 { 708 {
709 - hSession->cstate = CONNECTED_INITIAL; 709 + hSession->cstate = CONNECTED_INITIAL;
  710 + hSession->starting = 1; // Enable autostart
  711 +
710 lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True); 712 lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True);
711 if(hSession->update_connect) 713 if(hSession->update_connect)
712 hSession->update_connect(hSession,1); 714 hSession->update_connect(hSession,1);
@@ -716,7 +718,9 @@ void lib3270_set_disconnected(H3270 *hSession) @@ -716,7 +718,9 @@ void lib3270_set_disconnected(H3270 *hSession)
716 { 718 {
717 CHECK_SESSION_HANDLE(hSession); 719 CHECK_SESSION_HANDLE(hSession);
718 720
719 - hSession->cstate = NOT_CONNECTED; 721 + hSession->cstate = NOT_CONNECTED;
  722 + hSession->starting = 0;
  723 +
720 set_status(hSession,OIA_FLAG_UNDERA,False); 724 set_status(hSession,OIA_FLAG_UNDERA,False);
721 lib3270_st_changed(hSession,LIB3270_STATE_CONNECT, False); 725 lib3270_st_changed(hSession,LIB3270_STATE_CONNECT, False);
722 status_changed(hSession,LIB3270_MESSAGE_DISCONNECTED); 726 status_changed(hSession,LIB3270_MESSAGE_DISCONNECTED);
src/lib3270/kybd.c
@@ -1209,7 +1209,8 @@ LIB3270_ACTION( firstfield ) @@ -1209,7 +1209,8 @@ LIB3270_ACTION( firstfield )
1209 return 0; 1209 return 0;
1210 } 1210 }
1211 #endif /*]*/ 1211 #endif /*]*/
1212 - if (!hSession->formatted) { 1212 + if (!hSession->formatted)
  1213 + {
1213 cursor_move(hSession,0); 1214 cursor_move(hSession,0);
1214 return 0; 1215 return 0;
1215 } 1216 }
@@ -2066,8 +2067,10 @@ LIB3270_ACTION( eraseeof ) @@ -2066,8 +2067,10 @@ LIB3270_ACTION( eraseeof )
2066 operator_error(hSession,KL_OERR_PROTECTED); 2067 operator_error(hSession,KL_OERR_PROTECTED);
2067 return -1; 2068 return -1;
2068 } 2069 }
2069 - if (hSession->formatted) { /* erase to next field attribute */  
2070 - do { 2070 + if (hSession->formatted)
  2071 + { /* erase to next field attribute */
  2072 + do
  2073 + {
2071 ctlr_add(hSession,baddr, EBC_null, 0); 2074 ctlr_add(hSession,baddr, EBC_null, 0);
2072 INC_BA(baddr); 2075 INC_BA(baddr);
2073 } while (!hSession->ea_buf[baddr].fa); 2076 } while (!hSession->ea_buf[baddr].fa);
@@ -2109,7 +2112,8 @@ LIB3270_ACTION( eraseinput ) @@ -2109,7 +2112,8 @@ LIB3270_ACTION( eraseinput )
2109 if (IN_ANSI) 2112 if (IN_ANSI)
2110 return 0; 2113 return 0;
2111 #endif /*]*/ 2114 #endif /*]*/
2112 - if (hSession->formatted) { 2115 + if (hSession->formatted)
  2116 + {
2113 /* find first field attribute */ 2117 /* find first field attribute */
2114 baddr = 0; 2118 baddr = 0;
2115 do { 2119 do {
@@ -2170,7 +2174,8 @@ LIB3270_ACTION( deleteword ) @@ -2170,7 +2174,8 @@ LIB3270_ACTION( deleteword )
2170 return 0; 2174 return 0;
2171 } 2175 }
2172 #if defined(X3270_ANSI) /*[*/ 2176 #if defined(X3270_ANSI) /*[*/
2173 - if (IN_ANSI) { 2177 + if (IN_ANSI)
  2178 + {
2174 net_send_werase(hSession); 2179 net_send_werase(hSession);
2175 return 0; 2180 return 0;
2176 } 2181 }
@@ -2455,7 +2460,7 @@ static Boolean remargin(H3270 *hSession, int lmargin) @@ -2455,7 +2460,7 @@ static Boolean remargin(H3270 *hSession, int lmargin)
2455 return True; 2460 return True;
2456 } 2461 }
2457 2462
2458 -LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int pasting) 2463 +LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, const char *s, int len, int pasting)
2459 { 2464 {
2460 enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE; 2465 enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE;
2461 int literal = 0; 2466 int literal = 0;
@@ -2474,7 +2479,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int @@ -2474,7 +2479,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int
2474 UChar *ws; 2479 UChar *ws;
2475 #else /*][*/ 2480 #else /*][*/
2476 char c; 2481 char c;
2477 - char *ws; 2482 + const char *ws;
2478 #endif /*]*/ 2483 #endif /*]*/
2479 2484
2480 CHECK_SESSION_HANDLE(hSession); 2485 CHECK_SESSION_HANDLE(hSession);
src/lib3270/resolver.c
@@ -183,10 +183,10 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p) @@ -183,10 +183,10 @@ static int cresolve_host_and_port(H3270 *h, struct parms *p)
183 int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_len) 183 int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, unsigned short *pport,struct sockaddr *sa, socklen_t *sa_len, char *errmsg, int em_len)
184 { 184 {
185 int rc; 185 int rc;
186 - LIB3270_STATUS saved_status = hSession->oia_status; 186 + LIB3270_MESSAGE saved_status = hSession->oia_status;
187 struct parms p = { sizeof(struct parms), host, portname, pport, sa, sa_len, errmsg, em_len }; 187 struct parms p = { sizeof(struct parms), host, portname, pport, sa, sa_len, errmsg, em_len };
188 188
189 - trace("Calling resolver for %s", p.host); 189 + trace("Calling resolver for %s status=%d", p.host, (int) saved_status);
190 190
191 status_changed(hSession,LIB3270_STATUS_RESOLVING); 191 status_changed(hSession,LIB3270_STATUS_RESOLVING);
192 hSession->cursor(hSession,CURSOR_MODE_LOCKED); 192 hSession->cursor(hSession,CURSOR_MODE_LOCKED);
@@ -194,7 +194,9 @@ int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, uns @@ -194,7 +194,9 @@ int resolve_host_and_port(H3270 *hSession, const char *host, char *portname, uns
194 rc = lib3270_call_thread((int (*)(H3270 *, void *)) cresolve_host_and_port,hSession,&p); 194 rc = lib3270_call_thread((int (*)(H3270 *, void *)) cresolve_host_and_port,hSession,&p);
195 195
196 hSession->cursor(hSession,CURSOR_MODE_NORMAL); 196 hSession->cursor(hSession,CURSOR_MODE_NORMAL);
197 - status_changed(hSession,saved_status); 197 +
  198 + if(saved_status != -1)
  199 + status_changed(hSession,saved_status);
198 200
199 trace("Calling resolver for %s exits with %d", p.host, rc); 201 trace("Calling resolver for %s exits with %d", p.host, rc);
200 202
src/lib3270/screen.c
@@ -372,7 +372,21 @@ void screen_update(H3270 *session, int bstart, int bend) @@ -372,7 +372,21 @@ void screen_update(H3270 *session, int bstart, int bend)
372 session->changed(session,first,len); 372 session->changed(session,first,len);
373 } 373 }
374 374
375 - trace("%s ends",__FUNCTION__); 375 + if(session->starting && session->formatted && lib3270_in_3270(session))
  376 + {
  377 + session->starting = 0;
  378 + session->autostart(session);
  379 +#ifdef DEBUG
  380 + {
  381 + char *text = lib3270_get_text(session,0,-1);
  382 + trace("First screen:\n%s\n",text);
  383 + lib3270_free(text);
  384 + }
  385 +#endif
  386 + }
  387 +
  388 +// trace("%s ends",__FUNCTION__);
  389 +
376 } 390 }
377 391
378 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h) 392 LIB3270_EXPORT int lib3270_get_cursor_address(H3270 *h)
@@ -426,20 +440,20 @@ void status_ctlr_done(H3270 *session) @@ -426,20 +440,20 @@ void status_ctlr_done(H3270 *session)
426 440
427 void status_oerr(H3270 *session, int error_type) 441 void status_oerr(H3270 *session, int error_type)
428 { 442 {
429 - LIB3270_STATUS sts = LIB3270_STATUS_USER; 443 + LIB3270_STATUS sts = LIB3270_MESSAGE_USER;
430 444
431 CHECK_SESSION_HANDLE(session); 445 CHECK_SESSION_HANDLE(session);
432 446
433 switch (error_type) 447 switch (error_type)
434 { 448 {
435 case KL_OERR_PROTECTED: 449 case KL_OERR_PROTECTED:
436 - sts = LIB3270_STATUS_PROTECTED; 450 + sts = LIB3270_MESSAGE_PROTECTED;
437 break; 451 break;
438 case KL_OERR_NUMERIC: 452 case KL_OERR_NUMERIC:
439 - sts = LIB3270_STATUS_NUMERIC; 453 + sts = LIB3270_MESSAGE_NUMERIC;
440 break; 454 break;
441 case KL_OERR_OVERFLOW: 455 case KL_OERR_OVERFLOW:
442 - sts = LIB3270_STATUS_OVERFLOW; 456 + sts = LIB3270_MESSAGE_OVERFLOW;
443 break; 457 break;
444 458
445 default: 459 default:
@@ -453,9 +467,9 @@ void status_oerr(H3270 *session, int error_type) @@ -453,9 +467,9 @@ void status_oerr(H3270 *session, int error_type)
453 void status_connecting(H3270 *session, Boolean on) 467 void status_connecting(H3270 *session, Boolean on)
454 { 468 {
455 if(session->cursor) 469 if(session->cursor)
456 - session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); 470 + session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL);
457 471
458 - status_changed(session, on ? LIB3270_STATUS_CONNECTING : LIB3270_STATUS_BLANK); 472 + status_changed(session, on ? LIB3270_MESSAGE_CONNECTING : LIB3270_MESSAGE_NONE);
459 } 473 }
460 474
461 void status_reset(H3270 *session) 475 void status_reset(H3270 *session)
@@ -464,17 +478,17 @@ void status_reset(H3270 *session) @@ -464,17 +478,17 @@ void status_reset(H3270 *session)
464 478
465 if (session->kybdlock & KL_ENTER_INHIBIT) 479 if (session->kybdlock & KL_ENTER_INHIBIT)
466 { 480 {
467 - status_changed(session,LIB3270_STATUS_INHIBIT); 481 + status_changed(session,LIB3270_MESSAGE_INHIBIT);
468 } 482 }
469 else if (session->kybdlock & KL_DEFERRED_UNLOCK) 483 else if (session->kybdlock & KL_DEFERRED_UNLOCK)
470 { 484 {
471 - status_changed(session,LIB3270_STATUS_X); 485 + status_changed(session,LIB3270_MESSAGE_X);
472 } 486 }
473 else 487 else
474 { 488 {
475 if(session->cursor) 489 if(session->cursor)
476 session->cursor(session,CURSOR_MODE_NORMAL); 490 session->cursor(session,CURSOR_MODE_NORMAL);
477 - status_changed(session,LIB3270_STATUS_BLANK); 491 + status_changed(session,LIB3270_MESSAGE_NONE);
478 } 492 }
479 493
480 session->display(session); 494 session->display(session);
@@ -503,8 +517,7 @@ void status_changed(H3270 *session, LIB3270_STATUS id) @@ -503,8 +517,7 @@ void status_changed(H3270 *session, LIB3270_STATUS id)
503 517
504 session->oia_status = id; 518 session->oia_status = id;
505 519
506 - if(session->update_status)  
507 - session->update_status(session,id); 520 + session->update_status(session,id);
508 } 521 }
509 522
510 void status_twait(H3270 *session) 523 void status_twait(H3270 *session)
src/lib3270/selection.c
@@ -378,7 +378,7 @@ static char * get_text(H3270 *hSession,unsigned char all) @@ -378,7 +378,7 @@ static char * get_text(H3270 *hSession,unsigned char all)
378 size_t buflen = (hSession->rows * (hSession->cols+1))+1; 378 size_t buflen = (hSession->rows * (hSession->cols+1))+1;
379 size_t sz = 0; 379 size_t sz = 0;
380 380
381 - if(!lib3270_connected(hSession)) 381 + if(!(lib3270_connected(hSession) && hSession->text))
382 return NULL; 382 return NULL;
383 383
384 ret = lib3270_malloc(buflen); 384 ret = lib3270_malloc(buflen);
src/lib3270/session.c
@@ -160,7 +160,7 @@ static void screen_disp(H3270 *session) @@ -160,7 +160,7 @@ static void screen_disp(H3270 *session)
160 screen_update(session,0,session->rows*session->cols); 160 screen_update(session,0,session->rows*session->cols);
161 } 161 }
162 162
163 -static void set_width(H3270 *session, int width) 163 +static void nop_int(H3270 *session, int width)
164 { 164 {
165 return; 165 return;
166 } 166 }
@@ -194,7 +194,9 @@ static void lib3270_session_init(H3270 *hSession, const char *model) @@ -194,7 +194,9 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
194 hSession->message = message; 194 hSession->message = message;
195 hSession->update_ssl = update_ssl; 195 hSession->update_ssl = update_ssl;
196 hSession->display = screen_disp; 196 hSession->display = screen_disp;
197 - hSession->set_width = set_width; 197 + hSession->set_width = nop_int;
  198 + hSession->update_status = (void (*)(H3270 *, LIB3270_STATUS)) nop_int;
  199 + hSession->autostart = nop;
198 200
199 // Set the defaults. 201 // Set the defaults.
200 hSession->extended = 1; 202 hSession->extended = 1;
@@ -425,7 +427,11 @@ void check_session_handle(H3270 **hSession) @@ -425,7 +427,11 @@ void check_session_handle(H3270 **hSession)
425 427
426 *hSession = lib3270_get_default_session_handle(); 428 *hSession = lib3270_get_default_session_handle();
427 429
  430 +#ifdef ANDROID
  431 + __android_log_print(ANDROID_LOG_VERBOSE, PACKAGE_NAME, "%s called with empty session\n", __FUNCTION__);
  432 +#else
428 lib3270_write_log(*hSession,"%s called with empty session",__FUNCTION__); 433 lib3270_write_log(*hSession,"%s called with empty session",__FUNCTION__);
  434 +#endif // ANDROID
429 } 435 }
430 436
431 LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void) 437 LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void)
src/lib3270/telnet.c
@@ -1300,9 +1300,11 @@ static int telnet_fsm(H3270 *hSession, unsigned char c) @@ -1300,9 +1300,11 @@ static int telnet_fsm(H3270 *hSession, unsigned char c)
1300 hSession->ns_rrcvd++; 1300 hSession->ns_rrcvd++;
1301 if (process_eor(hSession)) 1301 if (process_eor(hSession))
1302 return -1; 1302 return -1;
1303 - } else 1303 + }
  1304 + else
  1305 + {
1304 Warning(hSession, _( "EOR received when not in 3270 mode, ignored." )); 1306 Warning(hSession, _( "EOR received when not in 3270 mode, ignored." ));
1305 - 1307 + }
1306 trace_dsn(hSession,"RCVD EOR\n"); 1308 trace_dsn(hSession,"RCVD EOR\n");
1307 hSession->ibptr = hSession->ibuf; 1309 hSession->ibptr = hSession->ibuf;
1308 hSession->telnet_state = TNS_DATA; 1310 hSession->telnet_state = TNS_DATA;
@@ -1900,6 +1902,7 @@ static void process_bind(H3270 *hSession, unsigned char *buf, int buflen) @@ -1900,6 +1902,7 @@ static void process_bind(H3270 *hSession, unsigned char *buf, int buflen)
1900 static int 1902 static int
1901 process_eor(H3270 *hSession) 1903 process_eor(H3270 *hSession)
1902 { 1904 {
  1905 + trace("%s: syncing=%s",__FUNCTION__,hSession->syncing ? "Yes" : "No");
1903 if (hSession->syncing || !(hSession->ibptr - hSession->ibuf)) 1906 if (hSession->syncing || !(hSession->ibptr - hSession->ibuf))
1904 return(0); 1907 return(0);
1905 1908
src/pw3270/common/common.h 0 → 100644
@@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como common.h e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 +#ifndef COMMON_H_INCLUDED
  31 +
  32 + #define COMMON_H_INCLUDED 1
  33 +
  34 + // "PW" Standards
  35 + #include <gtk/gtk.h>
  36 + #include <errno.h>
  37 + #include <lib3270/config.h>
  38 +
  39 + #ifdef WIN32
  40 +
  41 + #include <windows.h>
  42 + #define WIN_REGISTRY_ENABLED 1
  43 +
  44 + #ifndef KEY_WOW64_64KEY
  45 + #define KEY_WOW64_64KEY 0x0100
  46 + #endif // KEY_WOW64_64KEY
  47 +
  48 + #ifndef KEY_WOW64_32KEY
  49 + #define KEY_WOW64_32KEY 0x0200
  50 + #endif // KEY_WOW64_64KEY
  51 +
  52 + #endif // WIN32
  53 +
  54 + #define ENABLE_NLS
  55 +
  56 + #ifndef GETTEXT_PACKAGE
  57 + #define GETTEXT_PACKAGE PACKAGE_NAME
  58 + #endif
  59 +
  60 + #include <libintl.h>
  61 + #include <glib/gi18n.h>
  62 + #include <gtk/gtk.h>
  63 +
  64 + #if defined( DEBUG )
  65 + #define trace(x, ...) fprintf(stderr,"%s(%d):\t" x "\n",__FILE__,__LINE__, __VA_ARGS__); fflush(stderr);
  66 + #else
  67 + #define trace(x, ...) /* */
  68 + #endif
  69 +
  70 + // Configuration
  71 + void configuration_init(void);
  72 + void configuration_deinit(void);
  73 +
  74 + gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def);
  75 + gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def);
  76 + gint get_integer_from_config(const gchar *group, const gchar *key, gint def);
  77 +
  78 + void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...);
  79 + void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val);
  80 + void set_integer_to_config(const gchar *group, const gchar *key, gint val);
  81 +
  82 + gchar * build_data_filename(const gchar *first_element, ...);
  83 + gchar * filename_from_va(const gchar *first_element, va_list args);
  84 +
  85 + void save_window_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd);
  86 + void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd);
  87 +
  88 +#ifdef WIN_REGISTRY_ENABLED
  89 + gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired);
  90 + void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);
  91 + void registry_set_double(HKEY hKey, const gchar *key, gdouble value);
  92 + gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);
  93 +#else
  94 + GKeyFile * get_application_keyfile(void);
  95 +#endif // WIN_REGISTRY_ENABLED
  96 +
  97 +
  98 +#endif
src/pw3270/common/common.h.in
@@ -1,100 +0,0 @@ @@ -1,100 +0,0 @@
1 -/*  
2 - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270  
3 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a  
4 - * aplicativos mainframe. Registro no INPI sob o nome G3270.  
5 - *  
6 - * Copyright (C) <2008> <Banco do Brasil S.A.>  
7 - *  
8 - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob  
9 - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela  
10 - * Free Software Foundation.  
11 - *  
12 - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER  
13 - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO  
14 - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para  
15 - * obter mais detalhes.  
16 - *  
17 - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este  
18 - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin  
19 - * St, Fifth Floor, Boston, MA 02110-1301 USA  
20 - *  
21 - * Este programa está nomeado como common.h e possui - linhas de código.  
22 - *  
23 - * Contatos:  
24 - *  
25 - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)  
26 - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)  
27 - *  
28 - */  
29 -  
30 -#ifndef COMMON_H_INCLUDED  
31 -  
32 - #define COMMON_H_INCLUDED 1  
33 -  
34 - // "PW" Standards  
35 - #include <gtk/gtk.h>  
36 - #include <errno.h>  
37 -  
38 - #ifdef WIN32  
39 -  
40 - #include <windows.h>  
41 - #define WIN_REGISTRY_ENABLED 1  
42 -  
43 - #ifndef KEY_WOW64_64KEY  
44 - #define KEY_WOW64_64KEY 0x0100  
45 - #endif // KEY_WOW64_64KEY  
46 -  
47 - #ifndef KEY_WOW64_32KEY  
48 - #define KEY_WOW64_32KEY 0x0200  
49 - #endif // KEY_WOW64_64KEY  
50 -  
51 - #endif // WIN32  
52 -  
53 - #ifndef PACKAGE_NAME  
54 - #define PACKAGE_NAME "@PACKAGE_NAME@"  
55 - #endif  
56 -  
57 - #define ENABLE_NLS  
58 -  
59 - #ifndef GETTEXT_PACKAGE  
60 - #define GETTEXT_PACKAGE PACKAGE_NAME  
61 - #endif  
62 -  
63 - #include <libintl.h>  
64 - #include <glib/gi18n.h>  
65 - #include <gtk/gtk.h>  
66 -  
67 - #if defined( DEBUG )  
68 - #define trace(x, ...) fprintf(stderr,"%s(%d):\t" x "\n",__FILE__,__LINE__, __VA_ARGS__); fflush(stderr);  
69 - #else  
70 - #define trace(x, ...) /* */  
71 - #endif  
72 -  
73 - // Configuration  
74 - void configuration_init(void);  
75 - void configuration_deinit(void);  
76 -  
77 - gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def);  
78 - gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def);  
79 - gint get_integer_from_config(const gchar *group, const gchar *key, gint def);  
80 -  
81 - void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...);  
82 - void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val);  
83 - void set_integer_to_config(const gchar *group, const gchar *key, gint val);  
84 -  
85 - gchar * build_data_filename(const gchar *first_element, ...);  
86 - gchar * filename_from_va(const gchar *first_element, va_list args);  
87 -  
88 - void save_window_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd);  
89 - void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd);  
90 -  
91 -#ifdef WIN_REGISTRY_ENABLED  
92 - gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired);  
93 - void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);  
94 - void registry_set_double(HKEY hKey, const gchar *key, gdouble value);  
95 - gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);  
96 -#else  
97 - GKeyFile * get_application_keyfile(void);  
98 -#endif // WIN_REGISTRY_ENABLED  
99 -  
100 -#endif  
src/pw3270/main.c
@@ -42,7 +42,6 @@ @@ -42,7 +42,6 @@
42 42
43 #ifdef HAVE_GTKMAC 43 #ifdef HAVE_GTKMAC
44 GtkOSXApplication * osxapp = NULL; 44 GtkOSXApplication * osxapp = NULL;
45 - GtkMacBundle * macbundle = NULL;  
46 #endif // HAVE_GTKMAC 45 #endif // HAVE_GTKMAC
47 46
48 /*--[ Implement ]------------------------------------------------------------------------------------*/ 47 /*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -149,15 +148,13 @@ int main(int argc, char *argv[]) @@ -149,15 +148,13 @@ int main(int argc, char *argv[])
149 } 148 }
150 #elif defined(HAVE_GTKMAC) 149 #elif defined(HAVE_GTKMAC)
151 { 150 {
152 - osxapp = GTK_OSX_APPLICATION(g_object_new(GTK_TYPE_OSX_APPLICATION,NULL));  
153 -  
154 - macbundle = gtk_mac_bundle_get_default();  
155 - if(!macbundle)  
156 - macbundle = gtk_mac_bundle_new(); 151 + GtkMacBundle * macbundle = gtk_mac_bundle_get_default();
157 152
158 g_chdir(gtk_mac_bundle_get_datadir(macbundle)); 153 g_chdir(gtk_mac_bundle_get_datadir(macbundle));
159 bindtextdomain(PACKAGE_NAME,gtk_mac_bundle_get_localedir(macbundle)); 154 bindtextdomain(PACKAGE_NAME,gtk_mac_bundle_get_localedir(macbundle));
160 - 155 +
  156 + osxapp = GTK_OSX_APPLICATION(g_object_new(GTK_TYPE_OSX_APPLICATION,NULL));
  157 +
161 } 158 }
162 #elif defined( DATAROOTDIR ) 159 #elif defined( DATAROOTDIR )
163 { 160 {
src/pw3270/v3270/mouse.c
@@ -273,7 +273,7 @@ void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, Gt @@ -273,7 +273,7 @@ void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, Gt
273 action_scroll[((int) direction) & 0x03] = action; 273 action_scroll[((int) direction) & 0x03] = action;
274 } 274 }
275 275
276 -gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) 276 +gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event)
277 { 277 {
278 v3270 * terminal = GTK_V3270(widget); 278 v3270 * terminal = GTK_V3270(widget);
279 279
src/pw3270/v3270/private.h
@@ -254,6 +254,6 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event); @@ -254,6 +254,6 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event);
254 gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event); 254 gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event);
255 void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event); 255 void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event);
256 gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y); 256 gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y);
257 -gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data); 257 +gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event);
258 258
259 G_END_DECLS 259 G_END_DECLS