Make the GPL spotify code non-optional

(cherry picked from commit 2c55688601)
This commit is contained in:
David Sansome 2013-09-18 00:49:29 +10:00 committed by John Maguire
parent d89fb97701
commit 96a8c5a9fe
11 changed files with 70 additions and 151 deletions

View File

@ -76,7 +76,7 @@ pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92)
pkg_check_modules(LIBMTP libmtp>=1.0)
pkg_check_modules(LIBMYGPO_QT libmygpo-qt>=1.0.7)
pkg_check_modules(LIBXML libxml-2.0)
pkg_check_modules(QCA qca2)
pkg_check_modules(QCA REQUIRED qca2)
pkg_check_modules(QJSON REQUIRED QJson)
pkg_check_modules(SPOTIFY libspotify>=12.1.45)
pkg_check_modules(TAGLIB REQUIRED taglib>=1.6)
@ -254,24 +254,9 @@ optional_component(DEVICEKIT ON "Devices: DeviceKit backend"
DEPENDS "D-Bus support" HAVE_DBUS
)
optional_component(SPOTIFY ON "Spotify support: core code"
DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE
)
optional_component(SPOTIFY_BLOB ON "Spotify support: non-GPL binary helper"
DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE
DEPENDS "libspotify" SPOTIFY_FOUND
DEPENDS "Spotify support: core code" HAVE_SPOTIFY
)
set(NEED_SPOTIFY_DOWNLOADER OFF)
if(HAVE_SPOTIFY AND NOT HAVE_SPOTIFY_BLOB)
set(NEED_SPOTIFY_DOWNLOADER ON)
endif()
optional_component(SPOTIFY_DOWNLOADER
${NEED_SPOTIFY_DOWNLOADER} "Spotify support: blob downloader"
DEPENDS "qca2" QCA_FOUND
)
optional_component(MOODBAR ON "Moodbar support"
@ -450,6 +435,7 @@ add_subdirectory(ext/libclementine-common)
add_subdirectory(ext/libclementine-tagreader)
add_subdirectory(ext/clementine-tagreader)
add_subdirectory(ext/libclementine-remote)
add_subdirectory(ext/libclementine-spotifyblob)
option(WITH_DEBIAN OFF)
if(WITH_DEBIAN)
@ -460,10 +446,6 @@ if(HAVE_BREAKPAD)
add_subdirectory(3rdparty/google-breakpad)
endif(HAVE_BREAKPAD)
if(HAVE_SPOTIFY)
add_subdirectory(ext/libclementine-spotifyblob)
endif(HAVE_SPOTIFY)
if(HAVE_SPOTIFY_BLOB)
add_subdirectory(ext/clementine-spotifyblob)
endif(HAVE_SPOTIFY_BLOB)

View File

@ -10,6 +10,8 @@ if(BUILD_WERROR)
endif (LINUX)
endif(BUILD_WERROR)
link_directories(${QCA_LIBRARY_DIRS})
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(../3rdparty/gmock/gtest/include)
if(WIN32)
@ -38,6 +40,7 @@ include_directories(${ECHONEST_INCLUDE_DIRS})
include_directories(${SHA2_INCLUDE_DIRS})
include_directories(${CHROMAPRINT_INCLUDE_DIRS})
include_directories(${MYGPOQT_INCLUDE_DIRS})
include_directories(${QCA_INCLUDE_DIRS})
find_package(OpenGL)
include_directories(${OPENGL_INCLUDE_DIR})
@ -60,6 +63,8 @@ include_directories(${CMAKE_SOURCE_DIR}/ext/libclementine-tagreader)
include_directories(${CMAKE_BINARY_DIR}/ext/libclementine-tagreader)
include_directories(${CMAKE_SOURCE_DIR}/ext/libclementine-remote)
include_directories(${CMAKE_BINARY_DIR}/ext/libclementine-remote)
include_directories(${CMAKE_SOURCE_DIR}/ext/libclementine-spotifyblob)
include_directories(${CMAKE_BINARY_DIR}/ext/libclementine-spotifyblob)
cmake_policy(SET CMP0011 NEW)
include(../cmake/ParseArguments.cmake)
@ -155,6 +160,7 @@ set(SOURCES
globalsearch/simplesearchprovider.cpp
globalsearch/somafmsearchprovider.cpp
globalsearch/soundcloudsearchprovider.cpp
globalsearch/spotifysearchprovider.cpp
globalsearch/suggestionwidget.cpp
globalsearch/urlsearchprovider.cpp
@ -183,8 +189,8 @@ set(SOURCES
internet/localredirectserver.cpp
internet/magnatunedownloaddialog.cpp
internet/magnatuneplaylistitem.cpp
internet/magnatunesettingspage.cpp
internet/magnatuneservice.cpp
internet/magnatunesettingspage.cpp
internet/magnatuneurlhandler.cpp
internet/oauthenticator.cpp
internet/savedradio.cpp
@ -192,6 +198,10 @@ set(SOURCES
internet/somafmservice.cpp
internet/somafmurlhandler.cpp
internet/soundcloudservice.cpp
internet/spotifyblobdownloader.cpp
internet/spotifyserver.cpp
internet/spotifyservice.cpp
internet/spotifysettingspage.cpp
internet/subsonicservice.cpp
internet/subsonicsettingspage.cpp
internet/subsonicurlhandler.cpp
@ -386,6 +396,7 @@ set(SOURCES
widgets/tracksliderpopup.cpp
widgets/tracksliderslider.cpp
widgets/widgetfadehelper.cpp
)
set(HEADERS
@ -454,6 +465,7 @@ set(HEADERS
globalsearch/searchprovider.h
globalsearch/simplesearchprovider.h
globalsearch/soundcloudsearchprovider.h
globalsearch/spotifysearchprovider.h
globalsearch/suggestionwidget.h
internet/cloudfileservice.h
@ -478,14 +490,18 @@ set(HEADERS
internet/jamendoservice.h
internet/localredirectserver.h
internet/magnatunedownloaddialog.h
internet/magnatunesettingspage.h
internet/magnatuneservice.h
internet/magnatunesettingspage.h
internet/oauthenticator.h
internet/savedradio.h
internet/searchboxwidget.h
internet/somafmservice.h
internet/somafmurlhandler.h
internet/soundcloudservice.h
internet/spotifyblobdownloader.h
internet/spotifyserver.h
internet/spotifyservice.h
internet/spotifysettingspage.h
internet/subsonicservice.h
internet/subsonicsettingspage.h
internet/subsonicurlhandler.h
@ -823,32 +839,6 @@ optional_source(HAVE_LIBLASTFM
internet/lastfmstationdialog.ui
)
# Spotify
optional_source(HAVE_SPOTIFY
SOURCES
globalsearch/spotifysearchprovider.cpp
internet/spotifyserver.cpp
internet/spotifyservice.cpp
internet/spotifysettingspage.cpp
HEADERS
globalsearch/spotifysearchprovider.h
internet/spotifyserver.h
internet/spotifyservice.h
internet/spotifysettingspage.h
INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/ext/libclementine-spotifyblob
${CMAKE_BINARY_DIR}/ext/libclementine-spotifyblob
)
optional_source(HAVE_SPOTIFY_DOWNLOADER
SOURCES
internet/spotifyblobdownloader.cpp
HEADERS
internet/spotifyblobdownloader.h
INCLUDE_DIRECTORIES
${QCA_INCLUDE_DIRS}
)
# Platform specific - OS X
optional_source(APPLE
INCLUDE_DIRECTORIES
@ -1175,6 +1165,7 @@ add_dependencies(clementine_lib pot)
target_link_libraries(clementine_lib
clementine-spotifyblob-messages
libclementine-common
libclementine-tagreader
libclementine-remote
@ -1195,6 +1186,7 @@ target_link_libraries(clementine_lib
${QTSINGLECOREAPPLICATION_LIBRARIES}
${QTIOCOMPRESSOR_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${QCA_LIBRARIES}
z
Qocoa
)
@ -1243,19 +1235,6 @@ if(HAVE_BREAKPAD)
endif (LINUX)
endif(HAVE_BREAKPAD)
if(HAVE_SPOTIFY)
target_link_libraries(clementine_lib
clementine-spotifyblob-messages
)
endif(HAVE_SPOTIFY)
if(HAVE_SPOTIFY_DOWNLOADER)
target_link_libraries(clementine_lib
${QCA_LIBRARIES}
)
link_directories(${QCA_LIBRARY_DIRS})
endif(HAVE_SPOTIFY_DOWNLOADER)
if (APPLE)
target_link_libraries(clementine_lib
${GROWL}

View File

@ -39,8 +39,6 @@
#cmakedefine HAVE_QCA
#cmakedefine HAVE_SKYDRIVE
#cmakedefine HAVE_SPARKLE
#cmakedefine HAVE_SPOTIFY
#cmakedefine HAVE_SPOTIFY_DOWNLOADER
#cmakedefine HAVE_STATIC_SQLITE
#cmakedefine HAVE_UBUNTU_ONE
#cmakedefine HAVE_WIIMOTEDEV

View File

@ -30,10 +30,8 @@
#include "core/tagreaderclient.h"
#include "core/utilities.h"
#include "internet/internetmodel.h"
#include "internet/spotifyservice.h"
#ifdef HAVE_SPOTIFY
# include "internet/spotifyservice.h"
#endif
AlbumCoverLoader::AlbumCoverLoader(QObject* parent)
@ -173,28 +171,24 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
return TryLoadResult(true, false, QImage());
} else if (filename.toLower().startsWith("spotify://image/")) {
// HACK: we should add generic image URL handlers
#ifdef HAVE_SPOTIFY
SpotifyService* spotify = InternetModel::Service<SpotifyService>();
SpotifyService* spotify = InternetModel::Service<SpotifyService>();
if (!connected_spotify_) {
connect(spotify, SIGNAL(ImageLoaded(QString,QImage)),
SLOT(SpotifyImageLoaded(QString,QImage)));
connected_spotify_ = true;
}
if (!connected_spotify_) {
connect(spotify, SIGNAL(ImageLoaded(QString,QImage)),
SLOT(SpotifyImageLoaded(QString,QImage)));
connected_spotify_ = true;
}
QString id = QUrl(filename).path();
if (id.startsWith('/')) {
id.remove(0, 1);
}
remote_spotify_tasks_.insert(id, task);
QString id = QUrl(filename).path();
if (id.startsWith('/')) {
id.remove(0, 1);
}
remote_spotify_tasks_.insert(id, task);
// Need to schedule this in the spotify service's thread
QMetaObject::invokeMethod(spotify, "LoadImage", Qt::QueuedConnection,
Q_ARG(QString, id));
return TryLoadResult(true, false, QImage());
#else
return TryLoadResult(false, false, QImage());
#endif
// Need to schedule this in the spotify service's thread
QMetaObject::invokeMethod(spotify, "LoadImage", Qt::QueuedConnection,
Q_ARG(QString, id));
return TryLoadResult(true, false, QImage());
}
QImage image(filename);

View File

@ -29,11 +29,9 @@
#include "core/signalchecker.h"
#include "core/utilities.h"
#include "internet/internetmodel.h"
#include "internet/spotifyserver.h"
#include "internet/spotifyservice.h"
#ifdef HAVE_SPOTIFY
# include "internet/spotifyserver.h"
# include "internet/spotifyservice.h"
#endif
const int GstEnginePipeline::kGstStateTimeoutNanosecs = 10000000;
const int GstEnginePipeline::kFaderFudgeMsec = 2000;
@ -144,34 +142,29 @@ bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
GstElement* new_bin = NULL;
if (url.scheme() == "spotify") {
#ifdef HAVE_SPOTIFY
new_bin = gst_bin_new("spotify_bin");
new_bin = gst_bin_new("spotify_bin");
// Create elements
GstElement* src = engine_->CreateElement("tcpserversrc", new_bin);
GstElement* gdp = engine_->CreateElement("gdpdepay", new_bin);
if (!src || !gdp)
return false;
// Pick a port number
const int port = Utilities::PickUnusedPort();
g_object_set(G_OBJECT(src), "host", "127.0.0.1", NULL);
g_object_set(G_OBJECT(src), "port", port, NULL);
// Link the elements
gst_element_link(src, gdp);
// Add a ghost pad
GstPad* pad = gst_element_get_static_pad(gdp, "src");
gst_element_add_pad(GST_ELEMENT(new_bin), gst_ghost_pad_new("src", pad));
gst_object_unref(GST_OBJECT(pad));
// Tell spotify to start sending data to us.
InternetModel::Service<SpotifyService>()->server()->StartPlaybackLater(url.toString(), port);
#else // HAVE_SPOTIFY
qLog(Error) << "Tried to play a spotify:// url, but spotify support is not compiled in";
// Create elements
GstElement* src = engine_->CreateElement("tcpserversrc", new_bin);
GstElement* gdp = engine_->CreateElement("gdpdepay", new_bin);
if (!src || !gdp)
return false;
#endif
// Pick a port number
const int port = Utilities::PickUnusedPort();
g_object_set(G_OBJECT(src), "host", "127.0.0.1", NULL);
g_object_set(G_OBJECT(src), "port", port, NULL);
// Link the elements
gst_element_link(src, gdp);
// Add a ghost pad
GstPad* pad = gst_element_get_static_pad(gdp, "src");
gst_element_add_pad(GST_ELEMENT(new_bin), gst_ghost_pad_new("src", pad));
gst_object_unref(GST_OBJECT(pad));
// Tell spotify to start sending data to us.
InternetModel::Service<SpotifyService>()->server()->StartPlaybackLater(url.toString(), port);
} else {
new_bin = engine_->CreateElement("uridecodebin");
g_object_set(G_OBJECT(new_bin), "uri", url.toEncoded().constData(), NULL);

View File

@ -23,14 +23,14 @@
#include "digitallyimportedservicebase.h"
#include "groovesharkservice.h"
#include "icecastservice.h"
#include "jamendoservice.h"
#include "magnatuneservice.h"
#include "internetmimedata.h"
#include "internetservice.h"
#include "jamendoservice.h"
#include "magnatuneservice.h"
#include "savedradio.h"
#include "somafmservice.h"
#include "groovesharkservice.h"
#include "soundcloudservice.h"
#include "spotifyservice.h"
#include "subsonicservice.h"
#include "core/closure.h"
#include "core/logging.h"
@ -41,9 +41,6 @@
#ifdef HAVE_LIBLASTFM
#include "lastfmservice.h"
#endif
#ifdef HAVE_SPOTIFY
#include "spotifyservice.h"
#endif
#ifdef HAVE_GOOGLE_DRIVE
#include "googledriveservice.h"
#endif
@ -97,9 +94,7 @@ InternetModel::InternetModel(Application* app, QObject* parent)
AddService(new SkyFmService(app, this));
AddService(new SomaFMService(app, this));
AddService(new SoundCloudService(app, this));
#ifdef HAVE_SPOTIFY
AddService(new SpotifyService(app, this));
#endif
AddService(new SubsonicService(app, this));
#ifdef HAVE_UBUNTU_ONE
AddService(new UbuntuOneService(app, this));

View File

@ -2,6 +2,7 @@
#include "config.h"
#include "internetmodel.h"
#include "searchboxwidget.h"
#include "spotifyblobdownloader.h"
#include "spotifyserver.h"
#include "spotifyservice.h"
#include "core/application.h"
@ -30,9 +31,6 @@
#include <QSettings>
#include <QVariant>
#ifdef HAVE_SPOTIFY_DOWNLOADER
#include "spotifyblobdownloader.h"
#endif
Q_DECLARE_METATYPE(QStandardItem*);
@ -292,11 +290,9 @@ void SpotifyService::StartBlobProcess() {
app_->task_manager()->SetTaskFinished(login_task_id_);
}
#ifdef HAVE_SPOTIFY_DOWNLOADER
if (SpotifyBlobDownloader::Prompt()) {
InstallBlob();
}
#endif
if (SpotifyBlobDownloader::Prompt()) {
InstallBlob();
}
return;
}
@ -321,14 +317,12 @@ bool SpotifyService::IsBlobInstalled() const {
}
void SpotifyService::InstallBlob() {
#ifdef HAVE_SPOTIFY_DOWNLOADER
// The downloader deletes itself when it finishes
SpotifyBlobDownloader* downloader = new SpotifyBlobDownloader(
local_blob_version_, QFileInfo(local_blob_path_).path(), this);
connect(downloader, SIGNAL(Finished()), SLOT(BlobDownloadFinished()));
connect(downloader, SIGNAL(Finished()), SIGNAL(BlobStateChanged()));
downloader->Start();
#endif // HAVE_SPOTIFY_DOWNLOADER
}
void SpotifyService::BlobDownloadFinished() {

View File

@ -73,12 +73,7 @@ void SpotifySettingsPage::BlobStateChanged() {
ui_->account_group->setEnabled(installed);
ui_->blob_status->setText(installed ? tr("Installed") : tr("Not installed"));
#ifdef HAVE_SPOTIFY_DOWNLOADER
ui_->download_blob->setEnabled(!installed);
#else
ui_->download_blob->hide();
#endif
}
void SpotifySettingsPage::DownloadBlob() {

View File

@ -63,6 +63,7 @@
#include <QTextCodec>
#include <QTranslator>
#include <QtConcurrentRun>
#include <QtCrypto>
#include <QtDebug>
#include <glib-object.h>
@ -74,9 +75,6 @@ using boost::scoped_ptr;
#include <echonest/Config.h>
#ifdef HAVE_SPOTIFY_DOWNLOADER
#include <QtCrypto>
#endif
#ifdef Q_OS_DARWIN
#include <sys/resource.h>
@ -358,9 +356,7 @@ int main(int argc, char *argv[]) {
}
#endif
#ifdef HAVE_SPOTIFY_DOWNLOADER
QCA::Initializer qca_initializer;
#endif
// Resources
Q_INIT_RESOURCE(data);

View File

@ -80,11 +80,9 @@ QString About::MakeHtml() const {
ret += QString("<br /><a href=\"http://www.smitelli.com/?page=blog&p=54\">Scott Smitelli</a>");
ret += QString("<br /><a href=\"http://hyperboleandahalf.blogspot.com\">Allie Brosh</a></p>");
#ifdef HAVE_SPOTIFY
ret += "<p>This product uses Music by Spotify but is not endorsed, certified "
"or otherwise approved in any way by Spotify. Spotify is the registered "
"trade mark of the Spotify Group.</p>";
#endif // HAVE_SPOTIFY
return ret;
}

View File

@ -38,6 +38,7 @@
#include "internet/digitallyimportedsettingspage.h"
#include "internet/groovesharksettingspage.h"
#include "internet/magnatunesettingspage.h"
#include "internet/spotifysettingspage.h"
#include "internet/subsonicsettingspage.h"
#include "internet/ubuntuonesettingspage.h"
#include "library/librarysettingspage.h"
@ -58,9 +59,6 @@
# include "wiimotedev/wiimotesettingspage.h"
#endif
#ifdef HAVE_SPOTIFY
# include "internet/spotifysettingspage.h"
#endif
#ifdef HAVE_GOOGLE_DRIVE
# include "internet/googledrivesettingspage.h"
@ -176,10 +174,7 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams, QWi
AddPage(Page_Box, new BoxSettingsPage(this), providers);
#endif
#ifdef HAVE_SPOTIFY
AddPage(Page_Spotify, new SpotifySettingsPage(this), providers);
#endif
AddPage(Page_Magnatune, new MagnatuneSettingsPage(this), providers);
AddPage(Page_DigitallyImported, new DigitallyImportedSettingsPage(this), providers);
AddPage(Page_BackgroundStreams, new BackgroundStreamsSettingsPage(this), providers);