diff --git a/pw3270.cbp b/pw3270.cbp
index 6ae188e..807fb36 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -193,6 +193,9 @@
+
+
+
diff --git a/src/classlib/local.cc b/src/classlib/local.cc
index a64778e..18a4f06 100644
--- a/src/classlib/local.cc
+++ b/src/classlib/local.cc
@@ -158,6 +158,7 @@
int (*_erase_eof)(H3270 *hSession);
int (*_erase_eol)(H3270 *hSession);
int (*_erase_input)(H3270 *hSession);
+ int (*_action)(H3270 *hSession, const char *name);
const char * (*_ebc2asc)(H3270 *hSession, unsigned char *buffer, int sz);
const char * (*_asc2ebc)(H3270 *hSession, unsigned char *buffer, int sz);
@@ -223,6 +224,7 @@
{ (void **) & _ebc2asc, "lib3270_ebc2asc" },
{ (void **) & _asc2ebc, "lib3270_asc2ebc" },
+ { (void **) & _action, "lib3270_action" },
};
for(unsigned int f = 0; f < (sizeof (call) / sizeof ((call)[0]));f++)
@@ -468,6 +470,11 @@
return _ebc2asc(hSession,str,sz);
}
+ int action(const char *name)
+ {
+ return _action(hSession,name);
+ }
+
};
session * session::create_local(void) throw (std::exception)
diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc
index edbd1cc..c7fd54a 100644
--- a/src/classlib/remote.cc
+++ b/src/classlib/remote.cc
@@ -1156,6 +1156,33 @@
}
+ int action(const char *str)
+ {
+
+#if defined(WIN32)
+
+ size_t len = strlen(str);
+ struct hllapi_packet_text * query;
+ size_t cbSize = sizeof(struct hllapi_packet_text)+len;
+
+ query = (struct hllapi_packet_text *) malloc(cbSize);
+ query->packet_id = HLLAPI_PACKET_ACTION;
+ strcpy(query->text,str);
+
+ return query_intval((void *) query, cbSize, true);
+
+#elif defined(HAVE_DBUS)
+
+ return query_intval("action", DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID);
+#else
+
+ return -1;
+
+#endif
+
+ }
+
+
int get_field_start(int baddr)
{
#if defined(WIN32)
diff --git a/src/include/lib3270.h b/src/include/lib3270.h
index f4963a1..929e500 100644
--- a/src/include/lib3270.h
+++ b/src/include/lib3270.h
@@ -1028,6 +1028,9 @@
LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr);
LIB3270_EXPORT int lib3270_is_protected_at(H3270 *h, unsigned int row, unsigned int col);
+ LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name);
+
+
/**
* Alloc/Realloc memory buffer.
*
diff --git a/src/include/pw3270/class.h b/src/include/pw3270/class.h
index f0a40c8..29f8100 100644
--- a/src/include/pw3270/class.h
+++ b/src/include/pw3270/class.h
@@ -206,6 +206,7 @@
// Actions
virtual int quit(void) = 0;
+ virtual int action(const char *name) = 0;
int erase(int mode);
diff --git a/src/include/pw3270/ipcpackets.h b/src/include/pw3270/ipcpackets.h
index 7b8f467..8a84d83 100644
--- a/src/include/pw3270/ipcpackets.h
+++ b/src/include/pw3270/ipcpackets.h
@@ -61,6 +61,7 @@
HLLAPI_PACKET_IS_PROTECTED,
HLLAPI_PACKET_IS_PROTECTED_AT,
HLLAPI_PACKET_QUIT,
+ HLLAPI_PACKET_ACTION,
HLLAPI_PACKET_SET_HOST_CHARSET,
HLLAPI_PACKET_GET_HOST_CHARSET,
diff --git a/src/java/actions.cc b/src/java/actions.cc
index 64fa193..bb07239 100644
--- a/src/java/actions.cc
+++ b/src/java/actions.cc
@@ -147,3 +147,25 @@ JNIEXPORT jint JNICALL Java_pw3270_terminal_print(JNIEnv *env, jobject obj) {
return rc;
}
+
+JNIEXPORT jint JNICALL Java_pw3270_terminal_action(JNIEnv *env, jobject obj, jstring j_name) {
+
+ jint rc = -1;
+ const char * name = env->GetStringUTFChars(j_name, 0);
+
+ try {
+
+ rc = java::getHandle(env,obj)->action(name);
+
+ } catch(std::exception &e) {
+
+ env->ReleaseStringUTFChars( j_name, name);
+ env->ThrowNew(env->FindClass("java/lang/Exception"), e.what());
+ return -1;
+
+ }
+
+ env->ReleaseStringUTFChars( j_name, name);
+ return rc;
+
+}
diff --git a/src/java/plugin.cc b/src/java/plugin.cc
index f25b3a9..c89d239 100644
--- a/src/java/plugin.cc
+++ b/src/java/plugin.cc
@@ -340,6 +340,10 @@
return 0;
}
+ int action(const char *name) {
+ return lib3270_action(hSession,name);
+ }
+
};
diff --git a/src/java/terminal.java b/src/java/terminal.java
index ce737f4..49ce97c 100644
--- a/src/java/terminal.java
+++ b/src/java/terminal.java
@@ -350,6 +350,16 @@ public class terminal
public native int popup_dialog(int id, String title, String message, String secondary);
/**
+ * Launch a lib3270 action by name.
+ *
+ * @param name Name of the action to fire.
+ *
+ * @return Return code of the action call.
+ *
+ */
+ public native int action(String name);
+
+ /**
* File selection dialog.
*
* @param action Dialog action.
diff --git a/src/lib3270/actions.c b/src/lib3270/actions.c
index 82d7e5f..bdf830e 100644
--- a/src/lib3270/actions.c
+++ b/src/lib3270/actions.c
@@ -18,122 +18,67 @@
* 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 actions.c e possui 877 linhas de código.
+ * Este programa está nomeado como actions.c e possui - linhas de código.
*
* Contatos:
*
* perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
* erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- * licinio@bb.com.br (Licínio Luis Branco)
- * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
- * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
*
*/
-/*
- * actions.c
- * The X actions table and action debugging code.
- */
-
#include "globals.h"
-#include "appres.h"
+#include
-#include "actionsc.h"
-#include "hostc.h"
-#include "kybdc.h"
-#include "popupsc.h"
-#include "printc.h"
-#include "resources.h"
-#include "togglesc.h"
-#include "trace_dsc.h"
-#include "utilc.h"
-#include "xioc.h"
+/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
-#if defined(X3270_FT) /*[*/
-#include "ftc.h"
-#endif /*]*/
-// #if defined(X3270_DISPLAY)
-// #include "keypadc.h"
-//#endif
-#if defined(X3270_DISPLAY) || defined(C3270) || defined(WC3270) /*[*/
-#include "screenc.h"
-#endif /*]*/
+/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/
-#error Deprecated
+/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
-/*
+/**
+ * @brief Launch an action by name.
+ *
+ */
+LIB3270_EXPORT int lib3270_action(H3270 *hSession, const char *name)
+{
+ #undef DECLARE_LIB3270_ACTION
+ #undef DECLARE_LIB3270_CLEAR_SELECTION_ACTION
+ #undef DECLARE_LIB3270_KEY_ACTION
+ #undef DECLARE_LIB3270_CURSOR_ACTION
+ #undef DECLARE_LIB3270_FKEY_ACTION
-#if defined(X3270_DISPLAY)
-#include
+ #define DECLARE_LIB3270_ACTION( name ) { #name, lib3270_ ## name },
+ #define DECLARE_LIB3270_CLEAR_SELECTION_ACTION( name ) { #name, lib3270_ ## name },
+ #define DECLARE_LIB3270_KEY_ACTION( name ) { #name, lib3270_ ## name },
+ #define DECLARE_LIB3270_CURSOR_ACTION( name ) { #name, lib3270_cursor_ ## name },
+ #define DECLARE_LIB3270_FKEY_ACTION( name ) // name
-#define MODMAP_SIZE 8
-#define MAP_SIZE 13
-#define MAX_MODS_PER 4
-static struct {
- const char *name[MAX_MODS_PER];
- unsigned int mask;
- Boolean is_meta;
-} skeymask[MAP_SIZE] = {
- { { "Shift" }, ShiftMask, False },
- { { (char *)NULL } //, LockMask, False },
- { { "Ctrl" }, ControlMask, False },
- { { CN }, Mod1Mask, False },
- { { CN }, Mod2Mask, False },
- { { CN }, Mod3Mask, False },
- { { CN }, Mod4Mask, False },
- { { CN }, Mod5Mask, False },
- { { "Button1" }, Button1Mask, False },
- { { "Button2" }, Button2Mask, False },
- { { "Button3" }, Button3Mask, False },
- { { "Button4" }, Button4Mask, False },
- { { "Button5" }, Button5Mask, False }
-};
-static Boolean know_mods = False;
-#endif */
+ static const struct _action
+ {
+ const char * name;
+ int (*call)(H3270 *h);
+ } action[] =
+ {
+ #include
+ };
-/* Actions that are aliases for other actions. */
-/*
-static char *aliased_actions[] = {
- "Close", "HardPrint", "Open", NULL
-};
-*/
+ size_t f;
-/*
-enum iaction ia_cause;
-const char *ia_name[] = {
- "String", "Paste", "Screen redraw", "Keypad", "Default", "Key",
- "Macro", "Script", "Peek", "Typeahead", "File transfer", "Command",
- "Keymap", "Idle"
-};
-*/
+ CHECK_SESSION_HANDLE(hSession);
-/*
- * Return a name for an action.
- */ /*
-const char * action_name(XtActionProc action)
-{
- // TODO (perry#1#): Remove all calls to action_name; move all action processing to main program.
- return "Action";
-}
-*/
-/*
- * Check the number of argument to an action, and possibly pop up a usage
- * message.
- *
- * Returns 0 if the argument count is correct, -1 otherwise.
- */ /*
-int
-check_usage(XtActionProc action, Cardinal nargs, Cardinal nargs_min,
- Cardinal nargs_max)
-{
- if (nargs >= nargs_min && nargs <= nargs_max)
- return 0;
- if (nargs_min == nargs_max)
- popup_an_error("Action requires %d argument%s",action, nargs_min, nargs_min == 1 ? "" : "s");
- else
- popup_an_error("Action requires %d or %d arguments",nargs_min, nargs_max);
-// cancel_if_idle_command();
- return -1;
-} */
+ for(f=0; f< (sizeof(action)/sizeof(action[0])); f++)
+ {
+ if(!strcasecmp(name,action[f].name))
+ {
+ lib3270_trace_event(hSession,"Action %s activated\n",name);
+ return action[f].call(hSession);
+ }
+
+ }
+ lib3270_trace_event(hSession,"Unknown action %s\n",name);
+ errno = ENOENT;
+ return -1;
+}
diff --git a/src/lib3270/sources.mak b/src/lib3270/sources.mak
index f58a492..d885cd1 100644
--- a/src/lib3270/sources.mak
+++ b/src/lib3270/sources.mak
@@ -28,7 +28,7 @@
TERMINAL_SOURCES = bounds.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \
host.c sf.c ansi.c resolver.c charset.c \
version.c session.c state.c html.c trace_ds.c see.c \
- paste.c ssl.c
+ paste.c ssl.c actions.c
# tables.c utf8.c
diff --git a/src/plugins/dbus3270/gobject.c b/src/plugins/dbus3270/gobject.c
index b79c94f..9d93832 100644
--- a/src/plugins/dbus3270/gobject.c
+++ b/src/plugins/dbus3270/gobject.c
@@ -430,9 +430,14 @@ void pw3270_dbus_pa_key(PW3270Dbus *object, int key, DBusGMethodInvocation *cont
dbus_g_method_return(context,lib3270_get_is_protected_at(pw3270_dbus_get_session_handle(object),row,col));
}
+ void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context)
+ {
+ trace("%s object=%p context=%p",__FUNCTION__,object,context);
+ dbus_g_method_return(context,lib3270_action(pw3270_dbus_get_session_handle(object),text));
+ }
-void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context)
-{
+ void pw3270_dbus_get_clipboard(PW3270Dbus *object, DBusGMethodInvocation *context)
+ {
gchar *text;
trace("%s object=%p context=%p",__FUNCTION__,object,context);
diff --git a/src/plugins/dbus3270/pw3270dbus.xml b/src/plugins/dbus3270/pw3270dbus.xml
index 7f07b05..601b48e 100644
--- a/src/plugins/dbus3270/pw3270dbus.xml
+++ b/src/plugins/dbus3270/pw3270dbus.xml
@@ -197,6 +197,12 @@
+
+
+
+
+
+
diff --git a/src/plugins/dbus3270/service.h b/src/plugins/dbus3270/service.h
index c232cda..29420a0 100644
--- a/src/plugins/dbus3270/service.h
+++ b/src/plugins/dbus3270/service.h
@@ -90,13 +90,15 @@
void pw3270_dbus_get_field_length(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
void pw3270_dbus_get_next_unprotected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
- void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
+ void pw3270_dbus_get_is_protected(PW3270Dbus *object, int baddr, DBusGMethodInvocation *context);
void pw3270_dbus_get_is_protected_at(PW3270Dbus *object, int row, int col, DBusGMethodInvocation *context);
void pw3270_dbus_set_script(PW3270Dbus *object, const gchar *text, int mode, DBusGMethodInvocation *context);
void pw3270_dbus_show_popup(PW3270Dbus *object, int id, const gchar *title, const gchar *msg, const gchar *text, DBusGMethodInvocation *context);
+ void pw3270_dbus_action(PW3270Dbus *object, const gchar *text, DBusGMethodInvocation *context);
+
// Actions
void pw3270_dbus_enter(PW3270Dbus *object, DBusGMethodInvocation *context);
void pw3270_dbus_pf_key(PW3270Dbus *object, int key, DBusGMethodInvocation *context);
diff --git a/src/plugins/hllapi/pluginmain.c b/src/plugins/hllapi/pluginmain.c
index e501736..c878542 100644
--- a/src/plugins/hllapi/pluginmain.c
+++ b/src/plugins/hllapi/pluginmain.c
@@ -386,6 +386,12 @@
send_text(source,(char *) lib3270_get_host_charset(lib3270_get_default_session_handle()));
break;
+ case HLLAPI_PACKET_ACTION:
+ send_result(source,lib3270_action(lib3270_get_default_session_handle(),
+ (const char *) ((struct hllapi_packet_text *) source->buffer)->text);
+ break;
+
+
default:
send_result(source, EINVAL);
g_message("Invalid remote request (id=%d)",source->buffer[0]);
diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc
index d1146db..7cad14a 100644
--- a/src/plugins/rx3270/pluginmain.cc
+++ b/src/plugins/rx3270/pluginmain.cc
@@ -148,6 +148,7 @@
int file_transfer(LIB3270_FT_OPTION options, const gchar *local, const gchar *remote, int lrecl = 0, int blksize = 0, int primspace = 0, int secspace = 0, int dft = 4096);
int quit(void);
+ int action(const char *name);
protected:
@@ -766,6 +767,11 @@ int plugin::quit(void)
return 0;
}
+int plugin::action(const char *name)
+{
+ return lib3270_action(hSession,name);
+}
+
int plugin::set_host_charset(const char *charset)
{
return lib3270_set_host_charset(hSession,charset);
diff --git a/src/pw3270/actions.c b/src/pw3270/actions.c
index c3503a4..3c38169 100644
--- a/src/pw3270/actions.c
+++ b/src/pw3270/actions.c
@@ -57,7 +57,7 @@
/*--[ Implement ]------------------------------------------------------------------------------------*/
-static void lib3270_action(GtkAction *action, GtkWidget *widget)
+static void do_lib3270_action(GtkAction *action, GtkWidget *widget)
{
int (*call)(H3270 *h) = (int (*)(H3270 *h)) g_object_get_data(G_OBJECT(action),"lib3270_call");
@@ -270,7 +270,7 @@ static void connect_standard_action(GtkAction *action, GtkWidget *widget, const
if(!g_ascii_strcasecmp(name,lib3270_entry[f].name))
{
g_object_set_data(G_OBJECT(action),"lib3270_call",lib3270_entry[f].call);
- g_signal_connect(action,"activate",G_CALLBACK(lib3270_action),widget);
+ g_signal_connect(action,"activate",G_CALLBACK(do_lib3270_action),widget);
return;
}
}
@@ -834,7 +834,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash
case ACTION_TYPE_LIB3270:
action = new_action(nm,names,values);
g_object_set_data(G_OBJECT(action),"lib3270_call",callback[id]);
- g_signal_connect(action,"activate",G_CALLBACK(lib3270_action),widget);
+ g_signal_connect(action,"activate",G_CALLBACK(do_lib3270_action),widget);
break;
case ACTION_TYPE_STRING:
--
libgit2 0.21.2