mirror of https://github.com/KDE/kasts.git
Add capability to define custom gpodder server
FEATURE: 454674
This commit is contained in:
parent
cda9b450ea
commit
c4f12227a2
|
@ -20,7 +20,7 @@ Kirigami.ScrollablePage {
|
||||||
|
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
Kirigami.FormData.label: i18n("Current Status:")
|
Kirigami.FormData.label: i18n("Current Status:")
|
||||||
text: Sync.syncEnabled ? i18n("Logged into account \"%1\" on server \"%2\"", Sync.username, Sync.provider == SyncUtils.GPodderNet ? "gpodder.net" : Sync.hostname) : i18n("Syncing Disabled")
|
text: Sync.syncEnabled ? i18n("Logged into account \"%1\" on server \"%2\"", Sync.username, (Sync.provider == SyncUtils.GPodderNet && Sync.hostname == "") ? "gpodder.net" : Sync.hostname) : i18n("Syncing Disabled")
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,10 @@ Kirigami.ScrollablePage {
|
||||||
title: i18n("Sync Login Credentials")
|
title: i18n("Sync Login Credentials")
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (Sync.provider === Sync.GPodderNextcloud) {
|
if (Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked) {
|
||||||
Sync.hostname = hostnameField.text;
|
Sync.hostname = hostnameField.text;
|
||||||
|
} else {
|
||||||
|
Sync.hostname = ""
|
||||||
}
|
}
|
||||||
Sync.login(usernameField.text, passwordField.text);
|
Sync.login(usernameField.text, passwordField.text);
|
||||||
syncLoginOverlay.close();
|
syncLoginOverlay.close();
|
||||||
|
@ -166,16 +168,24 @@ Kirigami.ScrollablePage {
|
||||||
text: Sync.password
|
text: Sync.password
|
||||||
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
||||||
}
|
}
|
||||||
|
Controls.CheckBox {
|
||||||
|
id: customServerCheckBox
|
||||||
|
Layout.row: 2
|
||||||
|
Layout.column: 1
|
||||||
|
visible: Sync.provider === Sync.GPodderNet
|
||||||
|
checked: false
|
||||||
|
text: i18n("Use custom server")
|
||||||
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
visible: Sync.provider === Sync.GPodderNextcloud
|
visible: Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
text: i18n("Hostname:")
|
text: i18n("Hostname:")
|
||||||
}
|
}
|
||||||
Controls.TextField {
|
Controls.TextField {
|
||||||
visible: Sync.provider === Sync.GPodderNextcloud
|
visible: Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked
|
||||||
id: hostnameField
|
id: hostnameField
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: "https://nextcloud.mydomain.org"
|
placeholderText: Sync.provider === Sync.GPodderNet ? "https://gpodder.net" : "https://nextcloud.mydomain.org"
|
||||||
text: Sync.hostname
|
text: Sync.hostname
|
||||||
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,17 +71,20 @@ void Sync::retrieveCredentialsFromConfig()
|
||||||
if (!password.isEmpty()) {
|
if (!password.isEmpty()) {
|
||||||
m_syncEnabled = SettingsManager::self()->syncEnabled();
|
m_syncEnabled = SettingsManager::self()->syncEnabled();
|
||||||
m_password = password;
|
m_password = password;
|
||||||
|
m_hostname = SettingsManager::self()->syncHostname();
|
||||||
|
|
||||||
if (m_provider == Provider::GPodderNet) {
|
if (m_provider == Provider::GPodderNet) {
|
||||||
m_device = SettingsManager::self()->syncDevice();
|
m_device = SettingsManager::self()->syncDevice();
|
||||||
m_deviceName = SettingsManager::self()->syncDeviceName();
|
m_deviceName = SettingsManager::self()->syncDeviceName();
|
||||||
|
|
||||||
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_device.isEmpty()) {
|
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_device.isEmpty()) {
|
||||||
m_gpodder = new GPodder(m_username, m_password, this);
|
if (m_hostname.isEmpty()) { // use default official server
|
||||||
|
m_gpodder = new GPodder(m_username, m_password, this);
|
||||||
|
} else { // i.e. custom gpodder host
|
||||||
|
m_gpodder = new GPodder(m_username, m_password, m_hostname, m_provider, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (m_provider == Provider::GPodderNextcloud) {
|
} else if (m_provider == Provider::GPodderNextcloud) {
|
||||||
m_hostname = SettingsManager::self()->syncHostname();
|
|
||||||
|
|
||||||
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_hostname.isEmpty()) {
|
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_hostname.isEmpty()) {
|
||||||
m_gpodder = new GPodder(m_username, m_password, m_hostname, m_provider, this);
|
m_gpodder = new GPodder(m_username, m_password, m_hostname, m_provider, this);
|
||||||
}
|
}
|
||||||
|
@ -239,19 +242,24 @@ void Sync::setDeviceName(const QString &deviceName)
|
||||||
|
|
||||||
void Sync::setHostname(const QString &hostname)
|
void Sync::setHostname(const QString &hostname)
|
||||||
{
|
{
|
||||||
QString cleanedHostname = hostname;
|
if (hostname.isEmpty()) {
|
||||||
QUrl hostUrl = QUrl(hostname);
|
m_hostname.clear();
|
||||||
|
} else {
|
||||||
|
QString cleanedHostname = hostname;
|
||||||
|
QUrl hostUrl = QUrl(hostname);
|
||||||
|
|
||||||
if (hostUrl.scheme().isEmpty()) {
|
if (hostUrl.scheme().isEmpty()) {
|
||||||
hostUrl.setScheme(QStringLiteral("https"));
|
hostUrl.setScheme(QStringLiteral("https"));
|
||||||
if (hostUrl.authority().isEmpty() && !hostUrl.path().isEmpty()) {
|
if (hostUrl.authority().isEmpty() && !hostUrl.path().isEmpty()) {
|
||||||
hostUrl.setAuthority(hostUrl.path());
|
hostUrl.setAuthority(hostUrl.path());
|
||||||
hostUrl.setPath(QStringLiteral(""));
|
hostUrl.setPath(QStringLiteral(""));
|
||||||
|
}
|
||||||
|
cleanedHostname = hostUrl.toString();
|
||||||
}
|
}
|
||||||
cleanedHostname = hostUrl.toString();
|
|
||||||
|
m_hostname = cleanedHostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hostname = cleanedHostname;
|
|
||||||
SettingsManager::self()->setSyncHostname(m_hostname);
|
SettingsManager::self()->setSyncHostname(m_hostname);
|
||||||
SettingsManager::self()->save();
|
SettingsManager::self()->save();
|
||||||
Q_EMIT hostnameChanged();
|
Q_EMIT hostnameChanged();
|
||||||
|
@ -309,8 +317,12 @@ void Sync::login(const QString &username, const QString &password)
|
||||||
}
|
}
|
||||||
subRequest->deleteLater();
|
subRequest->deleteLater();
|
||||||
});
|
});
|
||||||
} else { // official gpodder.net server
|
} else {
|
||||||
m_gpodder = new GPodder(username, password, this);
|
if (m_hostname.isEmpty()) { // official gpodder.net server
|
||||||
|
m_gpodder = new GPodder(username, password, this);
|
||||||
|
} else { // custom server
|
||||||
|
m_gpodder = new GPodder(username, password, m_hostname, Provider::GPodderNet, this);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceRequest *deviceRequest = m_gpodder->getDevices();
|
DeviceRequest *deviceRequest = m_gpodder->getDevices();
|
||||||
connect(deviceRequest, &DeviceRequest::finished, this, [=]() {
|
connect(deviceRequest, &DeviceRequest::finished, this, [=]() {
|
||||||
|
@ -422,6 +434,7 @@ void Sync::clearSettings()
|
||||||
SettingsManager::self()->save();
|
SettingsManager::self()->save();
|
||||||
|
|
||||||
Q_EMIT credentialsChanged();
|
Q_EMIT credentialsChanged();
|
||||||
|
Q_EMIT hostnameChanged();
|
||||||
Q_EMIT syncProgressChanged();
|
Q_EMIT syncProgressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue