#5 More renaming

pull/32/head
Geoffrey Merck 4 years ago
parent 7127996a6c
commit 1be24fa41d

@ -135,6 +135,8 @@ public:
virtual bool receiveUser(std::string& userCallsign, std::string& repeaterCallsign, std::string& gatewayCallsign, std::string& address, std::string& timeStamp) = 0; virtual bool receiveUser(std::string& userCallsign, std::string& repeaterCallsign, std::string& gatewayCallsign, std::string& address, std::string& timeStamp) = 0;
virtual void close() = 0; // Implictely kills any threads in the IRC code virtual void close() = 0; // Implictely kills any threads in the IRC code
virtual void queryUsers() = 0;
}; };
typedef std::vector<CIRCDDB*> CIRCDDB_Array; typedef std::vector<CIRCDDB*> CIRCDDB_Array;

@ -89,13 +89,13 @@ public:
{ {
} }
int state; int m_state;
int timer; int m_timer;
int infoTimer; int m_infoTimer;
int wdTimer; int m_wdTimer;
IRCMessageQueue *sendQ; IRCMessageQueue *m_sendQ;
IRCMessageQueue replyQ; IRCMessageQueue m_replyQ;
std::string m_currentServer; std::string m_currentServer;
std::string m_myNick; std::string m_myNick;
@ -132,13 +132,13 @@ IRCDDBApp::IRCDDBApp(const std::string& u_chan)
: d(new IRCDDBAppPrivate) : d(new IRCDDBAppPrivate)
, m_maxTime((time_t)950000000) //februray 2000 , m_maxTime((time_t)950000000) //februray 2000
{ {
d->sendQ = NULL; d->m_sendQ = NULL;
d->m_initReady = false; d->m_initReady = false;
userListReset(); userListReset();
d->state = 0; d->m_state = 0;
d->timer = 0; d->m_timer = 0;
d->m_myNick = std::string("none"); d->m_myNick = std::string("none");
d->m_updateChannel = u_chan; d->m_updateChannel = u_chan;
@ -148,7 +148,7 @@ IRCDDBApp::IRCDDBApp(const std::string& u_chan)
IRCDDBApp::~IRCDDBApp() IRCDDBApp::~IRCDDBApp()
{ {
delete d->sendQ; delete d->m_sendQ;
delete d; delete d;
} }
@ -194,7 +194,7 @@ void IRCDDBApp::rptrQTH(const std::string& callsign, double latitude, double lon
CLog::logInfo("URL: %s\n", d->m_moduleURL[cs].c_str()); CLog::logInfo("URL: %s\n", d->m_moduleURL[cs].c_str());
} }
d->infoTimer = 5; // send info in 5 seconds d->m_infoTimer = 5; // send info in 5 seconds
} }
void IRCDDBApp::rptrQRG(const std::string& callsign, double txFrequency, double duplexShift, double range, double agl) void IRCDDBApp::rptrQRG(const std::string& callsign, double txFrequency, double duplexShift, double range, double agl)
@ -211,7 +211,7 @@ void IRCDDBApp::rptrQRG(const std::string& callsign, double txFrequency, double
d->m_moduleQRG[cs] = cs + std::string(" ") + f; d->m_moduleQRG[cs] = cs + std::string(" ") + f;
CLog::logInfo("QRG: %s\n", d->m_moduleQRG[cs].c_str()); CLog::logInfo("QRG: %s\n", d->m_moduleQRG[cs].c_str());
d->infoTimer = 5; // send info in 5 seconds d->m_infoTimer = 5; // send info in 5 seconds
} }
void IRCDDBApp::kickWatchdog(const std::string& callsign, const std::string& s) void IRCDDBApp::kickWatchdog(const std::string& callsign, const std::string& s)
@ -229,18 +229,18 @@ void IRCDDBApp::kickWatchdog(const std::string& callsign, const std::string& s)
std::lock_guard lockModuleWD(d->m_moduleWDMutex); std::lock_guard lockModuleWD(d->m_moduleWDMutex);
d->m_moduleWD[cs] = cs + std::string(" ") + text; d->m_moduleWD[cs] = cs + std::string(" ") + text;
d->wdTimer = 60; d->m_wdTimer = 60;
} }
} }
int IRCDDBApp::getConnectionState() int IRCDDBApp::getConnectionState()
{ {
return d->state; return d->m_state;
} }
IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType() IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType()
{ {
IRCMessage *m = d->replyQ.peekFirst(); IRCMessage *m = d->m_replyQ.peekFirst();
if (m == NULL) if (m == NULL)
return IDRT_NONE; return IDRT_NONE;
@ -262,7 +262,7 @@ IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType()
IRCMessage *IRCDDBApp::getReplyMessage() IRCMessage *IRCDDBApp::getReplyMessage()
{ {
return d->replyQ.getMessage(); return d->m_replyQ.getMessage();
} }
void IRCDDBApp::startWork() void IRCDDBApp::startWork()
@ -319,7 +319,7 @@ void IRCDDBApp::userJoin(const std::string& nick, const std::string& name, const
IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY"); IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY");
m2->addParam(gatewayCallsign); m2->addParam(gatewayCallsign);
m2->addParam(host); m2->addParam(host);
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
} }
} }
@ -345,8 +345,8 @@ void IRCDDBApp::userLeave(const std::string& nick)
if (0 == d->m_currentServer.compare(lnick)) { if (0 == d->m_currentServer.compare(lnick)) {
// m_currentServer = null; // m_currentServer = null;
d->state = 2; // choose new server d->m_state = 2; // choose new server
d->timer = 200; d->m_timer = 200;
d->m_initReady = false; d->m_initReady = false;
} }
} }
@ -469,7 +469,7 @@ bool IRCDDBApp::findGateway(const std::string& gwCall)
IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY"); IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY");
m2->addParam(gwCall); m2->addParam(gwCall);
m2->addParam(getIPAddress(s)); m2->addParam(getIPAddress(s));
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
return true; return true;
} }
@ -504,7 +504,7 @@ static void findReflector(const std::string& rptrCall, IRCDDBAppPrivate *d)
m2->addParam(rptrCall); m2->addParam(rptrCall);
m2->addParam(zonerp_cs); m2->addParam(zonerp_cs);
m2->addParam(ipAddr); m2->addParam(ipAddr);
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
bool IRCDDBApp::findRepeater(const std::string& rptrCall) bool IRCDDBApp::findRepeater(const std::string& rptrCall)
@ -534,7 +534,7 @@ bool IRCDDBApp::findRepeater(const std::string& rptrCall)
m2->addParam(rptrCall); m2->addParam(rptrCall);
m2->addParam(zonerp_cs); m2->addParam(zonerp_cs);
m2->addParam(getIPAddress(s)); m2->addParam(getIPAddress(s));
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
return true; return true;
} }
@ -543,7 +543,7 @@ void IRCDDBApp::sendDStarGatewayInfo(const std::string &subcommand, const std::v
{ {
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
std::string srv(d->m_currentServer); std::string srv(d->m_currentServer);
if (srv.size() && d->state>=6 && q) { if (srv.size() && d->m_state>=6 && q) {
std::string command("DStarGateway "); std::string command("DStarGateway ");
command.append(subcommand); command.append(subcommand);
for (auto it=pars.begin(); it!=pars.end(); it++) { for (auto it=pars.begin(); it!=pars.end(); it++) {
@ -585,7 +585,7 @@ bool IRCDDBApp::sendHeard(const std::string& myCall, const std::string& myCallEx
std::string srv(d->m_currentServer); std::string srv(d->m_currentServer);
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
if (srv.size() && d->state>=6 && q) { if (srv.size() && d->m_state>=6 && q) {
std::string cmd("UPDATE "); std::string cmd("UPDATE ");
cmd += CUtils::getCurrentTime(); cmd += CUtils::getCurrentTime();
@ -619,7 +619,7 @@ bool IRCDDBApp::findUser(const std::string& usrCall)
std::string srv(d->m_currentServer); std::string srv(d->m_currentServer);
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
if (srv.size()>0 && d->state>=6 && q) { if (srv.size()>0 && d->m_state>=6 && q) {
std::string usr(usrCall); std::string usr(usrCall);
CUtils::ReplaceChar(usr, ' ', '_'); CUtils::ReplaceChar(usr, ' ', '_');
IRCMessage * m =new IRCMessage(srv, std::string("FIND ") + usr); IRCMessage * m =new IRCMessage(srv, std::string("FIND ") + usr);
@ -629,7 +629,7 @@ bool IRCDDBApp::findUser(const std::string& usrCall)
m2->addParam(usrCall); m2->addParam(usrCall);
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
m2->addParam(std::string("")); m2->addParam(std::string(""));
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
return true; return true;
} }
@ -744,7 +744,7 @@ void IRCDDBApp::doUpdate(std::string& msg)
m2->addParam(arearp_cs); m2->addParam(arearp_cs);
m2->addParam(zonerp_cs); m2->addParam(zonerp_cs);
m2->addParam(getIPAddress(value)); m2->addParam(getIPAddress(value));
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
} else if (0==tableID && d->m_initReady) { } else if (0==tableID && d->m_initReady) {
std::lock_guard lockRptrMap(d->m_rptrMapMutex); std::lock_guard lockRptrMap(d->m_rptrMapMutex);
@ -770,7 +770,7 @@ void IRCDDBApp::doUpdate(std::string& msg)
m2->addParam(zonerp_cs); m2->addParam(zonerp_cs);
m2->addParam(ip_addr); m2->addParam(ip_addr);
m2->addParam(tk + std::string(" ") + timeToken); m2->addParam(tk + std::string(" ") + timeToken);
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
} }
} }
@ -812,11 +812,11 @@ void IRCDDBApp::msgQuery(IRCMessage *m)
} }
doUpdate(restOfLine); doUpdate(restOfLine);
} else if (0 == cmd.compare("LIST_END")) { } else if (0 == cmd.compare("LIST_END")) {
if (5 == d->state) // if in sendlist processing state if (5 == d->m_state) // if in sendlist processing state
d->state = 3; // get next table d->m_state = 3; // get next table
} else if (0 == cmd.compare("LIST_MORE")) { } else if (0 == cmd.compare("LIST_MORE")) {
if (5 == d->state) // if in sendlist processing state if (5 == d->m_state) // if in sendlist processing state
d->state = 4; // send next SENDLIST d->m_state = 4; // send next SENDLIST
} else if (0 == cmd.compare("NOT_FOUND")) { } else if (0 == cmd.compare("NOT_FOUND")) {
std::string callsign; std::string callsign;
std::string restOfLine; std::string restOfLine;
@ -834,7 +834,7 @@ void IRCDDBApp::msgQuery(IRCMessage *m)
m2->addParam(callsign); m2->addParam(callsign);
for (int i=0; i<4; i++) for (int i=0; i<4; i++)
m2->addParam(std::string("")); m2->addParam(std::string(""));
d->replyQ.putMessage(m2); d->m_replyQ.putMessage(m2);
} }
} }
} }
@ -842,12 +842,12 @@ void IRCDDBApp::msgQuery(IRCMessage *m)
void IRCDDBApp::setSendQ(IRCMessageQueue *s) void IRCDDBApp::setSendQ(IRCMessageQueue *s)
{ {
d->sendQ = s; d->m_sendQ = s;
} }
IRCMessageQueue *IRCDDBApp::getSendQ() IRCMessageQueue *IRCDDBApp::getSendQ()
{ {
return d->sendQ; return d->m_sendQ;
} }
std::string IRCDDBApp::getLastEntryTime(int tableID) std::string IRCDDBApp::getLastEntryTime(int tableID)
@ -871,29 +871,29 @@ void IRCDDBApp::Entry()
{ {
int sendlistTableID = 0; int sendlistTableID = 0;
while (!d->m_terminateThread) { while (!d->m_terminateThread) {
if (d->timer > 0) if (d->m_timer > 0)
d->timer--; d->m_timer--;
switch(d->state) { switch(d->m_state) {
case 0: // wait for network to start case 0: // wait for network to start
if (getSendQ()) if (getSendQ())
d->state = 1; d->m_state = 1;
break; break;
case 1: // connect to db case 1: // connect to db
d->state = 2; d->m_state = 2;
d->timer = 200; d->m_timer = 200;
break; break;
case 2: // choose server case 2: // choose server
CLog::logInfo("IRCDDBApp: state=2 choose new 's-'-user\n"); CLog::logInfo("IRCDDBApp: state=2 choose new 's-'-user\n");
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; d->m_state = 10;
else { else {
if (findServerUser()) { if (findServerUser()) {
sendlistTableID = numberOfTables; sendlistTableID = numberOfTables;
d->state = 3; // next: send "SENDLIST" d->m_state = 3; // next: send "SENDLIST"
} else if (0 == d->timer) { } else if (0 == d->m_timer) {
d->state = 10; d->m_state = 10;
IRCMessage *m = new IRCMessage("QUIT"); IRCMessage *m = new IRCMessage("QUIT");
m->addParam("no op user with 's-' found."); m->addParam("no op user with 's-' found.");
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
@ -905,39 +905,39 @@ void IRCDDBApp::Entry()
case 3: case 3:
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
else { else {
sendlistTableID--; sendlistTableID--;
if (sendlistTableID < 0) if (sendlistTableID < 0)
d->state = 6; // end of sendlist d->m_state = 6; // end of sendlist
else { else {
CLog::logInfo("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID); CLog::logInfo("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID);
d->state = 4; // send "SENDLIST" d->m_state = 4; // send "SENDLIST"
d->timer = 900; // 15 minutes max for update d->m_timer = 900; // 15 minutes max for update
} }
} }
break; break;
case 4: case 4:
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
else { else {
if (needsDatabaseUpdate(sendlistTableID)) { if (needsDatabaseUpdate(sendlistTableID)) {
IRCMessage *m = new IRCMessage(d->m_currentServer, std::string("SENDLIST") + getTableIDString(sendlistTableID, true) + std::string(" ") + getLastEntryTime(sendlistTableID)); IRCMessage *m = new IRCMessage(d->m_currentServer, std::string("SENDLIST") + getTableIDString(sendlistTableID, true) + std::string(" ") + getLastEntryTime(sendlistTableID));
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
if (q) if (q)
q->putMessage(m); q->putMessage(m);
d->state = 5; // wait for answers d->m_state = 5; // wait for answers
} else } else
d->state = 3; // don't send SENDLIST for this table, go to next table d->m_state = 3; // don't send SENDLIST for this table, go to next table
} }
break; break;
case 5: // sendlist processing case 5: // sendlist processing
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
else if (0 == d->timer) { else if (0 == d->m_timer) {
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
IRCMessage *m = new IRCMessage("QUIT"); IRCMessage *m = new IRCMessage("QUIT");
m->addParam("timeout SENDLIST"); m->addParam("timeout SENDLIST");
IRCMessageQueue *q = getSendQ(); IRCMessageQueue *q = getSendQ();
@ -948,23 +948,23 @@ void IRCDDBApp::Entry()
case 6: case 6:
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
else { else {
CLog::logInfo( "IRCDDBApp: state=6 initialization completed\n"); CLog::logInfo( "IRCDDBApp: state=6 initialization completed\n");
d->infoTimer = 2; d->m_infoTimer = 2;
d->m_initReady = true; d->m_initReady = true;
d->state = 7; d->m_state = 7;
} }
break; break;
case 7: // standby state after initialization case 7: // standby state after initialization
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->m_state = 10; // disconnect DB
if (d->infoTimer > 0) { if (d->m_infoTimer > 0) {
d->infoTimer--; d->m_infoTimer--;
if (0 == d->infoTimer) { if (0 == d->m_infoTimer) {
{ // Scope for mutext locking { // Scope for mutext locking
std::lock_guard lochQTHURL(d->m_moduleQTHURLMutex); std::lock_guard lochQTHURL(d->m_moduleQTHURLMutex);
for (auto it = d->m_moduleQTH.begin(); it != d->m_moduleQTH.end(); ++it) { for (auto it = d->m_moduleQTH.begin(); it != d->m_moduleQTH.end(); ++it) {
@ -998,10 +998,10 @@ void IRCDDBApp::Entry()
} }
} }
if (d->wdTimer > 0) { if (d->m_wdTimer > 0) {
d->wdTimer--; d->m_wdTimer--;
if (0 == d->wdTimer) { if (0 == d->m_wdTimer) {
std::lock_guard lockModuleWD(d->m_moduleWDMutex); std::lock_guard lockModuleWD(d->m_moduleWDMutex);
for (auto it = d->m_moduleWD.begin(); it != d->m_moduleWD.end(); ++it) { for (auto it = d->m_moduleWD.begin(); it != d->m_moduleWD.end(); ++it) {
@ -1018,8 +1018,8 @@ void IRCDDBApp::Entry()
case 10: case 10:
// disconnect db // disconnect db
d->state = 0; d->m_state = 0;
d->timer = 0; d->m_timer = 0;
d->m_initReady = false; d->m_initReady = false;
break; break;
} }

@ -272,6 +272,7 @@ bool CIRCDDBClient::findUser(const std::string& userCallsign)
CLog::logDebug("CIRCDDBClient::findUser:userCall='%s' len != 8\n", userCallsign.c_str()); CLog::logDebug("CIRCDDBClient::findUser:userCall='%s' len != 8\n", userCallsign.c_str());
return false; return false;
} }
CLog::logTrace("IRC Find user %s", userCallsign.c_str());
std::string usr(userCallsign); std::string usr(userCallsign);
CUtils::ToUpper(usr); CUtils::ToUpper(usr);
return d->app->findUser(usr); return d->app->findUser(usr);
@ -398,6 +399,9 @@ bool CIRCDDBClient::receiveUser(std::string& userCallsign, std::string& repeater
gatewayCallsign = m->getParam(2); gatewayCallsign = m->getParam(2);
address = m->getParam(3); address = m->getParam(3);
timeStamp = m->getParam(4); timeStamp = m->getParam(4);
CLog::logTrace("IRC Receive User %s %s %s %s %s", userCallsign.c_str(), repeaterCallsign.c_str(), gatewayCallsign.c_str(), address.c_str(), timeStamp.c_str());
delete m; delete m;
return true; return true;
} }
@ -408,3 +412,7 @@ void CIRCDDBClient::close() // Implictely kills any threads in the IRC code
d->app -> stopWork(); d->app -> stopWork();
} }
void CIRCDDBClient::queryUsers()
{
}

@ -130,6 +130,8 @@ public:
void close(); // Implictely kills any threads in the IRC code void close(); // Implictely kills any threads in the IRC code
void queryUsers();
private: private:
struct CIRCDDBClientPrivate * const d; struct CIRCDDBClientPrivate * const d;
bool m_isQuadNet; bool m_isQuadNet;

@ -244,7 +244,7 @@ IRCDDB_RESPONSE_TYPE CIRCDDBMultiClient::getMessageType()
} }
} }
IRCDDB_RESPONSE_TYPE result = IDRT_NONE; IRCDDB_RESPONSE_TYPE result = IDRT_NONE;
m_responseQueueLock.lock(); m_responseQueueLock.lock();
if (m_responseQueue.size() != 0) result = m_responseQueue[0]->getType(); if (m_responseQueue.size() != 0) result = m_responseQueue[0]->getType();
@ -372,3 +372,7 @@ CIRCDDBMultiClientQuery_HashMap * CIRCDDBMultiClient::getQueriesHashMap(IRCDDB_R
} }
void CIRCDDBMultiClient::queryUsers()
{
}

@ -157,6 +157,7 @@ public:
virtual bool receiveUser(std::string & userCallsign, std::string & repeaterCallsign, std::string & gatewayCallsign, std::string & address, std::string & timeStamp); virtual bool receiveUser(std::string & userCallsign, std::string & repeaterCallsign, std::string & gatewayCallsign, std::string & address, std::string & timeStamp);
virtual void sendDStarGatewayInfo(const std::string subcommand, const std::vector<std::string> parms); virtual void sendDStarGatewayInfo(const std::string subcommand, const std::vector<std::string> parms);
virtual void close(); virtual void close();
virtual void queryUsers();
// //

Loading…
Cancel
Save

Powered by TurnKey Linux.