Compare commits
14 Commits
copilot/fi
...
cloud_stor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c57c923d9 | ||
|
|
da2f28811a | ||
|
|
0bfa736081 | ||
|
|
1392bcbbe1 | ||
|
|
11705889f1 | ||
|
|
604dd2dbde | ||
|
|
25065ba98f | ||
|
|
7b16ec62bb | ||
|
|
d8f31592b9 | ||
|
|
80bb0f476d | ||
|
|
b7222ac85c | ||
|
|
241bca0828 | ||
|
|
90d86b10a3 | ||
|
|
4130c6670f |
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -739,12 +739,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
- name: Free disk space
|
||||||
|
run: |
|
||||||
|
df -h
|
||||||
|
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||||
|
sudo apt-get clean
|
||||||
|
df -h
|
||||||
- name: Build FreeBSD
|
- name: Build FreeBSD
|
||||||
id: build-freebsd
|
id: build-freebsd
|
||||||
uses: vmactions/freebsd-vm@v1.3.0
|
uses: vmactions/freebsd-vm@v1.3.2
|
||||||
with:
|
with:
|
||||||
usesh: true
|
usesh: true
|
||||||
mem: 4096
|
mem: 8192
|
||||||
prepare: pkg install -y git cmake pkgconf boost-libs alsa-lib glib qt6-base qt6-tools sqlite gstreamer1 gstreamer1-plugins chromaprint libebur128 taglib libcdio libmtp gdk-pixbuf2 libgpod fftw3 icu kdsingleapplication googletest pulseaudio sparsehash rapidjson
|
prepare: pkg install -y git cmake pkgconf boost-libs alsa-lib glib qt6-base qt6-tools sqlite gstreamer1 gstreamer1-plugins chromaprint libebur128 taglib libcdio libmtp gdk-pixbuf2 libgpod fftw3 icu kdsingleapplication googletest pulseaudio sparsehash rapidjson
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -766,7 +772,7 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
- name: Build OpenBSD
|
- name: Build OpenBSD
|
||||||
id: build-openbsd
|
id: build-openbsd
|
||||||
uses: vmactions/openbsd-vm@v1.2.5
|
uses: vmactions/openbsd-vm@v1.2.9
|
||||||
with:
|
with:
|
||||||
usesh: true
|
usesh: true
|
||||||
mem: 4096
|
mem: 4096
|
||||||
|
|||||||
@@ -379,6 +379,13 @@ optional_component(STREAMTAGREADER ON "Stream tagreader"
|
|||||||
|
|
||||||
optional_component(DISCORD_RPC ON "Discord Rich Presence"
|
optional_component(DISCORD_RPC ON "Discord Rich Presence"
|
||||||
DEPENDS "RapidJSON" RapidJSON_FOUND
|
DEPENDS "RapidJSON" RapidJSON_FOUND
|
||||||
|
|
||||||
|
optional_component(DROPBOX ON "Streaming: Dropbox"
|
||||||
|
DEPENDS "Stream tagreader" HAVE_STREAMTAGREADER
|
||||||
|
)
|
||||||
|
|
||||||
|
optional_component(ONEDRIVE ON "Streaming: OneDrive"
|
||||||
|
DEPENDS "Stream tagreader" HAVE_STREAMTAGREADER
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
|
if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
|
||||||
@@ -776,6 +783,7 @@ set(SOURCES
|
|||||||
src/streaming/streamingcollectionviewcontainer.cpp
|
src/streaming/streamingcollectionviewcontainer.cpp
|
||||||
src/streaming/streamingsearchview.cpp
|
src/streaming/streamingsearchview.cpp
|
||||||
src/streaming/streamsongmimedata.cpp
|
src/streaming/streamsongmimedata.cpp
|
||||||
|
src/streaming/cloudstoragestreamingservice.cpp
|
||||||
|
|
||||||
src/radios/radioservices.cpp
|
src/radios/radioservices.cpp
|
||||||
src/radios/radiobackend.cpp
|
src/radios/radiobackend.cpp
|
||||||
@@ -1072,6 +1080,7 @@ set(HEADERS
|
|||||||
src/streaming/streamingtabsview.h
|
src/streaming/streamingtabsview.h
|
||||||
src/streaming/streamingcollectionview.h
|
src/streaming/streamingcollectionview.h
|
||||||
src/streaming/streamingcollectionviewcontainer.h
|
src/streaming/streamingcollectionviewcontainer.h
|
||||||
|
src/streaming/cloudstoragestreamingservice.h
|
||||||
|
|
||||||
src/radios/radioservices.h
|
src/radios/radioservices.h
|
||||||
src/radios/radiobackend.h
|
src/radios/radiobackend.h
|
||||||
@@ -1480,6 +1489,25 @@ optional_source(HAVE_QOBUZ
|
|||||||
src/settings/qobuzsettingspage.ui
|
src/settings/qobuzsettingspage.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
optional_source(HAVE_DROPBOX
|
||||||
|
SOURCES
|
||||||
|
src/dropbox/dropboxservice.cpp
|
||||||
|
src/dropbox/dropboxurlhandler.cpp
|
||||||
|
src/dropbox/dropboxbaserequest.cpp
|
||||||
|
src/dropbox/dropboxsongsrequest.cpp
|
||||||
|
src/dropbox/dropboxstreamurlrequest.cpp
|
||||||
|
src/settings/dropboxsettingspage.cpp
|
||||||
|
HEADERS
|
||||||
|
src/dropbox/dropboxservice.h
|
||||||
|
src/dropbox/dropboxurlhandler.h
|
||||||
|
src/dropbox/dropboxbaserequest.h
|
||||||
|
src/dropbox/dropboxsongsrequest.h
|
||||||
|
src/dropbox/dropboxstreamurlrequest.h
|
||||||
|
src/settings/dropboxsettingspage.h
|
||||||
|
UI
|
||||||
|
src/settings/dropboxsettingspage.ui
|
||||||
|
)
|
||||||
|
|
||||||
qt_wrap_cpp(SOURCES ${HEADERS})
|
qt_wrap_cpp(SOURCES ${HEADERS})
|
||||||
qt_wrap_ui(SOURCES ${UI})
|
qt_wrap_ui(SOURCES ${UI})
|
||||||
qt_add_resources(SOURCES data/data.qrc data/icons.qrc)
|
qt_add_resources(SOURCES data/data.qrc data/icons.qrc)
|
||||||
|
|||||||
@@ -98,6 +98,7 @@
|
|||||||
<file>icons/128x128/somafm.png</file>
|
<file>icons/128x128/somafm.png</file>
|
||||||
<file>icons/128x128/radioparadise.png</file>
|
<file>icons/128x128/radioparadise.png</file>
|
||||||
<file>icons/128x128/musicbrainz.png</file>
|
<file>icons/128x128/musicbrainz.png</file>
|
||||||
|
<file>icons/128x128/dropbox.png</file>
|
||||||
<file>icons/64x64/albums.png</file>
|
<file>icons/64x64/albums.png</file>
|
||||||
<file>icons/64x64/alsa.png</file>
|
<file>icons/64x64/alsa.png</file>
|
||||||
<file>icons/64x64/application-exit.png</file>
|
<file>icons/64x64/application-exit.png</file>
|
||||||
@@ -197,6 +198,7 @@
|
|||||||
<file>icons/64x64/somafm.png</file>
|
<file>icons/64x64/somafm.png</file>
|
||||||
<file>icons/64x64/radioparadise.png</file>
|
<file>icons/64x64/radioparadise.png</file>
|
||||||
<file>icons/64x64/musicbrainz.png</file>
|
<file>icons/64x64/musicbrainz.png</file>
|
||||||
|
<file>icons/64x64/dropbox.png</file>
|
||||||
<file>icons/48x48/albums.png</file>
|
<file>icons/48x48/albums.png</file>
|
||||||
<file>icons/48x48/alsa.png</file>
|
<file>icons/48x48/alsa.png</file>
|
||||||
<file>icons/48x48/application-exit.png</file>
|
<file>icons/48x48/application-exit.png</file>
|
||||||
@@ -300,6 +302,7 @@
|
|||||||
<file>icons/48x48/somafm.png</file>
|
<file>icons/48x48/somafm.png</file>
|
||||||
<file>icons/48x48/radioparadise.png</file>
|
<file>icons/48x48/radioparadise.png</file>
|
||||||
<file>icons/48x48/musicbrainz.png</file>
|
<file>icons/48x48/musicbrainz.png</file>
|
||||||
|
<file>icons/48x48/dropbox.png</file>
|
||||||
<file>icons/32x32/albums.png</file>
|
<file>icons/32x32/albums.png</file>
|
||||||
<file>icons/32x32/alsa.png</file>
|
<file>icons/32x32/alsa.png</file>
|
||||||
<file>icons/32x32/application-exit.png</file>
|
<file>icons/32x32/application-exit.png</file>
|
||||||
@@ -403,6 +406,7 @@
|
|||||||
<file>icons/32x32/somafm.png</file>
|
<file>icons/32x32/somafm.png</file>
|
||||||
<file>icons/32x32/radioparadise.png</file>
|
<file>icons/32x32/radioparadise.png</file>
|
||||||
<file>icons/32x32/musicbrainz.png</file>
|
<file>icons/32x32/musicbrainz.png</file>
|
||||||
|
<file>icons/32x32/dropbox.png</file>
|
||||||
<file>icons/22x22/albums.png</file>
|
<file>icons/22x22/albums.png</file>
|
||||||
<file>icons/22x22/alsa.png</file>
|
<file>icons/22x22/alsa.png</file>
|
||||||
<file>icons/22x22/application-exit.png</file>
|
<file>icons/22x22/application-exit.png</file>
|
||||||
@@ -506,5 +510,6 @@
|
|||||||
<file>icons/22x22/somafm.png</file>
|
<file>icons/22x22/somafm.png</file>
|
||||||
<file>icons/22x22/radioparadise.png</file>
|
<file>icons/22x22/radioparadise.png</file>
|
||||||
<file>icons/22x22/musicbrainz.png</file>
|
<file>icons/22x22/musicbrainz.png</file>
|
||||||
|
<file>icons/22x22/dropbox.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
data/icons/128x128/dropbox.png
Normal file
BIN
data/icons/128x128/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/22x22/dropbox.png
Normal file
BIN
data/icons/22x22/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 638 B |
BIN
data/icons/32x32/dropbox.png
Normal file
BIN
data/icons/32x32/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 746 B |
BIN
data/icons/48x48/dropbox.png
Normal file
BIN
data/icons/48x48/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1011 B |
BIN
data/icons/64x64/dropbox.png
Normal file
BIN
data/icons/64x64/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
data/icons/full/dropbox.png
Normal file
BIN
data/icons/full/dropbox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
82
data/schema/schema-22.sql
Normal file
82
data/schema/schema-22.sql
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS dropbox_songs (
|
||||||
|
|
||||||
|
title TEXT,
|
||||||
|
album TEXT,
|
||||||
|
artist TEXT,
|
||||||
|
albumartist TEXT,
|
||||||
|
track INTEGER NOT NULL DEFAULT -1,
|
||||||
|
disc INTEGER NOT NULL DEFAULT -1,
|
||||||
|
year INTEGER NOT NULL DEFAULT -1,
|
||||||
|
originalyear INTEGER NOT NULL DEFAULT -1,
|
||||||
|
genre TEXT,
|
||||||
|
compilation INTEGER NOT NULL DEFAULT 0,
|
||||||
|
composer TEXT,
|
||||||
|
performer TEXT,
|
||||||
|
grouping TEXT,
|
||||||
|
comment TEXT,
|
||||||
|
lyrics TEXT,
|
||||||
|
|
||||||
|
artist_id TEXT,
|
||||||
|
album_id TEXT,
|
||||||
|
song_id TEXT,
|
||||||
|
|
||||||
|
beginning INTEGER NOT NULL DEFAULT 0,
|
||||||
|
length INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
bitrate INTEGER NOT NULL DEFAULT -1,
|
||||||
|
samplerate INTEGER NOT NULL DEFAULT -1,
|
||||||
|
bitdepth INTEGER NOT NULL DEFAULT -1,
|
||||||
|
|
||||||
|
source INTEGER NOT NULL DEFAULT 0,
|
||||||
|
directory_id INTEGER NOT NULL DEFAULT -1,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
filetype INTEGER NOT NULL DEFAULT 0,
|
||||||
|
filesize INTEGER NOT NULL DEFAULT -1,
|
||||||
|
mtime INTEGER NOT NULL DEFAULT -1,
|
||||||
|
ctime INTEGER NOT NULL DEFAULT -1,
|
||||||
|
unavailable INTEGER DEFAULT 0,
|
||||||
|
|
||||||
|
fingerprint TEXT,
|
||||||
|
|
||||||
|
playcount INTEGER NOT NULL DEFAULT 0,
|
||||||
|
skipcount INTEGER NOT NULL DEFAULT 0,
|
||||||
|
lastplayed INTEGER NOT NULL DEFAULT -1,
|
||||||
|
lastseen INTEGER NOT NULL DEFAULT -1,
|
||||||
|
|
||||||
|
compilation_detected INTEGER DEFAULT 0,
|
||||||
|
compilation_on INTEGER NOT NULL DEFAULT 0,
|
||||||
|
compilation_off INTEGER NOT NULL DEFAULT 0,
|
||||||
|
compilation_effective INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
art_embedded INTEGER DEFAULT 0,
|
||||||
|
art_automatic TEXT,
|
||||||
|
art_manual TEXT,
|
||||||
|
art_unset INTEGER DEFAULT 0,
|
||||||
|
|
||||||
|
effective_albumartist TEXT,
|
||||||
|
effective_originalyear INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
cue_path TEXT,
|
||||||
|
|
||||||
|
rating INTEGER DEFAULT -1,
|
||||||
|
|
||||||
|
acoustid_id TEXT,
|
||||||
|
acoustid_fingerprint TEXT,
|
||||||
|
|
||||||
|
musicbrainz_album_artist_id TEXT,
|
||||||
|
musicbrainz_artist_id TEXT,
|
||||||
|
musicbrainz_original_artist_id TEXT,
|
||||||
|
musicbrainz_album_id TEXT,
|
||||||
|
musicbrainz_original_album_id TEXT,
|
||||||
|
musicbrainz_recording_id TEXT,
|
||||||
|
musicbrainz_track_id TEXT,
|
||||||
|
musicbrainz_disc_id TEXT,
|
||||||
|
musicbrainz_release_group_id TEXT,
|
||||||
|
musicbrainz_work_id TEXT,
|
||||||
|
|
||||||
|
ebur128_integrated_loudness_lufs REAL,
|
||||||
|
ebur128_loudness_range_lu REAL
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE schema_version SET version=22;
|
||||||
@@ -1018,6 +1018,87 @@ CREATE TABLE IF NOT EXISTS qobuz_songs (
|
|||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS dropbox_songs (
|
||||||
|
|
||||||
|
title TEXT,
|
||||||
|
album TEXT,
|
||||||
|
artist TEXT,
|
||||||
|
albumartist TEXT,
|
||||||
|
track INTEGER NOT NULL DEFAULT -1,
|
||||||
|
disc INTEGER NOT NULL DEFAULT -1,
|
||||||
|
year INTEGER NOT NULL DEFAULT -1,
|
||||||
|
originalyear INTEGER NOT NULL DEFAULT -1,
|
||||||
|
genre TEXT,
|
||||||
|
compilation INTEGER NOT NULL DEFAULT 0,
|
||||||
|
composer TEXT,
|
||||||
|
performer TEXT,
|
||||||
|
grouping TEXT,
|
||||||
|
comment TEXT,
|
||||||
|
lyrics TEXT,
|
||||||
|
|
||||||
|
artist_id TEXT,
|
||||||
|
album_id TEXT,
|
||||||
|
song_id TEXT,
|
||||||
|
|
||||||
|
beginning INTEGER NOT NULL DEFAULT 0,
|
||||||
|
length INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
bitrate INTEGER NOT NULL DEFAULT -1,
|
||||||
|
samplerate INTEGER NOT NULL DEFAULT -1,
|
||||||
|
bitdepth INTEGER NOT NULL DEFAULT -1,
|
||||||
|
|
||||||
|
source INTEGER NOT NULL DEFAULT 0,
|
||||||
|
directory_id INTEGER NOT NULL DEFAULT -1,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
filetype INTEGER NOT NULL DEFAULT 0,
|
||||||
|
filesize INTEGER NOT NULL DEFAULT -1,
|
||||||
|
mtime INTEGER NOT NULL DEFAULT -1,
|
||||||
|
ctime INTEGER NOT NULL DEFAULT -1,
|
||||||
|
unavailable INTEGER DEFAULT 0,
|
||||||
|
|
||||||
|
fingerprint TEXT,
|
||||||
|
|
||||||
|
playcount INTEGER NOT NULL DEFAULT 0,
|
||||||
|
skipcount INTEGER NOT NULL DEFAULT 0,
|
||||||
|
lastplayed INTEGER NOT NULL DEFAULT -1,
|
||||||
|
lastseen INTEGER NOT NULL DEFAULT -1,
|
||||||
|
|
||||||
|
compilation_detected INTEGER DEFAULT 0,
|
||||||
|
compilation_on INTEGER NOT NULL DEFAULT 0,
|
||||||
|
compilation_off INTEGER NOT NULL DEFAULT 0,
|
||||||
|
compilation_effective INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
art_embedded INTEGER DEFAULT 0,
|
||||||
|
art_automatic TEXT,
|
||||||
|
art_manual TEXT,
|
||||||
|
art_unset INTEGER DEFAULT 0,
|
||||||
|
|
||||||
|
effective_albumartist TEXT,
|
||||||
|
effective_originalyear INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
cue_path TEXT,
|
||||||
|
|
||||||
|
rating INTEGER DEFAULT -1,
|
||||||
|
|
||||||
|
acoustid_id TEXT,
|
||||||
|
acoustid_fingerprint TEXT,
|
||||||
|
|
||||||
|
musicbrainz_album_artist_id TEXT,
|
||||||
|
musicbrainz_artist_id TEXT,
|
||||||
|
musicbrainz_original_artist_id TEXT,
|
||||||
|
musicbrainz_album_id TEXT,
|
||||||
|
musicbrainz_original_album_id TEXT,
|
||||||
|
musicbrainz_recording_id TEXT,
|
||||||
|
musicbrainz_track_id TEXT,
|
||||||
|
musicbrainz_disc_id TEXT,
|
||||||
|
musicbrainz_release_group_id TEXT,
|
||||||
|
musicbrainz_work_id TEXT,
|
||||||
|
|
||||||
|
ebur128_integrated_loudness_lufs REAL,
|
||||||
|
ebur128_loudness_range_lu REAL
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS playlists (
|
CREATE TABLE IF NOT EXISTS playlists (
|
||||||
|
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -189,6 +189,26 @@ void CollectionLibrary::ReloadSettings() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CollectionLibrary::CurrentSongChanged(const Song &song) {
|
||||||
|
|
||||||
|
current_song_url_ = song.url();
|
||||||
|
|
||||||
|
if (!pending_song_saves_.isEmpty()) {
|
||||||
|
SavePendingPlaycountsAndRatings();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CollectionLibrary::Stopped() {
|
||||||
|
|
||||||
|
current_song_url_ = QUrl();
|
||||||
|
|
||||||
|
if (!pending_song_saves_.isEmpty()) {
|
||||||
|
SavePendingPlaycountsAndRatings();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CollectionLibrary::SyncPlaycountAndRatingToFilesAsync() {
|
void CollectionLibrary::SyncPlaycountAndRatingToFilesAsync() {
|
||||||
|
|
||||||
(void)QtConcurrent::run(&CollectionLibrary::SyncPlaycountAndRatingToFiles, this);
|
(void)QtConcurrent::run(&CollectionLibrary::SyncPlaycountAndRatingToFiles, this);
|
||||||
@@ -212,18 +232,85 @@ void CollectionLibrary::SyncPlaycountAndRatingToFiles() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectionLibrary::SongsPlaycountChanged(const SongList &songs, const bool save_tags) const {
|
void CollectionLibrary::SongsPlaycountChanged(const SongList &songs, const bool save_tags) {
|
||||||
|
|
||||||
if (save_tags || save_playcounts_to_files_) {
|
if (save_tags || save_playcounts_to_files_) {
|
||||||
tagreader_client_->SaveSongsPlaycountAsync(songs);
|
SongList songs_to_save_now;
|
||||||
|
for (const Song &song : songs) {
|
||||||
|
if (song.url().isLocalFile() && song.url() == current_song_url_ &&
|
||||||
|
(song.filetype() == Song::FileType::OggFlac || song.filetype() == Song::FileType::OggVorbis || song.filetype() == Song::FileType::OggOpus)) {
|
||||||
|
qLog(Debug) << "Deferring playcount save for currently playing file" << song.url().toLocalFile();
|
||||||
|
if (pending_song_saves_.contains(song.url())) {
|
||||||
|
SharedPtr<PendingSongSave> pending_song_save = pending_song_saves_[song.url()];
|
||||||
|
pending_song_save->save_playcount = true;
|
||||||
|
pending_song_save->song.set_playcount(song.playcount());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SharedPtr<PendingSongSave> pending_song_save = make_shared<PendingSongSave>();
|
||||||
|
pending_song_save->save_playcount = true;
|
||||||
|
pending_song_save->song = song;
|
||||||
|
pending_song_saves_.insert(song.url(), pending_song_save);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
songs_to_save_now << song;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!songs_to_save_now.isEmpty()) {
|
||||||
|
tagreader_client_->SaveSongsPlaycountAsync(songs_to_save_now);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectionLibrary::SongsRatingChanged(const SongList &songs, const bool save_tags) const {
|
void CollectionLibrary::SongsRatingChanged(const SongList &songs, const bool save_tags) {
|
||||||
|
|
||||||
if (save_tags || save_ratings_to_files_) {
|
if (save_tags || save_ratings_to_files_) {
|
||||||
tagreader_client_->SaveSongsRatingAsync(songs);
|
SongList songs_to_save_now;
|
||||||
|
for (const Song &song : songs) {
|
||||||
|
if (song.url().isLocalFile() && song.url() == current_song_url_ &&
|
||||||
|
(song.filetype() == Song::FileType::OggFlac || song.filetype() == Song::FileType::OggVorbis || song.filetype() == Song::FileType::OggOpus)) {
|
||||||
|
qLog(Debug) << "Deferring rating save for currently playing file" << song.url().toLocalFile();
|
||||||
|
if (pending_song_saves_.contains(song.url())) {
|
||||||
|
SharedPtr<PendingSongSave> pending_song_save = pending_song_saves_[song.url()];
|
||||||
|
pending_song_save->save_rating = true;
|
||||||
|
pending_song_save->song.set_rating(song.rating());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SharedPtr<PendingSongSave> pending_song_save = make_shared<PendingSongSave>();
|
||||||
|
pending_song_save->save_rating = true;
|
||||||
|
pending_song_save->song = song;
|
||||||
|
pending_song_saves_.insert(song.url(), pending_song_save);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
songs_to_save_now << song;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!songs_to_save_now.isEmpty()) {
|
||||||
|
tagreader_client_->SaveSongsRatingAsync(songs_to_save_now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CollectionLibrary::SavePendingPlaycountsAndRatings() {
|
||||||
|
|
||||||
|
for (auto it = pending_song_saves_.constBegin(); it != pending_song_saves_.constEnd();) {
|
||||||
|
const QUrl url = it.key();
|
||||||
|
SharedPtr<PendingSongSave> pending_song_save = it.value();
|
||||||
|
if (url == current_song_url_) {
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
qLog(Debug) << "Saving deferred playcount/rating for" << url.toLocalFile();
|
||||||
|
if (pending_song_save->save_playcount) {
|
||||||
|
tagreader_client_->SaveSongsPlaycountAsync(SongList() << pending_song_save->song);
|
||||||
|
}
|
||||||
|
if (pending_song_save->save_rating) {
|
||||||
|
tagreader_client_->SaveSongsRatingAsync(SongList() << pending_song_save->song);
|
||||||
|
}
|
||||||
|
it = pending_song_saves_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
* Copyright 2018-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "includes/shared_ptr.h"
|
#include "includes/shared_ptr.h"
|
||||||
@@ -71,6 +72,7 @@ class CollectionLibrary : public QObject {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void SyncPlaycountAndRatingToFiles();
|
void SyncPlaycountAndRatingToFiles();
|
||||||
|
void SavePendingPlaycountsAndRatings();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
@@ -84,16 +86,26 @@ class CollectionLibrary : public QObject {
|
|||||||
|
|
||||||
void IncrementalScan();
|
void IncrementalScan();
|
||||||
|
|
||||||
|
void CurrentSongChanged(const Song &song);
|
||||||
|
void Stopped();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void ExitReceived();
|
void ExitReceived();
|
||||||
void SongsPlaycountChanged(const SongList &songs, const bool save_tags = false) const;
|
void SongsPlaycountChanged(const SongList &songs, const bool save_tags = false);
|
||||||
void SongsRatingChanged(const SongList &songs, const bool save_tags = false) const;
|
void SongsRatingChanged(const SongList &songs, const bool save_tags = false);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void Error(const QString &error);
|
void Error(const QString &error);
|
||||||
void ExitFinished();
|
void ExitFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class PendingSongSave {
|
||||||
|
public:
|
||||||
|
Song song;
|
||||||
|
bool save_playcount = false;
|
||||||
|
bool save_rating = false;
|
||||||
|
};
|
||||||
|
|
||||||
const SharedPtr<TaskManager> task_manager_;
|
const SharedPtr<TaskManager> task_manager_;
|
||||||
const SharedPtr<TagReaderClient> tagreader_client_;
|
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||||
|
|
||||||
@@ -111,6 +123,10 @@ class CollectionLibrary : public QObject {
|
|||||||
|
|
||||||
bool save_playcounts_to_files_;
|
bool save_playcounts_to_files_;
|
||||||
bool save_ratings_to_files_;
|
bool save_ratings_to_files_;
|
||||||
|
|
||||||
|
QUrl current_song_url_;
|
||||||
|
|
||||||
|
QMap<QUrl, SharedPtr<PendingSongSave>> pending_song_saves_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1209,49 +1209,41 @@ QString CollectionModel::ContainerKey(const GroupBy group_by, const Song &song,
|
|||||||
switch (group_by) {
|
switch (group_by) {
|
||||||
case GroupBy::AlbumArtist:
|
case GroupBy::AlbumArtist:
|
||||||
key = TextOrUnknown(song.effective_albumartist());
|
key = TextOrUnknown(song.effective_albumartist());
|
||||||
if (!song.effective_albumartistsort().isEmpty() && song.effective_albumartistsort() != song.effective_albumartist()) key.append(QLatin1Char('-') + TextOrUnknown(song.effective_albumartistsort()));
|
|
||||||
has_unique_album_identifier = true;
|
has_unique_album_identifier = true;
|
||||||
break;
|
break;
|
||||||
case GroupBy::Artist:
|
case GroupBy::Artist:
|
||||||
key = TextOrUnknown(song.artist());
|
key = TextOrUnknown(song.artist());
|
||||||
if (!song.artistsort().isEmpty() && song.artistsort() != song.artist()) key.append(QLatin1Char('-') + TextOrUnknown(song.artistsort()));
|
|
||||||
has_unique_album_identifier = true;
|
has_unique_album_identifier = true;
|
||||||
break;
|
break;
|
||||||
case GroupBy::Album:
|
case GroupBy::Album:
|
||||||
key = TextOrUnknown(song.album());
|
key = TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
break;
|
break;
|
||||||
case GroupBy::AlbumDisc:
|
case GroupBy::AlbumDisc:
|
||||||
key = TextOrUnknown(song.album());
|
key = TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
break;
|
break;
|
||||||
case GroupBy::YearAlbum:
|
case GroupBy::YearAlbum:
|
||||||
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
break;
|
break;
|
||||||
case GroupBy::YearAlbumDisc:
|
case GroupBy::YearAlbumDisc:
|
||||||
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
key = SortTextForYear(song.year()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
break;
|
break;
|
||||||
case GroupBy::OriginalYearAlbum:
|
case GroupBy::OriginalYearAlbum:
|
||||||
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
break;
|
break;
|
||||||
case GroupBy::OriginalYearAlbumDisc:
|
case GroupBy::OriginalYearAlbumDisc:
|
||||||
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
key = SortTextForYear(song.effective_originalyear()) + QLatin1Char('-') + TextOrUnknown(song.album());
|
||||||
if (!song.albumsort().isEmpty() && song.albumsort() != song.album()) key.append(QLatin1Char('-') + TextOrUnknown(song.albumsort()));
|
|
||||||
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
key.append(QLatin1Char('-') + SortTextForNumber(song.disc()));
|
||||||
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
if (!song.album_id().isEmpty()) key.append(QLatin1Char('-') + song.album_id());
|
||||||
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
if (options_active_.separate_albums_by_grouping && !song.grouping().isEmpty()) key.append(QLatin1Char('-') + song.grouping());
|
||||||
@@ -1270,12 +1262,10 @@ QString CollectionModel::ContainerKey(const GroupBy group_by, const Song &song,
|
|||||||
break;
|
break;
|
||||||
case GroupBy::Composer:
|
case GroupBy::Composer:
|
||||||
key = TextOrUnknown(song.composer());
|
key = TextOrUnknown(song.composer());
|
||||||
if (!song.composersort().isEmpty() && song.composersort() != song.composer()) key.append(QLatin1Char('-') + song.composersort());
|
|
||||||
has_unique_album_identifier = true;
|
has_unique_album_identifier = true;
|
||||||
break;
|
break;
|
||||||
case GroupBy::Performer:
|
case GroupBy::Performer:
|
||||||
key = TextOrUnknown(song.performer());
|
key = TextOrUnknown(song.performer());
|
||||||
if (!song.performersort().isEmpty() && song.performersort() != song.performer()) key.append(QLatin1Char('-') + song.performersort());
|
|
||||||
has_unique_album_identifier = true;
|
has_unique_album_identifier = true;
|
||||||
break;
|
break;
|
||||||
case GroupBy::Grouping:
|
case GroupBy::Grouping:
|
||||||
|
|||||||
@@ -41,9 +41,12 @@ bool CollectionPlaylistItem::InitFromQuery(const SqlRow &query) {
|
|||||||
case Song::Source::Collection:
|
case Song::Source::Collection:
|
||||||
col = 0;
|
col = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
case Song::Source::Dropbox:
|
||||||
col = static_cast<int>(Song::kRowIdColumns.count());
|
col = static_cast<int>(Song::kRowIdColumns.count());
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
col = static_cast<int>(Song::kRowIdColumns.count() * 2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
song_.InitFromQuery(query, true, col);
|
song_.InitFromQuery(query, true, col);
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#cmakedefine HAVE_SPOTIFY
|
#cmakedefine HAVE_SPOTIFY
|
||||||
#cmakedefine HAVE_QOBUZ
|
#cmakedefine HAVE_QOBUZ
|
||||||
#cmakedefine HAVE_DISCORD_RPC
|
#cmakedefine HAVE_DISCORD_RPC
|
||||||
|
#cmakedefine HAVE_DROPBOX
|
||||||
|
#cmakedefine HAVE_ONEDRIVE
|
||||||
|
|
||||||
#cmakedefine HAVE_TAGLIB_DSFFILE
|
#cmakedefine HAVE_TAGLIB_DSFFILE
|
||||||
#cmakedefine HAVE_TAGLIB_DSDIFFFILE
|
#cmakedefine HAVE_TAGLIB_DSDIFFFILE
|
||||||
|
|||||||
30
src/constants/dropboxconstants.h
Normal file
30
src/constants/dropboxconstants.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXCONSTANTS_H
|
||||||
|
#define DROPBOXCONSTANTS_H
|
||||||
|
|
||||||
|
namespace DropboxConstants {
|
||||||
|
|
||||||
|
constexpr char kApiUrl[] = "https://api.dropboxapi.com";
|
||||||
|
constexpr char kNotifyApiUrl[] = "https://notify.dropboxapi.com";
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // DROPBOXCONSTANTS_H
|
||||||
46
src/constants/dropboxsettings.h
Normal file
46
src/constants/dropboxsettings.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXSETTINGS_H
|
||||||
|
#define DROPBOXSETTINGS_H
|
||||||
|
|
||||||
|
namespace DropboxSettings {
|
||||||
|
|
||||||
|
constexpr char kSettingsGroup[] = "Dropbox";
|
||||||
|
|
||||||
|
constexpr char kEnabled[] = "enabled";
|
||||||
|
constexpr char kSearchDelay[] = "searchdelay";
|
||||||
|
constexpr char kArtistsSearchLimit[] = "artistssearchlimit";
|
||||||
|
constexpr char kAlbumsSearchLimit[] = "albumssearchlimit";
|
||||||
|
constexpr char kSongsSearchLimit[] = "songssearchlimit";
|
||||||
|
constexpr char kFetchAlbums[] = "fetchalbums";
|
||||||
|
constexpr char kDownloadAlbumCovers[] = "downloadalbumcovers";
|
||||||
|
|
||||||
|
constexpr char kTokenType[] = "token_type";
|
||||||
|
constexpr char kAccessToken[] = "access_token";
|
||||||
|
constexpr char kRefreshToken[] = "refresh_token";
|
||||||
|
constexpr char kExpiresIn[] = "expires_in";
|
||||||
|
constexpr char kLoginTime[] = "login_time";
|
||||||
|
|
||||||
|
constexpr char kApiUrl[] = "https://api.dropboxapi.com";
|
||||||
|
constexpr char kNotifyApiUrl[] = "https://notify.dropboxapi.com";
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif // DROPBOXSETTINGS_H
|
||||||
@@ -105,6 +105,10 @@
|
|||||||
# include "covermanager/qobuzcoverprovider.h"
|
# include "covermanager/qobuzcoverprovider.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
# include "dropbox/dropboxservice.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MOODBAR
|
#ifdef HAVE_MOODBAR
|
||||||
# include "moodbar/moodbarcontroller.h"
|
# include "moodbar/moodbarcontroller.h"
|
||||||
# include "moodbar/moodbarloader.h"
|
# include "moodbar/moodbarloader.h"
|
||||||
@@ -200,6 +204,9 @@ class ApplicationImpl {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
streaming_services->AddService(make_shared<QobuzService>(app->task_manager(), app->database(), app->network(), app->url_handlers(), app->albumcover_loader()));
|
streaming_services->AddService(make_shared<QobuzService>(app->task_manager(), app->database(), app->network(), app->url_handlers(), app->albumcover_loader()));
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
streaming_services->AddService(make_shared<DropboxService>(app->task_manager(), app->database(), app->network(), app->url_handlers(), app->tagreader_client(), app->albumcover_loader()));
|
||||||
#endif
|
#endif
|
||||||
return streaming_services;
|
return streaming_services;
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -110,21 +110,32 @@ bool FilesystemMusicStorage::CopyToStorage(const CopyJob &job, QString &error_te
|
|||||||
|
|
||||||
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
||||||
|
|
||||||
QString path = job.metadata_.url().toLocalFile();
|
const QString path = job.metadata_.url().toLocalFile();
|
||||||
QFileInfo fileInfo(path);
|
const QFileInfo fileInfo(path);
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
|
||||||
if (job.use_trash_ && QFile::supportsMoveToTrash()) {
|
if (job.use_trash_ && QFile::supportsMoveToTrash()) {
|
||||||
#else
|
#else
|
||||||
if (job.use_trash_) {
|
if (job.use_trash_) {
|
||||||
#endif
|
#endif
|
||||||
return QFile::moveToTrash(path);
|
if (QFile::moveToTrash(path)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
qLog(Warning) << "Moving file to trash failed for" << path << ", falling back to direct deletion";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
if (fileInfo.isDir()) {
|
if (fileInfo.isDir()) {
|
||||||
return Utilities::RemoveRecursive(path);
|
success = Utilities::RemoveRecursive(path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
success = QFile::remove(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QFile::remove(path);
|
if (!success) {
|
||||||
|
qLog(Error) << "Failed to delete file" << path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,6 @@
|
|||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
#include <QSettings>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@@ -179,6 +178,9 @@
|
|||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
# include "constants/qobuzsettings.h"
|
# include "constants/qobuzsettings.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
# include "constants/dropboxsettings.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "streaming/streamingservices.h"
|
#include "streaming/streamingservices.h"
|
||||||
#include "streaming/streamingservice.h"
|
#include "streaming/streamingservice.h"
|
||||||
@@ -356,6 +358,9 @@ MainWindow::MainWindow(Application *app,
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
qobuz_view_(new StreamingTabsView(app->streaming_services()->ServiceBySource(Song::Source::Qobuz), app->albumcover_loader(), QLatin1String(QobuzSettings::kSettingsGroup), this)),
|
qobuz_view_(new StreamingTabsView(app->streaming_services()->ServiceBySource(Song::Source::Qobuz), app->albumcover_loader(), QLatin1String(QobuzSettings::kSettingsGroup), this)),
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
dropbox_view_(new StreamingSongsView(app->streaming_services()->ServiceBySource(Song::Source::Dropbox), QLatin1String(DropboxSettings::kSettingsGroup), this)),
|
||||||
#endif
|
#endif
|
||||||
radio_view_(new RadioViewContainer(this)),
|
radio_view_(new RadioViewContainer(this)),
|
||||||
lastfm_import_dialog_(new LastFMImportDialog(app_->lastfm_import(), this)),
|
lastfm_import_dialog_(new LastFMImportDialog(app_->lastfm_import(), this)),
|
||||||
@@ -442,6 +447,9 @@ MainWindow::MainWindow(Application *app,
|
|||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
ui_->tabs->AddTab(qobuz_view_, u"qobuz"_s, IconLoader::Load(u"qobuz"_s, true, 0, 32), tr("Qobuz"));
|
ui_->tabs->AddTab(qobuz_view_, u"qobuz"_s, IconLoader::Load(u"qobuz"_s, true, 0, 32), tr("Qobuz"));
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
ui_->tabs->AddTab(dropbox_view_, u"dropbox"_s, IconLoader::Load(u"dropbox"_s, true, 0, 32), tr("Dropbox"));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Add the playing widget to the fancy tab widget
|
// Add the playing widget to the fancy tab widget
|
||||||
ui_->tabs->AddBottomWidget(ui_->widget_playing);
|
ui_->tabs->AddBottomWidget(ui_->widget_playing);
|
||||||
@@ -697,6 +705,9 @@ MainWindow::MainWindow(Application *app,
|
|||||||
QObject::connect(&*app_->task_manager(), &TaskManager::PauseCollectionWatchers, &*app_->collection(), &CollectionLibrary::PauseWatcher);
|
QObject::connect(&*app_->task_manager(), &TaskManager::PauseCollectionWatchers, &*app_->collection(), &CollectionLibrary::PauseWatcher);
|
||||||
QObject::connect(&*app_->task_manager(), &TaskManager::ResumeCollectionWatchers, &*app_->collection(), &CollectionLibrary::ResumeWatcher);
|
QObject::connect(&*app_->task_manager(), &TaskManager::ResumeCollectionWatchers, &*app_->collection(), &CollectionLibrary::ResumeWatcher);
|
||||||
|
|
||||||
|
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->collection(), &CollectionLibrary::CurrentSongChanged);
|
||||||
|
QObject::connect(&*app_->player(), &Player::Stopped, &*app_->collection(), &CollectionLibrary::Stopped);
|
||||||
|
|
||||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::LoadAlbumCover);
|
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded);
|
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded);
|
||||||
QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::Error, this, &MainWindow::ShowErrorDialog);
|
QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::Error, this, &MainWindow::ShowErrorDialog);
|
||||||
@@ -780,6 +791,12 @@ MainWindow::MainWindow(Application *app,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
QObject::connect(dropbox_view_, &StreamingSongsView::ShowErrorDialog, this, &MainWindow::ShowErrorDialog);
|
||||||
|
QObject::connect(dropbox_view_, &StreamingSongsView::OpenSettingsDialog, this, &MainWindow::OpenServiceSettingsDialog);
|
||||||
|
QObject::connect(dropbox_view_->view(), &StreamingCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||||
|
#endif
|
||||||
|
|
||||||
QObject::connect(radio_view_, &RadioViewContainer::Refresh, &*app_->radio_services(), &RadioServices::RefreshChannels);
|
QObject::connect(radio_view_, &RadioViewContainer::Refresh, &*app_->radio_services(), &RadioServices::RefreshChannels);
|
||||||
QObject::connect(radio_view_->view(), &RadioView::GetChannels, &*app_->radio_services(), &RadioServices::GetChannels);
|
QObject::connect(radio_view_->view(), &RadioView::GetChannels, &*app_->radio_services(), &RadioServices::GetChannels);
|
||||||
QObject::connect(radio_view_->view(), &RadioView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
QObject::connect(radio_view_->view(), &RadioView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||||
@@ -977,27 +994,28 @@ MainWindow::MainWindow(Application *app,
|
|||||||
|
|
||||||
// Load settings
|
// Load settings
|
||||||
qLog(Debug) << "Loading settings";
|
qLog(Debug) << "Loading settings";
|
||||||
settings_.beginGroup(MainWindowSettings::kSettingsGroup);
|
Settings settings;
|
||||||
|
settings.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
|
||||||
// Set last used geometry to position window on the correct monitor
|
// Set last used geometry to position window on the correct monitor
|
||||||
// Set window state only if the window was last maximized
|
// Set window state only if the window was last maximized
|
||||||
if (settings_.contains("geometry")) {
|
if (settings.contains("geometry")) {
|
||||||
restoreGeometry(settings_.value("geometry").toByteArray());
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings_.contains(MainWindowSettings::kSplitterState) || !ui_->splitter->restoreState(settings_.value(MainWindowSettings::kSplitterState).toByteArray())) {
|
if (!settings.contains(MainWindowSettings::kSplitterState) || !ui_->splitter->restoreState(settings.value(MainWindowSettings::kSplitterState).toByteArray())) {
|
||||||
ui_->splitter->setSizes(QList<int>() << 20 << (width() - 20));
|
ui_->splitter->setSizes(QList<int>() << 20 << (width() - 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_->tabs->setCurrentIndex(settings_.value("current_tab", 1).toInt());
|
ui_->tabs->setCurrentIndex(settings.value("current_tab", 1).toInt());
|
||||||
FancyTabWidget::Mode default_mode = FancyTabWidget::Mode::LargeSidebar;
|
FancyTabWidget::Mode default_mode = FancyTabWidget::Mode::LargeSidebar;
|
||||||
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(settings_.value("tab_mode", static_cast<int>(default_mode)).toInt());
|
FancyTabWidget::Mode tab_mode = static_cast<FancyTabWidget::Mode>(settings.value("tab_mode", static_cast<int>(default_mode)).toInt());
|
||||||
if (tab_mode == FancyTabWidget::Mode::None) tab_mode = default_mode;
|
if (tab_mode == FancyTabWidget::Mode::None) tab_mode = default_mode;
|
||||||
ui_->tabs->SetMode(tab_mode);
|
ui_->tabs->SetMode(tab_mode);
|
||||||
|
|
||||||
TabSwitched();
|
TabSwitched();
|
||||||
|
|
||||||
file_view_->SetPath(settings_.value("file_path", QDir::homePath()).toString());
|
file_view_->SetPath(settings.value("file_path", QDir::homePath()).toString());
|
||||||
|
|
||||||
// Users often collapse one side of the splitter by mistake and don't know how to restore it. This must be set after the state is restored above.
|
// Users often collapse one side of the splitter by mistake and don't know how to restore it. This must be set after the state is restored above.
|
||||||
ui_->splitter->setChildrenCollapsible(false);
|
ui_->splitter->setChildrenCollapsible(false);
|
||||||
@@ -1040,13 +1058,13 @@ MainWindow::MainWindow(Application *app,
|
|||||||
case BehaviourSettings::StartupBehaviour::Remember:
|
case BehaviourSettings::StartupBehaviour::Remember:
|
||||||
default:{
|
default:{
|
||||||
|
|
||||||
was_maximized_ = settings_.value(MainWindowSettings::kMaximized, true).toBool();
|
was_maximized_ = settings.value(MainWindowSettings::kMaximized, true).toBool();
|
||||||
if (was_maximized_) setWindowState(windowState() | Qt::WindowMaximized);
|
if (was_maximized_) setWindowState(windowState() | Qt::WindowMaximized);
|
||||||
|
|
||||||
was_minimized_ = settings_.value(MainWindowSettings::kMinimized, false).toBool();
|
was_minimized_ = settings.value(MainWindowSettings::kMinimized, false).toBool();
|
||||||
if (was_minimized_) setWindowState(windowState() | Qt::WindowMinimized);
|
if (was_minimized_) setWindowState(windowState() | Qt::WindowMinimized);
|
||||||
|
|
||||||
if (!systemtrayicon_->IsSystemTrayAvailable() || !systemtrayicon_->isVisible() || !settings_.value(MainWindowSettings::kHidden, false).toBool()) {
|
if (!systemtrayicon_->IsSystemTrayAvailable() || !systemtrayicon_->isVisible() || !settings.value(MainWindowSettings::kHidden, false).toBool()) {
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1054,7 +1072,7 @@ MainWindow::MainWindow(Application *app,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool show_sidebar = settings_.value(MainWindowSettings::kShowSidebar, true).toBool();
|
bool show_sidebar = settings.value(MainWindowSettings::kShowSidebar, true).toBool();
|
||||||
ui_->sidebar_layout->setVisible(show_sidebar);
|
ui_->sidebar_layout->setVisible(show_sidebar);
|
||||||
ui_->action_toggle_show_sidebar->setChecked(show_sidebar);
|
ui_->action_toggle_show_sidebar->setChecked(show_sidebar);
|
||||||
|
|
||||||
@@ -1225,7 +1243,9 @@ void MainWindow::ReloadSettings() {
|
|||||||
|
|
||||||
osd_->ReloadSettings();
|
osd_->ReloadSettings();
|
||||||
|
|
||||||
album_cover_choice_controller_->search_cover_auto_action()->setChecked(settings_.value(MainWindowSettings::kSearchForCoverAuto, true).toBool());
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
album_cover_choice_controller_->search_cover_auto_action()->setChecked(s.value(MainWindowSettings::kSearchForCoverAuto, true).toBool());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
#ifdef HAVE_SUBSONIC
|
#ifdef HAVE_SUBSONIC
|
||||||
s.beginGroup(SubsonicSettings::kSettingsGroup);
|
s.beginGroup(SubsonicSettings::kSettingsGroup);
|
||||||
@@ -1275,6 +1295,18 @@ void MainWindow::ReloadSettings() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
s.beginGroup(DropboxSettings::kSettingsGroup);
|
||||||
|
const bool enable_dropbox = s.value(DropboxSettings::kEnabled, false).toBool();
|
||||||
|
s.endGroup();
|
||||||
|
if (enable_dropbox) {
|
||||||
|
ui_->tabs->EnableTab(dropbox_view_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui_->tabs->DisableTab(dropbox_view_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ui_->tabs->ReloadSettings();
|
ui_->tabs->ReloadSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1321,10 +1353,12 @@ void MainWindow::ReloadAllSettings() {
|
|||||||
qobuz_view_->ReloadSettings();
|
qobuz_view_->ReloadSettings();
|
||||||
qobuz_view_->search_view()->ReloadSettings();
|
qobuz_view_->search_view()->ReloadSettings();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
dropbox_view_->ReloadSettings();
|
||||||
|
#endif
|
||||||
#ifdef HAVE_DISCORD_RPC
|
#ifdef HAVE_DISCORD_RPC
|
||||||
discord_rich_presence_->ReloadSettings();
|
discord_rich_presence_->ReloadSettings();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::RefreshStyleSheet() {
|
void MainWindow::RefreshStyleSheet() {
|
||||||
@@ -1342,8 +1376,11 @@ void MainWindow::SaveSettings() {
|
|||||||
ui_->playlist->view()->SaveSettings();
|
ui_->playlist->view()->SaveSettings();
|
||||||
app_->scrobbler()->WriteCache();
|
app_->scrobbler()->WriteCache();
|
||||||
|
|
||||||
settings_.setValue(MainWindowSettings::kShowSidebar, ui_->action_toggle_show_sidebar->isChecked());
|
Settings s;
|
||||||
settings_.setValue(MainWindowSettings::kSearchForCoverAuto, album_cover_choice_controller_->search_cover_auto_action()->isChecked());
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
s.setValue(MainWindowSettings::kShowSidebar, ui_->action_toggle_show_sidebar->isChecked());
|
||||||
|
s.setValue(MainWindowSettings::kSearchForCoverAuto, album_cover_choice_controller_->search_cover_auto_action()->isChecked());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1584,23 +1621,35 @@ void MainWindow::ToggleSidebar(const bool checked) {
|
|||||||
|
|
||||||
ui_->sidebar_layout->setVisible(checked);
|
ui_->sidebar_layout->setVisible(checked);
|
||||||
TabSwitched();
|
TabSwitched();
|
||||||
settings_.setValue(MainWindowSettings::kShowSidebar, checked);
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
s.setValue(MainWindowSettings::kShowSidebar, checked);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ToggleSearchCoverAuto(const bool checked) {
|
void MainWindow::ToggleSearchCoverAuto(const bool checked) {
|
||||||
settings_.setValue(MainWindowSettings::kSearchForCoverAuto, checked);
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
s.setValue(MainWindowSettings::kSearchForCoverAuto, checked);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::SaveGeometry() {
|
void MainWindow::SaveGeometry() {
|
||||||
|
|
||||||
if (!initialized_) return;
|
if (!initialized_) return;
|
||||||
|
|
||||||
settings_.setValue(MainWindowSettings::kMaximized, isMaximized());
|
Settings s;
|
||||||
settings_.setValue(MainWindowSettings::kMinimized, isMinimized());
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
settings_.setValue(MainWindowSettings::kHidden, isHidden());
|
s.setValue(MainWindowSettings::kMaximized, isMaximized());
|
||||||
settings_.setValue(MainWindowSettings::kGeometry, saveGeometry());
|
s.setValue(MainWindowSettings::kMinimized, isMinimized());
|
||||||
settings_.setValue(MainWindowSettings::kSplitterState, ui_->splitter->saveState());
|
s.setValue(MainWindowSettings::kHidden, isHidden());
|
||||||
|
s.setValue(MainWindowSettings::kGeometry, saveGeometry());
|
||||||
|
s.setValue(MainWindowSettings::kSplitterState, ui_->splitter->saveState());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1742,7 +1791,12 @@ void MainWindow::SetHiddenInTray(const bool hidden) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::FilePathChanged(const QString &path) {
|
void MainWindow::FilePathChanged(const QString &path) {
|
||||||
settings_.setValue("file_path", path);
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
s.setValue("file_path", path);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::Seeked(const qint64 microseconds) {
|
void MainWindow::Seeked(const qint64 microseconds) {
|
||||||
@@ -2324,7 +2378,9 @@ void MainWindow::EditValue() {
|
|||||||
void MainWindow::AddFile() {
|
void MainWindow::AddFile() {
|
||||||
|
|
||||||
// Last used directory
|
// Last used directory
|
||||||
QString directory = settings_.value("add_media_path", QDir::currentPath()).toString();
|
Settings s;
|
||||||
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
QString directory = s.value("add_media_path", QDir::currentPath()).toString();
|
||||||
|
|
||||||
PlaylistParser parser(app_->tagreader_client(), app_->collection_backend());
|
PlaylistParser parser(app_->tagreader_client(), app_->collection_backend());
|
||||||
|
|
||||||
@@ -2334,7 +2390,7 @@ void MainWindow::AddFile() {
|
|||||||
if (filenames.isEmpty()) return;
|
if (filenames.isEmpty()) return;
|
||||||
|
|
||||||
// Save last used directory
|
// Save last used directory
|
||||||
settings_.setValue("add_media_path", filenames[0]);
|
s.setValue("add_media_path", filenames[0]);
|
||||||
|
|
||||||
// Convert to URLs
|
// Convert to URLs
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
@@ -2352,14 +2408,16 @@ void MainWindow::AddFile() {
|
|||||||
void MainWindow::AddFolder() {
|
void MainWindow::AddFolder() {
|
||||||
|
|
||||||
// Last used directory
|
// Last used directory
|
||||||
QString directory = settings_.value("add_folder_path", QDir::currentPath()).toString();
|
Settings s;
|
||||||
|
s.beginGroup(MainWindowSettings::kSettingsGroup);
|
||||||
|
QString directory = s.value("add_folder_path", QDir::currentPath()).toString();
|
||||||
|
|
||||||
// Show dialog
|
// Show dialog
|
||||||
directory = QFileDialog::getExistingDirectory(this, tr("Add folder"), directory);
|
directory = QFileDialog::getExistingDirectory(this, tr("Add folder"), directory);
|
||||||
if (directory.isEmpty()) return;
|
if (directory.isEmpty()) return;
|
||||||
|
|
||||||
// Save last used directory
|
// Save last used directory
|
||||||
settings_.setValue("add_folder_path", directory);
|
s.setValue("add_folder_path", directory);
|
||||||
|
|
||||||
// Add media
|
// Add media
|
||||||
MimeData *mimedata = new MimeData;
|
MimeData *mimedata = new MimeData;
|
||||||
@@ -2688,6 +2746,9 @@ void MainWindow::OpenServiceSettingsDialog(const Song::Source source) {
|
|||||||
case Song::Source::Spotify:
|
case Song::Source::Spotify:
|
||||||
settings_dialog_->OpenAtPage(SettingsDialog::Page::Spotify);
|
settings_dialog_->OpenAtPage(SettingsDialog::Page::Spotify);
|
||||||
break;
|
break;
|
||||||
|
case Song::Source::Dropbox:
|
||||||
|
settings_dialog_->OpenAtPage(SettingsDialog::Page::Dropbox);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3369,6 +3430,11 @@ void MainWindow::FocusSearchField() {
|
|||||||
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(qobuz_view_) && !qobuz_view_->SearchFieldHasFocus()) {
|
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(qobuz_view_) && !qobuz_view_->SearchFieldHasFocus()) {
|
||||||
qobuz_view_->FocusSearchField();
|
qobuz_view_->FocusSearchField();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
else if (ui_->tabs->currentIndex() == ui_->tabs->IndexOfTab(dropbox_view_) && !dropbox_view_->SearchFieldHasFocus()) {
|
||||||
|
dropbox_view_->FocusSearchField();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (!ui_->playlist->SearchFieldHasFocus()) {
|
else if (!ui_->playlist->SearchFieldHasFocus()) {
|
||||||
ui_->playlist->FocusSearchField();
|
ui_->playlist->FocusSearchField();
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSettings>
|
|
||||||
#include <QtEvents>
|
#include <QtEvents>
|
||||||
|
|
||||||
#include "includes/scoped_ptr.h"
|
#include "includes/scoped_ptr.h"
|
||||||
@@ -53,7 +52,6 @@
|
|||||||
#include "includes/lazy.h"
|
#include "includes/lazy.h"
|
||||||
#include "core/platforminterface.h"
|
#include "core/platforminterface.h"
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
#include "core/settings.h"
|
|
||||||
#include "core/commandlineoptions.h"
|
#include "core/commandlineoptions.h"
|
||||||
#include "tagreader/tagreaderclient.h"
|
#include "tagreader/tagreaderclient.h"
|
||||||
#include "osd/osdbase.h"
|
#include "osd/osdbase.h"
|
||||||
@@ -357,6 +355,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
|||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
StreamingTabsView *qobuz_view_;
|
StreamingTabsView *qobuz_view_;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
StreamingSongsView *dropbox_view_;
|
||||||
|
#endif
|
||||||
|
|
||||||
RadioViewContainer *radio_view_;
|
RadioViewContainer *radio_view_;
|
||||||
|
|
||||||
@@ -390,7 +391,6 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
|||||||
|
|
||||||
QTimer *track_position_timer_;
|
QTimer *track_position_timer_;
|
||||||
QTimer *track_slider_timer_;
|
QTimer *track_slider_timer_;
|
||||||
Settings settings_;
|
|
||||||
|
|
||||||
bool keep_running_;
|
bool keep_running_;
|
||||||
bool playing_widget_;
|
bool playing_widget_;
|
||||||
|
|||||||
@@ -805,19 +805,19 @@ bool Song::lyrics_supported() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Song::albumartistsort_supported() const {
|
bool Song::albumartistsort_supported() const {
|
||||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::albumsort_supported() const {
|
bool Song::albumsort_supported() const {
|
||||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::artistsort_supported() const {
|
bool Song::artistsort_supported() const {
|
||||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::composersort_supported() const {
|
bool Song::composersort_supported() const {
|
||||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::performersort_supported() const {
|
bool Song::performersort_supported() const {
|
||||||
@@ -826,7 +826,7 @@ bool Song::performersort_supported() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Song::titlesort_supported() const {
|
bool Song::titlesort_supported() const {
|
||||||
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::MPEG;
|
return d->filetype_ == FileType::FLAC || d->filetype_ == FileType::OggFlac || d->filetype_ == FileType::OggVorbis || d->filetype_ == FileType::OggOpus || d->filetype_ == FileType::MPEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::save_embedded_cover_supported(const FileType filetype) {
|
bool Song::save_embedded_cover_supported(const FileType filetype) {
|
||||||
@@ -1163,6 +1163,8 @@ QString Song::TextForSource(const Source source) {
|
|||||||
case Source::Qobuz: return u"qobuz"_s;
|
case Source::Qobuz: return u"qobuz"_s;
|
||||||
case Source::SomaFM: return u"somafm"_s;
|
case Source::SomaFM: return u"somafm"_s;
|
||||||
case Source::RadioParadise: return u"radioparadise"_s;
|
case Source::RadioParadise: return u"radioparadise"_s;
|
||||||
|
case Source::Dropbox: return u"dropbox"_s;
|
||||||
|
case Source::OneDrive: return u"onedrive"_s;
|
||||||
case Source::Unknown: return u"unknown"_s;
|
case Source::Unknown: return u"unknown"_s;
|
||||||
}
|
}
|
||||||
return u"unknown"_s;
|
return u"unknown"_s;
|
||||||
@@ -1183,6 +1185,8 @@ QString Song::DescriptionForSource(const Source source) {
|
|||||||
case Source::Qobuz: return u"Qobuz"_s;
|
case Source::Qobuz: return u"Qobuz"_s;
|
||||||
case Source::SomaFM: return u"SomaFM"_s;
|
case Source::SomaFM: return u"SomaFM"_s;
|
||||||
case Source::RadioParadise: return u"Radio Paradise"_s;
|
case Source::RadioParadise: return u"Radio Paradise"_s;
|
||||||
|
case Source::Dropbox: return u"Dropbox"_s;
|
||||||
|
case Source::OneDrive: return u"OneDrive"_s;
|
||||||
case Source::Unknown: return u"Unknown"_s;
|
case Source::Unknown: return u"Unknown"_s;
|
||||||
}
|
}
|
||||||
return u"unknown"_s;
|
return u"unknown"_s;
|
||||||
@@ -1202,6 +1206,8 @@ Song::Source Song::SourceFromText(const QString &source) {
|
|||||||
if (source.compare("qobuz"_L1, Qt::CaseInsensitive) == 0) return Source::Qobuz;
|
if (source.compare("qobuz"_L1, Qt::CaseInsensitive) == 0) return Source::Qobuz;
|
||||||
if (source.compare("somafm"_L1, Qt::CaseInsensitive) == 0) return Source::SomaFM;
|
if (source.compare("somafm"_L1, Qt::CaseInsensitive) == 0) return Source::SomaFM;
|
||||||
if (source.compare("radioparadise"_L1, Qt::CaseInsensitive) == 0) return Source::RadioParadise;
|
if (source.compare("radioparadise"_L1, Qt::CaseInsensitive) == 0) return Source::RadioParadise;
|
||||||
|
if (source.compare("dropbox"_L1, Qt::CaseInsensitive) == 0) return Source::Dropbox;
|
||||||
|
if (source.compare("onedrive"_L1, Qt::CaseInsensitive) == 0) return Source::OneDrive;
|
||||||
|
|
||||||
return Source::Unknown;
|
return Source::Unknown;
|
||||||
|
|
||||||
@@ -1221,6 +1227,8 @@ QIcon Song::IconForSource(const Source source) {
|
|||||||
case Source::Qobuz: return IconLoader::Load(u"qobuz"_s);
|
case Source::Qobuz: return IconLoader::Load(u"qobuz"_s);
|
||||||
case Source::SomaFM: return IconLoader::Load(u"somafm"_s);
|
case Source::SomaFM: return IconLoader::Load(u"somafm"_s);
|
||||||
case Source::RadioParadise: return IconLoader::Load(u"radioparadise"_s);
|
case Source::RadioParadise: return IconLoader::Load(u"radioparadise"_s);
|
||||||
|
case Source::Dropbox: return IconLoader::Load(u"dropbox"_s);
|
||||||
|
case Source::OneDrive: return IconLoader::Load(u"onedrive"_s);
|
||||||
case Source::Unknown: return IconLoader::Load(u"edit-delete"_s);
|
case Source::Unknown: return IconLoader::Load(u"edit-delete"_s);
|
||||||
}
|
}
|
||||||
return IconLoader::Load(u"edit-delete"_s);
|
return IconLoader::Load(u"edit-delete"_s);
|
||||||
@@ -1470,7 +1478,7 @@ Song::FileType Song::FiletypeByExtension(const QString &ext) {
|
|||||||
|
|
||||||
bool Song::IsLinkedCollectionSource(const Source source) {
|
bool Song::IsLinkedCollectionSource(const Source source) {
|
||||||
|
|
||||||
return source == Source::Collection;
|
return source == Source::Collection || source == Source::Dropbox;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,11 +1497,14 @@ QString Song::ImageCacheDir(const Source source) {
|
|||||||
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/qobuzalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/qobuzalbumcovers"_s;
|
||||||
case Source::Device:
|
case Source::Device:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/devicealbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/devicealbumcovers"_s;
|
||||||
|
case Source::Dropbox:
|
||||||
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/dropboxalbumcovers"_s;
|
||||||
case Source::LocalFile:
|
case Source::LocalFile:
|
||||||
case Source::CDDA:
|
case Source::CDDA:
|
||||||
case Source::Stream:
|
case Source::Stream:
|
||||||
case Source::SomaFM:
|
case Source::SomaFM:
|
||||||
case Source::RadioParadise:
|
case Source::RadioParadise:
|
||||||
|
case Source::OneDrive:
|
||||||
case Source::Unknown:
|
case Source::Unknown:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/albumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/albumcovers"_s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ class Song {
|
|||||||
Qobuz = 8,
|
Qobuz = 8,
|
||||||
SomaFM = 9,
|
SomaFM = 9,
|
||||||
RadioParadise = 10,
|
RadioParadise = 10,
|
||||||
Spotify = 11
|
Spotify = 11,
|
||||||
|
Dropbox = 12,
|
||||||
|
OneDrive = 13,
|
||||||
};
|
};
|
||||||
static const int kSourceCount = 16;
|
static const int kSourceCount = 16;
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ SongLoader::SongLoader(const SharedPtr<UrlHandlers> url_handlers,
|
|||||||
|
|
||||||
QObject::connect(timeout_timer_, &QTimer::timeout, this, &SongLoader::Timeout);
|
QObject::connect(timeout_timer_, &QTimer::timeout, this, &SongLoader::Timeout);
|
||||||
|
|
||||||
|
QObject::connect(playlist_parser_, &PlaylistParser::Error, this, &SongLoader::ParserError);
|
||||||
|
QObject::connect(cue_parser_, &CueParser::Error, this, &SongLoader::ParserError);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SongLoader::~SongLoader() {
|
SongLoader::~SongLoader() {
|
||||||
@@ -106,6 +109,10 @@ SongLoader::~SongLoader() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SongLoader::ParserError(const QString &error) {
|
||||||
|
errors_ << error;
|
||||||
|
}
|
||||||
|
|
||||||
SongLoader::Result SongLoader::Load(const QUrl &url) {
|
SongLoader::Result SongLoader::Load(const QUrl &url) {
|
||||||
|
|
||||||
if (url.isEmpty()) return Result::Error;
|
if (url.isEmpty()) return Result::Error;
|
||||||
@@ -287,6 +294,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parser) { // It's a playlist!
|
if (parser) { // It's a playlist!
|
||||||
|
QObject::connect(parser, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||||
qLog(Debug) << "Parsing using" << parser->name();
|
qLog(Debug) << "Parsing using" << parser->name();
|
||||||
LoadPlaylist(parser, filename);
|
LoadPlaylist(parser, filename);
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
@@ -706,6 +714,10 @@ void SongLoader::MagicReady() {
|
|||||||
StopTypefindAsync(true);
|
StopTypefindAsync(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser_) {
|
||||||
|
QObject::connect(parser_, &ParserBase::Error, this, &SongLoader::ParserError, static_cast<Qt::ConnectionType>(Qt::QueuedConnection | Qt::UniqueConnection));
|
||||||
|
}
|
||||||
|
|
||||||
state_ = State::WaitingForData;
|
state_ = State::WaitingForData;
|
||||||
|
|
||||||
if (!IsPipelinePlaying()) {
|
if (!IsPipelinePlaying()) {
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ class SongLoader : public QObject {
|
|||||||
void ScheduleTimeout();
|
void ScheduleTimeout();
|
||||||
void Timeout();
|
void Timeout();
|
||||||
void StopTypefind();
|
void StopTypefind();
|
||||||
|
void ParserError(const QString &error);
|
||||||
|
|
||||||
#ifdef HAVE_AUDIOCD
|
#ifdef HAVE_AUDIOCD
|
||||||
void AudioCDTracksLoadErrorSlot(const QString &error);
|
void AudioCDTracksLoadErrorSlot(const QString &error);
|
||||||
|
|||||||
@@ -589,6 +589,8 @@ void AlbumCoverChoiceController::SaveArtManualToSong(Song *song, const QUrl &art
|
|||||||
case Song::Source::Tidal:
|
case Song::Source::Tidal:
|
||||||
case Song::Source::Spotify:
|
case Song::Source::Spotify:
|
||||||
case Song::Source::Qobuz:
|
case Song::Source::Qobuz:
|
||||||
|
case Song::Source::Dropbox:
|
||||||
|
case Song::Source::OneDrive:
|
||||||
StreamingServicePtr service = streaming_services_->ServiceBySource(song->source());
|
StreamingServicePtr service = streaming_services_->ServiceBySource(song->source());
|
||||||
if (!service) break;
|
if (!service) break;
|
||||||
if (service->artists_collection_backend()) {
|
if (service->artists_collection_backend()) {
|
||||||
|
|||||||
132
src/dropbox/dropboxbaserequest.cpp
Normal file
132
src/dropbox/dropboxbaserequest.cpp
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "constants/dropboxconstants.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
#include "dropboxbaserequest.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
using namespace DropboxConstants;
|
||||||
|
|
||||||
|
DropboxBaseRequest::DropboxBaseRequest(const SharedPtr<NetworkAccessManager> network, DropboxService *service, QObject *parent)
|
||||||
|
: JsonBaseRequest(network, parent),
|
||||||
|
service_(service) {}
|
||||||
|
|
||||||
|
QString DropboxBaseRequest::service_name() const {
|
||||||
|
|
||||||
|
return service_->name();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropboxBaseRequest::authentication_required() const {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropboxBaseRequest::authenticated() const {
|
||||||
|
|
||||||
|
return service_->authenticated();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropboxBaseRequest::use_authorization_header() const {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray DropboxBaseRequest::authorization_header() const {
|
||||||
|
|
||||||
|
return service_->authorization_header();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkReply *DropboxBaseRequest::GetTemporaryLink(const QUrl &url) {
|
||||||
|
|
||||||
|
QJsonObject json_object;
|
||||||
|
json_object.insert("path"_L1, url.path());
|
||||||
|
return CreatePostRequest(QUrl(QLatin1String(kApiUrl) + "/2/files/get_temporary_link"_L1), json_object);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonBaseRequest::JsonObjectResult DropboxBaseRequest::ParseJsonObject(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||||
|
return ReplyDataResult(ErrorCode::NetworkError, QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObjectResult result(ErrorCode::Success);
|
||||||
|
result.network_error = reply->error();
|
||||||
|
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).isValid()) {
|
||||||
|
result.http_status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray data = reply->readAll();
|
||||||
|
if (!data.isEmpty()) {
|
||||||
|
QJsonParseError json_parse_error;
|
||||||
|
const QJsonDocument json_document = QJsonDocument::fromJson(data, &json_parse_error);
|
||||||
|
if (json_parse_error.error == QJsonParseError::NoError) {
|
||||||
|
const QJsonObject json_object = json_document.object();
|
||||||
|
if (json_object.contains("error"_L1) && json_object["error"_L1].isObject()) {
|
||||||
|
const QJsonObject object_error = json_object["error"_L1].toObject();
|
||||||
|
if (object_error.contains("status"_L1) && object_error.contains("message"_L1)) {
|
||||||
|
const int status = object_error["status"_L1].toInt();
|
||||||
|
const QString message = object_error["message"_L1].toString();
|
||||||
|
result.error_code = ErrorCode::APIError;
|
||||||
|
result.error_message = QStringLiteral("%1 (%2)").arg(message).arg(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.json_object = json_document.object();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.error_code = ErrorCode::ParseError;
|
||||||
|
result.error_message = json_parse_error.errorString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.error_code != ErrorCode::APIError) {
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
result.error_code = ErrorCode::NetworkError;
|
||||||
|
result.error_message = QStringLiteral("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
|
}
|
||||||
|
else if (result.http_status_code != 200) {
|
||||||
|
result.error_code = ErrorCode::HttpError;
|
||||||
|
result.error_message = QStringLiteral("Received HTTP code %1").arg(result.http_status_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply->error() == QNetworkReply::AuthenticationRequiredError) {
|
||||||
|
service_->ClearSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
59
src/dropbox/dropboxbaserequest.h
Normal file
59
src/dropbox/dropboxbaserequest.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXBASEREQUEST_H
|
||||||
|
#define DROPBOXBASEREQUEST_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "core/jsonbaserequest.h"
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
class DropboxService;
|
||||||
|
|
||||||
|
class DropboxBaseRequest : public JsonBaseRequest {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxBaseRequest(const SharedPtr<NetworkAccessManager> network, DropboxService *service, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
QString service_name() const override;
|
||||||
|
bool authentication_required() const override;
|
||||||
|
bool authenticated() const override;
|
||||||
|
bool use_authorization_header() const override;
|
||||||
|
QByteArray authorization_header() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QNetworkReply *GetTemporaryLink(const QUrl &url);
|
||||||
|
JsonObjectResult ParseJsonObject(QNetworkReply *reply);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void ShowErrorDialog(const QString &error);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DropboxService *service_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPBOXBASEREQUEST_H
|
||||||
190
src/dropbox/dropboxservice.cpp
Normal file
190
src/dropbox/dropboxservice.cpp
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "constants/dropboxsettings.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
#include "core/database.h"
|
||||||
|
#include "core/urlhandlers.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
|
#include "core/oauthenticator.h"
|
||||||
|
#include "collection/collectionbackend.h"
|
||||||
|
#include "collection/collectionmodel.h"
|
||||||
|
#include "streaming/cloudstoragestreamingservice.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
#include "dropboxurlhandler.h"
|
||||||
|
#include "dropboxsongsrequest.h"
|
||||||
|
#include "dropboxstreamurlrequest.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
using namespace DropboxSettings;
|
||||||
|
|
||||||
|
const Song::Source DropboxService::kSource = Song::Source::Dropbox;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr char kClientIDB64[] = "Zmx0b2EyYzRwaGo2eHlw";
|
||||||
|
constexpr char kClientSecretB64[] = "emo3em5jNnNpM3Ftd2s3";
|
||||||
|
constexpr char kOAuthRedirectUrl[] = "http://localhost/";
|
||||||
|
constexpr char kOAuthAuthorizeUrl[] = "https://www.dropbox.com/1/oauth2/authorize";
|
||||||
|
constexpr char kOAuthAccessTokenUrl[] = "https://api.dropboxapi.com/1/oauth2/token";
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
DropboxService::DropboxService(const SharedPtr<TaskManager> task_manager,
|
||||||
|
const SharedPtr<Database> database,
|
||||||
|
const SharedPtr<NetworkAccessManager> network,
|
||||||
|
const SharedPtr<UrlHandlers> url_handlers,
|
||||||
|
const SharedPtr<TagReaderClient> tagreader_client,
|
||||||
|
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||||
|
QObject *parent)
|
||||||
|
: CloudStorageStreamingService(task_manager, database, tagreader_client, albumcover_loader, Song::Source::Dropbox, u"Dropbox"_s, u"dropbox"_s, QLatin1String(kSettingsGroup), parent),
|
||||||
|
network_(network),
|
||||||
|
oauth_(new OAuthenticator(network, this)),
|
||||||
|
songs_request_(new DropboxSongsRequest(network, collection_backend_, this, this)),
|
||||||
|
enabled_(false),
|
||||||
|
next_stream_url_request_id_(0) {
|
||||||
|
|
||||||
|
url_handlers->Register(new DropboxUrlHandler(task_manager, this, this));
|
||||||
|
|
||||||
|
oauth_->set_settings_group(QLatin1String(kSettingsGroup));
|
||||||
|
oauth_->set_type(OAuthenticator::Type::Authorization_Code);
|
||||||
|
oauth_->set_authorize_url(QUrl(QLatin1String(kOAuthAuthorizeUrl)));
|
||||||
|
oauth_->set_redirect_url(QUrl(QLatin1String(kOAuthRedirectUrl)));
|
||||||
|
oauth_->set_access_token_url(QUrl(QLatin1String(kOAuthAccessTokenUrl)));
|
||||||
|
oauth_->set_client_id(QString::fromLatin1(QByteArray::fromBase64(kClientIDB64)));
|
||||||
|
oauth_->set_client_secret(QString::fromLatin1(QByteArray::fromBase64(kClientSecretB64)));
|
||||||
|
oauth_->set_use_local_redirect_server(true);
|
||||||
|
oauth_->set_random_port(true);
|
||||||
|
|
||||||
|
QObject::connect(oauth_, &OAuthenticator::AuthenticationFinished, this, &DropboxService::OAuthFinished);
|
||||||
|
|
||||||
|
DropboxService::ReloadSettings();
|
||||||
|
oauth_->LoadSession();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropboxService::authenticated() const {
|
||||||
|
|
||||||
|
return oauth_->authenticated();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::Exit() {
|
||||||
|
|
||||||
|
wait_for_exit_ << &*collection_backend_;
|
||||||
|
QObject::connect(&*collection_backend_, &CollectionBackend::ExitFinished, this, &DropboxService::ExitReceived);
|
||||||
|
collection_backend_->ExitAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::ExitReceived() {
|
||||||
|
|
||||||
|
QObject *obj = sender();
|
||||||
|
QObject::disconnect(obj, nullptr, this, nullptr);
|
||||||
|
qLog(Debug) << obj << "successfully exited.";
|
||||||
|
wait_for_exit_.removeAll(obj);
|
||||||
|
if (wait_for_exit_.isEmpty()) Q_EMIT ExitFinished();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::ReloadSettings() {
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
enabled_ = s.value(kEnabled, false).toBool();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::Authenticate() {
|
||||||
|
|
||||||
|
oauth_->Authenticate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::ClearSession() {
|
||||||
|
|
||||||
|
oauth_->ClearSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::OAuthFinished(const bool success, const QString &error) {
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Q_EMIT LoginFinished(true);
|
||||||
|
Q_EMIT LoginSuccess();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Q_EMIT LoginFailure(error);
|
||||||
|
Q_EMIT LoginFinished(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray DropboxService::authorization_header() const {
|
||||||
|
return oauth_->authorization_header();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::Start() {
|
||||||
|
songs_request_->GetFolderList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::Reset() {
|
||||||
|
|
||||||
|
collection_backend_->DeleteAll();
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.remove("cursor");
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
if (authenticated()) {
|
||||||
|
Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint DropboxService::GetStreamURL(const QUrl &url, QString &error) {
|
||||||
|
|
||||||
|
if (!authenticated()) {
|
||||||
|
error = tr("Not authenticated with Dropbox.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint id = 0;
|
||||||
|
while (id == 0) id = ++next_stream_url_request_id_;
|
||||||
|
DropboxStreamURLRequestPtr stream_url_request = DropboxStreamURLRequestPtr(new DropboxStreamURLRequest(network_, this, id, url));
|
||||||
|
stream_url_requests_.insert(id, stream_url_request);
|
||||||
|
QObject::connect(&*stream_url_request, &DropboxStreamURLRequest::StreamURLRequestFinished, this, &DropboxService::StreamURLRequestFinishedSlot);
|
||||||
|
stream_url_request->Process();
|
||||||
|
|
||||||
|
return id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxService::StreamURLRequestFinishedSlot(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error) {
|
||||||
|
|
||||||
|
if (!stream_url_requests_.contains(id)) return;
|
||||||
|
DropboxStreamURLRequestPtr stream_url_request = stream_url_requests_.take(id);
|
||||||
|
|
||||||
|
Q_EMIT StreamURLRequestFinished(id, media_url, success, stream_url, error);
|
||||||
|
|
||||||
|
}
|
||||||
93
src/dropbox/dropboxservice.h
Normal file
93
src/dropbox/dropboxservice.h
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXSERVICE_H
|
||||||
|
#define DROPBOXSERVICE_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "core/song.h"
|
||||||
|
#include "streaming/cloudstoragestreamingservice.h"
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
|
class TaskManager;
|
||||||
|
class Database;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
class UrlHandlers;
|
||||||
|
class TagReaderClient;
|
||||||
|
class AlbumCoverLoader;
|
||||||
|
class OAuthenticator;
|
||||||
|
class DropboxSongsRequest;
|
||||||
|
class DropboxStreamURLRequest;
|
||||||
|
|
||||||
|
class DropboxService : public CloudStorageStreamingService {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxService(const SharedPtr<TaskManager> task_manager,
|
||||||
|
const SharedPtr<Database> database,
|
||||||
|
const SharedPtr<NetworkAccessManager> network,
|
||||||
|
const SharedPtr<UrlHandlers> url_handlers,
|
||||||
|
const SharedPtr<TagReaderClient> tagreader_client,
|
||||||
|
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
|
static const Song::Source kSource;
|
||||||
|
|
||||||
|
bool oauth() const override { return true; }
|
||||||
|
bool authenticated() const override;
|
||||||
|
bool show_progress() const override { return false; }
|
||||||
|
bool enable_refresh_button() const override { return false; }
|
||||||
|
|
||||||
|
void Exit() override;
|
||||||
|
void ReloadSettings() override;
|
||||||
|
|
||||||
|
void Authenticate();
|
||||||
|
void ClearSession();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Reset();
|
||||||
|
uint GetStreamURL(const QUrl &url, QString &error);
|
||||||
|
|
||||||
|
QByteArray authorization_header() const;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void StreamURLRequestFinished(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error = QString());
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void ExitReceived();
|
||||||
|
void OAuthFinished(const bool success, const QString &error = QString());
|
||||||
|
void StreamURLRequestFinishedSlot(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error = QString());
|
||||||
|
|
||||||
|
private:
|
||||||
|
const SharedPtr<NetworkAccessManager> network_;
|
||||||
|
OAuthenticator *oauth_;
|
||||||
|
DropboxSongsRequest *songs_request_;
|
||||||
|
bool enabled_;
|
||||||
|
QList<QObject*> wait_for_exit_;
|
||||||
|
bool finished_;
|
||||||
|
uint next_stream_url_request_id_;
|
||||||
|
QMap<uint, QSharedPointer<DropboxStreamURLRequest>> stream_url_requests_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPBOXSERVICE_H
|
||||||
244
src/dropbox/dropboxsongsrequest.cpp
Normal file
244
src/dropbox/dropboxsongsrequest.cpp
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonValue>
|
||||||
|
|
||||||
|
#include "constants/dropboxsettings.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
|
#include "collection/collectionbackend.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
#include "dropboxbaserequest.h"
|
||||||
|
#include "dropboxsongsrequest.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
using namespace DropboxSettings;
|
||||||
|
|
||||||
|
DropboxSongsRequest::DropboxSongsRequest(const SharedPtr<NetworkAccessManager> network, const SharedPtr<CollectionBackend> collection_backend, DropboxService *service, QObject *parent)
|
||||||
|
: DropboxBaseRequest(network, service, parent),
|
||||||
|
network_(network),
|
||||||
|
collection_backend_(collection_backend),
|
||||||
|
service_(service) {}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::GetFolderList() {
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
QString cursor = s.value("cursor").toString();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
QUrl url(QLatin1String(kApiUrl) + "/2/files/list_folder"_L1);
|
||||||
|
QJsonObject json_object;
|
||||||
|
|
||||||
|
if (cursor.isEmpty()) {
|
||||||
|
json_object.insert("path"_L1, ""_L1);
|
||||||
|
json_object.insert("recursive"_L1, true);
|
||||||
|
json_object.insert("include_deleted"_L1, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url.setUrl(QLatin1String(kApiUrl) + "/2/files/list_folder/continue"_L1);
|
||||||
|
json_object.insert("cursor"_L1, cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkReply *reply = CreatePostRequest(url, json_object);
|
||||||
|
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply] { GetFolderListFinished(reply); });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::GetFolderListFinished(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||||
|
if (json_object_result.success()) {
|
||||||
|
Error(json_object_result.error_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonObject &json_object = json_object_result.json_object;
|
||||||
|
if (json_object.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_object.contains("reset"_L1) && json_object["reset"_L1].toBool()) {
|
||||||
|
qLog(Debug) << "Resetting Dropbox database";
|
||||||
|
collection_backend_->DeleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue("cursor", json_object["cursor"_L1].toString());
|
||||||
|
s.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonArray entires = json_object["entries"_L1].toArray();
|
||||||
|
qLog(Debug) << "File list found:" << entires.size();
|
||||||
|
|
||||||
|
QList<QUrl> urls_deleted;
|
||||||
|
for (const QJsonValue &value_entry : entires) {
|
||||||
|
if (!value_entry.isObject()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const QJsonObject object_entry = value_entry.toObject();
|
||||||
|
const QString tag = object_entry[".tag"_L1].toString();
|
||||||
|
const QString path = object_entry["path_lower"_L1].toString();
|
||||||
|
const qint64 size = object_entry["size"_L1].toInt();
|
||||||
|
const QString server_modified = object_entry["server_modified"_L1].toString();
|
||||||
|
|
||||||
|
QUrl url;
|
||||||
|
url.setScheme(service_->url_scheme());
|
||||||
|
url.setPath(path);
|
||||||
|
|
||||||
|
if (tag == "deleted"_L1) {
|
||||||
|
qLog(Debug) << "Deleting song with URL" << url;
|
||||||
|
urls_deleted << url;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == "folder"_L1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DropboxService::IsSupportedFiletype(path)) {
|
||||||
|
GetStreamURL(url, path, size, QDateTime::fromString(server_modified, Qt::ISODate).toSecsSinceEpoch());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!urls_deleted.isEmpty()) {
|
||||||
|
collection_backend_->DeleteSongsByUrlsAsync(urls_deleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_object.contains("has_more"_L1) && json_object["has_more"_L1].isBool() && json_object["has_more"_L1].toBool()) {
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue("cursor", json_object["cursor"_L1].toVariant());
|
||||||
|
s.endGroup();
|
||||||
|
GetFolderList();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Long-poll wait for changes.
|
||||||
|
LongPollDelta();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::LongPollDelta() {
|
||||||
|
|
||||||
|
if (!service_->authenticated()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
const QString cursor = s.value("cursor").toString();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
QJsonObject json_object;
|
||||||
|
json_object.insert("cursor"_L1, cursor);
|
||||||
|
json_object.insert("timeout"_L1, 30);
|
||||||
|
|
||||||
|
QNetworkReply *reply = CreatePostRequest(QUrl(QLatin1String(kNotifyApiUrl) + "/2/files/list_folder/longpoll"_L1), json_object);
|
||||||
|
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply] { LongPollDeltaFinished(reply); });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::LongPollDeltaFinished(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||||
|
if (json_object_result.success()) {
|
||||||
|
Error(json_object_result.error_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonObject &json_object = json_object_result.json_object;
|
||||||
|
if (json_object["changes"_L1].toBool()) {
|
||||||
|
qLog(Debug) << "Dropbox: Received changes...";
|
||||||
|
GetFolderList();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bool ok = false;
|
||||||
|
int backoff = json_object["backoff"_L1].toString().toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
backoff = 10;
|
||||||
|
}
|
||||||
|
QTimer::singleShot(backoff * 1000, this, &DropboxSongsRequest::LongPollDelta);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::GetStreamURL(const QUrl &url, const QString &path, const qint64 size, const qint64 mtime) {
|
||||||
|
|
||||||
|
QNetworkReply *reply = GetTemporaryLink(url);
|
||||||
|
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, path, size, mtime]() {
|
||||||
|
GetStreamUrlFinished(reply, path, size, mtime);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::GetStreamUrlFinished(QNetworkReply *reply, const QString &filename, const qint64 size, const qint64 mtime) {
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
const JsonObjectResult json_object_result = ParseJsonObject(reply);
|
||||||
|
if (!json_object_result.success()) {
|
||||||
|
Error(json_object_result.error_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonObject &json_object = json_object_result.json_object;
|
||||||
|
if (json_object.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_object.contains("link"_L1)) {
|
||||||
|
Error(u"Missing link"_s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QUrl url = QUrl::fromEncoded(json_object["link"_L1].toVariant().toByteArray());
|
||||||
|
|
||||||
|
service_->MaybeAddFileToDatabase(url, filename, size, mtime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSongsRequest::Error(const QString &error_message, const QVariant &debug_output) {
|
||||||
|
|
||||||
|
qLog(Error) << service_name() << error_message;
|
||||||
|
if (debug_output.isValid()) {
|
||||||
|
qLog(Debug) << debug_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT ShowErrorDialog(error_message);
|
||||||
|
|
||||||
|
}
|
||||||
67
src/dropbox/dropboxsongsrequest.h
Normal file
67
src/dropbox/dropboxsongsrequest.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXSONGSREQUEST_H
|
||||||
|
#define DROPBOXSONGSREQUEST_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "dropboxbaserequest.h"
|
||||||
|
|
||||||
|
class NetworkAccessManager;
|
||||||
|
class CollectionBackend;
|
||||||
|
class QNetworkReply;
|
||||||
|
class DropboxService;
|
||||||
|
|
||||||
|
class DropboxSongsRequest : public DropboxBaseRequest {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxSongsRequest(const SharedPtr<NetworkAccessManager> network, const SharedPtr<CollectionBackend> collection_backend, DropboxService *service, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void ReloadSettings();
|
||||||
|
|
||||||
|
void GetFolderList();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void ShowErrorDialog(const QString &error);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LongPollDelta();
|
||||||
|
void GetStreamURL(const QUrl &url, const QString &path, const qint64 size, const qint64 mtime);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Error(const QString &error_message, const QVariant &debug_output = QVariant()) override;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void GetFolderListFinished(QNetworkReply *reply);
|
||||||
|
void LongPollDeltaFinished(QNetworkReply *reply);
|
||||||
|
void GetStreamUrlFinished(QNetworkReply *reply, const QString &filename, const qint64 size, const qint64 mtime);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const SharedPtr<NetworkAccessManager> network_;
|
||||||
|
const SharedPtr<CollectionBackend> collection_backend_;
|
||||||
|
DropboxService *service_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPBOXSONGSREQUEST_H
|
||||||
129
src/dropbox/dropboxstreamurlrequest.cpp
Normal file
129
src/dropbox/dropboxstreamurlrequest.cpp
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "core/networkaccessmanager.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
#include "dropboxbaserequest.h"
|
||||||
|
#include "dropboxstreamurlrequest.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
|
DropboxStreamURLRequest::DropboxStreamURLRequest(const SharedPtr<NetworkAccessManager> network, DropboxService *service, const uint id, const QUrl &media_url, QObject *parent)
|
||||||
|
: DropboxBaseRequest(network, service, parent),
|
||||||
|
network_(network),
|
||||||
|
service_(service),
|
||||||
|
id_(id),
|
||||||
|
media_url_(media_url),
|
||||||
|
reply_(nullptr) {}
|
||||||
|
|
||||||
|
DropboxStreamURLRequest::~DropboxStreamURLRequest() {
|
||||||
|
|
||||||
|
if (reply_) {
|
||||||
|
QObject::disconnect(reply_, nullptr, this, nullptr);
|
||||||
|
if (reply_->isRunning()) reply_->abort();
|
||||||
|
reply_->deleteLater();
|
||||||
|
reply_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::Cancel() {
|
||||||
|
|
||||||
|
if (reply_ && reply_->isRunning()) {
|
||||||
|
reply_->abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::Process() {
|
||||||
|
|
||||||
|
GetStreamURL();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::GetStreamURL() {
|
||||||
|
|
||||||
|
if (reply_) {
|
||||||
|
QObject::disconnect(reply_, nullptr, this, nullptr);
|
||||||
|
if (reply_->isRunning()) reply_->abort();
|
||||||
|
reply_->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
reply_ = GetTemporaryLink(media_url_);
|
||||||
|
QObject::connect(reply_, &QNetworkReply::finished, this, &DropboxStreamURLRequest::StreamURLReceived);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::StreamURLReceived() {
|
||||||
|
|
||||||
|
const QScopeGuard finish = qScopeGuard([this]() { Finish(); });
|
||||||
|
|
||||||
|
if (!reply_) return;
|
||||||
|
|
||||||
|
Q_ASSERT(replies_.contains(reply_));
|
||||||
|
replies_.removeAll(reply_);
|
||||||
|
|
||||||
|
const JsonObjectResult json_object_result = ParseJsonObject(reply_).json_object;
|
||||||
|
|
||||||
|
QObject::disconnect(reply_, nullptr, this, nullptr);
|
||||||
|
reply_->deleteLater();
|
||||||
|
reply_ = nullptr;
|
||||||
|
|
||||||
|
if (!json_object_result.success()) {
|
||||||
|
Error(json_object_result.error_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonObject &json_object = json_object_result.json_object;
|
||||||
|
if (json_object.isEmpty() || !json_object.contains("link"_L1)) {
|
||||||
|
Error(u"Could not parse stream URL"_s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream_url_ = QUrl::fromEncoded(json_object["link"_L1].toVariant().toByteArray());
|
||||||
|
success_ = stream_url_.isValid();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::Error(const QString &error_message, const QVariant &debug_output) {
|
||||||
|
|
||||||
|
qLog(Error) << service_name() << error_message;
|
||||||
|
if (debug_output.isValid()) {
|
||||||
|
qLog(Debug) << debug_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_ = error_message;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxStreamURLRequest::Finish() {
|
||||||
|
|
||||||
|
Q_EMIT StreamURLRequestFinished(id_, media_url_, success_, stream_url_, error_);
|
||||||
|
|
||||||
|
}
|
||||||
71
src/dropbox/dropboxstreamurlrequest.h
Normal file
71
src/dropbox/dropboxstreamurlrequest.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXSTREAMURLREQUEST_H
|
||||||
|
#define DROPBOXSTREAMURLREQUEST_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
#include "dropboxbaserequest.h"
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
|
||||||
|
class DropboxStreamURLRequest : public DropboxBaseRequest {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxStreamURLRequest(const SharedPtr<NetworkAccessManager> network, DropboxService *service, const uint id, const QUrl &media_url, QObject *parent = nullptr);
|
||||||
|
~DropboxStreamURLRequest() override;
|
||||||
|
|
||||||
|
void Process();
|
||||||
|
void Cancel();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void StreamURLRequestFinished(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error = QString());
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void StreamURLReceived();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetStreamURL();
|
||||||
|
void Error(const QString &error_message, const QVariant &debug_output = QVariant()) override;
|
||||||
|
void Finish();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const SharedPtr<NetworkAccessManager> network_;
|
||||||
|
DropboxService *service_;
|
||||||
|
uint id_;
|
||||||
|
QUrl media_url_;
|
||||||
|
QUrl stream_url_;
|
||||||
|
QNetworkReply *reply_;
|
||||||
|
bool success_;
|
||||||
|
QString error_;
|
||||||
|
};
|
||||||
|
|
||||||
|
using DropboxStreamURLRequestPtr = QSharedPointer<DropboxStreamURLRequest>;
|
||||||
|
|
||||||
|
#endif // DROPBOXSTREAMURLREQUEST_H
|
||||||
76
src/dropbox/dropboxurlhandler.cpp
Normal file
76
src/dropbox/dropboxurlhandler.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "core/taskmanager.h"
|
||||||
|
#include "dropboxurlhandler.h"
|
||||||
|
#include "dropboxservice.h"
|
||||||
|
|
||||||
|
DropboxUrlHandler::DropboxUrlHandler(const SharedPtr<TaskManager> task_manager, DropboxService *service, QObject *parent)
|
||||||
|
: UrlHandler(parent),
|
||||||
|
task_manager_(task_manager),
|
||||||
|
service_(service) {
|
||||||
|
|
||||||
|
QObject::connect(service, &DropboxService::StreamURLRequestFinished, this, &DropboxUrlHandler::StreamURLRequestFinished);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DropboxUrlHandler::scheme() const { return service_->url_scheme(); }
|
||||||
|
|
||||||
|
UrlHandler::LoadResult DropboxUrlHandler::StartLoading(const QUrl &url) {
|
||||||
|
|
||||||
|
Request request;
|
||||||
|
request.task_id = task_manager_->StartTask(QStringLiteral("Loading %1 stream...").arg(url.scheme()));
|
||||||
|
QString error;
|
||||||
|
request.id = service_->GetStreamURL(url, error);
|
||||||
|
if (request.id == 0) {
|
||||||
|
CancelTask(request.task_id);
|
||||||
|
return LoadResult(url, LoadResult::Type::Error, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
requests_.insert(request.id, request);
|
||||||
|
|
||||||
|
LoadResult load_result(url);
|
||||||
|
load_result.type_ = LoadResult::Type::WillLoadAsynchronously;
|
||||||
|
|
||||||
|
return load_result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxUrlHandler::StreamURLRequestFinished(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error) {
|
||||||
|
|
||||||
|
if (!requests_.contains(id)) return;
|
||||||
|
const Request request = requests_.take(id);
|
||||||
|
CancelTask(request.task_id);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Q_EMIT AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::TrackAvailable, stream_url));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Q_EMIT AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::Error, error));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxUrlHandler::CancelTask(const int task_id) {
|
||||||
|
task_manager_->SetTaskFinished(task_id);
|
||||||
|
}
|
||||||
56
src/dropbox/dropboxurlhandler.h
Normal file
56
src/dropbox/dropboxurlhandler.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXURLHANDLER_H
|
||||||
|
#define DROPBOXURLHANDLER_H
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "core/urlhandler.h"
|
||||||
|
|
||||||
|
class TaskManager;
|
||||||
|
class DropboxService;
|
||||||
|
|
||||||
|
class DropboxUrlHandler : public UrlHandler {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxUrlHandler(const SharedPtr<TaskManager> task_manager, DropboxService *service, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
QString scheme() const override;
|
||||||
|
LoadResult StartLoading(const QUrl &url) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CancelTask(const int task_id);
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void StreamURLRequestFinished(const uint id, const QUrl &media_url, const bool success, const QUrl &stream_url, const QString &error = QString());
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Request {
|
||||||
|
public:
|
||||||
|
explicit Request() : id(0), task_id(-1) {}
|
||||||
|
uint id;
|
||||||
|
int task_id;
|
||||||
|
};
|
||||||
|
const SharedPtr<TaskManager> task_manager_;
|
||||||
|
DropboxService *service_;
|
||||||
|
QMap<uint, Request> requests_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPBOXURLHANDLER_H
|
||||||
@@ -178,7 +178,6 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
|
|||||||
audiobin_(nullptr),
|
audiobin_(nullptr),
|
||||||
audiosink_(nullptr),
|
audiosink_(nullptr),
|
||||||
audioqueue_(nullptr),
|
audioqueue_(nullptr),
|
||||||
audioqueueconverter_(nullptr),
|
|
||||||
volume_(nullptr),
|
volume_(nullptr),
|
||||||
volume_sw_(nullptr),
|
volume_sw_(nullptr),
|
||||||
volume_fading_(nullptr),
|
volume_fading_(nullptr),
|
||||||
@@ -187,6 +186,7 @@ GstEnginePipeline::GstEnginePipeline(QObject *parent)
|
|||||||
equalizer_(nullptr),
|
equalizer_(nullptr),
|
||||||
equalizer_preamp_(nullptr),
|
equalizer_preamp_(nullptr),
|
||||||
eventprobe_(nullptr),
|
eventprobe_(nullptr),
|
||||||
|
bufferprobe_(nullptr),
|
||||||
logged_unsupported_analyzer_format_(false),
|
logged_unsupported_analyzer_format_(false),
|
||||||
about_to_finish_(false),
|
about_to_finish_(false),
|
||||||
finish_requested_(false),
|
finish_requested_(false),
|
||||||
@@ -436,7 +436,7 @@ void GstEnginePipeline::Disconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_probe_cb_id_.has_value()) {
|
if (buffer_probe_cb_id_.has_value()) {
|
||||||
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
|
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
|
||||||
if (pad) {
|
if (pad) {
|
||||||
gst_pad_remove_probe(pad, buffer_probe_cb_id_.value());
|
gst_pad_remove_probe(pad, buffer_probe_cb_id_.value());
|
||||||
gst_object_unref(pad);
|
gst_object_unref(pad);
|
||||||
@@ -674,8 +674,13 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
audioqueueconverter_ = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
|
GstElement *audioqueueconverter = CreateElement(u"audioconvert"_s, u"audioqueueconverter"_s, audiobin_, error);
|
||||||
if (!audioqueueconverter_) {
|
if (!audioqueueconverter) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstElement *audioqueueresampler = CreateElement(u"audioresample"_s, u"audioqueueresampler"_s, audiobin_, error);
|
||||||
|
if (!audioqueueresampler) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,6 +689,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstElement *audiosinkresampler = CreateElement(u"audioresample"_s, u"audiosinkresampler"_s, audiobin_, error);
|
||||||
|
if (!audiosinkresampler) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the volume element if it's enabled.
|
// Create the volume element if it's enabled.
|
||||||
if (volume_enabled_ && !volume_) {
|
if (volume_enabled_ && !volume_) {
|
||||||
volume_sw_ = CreateElement(u"volume"_s, u"volume_sw"_s, audiobin_, error);
|
volume_sw_ = CreateElement(u"volume"_s, u"volume_sw"_s, audiobin_, error);
|
||||||
@@ -761,7 +771,8 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eventprobe_ = audioqueueconverter_;
|
eventprobe_ = audioqueueconverter;
|
||||||
|
bufferprobe_ = audioqueueconverter;
|
||||||
|
|
||||||
// Create the replaygain elements if it's enabled.
|
// Create the replaygain elements if it's enabled.
|
||||||
GstElement *rgvolume = nullptr;
|
GstElement *rgvolume = nullptr;
|
||||||
@@ -847,12 +858,17 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
|
|
||||||
// Link all elements
|
// Link all elements
|
||||||
|
|
||||||
if (!gst_element_link(audioqueue_, audioqueueconverter_)) {
|
if (!gst_element_link(audioqueue_, audioqueueconverter)) {
|
||||||
error = u"Failed to link audio queue to audio queue converter."_s;
|
error = u"Failed to link audio queue to audio queue converter."_s;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstElement *element_link = audioqueueconverter_; // The next element to link from.
|
if (!gst_element_link(audioqueueconverter, audioqueueresampler)) {
|
||||||
|
error = u"Failed to link audio queue converter to audio queue resampler."_s;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstElement *element_link = audioqueueresampler; // The next element to link from.
|
||||||
|
|
||||||
// Link replaygain elements if enabled.
|
// Link replaygain elements if enabled.
|
||||||
if (rg_enabled_ && rgvolume && rglimiter && rgconverter) {
|
if (rg_enabled_ && rgvolume && rglimiter && rgconverter) {
|
||||||
@@ -928,6 +944,11 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gst_element_link(audiosinkconverter, audiosinkresampler)) {
|
||||||
|
error = "Failed to link audio sink converter to audio sink resampler."_L1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw");
|
||||||
if (!caps) {
|
if (!caps) {
|
||||||
@@ -938,16 +959,16 @@ bool GstEnginePipeline::InitAudioBin(QString &error) {
|
|||||||
qLog(Debug) << "Setting channels to" << channels_;
|
qLog(Debug) << "Setting channels to" << channels_;
|
||||||
gst_caps_set_simple(caps, "channels", G_TYPE_INT, channels_, nullptr);
|
gst_caps_set_simple(caps, "channels", G_TYPE_INT, channels_, nullptr);
|
||||||
}
|
}
|
||||||
const bool link_filtered_result = gst_element_link_filtered(audiosinkconverter, audiosink_, caps);
|
const bool link_filtered_result = gst_element_link_filtered(audiosinkresampler, audiosink_, caps);
|
||||||
gst_caps_unref(caps);
|
gst_caps_unref(caps);
|
||||||
if (!link_filtered_result) {
|
if (!link_filtered_result) {
|
||||||
error = "Failed to link audio sink converter to audio sink with filter for "_L1 + output_;
|
error = "Failed to link audio sink resampler to audio sink with filter for "_L1 + output_;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Add probes and handlers.
|
{ // Add probes and handlers.
|
||||||
GstPad *pad = gst_element_get_static_pad(audioqueueconverter_, "src");
|
GstPad *pad = gst_element_get_static_pad(bufferprobe_, "src");
|
||||||
if (pad) {
|
if (pad) {
|
||||||
buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr);
|
buffer_probe_cb_id_ = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, BufferProbeCallback, this, nullptr);
|
||||||
gst_object_unref(pad);
|
gst_object_unref(pad);
|
||||||
|
|||||||
@@ -355,7 +355,6 @@ class GstEnginePipeline : public QObject {
|
|||||||
GstElement *audiobin_;
|
GstElement *audiobin_;
|
||||||
GstElement *audiosink_;
|
GstElement *audiosink_;
|
||||||
GstElement *audioqueue_;
|
GstElement *audioqueue_;
|
||||||
GstElement *audioqueueconverter_;
|
|
||||||
GstElement *volume_;
|
GstElement *volume_;
|
||||||
GstElement *volume_sw_;
|
GstElement *volume_sw_;
|
||||||
GstElement *volume_fading_;
|
GstElement *volume_fading_;
|
||||||
@@ -364,6 +363,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
GstElement *equalizer_;
|
GstElement *equalizer_;
|
||||||
GstElement *equalizer_preamp_;
|
GstElement *equalizer_preamp_;
|
||||||
GstElement *eventprobe_;
|
GstElement *eventprobe_;
|
||||||
|
GstElement *bufferprobe_;
|
||||||
|
|
||||||
std::optional<gulong> upstream_events_probe_cb_id_;
|
std::optional<gulong> upstream_events_probe_cb_id_;
|
||||||
std::optional<gulong> buffer_probe_cb_id_;
|
std::optional<gulong> buffer_probe_cb_id_;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
|
||||||
#include "globalshortcutsmanager.h"
|
#include "globalshortcutsmanager.h"
|
||||||
#include "globalshortcutsbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
@@ -58,29 +59,32 @@ using namespace Qt::Literals::StringLiterals;
|
|||||||
|
|
||||||
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent) {
|
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent) {
|
||||||
|
|
||||||
settings_.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
Settings s;
|
||||||
|
s.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
||||||
|
|
||||||
// Create actions
|
// Create actions
|
||||||
AddShortcut(u"play"_s, tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
|
AddShortcut(s, u"play"_s, tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
|
||||||
AddShortcut(u"pause"_s, tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
|
AddShortcut(s, u"pause"_s, tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
|
||||||
AddShortcut(u"play_pause"_s, tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
|
AddShortcut(s, u"play_pause"_s, tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
|
||||||
AddShortcut(u"stop"_s, tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
|
AddShortcut(s, u"stop"_s, tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
|
||||||
AddShortcut(u"stop_after"_s, tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
|
AddShortcut(s, u"stop_after"_s, tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
|
||||||
AddShortcut(u"next_track"_s, tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
|
AddShortcut(s, u"next_track"_s, tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
|
||||||
AddShortcut(u"prev_track"_s, tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
|
AddShortcut(s, u"prev_track"_s, tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
|
||||||
AddShortcut(u"restart_or_prev_track"_s, tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
|
AddShortcut(s, u"restart_or_prev_track"_s, tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
|
||||||
AddShortcut(u"inc_volume"_s, tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
|
AddShortcut(s, u"inc_volume"_s, tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
|
||||||
AddShortcut(u"dec_volume"_s, tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
|
AddShortcut(s, u"dec_volume"_s, tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
|
||||||
AddShortcut(u"mute"_s, tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
|
AddShortcut(s, u"mute"_s, tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
|
||||||
AddShortcut(u"seek_forward"_s, tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
|
AddShortcut(s, u"seek_forward"_s, tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
|
||||||
AddShortcut(u"seek_backward"_s, tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
|
AddShortcut(s, u"seek_backward"_s, tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
|
||||||
AddShortcut(u"show_hide"_s, tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
|
AddShortcut(s, u"show_hide"_s, tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
|
||||||
AddShortcut(u"show_osd"_s, tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
|
AddShortcut(s, u"show_osd"_s, tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
|
||||||
AddShortcut(u"toggle_pretty_osd"_s, tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
|
AddShortcut(s, u"toggle_pretty_osd"_s, tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
|
||||||
AddShortcut(u"shuffle_mode"_s, tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
|
AddShortcut(s, u"shuffle_mode"_s, tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
|
||||||
AddShortcut(u"repeat_mode"_s, tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
|
AddShortcut(s, u"repeat_mode"_s, tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
|
||||||
AddShortcut(u"toggle_scrobbling"_s, tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
|
AddShortcut(s, u"toggle_scrobbling"_s, tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
|
||||||
AddShortcut(u"love"_s, tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
|
AddShortcut(s, u"love"_s, tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
|
||||||
|
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
// Create backends - these do the actual shortcut registration
|
// Create backends - these do the actual shortcut registration
|
||||||
|
|
||||||
@@ -116,35 +120,39 @@ void GlobalShortcutsManager::ReloadSettings() {
|
|||||||
backends_enabled_ << GlobalShortcutsBackend::Type::Win;
|
backends_enabled_ << GlobalShortcutsBackend::Type::Win;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(GlobalShortcutsSettings::kSettingsGroup);
|
||||||
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
|
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
|
||||||
if (settings_.value(GlobalShortcutsSettings::kUseKGlobalAccel, true).toBool()) {
|
if (s.value(GlobalShortcutsSettings::kUseKGlobalAccel, true).toBool()) {
|
||||||
backends_enabled_ << GlobalShortcutsBackend::Type::KGlobalAccel;
|
backends_enabled_ << GlobalShortcutsBackend::Type::KGlobalAccel;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_X11_GLOBALSHORTCUTS
|
#ifdef HAVE_X11_GLOBALSHORTCUTS
|
||||||
if (settings_.value(GlobalShortcutsSettings::kUseX11, false).toBool()) {
|
if (s.value(GlobalShortcutsSettings::kUseX11, false).toBool()) {
|
||||||
backends_enabled_ << GlobalShortcutsBackend::Type::X11;
|
backends_enabled_ << GlobalShortcutsBackend::Type::X11;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
s.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
Unregister();
|
Unregister();
|
||||||
Register();
|
Register();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key) { // clazy:exclude=function-args-by-ref
|
void GlobalShortcutsManager::AddShortcut(Settings &s, const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key) { // clazy:exclude=function-args-by-ref
|
||||||
|
|
||||||
Shortcut shortcut = AddShortcut(id, name, default_key);
|
Shortcut shortcut = AddShortcut(s, id, name, default_key);
|
||||||
QObject::connect(shortcut.action, &QAction::triggered, this, signal);
|
QObject::connect(shortcut.action, &QAction::triggered, this, signal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key) {
|
GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(Settings &s, const QString &id, const QString &name, const QKeySequence &default_key) {
|
||||||
|
|
||||||
Shortcut shortcut;
|
Shortcut shortcut;
|
||||||
shortcut.action = new QAction(name, this);
|
shortcut.action = new QAction(name, this);
|
||||||
QKeySequence key_sequence = QKeySequence::fromString(settings_.value(id, default_key.toString()).toString());
|
QKeySequence key_sequence = QKeySequence::fromString(s.value(id, default_key.toString()).toString());
|
||||||
shortcut.action->setShortcut(key_sequence);
|
shortcut.action->setShortcut(key_sequence);
|
||||||
shortcut.id = id;
|
shortcut.id = id;
|
||||||
shortcut.default_key = default_key;
|
shortcut.default_key = default_key;
|
||||||
|
|||||||
@@ -32,15 +32,14 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include "globalshortcutsbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
|
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
class QShortcut;
|
class QShortcut;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
|
class Settings;
|
||||||
|
|
||||||
class GlobalShortcutsManager : public QWidget {
|
class GlobalShortcutsManager : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -99,12 +98,11 @@ class GlobalShortcutsManager : public QWidget {
|
|||||||
void Love();
|
void Love();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddShortcut(const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key = QKeySequence(0));
|
void AddShortcut(Settings &s, const QString &id, const QString &name, std::function<void()> signal, const QKeySequence &default_key = QKeySequence(0));
|
||||||
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
|
Shortcut AddShortcut(Settings &s, const QString &id, const QString &name, const QKeySequence &default_key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<GlobalShortcutsBackend*> backends_;
|
QList<GlobalShortcutsBackend*> backends_;
|
||||||
Settings settings_;
|
|
||||||
QList<GlobalShortcutsBackend::Type> backends_enabled_;
|
QList<GlobalShortcutsBackend::Type> backends_enabled_;
|
||||||
QMap<QString, Shortcut> shortcuts_;
|
QMap<QString, Shortcut> shortcuts_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ using namespace Qt::Literals::StringLiterals;
|
|||||||
using std::make_shared;
|
using std::make_shared;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr int kSongTableJoins = 2;
|
constexpr int kSongTableJoins = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistBackend::PlaylistBackend(const SharedPtr<Database> database,
|
PlaylistBackend::PlaylistBackend(const SharedPtr<Database> database,
|
||||||
@@ -186,10 +186,12 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(const int id) {
|
|||||||
|
|
||||||
QString PlaylistBackend::PlaylistItemsQuery() {
|
QString PlaylistBackend::PlaylistItemsQuery() {
|
||||||
|
|
||||||
return QStringLiteral("SELECT %1, %2, p.type FROM playlist_items AS p "
|
return QStringLiteral("SELECT %1, %2, %3, p.type FROM playlist_items AS p "
|
||||||
"LEFT JOIN songs ON p.type = songs.source AND p.collection_id = songs.ROWID "
|
"LEFT JOIN songs ON p.type = songs.source AND p.collection_id = songs.ROWID "
|
||||||
|
"LEFT JOIN dropbox_songs ON p.type = dropbox_songs.source AND p.collection_id = dropbox_songs.ROWID "
|
||||||
"WHERE p.playlist = :playlist"
|
"WHERE p.playlist = :playlist"
|
||||||
).arg(Song::JoinSpec(u"songs"_s),
|
).arg(Song::JoinSpec(u"songs"_s),
|
||||||
|
Song::JoinSpec(u"dropbox_songs"_s),
|
||||||
Song::JoinSpec(u"p"_s));
|
Song::JoinSpec(u"p"_s));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,8 +106,6 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
|||||||
no_matches_font.setBold(true);
|
no_matches_font.setBold(true);
|
||||||
no_matches_label_->setFont(no_matches_font);
|
no_matches_label_->setFont(no_matches_font);
|
||||||
|
|
||||||
settings_.beginGroup(kSettingsGroup);
|
|
||||||
|
|
||||||
// Tab bar
|
// Tab bar
|
||||||
ui_->tab_bar->setExpanding(false);
|
ui_->tab_bar->setExpanding(false);
|
||||||
ui_->tab_bar->setMovable(true);
|
ui_->tab_bar->setMovable(true);
|
||||||
@@ -257,7 +255,11 @@ void PlaylistContainer::ReloadSettings() {
|
|||||||
ui_->redo->setIconSize(QSize(iconsize, iconsize));
|
ui_->redo->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->search_field->setIconSize(iconsize);
|
ui_->search_field->setIconSize(iconsize);
|
||||||
|
|
||||||
bool playlist_clear = settings_.value("playlist_clear", true).toBool();
|
s.beginGroup(kSettingsGroup);
|
||||||
|
const bool playlist_clear = s.value("playlist_clear", true).toBool();
|
||||||
|
const bool show_toolbar = s.value("show_toolbar", true).toBool();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
if (playlist_clear) {
|
if (playlist_clear) {
|
||||||
ui_->clear->show();
|
ui_->clear->show();
|
||||||
}
|
}
|
||||||
@@ -265,7 +267,6 @@ void PlaylistContainer::ReloadSettings() {
|
|||||||
ui_->clear->hide();
|
ui_->clear->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool show_toolbar = settings_.value("show_toolbar", true).toBool();
|
|
||||||
ui_->toolbar->setVisible(show_toolbar);
|
ui_->toolbar->setVisible(show_toolbar);
|
||||||
|
|
||||||
if (!show_toolbar) ui_->search_field->clear();
|
if (!show_toolbar) ui_->search_field->clear();
|
||||||
@@ -308,7 +309,12 @@ void PlaylistContainer::PlaylistAdded(const int id, const QString &name, const b
|
|||||||
ui_->tab_bar->InsertTab(id, index, name, favorite);
|
ui_->tab_bar->InsertTab(id, index, name, favorite);
|
||||||
|
|
||||||
// Are we start up, should we select this tab?
|
// Are we start up, should we select this tab?
|
||||||
if (starting_up_ && settings_.value("current_playlist", 1).toInt() == id) {
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
const int current_playlist = s.value("current_playlist", 1).toInt();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
if (starting_up_ && current_playlist == id) {
|
||||||
starting_up_ = false;
|
starting_up_ = false;
|
||||||
ui_->tab_bar->set_current_id(id);
|
ui_->tab_bar->set_current_id(id);
|
||||||
}
|
}
|
||||||
@@ -347,12 +353,14 @@ void PlaylistContainer::NewPlaylist() { manager_->New(tr("Playlist")); }
|
|||||||
|
|
||||||
void PlaylistContainer::LoadPlaylist() {
|
void PlaylistContainer::LoadPlaylist() {
|
||||||
|
|
||||||
QString filename = settings_.value("last_load_playlist").toString();
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
QString filename = s.value("last_load_playlist").toString();
|
||||||
filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters(PlaylistParser::Type::Load));
|
filename = QFileDialog::getOpenFileName(this, tr("Load playlist"), filename, manager_->parser()->filters(PlaylistParser::Type::Load));
|
||||||
|
|
||||||
if (filename.isNull()) return;
|
if (filename.isNull()) return;
|
||||||
|
|
||||||
settings_.setValue("last_load_playlist", filename);
|
s.setValue("last_load_playlist", filename);
|
||||||
|
|
||||||
manager_->Load(filename);
|
manager_->Load(filename);
|
||||||
|
|
||||||
@@ -391,7 +399,10 @@ void PlaylistContainer::Save() {
|
|||||||
|
|
||||||
if (starting_up_) return;
|
if (starting_up_) return;
|
||||||
|
|
||||||
settings_.setValue("current_playlist", ui_->tab_bar->current_id());
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue("current_playlist", ui_->tab_bar->current_id());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class QTimeLine;
|
class QTimeLine;
|
||||||
@@ -45,7 +44,6 @@ class PlaylistView;
|
|||||||
class Ui_PlaylistContainer;
|
class Ui_PlaylistContainer;
|
||||||
|
|
||||||
#include "includes/shared_ptr.h"
|
#include "includes/shared_ptr.h"
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
class PlaylistContainer : public QWidget {
|
class PlaylistContainer : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -118,7 +116,6 @@ class PlaylistContainer : public QWidget {
|
|||||||
QAction *redo_;
|
QAction *redo_;
|
||||||
Playlist *playlist_;
|
Playlist *playlist_;
|
||||||
|
|
||||||
Settings settings_;
|
|
||||||
bool starting_up_;
|
bool starting_up_;
|
||||||
|
|
||||||
bool tab_bar_visible_;
|
bool tab_bar_visible_;
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ PlaylistItemPtr PlaylistItem::NewFromSource(const Song::Source source) {
|
|||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case Song::Source::Collection:
|
case Song::Source::Collection:
|
||||||
|
case Song::Source::Dropbox:
|
||||||
|
case Song::Source::OneDrive:
|
||||||
return make_shared<CollectionPlaylistItem>(source);
|
return make_shared<CollectionPlaylistItem>(source);
|
||||||
case Song::Source::Subsonic:
|
case Song::Source::Subsonic:
|
||||||
case Song::Source::Tidal:
|
case Song::Source::Tidal:
|
||||||
@@ -72,6 +74,8 @@ PlaylistItemPtr PlaylistItem::NewFromSong(const Song &song) {
|
|||||||
|
|
||||||
switch (song.source()) {
|
switch (song.source()) {
|
||||||
case Song::Source::Collection:
|
case Song::Source::Collection:
|
||||||
|
case Song::Source::Dropbox:
|
||||||
|
case Song::Source::OneDrive:
|
||||||
return make_shared<CollectionPlaylistItem>(song);
|
return make_shared<CollectionPlaylistItem>(song);
|
||||||
case Song::Source::Subsonic:
|
case Song::Source::Subsonic:
|
||||||
case Song::Source::Tidal:
|
case Song::Source::Tidal:
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -34,12 +33,9 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QScreen>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
|
|
||||||
#include "core/iconloader.h"
|
#include "core/iconloader.h"
|
||||||
#include "core/settingsprovider.h"
|
#include "core/settingsprovider.h"
|
||||||
#include "utilities/screenutils.h"
|
|
||||||
#include "playlistsequence.h"
|
#include "playlistsequence.h"
|
||||||
#include "ui_playlistsequence.h"
|
#include "ui_playlistsequence.h"
|
||||||
|
|
||||||
@@ -47,14 +43,7 @@ using namespace Qt::Literals::StringLiterals;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr char kSettingsGroup[] = "PlaylistSequence";
|
constexpr char kSettingsGroup[] = "PlaylistSequence";
|
||||||
|
}
|
||||||
// Base icon size for reference resolution (1920x1080 at 1.0 scale)
|
|
||||||
constexpr int kBaseIconSize = 20;
|
|
||||||
constexpr int kReferenceWidth = 1920;
|
|
||||||
constexpr int kReferenceHeight = 1080;
|
|
||||||
constexpr qreal kReferenceDevicePixelRatio = 1.0;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings)
|
PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
@@ -71,11 +60,9 @@ PlaylistSequence::PlaylistSequence(QWidget *parent, SettingsProvider *settings)
|
|||||||
// Icons
|
// Icons
|
||||||
ui_->repeat->setIcon(AddDesaturatedIcon(IconLoader::Load(u"media-playlist-repeat"_s)));
|
ui_->repeat->setIcon(AddDesaturatedIcon(IconLoader::Load(u"media-playlist-repeat"_s)));
|
||||||
ui_->shuffle->setIcon(AddDesaturatedIcon(IconLoader::Load(u"media-playlist-shuffle"_s)));
|
ui_->shuffle->setIcon(AddDesaturatedIcon(IconLoader::Load(u"media-playlist-shuffle"_s)));
|
||||||
|
const int base_icon_size = static_cast<int>(fontMetrics().height() * 1.2);
|
||||||
// Calculate icon size dynamically based on screen resolution, aspect ratio, and scaling
|
ui_->repeat->setIconSize(QSize(base_icon_size, base_icon_size));
|
||||||
const int icon_size = CalculateIconSize();
|
ui_->shuffle->setIconSize(QSize(base_icon_size, base_icon_size));
|
||||||
ui_->repeat->setIconSize(QSize(icon_size, icon_size));
|
|
||||||
ui_->shuffle->setIconSize(QSize(icon_size, icon_size));
|
|
||||||
|
|
||||||
// Remove arrow indicators
|
// Remove arrow indicators
|
||||||
ui_->repeat->setStyleSheet(u"QToolButton::menu-indicator { image: none; }"_s);
|
ui_->repeat->setStyleSheet(u"QToolButton::menu-indicator { image: none; }"_s);
|
||||||
@@ -112,48 +99,6 @@ PlaylistSequence::~PlaylistSequence() {
|
|||||||
delete ui_;
|
delete ui_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlaylistSequence::CalculateIconSize() {
|
|
||||||
|
|
||||||
// Get screen information for the widget
|
|
||||||
QScreen *screen = Utilities::GetScreen(this);
|
|
||||||
if (!screen) {
|
|
||||||
screen = QGuiApplication::primaryScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!screen) {
|
|
||||||
// Fallback to a reasonable default if no screen is available
|
|
||||||
return kBaseIconSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get screen properties
|
|
||||||
const QSize screen_size = screen->size();
|
|
||||||
const qreal device_pixel_ratio = screen->devicePixelRatio();
|
|
||||||
const int screen_width = screen_size.width();
|
|
||||||
const int screen_height = screen_size.height();
|
|
||||||
|
|
||||||
// Calculate scaling factors based on resolution
|
|
||||||
// Use the smaller dimension to handle both landscape and portrait orientations
|
|
||||||
const int min_dimension = std::min(screen_width, screen_height);
|
|
||||||
const int ref_min_dimension = std::min(kReferenceWidth, kReferenceHeight);
|
|
||||||
const qreal resolution_factor = static_cast<qreal>(min_dimension) / static_cast<qreal>(ref_min_dimension);
|
|
||||||
|
|
||||||
// Apply device pixel ratio (for high-DPI displays)
|
|
||||||
const qreal dpi_factor = device_pixel_ratio / kReferenceDevicePixelRatio;
|
|
||||||
|
|
||||||
// Calculate final icon size with combined scaling
|
|
||||||
// Formula: 50% from resolution scaling + 50% from DPI scaling + 50% base multiplier
|
|
||||||
// The 0.5 base ensures icons scale up appropriately across different displays
|
|
||||||
// Without it, icons would be too small on average displays
|
|
||||||
const qreal combined_factor = (resolution_factor * 0.5) + (dpi_factor * 0.5) + 0.5;
|
|
||||||
int calculated_size = static_cast<int>(kBaseIconSize * combined_factor);
|
|
||||||
|
|
||||||
// Clamp to reasonable bounds (minimum 16px, maximum 48px)
|
|
||||||
calculated_size = std::max(16, std::min(48, calculated_size));
|
|
||||||
|
|
||||||
return calculated_size;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaylistSequence::Load() {
|
void PlaylistSequence::Load() {
|
||||||
|
|
||||||
loading_ = true; // Stops these setter functions calling Save()
|
loading_ = true; // Stops these setter functions calling Save()
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ class PlaylistSequence : public QWidget {
|
|||||||
private:
|
private:
|
||||||
void Load();
|
void Load();
|
||||||
void Save();
|
void Save();
|
||||||
int CalculateIconSize();
|
|
||||||
static QIcon AddDesaturatedIcon(const QIcon &icon);
|
static QIcon AddDesaturatedIcon(const QIcon &icon);
|
||||||
static QPixmap DesaturatedPixmap(const QPixmap &pixmap);
|
static QPixmap DesaturatedPixmap(const QPixmap &pixmap);
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@
|
|||||||
#include <QLinearGradient>
|
#include <QLinearGradient>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QtEvents>
|
#include <QtEvents>
|
||||||
#include <QSettings>
|
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
|
|
||||||
#include "includes/qt_blurimage.h"
|
#include "includes/qt_blurimage.h"
|
||||||
|
|||||||
@@ -80,12 +80,13 @@ void SongLoaderInserter::Load(Playlist *destination, const int row, const bool p
|
|||||||
songs_ << loader->songs();
|
songs_ << loader->songs();
|
||||||
playlist_name_ = loader->playlist_name();
|
playlist_name_ = loader->playlist_name();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
const QStringList errors = loader->errors();
|
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
|
||||||
for (const QString &error : errors) {
|
const QStringList errors = loader->errors();
|
||||||
Q_EMIT Error(error);
|
for (const QString &error : errors) {
|
||||||
}
|
Q_EMIT Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete loader;
|
delete loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,11 +193,13 @@ void SongLoaderInserter::AsyncLoad() {
|
|||||||
const SongLoader::Result result = loader->LoadFilenamesBlocking();
|
const SongLoader::Result result = loader->LoadFilenamesBlocking();
|
||||||
task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(++async_progress));
|
task_manager_->SetTaskProgress(async_load_id, static_cast<quint64>(++async_progress));
|
||||||
|
|
||||||
|
// Always check for errors, even on success (e.g., playlist parsed but some songs failed to load)
|
||||||
|
const QStringList errors = loader->errors();
|
||||||
|
for (const QString &error : errors) {
|
||||||
|
Q_EMIT Error(error);
|
||||||
|
}
|
||||||
|
|
||||||
if (result == SongLoader::Result::Error) {
|
if (result == SongLoader::Result::Error) {
|
||||||
const QStringList errors = loader->errors();
|
|
||||||
for (const QString &error : errors) {
|
|
||||||
Q_EMIT Error(error);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ SongPlaylistItem::SongPlaylistItem(const Song::Source source) : PlaylistItem(sou
|
|||||||
SongPlaylistItem::SongPlaylistItem(const Song &song) : PlaylistItem(song.source()), song_(song) {}
|
SongPlaylistItem::SongPlaylistItem(const Song &song) : PlaylistItem(song.source()), song_(song) {}
|
||||||
|
|
||||||
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||||
song_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count()));
|
song_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count() * 2));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void StreamPlaylistItem::InitMetadata() {
|
|||||||
|
|
||||||
bool StreamPlaylistItem::InitFromQuery(const SqlRow &query) {
|
bool StreamPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||||
|
|
||||||
song_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count()));
|
song_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count() * 2));
|
||||||
InitMetadata();
|
InitMetadata();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -112,10 +112,18 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the file exists before trying to read it
|
||||||
|
if (!QFile::exists(filename)) {
|
||||||
|
qLog(Error) << "File does not exist:" << filename;
|
||||||
|
Q_EMIT Error(tr("File %1 does not exist").arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (tagreader_client_) {
|
if (tagreader_client_) {
|
||||||
const TagReaderResult result = tagreader_client_->ReadFileBlocking(filename, song);
|
const TagReaderResult result = tagreader_client_->ReadFileBlocking(filename, song);
|
||||||
if (!result.success()) {
|
if (!result.success()) {
|
||||||
qLog(Error) << "Could not read file" << filename << result.error_string();
|
qLog(Error) << "Could not read file" << filename << result.error_string();
|
||||||
|
Q_EMIT Error(tr("Could not read file %1: %2").arg(filename, result.error_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
144
src/settings/dropboxsettingspage.cpp
Normal file
144
src/settings/dropboxsettingspage.cpp
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
#include "constants/dropboxsettings.h"
|
||||||
|
#include "core/settings.h"
|
||||||
|
#include "core/iconloader.h"
|
||||||
|
#include "widgets/loginstatewidget.h"
|
||||||
|
#include "dropbox/dropboxservice.h"
|
||||||
|
#include "settingsdialog.h"
|
||||||
|
#include "dropboxsettingspage.h"
|
||||||
|
#include "ui_dropboxsettingspage.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
using namespace DropboxSettings;
|
||||||
|
|
||||||
|
DropboxSettingsPage::DropboxSettingsPage(SettingsDialog *dialog, const SharedPtr<DropboxService> service, QWidget *parent)
|
||||||
|
: SettingsPage(dialog, parent),
|
||||||
|
ui_(new Ui_DropboxSettingsPage),
|
||||||
|
service_(service) {
|
||||||
|
|
||||||
|
Q_ASSERT(service);
|
||||||
|
|
||||||
|
ui_->setupUi(this);
|
||||||
|
|
||||||
|
setWindowIcon(IconLoader::Load(u"dropbox"_s));
|
||||||
|
|
||||||
|
ui_->login_state->AddCredentialGroup(ui_->widget_authorization);
|
||||||
|
|
||||||
|
QObject::connect(ui_->button_login, &QPushButton::clicked, this, &DropboxSettingsPage::LoginClicked);
|
||||||
|
QObject::connect(ui_->button_reset, &QPushButton::clicked, this, &DropboxSettingsPage::ResetClicked);
|
||||||
|
QObject::connect(ui_->login_state, &LoginStateWidget::LogoutClicked, this, &DropboxSettingsPage::LogoutClicked);
|
||||||
|
|
||||||
|
QObject::connect(this, &DropboxSettingsPage::Authorize, &*service_, &DropboxService::Authenticate);
|
||||||
|
QObject::connect(&*service_, &StreamingService::LoginFailure, this, &DropboxSettingsPage::LoginFailure);
|
||||||
|
QObject::connect(&*service_, &StreamingService::LoginSuccess, this, &DropboxSettingsPage::LoginSuccess);
|
||||||
|
|
||||||
|
dialog->installEventFilter(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DropboxSettingsPage::~DropboxSettingsPage() {
|
||||||
|
delete ui_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::Load() {
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
ui_->enable->setChecked(s.value(kEnabled, false).toBool());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
if (service_->authenticated()) ui_->login_state->SetLoggedIn(LoginStateWidget::State::LoggedIn);
|
||||||
|
|
||||||
|
Init(ui_->layout_dropboxsettingspage->parentWidget());
|
||||||
|
|
||||||
|
if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::Save() {
|
||||||
|
|
||||||
|
Settings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue(kEnabled, ui_->enable->isChecked());
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::LoginClicked() {
|
||||||
|
|
||||||
|
Q_EMIT Authorize();
|
||||||
|
|
||||||
|
ui_->button_login->setEnabled(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropboxSettingsPage::eventFilter(QObject *object, QEvent *event) {
|
||||||
|
|
||||||
|
if (object == dialog() && event->type() == QEvent::Enter) {
|
||||||
|
ui_->button_login->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SettingsPage::eventFilter(object, event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::LogoutClicked() {
|
||||||
|
|
||||||
|
service_->ClearSession();
|
||||||
|
ui_->button_login->setEnabled(true);
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::State::LoggedOut);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::LoginSuccess() {
|
||||||
|
|
||||||
|
if (!isVisible()) return;
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::State::LoggedIn);
|
||||||
|
ui_->button_login->setEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::LoginFailure(const QString &failure_reason) {
|
||||||
|
|
||||||
|
if (!isVisible()) return;
|
||||||
|
QMessageBox::warning(this, tr("Authentication failed"), failure_reason);
|
||||||
|
ui_->button_login->setEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DropboxSettingsPage::ResetClicked() {
|
||||||
|
|
||||||
|
service_->Reset();
|
||||||
|
|
||||||
|
}
|
||||||
58
src/settings/dropboxsettingspage.h
Normal file
58
src/settings/dropboxsettingspage.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DROPBOXSETTINGSPAGE_H
|
||||||
|
#define DROPBOXSETTINGSPAGE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "settingspage.h"
|
||||||
|
|
||||||
|
class DropboxService;
|
||||||
|
class Ui_DropboxSettingsPage;
|
||||||
|
|
||||||
|
class DropboxSettingsPage : public SettingsPage {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DropboxSettingsPage(SettingsDialog *dialog, const SharedPtr<DropboxService> service, QWidget *parent);
|
||||||
|
~DropboxSettingsPage();
|
||||||
|
|
||||||
|
void Load() override;
|
||||||
|
void Save() override;
|
||||||
|
|
||||||
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void Authorize();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void LoginClicked();
|
||||||
|
void LogoutClicked();
|
||||||
|
void LoginSuccess();
|
||||||
|
void LoginFailure(const QString &failure_reason);
|
||||||
|
void ResetClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui_DropboxSettingsPage *ui_;
|
||||||
|
const SharedPtr<DropboxService> service_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DROPBOXSETTINGSPAGE_H
|
||||||
125
src/settings/dropboxsettingspage.ui
Normal file
125
src/settings/dropboxsettingspage.ui
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DropboxSettingsPage</class>
|
||||||
|
<widget class="QWidget" name="DropboxSettingsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>569</width>
|
||||||
|
<height>491</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dropbox</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="layout_dropboxsettingspage">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_info">
|
||||||
|
<property name="text">
|
||||||
|
<string>Strawberry can play music that you have uploaded to Dropbox</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="enable">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LoginStateWidget" name="login_state" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_authorization" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>28</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="button_login">
|
||||||
|
<property name="text">
|
||||||
|
<string>Login</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_login">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_buttons">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="button_reset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset cursor and songs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_buttons">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_bottom">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>357</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LoginStateWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>widgets/loginstatewidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -90,6 +90,10 @@
|
|||||||
# include "qobuz/qobuzservice.h"
|
# include "qobuz/qobuzservice.h"
|
||||||
# include "qobuzsettingspage.h"
|
# include "qobuzsettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
# include "dropbox/dropboxservice.h"
|
||||||
|
# include "dropboxsettingspage.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
|
|
||||||
@@ -144,7 +148,7 @@ SettingsDialog::SettingsDialog(const SharedPtr<Player> player,
|
|||||||
AddPage(Page::Moodbar, new MoodbarSettingsPage(this, this), iface);
|
AddPage(Page::Moodbar, new MoodbarSettingsPage(this, this), iface);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_SUBSONIC) || defined(HAVE_TIDAL) || defined(HAVE_SPOTIFY) || defined(HAVE_QOBUZ)
|
#if defined(HAVE_SUBSONIC) || defined(HAVE_TIDAL) || defined(HAVE_SPOTIFY) || defined(HAVE_QOBUZ) || defined(HAVE_DROPBOX)
|
||||||
QTreeWidgetItem *streaming = AddCategory(tr("Streaming"));
|
QTreeWidgetItem *streaming = AddCategory(tr("Streaming"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -160,6 +164,9 @@ SettingsDialog::SettingsDialog(const SharedPtr<Player> player,
|
|||||||
#ifdef HAVE_QOBUZ
|
#ifdef HAVE_QOBUZ
|
||||||
AddPage(Page::Qobuz, new QobuzSettingsPage(this, streaming_services->Service<QobuzService>(), this), streaming);
|
AddPage(Page::Qobuz, new QobuzSettingsPage(this, streaming_services->Service<QobuzService>(), this), streaming);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DROPBOX
|
||||||
|
AddPage(Page::Dropbox, new DropboxSettingsPage(this, streaming_services->Service<DropboxService>(), this), streaming);
|
||||||
|
#endif
|
||||||
|
|
||||||
// List box
|
// List box
|
||||||
QObject::connect(ui_->list, &QTreeWidget::currentItemChanged, this, &SettingsDialog::CurrentItemChanged);
|
QObject::connect(ui_->list, &QTreeWidget::currentItemChanged, this, &SettingsDialog::CurrentItemChanged);
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ class SettingsDialog : public QDialog {
|
|||||||
Tidal,
|
Tidal,
|
||||||
Qobuz,
|
Qobuz,
|
||||||
Spotify,
|
Spotify,
|
||||||
|
Dropbox,
|
||||||
|
OneDrive,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Role {
|
enum Role {
|
||||||
|
|||||||
134
src/streaming/cloudstoragestreamingservice.cpp
Normal file
134
src/streaming/cloudstoragestreamingservice.cpp
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "core/database.h"
|
||||||
|
#include "core/taskmanager.h"
|
||||||
|
#include "core/song.h"
|
||||||
|
#include "collection/collectionbackend.h"
|
||||||
|
#include "collection/collectionmodel.h"
|
||||||
|
#include "playlist/playlist.h"
|
||||||
|
#include "cloudstoragestreamingservice.h"
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
using std::make_shared;
|
||||||
|
|
||||||
|
CloudStorageStreamingService::CloudStorageStreamingService(const SharedPtr<TaskManager> task_manager,
|
||||||
|
const SharedPtr<Database> database,
|
||||||
|
const SharedPtr<TagReaderClient> tagreader_client,
|
||||||
|
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||||
|
const Song::Source source,
|
||||||
|
const QString &name,
|
||||||
|
const QString &url_scheme,
|
||||||
|
const QString &settings_group,
|
||||||
|
QObject *parent)
|
||||||
|
: StreamingService(source, name, url_scheme, settings_group, parent),
|
||||||
|
task_manager_(task_manager),
|
||||||
|
tagreader_client_(tagreader_client),
|
||||||
|
source_(source),
|
||||||
|
indexing_task_id_(-1),
|
||||||
|
indexing_task_progress_(0),
|
||||||
|
indexing_task_max_(0) {
|
||||||
|
|
||||||
|
collection_backend_ = make_shared<CollectionBackend>();
|
||||||
|
collection_backend_->moveToThread(database->thread());
|
||||||
|
collection_backend_->Init(database, task_manager, source, name + "_songs"_L1);
|
||||||
|
collection_model_ = new CollectionModel(collection_backend_, albumcover_loader, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudStorageStreamingService::MaybeAddFileToDatabase(const QUrl &url, const QString &filename, const size_t size, const quint64 mtime, const QString &token_type, const QString &access_token) {
|
||||||
|
|
||||||
|
if (!IsSupportedFiletype(filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indexing_task_id_ == -1) {
|
||||||
|
indexing_task_id_ = task_manager_->StartTask(tr("Indexing %1").arg(name()));
|
||||||
|
indexing_task_progress_ = 0;
|
||||||
|
indexing_task_max_ = 0;
|
||||||
|
}
|
||||||
|
indexing_task_max_++;
|
||||||
|
task_manager_->SetTaskProgress(indexing_task_id_, indexing_task_progress_, indexing_task_max_);
|
||||||
|
|
||||||
|
TagReaderReadStreamReplyPtr reply = tagreader_client_->ReadStreamAsync(url, filename, size, mtime, token_type, access_token);
|
||||||
|
pending_tagreader_replies_.append(reply);
|
||||||
|
|
||||||
|
SharedPtr<QMetaObject::Connection> connection = make_shared<QMetaObject::Connection>();
|
||||||
|
*connection = QObject::connect(&*reply, &TagReaderReadStreamReply::Finished, this, [this, reply, url, filename, connection]() {
|
||||||
|
ReadStreamFinished(reply, url, filename);
|
||||||
|
QObject::disconnect(*connection);
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudStorageStreamingService::ReadStreamFinished(TagReaderReadStreamReplyPtr reply, const QUrl url, const QString filename) {
|
||||||
|
|
||||||
|
++indexing_task_progress_;
|
||||||
|
if (indexing_task_progress_ >= indexing_task_max_) {
|
||||||
|
task_manager_->SetTaskFinished(indexing_task_id_);
|
||||||
|
indexing_task_id_ = -1;
|
||||||
|
Q_EMIT AllIndexingTasksFinished();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
task_manager_->SetTaskProgress(indexing_task_id_, indexing_task_progress_, indexing_task_max_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!reply->result().success()) {
|
||||||
|
qLog(Error) << "Failed to read tags from stream, URL" << url << reply->result().error_string();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Song song = reply->song();
|
||||||
|
song.set_source(source_);
|
||||||
|
song.set_directory_id(0);
|
||||||
|
QUrl song_url;
|
||||||
|
song_url.setScheme(url_scheme());
|
||||||
|
song_url.setPath(filename);
|
||||||
|
song.set_url(song_url);
|
||||||
|
|
||||||
|
collection_backend_->AddOrUpdateSongs(SongList() << song);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CloudStorageStreamingService::IsSupportedFiletype(const QString &filename) {
|
||||||
|
|
||||||
|
const QFileInfo fileinfo(filename);
|
||||||
|
return Song::kAcceptedExtensions.contains(fileinfo.suffix(), Qt::CaseInsensitive) && !Song::kRejectedExtensions.contains(fileinfo.suffix(), Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloudStorageStreamingService::AbortReadTagsReplies() {
|
||||||
|
|
||||||
|
qLog(Debug) << "Aborting the read tags replies";
|
||||||
|
|
||||||
|
pending_tagreader_replies_.clear();
|
||||||
|
|
||||||
|
task_manager_->SetTaskFinished(indexing_task_id_);
|
||||||
|
indexing_task_id_ = -1;
|
||||||
|
|
||||||
|
Q_EMIT AllIndexingTasksFinished();
|
||||||
|
|
||||||
|
}
|
||||||
89
src/streaming/cloudstoragestreamingservice.h
Normal file
89
src/streaming/cloudstoragestreamingservice.h
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLOUDSTORAGESTREAMINGSERVICE_H
|
||||||
|
#define CLOUDSTORAGESTREAMINGSERVICE_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
#include "includes/shared_ptr.h"
|
||||||
|
#include "tagreader/tagreaderclient.h"
|
||||||
|
#include "streamingservice.h"
|
||||||
|
#include "covermanager/albumcovermanager.h"
|
||||||
|
#include "collection/collectionmodel.h"
|
||||||
|
|
||||||
|
class TaskManager;
|
||||||
|
class Database;
|
||||||
|
class TagReaderClient;
|
||||||
|
class AlbumCoverLoader;
|
||||||
|
class CollectionBackend;
|
||||||
|
class CollectionModel;
|
||||||
|
class NetworkAccessManager;
|
||||||
|
|
||||||
|
class CloudStorageStreamingService : public StreamingService {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CloudStorageStreamingService(const SharedPtr<TaskManager> task_manager,
|
||||||
|
const SharedPtr<Database> database,
|
||||||
|
const SharedPtr<TagReaderClient> tagreader_client,
|
||||||
|
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||||
|
const Song::Source source,
|
||||||
|
const QString &name,
|
||||||
|
const QString &url_scheme,
|
||||||
|
const QString &settings_group,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
|
bool is_indexing() const { return indexing_task_id_ != -1; }
|
||||||
|
|
||||||
|
SharedPtr<CollectionBackend> collection_backend() const { return collection_backend_; }
|
||||||
|
CollectionModel *collection_model() const { return collection_model_; }
|
||||||
|
CollectionFilter *collection_filter_model() const { return collection_model_->filter(); }
|
||||||
|
|
||||||
|
SharedPtr<CollectionBackend> songs_collection_backend() override { return collection_backend_; }
|
||||||
|
CollectionModel *songs_collection_model() override { return collection_model_; }
|
||||||
|
CollectionFilter *songs_collection_filter_model() override { return collection_model_->filter(); }
|
||||||
|
|
||||||
|
virtual void MaybeAddFileToDatabase(const QUrl &url, const QString &filename, const size_t size, const quint64 mtime, const QString &token_type = QString(), const QString &access_token = QString());
|
||||||
|
static bool IsSupportedFiletype(const QString &filename);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void AllIndexingTasksFinished();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void AbortReadTagsReplies();
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void ReadStreamFinished(TagReaderReadStreamReplyPtr reply, const QUrl url, const QString filename);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const SharedPtr<TaskManager> task_manager_;
|
||||||
|
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||||
|
SharedPtr<CollectionBackend> collection_backend_;
|
||||||
|
CollectionModel *collection_model_;
|
||||||
|
QList<TagReaderReplyPtr> pending_tagreader_replies_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Song::Source source_;
|
||||||
|
int indexing_task_id_;
|
||||||
|
int indexing_task_progress_;
|
||||||
|
int indexing_task_max_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CLOUDSTORAGESTREAMINGSERVICE_H
|
||||||
@@ -5526,7 +5526,7 @@ Are you sure you want to continue?</source>
|
|||||||
<name>RadioParadiseService</name>
|
<name>RadioParadiseService</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Getting %1 channels</source>
|
<source>Getting %1 channels</source>
|
||||||
<translation>Получение %1 каналов</translation>
|
<translation>Получение каналов %1</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
@@ -6191,7 +6191,7 @@ Are you sure you want to continue?</source>
|
|||||||
<name>SomaFMService</name>
|
<name>SomaFMService</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Getting %1 channels</source>
|
<source>Getting %1 channels</source>
|
||||||
<translation>Получение %1 каналов</translation>
|
<translation>Получение каналов %1</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
|||||||
@@ -1187,7 +1187,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Queue to play next</source>
|
<source>Queue to play next</source>
|
||||||
<translation>Sıradaki Yap</translation>
|
<translation>Sıradaki yap</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Search for this</source>
|
<source>Search for this</source>
|
||||||
@@ -3496,7 +3496,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Queue to play next</source>
|
<source>Queue to play next</source>
|
||||||
<translation>Sıradaki Yap</translation>
|
<translation>Sıradaki yap</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Unskip track</source>
|
<source>Unskip track</source>
|
||||||
@@ -4431,7 +4431,7 @@ If there are no matches then it will use the largest image in the directory.</tr
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>&Hide %1</source>
|
<source>&Hide %1</source>
|
||||||
<translation>&%1'i sakla</translation>
|
<translation>&%1 ögesini sakla</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
@@ -6407,7 +6407,7 @@ Devam etmek istediğinizden emin misiniz?</translation>
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Queue to play next</source>
|
<source>Queue to play next</source>
|
||||||
<translation>Sıradaki Yap</translation>
|
<translation>Sıradaki yap</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Remove from favorites</source>
|
<source>Remove from favorites</source>
|
||||||
|
|||||||
@@ -142,6 +142,8 @@ QString CoverUtils::CoverFilenameFromSource(const Song::Source source, const QUr
|
|||||||
case Song::Source::Stream:
|
case Song::Source::Stream:
|
||||||
case Song::Source::SomaFM:
|
case Song::Source::SomaFM:
|
||||||
case Song::Source::RadioParadise:
|
case Song::Source::RadioParadise:
|
||||||
|
case Song::Source::Dropbox:
|
||||||
|
case Song::Source::OneDrive:
|
||||||
case Song::Source::Unknown:
|
case Song::Source::Unknown:
|
||||||
filename = QString::fromLatin1(Sha1CoverHash(artist, album).toHex());
|
filename = QString::fromLatin1(Sha1CoverHash(artist, album).toHex());
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user