diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-02-15 15:12:40 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-05-06 00:40:49 +0100 |
commit | 18c02e406764898dfa43e18909285b0f0bb10ff4 (patch) | |
tree | a0193ed5864f253f550669506e19cdff0317bb94 | |
parent | Add all provided endpoints to the service proxy (diff) | |
download | netfs-18c02e406764898dfa43e18909285b0f0bb10ff4.tar.bz2 netfs-18c02e406764898dfa43e18909285b0f0bb10ff4.tar.xz netfs-18c02e406764898dfa43e18909285b0f0bb10ff4.zip |
Make more testable
-rw-r--r-- | netfs/daemon/Jamfile.jam | 6 | ||||
-rw-r--r-- | netfs/daemon/daemon.cpp | 23 | ||||
-rw-r--r-- | netfs/daemon/daemon.h | 10 | ||||
-rw-r--r-- | netfs/daemon/daemonService.h | 1 |
4 files changed, 29 insertions, 11 deletions
diff --git a/netfs/daemon/Jamfile.jam b/netfs/daemon/Jamfile.jam index fd8c463..d42175d 100644 --- a/netfs/daemon/Jamfile.jam +++ b/netfs/daemon/Jamfile.jam @@ -50,6 +50,12 @@ lib netfsd : <library>..//IceBox <library>..//libxmlpp <library>slicer-xml + : : + <include>. + <implicit-dependency>../ice//netfsComms + <library>netfsdConfiguration + <implicit-dependency>netfsdConfiguration + <library>..//IceBox ; diff --git a/netfs/daemon/daemon.cpp b/netfs/daemon/daemon.cpp index d36e63f..6c231f9 100644 --- a/netfs/daemon/daemon.cpp +++ b/netfs/daemon/daemon.cpp @@ -8,19 +8,28 @@ #include "ioHelpers.h" #include <sys/stat.h> +NetFSDaemon::NetFSDaemon(const Ice::CommunicatorPtr & i) : + ic(i) +{ +} + std::string NetFSDaemon::hostname() { - char buf[128]; - gethostname(buf, sizeof(buf)); - return buf; + auto props = ic->getProperties(); + auto hostNameOverride = props->getProperty("NetFSD.HostNameOverride"); + if (hostNameOverride.empty()) { + char buf[128]; + gethostname(buf, sizeof(buf)); + return buf; + } + return hostNameOverride; } // name = NetFSDaemonAdapter void -NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq&) +NetFSDaemon::start(const std::string & name, const Ice::CommunicatorPtr &, const Ice::StringSeq&) { - this->ic = ic; Ice::PropertiesPtr props = ic->getProperties(); LoadConfiguration(props->getProperty("NetFSD.ConfigPath")); @@ -49,9 +58,9 @@ NetFSDaemon::stop() extern "C" { IceBox::Service * - createNetFSDaemon(Ice::CommunicatorPtr) + createNetFSDaemon(Ice::CommunicatorPtr ic) { - return new NetFSDaemon(); + return new NetFSDaemon(ic); } } diff --git a/netfs/daemon/daemon.h b/netfs/daemon/daemon.h index 471a296..58d9f2f 100644 --- a/netfs/daemon/daemon.h +++ b/netfs/daemon/daemon.h @@ -9,17 +9,19 @@ class NetFSDaemon : public IceBox::Service { public: - virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&); - virtual void stop(); + NetFSDaemon(const Ice::CommunicatorPtr &); + + virtual void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&) override; + virtual void stop() override; private: void LoadConfiguration(const boost::filesystem::path & path); - Ice::CommunicatorPtr ic; + const Ice::CommunicatorPtr ic; Ice::ObjectAdapterPtr adapter; NetFS::Daemon::RuntimeConfigurationPtr dc; - static std::string hostname(); + std::string hostname(); }; class TempPrivs { diff --git a/netfs/daemon/daemonService.h b/netfs/daemon/daemonService.h index 783ad96..ab52eee 100644 --- a/netfs/daemon/daemonService.h +++ b/netfs/daemon/daemonService.h @@ -3,6 +3,7 @@ #include <service.h> #include <entCache.h> +#include <configuration.h> class ServiceServer : public NetFS::Service { public: |