diff --git a/android/jni/globals.h b/android/jni/globals.h index 0d1a3c8..f4454d7 100644 --- a/android/jni/globals.h +++ b/android/jni/globals.h @@ -47,7 +47,6 @@ #define pw3270_jni_call_void(name, sig, ...) pw3270_jni_active->env->CallVoidMethod(pw3270_jni_active->obj,lib3270_getmethodID(name,sig), __VA_ARGS__) #define pw3270_jni_call_int(name, sig, ...) pw3270_jni_active->env->CallIntMethod(pw3270_jni_active->obj,lib3270_getmethodID(name,sig), __VA_ARGS__) - #define pw3270_jni_new_string(str) pw3270_jni_active->env->NewStringUTF(str) #define pw3270_jni_new_byte_array(len) pw3270_jni_active->env->NewByteArray(len) typedef struct _pw3270_jni @@ -62,9 +61,9 @@ extern PW3270_JNI *pw3270_jni_active; - int pw3270_jni_lock(JNIEnv *env, jobject obj); - void pw3270_jni_unlock(); - void pw3270_jni_post_message(int msgid, int arg1 = 0, int arg2 = 0); - - jmethodID lib3270_getmethodID(const char *name, const char *sig); + int pw3270_jni_lock(JNIEnv *env, jobject obj); + void pw3270_jni_unlock(); + void pw3270_jni_post_message(int msgid, int arg1 = 0, int arg2 = 0); + jstring pw3270_jni_new_string(const char *str); + jmethodID lib3270_getmethodID(const char *name, const char *sig); diff --git a/android/jni/main.cpp b/android/jni/main.cpp index 617ce13..d457ce7 100644 --- a/android/jni/main.cpp +++ b/android/jni/main.cpp @@ -105,12 +105,6 @@ static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, con static const char *sig = "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"; char * descr = lib3270_vsprintf(fmt, args); - trace("%s: title=\"%s\"",__FUNCTION__,title); - trace("%s: msg=\"%s\"",__FUNCTION__,msg); - trace("%s: descr=\"%s\"",__FUNCTION__,descr); - - - if(msg) { pw3270_jni_call_void( "postPopup", @@ -431,3 +425,7 @@ void pw3270_jni_unlock(void) lib3270_free(datablock); } +jstring pw3270_jni_new_string(const char *str) +{ + return pw3270_jni_active->env->NewStringUTF(str ? str : ""); +} diff --git a/android/src/br/com/bb/pw3270/PW3270Activity.java b/android/src/br/com/bb/pw3270/PW3270Activity.java index 70d067f..098a36b 100644 --- a/android/src/br/com/bb/pw3270/PW3270Activity.java +++ b/android/src/br/com/bb/pw3270/PW3270Activity.java @@ -30,7 +30,7 @@ public class PW3270Activity extends Activity private Resources res; private WebView view; private terminal host; -// private Activity mainact; + private Activity mainact = this; private ProgressDialog dlgProgress; private class terminal extends lib3270 @@ -84,21 +84,24 @@ public class PW3270Activity extends Activity return true; } - protected void popupMessage(int type, String title, String text, String info) + protected void showPopupMessage(int type, String title, String text, String info) { + Log.v(TAG,"Popup Message:"); Log.v(TAG,title); Log.v(TAG,text); Log.v(TAG,info); - /* + AlertDialog d = new AlertDialog.Builder(mainact).create(); - d.setTitle(title); - d.setMessage(text); + if(title != "") + d.setTitle(title); + + if(text != "") + d.setMessage(text); d.setCancelable(true); hideProgressDialog(); d.show(); - */ } @SuppressWarnings("unused") @@ -174,7 +177,6 @@ public class PW3270Activity extends Activity id = R.raw.theme; } - // http://developer.android.com/reference/android/webkit/WebResourceResponse.html return new WebResourceResponse(mime,"utf-8",getResources().openRawResource(id)); } @@ -184,7 +186,7 @@ public class PW3270Activity extends Activity setContentView(view); view.loadUrl("file:index.html"); - // host.connect(); + host.connect(); } diff --git a/android/src/br/com/bb/pw3270/lib3270.java b/android/src/br/com/bb/pw3270/lib3270.java index de02d3f..5c84947 100644 --- a/android/src/br/com/bb/pw3270/lib3270.java +++ b/android/src/br/com/bb/pw3270/lib3270.java @@ -82,7 +82,7 @@ public class lib3270 case 3: // Popup popupMessageInfo popup = (popupMessageInfo) msg.obj; - popupMessage(msg.arg1, popup.title, popup.text, popup.info); + showPopupMessage(msg.arg1, popup.title, popup.text, popup.info); break; case 4: // erase @@ -347,16 +347,9 @@ public class lib3270 mainloop = null; info(TAG, "Network thread stopped"); - } - - public void postPopup(int type, String title, String text, String info) - { - Message msg = mHandler.obtainMessage(); - - msg.what = 3; - msg.arg1 = type; - msg.obj = new popupMessageInfo(title, text, info); - mHandler.sendMessage(msg); + + postPopup(0,"","Desconectado",""); + } } @@ -372,11 +365,11 @@ public class lib3270 public void postPopup(int type, String title, String text, String info) { - Log.d(TAG, "Type:" + type); - Log.d(TAG, "Title:" + title); - Log.d(TAG, "Text:" + text); - Log.d(TAG, "Info:" + info); - mainloop.postPopup(type, title, text, info); + Message msg = mHandler.obtainMessage(); + msg.what = 3; + msg.arg1 = type; + msg.obj = new popupMessageInfo(title, text, info); + mHandler.sendMessage(msg); } /*---[ Signal methods ]--------------------------------------------------*/ @@ -425,7 +418,7 @@ public class lib3270 return true; } - protected void popupMessage(int type, String title, String text, String info) + protected void showPopupMessage(int type, String title, String text, String info) { } -- libgit2 0.21.2