aboutsummaryrefslogtreecommitdiffstats
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-18 16:36:42 +0100
committerMax Kellermann <max@duempel.org>2014-01-26 00:10:05 +0100
commit5c4a42caa088335868342b25a834962cbc0d08a2 (patch)
tree388c039572317877f798e0f0c25d9e3c04ddcae3 /src/Main.cxx
parente847788569bd91ca136160694a49665097c0e8ab (diff)
downloadmpd-5c4a42caa088335868342b25a834962cbc0d08a2.tar.gz
mpd-5c4a42caa088335868342b25a834962cbc0d08a2.tar.xz
mpd-5c4a42caa088335868342b25a834962cbc0d08a2.zip
neighbor: new subsystem to detect file servers on the local network
This commit adds the NeighborPlugin API which can be used to detect nearby file servers that can be used by input plugins. This list of servers is exported using the new "listneighbors" command. The idle even "neighbor" notifies interested clients when a new neighbor is found or an existing one is lost. There's a lot missing currently: protocol&user documentation, and a way to "mount" remote servers into the music database. Obviously, some code from the UPnP database plugin can be moved to a neighbor plugin.
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index fc7efd036..f790ec574 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -67,6 +67,10 @@
#include "config/ConfigOption.hxx"
#include "Stats.hxx"
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+#include "neighbor/Glue.hxx"
+#endif
+
#ifdef ENABLE_INOTIFY
#include "db/update/InotifyUpdate.hxx"
#endif
@@ -394,6 +398,19 @@ int mpd_main(int argc, char *argv[])
instance = new Instance();
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+ instance->neighbors = new NeighborGlue();
+ if (!instance->neighbors->Init(io_thread_get(), *instance, error)) {
+ LogError(error);
+ return EXIT_FAILURE;
+ }
+
+ if (instance->neighbors->IsEmpty()) {
+ delete instance->neighbors;
+ instance->neighbors = nullptr;
+ }
+#endif
+
const unsigned max_clients = config_get_positive(CONF_MAX_CONN, 10);
instance->client_list = new ClientList(max_clients);
@@ -460,6 +477,12 @@ int mpd_main(int argc, char *argv[])
io_thread_start();
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+ if (instance->neighbors != nullptr &&
+ !instance->neighbors->Open(error))
+ FatalError(error);
+#endif
+
ZeroconfInit(*main_loop);
player_create(instance->partition->pc);
@@ -523,6 +546,13 @@ int mpd_main(int argc, char *argv[])
listen_global_finish();
delete instance->client_list;
+#ifdef ENABLE_NEIGHBOR_PLUGINS
+ if (instance->neighbors != nullptr) {
+ instance->neighbors->Close();
+ delete instance->neighbors;
+ }
+#endif
+
const clock_t start = clock();
DatabaseGlobalDeinit();
FormatDebug(main_domain,