|
|
|
@ -1,32 +1,8 @@
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CIRCDDB - ircDDB client library in C++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2010-2011 Michael Dirska, DL1BFF (dl1bff@mdx.de)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "IRCDDB.h"
|
|
|
|
#include "IRCDDB.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "IRCClient.h"
|
|
|
|
#include "IRCClient.h"
|
|
|
|
#include "IRCDDBApp.h"
|
|
|
|
#include "IRCDDBApp.h"
|
|
|
|
|
|
|
|
#include "IRCutils.h"
|
|
|
|
#include <wx/wx.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct CIRCDDBPrivate {
|
|
|
|
struct CIRCDDBPrivate {
|
|
|
|
IRCClient *client;
|
|
|
|
IRCClient *client;
|
|
|
|
@ -34,17 +10,15 @@ struct CIRCDDBPrivate {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CIRCDDB::CIRCDDB(const wxString& hostName, unsigned int port,
|
|
|
|
CIRCDDB::CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo, const std::string &localAddr)
|
|
|
|
const wxString& callsign, const wxString& password,
|
|
|
|
: d(new CIRCDDBPrivate)
|
|
|
|
const wxString& versionInfo, const wxString& localAddr ) : d( new CIRCDDBPrivate )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxString update_channel = wxT("#dstar");
|
|
|
|
std::string update_channel = "#dstar";
|
|
|
|
|
|
|
|
|
|
|
|
d->app = new IRCDDBApp(update_channel);
|
|
|
|
d->app = new IRCDDBApp(update_channel);
|
|
|
|
|
|
|
|
|
|
|
|
d->client = new IRCClient( d->app, update_channel, hostName, port, callsign,
|
|
|
|
d->client = new IRCClient(d->app, update_channel, hostName, port, callsign, password, versionInfo, localAddr);
|
|
|
|
password, versionInfo, localAddr );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CIRCDDB::~CIRCDDB()
|
|
|
|
CIRCDDB::~CIRCDDB()
|
|
|
|
@ -58,7 +32,7 @@ CIRCDDB::~CIRCDDB()
|
|
|
|
// A false return implies a network error, or unable to log in
|
|
|
|
// A false return implies a network error, or unable to log in
|
|
|
|
bool CIRCDDB::open()
|
|
|
|
bool CIRCDDB::open()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxLogVerbose(wxT("start"));
|
|
|
|
traceit("start");
|
|
|
|
return d->client->startWork() && d->app->startWork();
|
|
|
|
return d->client->startWork() && d->app->startWork();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,229 +43,215 @@ int CIRCDDB::getConnectionState()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CIRCDDB::rptrQTH(const wxString& rptrcall, double latitude, double longitude, const wxString& desc1, const wxString& desc2, const wxString& infoURL, const wxString &swVersion)
|
|
|
|
void CIRCDDB::rptrQTH(const std::string &rptrcall, double latitude, double longitude, const std::string &desc1, const std::string &desc2, const std::string &infoURL, const std::string &swVersion)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->app->rptrQTH(rptrcall, latitude, longitude, desc1, desc2, infoURL, swVersion);
|
|
|
|
d->app->rptrQTH(rptrcall, latitude, longitude, desc1, desc2, infoURL, swVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CIRCDDB::rptrQRG(const wxString& rptrcall, double txFrequency, double duplexShift, double range, double agl)
|
|
|
|
void CIRCDDB::rptrQRG(const std::string &rptrcall, double txFrequency, double duplexShift, double range, double agl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->app->rptrQRG(rptrcall, txFrequency, duplexShift, range, agl);
|
|
|
|
d->app->rptrQRG(rptrcall, txFrequency, duplexShift, range, agl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CIRCDDB::kickWatchdog ( const wxString& wdInfo )
|
|
|
|
void CIRCDDB::kickWatchdog(const std::string &wdInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->app->kickWatchdog(wdInfo);
|
|
|
|
d->app->kickWatchdog(wdInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send heard data, a false return implies a network error
|
|
|
|
// Send heard data, a false return implies a network error
|
|
|
|
bool CIRCDDB::sendHeard( const wxString& myCall, const wxString& myCallExt,
|
|
|
|
bool CIRCDDB::sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1,
|
|
|
|
const wxString& yourCall, const wxString& rpt1,
|
|
|
|
const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3)
|
|
|
|
const wxString& rpt2, unsigned char flag1,
|
|
|
|
|
|
|
|
unsigned char flag2, unsigned char flag3 )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (myCall.Len() != 8) {
|
|
|
|
if (myCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myCallExt.Len() != 4) {
|
|
|
|
if (myCallExt.size() != 4) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (yourCall.Len() != 8) {
|
|
|
|
if (yourCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt1.Len() != 8) {
|
|
|
|
if (rpt1.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt2.Len() != 8) {
|
|
|
|
if (rpt2.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3,
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, " ", "", "");
|
|
|
|
wxT(" "), wxT(""), wxT(""));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send heard data, a false return implies a network error
|
|
|
|
// Send heard data, a false return implies a network error
|
|
|
|
bool CIRCDDB::sendHeardWithTXMsg( const wxString& myCall, const wxString& myCallExt,
|
|
|
|
bool CIRCDDB::sendHeardWithTXMsg(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1,
|
|
|
|
const wxString& yourCall, const wxString& rpt1,
|
|
|
|
unsigned char flag2, unsigned char flag3, const std::string &network_destination, const std::string &tx_message)
|
|
|
|
const wxString& rpt2, unsigned char flag1,
|
|
|
|
|
|
|
|
unsigned char flag2, unsigned char flag3,
|
|
|
|
|
|
|
|
const wxString& network_destination,
|
|
|
|
|
|
|
|
const wxString& tx_message )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (myCall.Len() != 8) {
|
|
|
|
if (myCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myCallExt.Len() != 4) {
|
|
|
|
if (myCallExt.size() != 4) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (yourCall.Len() != 8) {
|
|
|
|
if (yourCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt1.Len() != 8) {
|
|
|
|
if (rpt1.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt2.Len() != 8) {
|
|
|
|
if (rpt2.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString dest = network_destination;
|
|
|
|
std::string dest = network_destination;
|
|
|
|
|
|
|
|
|
|
|
|
if (dest.Len() == 0) {
|
|
|
|
if (dest.size() == 0)
|
|
|
|
dest = wxT(" ");
|
|
|
|
dest = " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dest.Len() != 8) {
|
|
|
|
if (dest.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:network_destination: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:network_destination: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
std::string msg;
|
|
|
|
|
|
|
|
|
|
|
|
if (tx_message.Len() == 20) {
|
|
|
|
if (tx_message.length() == 20) {
|
|
|
|
unsigned int i;
|
|
|
|
for (unsigned int i=0; i < tx_message.size(); i++) {
|
|
|
|
for (i=0; i < tx_message.Len(); i++) {
|
|
|
|
char ch = tx_message.at(i);
|
|
|
|
wxChar ch = tx_message.GetChar(i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((ch > 32) && (ch < 127)) {
|
|
|
|
if (ch>32 && ch<127) {
|
|
|
|
msg.Append(ch);
|
|
|
|
msg.push_back(ch);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
msg.Append(wxT('_'));
|
|
|
|
msg.push_back('_');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3,
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, dest, msg, "");
|
|
|
|
dest, msg, wxT(""));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CIRCDDB::sendHeardWithTXStats( const wxString& myCall, const wxString& myCallExt,
|
|
|
|
bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1,
|
|
|
|
const wxString& yourCall, const wxString& rpt1,
|
|
|
|
unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors)
|
|
|
|
const wxString& rpt2, unsigned char flag1,
|
|
|
|
|
|
|
|
unsigned char flag2, unsigned char flag3,
|
|
|
|
|
|
|
|
int num_dv_frames,
|
|
|
|
|
|
|
|
int num_dv_silent_frames,
|
|
|
|
|
|
|
|
int num_bit_errors )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((num_dv_frames <= 0) || (num_dv_frames > 65535)) {
|
|
|
|
if (num_dv_frames<= 0 || num_dv_frames>65535) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535"));
|
|
|
|
traceit("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (num_dv_silent_frames > num_dv_frames) {
|
|
|
|
if (num_dv_silent_frames > num_dv_frames) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames"));
|
|
|
|
traceit("CIRCDDB::sendHeard:num_dv_silent_frames > num_dv_frames");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (num_bit_errors > (4*num_dv_frames)) { // max 4 bit errors per frame
|
|
|
|
if (num_bit_errors > 4*num_dv_frames) { // max 4 bit errors per frame
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)"));
|
|
|
|
traceit("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myCall.Len() != 8) {
|
|
|
|
if (myCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (myCallExt.Len() != 4) {
|
|
|
|
if (myCallExt.size() != 4) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
|
|
|
|
traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (yourCall.Len() != 8) {
|
|
|
|
if (yourCall.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:yourCall: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt1.Len() != 8) {
|
|
|
|
if (rpt1.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt1: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (rpt2.Len() != 8) {
|
|
|
|
if (rpt2.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
|
|
|
|
traceit("CIRCDDB::sendHeard:rpt2: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString stats = wxString::Format(wxT("%04x"), num_dv_frames);
|
|
|
|
char buf[16];
|
|
|
|
|
|
|
|
snprintf(buf, 16, "%04x", num_dv_frames);
|
|
|
|
|
|
|
|
std::string stats = buf;
|
|
|
|
|
|
|
|
|
|
|
|
if (num_dv_silent_frames >= 0) {
|
|
|
|
if (num_dv_silent_frames >= 0) {
|
|
|
|
wxString s = wxString::Format(wxT("%02x"), (num_dv_silent_frames * 100) / num_dv_frames);
|
|
|
|
snprintf(buf, 16, "%02x", num_dv_silent_frames * 100 / num_dv_frames);
|
|
|
|
stats.Append(s);
|
|
|
|
stats.append(buf);
|
|
|
|
|
|
|
|
|
|
|
|
if (num_bit_errors >= 0) {
|
|
|
|
if (num_bit_errors >= 0) {
|
|
|
|
s = wxString::Format(wxT("%02x"), (num_bit_errors * 125) / (num_dv_frames * 3));
|
|
|
|
snprintf(buf,16, "%02x", num_bit_errors * 125 / (num_dv_frames * 3));
|
|
|
|
stats.Append(s);
|
|
|
|
stats.append(buf);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stats.Append(wxT("__"));
|
|
|
|
stats.append("__");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stats.Append(wxT("____"));
|
|
|
|
stats.append("____");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stats.Append(wxT("____________")); // stats string should have 20 chars
|
|
|
|
stats.append("____________"); // stats string should have 20 chars
|
|
|
|
|
|
|
|
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3,
|
|
|
|
return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, " ", "", stats);
|
|
|
|
wxT(" "), wxT(""), stats);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send query for a gateway/reflector, a false return implies a network error
|
|
|
|
// Send query for a gateway/reflector, a false return implies a network error
|
|
|
|
bool CIRCDDB::findGateway(const wxString& gatewayCallsign)
|
|
|
|
bool CIRCDDB::findGateway(const std::string &gatewayCallsign)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (gatewayCallsign.Len() != 8) {
|
|
|
|
if (gatewayCallsign.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::findGateway: len != 8"));
|
|
|
|
traceit("CIRCDDB::findGateway: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string gcs = gatewayCallsign;
|
|
|
|
return d->app->findGateway( gatewayCallsign.Upper());
|
|
|
|
ToUpper(gcs);
|
|
|
|
|
|
|
|
return d->app->findGateway(gcs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CIRCDDB::findRepeater(const wxString& repeaterCallsign)
|
|
|
|
bool CIRCDDB::findRepeater(const std::string &repeaterCallsign)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (repeaterCallsign.Len() != 8) {
|
|
|
|
if (repeaterCallsign.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::findRepeater: len != 8"));
|
|
|
|
traceit("CIRCDDB::findRepeater: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string rcs = repeaterCallsign;
|
|
|
|
return d->app->findRepeater( repeaterCallsign.Upper());
|
|
|
|
ToUpper(rcs);
|
|
|
|
|
|
|
|
return d->app->findRepeater(rcs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Send query for a user, a false return implies a network error
|
|
|
|
// Send query for a user, a false return implies a network error
|
|
|
|
bool CIRCDDB::findUser(const wxString& userCallsign)
|
|
|
|
bool CIRCDDB::findUser(const std::string &userCallsign)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (userCallsign.Len() != 8) {
|
|
|
|
if (userCallsign.size() != 8) {
|
|
|
|
wxLogVerbose(wxT("CIRCDDB::findUser: len != 8"));
|
|
|
|
traceit("CIRCDDB::findUser: len != 8");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ucs = userCallsign;
|
|
|
|
return d->app->findUser( userCallsign.Upper());
|
|
|
|
ToUpper(ucs);
|
|
|
|
|
|
|
|
return d->app->findUser(ucs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The following functions are for processing received messages
|
|
|
|
// The following functions are for processing received messages
|
|
|
|
@ -304,29 +264,29 @@ IRCDDB_RESPONSE_TYPE CIRCDDB::getMessageType()
|
|
|
|
|
|
|
|
|
|
|
|
// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType()
|
|
|
|
// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType()
|
|
|
|
// A false return implies a network error
|
|
|
|
// A false return implies a network error
|
|
|
|
bool CIRCDDB::receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& /*protocol*/)
|
|
|
|
bool CIRCDDB::receiveRepeater(std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL &/*protocol*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
|
|
|
|
|
|
|
|
if (rt != IDRT_REPEATER) {
|
|
|
|
if (rt != IDRT_REPEATER) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected response type"));
|
|
|
|
traceit("CIRCDDB::receiveRepeater: unexpected response type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
|
|
|
|
|
|
|
|
if (m == NULL) {
|
|
|
|
if (m == NULL) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveRepeater: no message"));
|
|
|
|
traceit("CIRCDDB::receiveRepeater: no message");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!m->getCommand().IsSameAs(wxT("IDRT_REPEATER"))) {
|
|
|
|
if (m->getCommand().compare("IDRT_REPEATER")) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveRepeater: wrong message type"));
|
|
|
|
traceit("CIRCDDB::receiveRepeater: wrong message type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m->getParamCount() != 3) {
|
|
|
|
if (m->getParamCount() != 3) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected number of message parameters"));
|
|
|
|
traceit("CIRCDDB::receiveRepeater: unexpected number of message parameters");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -341,29 +301,29 @@ bool CIRCDDB::receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCalls
|
|
|
|
|
|
|
|
|
|
|
|
// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType()
|
|
|
|
// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType()
|
|
|
|
// A false return implies a network error
|
|
|
|
// A false return implies a network error
|
|
|
|
bool CIRCDDB::receiveGateway(wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& /*protocol*/)
|
|
|
|
bool CIRCDDB::receiveGateway(std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL& /*protocol*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
|
|
|
|
|
|
|
|
if (rt != IDRT_GATEWAY) {
|
|
|
|
if (rt != IDRT_GATEWAY) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveGateway: unexpected response type"));
|
|
|
|
traceit("CIRCDDB::receiveGateway: unexpected response type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
|
|
|
|
|
|
|
|
if (m == NULL) {
|
|
|
|
if (m == NULL) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveGateway: no message"));
|
|
|
|
traceit("CIRCDDB::receiveGateway: no message");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!m->getCommand().IsSameAs(wxT("IDRT_GATEWAY"))) {
|
|
|
|
if (m->getCommand().compare("IDRT_GATEWAY")) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveGateway: wrong message type"));
|
|
|
|
traceit("CIRCDDB::receiveGateway: wrong message type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m->getParamCount() != 2) {
|
|
|
|
if (m->getParamCount() != 2) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveGateway: unexpected number of message parameters"));
|
|
|
|
traceit("CIRCDDB::receiveGateway: unexpected number of message parameters");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -377,36 +337,36 @@ bool CIRCDDB::receiveGateway(wxString& gatewayCallsign, wxString& address, DSTAR
|
|
|
|
|
|
|
|
|
|
|
|
// Get a user message, as a result of IDRT_USER returned from getMessageType()
|
|
|
|
// Get a user message, as a result of IDRT_USER returned from getMessageType()
|
|
|
|
// A false return implies a network error
|
|
|
|
// A false return implies a network error
|
|
|
|
bool CIRCDDB::receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address)
|
|
|
|
bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
wxString dummy;
|
|
|
|
std::string dummy;
|
|
|
|
return receiveUser(userCallsign, repeaterCallsign, gatewayCallsign, address, dummy);
|
|
|
|
return receiveUser(userCallsign, repeaterCallsign, gatewayCallsign, address, dummy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CIRCDDB::receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address,
|
|
|
|
bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address,
|
|
|
|
wxString& timeStamp)
|
|
|
|
std::string &timeStamp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
|
|
|
|
|
|
|
|
|
|
|
|
if (rt != IDRT_USER) {
|
|
|
|
if (rt != IDRT_USER) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveUser: unexpected response type"));
|
|
|
|
traceit("CIRCDDB::receiveUser: unexpected response type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
IRCMessage * m = d->app->getReplyMessage();
|
|
|
|
|
|
|
|
|
|
|
|
if (m == NULL) {
|
|
|
|
if (m == NULL) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveUser: no message"));
|
|
|
|
traceit("CIRCDDB::receiveUser: no message");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!m->getCommand().IsSameAs(wxT("IDRT_USER"))) {
|
|
|
|
if (m->getCommand().compare("IDRT_USER")) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveUser: wrong message type"));
|
|
|
|
traceit("CIRCDDB::receiveUser: wrong message type");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m->getParamCount() != 5) {
|
|
|
|
if (m->getParamCount() != 5) {
|
|
|
|
wxLogError(wxT("CIRCDDB::receiveUser: unexpected number of message parameters"));
|
|
|
|
traceit("CIRCDDB::receiveUser: unexpected number of message parameters");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|