diff --git a/approot/artist.xml b/approot/artist.xml
index 13d24a6a..78195b00 100644
--- a/approot/artist.xml
+++ b/approot/artist.xml
@@ -24,7 +24,9 @@
${}
${tr:Lms.Explore.musicbrainz-artist}
${}
+ ${}
${download class="dropdown-item"}
+ ${}
diff --git a/approot/playqueue.xml b/approot/playqueue.xml
index c372f8df..2f6f2453 100644
--- a/approot/playqueue.xml
+++ b/approot/playqueue.xml
@@ -65,7 +65,9 @@
diff --git a/approot/release.xml b/approot/release.xml
index 0d856885..d19cd070 100644
--- a/approot/release.xml
+++ b/approot/release.xml
@@ -27,7 +27,9 @@
${}
${tr:Lms.Explore.musicbrainz-release}
${}
+ ${}
${download class="dropdown-item"}
+ ${}
${release-info class="dropdown-item"}
@@ -109,7 +111,9 @@
${play-next class="dropdown-item"}
${play-last class="dropdown-item"}
${star class="dropdown-item"}
+ ${}
${download class="dropdown-item"}
+ ${}
${track-info class="dropdown-item"}
${}${track-lyrics class="dropdown-item"}${}
diff --git a/approot/tracklist.xml b/approot/tracklist.xml
index 5a2ec74b..9f4fc8ca 100644
--- a/approot/tracklist.xml
+++ b/approot/tracklist.xml
@@ -13,7 +13,9 @@
diff --git a/conf/lms.conf b/conf/lms.conf
index 269ae960..3a22444d 100644
--- a/conf/lms.conf
+++ b/conf/lms.conf
@@ -113,9 +113,6 @@ artist-image-file-names = ("artist");
# Note: files named after the disc itself are always searched before the names in this list.
medium-image-file-names = ("discsubtitle");
-# Playqueue max entry count
-playqueue-max-entry-count = 1000;
-
# Internal tracing for profiling purposes. Enable only if necessary, as it incurs some runtime overhead!
# Possible values are "disabled", "overview" or "detailed".
# If enabled, data has to be dumped in the tracing view located in the admin menu
@@ -140,3 +137,9 @@ podcast-auto-download-episodes = true;
# Max age in days for auto-downloaded episodes before deletion
podcast-auto-download-episodes-max-age-days = 30;
+
+# Playqueue max entry count
+ui-playqueue-max-entry-count = 1000;
+
+# Allow downloads
+ui-allow-downloads = true;
\ No newline at end of file
diff --git a/src/lms/ui/LmsApplication.cpp b/src/lms/ui/LmsApplication.cpp
index 271b043a..216f0a36 100644
--- a/src/lms/ui/LmsApplication.cpp
+++ b/src/lms/ui/LmsApplication.cpp
@@ -26,9 +26,11 @@
#include
#include
+#include "core/IConfig.hpp"
#include "core/ILogger.hpp"
#include "core/ITraceLogger.hpp"
#include "core/Service.hpp"
+
#include "database/IDb.hpp"
#include "database/IQueryPlanRecorder.hpp"
#include "database/Session.hpp"
@@ -198,6 +200,31 @@ namespace lms::ui
return static_cast(Wt::WApplication::instance());
}
+ LmsApplication::LmsApplication(const Wt::WEnvironment& env, db::IDb& db, LmsApplicationManager& appManager, AuthenticationBackend authBackend)
+ : Wt::WApplication{ env }
+ , _db{ db }
+ , _appManager{ appManager }
+ , _authBackend{ authBackend }
+ , _areDownloadsEnabled(core::Service::get()->getBool("ui-allow-downloads", true))
+ {
+ try
+ {
+ init();
+ }
+ catch (LmsApplicationException& e)
+ {
+ LMS_LOG(UI, WARNING, "Caught a LmsApplication exception: " << e.what());
+ handleException(e);
+ }
+ catch (std::exception& e)
+ {
+ LMS_LOG(UI, ERROR, "Caught exception: " << e.what());
+ throw core::LmsException{ "Internal error" }; // Do not put details here at it may appear on the user rendered html
+ }
+ }
+
+ LmsApplication::~LmsApplication() = default;
+
db::IDb& LmsApplication::getDb()
{
return _db;
@@ -240,30 +267,11 @@ namespace lms::ui
return _user->userLoginName;
}
- LmsApplication::LmsApplication(const Wt::WEnvironment& env, db::IDb& db, LmsApplicationManager& appManager, AuthenticationBackend authBackend)
- : Wt::WApplication{ env }
- , _db{ db }
- , _appManager{ appManager }
- , _authBackend{ authBackend }
+ bool LmsApplication::areDownloadsEnabled() const
{
- try
- {
- init();
- }
- catch (LmsApplicationException& e)
- {
- LMS_LOG(UI, WARNING, "Caught a LmsApplication exception: " << e.what());
- handleException(e);
- }
- catch (std::exception& e)
- {
- LMS_LOG(UI, ERROR, "Caught exception: " << e.what());
- throw core::LmsException{ "Internal error" }; // Do not put details here at it may appear on the user rendered html
- }
+ return _areDownloadsEnabled;
}
- LmsApplication::~LmsApplication() = default;
-
void LmsApplication::init()
{
LMS_SCOPED_TRACE_OVERVIEW("UI", "ApplicationInit");
diff --git a/src/lms/ui/LmsApplication.hpp b/src/lms/ui/LmsApplication.hpp
index a7776097..c54646c4 100644
--- a/src/lms/ui/LmsApplication.hpp
+++ b/src/lms/ui/LmsApplication.hpp
@@ -70,6 +70,8 @@ namespace lms::ui
db::UserType getUserType() const; // user must be logged in prior this call
std::string_view getUserLoginName() const; // user must be logged in prior this call
+ bool areDownloadsEnabled() const;
+
// Proxified scanner events
scanner::Events& getScannerEvents() { return _scannerEvents; }
@@ -109,6 +111,7 @@ namespace lms::ui
Wt::Signal<> _preQuit;
LmsApplicationManager& _appManager;
const AuthenticationBackend _authBackend;
+ const bool _areDownloadsEnabled;
scanner::Events _scannerEvents;
struct UserAuthInfo
{
diff --git a/src/lms/ui/PlayQueue.cpp b/src/lms/ui/PlayQueue.cpp
index b5328b9a..3bdfe3e5 100644
--- a/src/lms/ui/PlayQueue.cpp
+++ b/src/lms/ui/PlayQueue.cpp
@@ -114,7 +114,7 @@ namespace lms::ui
PlayQueue::PlayQueue()
: Template{ Wt::WString::tr("Lms.PlayQueue.template") }
- , _capacity{ core::Service::get()->getULong("playqueue-max-entry-count", 1000) }
+ , _capacity{ core::Service::get()->getULong("ui-playqueue-max-entry-count", 1000) }
{
initTrackLists();
@@ -578,8 +578,12 @@ namespace lms::ui
}
});
- entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ if (LmsApp->areDownloadsEnabled())
+ {
+ entry->setCondition("if-has-download", true);
+ entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ }
}
void PlayQueue::enqueueRadioTracksIfNeeded()
diff --git a/src/lms/ui/explore/ArtistView.cpp b/src/lms/ui/explore/ArtistView.cpp
index 35ed3989..58c0590a 100644
--- a/src/lms/ui/explore/ArtistView.cpp
+++ b/src/lms/ui/explore/ArtistView.cpp
@@ -168,8 +168,13 @@ namespace lms::ui
.connect([this] {
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _artistId });
});
- bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(_artistId) });
+
+ if (LmsApp->areDownloadsEnabled())
+ {
+ setCondition("if-has-download", true);
+ bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(_artistId) });
+ }
{
auto isStarred{ [this] { return core::Service::get()->isStarred(LmsApp->getUserId(), _artistId); } };
diff --git a/src/lms/ui/explore/ReleaseView.cpp b/src/lms/ui/explore/ReleaseView.cpp
index 56ffb17f..ad55f306 100644
--- a/src/lms/ui/explore/ReleaseView.cpp
+++ b/src/lms/ui/explore/ReleaseView.cpp
@@ -359,8 +359,12 @@ namespace lms::ui
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, { _releaseId });
});
- bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(_releaseId) });
+ if (LmsApp->areDownloadsEnabled())
+ {
+ setCondition("if-has-download", true);
+ bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(_releaseId) });
+ }
bindNew("release-info", Wt::WString::tr("Lms.Explore.release-info"))
->clicked()
@@ -527,8 +531,12 @@ namespace lms::ui
starBtn->clicked().connect([=] { toggle(); });
}
- entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ if (LmsApp->areDownloadsEnabled())
+ {
+ entry->setCondition("if-has-download", true);
+ entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ }
entry->bindNew("track-info", Wt::WString::tr("Lms.Explore.track-info"))
->clicked()
diff --git a/src/lms/ui/explore/TrackListHelpers.cpp b/src/lms/ui/explore/TrackListHelpers.cpp
index c83d3be9..a7c6c07a 100644
--- a/src/lms/ui/explore/TrackListHelpers.cpp
+++ b/src/lms/ui/explore/TrackListHelpers.cpp
@@ -299,8 +299,12 @@ namespace lms::ui::TrackListHelpers
starBtn->clicked().connect([=] { toggle(); });
}
- entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ if (LmsApp->areDownloadsEnabled())
+ {
+ entry->setCondition("if-has-download", true);
+ entry->bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(trackId) });
+ }
entry->bindNew("track-info", Wt::WString::tr("Lms.Explore.track-info"))
->clicked()
diff --git a/src/lms/ui/explore/TrackListView.cpp b/src/lms/ui/explore/TrackListView.cpp
index 2bd658d2..6dc4717e 100644
--- a/src/lms/ui/explore/TrackListView.cpp
+++ b/src/lms/ui/explore/TrackListView.cpp
@@ -135,8 +135,12 @@ namespace lms::ui
_playQueueController.processCommand(PlayQueueController::Command::PlayOrAddLast, *trackListId);
});
- bindNew("download", Wt::WString::tr("Lms.Explore.download"))
- ->setLink(Wt::WLink{ std::make_unique(*trackListId) });
+ if (LmsApp->areDownloadsEnabled())
+ {
+ setCondition("if-has-download", true);
+ bindNew("download", Wt::WString::tr("Lms.Explore.download"))
+ ->setLink(Wt::WLink{ std::make_unique(*trackListId) });
+ }
if (trackList->getUserId() == LmsApp->getUserId())
{