diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index bc94151..772d49a 100644
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -5,6 +5,7 @@
android:versionName="1.0" >
+
+ #include
+ #include
+
+/*--[ Defines ]--------------------------------------------------------------------------------------*/
+
+ typedef struct _info
+ {
+ JNIEnv * env;
+ jobject obj;
+
+ } INFO;
+
+ #define session_request(env, obj) INFO jni_data = { env, obj }; \
+ H3270 * session = lib3270_get_default_session_handle(); \
+ session->widget = &jni_data;
+
+ #define session_release() session->widget = 0;
+
+/*--[ Globals ]--------------------------------------------------------------------------------------*/
+
+ extern const char *java_class_name;
+
+
diff --git a/android/jni/html.cpp b/android/jni/html.cpp
new file mode 100644
index 0000000..b006463
--- /dev/null
+++ b/android/jni/html.cpp
@@ -0,0 +1,55 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como main.cpp e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ *
+ */
+
+ #include "globals.h"
+ #include
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+
+JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env, jobject obj)
+{
+ jstring ret;
+
+ session_request(env,obj);
+
+ if(session)
+ {
+ char *text = getHTML(session);
+ ret = env->NewStringUTF(text);
+ lib3270_free(text);
+ }
+ else
+ {
+ ret = env->NewStringUTF("Invalid Session ID");
+ }
+
+ session_release();
+
+ return ret;
+}
diff --git a/android/jni/main.cpp b/android/jni/main.cpp
index 20be646..7d4c704 100644
--- a/android/jni/main.cpp
+++ b/android/jni/main.cpp
@@ -27,24 +27,7 @@
*/
#include "globals.h"
- #include
#include
- #include
-
-/*--[ Defines ]--------------------------------------------------------------------------------------*/
-
- typedef struct _info
- {
- JNIEnv * env;
- jobject obj;
-
- } INFO;
-
- #define session_request(env, obj) INFO jni_data = { env, obj }; \
- H3270 * session = lib3270_get_default_session_handle(); \
- session->widget = &jni_data;
-
- #define session_release() session->widget = 0;
/*--[ Globals ]--------------------------------------------------------------------------------------*/
@@ -74,6 +57,11 @@ static void changed(H3270 *session, int offset, int len)
post_message(session,2,offset,len);
}
+static void erase(H3270 *session)
+{
+ post_message(session,4);
+}
+
static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args)
{
if(session->widget)
@@ -98,6 +86,11 @@ static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, con
}
}
+static void ctlr_done(H3270 *session)
+{
+ post_message(session,4);
+}
+
JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass obj)
{
H3270 * session = lib3270_session_new("");
@@ -108,6 +101,8 @@ JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass ob
session->changed = changed;
session->update_status = update_status;
+ session->erase = erase;
+ session->ctlr_done = ctlr_done;
return 0;
}
@@ -153,3 +148,4 @@ JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_do_1connect(JNIEnv *env, jo
session_release();
return (jint) rc;
}
+
diff --git a/android/lib3270NDK.cbp b/android/lib3270NDK.cbp
index 8fbfc77..01a1732 100644
--- a/android/lib3270NDK.cbp
+++ b/android/lib3270NDK.cbp
@@ -35,6 +35,7 @@
+
diff --git a/android/res/layout/main.xml b/android/res/layout/main.xml
index 56be3a9..4e27c84 100644
--- a/android/res/layout/main.xml
+++ b/android/res/layout/main.xml
@@ -10,7 +10,7 @@
@@ -20,14 +20,19 @@
style="?android:attr/buttonStyleSmall"
android:layout_width="80dp"
android:layout_height="match_parent"
- android:text="Connect" />
+ android:text="@string/connect" />
-
+
+
\ No newline at end of file
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
index 525841f..e24868d 100644
--- a/android/res/values/strings.xml
+++ b/android/res/values/strings.xml
@@ -1,25 +1,26 @@
- Hello World, PW3270Activity!
+ Welcome to pw3270
PW3270
- LIB3270_MESSAGE_NONE
- - LIB3270_MESSAGE_SYSWAIT
- - LIB3270_MESSAGE_TWAIT
- - LIB3270_MESSAGE_CONNECTED
- - LIB3270_MESSAGE_DISCONNECTED
- - LIB3270_MESSAGE_AWAITING_FIRST
- - LIB3270_MESSAGE_MINUS
- - LIB3270_MESSAGE_PROTECTED
- - LIB3270_MESSAGE_NUMERIC
- - LIB3270_MESSAGE_OVERFLOW
- - LIB3270_MESSAGE_INHIBIT
- - LIB3270_MESSAGE_KYBDLOCK
- - LIB3270_MESSAGE_X
- - LIB3270_MESSAGE_RESOLVING
- - LIB3270_MESSAGE_CONNECTING
+ - X System
+ - X Aguarde
+ - Conectado
+ - Desconectado
+ - X
+ - X -f
+ - X Protegido
+ - X Numérico
+ - X Overflow
+ - X Inhibit
+ - X
+ - X
+ - X Resolvendo
+ - X Conectando
+ Connect
\ No newline at end of file
diff --git a/android/src/br/com/bb/pw3270/PW3270Activity.java b/android/src/br/com/bb/pw3270/PW3270Activity.java
index d247d8f..3047a14 100644
--- a/android/src/br/com/bb/pw3270/PW3270Activity.java
+++ b/android/src/br/com/bb/pw3270/PW3270Activity.java
@@ -9,29 +9,29 @@ import android.util.Log;
import android.view.View;
import android.content.res.*;
import android.app.AlertDialog;
-import android.app.Dialog;
+import android.webkit.WebView;
+// import android.app.Dialog;
public class PW3270Activity extends Activity implements View.OnClickListener
{
private class terminal extends lib3270
{
- TextView view;
+ TextView msgbox;
Activity Main;
- terminal(TextView view, Activity Main)
+ terminal(TextView msgbox, Activity Main)
{
- this.view = view;
+ this.msgbox = msgbox;
this.Main = Main;
-
}
protected void updateProgramMessage(int id)
{
try
{
- this.view.setText(message[id]);
- } catch(Exception e) { this.view.setText("Estado inesperado"); }
+ this.msgbox.setText(message[id]);
+ } catch(Exception e) { this.msgbox.setText("Estado inesperado"); }
}
public void popupMessage(int type, String title, String text, String info)
@@ -44,6 +44,12 @@ public class PW3270Activity extends Activity implements View.OnClickListener
d.setCancelable(true);
d.show();
}
+
+ protected void redraw()
+ {
+ String text = getHTML();
+ }
+
};
@@ -52,6 +58,7 @@ public class PW3270Activity extends Activity implements View.OnClickListener
private EditText uri;
private Resources res;
private String[] message;
+ private WebView view;
/** Called when the activity is first created. */
@Override
@@ -70,7 +77,7 @@ public class PW3270Activity extends Activity implements View.OnClickListener
Button btn = (Button) findViewById(R.id.connect);
btn.setOnClickListener((View.OnClickListener) this);
- host = new terminal((TextView) findViewById(R.id.text),this);
+ host = new terminal((TextView) findViewById(R.id.msgbox),this);
}
diff --git a/android/src/br/com/bb/pw3270/lib3270.java b/android/src/br/com/bb/pw3270/lib3270.java
index 435d858..55dc411 100644
--- a/android/src/br/com/bb/pw3270/lib3270.java
+++ b/android/src/br/com/bb/pw3270/lib3270.java
@@ -9,7 +9,8 @@ public class lib3270
{
private NetworkThread mainloop;
private static final String TAG = "lib3270";
-
+ private boolean changed;
+
static
{
System.loadLibrary("3270");
@@ -18,7 +19,8 @@ public class lib3270
lib3270()
{
- mainloop = null;
+ changed = false;
+ mainloop = null;
}
private class popupMessageInfo
@@ -26,7 +28,7 @@ public class lib3270
public String title;
public String text;
public String info;
-
+
popupMessageInfo(String title, String text, String info)
{
this.title = title;
@@ -34,7 +36,7 @@ public class lib3270
this.info = info;
}
}
-
+
// Main Thread
private class NetworkThread extends Thread
{
@@ -70,7 +72,7 @@ public class lib3270
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);
@@ -108,12 +110,27 @@ public class lib3270
break;
case 2: // Screen changed
+ Log.d(TAG,"Screen changed");
+ changed = true;
+ redraw();
break;
case 3: // Popup
popupMessageInfo popup = (popupMessageInfo) msg.obj;
popupMessage(msg.arg1, popup.title, popup.text, popup.info);
break;
+
+ case 4: // erase
+ changed = false;
+ erase();
+
+ case 5: // ctlr_done
+ Log.d(TAG,"ctlr_done");
+ if(changed)
+ {
+ changed = false;
+ redraw();
+ }
}
}
};
@@ -127,17 +144,26 @@ public class lib3270
public void popupMessage(int type, String title, String text, String info)
{
}
-
+
protected void info(String tag, String msg)
{
Log.i(tag,msg);
}
-
+
protected void error(String tag, String msg)
{
Log.e(tag,msg);
}
+ protected void erase()
+ {
+ Log.i(TAG,"Erase screen");
+ }
+
+ protected void redraw()
+ {
+ }
+
/*---[ External methods ]------------------------------------------------*/
public int connect()
@@ -170,5 +196,8 @@ public class lib3270
public native boolean isConnected();
public native boolean isTerminalReady();
+ // Get/Set screen contents
+ public native String getHTML();
+
}
--
libgit2 0.21.2