diff --git a/IRCApplication.h b/IRCApplication.h
index ee2194d..92b7018 100644
--- a/IRCApplication.h
+++ b/IRCApplication.h
@@ -1,54 +1,28 @@
-/*
-
-CIRCDDB - ircDDB client library in C++
-
-Copyright (C) 2010 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 .
-
-*/
-
-#if !defined(_IRCAPPLICATION_H)
-#define _IRCAPPLICATION_H
-
-#include
+#pragma once
+#include
#include "IRCMessageQueue.h"
class IRCApplication
{
public:
- virtual void userJoin (const wxString& nick, const wxString& name, const wxString& host) = 0;
- virtual void userLeave (const wxString& nick) = 0;
- virtual void userChanOp (const wxString& nick, bool op) = 0;
+ virtual void userJoin(const std::string& nick, const std::string& name, const std::string& host) = 0;
+ virtual void userLeave(const std::string& nick) = 0;
+ virtual void userChanOp(const std::string& nick, bool op) = 0;
virtual void userListReset(void) = 0;
- virtual void msgChannel (IRCMessage * m) = 0;
- virtual void msgQuery (IRCMessage * m) = 0;
+ virtual void msgChannel(IRCMessage * m) = 0;
+ virtual void msgQuery(IRCMessage * m) = 0;
- virtual void setCurrentNick(const wxString& nick) = 0;
- virtual void setTopic(const wxString& topic) = 0;
+ virtual void setCurrentNick(const std::string& nick) = 0;
+ virtual void setTopic(const std::string& topic) = 0;
- virtual void setBestServer(const wxString& ircUser) = 0;
+ virtual void setBestServer(const std::string& ircUser) = 0;
- virtual void setSendQ( IRCMessageQueue * s ) = 0;
- virtual IRCMessageQueue * getSendQ (void) = 0;
+ virtual void setSendQ(IRCMessageQueue *s) = 0;
+ virtual IRCMessageQueue *getSendQ(void) = 0;
virtual ~IRCApplication() {}
};
-
-
-#endif
diff --git a/IRCClient.cpp b/IRCClient.cpp
index 15013c3..14bff62 100644
--- a/IRCClient.cpp
+++ b/IRCClient.cpp
@@ -1,76 +1,34 @@
-/*
-
-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 .
-
-*/
-
-
-#if defined(WIN32)
-
-#define WIN32_LEAN_AND_MEAN
-
-#include
-#include
-
-#else
-
#include
#include
#include
-
-#endif
-
+#include
+#include
#include "IRCClient.h"
#include "IRCutils.h"
-#include
-
-
-
#include
#include
-
-
-
-
-
-IRCClient::IRCClient( IRCApplication * app, const wxString& update_channel,
- const wxString& hostName, unsigned int port, const wxString& callsign, const wxString& password,
- const wxString& versionInfo, const wxString& localAddr )
- : wxThread(wxTHREAD_JOINABLE)
+IRCClient::IRCClient(IRCApplication *app, const std::string &update_channel, const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password,
+ const std::string &versionInfo, const std::string &localAddr)
{
- safeStringCopy(host_name, hostName.mb_str(), sizeof host_name);
+ safeStringCopy(host_name, hostName.c_str(), sizeof host_name);
+
- this -> callsign = callsign.Lower();
- this -> port = port;
- this -> password = password;
+ this->callsign = callsign;
+ ToLower(this->callsign);
+ this->port = port;
+ this->password = password;
- this -> app = app;
+ this->app = app;
- if (localAddr.IsEmpty()) {
+ if (localAddr.empty())
safeStringCopy(local_addr, "0.0.0.0", sizeof local_addr);
- } else {
- safeStringCopy(local_addr, localAddr.mb_str(), sizeof local_addr);
- }
+ else
+ safeStringCopy(local_addr, localAddr.c_str(), sizeof local_addr);
- proto = new IRCProtocol ( app, this->callsign, password, update_channel, versionInfo );
+ proto = new IRCProtocol(app, this->callsign, password, update_channel, versionInfo);
recvQ = NULL;
sendQ = NULL;
@@ -86,34 +44,23 @@ IRCClient::~IRCClient()
bool IRCClient::startWork()
{
- if (Create() != wxTHREAD_NO_ERROR) {
- wxLogError(wxT("IRCClient::startWork: Could not create the worker thread!"));
- return false;
- }
-
terminateThread = false;
-
- if (Run() != wxTHREAD_NO_ERROR) {
- wxLogError(wxT("IRCClient::startWork: Could not run the worker thread!"));
- return false;
- }
-
+ client_thread = std::async(std::launch::async, &IRCClient::Entry, this);
return true;
}
void IRCClient::stopWork()
{
terminateThread = true;
-
- Wait();
+ client_thread.get();
}
-wxThread::ExitCode IRCClient::Entry ()
+#define MAXIPV4ADDR 10
+void IRCClient::Entry()
{
unsigned int numAddr;
-#define MAXIPV4ADDR 10
struct sockaddr_in addr[MAXIPV4ADDR];
struct sockaddr_in myaddr;
@@ -123,327 +70,264 @@ wxThread::ExitCode IRCClient::Entry ()
int sock = 0;
unsigned int currentAddr = 0;
- int result;
-
-
numAddr = 0;
- result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1);
+ int result = getAllIPV4Addresses(local_addr, 0, &numAddr, &myaddr, 1);
if ((result != 0) || (numAddr != 1)) {
- wxLogVerbose(wxT("IRCClient::Entry: local address not parseable, using 0.0.0.0"));
+ traceit("IRCClient::Entry: local address not parseable, using 0.0.0.0\n");
memset(&myaddr, 0x00, sizeof(struct sockaddr_in));
}
while (true) {
if (timer > 0) {
- timer --;
+ timer--;
}
switch (state) {
- case 0:
- if (terminateThread) {
- wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
- return 0;
- }
-
- if (timer == 0) {
- timer = 30;
-
- if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) {
- wxLogVerbose(wxT("IRCClient::Entry: number of DNS entries %d"), numAddr);
- if (numAddr > 0) {
- currentAddr = 0;
- state = 1;
- timer = 0;
- }
- }
- }
- break;
-
- case 1:
- if (terminateThread) {
- wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
- return 0;
- }
-
- if (timer == 0) {
- sock = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- if (sock < 0) {
- wxLogSysError(wxT("IRCClient::Entry: socket"));
- timer = 30;
- state = 0;
- } else {
-#if defined(__WINDOWS__)
- u_long nonBlock = 1UL;
- if (ioctlsocket( sock, FIONBIO, &nonBlock ) != 0) {
- wxLogSysError(wxT("IRCClient::Entry: ioctlsocket"));
- closesocket(sock);
- timer = 30;
- state = 0;
- }
-#else
- if (fcntl( sock, F_SETFL, O_NONBLOCK ) < 0) {
- wxLogSysError(wxT("IRCClient::Entry: fcntl"));
- close(sock);
- timer = 30;
- state = 0;
- }
-#endif
- else {
- unsigned char * h = (unsigned char *) &(myaddr.sin_addr);
- int res;
-
- if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0)) {
- wxLogVerbose(wxT("IRCClient::Entry: bind: local address %d.%d.%d.%d"),
- h[0], h[1], h[2], h[3]);
- }
-
- res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in));
-
- if (res != 0) {
-
- wxLogSysError(wxT("IRCClient::Entry: bind"));
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- state = 0;
- timer = 30;
- break;
- }
-
-
- h = (unsigned char *) &(addr[currentAddr].sin_addr);
- wxLogVerbose(wxT("IRCClient::Entry: trying to connect to %d.%d.%d.%d"),
- h[0], h[1], h[2], h[3]);
-
- res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in));
-
- if (res == 0) {
- wxLogVerbose(wxT("IRCClient::Entry: connected"));
- state = 4;
- } else {
-#if defined(__WINDOWS__)
- if (WSAGetLastError() == WSAEWOULDBLOCK)
-#else
- if (errno == EINPROGRESS)
-#endif
- {
- wxLogVerbose(wxT("IRCClient::Entry: connect in progress"));
- state = 3;
- timer = 10; // 5 second timeout
- } else {
- wxLogSysError(wxT("IRCClient::Entry: connect"));
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- currentAddr ++;
- if (currentAddr >= numAddr) {
- state = 0;
- timer = 30;
- } else {
- state = 1;
- timer = 4;
- }
- }
- }
- } // connect
- }
- }
- break;
-
- case 3: {
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- fd_set myset;
- FD_ZERO(&myset);
- FD_SET(sock, &myset);
- int res;
- res = select(sock+1, NULL, &myset, NULL, &tv);
-
- if (res < 0) {
- wxLogSysError(wxT("IRCClient::Entry: select"));
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- state = 0;
- timer = 30;
- } else if (res > 0) { // connect is finished
-#if defined(__WINDOWS__)
- int val_len;
-#else
- socklen_t val_len;
-#endif
- int value;
-
- val_len = sizeof value;
-
- if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) {
- wxLogSysError(wxT("IRCClient::Entry: getsockopt"));
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- state = 0;
- timer = 30;
- } else {
- if (value != 0) {
- wxLogWarning(wxT("IRCClient::Entry: SO_ERROR=%d"), value);
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- currentAddr ++;
- if (currentAddr >= numAddr) {
- state = 0;
- timer = 30;
- } else {
- state = 1;
- timer = 2;
- }
- } else {
- wxLogVerbose(wxT("IRCClient::Entry: connected2"));
- state = 4;
- }
- }
-
- } else if (timer == 0) {
- // select timeout and timer timeout
- wxLogVerbose(wxT("IRCClient::Entry: connect timeout"));
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
- currentAddr ++;
- if (currentAddr >= numAddr) {
- state = 0;
- timer = 30;
- } else {
- state = 1; // open new socket
- timer = 2;
- }
- }
-
- }
- break;
-
- case 4: {
- recvQ = new IRCMessageQueue();
- sendQ = new IRCMessageQueue();
-
- recv = new IRCReceiver(sock, recvQ);
- recv->startWork();
-
- proto->setNetworkReady(true);
- state = 5;
- timer = 0;
-
- }
- break;
-
-
- case 5:
- if (terminateThread) {
- state = 6;
- } else {
-
- if (recvQ -> isEOF()) {
- timer = 0;
- state = 6;
- } else if (proto -> processQueues(recvQ, sendQ) == false) {
- timer = 0;
- state = 6;
- }
-
- while ((state == 5) && sendQ->messageAvailable()) {
- IRCMessage * m = sendQ -> getMessage();
-
- wxString out;
-
- m -> composeMessage ( out );
-
- char buf[200];
- safeStringCopy(buf, out.mb_str(wxConvUTF8), sizeof buf);
- int len = strlen(buf);
-
- if (buf[len - 1] == 10) { // is there a NL char at the end?
- int r = send(sock, buf, len, 0);
-
- if (r != len) {
- wxLogVerbose(wxT("IRCClient::Entry: short write %d < %d"), r, len);
-
- timer = 0;
- state = 6;
- }
- /* else
- {
- wxLogVerbose(wxT("write %d bytes (") + out + wxT(")"), len );
- } */
- } else {
- wxLogVerbose(wxT("IRCClient::Entry: no NL at end, len=%d"), len);
-
- timer = 0;
- state = 6;
- }
-
- delete m;
- }
- }
- break;
-
- case 6: {
- if (app != NULL) {
- app->setSendQ(NULL);
- app->userListReset();
- }
-
- proto->setNetworkReady(false);
- recv->stopWork();
-
- wxThread::Sleep(2000);
-
- delete recv;
- delete recvQ;
- delete sendQ;
-
-#if defined(__WINDOWS__)
- closesocket(sock);
-#else
- close(sock);
-#endif
-
- if (terminateThread) { // request to end the thread
- wxLogVerbose(wxT("IRCClient::Entry: thread terminated at state=%d"), state);
- return 0;
- }
-
- timer = 30;
- state = 0; // reconnect to IRC server
- }
- break;
-
- }
-
- wxThread::Sleep(500);
+ case 0:
+ if (terminateThread) {
+ traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
+ return;
+ }
+
+ if (timer == 0) {
+ timer = 30;
+
+ if (getAllIPV4Addresses(host_name, port, &numAddr, addr, MAXIPV4ADDR) == 0) {
+ //traceit("IRCClient::Entry: number of DNS entries %d\n", numAddr);
+ if (numAddr > 0) {
+ currentAddr = 0;
+ state = 1;
+ timer = 0;
+ }
+ }
+ }
+ break;
+
+ case 1:
+ if (terminateThread) {
+ traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
+ return;
+ }
+
+ if (timer == 0) {
+ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if (sock < 0) {
+ traceit("IRCClient::Entry: could not create socket!\n");
+ timer = 30;
+ state = 0;
+ } else {
+ if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
+ traceit("IRCClient::Entry: fcntl error\n");
+ close(sock);
+ timer = 30;
+ state = 0;
+ }
+ else {
+ unsigned char *h = (unsigned char *) &(myaddr.sin_addr);
+ int res;
+
+ if ((h[0] != 0) || (h[1] != 0) || (h[2] != 0) || (h[3] != 0))
+ traceit("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
+
+ res = bind(sock, (struct sockaddr *) &myaddr, sizeof (struct sockaddr_in));
+
+ if (res != 0) {
+ traceit("IRCClient::Entry: bind error\n");
+ close(sock);
+ state = 0;
+ timer = 30;
+ break;
+ }
+
+
+ h = (unsigned char *) &(addr[currentAddr].sin_addr);
+ //traceit("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
+
+ res = connect(sock, (struct sockaddr *) (addr + currentAddr), sizeof (struct sockaddr_in));
+
+ if (res == 0) {
+ traceit("IRCClient::Entry: connected to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
+ state = 4;
+ } else {
+ if (errno == EINPROGRESS) {
+ //traceit("IRCClient::Entry: connect in progress\n");
+ state = 3;
+ timer = 10; // 5 second timeout
+ } else {
+ traceit("IRCClient::Entry: connect\n");
+ close(sock);
+ currentAddr++;
+ if (currentAddr >= numAddr) {
+ state = 0;
+ timer = 30;
+ } else {
+ state = 1;
+ timer = 4;
+ }
+ }
+ }
+ } // connect
+ }
+ }
+ break;
+
+ case 3: {
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ fd_set myset;
+ FD_ZERO(&myset);
+ FD_SET(sock, &myset);
+ int res = select(sock+1, NULL, &myset, NULL, &tv);
+
+ if (res < 0) {
+ traceit("IRCClient::Entry: select\n");
+ close(sock);
+ state = 0;
+ timer = 30;
+ } else if (res > 0) { // connect is finished
+ socklen_t val_len;
+ int value;
+
+ val_len = sizeof value;
+
+ if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) {
+ traceit("IRCClient::Entry: getsockopt error\n");
+ close(sock);
+ state = 0;
+ timer = 30;
+ } else {
+ if (value != 0) {
+ traceit("IRCClient::Entry: SO_ERROR=%d\n", value);
+ close(sock);
+ currentAddr ++;
+ if (currentAddr >= numAddr) {
+ state = 0;
+ timer = 30;
+ } else {
+ state = 1;
+ timer = 2;
+ }
+ } else {
+ traceit("IRCClient::Entry: connected2\n");
+ state = 4;
+ }
+ }
+
+ } else if (timer == 0) {
+ // select timeout and timer timeout
+ //traceit("IRCClient::Entry: connect timeout\n");
+ close(sock);
+ currentAddr++;
+ if (currentAddr >= numAddr) {
+ state = 0;
+ timer = 30;
+ } else {
+ state = 1; // open new socket
+ timer = 2;
+ }
+ }
+
+ }
+ break;
+
+ case 4: {
+ recvQ = new IRCMessageQueue();
+ sendQ = new IRCMessageQueue();
+
+ recv = new IRCReceiver(sock, recvQ);
+ recv->startWork();
+
+ proto->setNetworkReady(true);
+ state = 5;
+ timer = 0;
+
+ }
+ break;
+
+
+ case 5:
+ if (terminateThread) {
+ state = 6;
+ } else {
+
+ if (recvQ->isEOF()) {
+ timer = 0;
+ state = 6;
+ } else if (proto->processQueues(recvQ, sendQ) == false) {
+ timer = 0;
+ state = 6;
+ }
+
+ while ((state == 5) && sendQ->messageAvailable()) {
+ IRCMessage * m = sendQ->getMessage();
+
+ std::string out;
+
+ m->composeMessage(out);
+
+ char buf[200];
+ safeStringCopy(buf, out.c_str(), sizeof buf);
+ int len = strlen(buf);
+
+ if (buf[len - 1] == 10) { // is there a NL char at the end?
+ int r = send(sock, buf, len, 0);
+
+ if (r != len) {
+ traceit("IRCClient::Entry: short write %d < %d\n", r, len);
+
+ timer = 0;
+ state = 6;
+ }
+ /* else
+ {
+ traceit("write %d bytes (%s)\n", len, out.c_str());
+ } */
+ } else {
+ traceit("IRCClient::Entry: no NL at end, len=%d\n", len);
+
+ timer = 0;
+ state = 6;
+ }
+
+ delete m;
+ }
+ }
+ break;
+
+ case 6: {
+ if (app != NULL) {
+ app->setSendQ(NULL);
+ app->userListReset();
+ }
+
+ proto->setNetworkReady(false);
+ recv->stopWork();
+
+ sleep(2);
+
+ delete recv;
+ delete recvQ;
+ delete sendQ;
+
+ close(sock);
+
+ if (terminateThread) { // request to end the thread
+ traceit("IRCClient::Entry: thread terminated at state=%d\n", state);
+ return;
+ }
+
+ timer = 30;
+ state = 0; // reconnect to IRC server
+ }
+ break;
+ } // switch
+ usleep(500000);
}
-
- return 0;
+ return;
}
-
-
-
-
-
diff --git a/IRCClient.h b/IRCClient.h
index 0738404..f79f711 100644
--- a/IRCClient.h
+++ b/IRCClient.h
@@ -1,76 +1,39 @@
-/*
+#pragma once
-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 .
-
-*/
-
-
-#if !defined(_IRCCLIENT_H)
-#define _IRCCLIENT_H
+#include
#include "IRCReceiver.h"
#include "IRCMessageQueue.h"
#include "IRCProtocol.h"
#include "IRCApplication.h"
-#include
-
-
-class IRCClient : public wxThread
+class IRCClient
{
public:
+ IRCClient(IRCApplication *app, const std::string &update_channel, const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password,
+ const std::string &versionInfo, const std::string &localAddr);
- IRCClient( IRCApplication * app, const wxString& update_channel,
- const wxString& hostName, unsigned int port, const wxString& callsign, const wxString& password,
- const wxString& versionInfo, const wxString& localAddr );
-
- ~IRCClient();
-
-
+ virtual ~IRCClient();
bool startWork();
-
void stopWork();
-
protected:
-
- virtual wxThread::ExitCode Entry();
-
-
+ virtual void Entry();
private:
-
char host_name[100];
char local_addr[100];
unsigned int port;
- wxString callsign;
- wxString password;
+ std::string callsign;
+ std::string password;
bool terminateThread;
- IRCReceiver * recv;
- IRCMessageQueue * recvQ;
- IRCMessageQueue * sendQ;
- IRCProtocol * proto;
-
- IRCApplication * app;
+ IRCReceiver *recv;
+ IRCMessageQueue *recvQ;
+ IRCMessageQueue *sendQ;
+ IRCProtocol *proto;
+ std::future client_thread;
+ IRCApplication *app;
};
-
-
-#endif
diff --git a/IRCDDB.cpp b/IRCDDB.cpp
index 761547c..f208ecb 100644
--- a/IRCDDB.cpp
+++ b/IRCDDB.cpp
@@ -1,50 +1,24 @@
-/*
-
-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 .
-
-*/
-
-
#include "IRCDDB.h"
#include "IRCClient.h"
#include "IRCDDBApp.h"
-
-#include
-
+#include "IRCutils.h"
struct CIRCDDBPrivate {
- IRCClient * client;
- IRCDDBApp * app;
+ IRCClient *client;
+ IRCDDBApp *app;
};
-CIRCDDB::CIRCDDB(const wxString& hostName, unsigned int port,
- const wxString& callsign, const wxString& password,
- const wxString& versionInfo, const wxString& localAddr ) : d( new CIRCDDBPrivate )
+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)
+ : d(new CIRCDDBPrivate)
{
- wxString update_channel = wxT("#dstar");
+ std::string update_channel = "#dstar";
d->app = new IRCDDBApp(update_channel);
- d->client = new IRCClient( d->app, update_channel, hostName, port, callsign,
- password, versionInfo, localAddr );
+ d->client = new IRCClient(d->app, update_channel, hostName, port, callsign, password, versionInfo, localAddr);
}
CIRCDDB::~CIRCDDB()
@@ -58,8 +32,8 @@ CIRCDDB::~CIRCDDB()
// A false return implies a network error, or unable to log in
bool CIRCDDB::open()
{
- wxLogVerbose(wxT("start"));
- return d->client -> startWork() && d->app->startWork();
+ traceit("start");
+ 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);
}
-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);
}
-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
-bool CIRCDDB::sendHeard( const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- const wxString& rpt2, unsigned char flag1,
- unsigned char flag2, unsigned char flag3 )
+bool CIRCDDB::sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1,
+ const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3)
{
- if (myCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
+ if (myCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
- if (myCallExt.Len() != 4) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
+ if (myCallExt.size() != 4) {
+ traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
- if (yourCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
+ if (yourCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
- if (rpt1.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
+ if (rpt1.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
- if (rpt2.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
+ if (rpt2.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt2: len != 8");
return false;
}
- return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3,
- wxT(" "), wxT(""), wxT(""));
+ return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, " ", "", "");
}
-
// Send heard data, a false return implies a network error
-bool CIRCDDB::sendHeardWithTXMsg( const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- const wxString& rpt2, unsigned char flag1,
- unsigned char flag2, unsigned char flag3,
- const wxString& network_destination,
- const wxString& tx_message )
+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,
+ unsigned char flag2, unsigned char flag3, const std::string &network_destination, const std::string &tx_message)
{
- if (myCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
+ if (myCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
- if (myCallExt.Len() != 4) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
+ if (myCallExt.size() != 4) {
+ traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
- if (yourCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
+ if (yourCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
- if (rpt1.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
+ if (rpt1.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
- if (rpt2.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
+ if (rpt2.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt2: len != 8");
return false;
}
- wxString dest = network_destination;
+ std::string dest = network_destination;
- if (dest.Len() == 0) {
- dest = wxT(" ");
- }
+ if (dest.size() == 0)
+ dest = " ";
- if (dest.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:network_destination: len != 8"));
+ if (dest.size() != 8) {
+ traceit("CIRCDDB::sendHeard:network_destination: len != 8");
return false;
}
- wxString msg;
+ std::string msg;
- if (tx_message.Len() == 20) {
- unsigned int i;
- for (i=0; i < tx_message.Len(); i++) {
- wxChar ch = tx_message.GetChar(i);
+ if (tx_message.length() == 20) {
+ for (unsigned int i=0; i < tx_message.size(); i++) {
+ char ch = tx_message.at(i);
- if ((ch > 32) && (ch < 127)) {
- msg.Append(ch);
+ if (ch>32 && ch<127) {
+ msg.push_back(ch);
} else {
- msg.Append(wxT('_'));
+ msg.push_back('_');
}
}
}
- return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3,
- dest, msg, wxT(""));
+ return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, dest, msg, "");
}
-bool CIRCDDB::sendHeardWithTXStats( const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- 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 )
+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,
+ 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)) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535"));
+ if (num_dv_frames<= 0 || num_dv_frames>65535) {
+ traceit("CIRCDDB::sendHeard:num_dv_frames not in range 1-65535");
return false;
}
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;
}
- 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)"));
+ if (num_bit_errors > 4*num_dv_frames) { // max 4 bit errors per frame
+ traceit("CIRCDDB::sendHeard:num_bit_errors > (4*num_dv_frames)");
return false;
}
- if (myCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCall: len != 8"));
+ if (myCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:myCall: len != 8");
return false;
}
- if (myCallExt.Len() != 4) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:myCallExt: len != 4"));
+ if (myCallExt.size() != 4) {
+ traceit("CIRCDDB::sendHeard:myCallExt: len != 4");
return false;
}
- if (yourCall.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:yourCall: len != 8"));
+ if (yourCall.size() != 8) {
+ traceit("CIRCDDB::sendHeard:yourCall: len != 8");
return false;
}
- if (rpt1.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt1: len != 8"));
+ if (rpt1.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt1: len != 8");
return false;
}
- if (rpt2.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::sendHeard:rpt2: len != 8"));
+ if (rpt2.size() != 8) {
+ traceit("CIRCDDB::sendHeard:rpt2: len != 8");
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) {
- wxString s = wxString::Format(wxT("%02x"), (num_dv_silent_frames * 100) / num_dv_frames);
- stats.Append(s);
+ snprintf(buf, 16, "%02x", num_dv_silent_frames * 100 / num_dv_frames);
+ stats.append(buf);
if (num_bit_errors >= 0) {
- s = wxString::Format(wxT("%02x"), (num_bit_errors * 125) / (num_dv_frames * 3));
- stats.Append(s);
+ snprintf(buf,16, "%02x", num_bit_errors * 125 / (num_dv_frames * 3));
+ stats.append(buf);
} else {
- stats.Append(wxT("__"));
+ stats.append("__");
}
} 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,
- wxT(" "), wxT(""), stats);
+ return d->app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, " ", "", stats);
}
// 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) {
- wxLogVerbose(wxT("CIRCDDB::findGateway: len != 8"));
+ if (gatewayCallsign.size() != 8) {
+ traceit("CIRCDDB::findGateway: len != 8");
return false;
}
-
- return d->app->findGateway( gatewayCallsign.Upper());
+ std::string gcs = gatewayCallsign;
+ ToUpper(gcs);
+ return d->app->findGateway(gcs);
}
-bool CIRCDDB::findRepeater(const wxString& repeaterCallsign)
+bool CIRCDDB::findRepeater(const std::string &repeaterCallsign)
{
- if (repeaterCallsign.Len() != 8) {
- wxLogVerbose(wxT("CIRCDDB::findRepeater: len != 8"));
+ if (repeaterCallsign.size() != 8) {
+ traceit("CIRCDDB::findRepeater: len != 8");
return false;
}
-
- return d->app->findRepeater( repeaterCallsign.Upper());
+ std::string rcs = repeaterCallsign;
+ ToUpper(rcs);
+ return d->app->findRepeater(rcs);
}
// 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) {
- wxLogVerbose(wxT("CIRCDDB::findUser: len != 8"));
+ if (userCallsign.size() != 8) {
+ traceit("CIRCDDB::findUser: len != 8");
return false;
}
-
- return d->app->findUser( userCallsign.Upper());
+ std::string ucs = userCallsign;
+ ToUpper(ucs);
+ return d->app->findUser(ucs);
}
// 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()
// 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();
if (rt != IDRT_REPEATER) {
- wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected response type"));
+ traceit("CIRCDDB::receiveRepeater: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
- wxLogError(wxT("CIRCDDB::receiveRepeater: no message"));
+ traceit("CIRCDDB::receiveRepeater: no message");
return false;
}
- if (!m->getCommand().IsSameAs(wxT("IDRT_REPEATER"))) {
- wxLogError(wxT("CIRCDDB::receiveRepeater: wrong message type"));
+ if (m->getCommand().compare("IDRT_REPEATER")) {
+ traceit("CIRCDDB::receiveRepeater: wrong message type");
return false;
}
if (m->getParamCount() != 3) {
- wxLogError(wxT("CIRCDDB::receiveRepeater: unexpected number of message parameters"));
+ traceit("CIRCDDB::receiveRepeater: unexpected number of message parameters");
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()
// 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();
if (rt != IDRT_GATEWAY) {
- wxLogError(wxT("CIRCDDB::receiveGateway: unexpected response type"));
+ traceit("CIRCDDB::receiveGateway: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
- wxLogError(wxT("CIRCDDB::receiveGateway: no message"));
+ traceit("CIRCDDB::receiveGateway: no message");
return false;
}
- if (!m->getCommand().IsSameAs(wxT("IDRT_GATEWAY"))) {
- wxLogError(wxT("CIRCDDB::receiveGateway: wrong message type"));
+ if (m->getCommand().compare("IDRT_GATEWAY")) {
+ traceit("CIRCDDB::receiveGateway: wrong message type");
return false;
}
if (m->getParamCount() != 2) {
- wxLogError(wxT("CIRCDDB::receiveGateway: unexpected number of message parameters"));
+ traceit("CIRCDDB::receiveGateway: unexpected number of message parameters");
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()
// 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);
}
-bool CIRCDDB::receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address,
- wxString& timeStamp)
+bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address,
+ std::string &timeStamp)
{
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_USER) {
- wxLogError(wxT("CIRCDDB::receiveUser: unexpected response type"));
+ traceit("CIRCDDB::receiveUser: unexpected response type");
return false;
}
IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) {
- wxLogError(wxT("CIRCDDB::receiveUser: no message"));
+ traceit("CIRCDDB::receiveUser: no message");
return false;
}
- if (!m->getCommand().IsSameAs(wxT("IDRT_USER"))) {
- wxLogError(wxT("CIRCDDB::receiveUser: wrong message type"));
+ if (m->getCommand().compare("IDRT_USER")) {
+ traceit("CIRCDDB::receiveUser: wrong message type");
return false;
}
if (m->getParamCount() != 5) {
- wxLogError(wxT("CIRCDDB::receiveUser: unexpected number of message parameters"));
+ traceit("CIRCDDB::receiveUser: unexpected number of message parameters");
return false;
}
@@ -423,7 +383,7 @@ bool CIRCDDB::receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wx
void CIRCDDB::close() // Implictely kills any threads in the IRC code
{
- d->client -> stopWork();
- d->app -> stopWork();
+ d->client->stopWork();
+ d->app->stopWork();
}
diff --git a/IRCDDB.h b/IRCDDB.h
index 7e1a91f..af2691b 100644
--- a/IRCDDB.h
+++ b/IRCDDB.h
@@ -1,29 +1,6 @@
-/*
+#pragma once
-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 .
-
-*/
-
-
-#if !defined(_IRCDDB_H)
-#define _IRCDDB_H
-
-#include
+#include
enum IRCDDB_RESPONSE_TYPE {
IDRT_NONE,
@@ -44,8 +21,7 @@ struct CIRCDDBPrivate;
class CIRCDDB
{
public:
- CIRCDDB(const wxString& hostName, unsigned int port, const wxString& callsign, const wxString& password,
- const wxString& versionInfo, const wxString& localAddr = wxEmptyString );
+ CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo, const std::string &localAddr = "");
~CIRCDDB();
// A false return implies a network error, or unable to log in
@@ -58,7 +34,7 @@ public:
// longitude WGS84 position of antenna in degrees, positive value -> EAST
// desc1, desc2 20-character description of QTH
- void rptrQTH(const wxString& rptrcall, double latitude, double longitude, const wxString& desc1, const wxString& desc2, const wxString& infoURL, const wxString &swVersion);
+ void 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);
@@ -69,7 +45,7 @@ public:
// range range of the repeater in meters (meters = miles * 1609.344)
// agl height of the antenna above ground in meters (meters = feet * 0.3048)
- void rptrQRG(const wxString& rptrcall, double txFrequency, double duplexShift, double range, double agl);
+ void rptrQRG(const std::string &rptrcall, double txFrequency, double duplexShift, double range, double agl);
// If you call this method once, watchdog messages will be sent to the
@@ -80,7 +56,7 @@ public:
// version of the RF decoding software. For example, the ircDDB java software sets this
// to "rpm_ircddbmhd-x.z-z". The string wdInfo must contain at least one non-space character.
- void kickWatchdog(const wxString& wdInfo);
+ void kickWatchdog(const std::string &wdInfo);
@@ -94,10 +70,7 @@ public:
// 10 = some network error occured, next state is "0" (new connection attempt)
// Send heard data, a false return implies a network error
- bool sendHeard(const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- const wxString& rpt2, unsigned char flag1,
- unsigned char flag2, unsigned char flag3 );
+ bool sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3);
// same as sendHeard with two new fields:
@@ -105,12 +78,8 @@ public:
// or reflector, where this transmission is relayed to.
// tx_message: 20-char TX message or empty string, if the user did not
// send a TX message
- bool sendHeardWithTXMsg(const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- const wxString& rpt2, unsigned char flag1,
- unsigned char flag2, unsigned char flag3,
- const wxString& network_destination,
- const wxString& tx_message );
+ bool sendHeardWithTXMsg(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1,
+ unsigned char flag2, unsigned char flag3, const std::string &network_destination, const std::string &tx_message);
// this method should be called at the end of a transmission
// num_dv_frames: number of DV frames sent out (96 bit frames, 20ms)
@@ -122,24 +91,19 @@ public:
// So, the overall bit error rate is calculated like this:
// BER = num_bit_errors / (num_dv_frames * 24)
// Set num_bit_errors = -1, if the error information is not available.
- bool sendHeardWithTXStats(const wxString& myCall, const wxString& myCallExt,
- const wxString& yourCall, const wxString& rpt1,
- 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 );
+ bool sendHeardWithTXStats(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1,
+ unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors);
// The following three functions don't block waiting for a reply, they just send the data
// Send query for a gateway/reflector, a false return implies a network error
- bool findGateway(const wxString& gatewayCallsign);
+ bool findGateway(const std::string &gatewayCallsign);
// Send query for a repeater module, a false return implies a network error
- bool findRepeater(const wxString& repeaterCallsign);
+ bool findRepeater(const std::string &repeaterCallsign);
// Send query for a user, a false return implies a network error
- bool findUser(const wxString& userCallsign);
+ bool findUser(const std::string &userCallsign);
// The following functions are for processing received messages
@@ -148,18 +112,17 @@ public:
// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType()
// A false return implies a network error
- bool receiveRepeater(wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& protocol);
+ bool receiveRepeater(std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL& protocol);
// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType()
// A false return implies a network error
- bool receiveGateway(wxString& gatewayCallsign, wxString& address, DSTAR_PROTOCOL& protocol);
+ bool receiveGateway(std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL &protocol);
// Get a user message, as a result of IDRT_USER returned from getMessageType()
// A false return implies a network error
- bool receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address);
+ bool receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address);
- bool receiveUser(wxString& userCallsign, wxString& repeaterCallsign, wxString& gatewayCallsign, wxString& address,
- wxString& timeStamp );
+ bool receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, std::string &timeStamp);
void close(); // Implictely kills any threads in the IRC code
@@ -168,6 +131,3 @@ private:
struct CIRCDDBPrivate * const d;
};
-
-#endif // _IRCDDB_H
-
diff --git a/IRCDDBApp.cpp b/IRCDDBApp.cpp
index 2793f25..30b6b41 100644
--- a/IRCDDBApp.cpp
+++ b/IRCDDBApp.cpp
@@ -1,174 +1,113 @@
-/*
-
-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 .
-
-*/
-
-#if defined(WIN32)
-
-#define WIN32_LEAN_AND_MEAN
-
-#include
-#include
-
-#else
-
#include
#include
#include
-
-#endif
-
+#include
+#include
+#include