summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-02-15 15:12:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-02-15 15:12:40 +0000
commit328ed627c54165d75fc382487947ac05d7888027 (patch)
treea0193ed5864f253f550669506e19cdff0317bb94
parentAdd all provided endpoints to the service proxy (diff)
downloadnetfs-328ed627c54165d75fc382487947ac05d7888027.tar.bz2
netfs-328ed627c54165d75fc382487947ac05d7888027.tar.xz
netfs-328ed627c54165d75fc382487947ac05d7888027.zip
Make more testable
-rw-r--r--netfs/daemon/Jamfile.jam6
-rw-r--r--netfs/daemon/daemon.cpp23
-rw-r--r--netfs/daemon/daemon.h10
-rw-r--r--netfs/daemon/daemonService.h1
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: