Skip to content

Commit 2fe4be6

Browse files
committed
fix: merge SystemConfig and ConfigResolver
1 parent 00e27be commit 2fe4be6

16 files changed

+97
-165
lines changed

src/gui/creds/credentials.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ void Credentials::refreshAccessTokenInternal()
288288
return;
289289
// parent with nam to ensure we reset when the nam is reset
290290
// todo: #22 - the parenting here is highly questionable, as is the use of the shared account ptr
291-
_oAuthJob = new AccountBasedOAuth(_account, this);
291+
SystemConfig systemConfig;
292+
_oAuthJob = new AccountBasedOAuth(_account, systemConfig.openIdConfig(), this);
292293
connect(_oAuthJob, &AccountBasedOAuth::refreshError, this, &Credentials::handleRefreshError);
293294
connect(_oAuthJob, &AccountBasedOAuth::refreshFinished, this, &Credentials::handleRefreshSuccess);
294295

src/gui/creds/oauth.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "oauth.h"
1616

1717
#include "accessmanager.h"
18-
#include "config/configresolver.h"
18+
#include "config/systemconfig.h"
1919
#include "creds/credentialssupport.h"
2020
#include "gui/networkadapters/userinfoadapter.h"
2121
#include "libsync/creds/credentialmanager.h"
@@ -478,8 +478,8 @@ void OAuth::openBrowser()
478478
// todo: I was contemplating how we can make sure the passed account isn't null before we use it
479479
// to seed the OAuth ctr, and really, I'm not sure this should be a subclass of oauth in the first place. Instead it could simply use an
480480
// oauth instance to complete the tasks it can't do itself -> this could possibly be a "has a" not an "is a" impl
481-
AccountBasedOAuth::AccountBasedOAuth(Account *account, QObject *parent)
482-
: OAuth(account->url(), account->davUser(), ConfigResolver::openIdConfig(), account->accessManager(), parent)
481+
AccountBasedOAuth::AccountBasedOAuth(Account *account, const OpenIdConfig& openIdConfig, QObject *parent)
482+
: OAuth(account->url(), account->davUser(), openIdConfig, account->accessManager(), parent)
483483
, _account(account)
484484
{
485485
}

src/gui/creds/oauth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class AccountBasedOAuth : public OAuth
146146
Q_OBJECT
147147

148148
public:
149-
explicit AccountBasedOAuth(Account *account, QObject *parent);
149+
explicit AccountBasedOAuth(Account *account, const OpenIdConfig& openIdConfig, QObject *parent);
150150

151151
void startAuthentication() override;
152152

src/gui/creds/requestauthenticationcontroller.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "accountmodalwidget.h"
2222
#include "settingsdialog.h"
2323

24+
#include <config/systemconfig.h>
25+
2426
namespace OCC {
2527

2628
/**
@@ -58,8 +60,9 @@ void RequestAuthenticationController::startAuthentication(Account *account)
5860
delete _oauth;
5961
_oauth = nullptr;
6062
}
63+
SystemConfig systemConfig;
6164
_account = account;
62-
_oauth = new AccountBasedOAuth(_account, this);
65+
_oauth = new AccountBasedOAuth(_account, systemConfig.openIdConfig(), this);
6366
connect(_oauth, &OAuth::authorisationLinkChanged, this, &RequestAuthenticationController::authUrlReady);
6467
connect(_oauth, &OAuth::result, this, &RequestAuthenticationController::handleOAuthResult);
6568
if (_widget && _modalWidget == nullptr) { // first show of the gui

src/gui/newaccountwizard/oauthpagecontroller.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "accessmanager.h"
1717
#include "accountmanager.h"
18-
#include "config/configresolver.h"
18+
#include "config/systemconfig.h"
1919
#include "networkadapters/fetchcapabilitiesadapter.h"
2020
#include "networkadapters/userinfoadapter.h"
2121
#include "networkadapters/webfingerlookupadapter.h"
@@ -209,7 +209,8 @@ bool OAuthPageController::validate()
209209
_authEndpoint.clear();
210210
_urlField->clear();
211211

212-
_oauth = new OAuth(_authUrl, {}, ConfigResolver::openIdConfig(), _accessManager.get(), this);
212+
SystemConfig systemConfig;
213+
_oauth = new OAuth(_authUrl, {}, systemConfig.openIdConfig(), _accessManager.get(), this);
213214
// if we ever need to split out the auth link calculation, it's coming from fetchWellKnown which is a subset of
214215
// the "full" authentication routine in the oauth impl
215216
connect(_oauth, &OAuth::authorisationLinkChanged, this, &OAuthPageController::authUrlReady);

src/gui/newaccountwizard/urlpagecontroller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
#include "urlpagecontroller.h"
1515

16-
#include "../../libsync/config/configresolver.h"
1716
#include "../../libsync/config/systemconfig.h"
1817
#include "accessmanager.h"
1918
#include "configfile.h"
@@ -41,15 +40,16 @@ UrlPageController::UrlPageController(QWizardPage *page, AccessManager *accessMan
4140
return;
4241
}
4342

44-
QString serverUrl = ConfigResolver::serverUrl();
43+
SystemConfig systemConfig;
44+
QString serverUrl = systemConfig.serverUrl();
4545
// no server url was given by any means, so the user has to provide one
4646
if (serverUrl.isEmpty()) {
4747
return;
4848
}
4949
setUrl(serverUrl);
5050

5151
// The system admin provides the url, don't let the user change it!
52-
bool allowServerUrlChange = ConfigResolver::allowServerUrlChange();
52+
bool allowServerUrlChange = systemConfig.allowServerUrlChange();
5353
if (!allowServerUrlChange) {
5454
_urlField->setEnabled(false);
5555
_instructionLabel->setText(tr("Your web browser will be opened to complete sign in."));

src/libsync/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ set(libsync_SRCS
5353

5454
appprovider.cpp
5555
config/systemconfig.cpp
56-
config/configresolver.cpp
5756
config/openidconfig.cpp
5857
)
5958

src/libsync/config/configresolver.cpp

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/libsync/config/configresolver.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/libsync/config/openidconfig.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
namespace OCC {
77

8+
OpenIdConfig::OpenIdConfig()
9+
{
10+
}
11+
812
OpenIdConfig::OpenIdConfig(const QString &clientId, const QString &clientSecret, const QList<quint16> &ports, const QString &scopes, const QString &prompt)
913
: _clientId(clientId)
1014
, _clientSecret(clientSecret)

0 commit comments

Comments
 (0)