Commit 827dae935478547caa5df47aff018e33eb3fae3b

Authored by perry.werneck@gmail.com
1 parent fc25275f

Incluindo api de charset na versao windows

src/classlib/remote.cc
@@ -986,25 +986,58 @@ @@ -986,25 +986,58 @@
986 986
987 } 987 }
988 988
989 -#if defined(HAVE_DBUS)  
990 - string * get_clipboard(void) 989 + int set_host_charset(const char *charset)
991 { 990 {
992 - return query_string("getClipboard"); 991 +#if defined(WIN32)
  992 +
  993 + size_t len = strlen(charset);
  994 + struct hllapi_packet_set_text * query;
  995 + size_t cbSize = sizeof(struct hllapi_packet_set_text)+len;
  996 +
  997 + query = (struct hllapi_packet_set_text *) malloc(cbSize);
  998 + query->packet_id = HLLAPI_PACKET_SET_HOST_CHARSET;
  999 + query->len = len;
  1000 + strcpy(query->text,charset);
  1001 +
  1002 + return query_intval((void *) query, cbSize, true);
  1003 +
  1004 +#elif defined(HAVE_DBUS)
  1005 +
  1006 + return query_intval("setHostCharset", DBUS_TYPE_STRING, &charset, DBUS_TYPE_INVALID);
  1007 +
  1008 +#else
  1009 + return -1;
  1010 +#endif
993 } 1011 }
994 1012
995 - int set_clipboard(const char *text) 1013 + string * get_host_charset(void)
996 { 1014 {
997 - return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID); 1015 +#if defined(WIN32)
  1016 +
  1017 + struct hllapi_packet_query query = { HLLAPI_PACKET_GET_HOST_CHARSET };
  1018 + return query_string(&query,sizeof(query),100);
  1019 +
  1020 +#elif defined(HAVE_DBUS)
  1021 +
  1022 + return query_string("getHostCharset");
  1023 +
  1024 +#else
  1025 +
  1026 + return NULL;
  1027 +
  1028 +#endif
998 } 1029 }
999 1030
1000 - int set_host_charset(const char *charset) 1031 +
  1032 +#if defined(HAVE_DBUS)
  1033 + string * get_clipboard(void)
1001 { 1034 {
1002 - return query_intval("setHostCharset", DBUS_TYPE_STRING, &charset, DBUS_TYPE_INVALID); 1035 + return query_string("getClipboard");
1003 } 1036 }
1004 1037
1005 - string * get_host_charset(void) 1038 + int set_clipboard(const char *text)
1006 { 1039 {
1007 - return query_string("getHostCharset"); 1040 + return query_intval("setClipboard", DBUS_TYPE_STRING, &text, DBUS_TYPE_INVALID);
1008 } 1041 }
1009 1042
1010 string * get_display_charset(void) 1043 string * get_display_charset(void)
src/include/pw3270/ipcpackets.h
@@ -56,6 +56,9 @@ @@ -56,6 +56,9 @@
56 HLLAPI_PACKET_NEXT_UNPROTECTED, 56 HLLAPI_PACKET_NEXT_UNPROTECTED,
57 HLLAPI_PACKET_QUIT, 57 HLLAPI_PACKET_QUIT,
58 58
  59 + HLLAPI_PACKET_SET_HOST_CHARSET,
  60 + HLLAPI_PACKET_GET_HOST_CHARSET,
  61 +
59 HLLAPI_PACKET_INVALID 62 HLLAPI_PACKET_INVALID
60 63
61 } HLLAPI_PACKET; 64 } HLLAPI_PACKET;
@@ -162,6 +165,13 @@ struct hllapi_packet_set @@ -162,6 +165,13 @@ struct hllapi_packet_set
162 unsigned short value; 165 unsigned short value;
163 }; 166 };
164 167
  168 +struct hllapi_packet_set_text
  169 +{
  170 + unsigned char packet_id;
  171 + unsigned short len;
  172 + char text[1];
  173 +};
  174 +
165 175
166 #pragma pack() 176 #pragma pack()
167 177
src/plugins/hllapi/pluginmain.c
@@ -304,6 +304,15 @@ @@ -304,6 +304,15 @@
304 send_result(source,0); 304 send_result(source,0);
305 break; 305 break;
306 306
  307 + case HLLAPI_PACKET_SET_HOST_CHARSET:
  308 + send_result(source,lib3270_set_host_charset( lib3270_get_default_session_handle(),
  309 + (unsigned char *) ((struct hllapi_packet_set_text *) source->buffer)->text));
  310 + break;
  311 +
  312 + case HLLAPI_PACKET_GET_HOST_CHARSET:
  313 + send_text(source,lib3270_get_host_charset(lib3270_get_default_session_handle()));
  314 + break;
  315 +
307 default: 316 default:
308 send_result(source, EINVAL); 317 send_result(source, EINVAL);
309 g_message("Invalid remote request (id=%d)",source->buffer[0]); 318 g_message("Invalid remote request (id=%d)",source->buffer[0]);