Add Subsonic support (#180)

This commit is contained in:
Jonas Kvinge
2019-06-17 23:54:24 +02:00
committed by GitHub
parent a9da8811fc
commit 7b54cef23b
44 changed files with 2656 additions and 43 deletions

View File

@@ -71,6 +71,10 @@
# include "covermanager/tidalcoverprovider.h"
#endif
#ifdef HAVE_SUBSONIC
# include "subsonic/subsonicservice.h"
#endif
#ifdef HAVE_MOODBAR
# include "moodbar/moodbarcontroller.h"
# include "moodbar/moodbarloader.h"
@@ -135,6 +139,9 @@ class ApplicationImpl {
InternetServices *internet_services = new InternetServices(app);
#ifdef HAVE_TIDAL
internet_services->AddService(new TidalService(app, internet_services));
#endif
#ifdef HAVE_SUBSONIC
internet_services->AddService(new SubsonicService(app, internet_services));
#endif
return internet_services;
}),

View File

@@ -52,7 +52,7 @@
#include "scopedtransaction.h"
const char *Database::kDatabaseFilename = "strawberry.db";
const int Database::kSchemaVersion = 5;
const int Database::kSchemaVersion = 6;
const char *Database::kMagicAllSongsTables = "%allsongstables";
int Database::sNextConnectionId = 1;

View File

@@ -138,9 +138,14 @@
# include "tidal/tidalservice.h"
# include "settings/tidalsettingspage.h"
#endif
#ifdef HAVE_SUBSONIC
# include "subsonic/subsonicservice.h"
# include "settings/subsonicsettingspage.h"
#endif
#include "internet/internetservices.h"
#include "internet/internetservice.h"
#include "internet/internetsongsview.h"
#include "internet/internettabsview.h"
#include "scrobbler/audioscrobbler.h"
@@ -210,6 +215,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
}),
#ifdef HAVE_TIDAL
tidal_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source_Tidal), app_->tidal_search(), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page_Tidal, this)),
#endif
#ifdef HAVE_SUBSONIC
subsonic_view_(new InternetSongsView(app_, app->internet_services()->ServiceBySource(Song::Source_Subsonic), SubsonicSettingsPage::kSettingsGroup, SettingsDialog::Page_Subsonic, this)),
#endif
playlist_menu_(new QMenu(this)),
playlist_add_to_another_(nullptr),
@@ -265,6 +273,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
#ifdef HAVE_TIDAL
ui_->tabs->AddTab(tidal_view_, "tidal", IconLoader::Load("tidal"), tr("Tidal"));
#endif
#ifdef HAVE_SUBSONIC
ui_->tabs->AddTab(subsonic_view_, "subsonic", IconLoader::Load("subsonic"), tr("Subsonic"));
#endif
// Add the playing widget to the fancy tab widget
ui_->tabs->addBottomWidget(ui_->widget_playing);
@@ -558,6 +569,10 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
#endif
#ifdef HAVE_SUBSONIC
connect(subsonic_view_->view(), SIGNAL(AddToPlaylistSignal(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
#endif
// Playlist menu
playlist_play_pause_ = playlist_menu_->addAction(tr("Play"), this, SLOT(PlaylistPlay()));
playlist_menu_->addAction(ui_->action_stop);
@@ -874,6 +889,16 @@ void MainWindow::ReloadSettings() {
ui_->tabs->DisableTab(tidal_view_);
#endif
#ifdef HAVE_SUBSONIC
settings.beginGroup(SubsonicSettingsPage::kSettingsGroup);
bool enable_subsonic = settings.value("enabled", false).toBool();
settings.endGroup();
if (enable_subsonic)
ui_->tabs->EnableTab(subsonic_view_);
else
ui_->tabs->DisableTab(subsonic_view_);
#endif
}
void MainWindow::ReloadAllSettings() {
@@ -892,6 +917,9 @@ void MainWindow::ReloadAllSettings() {
#ifdef HAVE_TIDAL
tidal_view_->ReloadSettings();
#endif
#ifdef HAVE_SUBSONIC
subsonic_view_->ReloadSettings();
#endif
}

View File

@@ -91,6 +91,7 @@ class TranscodeDialog;
#endif
class Ui_MainWindow;
class Windows7ThumbBar;
class InternetSongsView;
class InternetTabsView;
class MainWindow : public QMainWindow, public PlatformInterface {
@@ -313,6 +314,7 @@ signals:
#endif
InternetTabsView *tidal_view_;
InternetSongsView *subsonic_view_;
QAction *collection_show_all_;
QAction *collection_show_duplicates_;

View File

@@ -333,7 +333,7 @@ bool Song::has_cue() const { return !d->cue_path_.isEmpty(); }
bool Song::is_collection_song() const { return !is_cdda() && !is_stream() && id() != -1; }
bool Song::is_metadata_good() const { return !d->title_.isEmpty() && !d->album_.isEmpty() && !d->artist_.isEmpty() && !d->url_.isEmpty() && d->end_ > 0; }
bool Song::is_stream() const { return d->source_ == Source_Stream || d->source_ == Source_Tidal; }
bool Song::is_stream() const { return d->source_ == Source_Stream || d->source_ == Source_Tidal || d->source_ == Source_Subsonic; }
bool Song::is_cdda() const { return d->source_ == Source_CDDA; }
const QString &Song::error() const { return d->error_; }
@@ -410,6 +410,7 @@ Song::Source Song::SourceFromURL(const QUrl &url) {
if (url.scheme() == "file") return Source_LocalFile;
else if (url.scheme() == "cdda") return Source_CDDA;
else if (url.scheme() == "tidal") return Source_Tidal;
else if (url.scheme() == "subsonic") return Source_Subsonic;
else if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "rtsp") return Source_Stream;
else return Source_Unknown;
@@ -424,8 +425,10 @@ QString Song::TextForSource(Source source) {
case Song::Source_Device: return QObject::tr("Device");
case Song::Source_Stream: return QObject::tr("Stream");
case Song::Source_Tidal: return QObject::tr("Tidal");
default: return QObject::tr("Unknown");
case Song::Source_Subsonic: return QObject::tr("subsonic");
case Song::Source_Unknown: return QObject::tr("Unknown");
}
return QObject::tr("Unknown");
}
@@ -438,8 +441,10 @@ QIcon Song::IconForSource(Source source) {
case Song::Source_Device: return IconLoader::Load("device");
case Song::Source_Stream: return IconLoader::Load("applications-internet");
case Song::Source_Tidal: return IconLoader::Load("tidal");
default: return IconLoader::Load("edit-delete");
case Song::Source_Subsonic: return IconLoader::Load("subsonic");
case Song::Source_Unknown: return IconLoader::Load("edit-delete");
}
return IconLoader::Load("edit-delete");
}

View File

@@ -74,6 +74,7 @@ class Song {
Source_Device = 4,
Source_Stream = 5,
Source_Tidal = 6,
Source_Subsonic = 7,
};
// Don't change these values - they're stored in the database, and defined in the tag reader protobuf.