Add CMake option to disable building of internal HTTP server.
BUG: 373
This commit is contained in:
committed by
craig.p.drummond
parent
eb51beb2bd
commit
7a2f2b6749
@@ -44,6 +44,7 @@ option(ENABLE_MUSICBRAINZ "Enable MusicBrianz libraries (either this or CDDB req
|
||||
option(ENABLE_PROXY_CONFIG "Enable proxy config in settings dialog" OFF)
|
||||
option(ENABLE_EXTERNAL_TAGS "Enable usage of external app for reading/writing tags (EXPERIMENTAL - NOT FULLY WORKING)" OFF)
|
||||
option(ENABLE_UNCACHED_MTP "Open MTP devices in un-cached mode (faster)" ON)
|
||||
option(ENABLE_HTTP_SERVER "Enable internal HTTP server to play non-MPD files" ON)
|
||||
|
||||
if (ENABLE_QT5)
|
||||
set(ENABLE_KDE FALSE)
|
||||
@@ -223,7 +224,7 @@ set(CANTATA_SRCS gui/application.cpp gui/main.cpp gui/initialsettingswizard.cpp
|
||||
widgets/basicitemdelegate.cpp widgets/sizegrip.cpp widgets/sizewidget.cpp widgets/servicestatuslabel.cpp widgets/spacerwidget.cpp
|
||||
widgets/songdialog.cpp
|
||||
network/networkaccessmanager.cpp network/networkproxyfactory.cpp
|
||||
http/httpserversettings.cpp http/httpserver.cpp http/httpsocket.cpp
|
||||
http/httpserver.cpp
|
||||
devices/deviceoptions.cpp
|
||||
context/lyricsettings.cpp context/ultimatelyricsprovider.cpp context/ultimatelyrics.cpp context/lyricsdialog.cpp
|
||||
context/contextwidget.cpp context/view.cpp context/artistview.cpp context/albumview.cpp context/songview.cpp context/contextengine.cpp
|
||||
@@ -247,7 +248,6 @@ set(CANTATA_MOC_HDRS
|
||||
widgets/playqueueview.h widgets/groupedview.h widgets/actionitemdelegate.h widgets/coverwidget.h widgets/volumeslider.h
|
||||
widgets/genrecombo.h widgets/toolbar.h widgets/searchwidget.h widgets/messageoverlay.h widgets/servicestatuslabel.h
|
||||
network/networkaccessmanager.h
|
||||
http/httpserver.h http/httpsocket.h
|
||||
context/togglelist.h context/ultimatelyrics.h context/ultimatelyricsprovider.h context/lyricsdialog.h
|
||||
context/contextwidget.h context/artistview.h context/albumview.h context/songview.h context/view.h context/contextengine.h
|
||||
context/wikipediaengine.h context/wikipediasettings.h context/othersettings.h context/lastfmengine.h context/metaengine.h
|
||||
@@ -262,6 +262,12 @@ set(CANTATA_UIS
|
||||
http/httpserversettings.ui
|
||||
online/onlineservicespage.ui online/onlinesettings.ui)
|
||||
|
||||
if (ENABLE_HTTP_SERVER)
|
||||
set(CANTATA_SRCS ${CANTATA_SRCS} http/httpserversettings.cpp http/httpsocket.cpp)
|
||||
set(CANTATA_MOC_HDRS ${CANTATA_MOC_HDRS} http/httpserver.h http/httpsocket.h)
|
||||
set(CANTATA_UIS ${CANTATA_UIS} http/httpserversettings.ui)
|
||||
endif (ENABLE_HTTP_SERVER)
|
||||
|
||||
if (ENABLE_MODEL_TEST AND NOT ENABLE_KDE AND NOT ENABLE_QT5)
|
||||
set(QTLIBS ${QTLIBS} ${QT_QTTEST_LIBRARY})
|
||||
set(CANTATA_SRCS ${CANTATA_SRCS} models/modeltest.cpp)
|
||||
@@ -619,7 +625,7 @@ if (TAGLIB_FOUND)
|
||||
endif (ENABLE_PROXY_CONFIG)
|
||||
endif (ENABLE_REMOTE_DEVICES OR ENABLE_HTTP_STREAM_PLAYBACK OR AUDIOCD_SUPPORT OR MTP_FOUND OR ENABLE_PROXY_CONFIG OR ENABLE_REPLAYGAIN_SUPPORT)
|
||||
|
||||
if (NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT AUDIOCD_SUPPORT OR NOT ENABLE_REPLAYGAIN_SUPPORT OR NOT ENABLE_HTTP_STREAM_PLAYBACK OR NOT ENABLE_REMOTE_DEVICES OR (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE))
|
||||
if (NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT AUDIOCD_SUPPORT OR NOT ENABLE_REPLAYGAIN_SUPPORT OR NOT ENABLE_HTTP_STREAM_PLAYBACK OR NOT ENABLE_REMOTE_DEVICES OR NOT ENABLE_HTTP_SERVER OR (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE))
|
||||
message(" Disabled features:")
|
||||
if (NOT ENABLE_HTTP_STREAM_PLAYBACK)
|
||||
message(" - MPD HTTP stream playback (Phonon required for Qt4, QtMultiMedia for Qt5)")
|
||||
@@ -639,7 +645,10 @@ if (TAGLIB_FOUND)
|
||||
if (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE)
|
||||
message(" - Proxy configuration")
|
||||
endif (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE)
|
||||
endif (NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT AUDIOCD_SUPPORT OR NOT ENABLE_REPLAYGAIN_SUPPORT OR NOT ENABLE_HTTP_STREAM_PLAYBACK OR NOT ENABLE_REMOTE_DEVICES OR (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE))
|
||||
if (NOT ENABLE_HTTP_SERVER)
|
||||
message(" - Internal HTTP server (playback of AudioCDs, and songs from media files disabled)")
|
||||
endif (NOT ENABLE_HTTP_SERVER)
|
||||
endif (NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT AUDIOCD_SUPPORT OR NOT ENABLE_REPLAYGAIN_SUPPORT OR NOT ENABLE_HTTP_STREAM_PLAYBACK OR NOT ENABLE_REMOTE_DEVICES OR NOT ENABLE_HTTP_SERVER OR (NOT ENABLE_PROXY_CONFIG AND NOT ENABLE_KDE))
|
||||
|
||||
if (ENABLE_EXTERNAL_TAGS)
|
||||
message(" Tags will be read/written via an external helper app")
|
||||
@@ -662,8 +671,11 @@ else (TAGLIB_FOUND)
|
||||
message(" - Remote device sync (EXPERIMENTAL) (taglib required)")
|
||||
endif (NOT WIN32 AND NOT APPLE)
|
||||
if (NOT ENABLE_REPLAYGAIN_SUPPORT)
|
||||
message(" - ReplayGain calculation(taglib, and ffmpeg and/or mpg123 required)")
|
||||
message(" - ReplayGain calculation (taglib, and ffmpeg and/or mpg123 required)")
|
||||
endif (NOT ENABLE_REPLAYGAIN_SUPPORT)
|
||||
if (NOT ENABLE_HTTP_SERVER)
|
||||
message(" - Internal HTTP server (playback of AudioCDs, and songs from media files disabled)")
|
||||
endif (NOT ENABLE_HTTP_SERVER)
|
||||
|
||||
endif (TAGLIB_FOUND)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
file:/// URLs to MPD - i.e. dont use internal HTTP server. To foce usage of
|
||||
HTTP server - set alwaysUseHttp to true in Cantata's config file. Refer to
|
||||
README for more details.
|
||||
16. Add CMake option to disable building of internal HTTP server.
|
||||
|
||||
1.2.2
|
||||
-----
|
||||
|
||||
4
INSTALL
4
INSTALL
@@ -96,6 +96,10 @@ The following options may be passed to CMake:
|
||||
Open MTP devices in un-cached mode (faster)
|
||||
Default: ON
|
||||
|
||||
-DENABLE_HTTP_SERVER=ON
|
||||
Enable usage of internal HTTP server for non-MPD file playback.
|
||||
Default: ON
|
||||
|
||||
|
||||
Windows specific:
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#cmakedefine CDPARANOIA_HAS_CACHEMODEL_SIZE 1
|
||||
#cmakedefine QT_QTDBUS_FOUND 1
|
||||
#cmakedefine ENABLE_UNCACHED_MTP 1
|
||||
#cmakedefine ENABLE_HTTP_SERVER 1
|
||||
|
||||
/*
|
||||
This is done via CMake add_defintions - as it controls SLOT generation in GtkProxyStyle
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "device.h"
|
||||
#include "covers.h"
|
||||
#include "httpserver.h"
|
||||
#ifdef ENABLE_KDE_SUPPORT
|
||||
#include <solid/opticaldrive.h>
|
||||
#else
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
void saveOptions() { }
|
||||
QString subText() { return album; }
|
||||
quint32 totalTime();
|
||||
bool canPlaySongs() const { return true; }
|
||||
bool canPlaySongs() const { return HttpServer::self()->isAlive(); }
|
||||
QString albumName() const { return album; }
|
||||
QString albumArtist() const { return artist; }
|
||||
QString albumComposer() const { return composer; }
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "utils.h"
|
||||
#include "freespaceinfo.h"
|
||||
#include "musiclibraryitemroot.h"
|
||||
#include "httpserver.h"
|
||||
#include <QStringList>
|
||||
|
||||
class Thread;
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
void saveCache();
|
||||
void removeCache();
|
||||
bool isStdFs() const { return true; }
|
||||
bool canPlaySongs() const { return true; }
|
||||
bool canPlaySongs() const { return HttpServer::self()->isAlive(); }
|
||||
|
||||
Q_SIGNALS:
|
||||
// For talking to scanner...
|
||||
|
||||
@@ -937,7 +937,7 @@ void MainWindow::load(const QStringList &urls)
|
||||
} else if (u.scheme().isEmpty() || QLatin1String("file")==u.scheme()) {
|
||||
if (!HttpServer::self()->forceUsage() && MPDConnection::self()->getDetails().isLocal()) {
|
||||
useable.append(QLatin1String("file://")+u.path());
|
||||
} else {
|
||||
} else if (HttpServer::self()->isAlive()) {
|
||||
useable.append(HttpServer::self()->encodeUrl(u.path()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, const QStringList &hiddenP
|
||||
streams = hiddenPages.contains(QLatin1String("StreamsPage")) ? 0 : new StreamsSettings(0);
|
||||
online = hiddenPages.contains(QLatin1String("OnlineServicesPage")) ? 0 : new OnlineSettings(0);
|
||||
context = new ContextSettings(0);
|
||||
http = new HttpServerSettings(0);
|
||||
cache = new CacheSettings(0);
|
||||
server->load();
|
||||
playback->load();
|
||||
@@ -90,6 +89,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, const QStringList &hiddenP
|
||||
online->load();
|
||||
}
|
||||
pageWidget->addPage(context, i18n("Context"), Icons::self()->contextIcon, i18n("Context View Settings"));
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
http = new HttpServerSettings(0);
|
||||
if (http->haveMultipleInterfaces()) {
|
||||
http->load();
|
||||
Icon icon("network-server");
|
||||
@@ -101,6 +102,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, const QStringList &hiddenP
|
||||
http->deleteLater();
|
||||
http=0;
|
||||
}
|
||||
#endif
|
||||
#if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
|
||||
audiocd = new AudioCdSettings(0);
|
||||
audiocd->load();
|
||||
@@ -154,9 +156,11 @@ void PreferencesDialog::writeSettings()
|
||||
if (online) {
|
||||
online->save();
|
||||
}
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
if (http) {
|
||||
http->save();
|
||||
}
|
||||
#endif
|
||||
#ifndef ENABLE_KDE_SUPPORT
|
||||
#ifdef ENABLE_PROXY_CONFIG
|
||||
proxy->save();
|
||||
|
||||
@@ -80,7 +80,9 @@ private:
|
||||
StreamsSettings *streams;
|
||||
OnlineSettings *online;
|
||||
ContextSettings *context;
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
HttpServerSettings *http;
|
||||
#endif
|
||||
#ifdef ENABLE_PROXY_CONFIG
|
||||
ProxySettings *proxy;
|
||||
#endif
|
||||
|
||||
@@ -645,7 +645,11 @@ QString Settings::httpInterface()
|
||||
|
||||
bool Settings::alwaysUseHttp()
|
||||
{
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
return GET_BOOL("alwaysUseHttp", false);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Settings::playQueueGrouped()
|
||||
|
||||
@@ -73,6 +73,7 @@ HttpServer * HttpServer::self()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
HttpServer::HttpServer()
|
||||
: QObject(0)
|
||||
, thread(0)
|
||||
@@ -361,3 +362,5 @@ void HttpServer::removedIds(const QSet<qint32> &ids)
|
||||
startCloseTimer();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,9 @@ class QTimer;
|
||||
|
||||
class HttpServer : public QObject
|
||||
{
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
Q_OBJECT
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void enableDebug();
|
||||
@@ -45,10 +47,10 @@ public:
|
||||
|
||||
static HttpServer * self();
|
||||
|
||||
HttpServer();
|
||||
virtual ~HttpServer() { }
|
||||
|
||||
bool start();
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
HttpServer();
|
||||
bool isAlive() const { return true; } // Started on-demamnd!
|
||||
bool forceUsage() const { return force; }
|
||||
void readConfig();
|
||||
@@ -58,11 +60,25 @@ public:
|
||||
QByteArray encodeUrl(const QString &file);
|
||||
Song decodeUrl(const QUrl &url) const;
|
||||
Song decodeUrl(const QString &file) const;
|
||||
#else
|
||||
HttpServer() { }
|
||||
bool isAlive() const { return false; } // Not used!
|
||||
bool forceUsage() const { return false; }
|
||||
void readConfig() { }
|
||||
QString address() const { return QString(); }
|
||||
bool isOurs(const QString &) const { return false; }
|
||||
QByteArray encodeUrl(const Song &) { return QByteArray(); }
|
||||
QByteArray encodeUrl(const QString &) { return QByteArray(); }
|
||||
Song decodeUrl(const QUrl &) const { return Song(); }
|
||||
Song decodeUrl(const QString &) const { return Song(); }
|
||||
#endif
|
||||
|
||||
public Q_SLOTS:
|
||||
void stop();
|
||||
private:
|
||||
#ifdef ENABLE_HTTP_SERVER
|
||||
bool start();
|
||||
|
||||
private Q_SLOTS:
|
||||
void stop();
|
||||
void startCloseTimer();
|
||||
void mpdAddress(const QString &a);
|
||||
void cantataStreams(const QStringList &files);
|
||||
@@ -80,6 +96,7 @@ private:
|
||||
QString mpdAddr;
|
||||
QSet<qint32> streamIds; // Currently playing MPD stream IDs
|
||||
QTimer *closeTimer;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -555,7 +555,7 @@ bool PlayQueueModel::dropMimeData(const QMimeData *data,
|
||||
if (checkExtension(u)) {
|
||||
if (!HttpServer::self()->forceUsage() && MPDConnection::self()->getDetails().isLocal()) {
|
||||
useable.append(QLatin1String("file://")+QUrl::fromPercentEncoding(u.toUtf8()));
|
||||
} else {
|
||||
} else if (HttpServer::self()->isAlive()) {
|
||||
useable.append(HttpServer::self()->encodeUrl(QUrl::fromPercentEncoding(u.toUtf8())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ Song PodcastService::fixPath(const Song &orig, bool) const
|
||||
if (!orig.podcastLocalPath().isEmpty() && QFile::exists(orig.podcastLocalPath())) {
|
||||
if (!HttpServer::self()->forceUsage() && MPDConnection::self()->getDetails().isLocal()) {
|
||||
song.file=QLatin1String("file://")+orig.podcastLocalPath();
|
||||
} else {
|
||||
} else if (HttpServer::self()->isAlive()) {
|
||||
song.file=orig.podcastLocalPath();
|
||||
song.file=HttpServer::self()->encodeUrl(song);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user