Commit d851a9708b84f4a130c1b8ed3fffb50bec19e7b7
1 parent
71c1ea6a
Exists in
master
and in
5 other branches
Finalizando classe de apoio para extensões
Showing
6 changed files
with
405 additions
and
18 deletions
Show diff stats
src/classlib/Makefile.in
| ... | ... | @@ -48,7 +48,7 @@ LN_S=@LN_S@ |
| 48 | 48 | |
| 49 | 49 | #---[ Flags ]------------------------------------------------------------------ |
| 50 | 50 | |
| 51 | -CFLAGS=@CFLAGS@ @DBUS_CFLAGS@ -I../include | |
| 51 | +CFLAGS=@CFLAGS@ @DBUS_CFLAGS@ @GTK_CFLAGS@ -I../include | |
| 52 | 52 | LIBS=@LIBS@ @LIBICONV@ @DBUS_LIBS@ |
| 53 | 53 | |
| 54 | 54 | DEBUG_CFLAGS=-DDEBUG=1 -g -Wall | ... | ... |
src/classlib/classlib.cbp
| ... | ... | @@ -33,11 +33,10 @@ |
| 33 | 33 | <Compiler> |
| 34 | 34 | <Add option="-Wall" /> |
| 35 | 35 | </Compiler> |
| 36 | - <Unit filename="Makefile" /> | |
| 36 | + <Unit filename="Makefile.in" /> | |
| 37 | 37 | <Unit filename="exception.cc" /> |
| 38 | 38 | <Unit filename="local.cc" /> |
| 39 | 39 | <Unit filename="main.cc" /> |
| 40 | - <Unit filename="pw3270class.h" /> | |
| 41 | 40 | <Unit filename="remote.cc" /> |
| 42 | 41 | <Unit filename="session.cc" /> |
| 43 | 42 | <Unit filename="testprogram.cc" /> | ... | ... |
src/classlib/local.cc
| ... | ... | @@ -481,6 +481,61 @@ |
| 481 | 481 | return _get_cursor_addr(hSession); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | + int enter(void) | |
| 485 | + { | |
| 486 | + return _enter(hSession); | |
| 487 | + } | |
| 488 | + | |
| 489 | + int pfkey(int key) | |
| 490 | + { | |
| 491 | + return _pfkey(hSession,key); | |
| 492 | + } | |
| 493 | + | |
| 494 | + int pakey(int key) | |
| 495 | + { | |
| 496 | + return _pakey(hSession,key); | |
| 497 | + } | |
| 498 | + | |
| 499 | + int quit(void) | |
| 500 | + { | |
| 501 | + return EINVAL; | |
| 502 | + } | |
| 503 | + | |
| 504 | + int set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 505 | + { | |
| 506 | + return _set_toggle(hSession, ix, (int) value); | |
| 507 | + } | |
| 508 | + | |
| 509 | + int emulate_input(const char *str) | |
| 510 | + { | |
| 511 | + return _emulate_input(hSession,str,-1,1); | |
| 512 | + } | |
| 513 | + | |
| 514 | + int get_field_start(int baddr) | |
| 515 | + { | |
| 516 | + return _get_field_start(hSession,baddr); | |
| 517 | + } | |
| 518 | + | |
| 519 | + int get_field_len(int baddr) | |
| 520 | + { | |
| 521 | + return _get_field_len(hSession,baddr); | |
| 522 | + } | |
| 523 | + | |
| 524 | + int get_next_unprotected(int baddr) | |
| 525 | + { | |
| 526 | + return _get_next_unprotected(hSession,baddr); | |
| 527 | + } | |
| 528 | + | |
| 529 | + int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | |
| 530 | + { | |
| 531 | + va_list args; | |
| 532 | + va_start(args, fmt); | |
| 533 | + _popup_va(hSession, id, title, message, fmt, args); | |
| 534 | + va_end(args); | |
| 535 | + return 0; | |
| 536 | + } | |
| 537 | + | |
| 538 | + | |
| 484 | 539 | }; |
| 485 | 540 | |
| 486 | 541 | session * session::create_local(void) | ... | ... |
src/classlib/remote.cc
| ... | ... | @@ -842,6 +842,306 @@ |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | |
| 845 | + int enter(void) | |
| 846 | + { | |
| 847 | +#if defined(WIN32) | |
| 848 | + | |
| 849 | + return query_intval(HLLAPI_PACKET_ENTER); | |
| 850 | + | |
| 851 | +#elif defined(HAVE_DBUS) | |
| 852 | + | |
| 853 | + return query_intval("enter"); | |
| 854 | + | |
| 855 | +#else | |
| 856 | + | |
| 857 | + return -1; | |
| 858 | + | |
| 859 | +#endif | |
| 860 | + | |
| 861 | + } | |
| 862 | + | |
| 863 | + int pfkey(int key) | |
| 864 | + { | |
| 865 | +#if defined(WIN32) | |
| 866 | + | |
| 867 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PFKEY, (unsigned short) key }; | |
| 868 | + struct hllapi_packet_result response; | |
| 869 | + DWORD cbSize = sizeof(query); | |
| 870 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 871 | + return response.rc; | |
| 872 | + | |
| 873 | +#elif defined(HAVE_DBUS) | |
| 874 | + | |
| 875 | + dbus_int32_t k = (dbus_int32_t) key; | |
| 876 | + | |
| 877 | + DBusMessage * msg = create_message("pfKey"); | |
| 878 | + if(msg) | |
| 879 | + { | |
| 880 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 881 | + return get_intval(call(msg)); | |
| 882 | + } | |
| 883 | + | |
| 884 | + return -1; | |
| 885 | + | |
| 886 | +#else | |
| 887 | + | |
| 888 | + return -1; | |
| 889 | + | |
| 890 | +#endif | |
| 891 | + | |
| 892 | + } | |
| 893 | + | |
| 894 | + int pakey(int key) | |
| 895 | + { | |
| 896 | +#if defined(WIN32) | |
| 897 | + | |
| 898 | + struct hllapi_packet_keycode query = { HLLAPI_PACKET_PAKEY, (unsigned short) key }; | |
| 899 | + struct hllapi_packet_result response; | |
| 900 | + DWORD cbSize = sizeof(query); | |
| 901 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 902 | + return response.rc; | |
| 903 | + | |
| 904 | +#elif defined(HAVE_DBUS) | |
| 905 | + | |
| 906 | + dbus_int32_t k = (dbus_int32_t) key; | |
| 907 | + | |
| 908 | + DBusMessage * msg = create_message("paKey"); | |
| 909 | + if(msg) | |
| 910 | + { | |
| 911 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 912 | + return get_intval(call(msg)); | |
| 913 | + } | |
| 914 | + return -1; | |
| 915 | + | |
| 916 | +#else | |
| 917 | + | |
| 918 | + return -1; | |
| 919 | + | |
| 920 | +#endif | |
| 921 | + | |
| 922 | + } | |
| 923 | + | |
| 924 | + int quit(void) | |
| 925 | + { | |
| 926 | +#if defined(WIN32) | |
| 927 | + | |
| 928 | + return query_intval(HLLAPI_PACKET_QUIT); | |
| 929 | + | |
| 930 | +#elif defined(HAVE_DBUS) | |
| 931 | + | |
| 932 | + return query_intval("quit"); | |
| 933 | + | |
| 934 | +#else | |
| 935 | + | |
| 936 | + return -1; | |
| 937 | + | |
| 938 | +#endif | |
| 939 | + | |
| 940 | + } | |
| 941 | + | |
| 942 | + int set_toggle(LIB3270_TOGGLE ix, bool value) | |
| 943 | + { | |
| 944 | +#if defined(WIN32) | |
| 945 | + | |
| 946 | + struct hllapi_packet_set query = { HLLAPI_PACKET_SET_TOGGLE, (unsigned short) ix, (unsigned short) value }; | |
| 947 | + struct hllapi_packet_result response; | |
| 948 | + DWORD cbSize = sizeof(query); | |
| 949 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 950 | + return response.rc; | |
| 951 | + | |
| 952 | +#elif defined(HAVE_DBUS) | |
| 953 | + | |
| 954 | + dbus_int32_t i = (dbus_int32_t) ix; | |
| 955 | + dbus_int32_t v = (dbus_int32_t) value; | |
| 956 | + | |
| 957 | + DBusMessage * msg = create_message("setToggle"); | |
| 958 | + if(msg) | |
| 959 | + { | |
| 960 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &i, DBUS_TYPE_INT32, &v, DBUS_TYPE_INVALID); | |
| 961 | + return get_intval(call(msg)); | |
| 962 | + } | |
| 963 | + | |
| 964 | + return -1; | |
| 965 | + | |
| 966 | +#else | |
| 967 | + return -1; | |
| 968 | + | |
| 969 | +#endif | |
| 970 | + | |
| 971 | + } | |
| 972 | + | |
| 973 | + int emulate_input(const char *str) | |
| 974 | + { | |
| 975 | +#if defined(WIN32) | |
| 976 | + | |
| 977 | + size_t len = strlen(str); | |
| 978 | + struct hllapi_packet_emulate_input * query; | |
| 979 | + struct hllapi_packet_result response; | |
| 980 | + DWORD cbSize = sizeof(struct hllapi_packet_emulate_input)+len; | |
| 981 | + | |
| 982 | + query = (struct hllapi_packet_emulate_input *) malloc(cbSize); | |
| 983 | + query->packet_id = HLLAPI_PACKET_EMULATE_INPUT; | |
| 984 | + query->len = len; | |
| 985 | + query->pasting = 1; | |
| 986 | + strcpy(query->text,str); | |
| 987 | + | |
| 988 | + TransactNamedPipe(hPipe,(LPVOID) query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 989 | + | |
| 990 | + free(query); | |
| 991 | + | |
| 992 | + return response.rc; | |
| 993 | + | |
| 994 | +#elif defined(HAVE_DBUS) | |
| 995 | + | |
| 996 | + DBusMessage * msg = create_message("input"); | |
| 997 | + if(msg) | |
| 998 | + { | |
| 999 | + dbus_message_append_args(msg, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID); | |
| 1000 | + return get_intval(call(msg)); | |
| 1001 | + } | |
| 1002 | + return -1; | |
| 1003 | + | |
| 1004 | +#else | |
| 1005 | + | |
| 1006 | + return -1; | |
| 1007 | + | |
| 1008 | +#endif | |
| 1009 | + | |
| 1010 | + } | |
| 1011 | + | |
| 1012 | + int get_field_start(int baddr) | |
| 1013 | + { | |
| 1014 | +#if defined(WIN32) | |
| 1015 | + | |
| 1016 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_START, (unsigned short) baddr }; | |
| 1017 | + struct hllapi_packet_result response; | |
| 1018 | + DWORD cbSize = sizeof(query); | |
| 1019 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 1020 | + return response.rc; | |
| 1021 | + | |
| 1022 | +#elif defined(HAVE_DBUS) | |
| 1023 | + | |
| 1024 | + dbus_int32_t k = (dbus_int32_t) baddr; | |
| 1025 | + | |
| 1026 | + DBusMessage * msg = create_message("getFieldStart"); | |
| 1027 | + if(msg) | |
| 1028 | + { | |
| 1029 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 1030 | + return get_intval(call(msg)); | |
| 1031 | + } | |
| 1032 | + | |
| 1033 | + return -1; | |
| 1034 | + | |
| 1035 | +#else | |
| 1036 | + | |
| 1037 | + return -1; | |
| 1038 | + | |
| 1039 | +#endif | |
| 1040 | + | |
| 1041 | + } | |
| 1042 | + | |
| 1043 | + int get_field_len(int baddr) | |
| 1044 | + { | |
| 1045 | +#if defined(WIN32) | |
| 1046 | + | |
| 1047 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_FIELD_LEN, (unsigned short) baddr }; | |
| 1048 | + struct hllapi_packet_result response; | |
| 1049 | + DWORD cbSize = sizeof(query); | |
| 1050 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 1051 | + return response.rc; | |
| 1052 | + | |
| 1053 | +#elif defined(HAVE_DBUS) | |
| 1054 | + | |
| 1055 | + dbus_int32_t k = (dbus_int32_t) baddr; | |
| 1056 | + | |
| 1057 | + DBusMessage * msg = create_message("getFieldLength"); | |
| 1058 | + if(msg) | |
| 1059 | + { | |
| 1060 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 1061 | + return get_intval(call(msg)); | |
| 1062 | + } | |
| 1063 | + | |
| 1064 | + return -1; | |
| 1065 | + | |
| 1066 | +#else | |
| 1067 | + | |
| 1068 | + return -1; | |
| 1069 | + | |
| 1070 | +#endif | |
| 1071 | + } | |
| 1072 | + | |
| 1073 | + int get_next_unprotected(int baddr) | |
| 1074 | + { | |
| 1075 | +#if defined(WIN32) | |
| 1076 | + | |
| 1077 | + struct hllapi_packet_addr query = { HLLAPI_PACKET_NEXT_UNPROTECTED, (unsigned short) baddr }; | |
| 1078 | + struct hllapi_packet_result response; | |
| 1079 | + DWORD cbSize = sizeof(query); | |
| 1080 | + TransactNamedPipe(hPipe,(LPVOID) &query, cbSize, &response, sizeof(response), &cbSize,NULL); | |
| 1081 | + return response.rc; | |
| 1082 | + | |
| 1083 | +#elif defined(HAVE_DBUS) | |
| 1084 | + | |
| 1085 | + dbus_int32_t k = (dbus_int32_t) baddr; | |
| 1086 | + | |
| 1087 | + DBusMessage * msg = create_message("getNextUnprotected"); | |
| 1088 | + if(msg) | |
| 1089 | + { | |
| 1090 | + dbus_message_append_args(msg, DBUS_TYPE_INT32, &k, DBUS_TYPE_INVALID); | |
| 1091 | + return get_intval(call(msg)); | |
| 1092 | + } | |
| 1093 | + | |
| 1094 | + return -1; | |
| 1095 | + | |
| 1096 | +#else | |
| 1097 | + | |
| 1098 | + return -1; | |
| 1099 | + | |
| 1100 | +#endif | |
| 1101 | + | |
| 1102 | + } | |
| 1103 | + | |
| 1104 | + int set_clipboard(const char *text) | |
| 1105 | + { | |
| 1106 | +#if defined(WIN32) | |
| 1107 | + | |
| 1108 | + return -1; | |
| 1109 | + | |
| 1110 | +#elif defined(HAVE_DBUS) | |
| 1111 | + | |
| 1112 | + DBusMessage * msg = create_message("setClipboard"); | |
| 1113 | + if(msg) | |
| 1114 | + { | |
| 1115 | + dbus_message_append_args(msg, DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); | |
| 1116 | + return get_intval(call(msg)); | |
| 1117 | + } | |
| 1118 | + | |
| 1119 | + return -1; | |
| 1120 | + | |
| 1121 | +#else | |
| 1122 | + | |
| 1123 | + return -1; | |
| 1124 | + | |
| 1125 | +#endif | |
| 1126 | + | |
| 1127 | + } | |
| 1128 | + | |
| 1129 | + string * get_clipboard(void) | |
| 1130 | + { | |
| 1131 | +#if defined(WIN32) | |
| 1132 | + | |
| 1133 | + return NULL; | |
| 1134 | + | |
| 1135 | +#elif defined(HAVE_DBUS) | |
| 1136 | + | |
| 1137 | + trace("%s",__FUNCTION__); | |
| 1138 | + return query_string("getClipboard"); | |
| 1139 | + | |
| 1140 | +#endif | |
| 1141 | + | |
| 1142 | + return NULL; | |
| 1143 | + } | |
| 1144 | + | |
| 845 | 1145 | }; |
| 846 | 1146 | |
| 847 | 1147 | session * session::create_remote(const char *session) | ... | ... |
src/classlib/session.cc
| ... | ... | @@ -156,7 +156,38 @@ |
| 156 | 156 | return ETIMEDOUT; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | + int session::set_copy(const char *text) | |
| 160 | + { | |
| 161 | + return EINVAL; | |
| 162 | + } | |
| 163 | + | |
| 164 | + string * session::get_copy(void) | |
| 165 | + { | |
| 166 | + errno = EINVAL; | |
| 167 | + return NULL; | |
| 168 | + } | |
| 159 | 169 | |
| 170 | + string * session::get_clipboard(void) | |
| 171 | + { | |
| 172 | + errno = EINVAL; | |
| 173 | + return NULL; | |
| 174 | + } | |
| 175 | + | |
| 176 | + int session::set_clipboard(const char *text) | |
| 177 | + { | |
| 178 | + return EINVAL; | |
| 179 | + } | |
| 180 | + | |
| 181 | + | |
| 182 | + int session::popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...) | |
| 183 | + { | |
| 184 | + return -1; | |
| 185 | + } | |
| 186 | + | |
| 187 | + string * session::file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename) | |
| 188 | + { | |
| 189 | + return NULL; | |
| 190 | + } | |
| 160 | 191 | |
| 161 | 192 | } |
| 162 | 193 | ... | ... |
src/include/pw3270/class.h
| ... | ... | @@ -40,6 +40,7 @@ |
| 40 | 40 | #include <exception> |
| 41 | 41 | #include <lib3270/config.h> |
| 42 | 42 | #include <lib3270.h> |
| 43 | + #include <lib3270/popup.h> | |
| 43 | 44 | |
| 44 | 45 | #ifdef HAVE_ICONV |
| 45 | 46 | #include <iconv.h> |
| ... | ... | @@ -48,6 +49,7 @@ |
| 48 | 49 | #include <string> |
| 49 | 50 | #include <stdarg.h> |
| 50 | 51 | #include <lib3270.h> |
| 52 | + #include <gtk/gtk.h> | |
| 51 | 53 | |
| 52 | 54 | namespace pw3270 |
| 53 | 55 | { |
| ... | ... | @@ -113,29 +115,29 @@ |
| 113 | 115 | virtual int set_cursor_addr(int addr) = 0; |
| 114 | 116 | virtual int get_cursor_addr(void) = 0; |
| 115 | 117 | |
| 116 | -// virtual int set_toggle(LIB3270_TOGGLE ix, bool value) = 0; | |
| 118 | + virtual int set_toggle(LIB3270_TOGGLE ix, bool value) = 0; | |
| 117 | 119 | |
| 118 | -// virtual int enter(void) = 0; | |
| 119 | -// virtual int pfkey(int key) = 0; | |
| 120 | -// virtual int pakey(int key) = 0; | |
| 120 | + virtual int enter(void) = 0; | |
| 121 | + virtual int pfkey(int key) = 0; | |
| 122 | + virtual int pakey(int key) = 0; | |
| 121 | 123 | |
| 122 | -// virtual int emulate_input(const char *str) = 0; | |
| 124 | + virtual int emulate_input(const char *str) = 0; | |
| 123 | 125 | |
| 124 | -// virtual int get_field_start(int baddr = -1) = 0; | |
| 125 | -// virtual int get_field_len(int baddr = -1) = 0; | |
| 126 | -// virtual int get_next_unprotected(int baddr = -1) = 0; | |
| 126 | + virtual int get_field_start(int baddr = -1) = 0; | |
| 127 | + virtual int get_field_len(int baddr = -1) = 0; | |
| 128 | + virtual int get_next_unprotected(int baddr = -1) = 0; | |
| 127 | 129 | |
| 128 | -// virtual int set_copy(const char *text); | |
| 129 | -// virtual char * get_copy(void); | |
| 130 | + virtual int set_copy(const char *text); | |
| 131 | + virtual string * get_copy(void); | |
| 130 | 132 | |
| 131 | -// virtual char * get_clipboard(void); | |
| 132 | -// virtual int set_clipboard(const char *text); | |
| 133 | + virtual string * get_clipboard(void); | |
| 134 | + virtual int set_clipboard(const char *text); | |
| 133 | 135 | |
| 134 | -// virtual int quit(void) = 0; | |
| 136 | + virtual int quit(void) = 0; | |
| 135 | 137 | |
| 136 | 138 | // Dialogs |
| 137 | -// virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | |
| 138 | -// virtual char * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); | |
| 139 | + virtual int popup_dialog(LIB3270_NOTIFY id , const char *title, const char *message, const char *fmt, ...); | |
| 140 | + virtual string * file_chooser_dialog(GtkFileChooserAction action, const char *title, const char *extension, const char *filename); | |
| 139 | 141 | |
| 140 | 142 | private: |
| 141 | 143 | ... | ... |