Commit 61045cafe255666648ed100c187a2a497bde1ae2
1 parent
72623bf1
Exists in
master
and in
5 other branches
Iniciando implementação de novas funções para o plugin hllapi
Showing
6 changed files
with
68 additions
and
80 deletions
Show diff stats
src/include/pw3270/hllapi.h
| ... | ... | @@ -38,16 +38,25 @@ |
| 38 | 38 | extern "C" { |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | - #define HLLAPI_REQUEST_ID 0x01 | |
| 41 | + #define HLLAPI_REQUEST_QUERY 0x01 | |
| 42 | + #define HLLAPI_RESPONSE_VALUE 0x02 | |
| 43 | + #define HLLAPI_RESPONSE_TEXT 0x03 | |
| 44 | + | |
| 42 | 45 | #define HLLAPI_MAXLENGTH 32768 |
| 43 | 46 | |
| 44 | 47 | #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ |
| 45 | 48 | #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ |
| 46 | 49 | #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ |
| 47 | 50 | #define HLLAPI_CMD_WAIT 4 /**< Wait if the session is waiting for a host response */ |
| 51 | + #define HLLAPI_CMD_COPYPS 5 /**< Copies the contents of the presentation space into a string buffer. */ | |
| 52 | + #define HLLAPI_CMD_SEARCHPS 6 /**< Search the presentation space for a specified string. */ | |
| 53 | + #define HLLAPI_CMD_QUERYCURSOR 7 /**< Determines the location of the cursor in the presentation space. */ | |
| 54 | + #define HLLAPI_CMD_COPYPSTOSTR 8 /**< Copy presentation space to string */ | |
| 55 | + #define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */ | |
| 56 | + #define HLLAPI_CMD_SETCURSOR 40 /**< Places the cursor at a specified position in presentation space.*/ | |
| 57 | + #define HLLAPI_CMD_SENDFILE 90 /**< Send file to the host */ | |
| 58 | + #define HLLAPI_CMD_RECEIVEFILE 91 /**< Receive a file from the host */ | |
| 48 | 59 | |
| 49 | - #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ | |
| 50 | - #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ | |
| 51 | 60 | #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ |
| 52 | 61 | |
| 53 | 62 | #pragma pack(1) |
| ... | ... | @@ -56,7 +65,7 @@ extern "C" { |
| 56 | 65 | unsigned char id; /**< Request id */ |
| 57 | 66 | unsigned long func; /**< Function number */ |
| 58 | 67 | unsigned short rc; /**< Short argument/return code */ |
| 59 | - unsigned short len; /**< Text length */ | |
| 68 | + unsigned int value; /**< Requested value */ | |
| 60 | 69 | char string[1]; /**< String argument */ |
| 61 | 70 | } HLLAPI_DATA; |
| 62 | 71 | #pragma pack() | ... | ... |
src/plugins/remotectl/hllapi.c
| ... | ... | @@ -98,10 +98,10 @@ |
| 98 | 98 | |
| 99 | 99 | memset(buffer,0,HLLAPI_MAXLENGTH); |
| 100 | 100 | |
| 101 | - data->id = HLLAPI_REQUEST_ID; | |
| 101 | + data->id = HLLAPI_REQUEST_QUERY; | |
| 102 | 102 | data->func = func; |
| 103 | 103 | data->rc = *rc; |
| 104 | - data->len = *length; | |
| 104 | + data->value = *length; | |
| 105 | 105 | |
| 106 | 106 | if(arg && *length > 0) |
| 107 | 107 | memcpy(data->string,arg,*length); |
| ... | ... | @@ -116,15 +116,15 @@ |
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | 118 | *rc = buffer->rc; |
| 119 | - *length = buffer->len; | |
| 119 | + *length = buffer->value; | |
| 120 | 120 | |
| 121 | - trace("buffer->len=%d rc=%d",buffer->len,buffer->rc); | |
| 121 | + trace("buffer->id=%d buffer->value=%d rc=%d",buffer->id,buffer->value,buffer->rc); | |
| 122 | 122 | |
| 123 | - if(buffer->len > 0) | |
| 123 | + if(buffer->value > 0 && buffer->id == HLLAPI_RESPONSE_TEXT) | |
| 124 | 124 | { |
| 125 | - outBuffer = malloc(buffer->len+1); | |
| 126 | - memcpy(outBuffer,buffer->string,buffer->len); | |
| 127 | - outBuffer[buffer->len] = 0; | |
| 125 | + outBuffer = malloc(buffer->value+1); | |
| 126 | + memcpy(outBuffer,buffer->string,buffer->value); | |
| 127 | + outBuffer[buffer->value] = 0; | |
| 128 | 128 | |
| 129 | 129 | trace("outBuffer=[%s]",outBuffer); |
| 130 | 130 | } | ... | ... |
src/plugins/remotectl/pipesource.c
| ... | ... | @@ -143,12 +143,12 @@ static void wait_for_client(pipe_source *source) |
| 143 | 143 | qry->hPipe = source->hPipe; |
| 144 | 144 | qry->text = (const gchar *) (qry+1); |
| 145 | 145 | |
| 146 | - if(data->id == 0x01) | |
| 146 | + if(data->id == HLLAPI_REQUEST_QUERY) | |
| 147 | 147 | { |
| 148 | 148 | // HLLAPI query |
| 149 | 149 | qry->cmd = (int) data->func; |
| 150 | 150 | qry->pos = (int) data->rc; |
| 151 | - qry->length = data->len; | |
| 151 | + qry->length = data->value; | |
| 152 | 152 | memcpy((gchar *)(qry->text),data->string,qry->length); |
| 153 | 153 | } |
| 154 | 154 | else |
| ... | ... | @@ -175,26 +175,29 @@ static void wait_for_client(pipe_source *source) |
| 175 | 175 | { |
| 176 | 176 | request_buffer(qry, rc, 0, NULL); |
| 177 | 177 | } |
| 178 | -/* | |
| 179 | - HLLAPI_DATA data; | |
| 178 | + } | |
| 180 | 179 | |
| 181 | - memset(&data,0,sizeof(data)); | |
| 180 | + void request_value(QUERY *qry, int rc, unsigned int value) | |
| 181 | + { | |
| 182 | + HLLAPI_DATA data; | |
| 182 | 183 | |
| 183 | - data.id = 0x01; | |
| 184 | + memset(&data,0,sizeof(data)); | |
| 185 | + data.id = HLLAPI_RESPONSE_VALUE; | |
| 184 | 186 | data.func = qry->cmd; |
| 185 | 187 | data.rc = rc; |
| 186 | - | |
| 187 | - trace("rc=%d",rc); | |
| 188 | + data.value = value; | |
| 188 | 189 | |
| 189 | 190 | #ifdef WIN32 |
| 190 | 191 | { |
| 191 | 192 | DWORD wrote = sizeof(data); |
| 192 | 193 | WriteFile(qry->hPipe,&data,wrote,&wrote,NULL); |
| 194 | + trace("Wrote=%d len=%d",(int) wrote, sizeof(data)); | |
| 193 | 195 | } |
| 194 | 196 | #endif // WIN32 |
| 195 | 197 | |
| 196 | 198 | g_free(qry); |
| 197 | -*/ | |
| 199 | + | |
| 200 | + | |
| 198 | 201 | } |
| 199 | 202 | |
| 200 | 203 | void request_buffer(QUERY *qry, int rc, size_t szBuffer, const gpointer buffer) |
| ... | ... | @@ -206,20 +209,21 @@ static void wait_for_client(pipe_source *source) |
| 206 | 209 | { |
| 207 | 210 | sz = sizeof(HLLAPI_DATA)+szBuffer; |
| 208 | 211 | data = g_malloc0(sz); |
| 209 | - data->len = szBuffer; | |
| 212 | + data->id = HLLAPI_RESPONSE_TEXT; | |
| 210 | 213 | memcpy(data->string,buffer,szBuffer); |
| 211 | 214 | } |
| 212 | 215 | else |
| 213 | 216 | { |
| 214 | - sz = sizeof(HLLAPI_DATA); | |
| 215 | - data = g_malloc0(sz); | |
| 217 | + sz = sizeof(HLLAPI_DATA); | |
| 218 | + data = g_malloc0(sz); | |
| 219 | + data->id = HLLAPI_RESPONSE_VALUE; | |
| 216 | 220 | } |
| 217 | 221 | |
| 218 | - data->id = 0x01; | |
| 219 | 222 | data->func = qry->cmd; |
| 220 | 223 | data->rc = rc; |
| 224 | + data->value = szBuffer; | |
| 221 | 225 | |
| 222 | - trace("rc=%d data->len=%d",rc,(int) data->len); | |
| 226 | + trace("rc=%d data->len=%d",rc,(int) szBuffer); | |
| 223 | 227 | |
| 224 | 228 | #ifdef WIN32 |
| 225 | 229 | { | ... | ... |
src/plugins/remotectl/remotectl.c
| ... | ... | @@ -405,6 +405,11 @@ |
| 405 | 405 | g_free(buffer); |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | + static void cmd_querycursor(QUERY *qry) | |
| 409 | + { | |
| 410 | + request_value(qry,0,lib3270_get_cursor_address(qry->hSession)); | |
| 411 | + } | |
| 412 | + | |
| 408 | 413 | void enqueue_request(QUERY *qry) |
| 409 | 414 | { |
| 410 | 415 | static const struct _cmd |
| ... | ... | @@ -413,15 +418,29 @@ |
| 413 | 418 | void (*exec)(QUERY *qry); |
| 414 | 419 | } cmd[] = |
| 415 | 420 | { |
| 416 | - { HLLAPI_CMD_CONNECTPS, cmd_connectps }, | |
| 417 | - { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, | |
| 418 | - { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, | |
| 419 | - { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, | |
| 421 | + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, // 1 | |
| 422 | + { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, // 2 | |
| 423 | + { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, // 3 | |
| 424 | + { HLLAPI_CMD_WAIT, cmd_wait }, // 4 | |
| 425 | +// { HLLAPI_CMD_COPYPS, }, // 5 | |
| 426 | +// { HLLAPI_CMD_SEARCHPS, }, // 6 | |
| 427 | + { HLLAPI_CMD_QUERYCURSOR, cmd_querycursor }, // 7 | |
| 428 | + | |
| 429 | + { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, // 8 | |
| 430 | + | |
| 431 | +// { HLLAPI_CMD_COPYSTRTOPS }, // 15 | |
| 432 | + | |
| 433 | + { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, // 40 | |
| 434 | + | |
| 435 | +// { HLLAPI_CMD_SENDFILE }, // 90 | |
| 436 | +// { HLLAPI_CMD_RECEIVEFILE }, | |
| 437 | + | |
| 438 | + | |
| 420 | 439 | { HLLAPI_CMD_GETREVISION, cmd_getrevision }, |
| 421 | - { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, | |
| 422 | - { HLLAPI_CMD_WAIT, cmd_wait }, | |
| 423 | 440 | }; |
| 424 | 441 | |
| 442 | + | |
| 443 | + | |
| 425 | 444 | int f; |
| 426 | 445 | |
| 427 | 446 | trace("HLLAPI function %d",(int) qry->cmd); |
| ... | ... | @@ -441,23 +460,6 @@ |
| 441 | 460 | request_status(qry,EINVAL); |
| 442 | 461 | } |
| 443 | 462 | |
| 444 | -/* | |
| 445 | - int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc) | |
| 446 | - { | |
| 447 | - | |
| 448 | - trace("HLLAPI function %d",(int) function); | |
| 449 | - | |
| 450 | - for(f=0;f<G_N_ELEMENTS(cmd);f++) | |
| 451 | - { | |
| 452 | - if(cmd[f].function == function) | |
| 453 | - return cmd[f].exec(lib3270_get_default_session_handle(),rc,string,length); | |
| 454 | - } | |
| 455 | - | |
| 456 | - g_warning("Unexpected HLLAPI function %d",(int) function); | |
| 457 | - return EINVAL; | |
| 458 | - } | |
| 459 | -*/ | |
| 460 | - | |
| 461 | 463 | G_GNUC_INTERNAL void set_active(gboolean on) |
| 462 | 464 | { |
| 463 | 465 | v3270_set_script(pw3270_get_terminal_widget(NULL),'H',on); | ... | ... |
src/plugins/remotectl/remotectl.h
| ... | ... | @@ -61,7 +61,9 @@ |
| 61 | 61 | G_GNUC_INTERNAL void set_active(gboolean on); |
| 62 | 62 | G_GNUC_INTERNAL void enqueue_request(QUERY *qry); |
| 63 | 63 | G_GNUC_INTERNAL void request_complete(QUERY *qry, int rc, const gchar *text); |
| 64 | + | |
| 64 | 65 | G_GNUC_INTERNAL void request_status(QUERY *qry, int rc); |
| 66 | + G_GNUC_INTERNAL void request_value(QUERY *qry, int rc, unsigned int value); | |
| 65 | 67 | G_GNUC_INTERNAL void request_buffer(QUERY *qry, int rc, size_t sz, const gpointer buffer); |
| 66 | 68 | |
| 67 | 69 | // int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc); | ... | ... |
src/pw3270/filetransfer.c
| ... | ... | @@ -177,7 +177,7 @@ static void check_entry(GtkEditable *editable, struct ftdialog *dlg) |
| 177 | 177 | gtk_widget_set_sensitive(dlg->ready,is_dialog_ok(editable,dlg)); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | -static GtkWidget * add_filename_entry(GObject *action, int ix, int row, struct ftdialog *dlg, GtkTable *table) | |
| 180 | +static GtkEntry * add_filename_entry(GObject *action, int ix, int row, struct ftdialog *dlg, GtkTable *table) | |
| 181 | 181 | { |
| 182 | 182 | static const gchar * label_text[] = { N_( "_Local file name:" ), N_( "_Host file name:" ) }; |
| 183 | 183 | static const gchar * attr[] = { "local", "remote" }; |
| ... | ... | @@ -201,14 +201,13 @@ static GtkWidget * add_filename_entry(GObject *action, int ix, int row, struct f |
| 201 | 201 | |
| 202 | 202 | gtk_table_attach(GTK_TABLE(table),entry,1,3,row,row+1,GTK_EXPAND|GTK_SHRINK|GTK_FILL,GTK_EXPAND|GTK_SHRINK|GTK_FILL,2,2); |
| 203 | 203 | |
| 204 | - return entry; | |
| 204 | + return GTK_ENTRY(entry); | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | static void add_file_fields(GObject *action, struct ftdialog *dlg) |
| 208 | 208 | { |
| 209 | 209 | GtkTable * table = GTK_TABLE(gtk_table_new(2,3,FALSE)); |
| 210 | 210 | GtkWidget * widget; |
| 211 | - int f; | |
| 212 | 211 | |
| 213 | 212 | gtk_container_set_border_width(GTK_CONTAINER(table),2); |
| 214 | 213 | |
| ... | ... | @@ -232,34 +231,6 @@ static void add_file_fields(GObject *action, struct ftdialog *dlg) |
| 232 | 231 | |
| 233 | 232 | dlg->file[1] = add_filename_entry(action,1,1,dlg,table); |
| 234 | 233 | } |
| 235 | - | |
| 236 | - | |
| 237 | -/* | |
| 238 | - for(f=0;f<2;f++) | |
| 239 | - { | |
| 240 | - | |
| 241 | - gchar *val; | |
| 242 | - | |
| 243 | - widget = gtk_label_new_with_mnemonic(gettext(label[f])); | |
| 244 | - | |
| 245 | - gtk_misc_set_alignment(GTK_MISC(widget),0,.5); | |
| 246 | - gtk_table_attach(GTK_TABLE(table),widget,0,1,f,f+1,GTK_FILL,GTK_FILL,2,2); | |
| 247 | - | |
| 248 | - dlg->file[f] = GTK_ENTRY(gtk_entry_new()); | |
| 249 | - | |
| 250 | - gtk_widget_set_name(GTK_WIDGET(dlg->file[f]),attr[f]); | |
| 251 | - | |
| 252 | - val = get_attribute(action,dlg,attr[f]); | |
| 253 | - gtk_entry_set_text(dlg->file[f],val); | |
| 254 | - g_free(val); | |
| 255 | - | |
| 256 | - gtk_entry_set_width_chars(dlg->file[f],40); | |
| 257 | - | |
| 258 | - gtk_label_set_mnemonic_widget(GTK_LABEL(widget),GTK_WIDGET(dlg->file[f])); | |
| 259 | - | |
| 260 | - gtk_table_attach(GTK_TABLE(table),GTK_WIDGET(dlg->file[f]),1,3,f,f+1,GTK_EXPAND|GTK_SHRINK|GTK_FILL,GTK_EXPAND|GTK_SHRINK|GTK_FILL,2,2); | |
| 261 | - } | |
| 262 | -*/ | |
| 263 | 234 | |
| 264 | 235 | gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg->dialog))),GTK_WIDGET(table),FALSE,FALSE,2); |
| 265 | 236 | ... | ... |