Use a proper cache directory for spotify on windows and Linux.
This commit is contained in:
parent
e4c8eee7d9
commit
712745c605
@ -12,6 +12,7 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
spotifyclient.cpp
|
spotifyclient.cpp
|
||||||
|
spotify_utilities.cpp
|
||||||
|
|
||||||
${CMAKE_SOURCE_DIR}/src/core/logging.cpp
|
${CMAKE_SOURCE_DIR}/src/core/logging.cpp
|
||||||
)
|
)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
QCoreApplication::setApplicationName("Clementine");
|
||||||
|
|
||||||
logging::Init();
|
logging::Init();
|
||||||
|
|
||||||
|
32
spotifyblob/blob/spotify_utilities.cpp
Normal file
32
spotifyblob/blob/spotify_utilities.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "spotify_utilities.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
namespace utilities {
|
||||||
|
|
||||||
|
QString GetUserCacheDirectory() {
|
||||||
|
#ifndef Q_OS_WINDOWS
|
||||||
|
const char* xdg_cache_dir = getenv("XDG_CACHE_HOME");
|
||||||
|
if (!xdg_cache_dir) {
|
||||||
|
return QDir::homePath() + "/.config";
|
||||||
|
}
|
||||||
|
return QString::fromLocal8Bit(xdg_cache_dir);
|
||||||
|
|
||||||
|
#else
|
||||||
|
const char* cache_dir = getenv("APPDATA");
|
||||||
|
if (!cache_dir) {
|
||||||
|
return QDir::homePath() + "/.config/";
|
||||||
|
}
|
||||||
|
return QDir::fromNativeSeparators(QString::fromLocal8Bit(cache_dir));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GetCacheDirectory() {
|
||||||
|
QString user_cache = GetUserCacheDirectory();
|
||||||
|
return user_cache + "/" + QCoreApplication::applicationName() + "/spotify-cache";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace utilities
|
12
spotifyblob/blob/spotify_utilities.h
Normal file
12
spotifyblob/blob/spotify_utilities.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef SPOTIFY_UTILITIES_H
|
||||||
|
#define SPOTIFY_UTILITIES_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace utilities {
|
||||||
|
|
||||||
|
QString GetCacheDirectory();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -23,6 +23,7 @@
|
|||||||
#include "spotifykey.h"
|
#include "spotifykey.h"
|
||||||
#include "spotifymessagehandler.h"
|
#include "spotifymessagehandler.h"
|
||||||
#include "spotifymessages.pb.h"
|
#include "spotifymessages.pb.h"
|
||||||
|
#include "spotify_utilities.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -67,8 +68,11 @@ SpotifyClient::SpotifyClient(QObject* parent)
|
|||||||
|
|
||||||
load_playlist_callbacks_.playlist_state_changed = &PlaylistStateChangedForLoadPlaylist;
|
load_playlist_callbacks_.playlist_state_changed = &PlaylistStateChangedForLoadPlaylist;
|
||||||
|
|
||||||
|
QString cache = utilities::GetCacheDirectory();
|
||||||
|
qLog(Debug) << "Using:" << cache << "for Spotify cache";
|
||||||
|
|
||||||
spotify_config_.api_version = SPOTIFY_API_VERSION; // From libspotify/api.h
|
spotify_config_.api_version = SPOTIFY_API_VERSION; // From libspotify/api.h
|
||||||
spotify_config_.cache_location = strdup(QDir::tempPath().toLocal8Bit().constData());
|
spotify_config_.cache_location = strdup(cache.toLocal8Bit().constData());
|
||||||
spotify_config_.settings_location = strdup(QDir::tempPath().toLocal8Bit().constData());
|
spotify_config_.settings_location = strdup(QDir::tempPath().toLocal8Bit().constData());
|
||||||
spotify_config_.application_key = api_key_.constData();
|
spotify_config_.application_key = api_key_.constData();
|
||||||
spotify_config_.application_key_size = api_key_.size();
|
spotify_config_.application_key_size = api_key_.size();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user