Skip to content

Commit

Permalink
Callsign check bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Jan 7, 2022
1 parent 6b978f5 commit 7654154
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Jan 2022 - 1.8.6
- Bugfix: Serial Hamlib rigs were not properly working. (TNX W5PNY)
- Bugfix: QRZ.com was disabled if user was not subscribed. (TNX EA5WA)
- Bugfix: QRZ.com data was not updated if the boxes were already filled. (TNX EA5WA)
- Bugfix: Callsigns formet were not always properly checked.
- Improvement: Hamlib 4.4 in binary packages (macOS & Windows) tested also in Linux.
- Improvement: RTS & DTR are defined to OFF by default in hamlib.
- Improvement:KLog differenciates QRZ.com subcribed users from non subscribed. (TNX EA5WA)
Expand Down
11 changes: 7 additions & 4 deletions src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void Utilities::init()
{
softwareVersion = "0.0";
darkMode = false;
callValidation = true;
//callValidation = true;

}

void Utilities::setVersion(const QString &_v)
Expand Down Expand Up @@ -577,14 +578,15 @@ bool Utilities::isValidSubCall(const QString &_c)
if (!_c.at(i).isLetterOrNumber ())
{
// Non valid chars
//qDebug() << "Utilities::isValidSubCall: FALSE-1.2: " << _c ;
return false;
}
}

int prefixLength = isAPrefix (_c);
if (prefixLength<1)
{
//qDebug() << "Utilities::isValidSubCall: FALSE-1.2: " << _c ;
//qDebug() << "Utilities::isValidSubCall: FALSE-1.3: " << _c ;
return false;
}

