Add scheme setting for subsonic
This commit is contained in:
@@ -51,6 +51,9 @@ SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *parent)
|
|||||||
|
|
||||||
dialog()->installEventFilter(this);
|
dialog()->installEventFilter(this);
|
||||||
|
|
||||||
|
ui_->scheme->addItem("HTTP", "http");
|
||||||
|
ui_->scheme->addItem("HTTPS", "https");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubsonicSettingsPage::~SubsonicSettingsPage() { delete ui_; }
|
SubsonicSettingsPage::~SubsonicSettingsPage() { delete ui_; }
|
||||||
@@ -61,6 +64,7 @@ void SubsonicSettingsPage::Load() {
|
|||||||
|
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||||
|
dialog()->ComboBoxLoadFromSettings(s, ui_->scheme, "scheme", "https");
|
||||||
ui_->hostname->setText(s.value("hostname").toString());
|
ui_->hostname->setText(s.value("hostname").toString());
|
||||||
ui_->port->setText(QString::number(s.value("port", 4040).toInt()));
|
ui_->port->setText(QString::number(s.value("port", 4040).toInt()));
|
||||||
ui_->username->setText(s.value("username").toString());
|
ui_->username->setText(s.value("username").toString());
|
||||||
@@ -78,6 +82,7 @@ void SubsonicSettingsPage::Save() {
|
|||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.setValue("enabled", ui_->enable->isChecked());
|
s.setValue("enabled", ui_->enable->isChecked());
|
||||||
|
s.setValue("scheme", ui_->scheme->itemData(ui_->scheme->currentIndex()));
|
||||||
s.setValue("hostname", ui_->hostname->text());
|
s.setValue("hostname", ui_->hostname->text());
|
||||||
s.setValue("port", ui_->port->text().toInt());
|
s.setValue("port", ui_->port->text().toInt());
|
||||||
s.setValue("username", ui_->username->text());
|
s.setValue("username", ui_->username->text());
|
||||||
|
|||||||
@@ -37,11 +37,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_server">
|
<layout class="QHBoxLayout" name="layout_server">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_server_url">
|
<widget class="QComboBox" name="scheme"/>
|
||||||
<property name="text">
|
|
||||||
<string>Hostname</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="hostname"/>
|
<widget class="QLineEdit" name="hostname"/>
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ QUrl SubsonicBaseRequest::CreateUrl(const QString &ressource_name, const QList<P
|
|||||||
}
|
}
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("https");
|
if (scheme().isEmpty()) url.setScheme("https");
|
||||||
|
else url.setScheme(scheme());
|
||||||
url.setHost(hostname());
|
url.setHost(hostname());
|
||||||
if (port() > 0 && port() != 443)
|
if (port() > 0 && port() != 443)
|
||||||
url.setPort(port());
|
url.setPort(port());
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class SubsonicBaseRequest : public QObject {
|
|||||||
|
|
||||||
QString client_name() { return service_->client_name(); }
|
QString client_name() { return service_->client_name(); }
|
||||||
QString api_version() { return service_->api_version(); }
|
QString api_version() { return service_->api_version(); }
|
||||||
|
QString scheme() { return service_->scheme(); }
|
||||||
QString hostname() { return service_->hostname(); }
|
QString hostname() { return service_->hostname(); }
|
||||||
int port() { return service_->port(); }
|
int port() { return service_->port(); }
|
||||||
QString username() { return service_->username(); }
|
QString username() { return service_->username(); }
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ void SubsonicService::ReloadSettings() {
|
|||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
|
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
|
||||||
|
|
||||||
|
scheme_ = s.value("scheme", "https").toString();
|
||||||
hostname_ = s.value("hostname").toString();
|
hostname_ = s.value("hostname").toString();
|
||||||
port_ = s.value("port", 443).toInt();
|
port_ = s.value("port", 443).toInt();
|
||||||
username_ = s.value("username").toString();
|
username_ = s.value("username").toString();
|
||||||
@@ -142,7 +143,8 @@ void SubsonicService::SendPing(const QString &hostname, const int port, const QS
|
|||||||
}
|
}
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("https");
|
if (scheme_.isEmpty()) url.setScheme("https");
|
||||||
|
else url.setScheme(scheme_);
|
||||||
url.setHost(hostname);
|
url.setHost(hostname);
|
||||||
url.setPort(port);
|
url.setPort(port);
|
||||||
url.setPath("/rest/ping.view");
|
url.setPath("/rest/ping.view");
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class SubsonicService : public InternetService {
|
|||||||
|
|
||||||
QString client_name() { return kClientName; }
|
QString client_name() { return kClientName; }
|
||||||
QString api_version() { return kApiVersion; }
|
QString api_version() { return kApiVersion; }
|
||||||
|
QString scheme() { return scheme_; }
|
||||||
QString hostname() { return hostname_; }
|
QString hostname() { return hostname_; }
|
||||||
int port() { return port_; }
|
int port() { return port_; }
|
||||||
QString username() { return username_; }
|
QString username() { return username_; }
|
||||||
@@ -118,6 +119,7 @@ class SubsonicService : public InternetService {
|
|||||||
|
|
||||||
std::shared_ptr<SubsonicRequest> songs_request_;
|
std::shared_ptr<SubsonicRequest> songs_request_;
|
||||||
|
|
||||||
|
QString scheme_;
|
||||||
QString hostname_;
|
QString hostname_;
|
||||||
int port_;
|
int port_;
|
||||||
QString username_;
|
QString username_;
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QUrl media_url;
|
QUrl media_url;
|
||||||
media_url.setScheme("https");
|
if (server_scheme().isEmpty()) media_url.setScheme("https");
|
||||||
|
else media_url.setScheme(server_scheme());
|
||||||
media_url.setHost(service_->hostname());
|
media_url.setHost(service_->hostname());
|
||||||
if (service_->port() > 0 && service_->port() != 443)
|
if (service_->port() > 0 && service_->port() != 443)
|
||||||
media_url.setPort(service_->port());
|
media_url.setPort(service_->port());
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class SubsonicUrlHandler : public UrlHandler {
|
|||||||
SubsonicUrlHandler(Application *app, SubsonicService *service);
|
SubsonicUrlHandler(Application *app, SubsonicService *service);
|
||||||
|
|
||||||
QString scheme() const { return service_->url_scheme(); }
|
QString scheme() const { return service_->url_scheme(); }
|
||||||
|
QString server_scheme() const { return service_->scheme(); }
|
||||||
LoadResult StartLoading(const QUrl &url);
|
LoadResult StartLoading(const QUrl &url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user