diff --git a/pw3270.cbp b/pw3270.cbp
index d612a83..8d66344 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -45,6 +45,8 @@
+
+
diff --git a/src/android/jni/Android.mk b/src/android/jni/Android.mk
index 28d354a..ec4f784 100644
--- a/src/android/jni/Android.mk
+++ b/src/android/jni/Android.mk
@@ -33,7 +33,7 @@ LOCAL_CFLAGS=-I../include
LOCAL_DEFAULT_CPP_EXTENSION := cpp
LOCAL_MODULE := lib3270
LOCAL_SRC_FILES := $(foreach SRC, $(TERMINAL_SOURCES), ../../lib3270/$(SRC)) \
- misc.cpp init.cpp
+ main.cpp misc.cpp
include $(BUILD_SHARED_LIBRARY)
diff --git a/src/android/jni/globals.h b/src/android/jni/globals.h
new file mode 100644
index 0000000..3560298
--- /dev/null
+++ b/src/android/jni/globals.h
@@ -0,0 +1,30 @@
+/*
+ * "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 globals.h e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ *
+ */
+
+ #include "lib3270jni.h"
+ #include
diff --git a/src/android/jni/init.cpp b/src/android/jni/init.cpp
deleted file mode 100644
index ce6daf4..0000000
--- a/src/android/jni/init.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * "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 init.cpp e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- *
- */
-
- #include "lib3270jni.h"
- #include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jobject obj)
-{
- H3270 *session = lib3270_session_new("");
-
-
-}
-
diff --git a/src/android/jni/main.cpp b/src/android/jni/main.cpp
new file mode 100644
index 0000000..7d582f6
--- /dev/null
+++ b/src/android/jni/main.cpp
@@ -0,0 +1,73 @@
+/*
+ * "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
+
+/*--[ Defines ]--------------------------------------------------------------------------------------*/
+
+ typedef struct _info
+ {
+ JNIEnv * env;
+ jobject obj;
+
+ } INFO;
+
+/*--[ Implement ]------------------------------------------------------------------------------------*/
+
+JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_init(JNIEnv *env, jclass obj)
+{
+ H3270 * session = lib3270_session_new("");
+
+ return 0;
+}
+
+JNIEXPORT jint JNICALL Java_br_com_bb_pw3270_lib3270_processEvents(JNIEnv *env, jobject obj)
+{
+ /*
+ INFO data = { env, obj };
+ H3270 * session = lib3270_get_default_session_handle();
+
+ session->widget = &data;
+ lib3270_main_iterate(session,1);
+ session->widget = 0;
+ */
+ return 0;
+}
+
+JNIEXPORT jboolean JNICALL Java_br_com_bb_pw3270_lib3270_isConnected(JNIEnv *, jobject)
+{
+// return (lib3270_connected(lib3270_get_default_session_handle())) ? JNI_TRUE : JNI_FALSE;;
+ return JNI_FALSE;
+}
+
+JNIEXPORT jboolean JNICALL Java_br_com_bb_pw3270_lib3270_isTerminalReady(JNIEnv *, jobject)
+{
+ return JNI_FALSE;
+}
+
diff --git a/src/android/jni/misc.cpp b/src/android/jni/misc.cpp
index f1465e8..9c70dc6 100644
--- a/src/android/jni/misc.cpp
+++ b/src/android/jni/misc.cpp
@@ -26,8 +26,7 @@
*
*/
- #include "lib3270jni.h"
- #include
+ #include "globals.h"
/*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -40,3 +39,8 @@ JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getRevision(JNIEnv *env,
{
return env->NewStringUTF(lib3270_get_revision());
}
+
+JNIEXPORT jstring JNICALL Java_br_com_bb_pw3270_lib3270_getEncoding(JNIEnv *env, jobject obj)
+{
+ return env->NewStringUTF(lib3270_get_charset(lib3270_get_default_session_handle()));
+}
diff --git a/src/android/lib3270NDK.cbp b/src/android/lib3270NDK.cbp
index fa8ae0e..8fbfc77 100644
--- a/src/android/lib3270NDK.cbp
+++ b/src/android/lib3270NDK.cbp
@@ -34,7 +34,8 @@
-
+
+
diff --git a/src/android/src/br/com/bb/pw3270/lib3270.java b/src/android/src/br/com/bb/pw3270/lib3270.java
index a820735..140bec1 100644
--- a/src/android/src/br/com/bb/pw3270/lib3270.java
+++ b/src/android/src/br/com/bb/pw3270/lib3270.java
@@ -1,6 +1,9 @@
package br.com.bb.pw3270;
-public class lib3270 {
+import java.lang.Thread;
+
+public class lib3270 extends Thread
+{
static
{
@@ -16,11 +19,28 @@ public class lib3270 {
// TODO Auto-generated method stub
}
+
+ /**
+ * Connect to host, keep event loop running until disconnected.
+ */
+ public void run()
+ {
+ while(isConnected())
+ processEvents();
+ }
+
+ static private native int init();
+ private native int processEvents();
// Misc calls
- static private native int init();
- public native String getVersion();
- public native String getRevision();
+ public native String getEncoding();
+
+ public native String getVersion();
+ public native String getRevision();
+
+ // Connection status
+ public native boolean isConnected();
+ public native boolean isTerminalReady();
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index a44179e..ab4834f 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -647,10 +647,11 @@
*
* Run lib3270 internal iterations, check for network inputs, process signals.
*
+ * @param h Related session.
* @param wait Wait for signal if not available.
*
*/
- LIB3270_EXPORT void lib3270_main_iterate(int wait);
+ LIB3270_EXPORT void lib3270_main_iterate(H3270 *h, int wait);
/**
* Wait for "N" seconds keeping main loop active.
@@ -776,6 +777,14 @@
/**
+ * Get default session handle.
+ *
+ * @return Internal's lib3270 session handle.
+ *
+ */
+ LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void);
+
+ /**
* Get resource string.
*
* @param first_element First element of resource path
diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h
index 191bcb4..a7b3770 100644
--- a/src/include/lib3270/session.h
+++ b/src/include/lib3270/session.h
@@ -119,7 +119,7 @@
char * qualified_host;
char * proxy; /**< Proxy server (type:host[:port]) */
char * termname;
-
+ char * charset;
LIB3270_MESSAGE oia_status;
@@ -131,7 +131,7 @@
void * ft; /**< Active file transfer data */
// screen info
- char * charset;
+ const char * host_charset;
int ov_rows;
int ov_cols;
int maxROWS;
diff --git a/src/lib3270/XtGlue.c b/src/lib3270/XtGlue.c
index 0dcf729..3c43508 100644
--- a/src/lib3270/XtGlue.c
+++ b/src/lib3270/XtGlue.c
@@ -850,7 +850,12 @@ void RemoveInput(unsigned long id)
callbacks->RemoveInput(id);
}
-int LIB3270_EXPORT lib3270_register_handlers(const struct lib3270_callbacks *cbk)
+LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void)
+{
+ return &h3270;
+}
+
+LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk)
{
if(!cbk)
return EINVAL;
@@ -937,7 +942,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *
if(h->set_timer)
h->set_timer(h,1);
- lib3270_main_iterate(0);
+ lib3270_main_iterate(h,0);
if(callbacks->callthread)
{
h->bgthread = 1;
@@ -950,7 +955,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *
{
rc = callback(h,parm);
}
- lib3270_main_iterate(0);
+ lib3270_main_iterate(h,0);
if(h->set_timer)
h->set_timer(h,0);
@@ -958,7 +963,7 @@ LIB3270_EXPORT int lib3270_call_thread(int(*callback)(H3270 *h, void *), H3270 *
return rc;
}
-LIB3270_EXPORT void lib3270_main_iterate(int wait)
+LIB3270_EXPORT void lib3270_main_iterate(H3270 *session, int wait)
{
if(callbacks->RunPendingEvents)
callbacks->RunPendingEvents(wait);
@@ -976,7 +981,7 @@ LIB3270_EXPORT int lib3270_wait(seconds)
while(time(0) < end)
{
- lib3270_main_iterate(1);
+ lib3270_main_iterate(&h3270,1);
}
return 0;
diff --git a/src/lib3270/appres.h b/src/lib3270/appres.h
index 50c2245..1699efd 100644
--- a/src/lib3270/appres.h
+++ b/src/lib3270/appres.h
@@ -149,7 +149,7 @@ typedef struct {
char *model;
// char *hostsfile;
// char *port;
- char *charset;
+// char *charset;
// char *termname;
// char *login_macro;
char *macros;
diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c
index b7d0003..d9c841a 100644
--- a/src/lib3270/charset.c
+++ b/src/lib3270/charset.c
@@ -90,10 +90,9 @@ unsigned char xk_selector = 0;
unsigned char auto_keymap = 0;
/* Statics. */
-static enum cs_result resource_charset(char *csname, char *cs, char *ftcs);
+static enum cs_result resource_charset(const char *csname, char *cs, char *ftcs);
typedef enum { CS_ONLY, FT_ONLY, BOTH } remap_scope;
-static enum cs_result remap_chars(char *csname, char *spec, remap_scope scope,
- int *ne);
+static enum cs_result remap_chars(const char *csname, char *spec, remap_scope scope, int *ne);
static void remap_one(unsigned char ebc, KeySym iso, remap_scope scope,Boolean one_way);
#if defined(DEBUG_CHARSET) /*[*/
@@ -195,7 +194,7 @@ wide_resource_init(char *csname)
/*
* Change character sets.
*/
-enum cs_result charset_init(H3270 *session, char *csname)
+enum cs_result charset_init(H3270 *session, const char *csname)
{
char *cs;
const char *ftcs;
@@ -370,7 +369,7 @@ set_charset_name(char *csname)
*/
/* Define a charset from resources. */
-static enum cs_result resource_charset(char *csname, char *cs, char *ftcs)
+static enum cs_result resource_charset(const char *csname, char *cs, char *ftcs)
{
enum cs_result rc;
int ne = 0;
@@ -586,8 +585,7 @@ remap_one(unsigned char ebc, KeySym iso, remap_scope scope, Boolean one_way)
* characters that replace certain standard Latin-1 graphics. The keysym
* will be entered into the extended keysym translation table.
*/
-static enum cs_result
-remap_chars(char *csname, char *spec, remap_scope scope, int *ne)
+static enum cs_result remap_chars(const char *csname, char *spec, remap_scope scope, int *ne)
{
char *s;
char *ebcs, *isos;
diff --git a/src/lib3270/charsetc.h b/src/lib3270/charsetc.h
index 3a302bf..b145390 100644
--- a/src/lib3270/charsetc.h
+++ b/src/lib3270/charsetc.h
@@ -35,7 +35,7 @@ LIB3270_INTERNAL char *default_display_charset;
enum cs_result { CS_OKAY, CS_NOTFOUND, CS_BAD, CS_PREREQ, CS_ILLEGAL };
-LIB3270_INTERNAL enum cs_result charset_init(H3270 *session, char *csname);
+LIB3270_INTERNAL enum cs_result charset_init(H3270 *session, const char *csname);
// LIB3270_INTERNAL char *get_charset_name(void);
LIB3270_INTERNAL void set_display_charset(H3270 *session, const char *dcs);
diff --git a/src/lib3270/glue.c b/src/lib3270/glue.c
index 0d31897..b67883d 100644
--- a/src/lib3270/glue.c
+++ b/src/lib3270/glue.c
@@ -171,15 +171,15 @@ static void initialize(void)
// appres.hostsfile = CN;
// appres.port = "telnet";
-#if !defined(_WIN32) /*[*/
- appres.charset = "bracket";
-#else /*][*/
-
- if (is_nt)
- appres.charset = "bracket";
- else
- appres.charset = "bracket437";
-#endif /*]*/
+// #if !defined(_WIN32) /*[*/
+// appres.charset = "bracket";
+// #else /*][*/
+//
+// if (is_nt)
+// appres.charset = "bracket";
+// else
+// appres.charset = "bracket437";
+//#endif /*]*/
// appres.termname = CN;
appres.macros = CN;
@@ -305,7 +305,7 @@ static const struct lib3270_option options[] =
#if defined(HAVE_LIBSSL) /*[*/
{ OptCertFile, OPT_STRING, False, ResCertFile, offset(cert_file), NULL },
#endif /*]*/
- { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL },
+// { OptCharset, OPT_STRING, False, ResCharset, offset(charset), NULL },
{ OptClear, OPT_SKIP2, False, NULL, NULL, NULL },
// { OptDefScreen,OPT_STRING, False, ResDefScreen, offset(defscreen), NULL },
//#if defined(X3270_TRACE)
@@ -383,7 +383,7 @@ static struct {
#if defined(HAVE_LIBSSL) /*[*/
{ ResCertFile, offset(cert_file), XRM_STRING },
#endif /*]*/
- { ResCharset, offset(charset), XRM_STRING },
+// { ResCharset, offset(charset), XRM_STRING },
// { ResColor8, offset(color8), XRM_BOOLEAN },
{ ResConfDir, offset(conf_dir), XRM_STRING },
// { ResDefScreen, offset(defscreen), XRM_STRING },
diff --git a/src/lib3270/host.c b/src/lib3270/host.c
index 0458b77..441bc83 100644
--- a/src/lib3270/host.c
+++ b/src/lib3270/host.c
@@ -615,7 +615,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait)
CHECK_SESSION_HANDLE(h);
- lib3270_main_iterate(0);
+ lib3270_main_iterate(h,0);
if(h->auto_reconnect_inprogress)
return EAGAIN;
@@ -638,7 +638,7 @@ int lib3270_connect(H3270 *h, const char *n, int wait)
{
while(!IN_ANSI && !IN_3270)
{
- lib3270_main_iterate(1);
+ lib3270_main_iterate(h,1);
if(!PCONNECTED)
{
diff --git a/src/lib3270/init.c b/src/lib3270/init.c
index f7c5938..6c94bfc 100644
--- a/src/lib3270/init.c
+++ b/src/lib3270/init.c
@@ -32,7 +32,7 @@
#include "globals.h"
-#include "appres.h"
+// #include "appres.h"
#include "charsetc.h"
#include "kybdc.h"
#include "ansic.h"
@@ -142,6 +142,20 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
hSession->unlock_delay = 1;
hSession->icrnl = 1;
hSession->onlcr = 1;
+ hSession->host_charset = "bracket";
+
+/*
+#if !defined(_WIN32)
+ hSession->host_charset = "bracket";
+#else
+
+ if (is_nt)
+ hSession->host_charset = "bracket";
+ else
+ hSession->host_charset = "bracket437";
+#endif
+*/
+
// Initialize toggles
initialize_toggles(hSession);
@@ -223,7 +237,7 @@ static void lib3270_session_init(H3270 *hSession, const char *model)
Trace("Termtype: %s",hSession->termtype);
if (hSession->apl_mode)
- appres.charset = "apl";
+ hSession->host_charset = "apl";
}
@@ -244,15 +258,16 @@ H3270 * lib3270_session_new(const char *model)
configured = 1;
+
lib3270_session_init(hSession, model);
if(screen_init(hSession))
return NULL;
- Trace("Charset: %s",appres.charset);
- if (charset_init(hSession,appres.charset) != CS_OKAY)
+ Trace("Charset: %s",hSession->host_charset);
+ if (charset_init(hSession,hSession->host_charset) != CS_OKAY)
{
- Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), appres.charset);
+ Warning(hSession, _( "Cannot find charset \"%s\", using defaults" ), hSession->host_charset);
(void) charset_init(hSession,CN);
}
diff --git a/src/lib3270/sources.mak b/src/lib3270/sources.mak
index 4a3b4b7..ec9bb16 100644
--- a/src/lib3270/sources.mak
+++ b/src/lib3270/sources.mak
@@ -27,9 +27,9 @@
# Terminal only sources
TERMINAL_SOURCES = bounds.c XtGlue.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \
host.c sf.c ansi.c log.c resolver.c xio.c tables.c proxy.c utf8.c charset.c \
- version.c
+ version.c init.c
# Full library sources
-SOURCES = $(TERMINAL_SOURCES) init.c actions.c ft.c ft_cut.c ft_dft.c glue.c resources.c \
+SOURCES = $(TERMINAL_SOURCES) actions.c ft.c ft_cut.c ft_dft.c glue.c resources.c \
rpq.c see.c trace_ds.c paste.c macros.c fallbacks.c
--
libgit2 0.21.2