Expand All @@ -595,7 +597,7 @@ bool Utilities::isValidSubCall(const QString &_c)
{
if (!((_c.at(i).isLetter()) ))
{
//qDebug() << "Utilities::isValidSubCall: FALSE-1.3: " << _c ;
//qDebug() << "Utilities::isValidSubCall: FALSE-1.4: " << _c ;
return false;
}
i++;
Expand Down Expand Up @@ -840,7 +842,8 @@ int Utilities::isAPrefix (const QString &_c)

void Utilities::setCallValidation(const bool _b)
{
callValidation = _b;
//callValidation = _b;
g_callsignCheck = _b;
}

bool Utilities::isValidCall(const QString &_c)
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Utilities
bool isValidSubCall(const QString &_c);
//QPair<QString, QString> getCallParts(const QString &_c);

bool darkMode, callValidation;
bool darkMode;//, callValidation;
QString dbPath;
QString softwareVersion;
//QPalette palRed, palBlack;
Expand Down
60 changes: 30 additions & 30 deletions tests/utilities/tst_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ void tst_Utilities::test_isValidCall()
// and a single digit,
// followed by a group of not more than four characters,
// the last of which shall be a letter,
util->setCallValidation (true);
util->setCallValidation(true);
//qDebug() << Q_FUNC_INFO << " 1 Letter" << endl;
QVERIFY2(util->isValidCall("B1A") == true, "B1A");
QVERIFY2(util->isValidCall("B1AA") == true, "B1AA");
QVERIFY2(util->isValidCall("B1AAA") == true, "B1AAA");
QVERIFY2(util->isValidCall("B1AAAA") == true, "B1AAAA");
QVERIFY2(util->isValidCall("B11") == false, "B11");
QVERIFY2(util->isValidCall("B1A"), "B1A");
QVERIFY2(util->isValidCall("B1AA"), "B1AA");
QVERIFY2(util->isValidCall("B1AAA"), "B1AAA");
QVERIFY2(util->isValidCall("B1AAAA"), "B1AAAA");
QVERIFY2(!util->isValidCall("B11"), "B11");
// TODO: FIX the isValidCall to cover these cases
//QVERIFY(util->isValidCall("B1A1") == false);
//QVERIFY(util->isValidCall("B1AA1") == false);
Expand All @@ -168,40 +168,40 @@ void tst_Utilities::test_isValidCall()
//2) or–two characters and a single digit,
// followed by a group of not more than four characters, the last of which shall be a letter.
//qDebug() << Q_FUNC_INFO << " 2 Letters" << endl;
QVERIFY2(util->isValidCall("EA4K") == true, "EA4K");
QVERIFY2(util->isValidCall("EA4KK") == true, "EA4KK");
QVERIFY2(util->isValidCall("EA4KKK") == true, "EA4KKK");
QVERIFY2(util->isValidCall("EA4KKKK") == true, "EA4KKKK");
QVERIFY2(util->isValidCall("AM500MMM") == true, "AM500MMM");
QVERIFY2(util->isValidCall("EA4K"), "EA4K");
QVERIFY2(util->isValidCall("EA4KK"), "EA4KK");
QVERIFY2(util->isValidCall("EA4KKK"), "EA4KKK");
QVERIFY2(util->isValidCall("EA4KKKK"), "EA4KKKK");
QVERIFY2(util->isValidCall("AM500MMM"), "AM500MMM");

QVERIFY2(util->isValidCall("2E1A") == true, "2E1A");
QVERIFY2(util->isValidCall("E33E") == true, "E33E");
QVERIFY2(util->isValidCall("EA5666K") == true, "EA5666K");
QVERIFY2(util->isValidCall("2E1A"), "2E1A");
QVERIFY2(util->isValidCall("E33E"), "E33E");
QVERIFY2(util->isValidCall("EA5666K"), "EA5666K");

// 5(WRC-03)19.68A1A) On special occasions, for temporary use, administrations may authorize
// use of call signs with more than the four characters referred to in No. 19.68.(WRC-03
//qDebug() << Q_FUNC_INFO << " Complex" << endl;
QVERIFY2(util->isValidCall("EA4K/P") == true, "EA4K/P");
QVERIFY2(util->isValidCall("K/EA4K/P") == true, "EA4K/P");
QVERIFY2(util->isValidCall("EA4K/F") == true, "EA4K/F");
QVERIFY2(util->isValidCall("EA4K/1") == true, "EA4K/1");
QVERIFY2(util->isValidCall("EA4K/K1") == true, "EA4K/K1");
QVERIFY2(util->isValidCall("K1/EA4K") == true, "K1/EA4K");
QVERIFY2(util->isValidCall("K/EA4K") == true, "K/EA4K");
QVERIFY2(util->isValidCall("EA4K/P"), "EA4K/P");
QVERIFY2(util->isValidCall("K/EA4K/P"), "EA4K/P");
QVERIFY2(util->isValidCall("EA4K/F"), "EA4K/F");
QVERIFY2(util->isValidCall("EA4K/1"), "EA4K/1");
QVERIFY2(util->isValidCall("EA4K/K1"), "EA4K/K1");
QVERIFY2(util->isValidCall("K1/EA4K"), "K1/EA4K");
QVERIFY2(util->isValidCall("K/EA4K"), "K/EA4K");
// TODO: FIX the isValidCall to cover this case
//QVERIFY(util->isValidCall("1/EA4K") == false);
//qDebug() << Q_FUNC_INFO << " Wrong calls" << endl;
QVERIFY2(util->isValidCall("EA") == false, "EA");
QVERIFY2(util->isValidCall("EA4") == false, "EA4");
QVERIFY2(util->isValidCall("-") == false, "-");
QVERIFY2(util->isValidCall("EAK4") == false, "EAK4");
QVERIFY2(util->isValidCall("QQQ/EA4K") == false, "QQQ/EA4K");
QVERIFY2(!util->isValidCall("EA"), "EA");
QVERIFY2(!util->isValidCall("EA4"), "EA4");
QVERIFY2(!util->isValidCall("-"), "-");
QVERIFY2(!util->isValidCall("EAK4"), "EAK4");
QVERIFY2(!util->isValidCall("QQQ/EA4K"), "QQQ/EA4K");

util->setCallValidation (false);
QVERIFY2(util->isValidCall("EA") == true, "Should be true: EA");
QVERIFY2(util->isValidCall("EA4") == true, "Should be true: EA4");
QVERIFY2(util->isValidCall("-") == true, "Should be true: EAK4");
QVERIFY2(util->isValidCall("EA4K") == true, "Should be true: QQQ/EA4K");
QVERIFY2(util->isValidCall("EA"), "Should be true: EA");
QVERIFY2(util->isValidCall("EA4"), "Should be true: EA4");
QVERIFY2(util->isValidCall("-"), "Should be true: EAK4");
QVERIFY2(util->isValidCall("EA4K"), "Should be true: QQQ/EA4K");
util->setCallValidation (true);
}

Expand Down

0 comments on commit 7654154

Please sign in to comment.