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.
This commit is contained in:
30
src/Main.cxx
30
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,
|
||||
|
Reference in New Issue
Block a user