Separate out spotify blob downloader into a new optional component.

This commit is contained in:
John Maguire 2012-09-03 17:35:43 +02:00
parent a73e3a4122
commit 27975c7a16
6 changed files with 39 additions and 19 deletions

View File

@ -224,23 +224,26 @@ 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
)
optional_component(SPOTIFY ON "Spotify support: core code"
DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE
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
)
# If we're building the spotify blob then we don't need qca2 for the core code
if(HAVE_SPOTIFY_BLOB)
set(QCA_FOUND ON)
elseif(QCA_FOUND AND HAVE_SPOTIFY)
set(HAVE_QCA ON)
endif()
optional_component(MOODBAR ON "Moodbar support"
DEPENDS "fftw3" FFTW3_FOUND
)

View File

@ -778,13 +778,11 @@ optional_source(HAVE_LIBLASTFM
optional_source(HAVE_SPOTIFY
SOURCES
globalsearch/spotifysearchprovider.cpp
internet/spotifyblobdownloader.cpp
internet/spotifyserver.cpp
internet/spotifyservice.cpp
internet/spotifysettingspage.cpp
HEADERS
globalsearch/spotifysearchprovider.h
internet/spotifyblobdownloader.h
internet/spotifyserver.h
internet/spotifyservice.h
internet/spotifysettingspage.h
@ -793,7 +791,14 @@ optional_source(HAVE_SPOTIFY
${CMAKE_BINARY_DIR}/ext/libclementine-spotifyblob
)
optional_source(HAVE_QCA INCLUDE_DIRECTORIES ${QCA_INCLUDE_DIRS})
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
@ -1139,10 +1144,15 @@ 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)
endif(HAVE_SPOTIFY_DOWNLOADER)
if (APPLE)
target_link_libraries(clementine_lib

View File

@ -39,6 +39,7 @@
#cmakedefine HAVE_SAC
#cmakedefine HAVE_SPARKLE
#cmakedefine HAVE_SPOTIFY
#cmakedefine HAVE_SPOTIFY_DOWNLOADER
#cmakedefine HAVE_STATIC_SQLITE
#cmakedefine HAVE_WIIMOTEDEV
#cmakedefine IMOBILEDEVICE_USES_UDIDS

View File

@ -1,7 +1,6 @@
#include "blobversion.h"
#include "config.h"
#include "internetmodel.h"
#include "spotifyblobdownloader.h"
#include "spotifyserver.h"
#include "spotifyservice.h"
#include "core/application.h"
@ -32,6 +31,10 @@
#include <QSettings>
#include <QVariant>
#ifdef HAVE_SPOTIFY_DOWNLOADER
#include "spotifyblobdownloader.h"
#endif
Q_DECLARE_METATYPE(QStandardItem*);
const char* SpotifyService::kServiceName = "Spotify";
@ -290,7 +293,7 @@ void SpotifyService::StartBlobProcess() {
app_->task_manager()->SetTaskFinished(login_task_id_);
}
#ifdef Q_OS_LINUX
#ifdef HAVE_SPOTIFY_DOWNLOADER
if (SpotifyBlobDownloader::Prompt()) {
InstallBlob();
}
@ -319,12 +322,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() {

View File

@ -17,6 +17,7 @@
#include "spotifysettingspage.h"
#include "config.h"
#include "spotifymessages.pb.h"
#include "spotifyservice.h"
#include "internetmodel.h"
@ -73,10 +74,10 @@ void SpotifySettingsPage::BlobStateChanged() {
ui_->account_group->setEnabled(installed);
ui_->blob_status->setText(installed ? tr("Installed") : tr("Not installed"));
#ifdef Q_OS_LINUX
#ifdef HAVE_SPOTIFY_DOWNLOADER
ui_->download_blob->setEnabled(!installed);
#else
ui_->download_blob->setEnabled(false);
ui_->download_blob->hide();
#endif
}

View File

@ -71,7 +71,7 @@ using boost::scoped_ptr;
#include <echonest/Config.h>
#ifdef HAVE_QCA
#ifdef HAVE_SPOTIFY_DOWNLOADER
#include <QtCrypto>
#endif
@ -354,7 +354,7 @@ int main(int argc, char *argv[]) {
}
#endif
#ifdef HAVE_QCA
#ifdef HAVE_SPOTIFY_DOWNLOADER
QCA::Initializer qca_initializer;
#endif