diff --git a/Common/DDHandler.cpp b/Common/DDHandler.cpp index faa9a40..604babe 100644 --- a/Common/DDHandler.cpp +++ b/Common/DDHandler.cpp @@ -26,8 +26,10 @@ #include #include #include +#if defined(__linux__) #include #include +#endif #include #endif diff --git a/Common/DStarDefines.h b/Common/DStarDefines.h index b0c3972..5899b0f 100644 --- a/Common/DStarDefines.h +++ b/Common/DStarDefines.h @@ -15,6 +15,7 @@ #define DStarDefines_H #include +#include "../GlobalDefines.h" const unsigned int DSTAR_GMSK_SYMBOL_RATE = 4800U; const float DSTAR_GMSK_BT = 0.5F; diff --git a/Common/Defs.h b/Common/Defs.h index f2c5c31..ca9d950 100644 --- a/Common/Defs.h +++ b/Common/Defs.h @@ -20,6 +20,7 @@ #define Defs_H #include +#include "../GlobalDefines.h" const wxString DEXTRA_HOSTS_FILE_NAME = wxT("DExtra_Hosts.txt"); const wxString DPLUS_HOSTS_FILE_NAME = wxT("DPlus_Hosts.txt"); diff --git a/Common/Logger.cpp b/Common/Logger.cpp index 6aa789b..3747b1b 100644 --- a/Common/Logger.cpp +++ b/Common/Logger.cpp @@ -18,6 +18,12 @@ #include "Logger.h" +#if defined(LOG_LOCALTIME) && LOG_LOCALTIME == 1 +static const bool utc = false; +#else +static const bool utc = true; +#endif + CLogger::CLogger(const wxString& directory, const wxString& name) : wxLog(), m_name(name), @@ -32,7 +38,12 @@ m_day(0) time_t timestamp; ::time(×tamp); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } wxString text; text.Printf(wxT("%s-%04d-%02d-%02d"), m_name.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); @@ -74,7 +85,12 @@ void CLogger::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogReco default: letter = wxT("U"); break; } - struct tm* tm = ::gmtime(&info.timestamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(&info.timestamp); + }else{ + tm = ::localtime(&info.timestamp); + } wxString message; message.Printf(wxT("%s: %04d-%02d-%02d %02d:%02d:%02d: %s\n"), letter.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msg.c_str()); @@ -91,7 +107,12 @@ void CLogger::writeLog(const wxChar* msg, time_t timestamp) wxASSERT(m_file->IsOpened()); wxASSERT(msg != NULL); - struct tm* tm = ::gmtime(×tamp); + struct tm* tm; + if (utc){ + tm = ::gmtime(×tamp); + }else{ + tm = ::localtime(×tamp); + } int day = tm->tm_yday; if (day != m_day) { @@ -112,5 +133,4 @@ void CLogger::writeLog(const wxChar* msg, time_t timestamp) m_file->Write(wxString(msg)); m_file->Flush(); -} - +} \ No newline at end of file diff --git a/Common/XLXHostsFileDownloader.cpp b/Common/XLXHostsFileDownloader.cpp index 869ddd0..09c6be8 100644 --- a/Common/XLXHostsFileDownloader.cpp +++ b/Common/XLXHostsFileDownloader.cpp @@ -31,6 +31,7 @@ wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL) wxLogMessage(_T("Downloading XLX reflector list from %s"), xlxHostsFileURL.c_str()); wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_")); + wxLogMessage(_T("Downloading XLX host file...")); wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL; bool execResult = wxShell(commandLine); diff --git a/GlobalDefines.h b/GlobalDefines.h new file mode 100644 index 0000000..e17c85a --- /dev/null +++ b/GlobalDefines.h @@ -0,0 +1,30 @@ +#ifndef __GLOBAL_DEFS__ +#define __GLOBAL_DEFS__ + +#if defined(__APPLE__) || defined(LINUX) +#define DATA_DIR "/opt/mmdvm/conf/dstar" +#define LOG_DIR "/opt/mmdvm/logs" +#define CONF_DIR "/opt/mmdvm/conf" +#define CONF_FILE "ircDDBGateway.ini" +#define PID_FILE "/tmp/ircDDBGateway.pid" +#define PID_FILE_T "/tmp/ircDDBGateway_%s.pid" + +#elif defined(OPENWRT) && OPENWRT == 1 +#define DATA_DIR "/etc/mmdvm/dstar" +#define LOG_DIR "/var/log/mmdvm" +#define CONF_DIR "/etc" +#define CONF_FILE "ircDDBGateway.ini" +#define PID_FILE "/tmp/ircDDBGateway.pid" +#define PID_FILE_T "/tmp/ircDDBGateway_%s.pid" + +#else +#define DATA_DIR "/usr/share/ircddbgateway" +#define LOG_DIR "/tmp" +#define CONF_DIR "/etc" +#define CONF_FILE "ircddbgateway" +#define PID_FILE "/var/run/ircddbgateway.pid" +#define PID_FILE_T "/var/run/ircddbgateway_%s.pid" + +#endif + +#endif diff --git a/Makefile.linux b/Makefile.linux new file mode 100644 index 0000000..e6be2ea --- /dev/null +++ b/Makefile.linux @@ -0,0 +1,70 @@ +export CXX ?= $(shell wx-config --cxx) +export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 -DLINUX=1 +export GUILIBS ?= $(shell wx-config --libs adv,core,base) +export LIBS ?= $(shell wx-config --libs base) +export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + diff --git a/Makefile.openwrt b/Makefile.openwrt new file mode 100644 index 0000000..8e07cf3 --- /dev/null +++ b/Makefile.openwrt @@ -0,0 +1,70 @@ +# export CXX ?= $(shell wx-config --cxx) +# export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) +# export GUILIBS ?= $(shell wx-config --libs adv,core,base) +# export LIBS ?= $(shell wx-config --libs base) +# export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + diff --git a/Makefile.osx b/Makefile.osx new file mode 100644 index 0000000..66755cd --- /dev/null +++ b/Makefile.osx @@ -0,0 +1,70 @@ +export CXX ?= $(shell wx-config --cxx) +export CFLAGS ?= -O2 -Wall $(shell wx-config --cxxflags) -DLOG_LOCALTIME=1 +export GUILIBS ?= $(shell wx-config --libs adv,core,base) +export LIBS ?= $(shell wx-config --libs base) +export LDFLAGS ?= + +all: ircDDBGateway/ircddbgatewayd ircDDBGatewayConfig/ircddbgatewayconfig + +ircDDBGateway/ircddbgatewayd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C ircDDBGateway + +ircDDBGatewayConfig/ircddbgatewayconfig: GUICommon/GUICommon.a Common/Common.a + $(MAKE) -C ircDDBGatewayConfig + +APRSTransmit/aprstransmitd: Common/Common.a + $(MAKE) -C APRSTransmit + +RemoteControl/remotecontrold: Common/Common.a + $(MAKE) -C RemoteControl + +StarNetServer/starnetserverd: Common/Common.a ircDDB/IRCDDB.a + $(MAKE) -C StarNetServer + +TextTransmit/texttransmitd: Common/Common.a + $(MAKE) -C TextTransmit + +TimerControl/timercontrold: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimerControl + +TimeServer/timeserverd: Common/Common.a GUICommon/GUICommon.a + $(MAKE) -C TimeServer + +VoiceTransmit/voicetransmitd: Common/Common.a + $(MAKE) -C VoiceTransmit + +GUICommon/GUICommon.a: + $(MAKE) -C GUICommon + +Common/Common.a: + $(MAKE) -C Common + +ircDDB/IRCDDB.a: + $(MAKE) -C ircDDB + +install: all + $(MAKE) -C Data install + $(MAKE) -C APRSTransmit install + $(MAKE) -C ircDDBGateway install + $(MAKE) -C RemoteControl install + $(MAKE) -C StarNetServer install + $(MAKE) -C TextTransmit install + $(MAKE) -C TimerControl install + $(MAKE) -C TimeServer install + $(MAKE) -C VoiceTransmit install + $(MAKE) -C ircDDBGatewayConfig install + +clean: + $(MAKE) -C Common clean + $(MAKE) -C ircDDB clean + $(MAKE) -C GUICommon clean + $(MAKE) -C APRSTransmit clean + $(MAKE) -C ircDDBGateway clean + $(MAKE) -C RemoteControl clean + $(MAKE) -C StarNetServer clean + $(MAKE) -C TextTransmit clean + $(MAKE) -C TimerControl clean + $(MAKE) -C TimeServer clean + $(MAKE) -C VoiceTransmit clean + $(MAKE) -C ircDDBGatewayConfig clean + diff --git a/ircDDBGateway/IRCDDBGatewayAppD.cpp b/ircDDBGateway/IRCDDBGatewayAppD.cpp index 4ea6d25..5dcaa61 100644 --- a/ircDDBGateway/IRCDDBGatewayAppD.cpp +++ b/ircDDBGateway/IRCDDBGatewayAppD.cpp @@ -42,6 +42,8 @@ #include #include +#include "../GlobalDefines.h" + const wxChar* NAME_PARAM = wxT("Gateway Name"); const wxChar* NOLOGGING_SWITCH = wxT("nolog"); const wxChar* DEBUG_SWITCH = wxT("debug"); @@ -122,9 +124,9 @@ int main(int argc, char** argv) wxString pidFileName; if (!name.IsEmpty()) - pidFileName.Printf(wxT("/var/run/opendv/ircddbgateway_%s.pid"), name.c_str()); + pidFileName.Printf(wxT(PID_FILE_T), name.c_str()); else - pidFileName = wxT("/var/run/opendv/ircddbgateway.pid"); + pidFileName = wxT(PID_FILE); pidFileName.Replace(wxT(" "), wxT("_")); char fileName[128U]; @@ -198,6 +200,7 @@ bool CIRCDDBGatewayAppD::init() new wxLogNull; } +#if !defined(OPENWRT) || OPENWRT != 1 wxString appName; if (!m_name.IsEmpty()) appName = APPLICATION_NAME + wxT(" ") + m_name; @@ -211,6 +214,7 @@ bool CIRCDDBGatewayAppD::init() wxLogError(wxT("Another copy of the ircDDB Gateway is running, exiting")); return false; } +#endif wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" daemon - ") + VERSION); diff --git a/ircDDBGateway/IRCDDBGatewayDefs.h b/ircDDBGateway/IRCDDBGatewayDefs.h index 9eac8a0..7806c3b 100644 --- a/ircDDBGateway/IRCDDBGatewayDefs.h +++ b/ircDDBGateway/IRCDDBGatewayDefs.h @@ -20,10 +20,11 @@ #define IRCDDBGatewayDefs_H #include +#include "../GlobalDefines.h" const wxString APPLICATION_NAME = wxT("ircDDB Gateway"); -const wxString CONFIG_FILE_NAME = wxT("ircddbgateway"); +const wxString CONFIG_FILE_NAME = wxT(CONF_FILE); const wxString STATUS1_FILE_NAME = wxT("status1.txt"); const wxString STATUS2_FILE_NAME = wxT("status2.txt"); diff --git a/ircDDBGateway/IRCDDBGatewayThread.cpp b/ircDDBGateway/IRCDDBGatewayThread.cpp index 37b8b59..301bc4e 100644 --- a/ircDDBGateway/IRCDDBGatewayThread.cpp +++ b/ircDDBGateway/IRCDDBGatewayThread.cpp @@ -693,19 +693,19 @@ void CIRCDDBGatewayThread::processIrcDDB() case 0: case 10: if (m_lastStatus != IS_DISCONNECTED) { - wxLogInfo(wxT("Disconnected from ircDDB")); + wxLogMessage(wxT("Disconnected from ircDDB")); m_lastStatus = IS_DISCONNECTED; } break; case 7: if (m_lastStatus != IS_CONNECTED) { - wxLogInfo(wxT("Connected to ircDDB")); + wxLogMessage(wxT("Connected to ircDDB")); m_lastStatus = IS_CONNECTED; } break; default: if (m_lastStatus != IS_CONNECTING) { - wxLogInfo(wxT("Connecting to ircDDB")); + wxLogMessage(wxT("Connecting to ircDDB")); m_lastStatus = IS_CONNECTING; } break; @@ -726,13 +726,13 @@ void CIRCDDBGatewayThread::processIrcDDB() break; if (!address.IsEmpty()) { - wxLogMessage(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("USER: %s %s %s %s"), user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false); #if defined(ENABLE_NAT_TRAVERSAL) m_natTraversal->traverseNatG2(address); #endif } else { - wxLogMessage(wxT("USER: %s NOT FOUND"), user.c_str()); + wxLogInfo(wxT("USER: %s NOT FOUND"), user.c_str()); } } break; @@ -745,7 +745,7 @@ void CIRCDDBGatewayThread::processIrcDDB() CRepeaterHandler::resolveRepeater(repeater, gateway, address, DP_DEXTRA); if (!address.IsEmpty()) { - wxLogMessage(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("REPEATER: %s %s %s"), repeater.c_str(), gateway.c_str(), address.c_str()); m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false); #if defined(ENABLE_NAT_TRAVERSAL) m_natTraversal->traverseNatG2(address); @@ -765,7 +765,7 @@ void CIRCDDBGatewayThread::processIrcDDB() CDExtraHandler::gatewayUpdate(gateway, address); CDPlusHandler::gatewayUpdate(gateway, address); if (!address.IsEmpty()) { - wxLogMessage(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str()); + wxLogInfo(wxT("GATEWAY: %s %s"), gateway.c_str(), address.c_str()); m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false); #if defined(ENABLE_NAT_TRAVERSAL) m_natTraversal->traverseNatG2(address); @@ -812,7 +812,7 @@ void CIRCDDBGatewayThread::processRepeater(IRepeaterProtocolHandler* handler) if (!repeater.IsSameAs(user)) { CRepeaterHandler* handler = CRepeaterHandler::findDVRepeater(repeater); if (handler == NULL) - wxLogMessage(wxT("Heard received from unknown repeater, %s"), repeater.c_str()); + wxLogInfo(wxT("Heard received from unknown repeater, %s"), repeater.c_str()); else handler->processRepeater(*heard);