diff --git a/DStarGatewayConfig.cpp b/DStarGatewayConfig.cpp index aed1ba1..eb70f0d 100644 --- a/DStarGatewayConfig.cpp +++ b/DStarGatewayConfig.cpp @@ -42,7 +42,11 @@ bool CDStarGatewayConfig::load() && loadIrcDDB(cfg) && loadRepeaters(cfg) && loadPaths(cfg) - && loadAPRS(cfg)) { + && loadAPRS(cfg) + && loadDextra(cfg) + && loadDCS(cfg) + && loadDPlus(cfg) + && loadRemote(cfg)) { //properly size values m_gateway.callsign.resize(LONG_CALLSIGN_LENGTH - 1U, ' '); @@ -56,6 +60,38 @@ bool CDStarGatewayConfig::load() return false; } +bool CDStarGatewayConfig::loadRemote(const Config & cfg) +{ + bool ret = get_value(cfg, "remote.enabled", m_remote.enabled, false); + ret = get_value(cfg, "remote.port", m_remote.port, 1U, 65535U, 4242U) && ret; + ret = get_value(cfg, "remote.password", m_remote.password, 0, 1024, "", true) && ret; + + m_remote.enabled = m_remote.enabled && !m_remote.password.empty(); + + return ret; +} + +bool CDStarGatewayConfig::loadDextra(const Config & cfg) +{ + bool ret = get_value(cfg, "dextra.enabled", m_dextra.enabled, true); + ret = get_value(cfg, "dextra.maxDongles", m_dextra.maxDongles, 1U, 5U, 5U) && ret; + return ret; +} + +bool CDStarGatewayConfig::loadDPlus(const Config & cfg) +{ + bool ret = get_value(cfg, "dplus.enabled", m_dplus.enabled, true); + ret = get_value(cfg, "dplus.maxDongles", m_dplus.maxDongles, 1U, 5U, 5U) && ret; + ret = get_value(cfg, "dplus.maxDongles", m_dplus.login, 0, LONG_CALLSIGN_LENGTH, m_gateway.callsign, true) && ret; + return ret; +} + +bool CDStarGatewayConfig::loadDCS(const Config & cfg) +{ + bool ret = get_value(cfg, "dcs.enabled", m_dcs.enabled, true); + return ret; +} + bool CDStarGatewayConfig::loadAPRS(const Config & cfg) { bool ret = get_value(cfg, "aprs.enabled", m_aprs.enabled, false); @@ -458,3 +494,23 @@ void CDStarGatewayConfig::getAPRS(TAPRS & aprs) const { aprs = m_aprs; } + +void CDStarGatewayConfig::getDExtra(TDextra & dextra) const +{ + dextra = m_dextra; +} + +void CDStarGatewayConfig::getDPlus(TDplus & dplus) const +{ + dplus = m_dplus; +} + +void CDStarGatewayConfig::getDCS(TDCS & dcs) const +{ + dcs = m_dcs; +} + +void CDStarGatewayConfig::getRemote(TRemote & remote) const +{ + remote = m_remote; +} diff --git a/DStarGatewayConfig.h b/DStarGatewayConfig.h index 324ada5..97d4f12 100644 --- a/DStarGatewayConfig.h +++ b/DStarGatewayConfig.h @@ -86,6 +86,28 @@ typedef struct { std::string password; } TAPRS; +typedef struct { + bool enabled; + unsigned int maxDongles; +} TDextra; + +typedef struct { + bool enabled; + std::string login; + unsigned int maxDongles; +} TDplus; + +typedef struct { + bool enabled; +} TDCS; + +typedef struct { + bool enabled; + unsigned int port; + std::string login; + std::string password; +} TRemote; + class CDStarGatewayConfig { public: CDStarGatewayConfig(const std::string &pathname); @@ -99,6 +121,10 @@ public: unsigned int getRepeaterCount() const; void getPaths(Tpaths & paths) const; void getAPRS(TAPRS & aprs) const; + void getDExtra(TDextra & dextra) const; + void getDPlus(TDplus & dplus) const; + void getDCS(TDCS & dcs) const; + void getRemote(TRemote & remote) const; private: bool open(Config & cfg); @@ -107,6 +133,10 @@ private: bool loadRepeaters(const Config & cfg); bool loadPaths(const Config & cfg); bool loadAPRS(const Config & cfg); + bool loadDextra(const Config & cfg); + bool loadDPlus(const Config & cfg); + bool loadDCS(const Config & cfg); + bool loadRemote(const Config & cfg); bool get_value(const Config &cfg, const std::string &path, unsigned int &value, unsigned int min, unsigned int max, unsigned int default_value); bool get_value(const Config &cfg, const std::string &path, int &value, int min, int max, int default_value); bool get_value(const Config &cfg, const std::string &path, double &value, double min, double max, double default_value); @@ -119,6 +149,10 @@ private: TGateway m_gateway; Tpaths m_paths; TAPRS m_aprs; + TDextra m_dextra; + TDplus m_dplus; + TDCS m_dcs; + TRemote m_remote; std::vector m_repeaters; std::vector m_ircDDB; }; diff --git a/example.cfg b/example.cfg index 38d3ad4..39dc071 100644 --- a/example.cfg +++ b/example.cfg @@ -77,4 +77,30 @@ aprs = { paths = { log="/var/log/dstargateway/" data="/usr/local/share/dstargateway/" #Path where the data (hostfiles, audio files etc) can be found +} + +dextra { + enabled=true # There is no reason to disable this + maxDongles=5 +} + +dplus { + enabled=true # There is no reason to disable this + maxDongles=5 + login="" # defaults to gateway callsign +} + +dcs { + enabled=true # There is no reason to disable this +} + +xlx { + enabled=true + hostfileUrl="http://xlxapi.rlx.lu/api.php?do=GetReflectorHostname" +} + +remote { + enabled=false + port=4242 + password="CHANGE_ME" # If password is left blank, remote will be disabled regardless of the enabled field } \ No newline at end of file