From 98170dce4f1313cbf42bd0ae4bf5d1c490a077da Mon Sep 17 00:00:00 2001 From: Matthew Chambers Date: Thu, 16 Dec 2021 15:02:46 -0600 Subject: [PATCH] Initial workup for LoTW throttling & diff fetching --- package.nw/lib/adif.js | 110 +++++-------------------------------- package.nw/lib/defaults.js | 1 - 2 files changed, 15 insertions(+), 96 deletions(-) diff --git a/package.nw/lib/adif.js b/package.nw/lib/adif.js index b309c879..082151a6 100644 --- a/package.nw/lib/adif.js +++ b/package.nw/lib/adif.js @@ -1,4 +1,4 @@ -// GridTracker Copyright © 2022 GridTracker.org +// GridTracker Copyright © 2021 GridTracker.org // All rights reserved. // See LICENSE for more information. @@ -607,19 +607,9 @@ function lotwCallback(buffer, flag) if (lotwQSHeader !== null) { if (lotwQSHeader[1].toUpperCase() == "QSORX") -<<<<<<< HEAD - { - g_adifLogSettings.lastFetch.lotw_qso = lotwQSHeader[2] - } - else if (lotwQSHeader[1].toUpperCase() == "QSL") - { - g_adifLogSettings.lastFetch.lotw_qsl = lotwQSHeader[2]; - } -======= { g_adifLogSettings.lastFetch.lotw_qso = lotwQSHeader[2] } elseif(lotwQSHeader[1].toUpperCase() == "QSL") g_adifLogSettings.lastFetch.lotw_qsl = lotwQSHeader[2]; ->>>>>>> 272892e... Initial workup for LoTW throttling & diff fetching } rawAdiBuffer = cleanAndPrepADIF( @@ -673,16 +663,6 @@ var g_isGettingLOTW = false; function grabLOtWLog(test) { -<<<<<<< HEAD - var lastQSLDateString = ""; - - if (test == true && g_isGettingLOTW == false) - { - lotwTestResult.innerHTML = "Testing"; - lastQSLDateString = "&qso_qsosince=2100-01-01"; - - // Fetch Test Results -======= var dLoTWQSO = Date.parse(g_adifLogSettings.lastFetch.lotw_qso); var dLoTWQSL = Date.parse(g_adifLogSettings.lastFetch.lotw_qsl); var tmpDate = ((new Date().getTime()) - 300); @@ -703,79 +683,19 @@ function grabLOtWLog(test) } // Fetch QSOs ->>>>>>> 272892e... Initial workup for LoTW throttling & diff fetching getABuffer( "https://lotw.arrl.org/lotwuser/lotwreport.adi?login=" + - lotwLogin.value + - "&password=" + - encodeURIComponent(lotwPassword.value) + - "&qso_query=1&qso_qsl=no&qso_qsldetail=yes&qso_withown=yes" + - lastQSLDateString, + lotwLogin.value + + "&password=" + + encodeURIComponent(lotwPassword.value) + + "&qso_query=1&qso_qsl=no&qso_qsldetail=yes&qso_withown=yes" + + lastQSLDateString, lotwCallback, test, "https", 443, lotwLogImg, "g_isGettingLOTW", - 150000 - ); - } - - if (test == false) - { - setTimeout(grabLoTWQSO, 500); - setTimeout(grabLoTWQSL, 10000); - } -} - -function grabLoTWQSO() -{ - var dLoTWQSO = Date.parse(dateToISO8601(g_adifLogSettings.lastFetch.lotw_qso, "Z")); - var tmpDate = ((new Date().getTime()) - 300); - - if ((g_isGettingLOTW == false) && ((isNaN(dLoTWQSO) == false) && (dLoTWQSO < tmpDate))) - { - // Fetch QSOs - lastQSLDateString = "&qso_qsorxsince=" + g_adifLogSettings.lastFetch.lotw_qso; - getABuffer( - "https://lotw.arrl.org/lotwuser/lotwreport.adi?login=" + - lotwLogin.value + - "&password=" + - encodeURIComponent(lotwPassword.value) + - "&qso_query=1&qso_qsl=no&qso_qsldetail=yes&qso_withown=yes" + - lastQSLDateString, - lotwCallback, - false, - "https", - 443, - lotwLogImg, - "g_isGettingLOTW", - 120000 - ); - } -} - -function grabLoTWQSL() -{ - var dLoTWQSL = Date.parse(dateToISO8601(g_adifLogSettings.lastFetch.lotw_qsl, "Z")); - var tmpDate = ((new Date().getTime()) - 300); - - if ((g_isGettingLOTW == false) && ((isNaN(dLoTWQSL) == false) && (dLoTWQSL < tmpDate))) - { - lastQSLDateString = "&qso_qslsince=" + g_adifLogSettings.lastFetch.lotw_qsl; - getABuffer( - "https://lotw.arrl.org/lotwuser/lotwreport.adi?login=" + - lotwLogin.value + - "&password=" + - encodeURIComponent(lotwPassword.value) + - "&qso_query=1&qso_qsl=yes&qso_qsldetail=yes&qso_withown=yes" + - lastQSLDateString, - lotwCallback, - false, - "https", - 443, - lotwLogImg, - "g_isGettingLOTW", 120000 ); @@ -1537,6 +1457,11 @@ function getABuffer( }) .on("end", function () { + if (typeof callback === "function") + { + // Call it, since we have confirmed it is callable + callback(fileBuffer, flag, cookies); + } if (typeof stringOfFlag != "undefined") { window[stringOfFlag] = false; @@ -1546,11 +1471,6 @@ function getABuffer( imgToGray.parentNode.style.background = ""; imgToGray.style.webkitFilter = ""; } - if (typeof callback === "function") - { - // Call it, since we have confirmed it is callable - callback(fileBuffer, flag, cookies); - } }) .on("error", function () { @@ -1718,7 +1638,7 @@ function sendTcpMessage(msg, length, port, address) client.setTimeout(30000); client.connect(port, address, function () { - client.write(Buffer.from(msg, "utf-8")); + client.write(msg); }); client.on("close", function () {}); @@ -1727,7 +1647,7 @@ function sendTcpMessage(msg, length, port, address) function valueToAdiField(field, value) { var adi = "<" + field + ":"; - adi += Buffer.byteLength(String(value)) + ">"; + adi += String(value).length + ">"; adi += String(value) + " "; return adi; } @@ -2007,7 +1927,7 @@ function finishSendingReport(record, localMode) for (let key in record) { - report += "<" + key + ":" + Buffer.byteLength(record[key]) + ">" + record[key] + " "; + report += "<" + key + ":" + record[key].length + ">" + record[key] + " "; } report += ""; @@ -2189,7 +2109,7 @@ function finishSendingReport(record, localMode) for (var key in record) { report += - "<" + key + ":" + Buffer.byteLength(record[key]) + ">" + record[key] + " "; + "<" + key + ":" + record[key].length + ">" + record[key] + " "; } report += ""; } diff --git a/package.nw/lib/defaults.js b/package.nw/lib/defaults.js index 78a91359..51a9beeb 100644 --- a/package.nw/lib/defaults.js +++ b/package.nw/lib/defaults.js @@ -61,7 +61,6 @@ var def_appSettings = { lookupPasswordQth: "", lookupService: "CALLOOK", lookupCallookPreferred: false, - clearRosterOnBandChange: false, moonPath: 0, moonTrack: 0, mouseTrack: 0,