Commit 0d7ac68c4135111cd21a3f5dc0e411b18f88e155
1 parent
66439b4d
Exists in
master
and in
5 other branches
Android - Work in progress
Showing
11 changed files
with
175 additions
and
57 deletions
Show diff stats
android/AndroidManifest.xml
android/Makefile
... | ... | @@ -41,22 +41,22 @@ clean: |
41 | 41 | @rm -f $(foreach DIR, $(RESOLUTION), res/drawable-$(DIR)/ic_launcher.png) |
42 | 42 | |
43 | 43 | res/drawable-xhdpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg |
44 | - @echo " GEN `basename $@`" | |
44 | + @echo " ICON xhdpi" | |
45 | 45 | @$(MKDIR) `dirname $@` |
46 | 46 | @$(CONVERT) --format=png --width=96 --height=96 --output=$@ $< |
47 | 47 | |
48 | 48 | res/drawable-mdpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg |
49 | - @echo " GEN `basename $@`" | |
49 | + @echo " ICON mdpi" | |
50 | 50 | @$(MKDIR) `dirname $@` |
51 | 51 | @$(CONVERT) --format=png --width=48 --height=48 --output=$@ $< |
52 | 52 | |
53 | 53 | res/drawable-ldpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg |
54 | - @echo " GEN `basename $@`" | |
54 | + @echo " ICON ldpi" | |
55 | 55 | @$(MKDIR) `dirname $@` |
56 | 56 | @$(CONVERT) --format=png --width=36 --height=36 --output=$@ $< |
57 | 57 | |
58 | 58 | res/drawable-hdpi/ic_launcher.png: ../src/pw3270/pixmaps/pw3270.svg |
59 | - @echo " GEN `basename $@`" | |
59 | + @echo " ICON hdpi" | |
60 | 60 | @$(MKDIR) `dirname $@` |
61 | 61 | @$(CONVERT) --format=png --width=72 --height=72 --output=$@ $< |
62 | 62 | ... | ... |
android/jni/Android.mk
... | ... | @@ -34,7 +34,7 @@ LOCAL_DEFAULT_CPP_EXTENSION := cpp |
34 | 34 | LOCAL_MODULE := lib3270 |
35 | 35 | LOCAL_LDLIBS := -llog |
36 | 36 | LOCAL_SRC_FILES := $(foreach SRC, $(TERMINAL_SOURCES) $(NETWORK_SOURCES), ../../src/lib3270/$(SRC)) \ |
37 | - main.cpp misc.cpp | |
37 | + main.cpp misc.cpp html.cpp | |
38 | 38 | |
39 | 39 | include $(BUILD_SHARED_LIBRARY) |
40 | 40 | ... | ... |
android/jni/globals.h
... | ... | @@ -29,4 +29,27 @@ |
29 | 29 | #include "lib3270jni.h" |
30 | 30 | |
31 | 31 | #include <lib3270.h> |
32 | + #include <lib3270/session.h> | |
33 | + #include <lib3270/log.h> | |
34 | + | |
35 | +/*--[ Defines ]--------------------------------------------------------------------------------------*/ | |
36 | + | |
37 | + typedef struct _info | |
38 | + { | |
39 | + JNIEnv * env; | |
40 | + jobject obj; | |
41 | + | |
42 | + } INFO; | |
43 | + | |
44 | + #define session_request(env, obj) INFO jni_data = { env, obj }; \ | |
45 | + H3270 * session = lib3270_get_default_session_handle(); \ | |
46 | + session->widget = &jni_data; | |
47 | + | |
48 | + #define session_release() session->widget = 0; | |
49 | + | |
50 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
51 | + | |
52 | + extern const char *java_class_name; | |
53 | + | |
54 | + | |
32 | 55 | ... | ... |
... | ... | @@ -0,0 +1,55 @@ |
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. 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., 59 Temple | |
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | + * | |
21 | + * Este programa está nomeado como main.cpp e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * | |
27 | + */ | |
28 | + | |
29 | + #include "globals.h" | |
30 | + #include <string.h> | |
31 | + | |
32 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
33 | + | |
34 | + | |
35 | +JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getHTML(JNIEnv *env, jobject obj) | |
36 | +{ | |
37 | + jstring ret; | |
38 | + | |
39 | + session_request(env,obj); | |
40 | + | |
41 | + if(session) | |
42 | + { | |
43 | + char *text = getHTML(session); | |
44 | + ret = env->NewStringUTF(text); | |
45 | + lib3270_free(text); | |
46 | + } | |
47 | + else | |
48 | + { | |
49 | + ret = env->NewStringUTF("<b>Invalid Session ID</b>"); | |
50 | + } | |
51 | + | |
52 | + session_release(); | |
53 | + | |
54 | + return ret; | |
55 | +} | ... | ... |
android/jni/main.cpp
... | ... | @@ -27,24 +27,7 @@ |
27 | 27 | */ |
28 | 28 | |
29 | 29 | #include "globals.h" |
30 | - #include <lib3270/session.h> | |
31 | 30 | #include <lib3270/popup.h> |
32 | - #include <lib3270/log.h> | |
33 | - | |
34 | -/*--[ Defines ]--------------------------------------------------------------------------------------*/ | |
35 | - | |
36 | - typedef struct _info | |
37 | - { | |
38 | - JNIEnv * env; | |
39 | - jobject obj; | |
40 | - | |
41 | - } INFO; | |
42 | - | |
43 | - #define session_request(env, obj) INFO jni_data = { env, obj }; \ | |
44 | - H3270 * session = lib3270_get_default_session_handle(); \ | |
45 | - session->widget = &jni_data; | |
46 | - | |
47 | - #define session_release() session->widget = 0; | |
48 | 31 | |
49 | 32 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
50 | 33 | |
... | ... | @@ -74,6 +57,11 @@ static void changed(H3270 *session, int offset, int len) |
74 | 57 | post_message(session,2,offset,len); |
75 | 58 | } |
76 | 59 | |
60 | +static void erase(H3270 *session) | |
61 | +{ | |
62 | + post_message(session,4); | |
63 | +} | |
64 | + | |
77 | 65 | static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list args) |
78 | 66 | { |
79 | 67 | if(session->widget) |
... | ... | @@ -98,6 +86,11 @@ static int popuphandler(H3270 *session, void *terminal, LIB3270_NOTIFY type, con |
98 | 86 | } |
99 | 87 | } |
100 | 88 | |
89 | +static void ctlr_done(H3270 *session) | |
90 | +{ | |
91 | + post_message(session,4); | |
92 | +} | |
93 | + | |
101 | 94 | JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass obj) |
102 | 95 | { |
103 | 96 | H3270 * session = lib3270_session_new(""); |
... | ... | @@ -108,6 +101,8 @@ JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass ob |
108 | 101 | |
109 | 102 | session->changed = changed; |
110 | 103 | session->update_status = update_status; |
104 | + session->erase = erase; | |
105 | + session->ctlr_done = ctlr_done; | |
111 | 106 | |
112 | 107 | return 0; |
113 | 108 | } |
... | ... | @@ -153,3 +148,4 @@ JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_do_1connect(JNIEnv *env, jo |
153 | 148 | session_release(); |
154 | 149 | return (jint) rc; |
155 | 150 | } |
151 | + | ... | ... |
android/lib3270NDK.cbp
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | <Unit filename="Makefile" /> |
36 | 36 | <Unit filename="jni/Android.mk" /> |
37 | 37 | <Unit filename="jni/globals.h" /> |
38 | + <Unit filename="jni/html.cpp" /> | |
38 | 39 | <Unit filename="jni/main.cpp" /> |
39 | 40 | <Unit filename="jni/misc.cpp" /> |
40 | 41 | <Unit filename="src/br/com/bb/pw3270/lib3270.java" /> | ... | ... |
android/res/layout/main.xml
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | |
11 | 11 | <EditText |
12 | 12 | android:id="@+id/hostname" |
13 | - android:layout_width="match_parent" | |
13 | + android:layout_width="0dip" | |
14 | 14 | android:layout_height="match_parent" |
15 | 15 | android:layout_weight="1" |
16 | 16 | android:ems="10" /> |
... | ... | @@ -20,14 +20,19 @@ |
20 | 20 | style="?android:attr/buttonStyleSmall" |
21 | 21 | android:layout_width="80dp" |
22 | 22 | android:layout_height="match_parent" |
23 | - android:text="Connect" /> | |
23 | + android:text="@string/connect" /> | |
24 | 24 | |
25 | 25 | </LinearLayout> |
26 | 26 | |
27 | - <TextView | |
28 | - android:id="@+id/text" | |
27 | + <TextView | |
28 | + android:id="@+id/msgbox" | |
29 | 29 | android:layout_width="fill_parent" |
30 | - android:layout_height="match_parent" | |
30 | + android:layout_height="wrap_content" | |
31 | 31 | android:text="@string/hello" /> |
32 | + | |
33 | + <WebView | |
34 | + android:id="@+id/view" | |
35 | + android:layout_width="match_parent" | |
36 | + android:layout_height="match_parent" /> | |
32 | 37 | |
33 | 38 | </LinearLayout> |
34 | 39 | \ No newline at end of file | ... | ... |
android/res/values/strings.xml
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <resources> |
3 | 3 | |
4 | - <string name="hello">Hello World, PW3270Activity!</string> | |
4 | + <string name="hello">Welcome to pw3270</string> | |
5 | 5 | <string name="app_name">PW3270</string> |
6 | 6 | <string-array name="program_msg"> |
7 | 7 | <item>LIB3270_MESSAGE_NONE</item> |
8 | - <item>LIB3270_MESSAGE_SYSWAIT</item> | |
9 | - <item>LIB3270_MESSAGE_TWAIT</item> | |
10 | - <item>LIB3270_MESSAGE_CONNECTED</item> | |
11 | - <item>LIB3270_MESSAGE_DISCONNECTED</item> | |
12 | - <item>LIB3270_MESSAGE_AWAITING_FIRST</item> | |
13 | - <item>LIB3270_MESSAGE_MINUS</item> | |
14 | - <item>LIB3270_MESSAGE_PROTECTED</item> | |
15 | - <item>LIB3270_MESSAGE_NUMERIC</item> | |
16 | - <item>LIB3270_MESSAGE_OVERFLOW</item> | |
17 | - <item>LIB3270_MESSAGE_INHIBIT</item> | |
18 | - <item>LIB3270_MESSAGE_KYBDLOCK</item> | |
19 | - <item>LIB3270_MESSAGE_X</item> | |
20 | - <item>LIB3270_MESSAGE_RESOLVING</item> | |
21 | - <item>LIB3270_MESSAGE_CONNECTING</item> | |
8 | + <item>X System</item> | |
9 | + <item>X Aguarde</item> | |
10 | + <item>Conectado</item> | |
11 | + <item>Desconectado</item> | |
12 | + <item>X</item> | |
13 | + <item>X -f</item> | |
14 | + <item>X Protegido</item> | |
15 | + <item>X Numérico</item> | |
16 | + <item>X Overflow</item> | |
17 | + <item>X Inhibit</item> | |
18 | + <item>X</item> | |
19 | + <item>X</item> | |
20 | + <item>X Resolvendo</item> | |
21 | + <item>X Conectando</item> | |
22 | 22 | </string-array> |
23 | + <string name="connect">Connect</string> | |
23 | 24 | |
24 | 25 | |
25 | 26 | </resources> |
26 | 27 | \ No newline at end of file | ... | ... |
android/src/br/com/bb/pw3270/PW3270Activity.java
... | ... | @@ -9,29 +9,29 @@ import android.util.Log; |
9 | 9 | import android.view.View; |
10 | 10 | import android.content.res.*; |
11 | 11 | import android.app.AlertDialog; |
12 | -import android.app.Dialog; | |
12 | +import android.webkit.WebView; | |
13 | +// import android.app.Dialog; | |
13 | 14 | |
14 | 15 | public class PW3270Activity extends Activity implements View.OnClickListener |
15 | 16 | { |
16 | 17 | private class terminal extends lib3270 |
17 | 18 | { |
18 | - TextView view; | |
19 | + TextView msgbox; | |
19 | 20 | Activity Main; |
20 | 21 | |
21 | 22 | |
22 | - terminal(TextView view, Activity Main) | |
23 | + terminal(TextView msgbox, Activity Main) | |
23 | 24 | { |
24 | - this.view = view; | |
25 | + this.msgbox = msgbox; | |
25 | 26 | this.Main = Main; |
26 | - | |
27 | 27 | } |
28 | 28 | |
29 | 29 | protected void updateProgramMessage(int id) |
30 | 30 | { |
31 | 31 | try |
32 | 32 | { |
33 | - this.view.setText(message[id]); | |
34 | - } catch(Exception e) { this.view.setText("Estado inesperado"); } | |
33 | + this.msgbox.setText(message[id]); | |
34 | + } catch(Exception e) { this.msgbox.setText("Estado inesperado"); } | |
35 | 35 | } |
36 | 36 | |
37 | 37 | public void popupMessage(int type, String title, String text, String info) |
... | ... | @@ -44,6 +44,12 @@ public class PW3270Activity extends Activity implements View.OnClickListener |
44 | 44 | d.setCancelable(true); |
45 | 45 | d.show(); |
46 | 46 | } |
47 | + | |
48 | + protected void redraw() | |
49 | + { | |
50 | + String text = getHTML(); | |
51 | + } | |
52 | + | |
47 | 53 | |
48 | 54 | |
49 | 55 | }; |
... | ... | @@ -52,6 +58,7 @@ public class PW3270Activity extends Activity implements View.OnClickListener |
52 | 58 | private EditText uri; |
53 | 59 | private Resources res; |
54 | 60 | private String[] message; |
61 | + private WebView view; | |
55 | 62 | |
56 | 63 | /** Called when the activity is first created. */ |
57 | 64 | @Override |
... | ... | @@ -70,7 +77,7 @@ public class PW3270Activity extends Activity implements View.OnClickListener |
70 | 77 | Button btn = (Button) findViewById(R.id.connect); |
71 | 78 | btn.setOnClickListener((View.OnClickListener) this); |
72 | 79 | |
73 | - host = new terminal((TextView) findViewById(R.id.text),this); | |
80 | + host = new terminal((TextView) findViewById(R.id.msgbox),this); | |
74 | 81 | |
75 | 82 | |
76 | 83 | } | ... | ... |
android/src/br/com/bb/pw3270/lib3270.java
... | ... | @@ -9,7 +9,8 @@ public class lib3270 |
9 | 9 | { |
10 | 10 | private NetworkThread mainloop; |
11 | 11 | private static final String TAG = "lib3270"; |
12 | - | |
12 | + private boolean changed; | |
13 | + | |
13 | 14 | static |
14 | 15 | { |
15 | 16 | System.loadLibrary("3270"); |
... | ... | @@ -18,7 +19,8 @@ public class lib3270 |
18 | 19 | |
19 | 20 | lib3270() |
20 | 21 | { |
21 | - mainloop = null; | |
22 | + changed = false; | |
23 | + mainloop = null; | |
22 | 24 | } |
23 | 25 | |
24 | 26 | private class popupMessageInfo |
... | ... | @@ -26,7 +28,7 @@ public class lib3270 |
26 | 28 | public String title; |
27 | 29 | public String text; |
28 | 30 | public String info; |
29 | - | |
31 | + | |
30 | 32 | popupMessageInfo(String title, String text, String info) |
31 | 33 | { |
32 | 34 | this.title = title; |
... | ... | @@ -34,7 +36,7 @@ public class lib3270 |
34 | 36 | this.info = info; |
35 | 37 | } |
36 | 38 | } |
37 | - | |
39 | + | |
38 | 40 | // Main Thread |
39 | 41 | private class NetworkThread extends Thread |
40 | 42 | { |
... | ... | @@ -70,7 +72,7 @@ public class lib3270 |
70 | 72 | public void postPopup(int type, String title, String text, String info) |
71 | 73 | { |
72 | 74 | Message msg = mHandler.obtainMessage(); |
73 | - | |
75 | + | |
74 | 76 | msg.what = 3; |
75 | 77 | msg.arg1 = type; |
76 | 78 | msg.obj = new popupMessageInfo(title,text,info); |
... | ... | @@ -108,12 +110,27 @@ public class lib3270 |
108 | 110 | break; |
109 | 111 | |
110 | 112 | case 2: // Screen changed |
113 | + Log.d(TAG,"Screen changed"); | |
114 | + changed = true; | |
115 | + redraw(); | |
111 | 116 | break; |
112 | 117 | |
113 | 118 | case 3: // Popup |
114 | 119 | popupMessageInfo popup = (popupMessageInfo) msg.obj; |
115 | 120 | popupMessage(msg.arg1, popup.title, popup.text, popup.info); |
116 | 121 | break; |
122 | + | |
123 | + case 4: // erase | |
124 | + changed = false; | |
125 | + erase(); | |
126 | + | |
127 | + case 5: // ctlr_done | |
128 | + Log.d(TAG,"ctlr_done"); | |
129 | + if(changed) | |
130 | + { | |
131 | + changed = false; | |
132 | + redraw(); | |
133 | + } | |
117 | 134 | } |
118 | 135 | } |
119 | 136 | }; |
... | ... | @@ -127,17 +144,26 @@ public class lib3270 |
127 | 144 | public void popupMessage(int type, String title, String text, String info) |
128 | 145 | { |
129 | 146 | } |
130 | - | |
147 | + | |
131 | 148 | protected void info(String tag, String msg) |
132 | 149 | { |
133 | 150 | Log.i(tag,msg); |
134 | 151 | } |
135 | - | |
152 | + | |
136 | 153 | protected void error(String tag, String msg) |
137 | 154 | { |
138 | 155 | Log.e(tag,msg); |
139 | 156 | } |
140 | 157 | |
158 | + protected void erase() | |
159 | + { | |
160 | + Log.i(TAG,"Erase screen"); | |
161 | + } | |
162 | + | |
163 | + protected void redraw() | |
164 | + { | |
165 | + } | |
166 | + | |
141 | 167 | /*---[ External methods ]------------------------------------------------*/ |
142 | 168 | |
143 | 169 | public int connect() |
... | ... | @@ -170,5 +196,8 @@ public class lib3270 |
170 | 196 | public native boolean isConnected(); |
171 | 197 | public native boolean isTerminalReady(); |
172 | 198 | |
199 | + // Get/Set screen contents | |
200 | + public native String getHTML(); | |
201 | + | |
173 | 202 | |
174 | 203 | } | ... | ... |