diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2022-02-16 13:10:47 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2022-02-18 12:21:15 +0300 |
commit | 2a72f0eb1b4a48824e9a2d68a806ec0bf6d5441f (patch) | |
tree | 4c155b7b2d33871f7fd125686b67811d82ab7869 /src/gui | |
parent | 2b446390d4800c9e245fcd2f6e6eed79137a9f0d (diff) |
Use a per folder davUrl
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accountsettings.cpp | 20 | ||||
-rw-r--r-- | src/gui/connectionvalidator.cpp | 2 | ||||
-rw-r--r-- | src/gui/folder.cpp | 93 | ||||
-rw-r--r-- | src/gui/folder.h | 52 | ||||
-rw-r--r-- | src/gui/folderman.cpp | 21 | ||||
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 6 | ||||
-rw-r--r-- | src/gui/folderwizard.cpp | 6 | ||||
-rw-r--r-- | src/gui/owncloudgui.cpp | 2 | ||||
-rw-r--r-- | src/gui/owncloudsetupwizard.cpp | 82 | ||||
-rw-r--r-- | src/gui/owncloudsetupwizard.h | 2 | ||||
-rw-r--r-- | src/gui/protocolwidget.cpp | 2 | ||||
-rw-r--r-- | src/gui/quotainfo.cpp | 7 | ||||
-rw-r--r-- | src/gui/selectivesyncdialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/sharedialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/sharedialog.h | 2 | ||||
-rw-r--r-- | src/gui/sharelinkwidget.h | 1 | ||||
-rw-r--r-- | src/gui/shareusergroupwidget.h | 1 | ||||
-rw-r--r-- | src/gui/socketapi/socketapi.cpp | 1 | ||||
-rw-r--r-- | src/gui/socketapi/socketuploadjob.cpp | 19 | ||||
-rw-r--r-- | src/gui/thumbnailjob.cpp | 4 | ||||
-rw-r--r-- | src/gui/wizard/owncloudadvancedsetuppage.cpp | 3 |
21 files changed, 191 insertions, 145 deletions
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 0a467dfac..4ea0b7f91 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -312,8 +312,8 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos) // Only add the path of subfolders, because the remote path is the path of the root folder. path += info->_path; } - menu->addAction(tr("Show in Browser"), [this, path] { - fetchPrivateLinkUrl(_accountState->account(), path, this, [](const QString &url) { + menu->addAction(tr("Show in Browser"), [path, davUrl = info->_folder->webDavUrl(), this] { + fetchPrivateLinkUrl(_accountState->account(), davUrl, path, this, [](const QString &url) { Utility::openBrowser(url, nullptr); }); }); @@ -442,28 +442,26 @@ void AccountSettings::slotFolderWizardAccepted() qCInfo(lcAccountSettings) << "Folder wizard completed"; FolderDefinition definition; - definition.localPath = FolderDefinition::prepareLocalPath( - folderWizard->field(QLatin1String("sourceFolder")).toString()); - definition.targetPath = FolderDefinition::prepareTargetPath( - folderWizard->property("targetPath").toString()); + definition.setLocalPath(folderWizard->field(QLatin1String("sourceFolder")).toString()); + definition.setTargetPath(folderWizard->property("targetPath").toString()); if (folderWizard->property("useVirtualFiles").toBool()) { definition.virtualFilesMode = bestAvailableVfsMode(); } { - QDir dir(definition.localPath); + QDir dir(definition.localPath()); if (!dir.exists()) { - qCInfo(lcAccountSettings) << "Creating folder" << definition.localPath; + qCInfo(lcAccountSettings) << "Creating folder" << definition.localPath(); if (!dir.mkpath(".")) { QMessageBox::warning(this, tr("Folder creation failed"), tr("<p>Could not create local folder <i>%1</i>.") - .arg(QDir::toNativeSeparators(definition.localPath))); + .arg(QDir::toNativeSeparators(definition.localPath()))); return; } } - FileSystem::setFolderMinimumPermissions(definition.localPath); - Utility::setupFavLink(definition.localPath); + FileSystem::setFolderMinimumPermissions(definition.localPath()); + Utility::setupFavLink(definition.localPath()); } /* take the value from the definition of already existing folders. All folders have diff --git a/src/gui/connectionvalidator.cpp b/src/gui/connectionvalidator.cpp index b99bbe579..926015589 100644 --- a/src/gui/connectionvalidator.cpp +++ b/src/gui/connectionvalidator.cpp @@ -174,7 +174,7 @@ void ConnectionValidator::checkAuthentication() // simply GET the webdav root, will fail if credentials are wrong. // continue in slotAuthCheck here :-) qCDebug(lcConnectionValidator) << "# Check whether authenticated propfind works."; - PropfindJob *job = new PropfindJob(_account, "/", this); + PropfindJob *job = new PropfindJob(_account, _account->davUrl(), {}, this); job->setAuthenticationJob(true); // don't retry job->setTimeout(timeoutToUse); job->setProperties(QList<QByteArray>() << "getlastmodified"); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index fe8ccbccd..005f912e5 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -59,9 +59,13 @@ namespace { */ auto versionC() { - return QStringLiteral("version"); + return QLatin1String("version"); } +auto davUrlC() +{ + return QLatin1String("davUrl"); +} constexpr int WinVfsSettingsVersion = 4; constexpr int SettingsVersion = 2; } @@ -101,7 +105,7 @@ Folder::Folder(const FolderDefinition &definition, // those errors should not persist over sessions _journal.wipeErrorBlacklistCategory(SyncJournalErrorBlacklistRecord::Category::LocalSoftError); - _engine.reset(new SyncEngine(_accountState->account(), path(), remotePath(), &_journal)); + _engine.reset(new SyncEngine(_accountState->account(), webDavUrl(), path(), remotePath(), &_journal)); // pass the setting if hidden files are to be ignored, will be read in csync_update _engine->setIgnoreHiddenFiles(_definition.ignoreHiddenFiles); @@ -182,15 +186,15 @@ bool Folder::checkLocalPath() #ifdef Q_OS_WIN Utility::NtfsPermissionLookupRAII ntfs_perm; #endif - const QFileInfo fi(_definition.localPath); + const QFileInfo fi(_definition.localPath()); _canonicalLocalPath = fi.canonicalFilePath(); #ifdef Q_OS_MAC // Workaround QTBUG-55896 (Should be fixed in Qt 5.8) _canonicalLocalPath = _canonicalLocalPath.normalized(QString::NormalizationForm_C); #endif if (_canonicalLocalPath.isEmpty()) { - qCWarning(lcFolder) << "Broken symlink:" << _definition.localPath; - _canonicalLocalPath = _definition.localPath; + qCWarning(lcFolder) << "Broken symlink:" << _definition.localPath(); + _canonicalLocalPath = _definition.localPath(); } else if (!_canonicalLocalPath.endsWith('/')) { _canonicalLocalPath.append('/'); } @@ -200,14 +204,14 @@ bool Folder::checkLocalPath() } else { QString error; // Check directory again - if (!FileSystem::fileExists(_definition.localPath, fi)) { - error = tr("Local folder %1 does not exist.").arg(_definition.localPath); + if (!FileSystem::fileExists(_definition.localPath(), fi)) { + error = tr("Local folder %1 does not exist.").arg(_definition.localPath()); } else if (!fi.isDir()) { - error = tr("%1 should be a folder but is not.").arg(_definition.localPath); + error = tr("%1 should be a folder but is not.").arg(_definition.localPath()); } else if (!fi.isReadable()) { - error = tr("%1 is not readable.").arg(_definition.localPath); + error = tr("%1 is not readable.").arg(_definition.localPath()); } else if (!fi.isWritable()) { - error = tr("%1 is not writable.").arg(_definition.localPath); + error = tr("%1 is not writable.").arg(_definition.localPath()); } if (!error.isEmpty()) { _syncResult.appendErrorString(error); @@ -243,7 +247,7 @@ QString Folder::path() const QString Folder::shortGuiLocalPath() const { - QString p = _definition.localPath; + QString p = _definition.localPath(); QString home = QDir::homePath(); if (!home.endsWith('/')) { home.append('/'); @@ -286,20 +290,27 @@ bool Folder::isSyncRunning() const QString Folder::remotePath() const { - return _definition.targetPath; + return _definition.targetPath(); +} + +QUrl Folder::webDavUrl() const +{ + return _definition.webDavUrl(); } QString Folder::remotePathTrailingSlash() const { - QString result = remotePath(); - if (!result.endsWith('/')) - result.append('/'); - return result; + const QString remote = remotePath(); + if (remote == QLatin1Char('/')) { + return remote; + } + Q_ASSERT(!remote.endsWith(QLatin1Char('/'))); + return remote + QLatin1Char('/'); } QUrl Folder::remoteUrl() const { - return Utility::concatUrlPath(_accountState->account()->davUrl(), remotePath()); + return Utility::concatUrlPath(webDavUrl(), remotePath()); } bool Folder::syncPaused() const @@ -391,7 +402,7 @@ void Folder::slotRunEtagJob() // Do the ordinary etag check for the root folder and schedule a // sync if it's different. - _requestEtagJob = new RequestEtagJob(account, remotePath(), this); + _requestEtagJob = new RequestEtagJob(account, webDavUrl(), remotePath(), this); _requestEtagJob->setTimeout(60s); // check if the etag is different when retrieved QObject::connect(_requestEtagJob.data(), &RequestEtagJob::etagRetreived, this, &Folder::etagRetreived); @@ -533,10 +544,9 @@ void Folder::startVfs() return; } - VfsSetupParams vfsParams; + VfsSetupParams vfsParams(_accountState->account(), webDavUrl()); vfsParams.filesystemPath = path(); vfsParams.remotePath = remotePathTrailingSlash(); - vfsParams.account = _accountState->account(); vfsParams.journal = &_journal; vfsParams.providerDisplayName = Theme::instance()->appNameGUI(); vfsParams.providerName = Theme::instance()->appName(); @@ -571,7 +581,7 @@ void Folder::startVfs() int Folder::slotDiscardDownloadProgress() { // Delete from journal and from filesystem. - QDir folderpath(_definition.localPath); + QDir folderpath(_definition.localPath()); QSet<QString> keep_nothing; const QVector<SyncJournalDb::DownloadInfo> deleted_infos = _journal.getAndDeleteStaleDownloadInfos(keep_nothing); @@ -1327,9 +1337,10 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, std::functio void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder) { - settings.setValue(QLatin1String("localPath"), folder.localPath); + settings.setValue(QLatin1String("localPath"), folder.localPath()); settings.setValue(QLatin1String("journalPath"), folder.journalPath); - settings.setValue(QLatin1String("targetPath"), folder.targetPath); + settings.setValue(QLatin1String("targetPath"), folder.targetPath()); + settings.setValue(davUrlC(), folder.webDavUrl()); settings.setValue(QLatin1String("paused"), folder.paused); settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles); @@ -1351,9 +1362,10 @@ bool FolderDefinition::load(QSettings &settings, const QString &alias, FolderDefinition *folder) { folder->alias = FolderMan::unescapeAlias(alias); - folder->localPath = settings.value(QLatin1String("localPath")).toString(); + folder->setLocalPath(settings.value(QLatin1String("localPath")).toString()); folder->journalPath = settings.value(QLatin1String("journalPath")).toString(); - folder->targetPath = settings.value(QLatin1String("targetPath")).toString(); + folder->setTargetPath(settings.value(QLatin1String("targetPath")).toString()); + folder->_webDavUrl = settings.value(davUrlC()).toUrl(); folder->paused = settings.value(QLatin1String("paused")).toBool(); folder->ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), QVariant(true)).toBool(); folder->navigationPaneClsid = settings.value(QLatin1String("navigationPaneClsid")).toUuid(); @@ -1372,43 +1384,30 @@ bool FolderDefinition::load(QSettings &settings, const QString &alias, folder->upgradeVfsMode = true; // maybe winvfs is available? } } - - // Old settings can contain paths with native separators. In the rest of the - // code we assume /, so clean it up now. - folder->localPath = prepareLocalPath(folder->localPath); - - // Target paths also have a convention - folder->targetPath = prepareTargetPath(folder->targetPath); - return true; } -QString FolderDefinition::prepareLocalPath(const QString &path) +void FolderDefinition::setLocalPath(const QString &path) { - QString p = QDir::fromNativeSeparators(path); - if (!p.endsWith(QLatin1Char('/'))) { - p.append(QLatin1Char('/')); + _localPath = QDir::fromNativeSeparators(path); + if (!_localPath.endsWith(QLatin1Char('/'))) { + _localPath.append(QLatin1Char('/')); } - return p; } -QString FolderDefinition::prepareTargetPath(const QString &path) +void FolderDefinition::setTargetPath(const QString &path) { - QString p = path; - if (p.endsWith(QLatin1Char('/'))) { - p.chop(1); - } + _targetPath = Utility::stripTrailingSlash(path); // Doing this second ensures the empty string or "/" come // out as "/". - if (!p.startsWith(QLatin1Char('/'))) { - p.prepend(QLatin1Char('/')); + if (!_targetPath.startsWith(QLatin1Char('/'))) { + _targetPath.prepend(QLatin1Char('/')); } - return p; } QString FolderDefinition::absoluteJournalPath() const { - return QDir(localPath).filePath(journalPath); + return QDir(localPath()).filePath(journalPath); } } // namespace OCC diff --git a/src/gui/folder.h b/src/gui/folder.h index ea692849f..da964dd1d 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -51,24 +51,21 @@ class LocalDiscoveryTracker; class FolderDefinition { public: - FolderDefinition() - : paused(false) - , ignoreHiddenFiles(true) - { - } + FolderDefinition() = default; + FolderDefinition(const QUrl &davUrl) + : _webDavUrl(davUrl) { + + }; /// The name of the folder in the ui and internally QString alias; - /// path on local machine (always trailing /) - QString localPath; /// path to the journal, usually relative to localPath QString journalPath; - /// path on remote (usually no trailing /, exception "/") - QString targetPath; + /// whether the folder is paused - bool paused; + bool paused = false; /// whether the folder syncs hidden files - bool ignoreHiddenFiles; + bool ignoreHiddenFiles = true; /// Which virtual files setting the folder uses Vfs::Mode virtualFilesMode = Vfs::Off; /// The CLSID where this folder appears in registry for the Explorer navigation pane entry. @@ -95,13 +92,37 @@ public: static int maxSettingsVersion() { return 4; } /// Ensure / as separator and trailing /. - static QString prepareLocalPath(const QString &path); + void setLocalPath(const QString &path); /// Remove ending /, then ensure starting '/': so "/foo/bar" and "/". - static QString prepareTargetPath(const QString &path); + void setTargetPath(const QString &path); /// journalPath relative to localPath. QString absoluteJournalPath() const; + + QString localPath() const + { + return _localPath; + } + QString targetPath() const + { + return _targetPath; + } + const QUrl &webDavUrl() const + { + Q_ASSERT(_webDavUrl.isValid()); + return _webDavUrl; + } + +private: + /// path on local machine (always trailing /) + QString _localPath; + /// path on remote (usually no trailing /, exception "/") + QString _targetPath; + + QUrl _webDavUrl; + + friend class FolderMan; }; /** @@ -159,6 +180,11 @@ public: QString remotePath() const; /** + * The full remote webdav url + */ + QUrl webDavUrl() const; + + /** * remote folder path, always with a trailing / */ QString remotePathTrailingSlash() const; diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index b34a3df64..2ca61d99d 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -68,8 +68,8 @@ QString makeLegacyDbName(const OCC::FolderDefinition &def, const OCC::AccountPtr if (legacyUrl.path() == QLatin1String("/")) { legacyUrl.setPath(QString()); } - const QString key = QStringLiteral("%1@%2:%3").arg(account->credentials()->user(), legacyUrl.toString(), def.targetPath); - return OCC::SyncJournalDb::makeDbName(def.localPath, QString::fromUtf8(QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Md5).left(6).toHex())); + const QString key = QStringLiteral("%1@%2:%3").arg(account->credentials()->user(), legacyUrl.toString(), def.targetPath()); + return OCC::SyncJournalDb::makeDbName(def.localPath(), QString::fromUtf8(QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Md5).left(6).toHex())); } } @@ -315,8 +315,8 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, const auto defaultJournalPath = [&account, folderDefinition] { // if we would have booth the 2.9.0 file name and the lagacy file // with the md5 infix we prefer the 2.9.0 version - const QDir info(folderDefinition.localPath); - const QString defaultPath = SyncJournalDb::makeDbName(folderDefinition.localPath); + const QDir info(folderDefinition.localPath()); + const QString defaultPath = SyncJournalDb::makeDbName(folderDefinition.localPath()); if (info.exists(defaultPath)) { return defaultPath; } @@ -333,6 +333,11 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, return defaultPath; }(); + // migration: 2.10 did not specify a webdav url + if (folderDefinition._webDavUrl.isEmpty()) { + folderDefinition._webDavUrl = account->account()->davUrl(); + } + // Migration: Old settings don't have journalPath if (folderDefinition.journalPath.isEmpty()) { folderDefinition.journalPath = defaultJournalPath; @@ -350,7 +355,7 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, // Migration: If an old .csync_journal.db is found, move it to the new name. if (backwardsCompatible) { - SyncJournalDb::maybeMigrateDb(folderDefinition.localPath, folderDefinition.absoluteJournalPath()); + SyncJournalDb::maybeMigrateDb(folderDefinition.localPath(), folderDefinition.absoluteJournalPath()); } auto vfs = createVfsFromPlugin(folderDefinition.virtualFilesMode); @@ -584,8 +589,8 @@ Folder *FolderMan::setupFolderFromOldConfigFile(const QString &file, AccountStat FolderDefinition folderDefinition; folderDefinition.alias = alias; - folderDefinition.localPath = path; - folderDefinition.targetPath = targetPath; + folderDefinition.setLocalPath(path); + folderDefinition.setTargetPath(targetPath); folderDefinition.paused = paused; folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles(); @@ -1058,7 +1063,7 @@ Folder *FolderMan::addFolder(AccountStatePtr accountState, const FolderDefinitio { // Choose a db filename auto definition = folderDefinition; - definition.journalPath = SyncJournalDb::makeDbName(folderDefinition.localPath); + definition.journalPath = SyncJournalDb::makeDbName(folderDefinition.localPath()); if (!ensureJournalGone(definition.absoluteJournalPath())) { return nullptr; diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 37dad168d..591ca9f1c 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -564,11 +564,9 @@ void FolderStatusModel::fetchMore(const QModelIndex &parent) if (info->_path != QLatin1String("/")) { path += info->_path; } - LsColJob *job = new LsColJob(_accountState->account(), path, this); + LsColJob *job = new LsColJob(_accountState->account(), info->_folder->webDavUrl(), path, this); info->_fetchingJob = job; - job->setProperties(QList<QByteArray>() << "resourcetype" - << "http://owncloud.org/ns:size" - << "http://owncloud.org/ns:permissions"); + job->setProperties({ QByteArrayLiteral("resourcetype"), QByteArrayLiteral("http://owncloud.org/ns:size"), QByteArrayLiteral("http://owncloud.org/ns:permissions") }); job->setTimeout(60s); connect(job, &LsColJob::directoryListingSubfolders, this, &FolderStatusModel::slotUpdateDirectories); diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 7ce5be987..7b358ba69 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -196,7 +196,8 @@ void FolderWizardRemotePath::slotCreateRemoteFolder(const QString &folder) } fullPath += "/" + folder; - MkColJob *job = new MkColJob(_account, fullPath, this); + // TODO: legacy + MkColJob *job = new MkColJob(_account, _account->davUrl(), fullPath, {}, this); /* check the owncloud configuration file and query the ownCloud */ connect(job, &MkColJob::finishedWithoutError, this, &FolderWizardRemotePath::slotCreateRemoteFolderFinished); @@ -395,7 +396,8 @@ void FolderWizardRemotePath::slotTypedPathFound(const QStringList &subpaths) LsColJob *FolderWizardRemotePath::runLsColJob(const QString &path) { - LsColJob *job = new LsColJob(_account, path, this); + // TODO: legacy + LsColJob *job = new LsColJob(_account, _account->davUrl(), path, this); job->setProperties(QList<QByteArray>() << "resourcetype"); connect(job, &LsColJob::directoryListingSubfolders, this, &FolderWizardRemotePath::slotUpdateDirectories); diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 7dff908eb..4ab038857 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -1106,7 +1106,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l w = _shareDialogs[localPath]; } else { qCInfo(lcApplication) << "Opening share dialog" << sharePath << localPath << maxSharingPermissions; - w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions, startPage, settingsDialog()); + w = new ShareDialog(accountState, folder->webDavUrl(), sharePath, localPath, maxSharingPermissions, startPage, settingsDialog()); w->setAttribute(Qt::WA_DeleteOnClose, true); _shareDialogs[localPath] = w; diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 1acd97bbf..b6418d67c 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -276,7 +276,8 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders() qCDebug(lcWizard) << "Creating local sync folder" << _ocWizard->localFolder() << "success:" << ok; } if (nextStep) { - EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), Utility::concatUrlPath(_ocWizard->account()->davPath(), _ocWizard->remoteFolder()).path(), this); + // TODO: legacy + EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), _ocWizard->account()->davUrl(), _ocWizard->remoteFolder(), this); connect(job, &EntityExistsJob::exists, this, &OwncloudSetupWizard::slotRemoteFolderExists); job->start(); } else { @@ -312,7 +313,8 @@ void OwncloudSetupWizard::createRemoteFolder() { qCDebug(lcWizard) << "creating folder on ownCloud:" << _ocWizard->remoteFolder(); - MkColJob *job = new MkColJob(_ocWizard->account(), _ocWizard->remoteFolder(), this); + // TODO: legacy + MkColJob *job = new MkColJob(_ocWizard->account(), _ocWizard->account()->davUrl(), _ocWizard->remoteFolder(), {}, this); connect(job, &MkColJob::finishedWithError, this, &OwncloudSetupWizard::slotCreateRemoteFolderFinished); connect(job, &MkColJob::finishedWithoutError, this, [this] { qCDebug(lcWizard) << "Remote folder" << _ocWizard->remoteFolder() << "created successfully."; @@ -383,6 +385,41 @@ bool OwncloudSetupWizard::ensureStartFromScratch(const QString &localFolder) return renameOk; } + +void OwncloudSetupWizard::addFolder(AccountStatePtr account, const QString &localFolder, const QString &remotePath, const QUrl &webDavUrl) +{ + FolderMan *folderMan = FolderMan::instance(); + qCInfo(lcWizard) << "Adding folder definition for" << localFolder << remotePath; + FolderDefinition folderDefinition(webDavUrl); + folderDefinition.setLocalPath(localFolder); + folderDefinition.setTargetPath(remotePath); + folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles(); + if (_ocWizard->useVirtualFileSync()) { + folderDefinition.virtualFilesMode = bestAvailableVfsMode(); + } +#ifdef Q_OS_WIN + if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) + folderDefinition.navigationPaneClsid = QUuid::createUuid(); +#endif + + auto f = folderMan->addFolder(account, folderDefinition); + if (f) { + if (folderDefinition.virtualFilesMode != Vfs::Off && _ocWizard->useVirtualFileSync()) + f->setRootPinState(PinState::OnlineOnly); + + f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, + _ocWizard->selectiveSyncBlacklist()); + if (!_ocWizard->isConfirmBigFolderChecked()) { + // The user already accepted the selective sync dialog. everything is in the white list + f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, + QStringList() << QLatin1String("/")); + } + qCDebug(lcWizard) << "Local sync folder" << localFolder << "successfully created!"; + } else { + qCWarning(lcWizard) << "Failed to create local sync folder!"; + } +} + // Method executed when the user end has finished the basic setup. void OwncloudSetupWizard::slotAssistantFinished(int result) { @@ -391,45 +428,16 @@ void OwncloudSetupWizard::slotAssistantFinished(int result) } else if (_ocWizard->manualFolderConfig()) { applyAccountChanges(); } else { - FolderMan *folderMan = FolderMan::instance(); - auto account = applyAccountChanges(); - - QString localFolder = FolderDefinition::prepareLocalPath(_ocWizard->localFolder()); - + const QString localFolder = _ocWizard->localFolder(); bool startFromScratch = _ocWizard->field("OCSyncFromScratch").toBool(); - if (!startFromScratch || ensureStartFromScratch(localFolder)) { - qCInfo(lcWizard) << "Adding folder definition for" << localFolder << _ocWizard->remoteFolder(); - FolderDefinition folderDefinition; - folderDefinition.localPath = localFolder; - folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_ocWizard->remoteFolder()); - folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles(); - if (_ocWizard->useVirtualFileSync()) { - folderDefinition.virtualFilesMode = bestAvailableVfsMode(); - } -#ifdef Q_OS_WIN - if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) - folderDefinition.navigationPaneClsid = QUuid::createUuid(); -#endif - auto f = folderMan->addFolder(account, folderDefinition); - if (f) { - if (folderDefinition.virtualFilesMode != Vfs::Off && _ocWizard->useVirtualFileSync()) - f->setRootPinState(PinState::OnlineOnly); - - f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, - _ocWizard->selectiveSyncBlacklist()); - if (!_ocWizard->isConfirmBigFolderChecked()) { - // The user already accepted the selective sync dialog. everything is in the white list - f->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, - QStringList() << QLatin1String("/")); - } - qCDebug(lcWizard) << "Local sync folder" << localFolder << "successfully created!"; - } else { - qCWarning(lcWizard) << "Failed to create local sync folder!"; - } + if (!startFromScratch || ensureStartFromScratch(localFolder)) { + auto account = applyAccountChanges(); + addFolder(account, localFolder, _ocWizard->remoteFolder(), account->account()->davUrl()); + } else { + qCWarning(lcWizard) << "Failed to create local sync folder!"; } } - // notify others. emit ownCloudWizardDone(result); } diff --git a/src/gui/owncloudsetupwizard.h b/src/gui/owncloudsetupwizard.h index 48021434d..7c29e72b2 100644 --- a/src/gui/owncloudsetupwizard.h +++ b/src/gui/owncloudsetupwizard.h @@ -66,6 +66,8 @@ private slots: private: explicit OwncloudSetupWizard(QWidget *parent = nullptr); ~OwncloudSetupWizard() override; + + void addFolder(AccountStatePtr account, const QString &localFolder, const QString &remotePath, const QUrl &webDavUrl); void startWizard(); void testOwnCloudConnect(); void createRemoteFolder(); diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp index 73b33b314..65c14488f 100644 --- a/src/gui/protocolwidget.cpp +++ b/src/gui/protocolwidget.cpp @@ -120,7 +120,7 @@ void ProtocolWidget::showContextMenu(QWidget *parent, ProtocolItemModel *model, } // "Open in Browser" action { - fetchPrivateLinkUrl(data.folder()->accountState()->account(), data.folder()->remotePathTrailingSlash() + data.path(), parent, [parent, menu = QPointer<QMenu>(menu)](const QString &url) { + fetchPrivateLinkUrl(data.folder()->accountState()->account(), data.folder()->webDavUrl(), data.folder()->remotePathTrailingSlash() + data.path(), parent, [parent, menu = QPointer<QMenu>(menu)](const QString &url) { // as fetchPrivateLinkUrl is async we need to check the menu still exists if (menu) { menu->addAction(tr("Show in web browser"), parent, [url, parent] { diff --git a/src/gui/quotainfo.cpp b/src/gui/quotainfo.cpp index d573e7ab4..0007469f9 100644 --- a/src/gui/quotainfo.cpp +++ b/src/gui/quotainfo.cpp @@ -98,10 +98,9 @@ void QuotaInfo::slotCheckQuota() _job->deleteLater(); } - AccountPtr account = _accountState->account(); - _job = new PropfindJob(account, quotaBaseFolder(), this); - _job->setProperties(QList<QByteArray>() << "quota-available-bytes" - << "quota-used-bytes"); + const AccountPtr &account = _accountState->account(); + _job = new PropfindJob(account, account->davUrl(), quotaBaseFolder(), this); + _job->setProperties({ QByteArrayLiteral("quota-available-bytes"), QByteArrayLiteral("quota-used-bytes") }); connect(_job.data(), &PropfindJob::result, this, &QuotaInfo::slotUpdateLastQuota); connect(_job.data(), &AbstractNetworkJob::networkError, this, &QuotaInfo::slotRequestFailed); _job->start(); diff --git a/src/gui/selectivesyncdialog.cpp b/src/gui/selectivesyncdialog.cpp index e16091862..e68b6d021 100644 --- a/src/gui/selectivesyncdialog.cpp +++ b/src/gui/selectivesyncdialog.cpp @@ -106,7 +106,8 @@ QSize SelectiveSyncWidget::sizeHint() const void SelectiveSyncWidget::refreshFolders() { - LsColJob *job = new LsColJob(_account, _folderPath, this); + // TODO: legacy + LsColJob *job = new LsColJob(_account, _account->davUrl(), _folderPath, this); job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size"); connect(job, &LsColJob::directoryListingSubfolders, @@ -272,7 +273,8 @@ void SelectiveSyncWidget::slotItemExpanded(QTreeWidgetItem *item) QString dir = item->data(0, Qt::UserRole).toString(); if (dir.isEmpty()) return; - LsColJob *job = new LsColJob(_account, _folderPath + dir, this); + // TODO: legacy + LsColJob *job = new LsColJob(_account, _account->davUrl(), _folderPath + dir, this); job->setProperties(QList<QByteArray>() << "resourcetype" << "http://owncloud.org/ns:size"); connect(job, &LsColJob::directoryListingSubfolders, diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 01758a8cc..106432676 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -40,6 +40,7 @@ namespace OCC { static const int thumbnailSize = 40; ShareDialog::ShareDialog(AccountStatePtr accountState, + const QUrl &baseUrl, const QString &sharePath, const QString &localPath, SharePermissions maxSharingPermissions, @@ -55,6 +56,7 @@ ShareDialog::ShareDialog(AccountStatePtr accountState, , _linkWidget(nullptr) , _userGroupWidget(nullptr) , _progressIndicator(nullptr) + , _baseUrl(baseUrl) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setAttribute(Qt::WA_DeleteOnClose); @@ -128,7 +130,7 @@ ShareDialog::ShareDialog(AccountStatePtr accountState, // Server versions >= 9.1 support the "share-permissions" property // older versions will just return share-permissions: "" - auto job = new PropfindJob(accountState->account(), _sharePath); + auto job = new PropfindJob(accountState->account(), _baseUrl, _sharePath); job->setProperties({ QByteArrayLiteral("http://open-collaboration-services.org/ns:share-permissions"), QByteArrayLiteral("http://owncloud.org/ns:privatelink") }); job->setTimeout(10s); diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index 46dfbf661..8093a8213 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -41,6 +41,7 @@ class ShareDialog : public QDialog public: explicit ShareDialog(AccountStatePtr accountState, + const QUrl &baseUrl, const QString &sharePath, const QString &localPath, SharePermissions maxSharingPermissions, @@ -71,6 +72,7 @@ private: ShareLinkWidget *_linkWidget; ShareUserGroupWidget *_userGroupWidget; QProgressIndicator *_progressIndicator; + const QUrl _baseUrl; }; } diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h index 7364fba24..aabec3c35 100644 --- a/src/gui/sharelinkwidget.h +++ b/src/gui/sharelinkwidget.h @@ -34,7 +34,6 @@ namespace Ui { } class AbstractCredentials; -class QuotaInfo; class SyncResult; class LinkShare; class Share; diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h index db2ef6b3c..7c5b47b5b 100644 --- a/src/gui/shareusergroupwidget.h +++ b/src/gui/shareusergroupwidget.h @@ -37,7 +37,6 @@ namespace Ui { } class AbstractCredentials; -class QuotaInfo; class SyncResult; class Share; class Sharee; diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index f62943273..664a413c3 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -679,6 +679,7 @@ void SocketApi::fetchPrivateLinkUrlHelper(const QString &localFile, const std::f fetchPrivateLinkUrl( fileData.folder->accountState()->account(), + fileData.folder->webDavUrl(), fileData.serverRelativePath, this, targetFun); diff --git a/src/gui/socketapi/socketuploadjob.cpp b/src/gui/socketapi/socketuploadjob.cpp index 0fb01804a..9967e7111 100644 --- a/src/gui/socketapi/socketuploadjob.cpp +++ b/src/gui/socketapi/socketuploadjob.cpp @@ -52,9 +52,10 @@ SocketUploadJob::SocketUploadJob(const QSharedPointer<SocketApiJobV2> &job) void SocketUploadJob::prepareTag(const AccountPtr &account) { const QJsonObject json({ { QStringLiteral("name"), backupTagNameC() } }); - auto tagJob = new OCC::SimpleNetworkJob(account, tagUrl(), "POST", json, {}, this); + auto tagJob = new OCC::SimpleNetworkJob(account, account->url(), tagUrl(), "POST", json, {}, this); connect(tagJob, &OCC::SimpleNetworkJob::finishedSignal, this, [account, this] { - auto propfindJob = new OCC::LsColJob(account, tagUrl(), this); + // TODO: dav url + auto propfindJob = new OCC::LsColJob(account, account->davUrl(), tagUrl(), this); propfindJob->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:display-name"), QByteArrayLiteral("http://owncloud.org/ns:id") }); connect(propfindJob, &LsColJob::directoryListingIterated, this, [this](const QString &, const QMap<QString, QString> &data) { @@ -108,7 +109,8 @@ void SocketUploadJob::start() } auto db = new SyncJournalDb(tmp->fileName(), this); - auto engine = new SyncEngine(account->account(), _localPath.endsWith(QLatin1Char('/')) ? _localPath : _localPath + QLatin1Char('/'), remotePath, db); + // TODO: folder based url + auto engine = new SyncEngine(account->account(), account->account()->davUrl(), _localPath.endsWith(QLatin1Char('/')) ? _localPath : _localPath + QLatin1Char('/'), remotePath, db); engine->setParent(db); tmp->setParent(db); @@ -129,7 +131,7 @@ void SocketUploadJob::start() connect(engine, &OCC::SyncEngine::finished, this, [engine, this](bool ok) { if (ok) { - auto tagJob = new OCC::SimpleNetworkJob(engine->account(), + auto tagJob = new OCC::SimpleNetworkJob(engine->account(), engine->account()->url(), QStringLiteral("remote.php/dav/systemtags-relations/files/%1/%2").arg(_backupFileId, QString::number(_finisedTagId)), "PUT", {}, {}, this); connect(tagJob, &OCC::SimpleNetworkJob::finishedSignal, this, [tagJob, this] { @@ -161,11 +163,12 @@ void SocketUploadJob::start() prepareTag(account->account()); // create the dir, fail if it already exists - auto mkdir = new OCC::MkColJob(engine->account(), remotePath); - connect(mkdir, &OCC::MkColJob::finishedWithoutError, this, [engine, remotePath, this]{ - + // TODO:: dav url + auto mkdir = new OCC::MkColJob(engine->account(), engine->account()->davUrl(), remotePath, {}, this); + connect(mkdir, &OCC::MkColJob::finishedWithoutError, this, [engine, remotePath, this] { // we need the int file id without the instance id so we can't use the OC-FileId - auto propfindJob = new PropfindJob(engine->account(), remotePath, this); + // TODO; dav url + auto propfindJob = new PropfindJob(engine->account(), engine->account()->davUrl(), remotePath, this); propfindJob->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:fileid") }); connect(propfindJob, &PropfindJob::result, this, [engine, this](const QMap<QString, QString> &data) { diff --git a/src/gui/thumbnailjob.cpp b/src/gui/thumbnailjob.cpp index 05d81f134..861d29f51 100644 --- a/src/gui/thumbnailjob.cpp +++ b/src/gui/thumbnailjob.cpp @@ -19,14 +19,14 @@ namespace OCC { ThumbnailJob::ThumbnailJob(const QString &path, AccountPtr account, QObject *parent) - : AbstractNetworkJob(account, QLatin1String("index.php/apps/files/api/v1/thumbnail/150/150/") + path, parent) + : AbstractNetworkJob(account, account->davUrl(), QLatin1String("index.php/apps/files/api/v1/thumbnail/150/150/") + path, parent) { setIgnoreCredentialFailure(true); } void ThumbnailJob::start() { - sendRequest("GET", makeAccountUrl(path())); + sendRequest("GET"); AbstractNetworkJob::start(); } diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index bdaba3ad1..78be8fce0 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -135,7 +135,8 @@ void OwncloudAdvancedSetupPage::initializePage() QTimer::singleShot(0, wizard()->button(QWizard::FinishButton), qOverload<>(&QWidget::setFocus)); auto acc = owncloudWizard()->account(); - auto quotaJob = new PropfindJob(acc, owncloudWizard()->remoteFolder(), this); + // TODO: legacy + auto quotaJob = new PropfindJob(acc, acc->davUrl(), owncloudWizard()->remoteFolder(), this); quotaJob->setProperties(QList<QByteArray>() << "http://owncloud.org/ns:size"); connect(quotaJob, &PropfindJob::result, this, &OwncloudAdvancedSetupPage::slotQuotaRetrieved); |