Add method to signal file provider domain via file provider settings controller

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-01-09 22:48:59 +08:00
parent 1d01f67790
commit f1c7811962
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 25 additions and 0 deletions

View file

@ -49,6 +49,7 @@ public slots:
void setVfsEnabledForAccount(const QString &userIdAtHost, const bool setEnabled);
void createEvictionWindowForAccount(const QString &userIdAtHost);
void signalFileProviderDomain(const QString &userIdAtHost);
void createDebugArchive(const QString &userIdAtHost);
signals:

View file

@ -22,6 +22,7 @@
#include "gui/macOS/fileprovider.h"
#include "gui/macOS/fileprovideritemmetadata.h"
#include "gui/macOS/fileprovidermaterialiseditemsmodel.h"
#include "gui/macOS/fileproviderutils.h"
// Objective-C imports
#import <Foundation/Foundation.h>
@ -161,6 +162,24 @@ public:
return _materialisedFiles.value(userIdAtHost);
}
void signalFileProviderDomain(const QString &userIdAtHost) const
{
qCInfo(lcFileProviderSettingsController) << "Signalling file provider domain" << userIdAtHost;
NSFileProviderDomain * const domain = FileProviderUtils::domainForIdentifier(userIdAtHost);
NSFileProviderManager * const manager = [NSFileProviderManager managerForDomain:domain];
[manager signalEnumeratorForContainerItemIdentifier:NSFileProviderRootContainerItemIdentifier
completionHandler:^(NSError *const error) {
if (error != nil) {
qCWarning(lcFileProviderSettingsController) << "Could not signal file provider domain, error"
<< error.localizedDescription;
return;
}
qCInfo(lcFileProviderSettingsController) << "Successfully signalled file provider domain";
// TODO: Provide some feedback in the UI
}];
}
private:
[[nodiscard]] NSArray<NSString *> *nsEnabledAccounts() const
{
@ -386,6 +405,11 @@ void FileProviderSettingsController::createEvictionWindowForAccount(const QStrin
dialog->show();
}
void FileProviderSettingsController::signalFileProviderDomain(const QString &userIdAtHost)
{
d->signalFileProviderDomain(userIdAtHost);
}
void FileProviderSettingsController::createDebugArchive(const QString &userIdAtHost)
{
const auto filename = QFileDialog::getSaveFileName(nullptr,