From 65b8e147ed58bda3b32f79e8d921c25096186bb8 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 18 Sep 2013 01:09:56 +1000 Subject: [PATCH] Make the Spotify downloader optional again on Windows and Mac (cherry picked from commit 4e8dba16d452c5ba7825fd32f0fa62351f4fe862) --- CMakeLists.txt | 8 +++++++- src/CMakeLists.txt | 24 +++++++++++++++++------- src/config.h.in | 1 + src/internet/spotifyservice.cpp | 14 ++++++++++---- src/internet/spotifysettingspage.cpp | 5 +++++ src/main.cpp | 6 +++++- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3b444a8b..8ba5a8a56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 REQUIRED qca2) +pkg_check_modules(QCA qca2) pkg_check_modules(QJSON REQUIRED QJson) pkg_check_modules(SPOTIFY libspotify>=12.1.45) pkg_check_modules(TAGLIB REQUIRED taglib>=1.6) @@ -270,6 +270,12 @@ optional_component(SPARKLE ON "Sparkle integration" optional_component(VISUALISATIONS ON "Visualisations") +if(NOT HAVE_SPOTIFY_BLOB AND NOT QCA_FOUND) + message(FATAL_ERROR "Either QCA must be available or the non-GPL Spotify " + "code must be compiled in") +elif(QCA_FOUND) + set(HAVE_SPOTIFY_DOWNLOADER ON) +endif() # Find DBus if it's enabled if (HAVE_DBUS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff4486392..289bbb6fe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,8 +10,6 @@ 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) @@ -40,7 +38,6 @@ 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}) @@ -198,7 +195,6 @@ set(SOURCES internet/somafmservice.cpp internet/somafmurlhandler.cpp internet/soundcloudservice.cpp - internet/spotifyblobdownloader.cpp internet/spotifyserver.cpp internet/spotifyservice.cpp internet/spotifysettingspage.cpp @@ -396,7 +392,6 @@ set(SOURCES widgets/tracksliderpopup.cpp widgets/tracksliderslider.cpp widgets/widgetfadehelper.cpp - ) set(HEADERS @@ -498,7 +493,6 @@ set(HEADERS internet/somafmservice.h internet/somafmurlhandler.h internet/soundcloudservice.h - internet/spotifyblobdownloader.h internet/spotifyserver.h internet/spotifyservice.h internet/spotifysettingspage.h @@ -839,6 +833,16 @@ optional_source(HAVE_LIBLASTFM internet/lastfmstationdialog.ui ) + +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 @@ -1186,7 +1190,6 @@ target_link_libraries(clementine_lib ${QTSINGLECOREAPPLICATION_LIBRARIES} ${QTIOCOMPRESSOR_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} - ${QCA_LIBRARIES} z Qocoa ) @@ -1235,6 +1238,13 @@ if(HAVE_BREAKPAD) endif (LINUX) endif(HAVE_BREAKPAD) +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} diff --git a/src/config.h.in b/src/config.h.in index 90e4ee22d..6cac97ec7 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -39,6 +39,7 @@ #cmakedefine HAVE_QCA #cmakedefine HAVE_SKYDRIVE #cmakedefine HAVE_SPARKLE +#cmakedefine HAVE_SPOTIFY_DOWNLOADER #cmakedefine HAVE_STATIC_SQLITE #cmakedefine HAVE_UBUNTU_ONE #cmakedefine HAVE_WIIMOTEDEV diff --git a/src/internet/spotifyservice.cpp b/src/internet/spotifyservice.cpp index c8a6b1e15..543744ed3 100644 --- a/src/internet/spotifyservice.cpp +++ b/src/internet/spotifyservice.cpp @@ -2,7 +2,6 @@ #include "config.h" #include "internetmodel.h" #include "searchboxwidget.h" -#include "spotifyblobdownloader.h" #include "spotifyserver.h" #include "spotifyservice.h" #include "core/application.h" @@ -31,6 +30,9 @@ #include #include +#ifdef HAVE_SPOTIFY_DOWNLOADER +#include "spotifyblobdownloader.h" +#endif Q_DECLARE_METATYPE(QStandardItem*); @@ -290,9 +292,11 @@ void SpotifyService::StartBlobProcess() { app_->task_manager()->SetTaskFinished(login_task_id_); } - if (SpotifyBlobDownloader::Prompt()) { - InstallBlob(); - } + #ifdef HAVE_SPOTIFY_DOWNLOADER + if (SpotifyBlobDownloader::Prompt()) { + InstallBlob(); + } + #endif return; } @@ -317,12 +321,14 @@ 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() { diff --git a/src/internet/spotifysettingspage.cpp b/src/internet/spotifysettingspage.cpp index 94f663982..f1a73bfa7 100644 --- a/src/internet/spotifysettingspage.cpp +++ b/src/internet/spotifysettingspage.cpp @@ -73,7 +73,12 @@ 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() { diff --git a/src/main.cpp b/src/main.cpp index ad7b91451..43db7d2b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,7 +63,6 @@ #include #include #include -#include #include #include @@ -75,6 +74,9 @@ using boost::scoped_ptr; #include +#ifdef HAVE_SPOTIFY_DOWNLOADER + #include +#endif #ifdef Q_OS_DARWIN #include @@ -356,7 +358,9 @@ int main(int argc, char *argv[]) { } #endif +#ifdef HAVE_SPOTIFY_DOWNLOADER QCA::Initializer qca_initializer; +#endif // Resources Q_INIT_RESOURCE(data);