Nextcloud configuration
This commit is contained in:
parent
dc0e633e46
commit
4c1025f501
@ -5,8 +5,10 @@
|
||||
|
||||
#include <QWebEngineView>
|
||||
#include <QWebEngineHttpRequest>
|
||||
#include <QMessageBox>
|
||||
#include <QUrlQuery>
|
||||
#include <QScrollBar>
|
||||
#include <QDir>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -59,16 +61,56 @@ void ServicesDialog::configureService() {
|
||||
if(!w)
|
||||
return;
|
||||
|
||||
Service const &s = w->service();
|
||||
if(s.title == "Nextcloud") {
|
||||
QSettings ncSettings(QDir::homePath() + "/.config/Nextcloud/nextcloud.cfg", QSettings::IniFormat, this);
|
||||
ncSettings.beginGroup("Accounts");
|
||||
int numAccounts = -1;
|
||||
int ourAccount = -1;
|
||||
for(QString &g : ncSettings.childGroups()) {
|
||||
ncSettings.beginGroup(g);
|
||||
if(!ncSettings.contains("url")) {
|
||||
ncSettings.endGroup();
|
||||
continue;
|
||||
}
|
||||
if(QUrl(ncSettings.value("url").toString()) == s.url && ncSettings.value("webflow_user") == app->user()) {
|
||||
// This user is already configured -- update existing config
|
||||
// rather than creating a new one
|
||||
ourAccount = g.toInt();
|
||||
ncSettings.endGroup();
|
||||
break;
|
||||
}
|
||||
numAccounts = std::max(numAccounts, g.toInt());
|
||||
ncSettings.endGroup();
|
||||
}
|
||||
if(ourAccount >= 0) {
|
||||
if(QMessageBox::question(this, tr("Nextcloud"), tr("This account seems to be configured in your Nextcloud client already. Do you want to overwrite the existing configuration?")) == QMessageBox::No)
|
||||
return;
|
||||
} else {
|
||||
ourAccount = numAccounts+1;
|
||||
}
|
||||
ncSettings.beginGroup(QString::number(ourAccount));
|
||||
ncSettings.setValue("authType", "webflow");
|
||||
ncSettings.setValue("dav_user", app->user().section('@', 0, 1));
|
||||
ncSettings.setValue("displayName", app->user().section('@', 0, 1));
|
||||
ncSettings.setValue("webflow_user", app->user());
|
||||
ncSettings.setValue("url", s.url.toString());
|
||||
ncSettings.setValue("version", 1);
|
||||
ncSettings.endGroup();
|
||||
ncSettings.endGroup();
|
||||
} else if(s.title == "Panel") {
|
||||
QWebEngineView *v = new QWebEngineView(static_cast<QWidget*>(nullptr));
|
||||
if(w->service().title == "Panel") {
|
||||
QWebEngineHttpRequest req = QWebEngineHttpRequest::postRequest(w->service().url, {
|
||||
QWebEngineHttpRequest req = QWebEngineHttpRequest::postRequest(s.url, {
|
||||
{"user_id", app->user()},
|
||||
{"password", app->password()}
|
||||
});
|
||||
v->load(req);
|
||||
} else
|
||||
v->load(w->service().url);
|
||||
v->show();
|
||||
} else {
|
||||
QWebEngineView *v = new QWebEngineView(static_cast<QWidget*>(nullptr));
|
||||
v->load(s.url);
|
||||
v->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ServicesDialog::serviceHelp() {
|
||||
|
Loading…
Reference in New Issue
Block a user