From ee27d64e6e195cd9db6ecc2d35ed40ff3794d178 Mon Sep 17 00:00:00 2001 From: David Freese Date: Mon, 14 Nov 2011 06:34:51 -0600 Subject: [PATCH] eQSL update * Added embedded tags to optional message - {CALL} other operators callsign - {NAME} other operators name - {MODE} full mode / submode eQSL.cc does not accept all submodes, i.e MFSK11 must be logged at MFSK16 THROB4 must be logged as THRB etc. This tag allows you to add specificity to the eQSL record * Added default message * Added switch to enable sending eQSL when either - log button is pressed - or is encountered in macro - logic to disallow duplicating eQSL submission --- src/dialogs/confdialog.cxx | 63 +++++++++++++++++++++ src/dialogs/confdialog.fl | 47 +++++++++++++++- src/include/confdialog.h | 5 ++ src/include/configuration.h | 6 ++ src/include/lookupcall.h | 1 + src/logger/logger.cxx | 4 ++ src/misc/lookupcall.cxx | 107 +++++++++++++++++++++++++++++++++++- src/misc/macros.cxx | 82 +-------------------------- 8 files changed, 233 insertions(+), 82 deletions(-) diff --git a/src/dialogs/confdialog.cxx b/src/dialogs/confdialog.cxx index 19d80af8..09d16c54 100644 --- a/src/dialogs/confdialog.cxx +++ b/src/dialogs/confdialog.cxx @@ -4,6 +4,7 @@ #include "confdialog.h" #include #include +#include #include #include "main.h" #include "fl_digi.h" @@ -2998,6 +2999,26 @@ static void cb_inpEQSL_nick(Fl_Input2* o, void*) { progdefaults.changed = true; } +Fl_Check_Button *btn_send_when_logged=(Fl_Check_Button *)0; + +static void cb_btn_send_when_logged(Fl_Check_Button* o, void*) { + progdefaults.eqsl_when_logged = o->value(); +progdefaults.changed = true; +} + +Fl_Input2 *txt_eqsl_default_message=(Fl_Input2 *)0; + +static void cb_txt_eqsl_default_message(Fl_Input2* o, void*) { + progdefaults.eqsl_default_message = o->value(); +progdefaults.changed = true; +} + +Fl_Box *eqsl_txt1=(Fl_Box *)0; + +Fl_Box *eqsl_txt2=(Fl_Box *)0; + +Fl_Box *eqsl_txt3=(Fl_Box *)0; + Fl_Button *btnSaveConfig=(Fl_Button *)0; static void cb_btnSaveConfig(Fl_Button*, void*) { @@ -6701,6 +6722,48 @@ d frequency")); o->value(progdefaults.eqsl_nick.c_str()); inpEQSL_nick->labelsize(FL_NORMAL_SIZE); } // Fl_Input2* inpEQSL_nick + { Fl_Group* o = new Fl_Group(4, 170, 492, 194, _("Options")); + o->box(FL_ENGRAVED_FRAME); + o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); + { Fl_Check_Button* o = btn_send_when_logged = new Fl_Check_Button(29, 191, 70, 15, _("send when logged (log button, , )")); + btn_send_when_logged->tooltip(_("eQSL upload when record logged")); + btn_send_when_logged->down_box(FL_DOWN_BOX); + btn_send_when_logged->callback((Fl_Callback*)cb_btn_send_when_logged); + o->value(progdefaults.eqsl_when_logged); + } // Fl_Check_Button* btn_send_when_logged + { Fl_Input2* o = txt_eqsl_default_message = new Fl_Input2(33, 226, 451, 40, _("Default message")); + txt_eqsl_default_message->tooltip(_("Default message sent with eQSL")); + txt_eqsl_default_message->type(4); + txt_eqsl_default_message->box(FL_DOWN_BOX); + txt_eqsl_default_message->color((Fl_Color)FL_BACKGROUND2_COLOR); + txt_eqsl_default_message->selection_color((Fl_Color)FL_SELECTION_COLOR); + txt_eqsl_default_message->labeltype(FL_NORMAL_LABEL); + txt_eqsl_default_message->labelfont(0); + txt_eqsl_default_message->labelsize(14); + txt_eqsl_default_message->labelcolor((Fl_Color)FL_FOREGROUND_COLOR); + txt_eqsl_default_message->callback((Fl_Callback*)cb_txt_eqsl_default_message); + txt_eqsl_default_message->align(FL_ALIGN_TOP_LEFT); + txt_eqsl_default_message->when(FL_WHEN_CHANGED); + o->value(progdefaults.eqsl_default_message.c_str()); + } // Fl_Input2* txt_eqsl_default_message + { Fl_Group* o = new Fl_Group(8, 270, 484, 90, _("Text Tags (tags use {} delimiters)")); + o->box(FL_THIN_DOWN_BOX); + o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); + { eqsl_txt1 = new Fl_Box(14, 317, 220, 17, _("{CALL} other ops call sign")); + eqsl_txt1->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + } // Fl_Box* eqsl_txt1 + { eqsl_txt2 = new Fl_Box(12, 336, 220, 17, _("{MODE} full mode / submode")); + eqsl_txt2->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + } // Fl_Box* eqsl_txt2 + { eqsl_txt3 = new Fl_Box(260, 317, 220, 17, _("{NAME} other ops name")); + eqsl_txt3->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + } // Fl_Box* eqsl_txt3 + { new Fl_Box(28, 293, 440, 17, _("These tags can also be used in ")); + } // Fl_Box* o + o->end(); + } // Fl_Group* o + o->end(); + } // Fl_Group* o o->end(); } // Fl_Group* o o->end(); diff --git a/src/dialogs/confdialog.fl b/src/dialogs/confdialog.fl index cdf1f387..3266ebe7 100644 --- a/src/dialogs/confdialog.fl +++ b/src/dialogs/confdialog.fl @@ -9,6 +9,8 @@ decl {\#include } {} decl {\#include } {} +decl {\#include } {} + decl {\#include } {} decl {\#include "main.h"} {} @@ -98,14 +100,14 @@ static const char szBaudRates[] = "300|600|1200|2400|4800|9600|19200|38400|57600 static const char szProsigns[] = "~|%|&|+|=|{|}|<|>|[|]| ";} {} Fl_Window {} { label {Fldigi configuration} open - xywh {644 190 500 400} type Double color 45 selection_color 51 labelsize 18 align 80 non_modal visible + xywh {592 125 500 400} type Double color 45 selection_color 51 labelsize 18 align 80 non_modal visible } { Fl_Tabs tabsConfigure {open xywh {-4 0 521 372} color 50 selection_color 50 } { Fl_Group tabOperator { label Operator - callback {progdefaults.changed = true;} selected + callback {progdefaults.changed = true;} open selected tooltip {Operator information} xywh {0 25 500 345} when 1 } { Fl_Group {} { @@ -3823,6 +3825,47 @@ progdefaults.changed = true;} code1 {inpEQSL_nick->labelsize(FL_NORMAL_SIZE);} class Fl_Input2 } + Fl_Group {} { + label Options open + xywh {4 170 492 194} box ENGRAVED_FRAME align 21 + } { + Fl_Check_Button btn_send_when_logged { + label {send when logged (log button, , )} + callback {progdefaults.eqsl_when_logged = o->value(); +progdefaults.changed = true;} + tooltip {eQSL upload when record logged} xywh {29 191 70 15} down_box DOWN_BOX + code0 {o->value(progdefaults.eqsl_when_logged);} + } + Fl_Input txt_eqsl_default_message { + label {Default message} + callback {progdefaults.eqsl_default_message = o->value(); +progdefaults.changed = true;} + tooltip {Default message sent with eQSL} xywh {33 226 451 40} type Multiline align 5 when 1 + code0 {o->value(progdefaults.eqsl_default_message.c_str());} + class Fl_Input2 + } + Fl_Group {} { + label {Text Tags (tags use {} delimiters)} open + xywh {8 270 484 90} box THIN_DOWN_BOX align 21 + } { + Fl_Box eqsl_txt1 { + label {{CALL} other ops call sign} + xywh {14 317 220 17} align 20 + } + Fl_Box eqsl_txt2 { + label {{MODE} full mode / submode} + xywh {12 336 220 17} align 20 + } + Fl_Box eqsl_txt3 { + label {{NAME} other ops name} + xywh {260 317 220 17} align 20 + } + Fl_Box {} { + label {These tags can also be used in } + xywh {28 293 440 17} + } + } + } } } } diff --git a/src/include/confdialog.h b/src/include/confdialog.h index 03c2da4a..bc0ca26b 100644 --- a/src/include/confdialog.h +++ b/src/include/confdialog.h @@ -420,6 +420,11 @@ extern Fl_Input2 *inpEQSL_id; extern Fl_Input2 *inpEQSL_pwd; extern Fl_Button *btnEQSL_pwd_show; extern Fl_Input2 *inpEQSL_nick; +extern Fl_Check_Button *btn_send_when_logged; +extern Fl_Input2 *txt_eqsl_default_message; +extern Fl_Box *eqsl_txt1; +extern Fl_Box *eqsl_txt2; +extern Fl_Box *eqsl_txt3; extern Fl_Button *btnSaveConfig; #include extern Fl_Return_Button *btnCloseConfig; diff --git a/src/include/configuration.h b/src/include/configuration.h index 2c9a82c5..a3632daf 100644 --- a/src/include/configuration.h +++ b/src/include/configuration.h @@ -672,6 +672,12 @@ ELEM_(std::string, eqsl_nick, "EQSL_NICKNAME", \ "eQSL nickname", \ "") \ + ELEM_(std::string, eqsl_default_message, "EQSL_DEF_MSG", \ + "eQSl default message", \ + "") \ + ELEM_(bool, eqsl_when_logged, "EQSL_WHEN_LOGGED", \ + "Send eQSL when other log action invoked", \ + false) \ /* Rig control */ \ ELEM_(bool, btnusb, "BTNUSB", \ "This setting is currently unused", \ diff --git a/src/include/lookupcall.h b/src/include/lookupcall.h index 632ab500..4afff113 100644 --- a/src/include/lookupcall.h +++ b/src/include/lookupcall.h @@ -19,5 +19,6 @@ extern void CALLSIGNquery(); enum qrz_query_t { QRZ_EXIT = -1, QRZNONE, QRZNET, QRZCD, HAMCALLNET, QRZHTML, HAMCALLHTML, CALLOOK, HAMQTH }; extern void sendEQSL(const char *url); +extern void makeEQSL(const char *msg); #endif diff --git a/src/logger/logger.cxx b/src/logger/logger.cxx index a482919a..263c4869 100644 --- a/src/logger/logger.cxx +++ b/src/logger/logger.cxx @@ -46,6 +46,7 @@ #include "configuration.h" #include "logsupport.h" +#include "lookupcall.h" #include @@ -215,6 +216,9 @@ void submit_log(void) logmode = mode_info[active_modem->get_mode()].adif_name; + if (progdefaults.eqsl_when_logged) + makeEQSL(""); + if (progdefaults.xml_logbook) xml_add_record(); else diff --git a/src/misc/lookupcall.cxx b/src/misc/lookupcall.cxx index c195e2c8..de557716 100644 --- a/src/misc/lookupcall.cxx +++ b/src/misc/lookupcall.cxx @@ -44,10 +44,12 @@ #include "configuration.h" #include "lookupcall.h" +#include "logsupport.h" #include "main.h" #include "confdialog.h" #include "fl_digi.h" #include "qrzlib.h" +#include "trx.h" #include "xmlreader.h" @@ -1046,7 +1048,7 @@ static void *EQSL_loop(void *args) else if ((p = EQSL_xmlpage.find("Error:")) != std::string::npos) { size_t p2 = EQSL_xmlpage.find('\n', p); - LOG_ERROR("%s", EQSL_xmlpage.substr(p, p2 - p - 1).c_str()); + LOG_ERROR("%s\n%s", EQSL_xmlpage.substr(p, p2 - p - 1).c_str(), EQSL_url.c_str()); } else LOG_INFO("eQSL logged %s", EQSL_url.c_str()); @@ -1100,3 +1102,106 @@ void sendEQSL(const char *url) pthread_cond_signal(&EQSLcond); pthread_mutex_unlock(&EQSLmutex); } + +// this function may be called from several places including macro +// expansion and execution + +void makeEQSL(const char *message) +{ + char sztemp[100]; + std::string tempstr; + std::string eQSL_url; + std::string msg; + size_t p = 0; + + msg = message; + + if (msg.empty()) msg = progdefaults.eqsl_default_message; + +// replace message tags {CALL}, {NAME}, {MODE} + while ((p = msg.find("{CALL}")) != std::string::npos) + msg.replace(p, 6, inpCall->value()); + while ((p = msg.find("{NAME}")) != std::string::npos) + msg.replace(p, 6, inpName->value()); + while ((p = msg.find("{MODE}")) != std::string::npos) + msg.replace(p, 6, mode_info[active_modem->get_mode()].adif_name); + + +// eqsl url header + eQSL_url = "http://www.eqsl.cc/qslcard/importADIF.cfm?ADIFdata=upload 2.1.9"; + snprintf(sztemp, sizeof(sztemp),"%s%s", + progdefaults.eqsl_id.length(), progdefaults.eqsl_id.c_str(), + progdefaults.eqsl_pwd.length(), progdefaults.eqsl_pwd.c_str()); + eQSL_url.append(sztemp); +// eqsl nickname + if (!progdefaults.eqsl_nick.empty()) { + snprintf(sztemp, sizeof(sztemp), "%s", + progdefaults.eqsl_nick.length(), progdefaults.eqsl_nick.c_str()); + eQSL_url.append(sztemp); + } + eQSL_url.append("FLDIGI"); + +// eqsl record +// band + tempstr = band_name(band(wf->rfcarrier())); + snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); + eQSL_url.append(sztemp); +// call + tempstr = inpCall->value(); + snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); + eQSL_url.append(sztemp); +// mode + tempstr = mode_info[active_modem->get_mode()].adif_name; +// test for modes not supported by eQSL + if ((tempstr.find("MFSK4") != std::string::npos) || + (tempstr.find("MFSK11") != std::string::npos) || + (tempstr.find("MFSK22") != std::string::npos) || + (tempstr.find("MFSK31") != std::string::npos) || + (tempstr.find("MFSK32") != std::string::npos) || + (tempstr.find("MFSK64") != std::string::npos) ) + tempstr = "MFSK16"; + if ((tempstr.find("PSK250") != std::string::npos) || + (tempstr.find("PSK500") != std::string::npos) || + (tempstr.find("PSK125R") != std::string::npos) || + (tempstr.find("PSK250R") != std::string::npos) || + (tempstr.find("PSK500R") != std::string::npos)) + tempstr = "PSK125"; + if ((tempstr.find("QPSK250") != std::string::npos) || + (tempstr.find("QPSK500") != std::string::npos) || + (tempstr.find("QPSK125R") != std::string::npos) || + (tempstr.find("QPSK250R") != std::string::npos) || + (tempstr.find("QPSK500R") != std::string::npos)) + tempstr = "QPSK125"; + + snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); + eQSL_url.append(sztemp); +// qso date + snprintf(sztemp, sizeof(sztemp), "%s", sDate_on.length(), sDate_on.c_str()); + eQSL_url.append(sztemp); +// qso time + tempstr = inpTimeOn->value(); + snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); + eQSL_url.append(sztemp); +// rst sent + tempstr = inpRstOut->value(); + snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); + eQSL_url.append(sztemp); +// message + if (!msg.empty()) { + snprintf(sztemp, sizeof(sztemp), "%s", msg.length(), msg.c_str()); + eQSL_url.append(sztemp); + } + eQSL_url.append(""); + + tempstr.clear(); + for (size_t n = 0; n < eQSL_url.length(); n++) { + if (eQSL_url[n] == ' ') tempstr.append("%20"); + else if (eQSL_url[n] == '<') tempstr.append("%3c"); + else if (eQSL_url[n] == '>') tempstr.append("%3e"); + else tempstr += eQSL_url[n]; + } + + sendEQSL(tempstr.c_str()); + +} + diff --git a/src/misc/macros.cxx b/src/misc/macros.cxx index 7f819e99..7134a6ea 100644 --- a/src/misc/macros.cxx +++ b/src/misc/macros.cxx @@ -1671,7 +1671,7 @@ static void pEXEC(std::string& s, size_t& i, size_t endbracket) static void pEQSL(std::string& s, size_t& i, size_t endbracket) { - if (within_exec) { + if (within_exec || progdefaults.eqsl_when_logged) { s.replace(i, endbracket - i + 1, ""); return; } @@ -1681,83 +1681,7 @@ static void pEQSL(std::string& s, size_t& i, size_t endbracket) if (start != std::string::npos) msg = s.substr(start + 1, endbracket-start-1); - char sztemp[100]; - std::string tempstr; - std::string eQSL_url; - -// eqsl url header - eQSL_url = "http://www.eqsl.cc/qslcard/importADIF.cfm?ADIFdata=upload 2.1.9"; - snprintf(sztemp, sizeof(sztemp),"%s%s", - progdefaults.eqsl_id.length(), progdefaults.eqsl_id.c_str(), - progdefaults.eqsl_pwd.length(), progdefaults.eqsl_pwd.c_str()); - eQSL_url.append(sztemp); -// eqsl nickname - if (!progdefaults.eqsl_nick.empty()) { - snprintf(sztemp, sizeof(sztemp), "%s", - progdefaults.eqsl_nick.length(), progdefaults.eqsl_nick.c_str()); - eQSL_url.append(sztemp); - } - eQSL_url.append("FLDIGI"); -// band - tempstr = band_name(band(wf->rfcarrier())); - snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); - eQSL_url.append(sztemp); -// call - tempstr = inpCall->value(); - snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); - eQSL_url.append(sztemp); -// mode - tempstr = mode_info[active_modem->get_mode()].adif_name; -// test for modes not supported by eQSL - if ((tempstr.find("MFSK4") != std::string::npos) || - (tempstr.find("MFSK11") != std::string::npos) || - (tempstr.find("MFSK22") != std::string::npos) || - (tempstr.find("MFSK31") != std::string::npos) || - (tempstr.find("MFSK32") != std::string::npos) || - (tempstr.find("MFSK64") != std::string::npos) ) - tempstr = "MFSK16"; - if ((tempstr.find("PSK250") != std::string::npos) || - (tempstr.find("PSK500") != std::string::npos) || - (tempstr.find("PSK125R") != std::string::npos) || - (tempstr.find("PSK250R") != std::string::npos) || - (tempstr.find("PSK500R") != std::string::npos)) - tempstr = "PSK125"; - if ((tempstr.find("QPSK250") != std::string::npos) || - (tempstr.find("QPSK500") != std::string::npos) || - (tempstr.find("QPSK125R") != std::string::npos) || - (tempstr.find("QPSK250R") != std::string::npos) || - (tempstr.find("QPSK500R") != std::string::npos)) - tempstr = "QPSK125"; - - snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); - eQSL_url.append(sztemp); -// qso date - snprintf(sztemp, sizeof(sztemp), "%s", sDate_on.length(), sDate_on.c_str()); - eQSL_url.append(sztemp); -// qso time - tempstr = inpTimeOn->value(); - snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); - eQSL_url.append(sztemp); -// rst sent - tempstr = inpRstOut->value(); - snprintf(sztemp, sizeof(sztemp), "%s", tempstr.length(), tempstr.c_str()); - eQSL_url.append(sztemp); -// message - if (!msg.empty()) { - snprintf(sztemp, sizeof(sztemp), "%s", msg.length(), msg.c_str()); - eQSL_url.append(sztemp); - } - eQSL_url.append(""); - - tempstr.clear(); - for (size_t n = 0; n < eQSL_url.length(); n++) { - if (eQSL_url[n] == ' ') tempstr.append("%20"); - else if (eQSL_url[n] == '<') tempstr.append("%3c"); - else if (eQSL_url[n] == '>') tempstr.append("%3e"); - else tempstr += eQSL_url[n]; - } - - sendEQSL(tempstr.c_str()); + makeEQSL(msg.c_str()); s.replace(i, endbracket - i + 1, ""); return; @@ -1957,7 +1881,7 @@ static const MTAGS mtags[] = { {"", pLOG}, {"", pLNW}, {"", pCLRLOG}, -{"