From d0cd678b403c8d130b692dcd334fe71824d7befa Mon Sep 17 00:00:00 2001 From: David Freese Date: Sun, 16 Sep 2012 18:02:17 -0500 Subject: [PATCH] File transfer * Added escape encoding for all file types - Allows compressed files to transferred using either base64, base128 or base256 with escaped control bytes. * Added ability to transmit generic files including: - jpeg image - png images - xls, doc and other office documents * Transfer time computed for various levels of compression / base encoding --- src/Makefile.am | 7 + src/blank-dnd/blank.cxx | 16 ++ src/csv/csv.cxx | 16 ++ src/flmsg.cxx | 102 +++++++-- src/flmsg_dialog.cxx | 260 ++++++++++++++++++----- src/hics/hics203.cxx | 17 ++ src/hics/hics206.cxx | 17 ++ src/hics/hics213.cxx | 17 ++ src/hics/hics214.cxx | 17 ++ src/iaru/iaru.cxx | 28 ++- src/ics/ics203.cxx | 17 ++ src/ics/ics205.cxx | 17 ++ src/ics/ics205a.cxx | 17 ++ src/ics/ics206.cxx | 17 ++ src/ics/ics213.cxx | 17 ++ src/ics/ics214.cxx | 17 ++ src/ics/ics216.cxx | 17 ++ src/include/base128.h | 49 +++++ src/include/base256.h | 46 ++++ src/include/base64.h | 2 +- src/include/crc16.h | 4 + src/include/flmsg.h | 63 +++++- src/include/flmsg_config.h | 2 + src/include/flmsg_dialog.h | 29 ++- src/include/status.h | 2 + src/include/transfer.h | 18 ++ src/include/wrap.h | 4 +- src/lzma/LzmaDec.c | 18 ++ src/lzma/Types.h | 2 + src/mars/mars_army.cxx | 17 ++ src/mars/mars_daily.cxx | 17 ++ src/mars/mars_ineei.cxx | 17 ++ src/mars/mars_navy.cxx | 17 ++ src/mars/mars_net.cxx | 17 ++ src/nhc/hurricane.cxx | 17 ++ src/plaintext/plaintext.cxx | 17 ++ src/radiogram/radiogram.cxx | 16 ++ src/redx/redx_5739.cxx | 17 ++ src/redx/redx_5739A.cxx | 17 ++ src/redx/redx_5739B.cxx | 17 ++ src/redx/redx_snw.cxx | 17 ++ src/transfer/transfer.cxx | 295 ++++++++++++++++++++++++++ src/transfer/transfer_tab.cxx | 51 +++++ src/transfer/transfer_templates.cxx | 21 ++ src/utils/base128.cxx | 191 +++++++++++++++++ src/utils/base256.cxx | 130 ++++++++++++ src/utils/base64.cxx | 2 +- src/utils/status.cxx | 25 ++- src/utils/wrap.cxx | 317 ++++++++++++++++++---------- 49 files changed, 1877 insertions(+), 213 deletions(-) create mode 100644 src/include/base128.h create mode 100644 src/include/base256.h create mode 100644 src/include/transfer.h create mode 100644 src/transfer/transfer.cxx create mode 100644 src/transfer/transfer_tab.cxx create mode 100644 src/transfer/transfer_templates.cxx create mode 100644 src/utils/base128.cxx create mode 100644 src/utils/base256.cxx diff --git a/src/Makefile.am b/src/Makefile.am index 91f99a6..2c09eb2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -192,7 +192,11 @@ flmsg_SOURCES += \ $(srcdir)/redx/redx_5739B.cxx \ $(srcdir)/redx/redx_5739B_tab.cxx \ $(srcdir)/redx/redx_5739_template.cxx \ + $(srcdir)/transfer/transfer.cxx \ + $(srcdir)/transfer/transfer_tab.cxx \ $(srcdir)/utils/base64.cxx \ + $(srcdir)/utils/base128.cxx \ + $(srcdir)/utils/base256.cxx \ $(srcdir)/utils/debug.cxx \ $(srcdir)/utils/parse_xml.cxx \ $(srcdir)/utils/threads.cxx \ @@ -229,6 +233,8 @@ EXTRA_DIST = \ $(srcdir)/include/arl_msgs.h \ $(srcdir)/include/ascii.h \ $(srcdir)/include/base64.h \ + $(srcdir)/include/base128.h \ + $(srcdir)/include/base256.h \ $(srcdir)/include/calendar.h \ $(srcdir)/include/combo.h \ $(srcdir)/include/compat.h \ @@ -260,6 +266,7 @@ EXTRA_DIST = \ $(srcdir)/include/status.h \ $(srcdir)/include/threads.h \ $(srcdir)/include/timeops.h \ + $(srcdir)/include/transfer.h \ $(srcdir)/include/util.h \ $(srcdir)/include/wrap.h \ $(srcdir)/widgets/Fl_Text_Buffer_mod_1_1.cxx \ diff --git a/src/blank-dnd/blank.cxx b/src/blank-dnd/blank.cxx index ed080f8..26d0311 100644 --- a/src/blank-dnd/blank.cxx +++ b/src/blank-dnd/blank.cxx @@ -159,6 +159,22 @@ void cb_blank_wrap_import(string wrapfilename, string inpbuffer) using_blank_template = false; } +int eval_blank_fsize() +{ + Ccrc16 chksum; + string fbuff("[WRAP:beg][WRAP:lf][WRAP:fn "); + fbuff.append(base_blank_filename).append("]"); + update_blankfields(); + update_header(FROM); + fbuff.append(header("")); + string outbuf = lineout( blank_msg, blank_field ); + if (outbuf.empty()) return 0; + compress_maybe( outbuf ); + fbuff.append( outbuf ); + fbuff.append("[WRAP:chksum ").append(chksum.scrc16(fbuff)).append("][WRAP:end]"); + return fbuff.length(); +} + void cb_blank_wrap_export() { if (check_blankfields()) { diff --git a/src/csv/csv.cxx b/src/csv/csv.cxx index 6a5bbbe..b9a02a1 100644 --- a/src/csv/csv.cxx +++ b/src/csv/csv.cxx @@ -157,6 +157,22 @@ void cb_csv_wrap_import(string wrapfilename, string inpbuffer) using_csv_template = false; } +int eval_csv_fsize() +{ + Ccrc16 chksum; + string fbuff("[WRAP:beg][WRAP:lf][WRAP:fn "); + fbuff.append(base_csv_filename).append("]"); + update_csvfields(); + update_header(FROM); + fbuff.append(header("")); + string outbuf = lineout( csv_msg, csv_field ); + if (outbuf.empty()) return 0; + compress_maybe( outbuf ); + fbuff.append( outbuf ); + fbuff.append("[WRAP:chksum ").append(chksum.scrc16(fbuff)).append("][WRAP:end]"); + return fbuff.length(); +} + void cb_csv_wrap_export() { if (check_csvfields()) { diff --git a/src/flmsg.cxx b/src/flmsg.cxx index 0e93fad..c356787 100644 --- a/src/flmsg.cxx +++ b/src/flmsg.cxx @@ -113,6 +113,7 @@ string ICS_dir = ""; string ICS_msg_dir = ""; string ICS_tmp_dir = ""; string CSV_dir = ""; +string XFR_dir = ""; string FLMSG_temp_dir = ""; string cmd_fname = ""; @@ -633,11 +634,11 @@ void extract_text(string &buffer, const char *fname) void read_data_file(string s) { long filesize = 0; - char *buff, *buffend; +// char *buff, *buffend; int retval; FILE *icsfile; - icsfile = fopen (s.c_str(), "r"); + icsfile = fopen (s.c_str(), "rb");// "r"); if (!icsfile) return; // determine its size for buffer creation @@ -649,20 +650,55 @@ void read_data_file(string s) return; } - buff = new char[filesize + 1]; - memset(buff, 0, filesize + 1); // read the entire file into the buffer - fseek (icsfile, 0, SEEK_SET); - retval = fread (buff, filesize, 1, icsfile); - fclose (icsfile); - buffend = buff + filesize; - - string buffer = buff; - delete [] buff; + string buffer; + buffer.resize(filesize); + fseek(icsfile, 0, SEEK_SET); + retval = fread( (void*)buffer.c_str(), 1, filesize, icsfile); + fclose(icsfile); + if (retval != filesize) { + fl_alert2(_("Read error")); + return; + } extract_text(buffer, s.c_str()); } +int eval_transfer_size() +{ + switch (selected_form) { + case ICS203: return eval_203_fsize(); + case ICS205: return eval_205_fsize(); + case ICS205A: return eval_205a_fsize(); + case ICS206: return eval_206_fsize(); + case ICS213: return eval_213_fsize(); + case ICS214: return eval_214_fsize(); + case ICS216: return eval_216_fsize(); + case HICS203: return eval_hics203_fsize(); + case HICS206: return eval_h206_fsize(); + case HICS213: return eval_h213_fsize(); + case HICS214: return eval_hics214_fsize(); + case RADIOGRAM: return eval_rg_fsize(); + case IARU: return eval_iaru_fsize(); + case PLAINTEXT: return eval_pt_fsize(); + case BLANK: return eval_blank_fsize(); + case CSV: return eval_csv_fsize(); + case TRANSFER: return eval_transfer_fsize(); + case MARSDAILY: return eval_mars_daily_fsize(); + case MARSINEEI: return eval_mars_ineei_fsize(); + case MARSNET: return eval_mars_net_fsize(); + case MARSARMY: return eval_mars_army_fsize(); + case MARSNAVY: return eval_mars_navy_fsize(); + case WXHC: return eval_wxhc_fsize(); + case REDXSNW: return eval_redx_snw_fsize(); + case REDX5739: return eval_redx_5739_fsize(); + case REDX5739A: return eval_redx_5739A_fsize(); + case REDX5739B: return eval_redx_5739B_fsize(); + default : ; + } + return 0; +} + void cb_new() { switch (selected_form) { @@ -681,6 +717,7 @@ void cb_new() case IARU: iaru_cb_new(); break; case PLAINTEXT: cb_pt_new(); break; case BLANK: cb_blank_new(); break; + case TRANSFER: cb_transfer_new(); break; case CSV: cb_csv_new(); break; case MARSDAILY: cb_mars_daily_new(); break; case MARSINEEI: cb_mars_ineei_new(); break; @@ -694,6 +731,7 @@ void cb_new() case REDX5739B: cb_redx_5739B_new(); break; default : ; } + estimate(); } void cb_import() @@ -728,6 +766,7 @@ void cb_import() default: fl_alert2("Not implemented"); } + estimate(); } void cb_export() @@ -776,8 +815,8 @@ void wrap_import(const char *fname) } if (isok) { - - remove_cr( inpbuffer ); + if (inpbuffer.find("") == string::npos) + remove_cr( inpbuffer ); if (inpbuffer.find("") != string::npos) { @@ -858,6 +897,9 @@ void wrap_import(const char *fname) } else if (inpbuffer.find("") != string::npos) { selected_form = REDX5739B; cb_redx_5739B_wrap_import(filename, inpbuffer); + } else if (inpbuffer.find("") != string::npos) { + selected_form = TRANSFER; + cb_transfer_wrap_import(filename, inpbuffer); } else if (!exit_after_print) { selected_form = NONE; if (!fl_choice2(_("Cannot identify file type\n\nOpen as text file?"), "yes", "no", NULL)) { @@ -871,6 +913,7 @@ void wrap_import(const char *fname) } } select_form(selected_form); + estimate(); return; } @@ -902,6 +945,7 @@ void wrap_import(const char *fname) open_url(badfile_name.c_str()); if (exit_after_print) return; + estimate(); } if (!fl_choice2(_("Open as text file?"), "yes", "no", NULL)) { @@ -946,6 +990,7 @@ void cb_wrap_export() case PLAINTEXT: cb_pt_wrap_export(); break; case BLANK: cb_blank_wrap_export(); break; case CSV: cb_csv_wrap_export(); break; + case TRANSFER: cb_transfer_wrap_export(); break; case MARSDAILY: cb_mars_daily_wrap_export(); break; case MARSINEEI: cb_mars_ineei_wrap_export(); break; case MARSNET: cb_mars_net_wrap_export(); break; @@ -988,6 +1033,7 @@ void cb_wrap_autosend() case PLAINTEXT: cb_pt_wrap_autosend(); break; case BLANK: cb_blank_wrap_autosend(); break; case CSV: cb_csv_wrap_autosend(); break; + case TRANSFER: cb_transfer_wrap_autosend(); break; case MARSDAILY: cb_mars_daily_wrap_autosend(); break; case MARSINEEI: cb_mars_ineei_wrap_autosend(); break; case MARSNET: cb_mars_net_wrap_autosend(); break; @@ -1033,6 +1079,7 @@ void cb_load_template() case REDX5739B: cb_redx_5739B_load_template(); break; default: ; } + estimate(); } void cb_save_template() @@ -1132,6 +1179,7 @@ void cb_open() case REDX5739B: cb_redx_5739B_open(); break; default : ; } + estimate(); } void cb_save_as() @@ -1392,6 +1440,9 @@ void show_filename(string p) case CSV: base_csv_filename = fl_filename_name(p.c_str()); break; + case TRANSFER: + base_transfer_filename = fl_filename_name(p.c_str()); + break; default: return; } @@ -1484,6 +1535,7 @@ void after_start(void *) LOG_INFO("ICS_msg_dir %s", ICS_msg_dir.c_str()); LOG_INFO("ICS_tmp_dir %s", ICS_tmp_dir.c_str()); LOG_INFO("CSV_dir %s", CSV_dir.c_str()); + LOG_INFO("Transfer dir %s", XFR_dir.c_str()); LOG_INFO("FLMSG_temp_dir %s", FLMSG_temp_dir.c_str()); def_203_filename = ICS_msg_dir; @@ -1625,6 +1677,7 @@ void after_start(void *) read_data_file(cmd_fname); show_filename(cmd_fname); } + estimate(); } else default_form(); @@ -1669,6 +1722,8 @@ int main(int argc, char *argv[]) if (!(FLMSG_dir[len - 1] == '/' || FLMSG_dir[len-1] == '\\')) FLMSG_dir += '/'; + progStatus.loadLastState(); + mainwindow = flmsg_dialog(); mainwindow->callback(exit_main); @@ -1682,10 +1737,24 @@ int main(int argc, char *argv[]) config_radiogram_window = radiogram_dialog(); header_window = headers_dialog(); + btn_utc_format0->value(progStatus.UTC == 0); + btn_utc_format1->value(progStatus.UTC == 1); + btn_utc_format2->value(progStatus.UTC == 2); + btn_utc_format3->value(progStatus.UTC == 3); + btn_utc_format4->value(progStatus.UTC == 4); + btn_utc_format5->value(progStatus.UTC == 5); + + btn_dtformat0->value(progStatus.dtformat == 0); + btn_dtformat1->value(progStatus.dtformat == 1); + btn_dtformat2->value(progStatus.dtformat == 2); + btn_dtformat3->value(progStatus.dtformat == 3); + + cnt_wpl->value(progStatus.wpl); + Fl_File_Icon::load_system_icons(); FSEL::create(); - progStatus.loadLastState(); +// progStatus.loadLastState(); checkdirectories(); @@ -1859,6 +1928,7 @@ void drop_box_changed() read_data_file(buffer.c_str()); } else // try to extract as a text buffer extract_text(buffer, NULL); + estimate(); } void drop_file_changed() @@ -1880,6 +1950,7 @@ void drop_file_changed() read_data_file(buffer.c_str()); } else // try to extract as a text buffer extract_text(buffer, NULL); + estimate(); } void checkdirectories(void) @@ -1903,6 +1974,7 @@ void checkdirectories(void) { ICS_msg_dir, "ICS/messages", 0 }, { ICS_tmp_dir, "ICS/templates", 0 }, { CSV_dir, "CSV", 0}, + { XFR_dir, "TRANSFERS", 0}, { FLMSG_temp_dir, "temp_files", 0 }, }; @@ -2146,6 +2218,8 @@ int parse_args(int argc, char **argv, int& idx) fname.find(FREDX5739B_EXT) != string::npos || fname.find(TREDX5739B_EXT) != string::npos || + fname.find(TRANSFER_EXT) != string::npos || + fname.find(WRAP_EXT) != string::npos ) { cmd_fname = fname; } diff --git a/src/flmsg_dialog.cxx b/src/flmsg_dialog.cxx index 8588c95..7d022e8 100644 --- a/src/flmsg_dialog.cxx +++ b/src/flmsg_dialog.cxx @@ -25,6 +25,8 @@ #include "fileselect.h" #include "debug.h" +#include "transfer.h" + //====================================================================== Fl_Browser *brwsOptions = (Fl_Browser *)0; @@ -35,13 +37,15 @@ Fl_Output *txt_formname = (Fl_Output *)0; Fl_Output *txt_filename = (Fl_Output *)0; Fl_Input *drop_file = (Fl_Input *)0; +Fl_Group *controls = (Fl_Group *)0; + int tab_top; Fl_Browser *select_arl = (Fl_Browser *)0; -Fl_Input *txt_arl_fill1 = (Fl_Input *)0; -Fl_Input *txt_arl_fill2 = (Fl_Input *)0; -Fl_Input *txt_arl_fill3 = (Fl_Input *)0; -Fl_Input *txt_arl_fill4 = (Fl_Input *)0; +Fl_Input2 *txt_arl_fill1 = (Fl_Input2 *)0; +Fl_Input2 *txt_arl_fill2 = (Fl_Input2 *)0; +Fl_Input2 *txt_arl_fill3 = (Fl_Input2 *)0; +Fl_Input2 *txt_arl_fill4 = (Fl_Input2 *)0; Fl_Button *btn_arl_cancel = (Fl_Button *)0; Fl_Button *btn_arl_add = (Fl_Button *)0; FTextEdit *arl_text = (FTextEdit *)0; @@ -58,32 +62,120 @@ Fl_Round_Button *btn_utc_format3 = (Fl_Round_Button *)0; Fl_Round_Button *btn_utc_format4 = (Fl_Round_Button *)0; Fl_Round_Button *btn_utc_format5 = (Fl_Round_Button *)0; -Fl_Input *txt_my_call = (Fl_Input *)0; -Fl_Input *txt_my_tel = (Fl_Input *)0; -Fl_Input *txt_my_name = (Fl_Input *)0; -Fl_Input *txt_my_addr = (Fl_Input *)0; -Fl_Input *txt_my_city = (Fl_Input *)0; +Fl_Input2 *txt_my_call = (Fl_Input2 *)0; +Fl_Input2 *txt_my_tel = (Fl_Input2 *)0; +Fl_Input2 *txt_my_name = (Fl_Input2 *)0; +Fl_Input2 *txt_my_addr = (Fl_Input2 *)0; +Fl_Input2 *txt_my_city = (Fl_Input2 *)0; Fl_Spinner *cnt_wpl = (Fl_Spinner *)0; Fl_Check_Button *btn_rgnbr_fname = (Fl_Check_Button *)0; Fl_Check_Button *btn_arl_desc = (Fl_Check_Button *)0; -Fl_Input *txt_rgnbr = (Fl_Input *)0; +Fl_Input2 *txt_rgnbr = (Fl_Input2 *)0; Fl_Check_Button *btn_open_on_export = (Fl_Check_Button *)0; Fl_Check_Button *btn_call_fname = (Fl_Check_Button *)0; Fl_Check_Button *btn_dt_fname = (Fl_Check_Button *)0; Fl_Check_Button *btn_sernbr_fname = (Fl_Check_Button *)0; -Fl_Input *txt_sernbr = (Fl_Input *)0; +Fl_Input2 *txt_sernbr = (Fl_Input2 *)0; Fl_Input2 *txt_mars_roster_file = (Fl_Input2 *)0; Fl_Input2* txt_hdr_from = (Fl_Input2 *)0; Fl_Input2* txt_hdr_edit = (Fl_Input2 *)0; +Fl_Input2 * txt_socket_addr = (Fl_Input2 *)0; +Fl_Input2 * txt_socket_port = (Fl_Input2 *)0; +Fl_Button * btn_close_socket_dialog = (Fl_Button *)0; + Fl_Check_Button *btnAutoWordWrap = 0; Fl_Check_Button *btn_use_compression = 0; +Fl_ComboBox *encoders = 0; + Fl_Counter *cntCharCount = 0; +Fl_ComboBox *cbo_modes = 0; +Fl_Output *txt_transfer_size = 0; +Fl_Output *txt_transfer_time = 0; + +int transfer_size; + +void cb_btn_transfer_size(Fl_Button *, void*); + +struct st_modes {const char *s_mode; float f_cps;}; + +static st_modes s_modes[] = { +{"DOMX22", 16.0}, {"DOMX44", 31.2}, {"DOMX88", 61.4}, +{"MFSK16", 5.8}, {"MFSK22", 8.0}, {"MFSK31", 5.5}, +{"MFSK32", 12.0}, {"MFSK64", 24.0}, {"MFSK128", 48.0}, +{"MT63-500", 5.0}, {"MT63-1K", 10.0}, {"MT63-2K", 20.0}, + +{"PSK63RC4", 15.0}, {"PSK63RC5", 19.0}, {"PSK63RC10", 38.0}, +{"PSK63RC20", 74.0}, {"PSK63RC32", 120.0}, + +{"PSK125R", 7.0}, {"PSK125RC4", 28.0}, {"PSK125RC5", 35.0}, +{"PSK125RC10", 70.0}, {"PSK125RC16", 112.0}, + +{"PSK250R", 15.0}, {"PSK250RC2", 30.0}, {"PSK250RC3", 45.0}, +{"PSK250RC5", 75.0}, {"PSK250RC7", 105.0}, + +{"PSK500", 48.0}, {"PSK500C2", 96.0}, {"PSK500C4", 192.0}, +{"PSK500R", 29.0}, {"PSK500RC2", 58.0}, {"PSK500RC3", 85.8}, +{"PSK500RC4", 114.4}, + +{"PSK800RC2", 80.0}, + +{"PSK1000", 96.0}, {"PSK1000C2", 192.0}, {"PSK1000R", 60.0}, +{"PSK1000RC2", 120.0}, + +{ "OL 4-250", 3.0 }, { "OL 8-250", 1.5 }, { "OL 4-500", 6.0 }, +{ "OL 8-500", 3.0 }, { "OL 16-500", 1.5 }, { "OL 8-1K", 6.0 }, +{ "OL 16-1K", 4.0 }, { "OL 32-1K", 2.0 }, { "OL 64-2K", 2.0 }, + +{"THOR16", 3.5}, {"THOR22", 4.7}, {"THOR22Q", 4.7}, +{"THOR32", 6.7}, {"THOR44", 12.5}, {"THOR64", 13.3}, +{"THOR88", 25.0}, {NULL, 0} }; + +void init_cbo_modes() +{ + int i = 0; + cbo_modes->clear(); + while (s_modes[i].s_mode != NULL) { cbo_modes->add(s_modes[i].s_mode); i++; } + cbo_modes->index(progStatus.selected_mode); +} + +void init_encoders() +{ + encoders->clear(); + encoders->add("base64"); + encoders->add("base128"); + encoders->add("base256"); + encoders->index(progStatus.encoder); +} + +void estimate() { + static char sz_xfr_size[20]; + static char sz_xfr_time[20]; + float cps = 0, xfr_time = 0; + transfer_size = eval_transfer_size(); + if (transfer_size == 0) { + txt_transfer_size->value(""); + txt_transfer_time->value(""); + return; + } + snprintf(sz_xfr_size, sizeof(sz_xfr_size), "%d bytes", transfer_size); + txt_transfer_size->value(sz_xfr_size); + + cps = s_modes[cbo_modes->index()].f_cps; + + if (transfer_size <= 0) return; + + xfr_time = transfer_size / cps; + + snprintf(sz_xfr_time, sizeof(sz_xfr_time), " %.1f secs", xfr_time); + txt_transfer_time->value(sz_xfr_time); +} + //====================================================================== static void cb_mnu_folders(Fl_Menu_*, void*) { @@ -223,6 +315,7 @@ int mREDX5739 = REDX5739; int mREDX5739A = REDX5739A; int mREDX5739B = REDX5739B; int mWXHC = WXHC; +int mTRANSFER = TRANSFER; Fl_Group *oldtab = (Fl_Group *)0; @@ -385,6 +478,12 @@ void select_form(int form) txt_formname->value(_("CSV spreadsheet")); show_filename(def_csv_filename); break; + case TRANSFER: + oldtab = tab_transfer; + tab_transfer->show(); + txt_formname->value(_("File transfer")); + show_filename(def_transfer_filename); + break; case BLANK: case NONE: default: @@ -394,6 +493,7 @@ void select_form(int form) show_filename(def_blank_filename); break; } + eval_transfer_size(); } static void cb_mnuFormSelect(Fl_Menu_*, void *d) { @@ -471,6 +571,7 @@ Fl_Menu_Item menu_[] = { {_("Plaintext"), 0, (Fl_Callback*)cb_mnuFormSelect, &mPLAINTEXT, 0, FL_NORMAL_LABEL, 0, 14, 0}, {_("CSV"), 0, (Fl_Callback*)cb_mnuFormSelect, &mCSV, 0, FL_NORMAL_LABEL, 0, 14, 0}, {_("Blank"), 0, (Fl_Callback*)cb_mnuFormSelect, &mBLANK, 0, FL_NORMAL_LABEL, 0, 14, 0}, + {_("Transfer"), 0, (Fl_Callback*)cb_mnuFormSelect, &mTRANSFER, 0, FL_NORMAL_LABEL, 0, 14, 0}, {0,0,0,0,0,0,0,0,0}, {_("&Template"), 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0}, {_("Load"), 0, (Fl_Callback*)cb_mnu_load_template, 0, 128, FL_NORMAL_LABEL, 0, 14, 0}, @@ -503,12 +604,30 @@ static void cb_drop_file(Fl_Input*, void*) { drop_file_changed(); } +void cb_use_compression() +{ + progStatus.use_compression = btn_use_compression->value(); + estimate(); +} + +void cb_use_encoder() +{ + progStatus.encoder = encoders->index(); + estimate(); +} + +void cb_cbo_modes() +{ + estimate(); +} + Fl_Double_Window* flmsg_dialog() { - Fl_Double_Window* w = new Fl_Double_Window(570, 430, _("Standard Message Generator"));; + int W = 570, H = 465; + Fl_Double_Window* w = new Fl_Double_Window(570, 465, "");; w->begin(); - Fl_Menu_Bar* mb = new Fl_Menu_Bar(0, 0, 570, 22); - mb->menu(menu_); + Fl_Menu_Bar* mb = new Fl_Menu_Bar(0, 0, W, 22); + mb->menu(menu_); txt_formname = new Fl_Output(4, 26, 220, 20); txt_formname->box(FL_FLAT_BOX); @@ -519,7 +638,7 @@ Fl_Double_Window* flmsg_dialog() { txt_filename->align(FL_ALIGN_LEFT); txt_filename->color(fl_rgb_color(245, 245, 245)); - drop_file = new Fl_Input(535, 22, 28, 28); + drop_file = new Fl_Input2(535, 22, 28, 28); drop_file->box(FL_OVAL_BOX); drop_file->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE); drop_file->value(""); @@ -544,8 +663,55 @@ Fl_Double_Window* flmsg_dialog() { create_csv_tab(); create_dnd_tab(); create_wxhc_tab(); + create_transfer_tab(); + + controls = new Fl_Group(2, 465 - 28, 566, 26, ""); + controls->box(FL_NO_BOX);//DOWN_BOX); + controls->begin(); + + btn_use_compression = new Fl_Check_Button(10, H-28+4, 60, 18, _("Comp")); + btn_use_compression->tooltip(_("Data will be sent compressed\nif file size is reduced")); + btn_use_compression->down_box(FL_DOWN_BOX); + btn_use_compression->callback((Fl_Callback*)cb_use_compression); + btn_use_compression->value(progStatus.use_compression); + + encoders = new Fl_ComboBox(74, H-28+2, 100, 22, ""); + encoders->begin(); + encoders->when(FL_WHEN_RELEASE); + encoders->tooltip(_("Encode after compression")); + encoders->callback((Fl_Callback*)cb_use_encoder); + encoders->end(); + + cbo_modes = new Fl_ComboBox(190, H-28+2, 120, 22, _("Mode")); + cbo_modes->begin(); + cbo_modes->align(FL_ALIGN_RIGHT); + cbo_modes->when(FL_WHEN_RELEASE); + cbo_modes->tooltip(_("fldigi modem type")); + cbo_modes->box(FL_DOWN_BOX); + cbo_modes->color(FL_BACKGROUND2_COLOR); + cbo_modes->selection_color(FL_BACKGROUND_COLOR); + cbo_modes->labeltype(FL_NORMAL_LABEL); + cbo_modes->labelfont(0); + cbo_modes->labelsize(14); + cbo_modes->labelcolor(FL_FOREGROUND_COLOR); + cbo_modes->callback((Fl_Callback*)cb_cbo_modes); + cbo_modes->end(); + + txt_transfer_size = new Fl_Output(360, H-28+2, 100, 22, ""); + txt_transfer_size->tooltip(_("Transfer size in bytes")); + txt_transfer_size->value(""); + + txt_transfer_time = new Fl_Output(465, H-28+2, 100, 22, ""); + txt_transfer_time->tooltip(_("Transfer time in seconds")); + txt_transfer_time->value(""); + + controls->end(); w->end(); + + init_cbo_modes(); + init_encoders(); + return w; } @@ -553,23 +719,21 @@ static void cb_btnCloseOptions(Fl_Return_Button*, void*) { closeoptions(); } +static int opt_col_sizes[] = {200, 0}; + Fl_Double_Window* optionsdialog() { - Fl_Double_Window* w; - { Fl_Double_Window* o = new Fl_Double_Window(410, 260, _("Command Line Options")); - w = o; - { brwsOptions = new Fl_Browser(3, 31, 405, 202); - } // Fl_Browser* brwsOptions - { btnCloseOptions = new Fl_Return_Button(329, 239, 72, 20, _("OK")); - btnCloseOptions->callback((Fl_Callback*)cb_btnCloseOptions); - } // Fl_Return_Button* btnCloseOptions - { Fl_Box* o = new Fl_Box(4, 7, 401, 21, _("usage: flics -