mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Clean up FileProviderXPC code, separate everything into single-responsibility methods
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
5ee2cfa749
commit
95bebc5214
3 changed files with 25 additions and 5 deletions
|
@ -60,7 +60,8 @@ FileProvider::FileProvider(QObject * const parent)
|
||||||
_xpc = std::make_unique<FileProviderXPC>(new FileProviderXPC(this));
|
_xpc = std::make_unique<FileProviderXPC>(new FileProviderXPC(this));
|
||||||
if (_xpc) {
|
if (_xpc) {
|
||||||
qCInfo(lcMacFileProvider) << "Initialised file provider XPC.";
|
qCInfo(lcMacFileProvider) << "Initialised file provider XPC.";
|
||||||
_xpc->start();
|
_xpc->connectToExtensions();
|
||||||
|
_xpc->configureExtensions();
|
||||||
} else {
|
} else {
|
||||||
qCWarning(lcMacFileProvider) << "Could not initialise file provider XPC.";
|
qCWarning(lcMacFileProvider) << "Could not initialise file provider XPC.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
namespace Mac {
|
namespace Mac {
|
||||||
|
@ -28,7 +30,14 @@ public:
|
||||||
explicit FileProviderXPC(QObject *parent = nullptr);
|
explicit FileProviderXPC(QObject *parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void connectToExtensions();
|
||||||
|
void configureExtensions();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnections();
|
||||||
|
void processConnections(NSArray *const services);
|
||||||
|
|
||||||
|
NSArray *_clientCommServices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ FileProviderXPC::FileProviderXPC(QObject *parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileProviderXPC::start()
|
void FileProviderXPC::connectToExtensions()
|
||||||
{
|
{
|
||||||
qCInfo(lcFileProviderXPC) << "Starting file provider XPC";
|
qCInfo(lcFileProviderXPC) << "Starting file provider XPC";
|
||||||
|
|
||||||
|
@ -40,6 +40,11 @@ void FileProviderXPC::start()
|
||||||
const auto domainUrls = FileProviderXPCUtils::getDomainUrlsForManagers(managers);
|
const auto domainUrls = FileProviderXPCUtils::getDomainUrlsForManagers(managers);
|
||||||
const auto fpServices = FileProviderXPCUtils::getFileProviderServicesAtUrls(domainUrls);
|
const auto fpServices = FileProviderXPCUtils::getFileProviderServicesAtUrls(domainUrls);
|
||||||
const auto connections = FileProviderXPCUtils::connectToFileProviderServices(fpServices);
|
const auto connections = FileProviderXPCUtils::connectToFileProviderServices(fpServices);
|
||||||
|
processConnections(connections);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileProviderXPC::processConnections(NSArray *const connections)
|
||||||
|
{
|
||||||
dispatch_group_t group = dispatch_group_create();
|
dispatch_group_t group = dispatch_group_create();
|
||||||
|
|
||||||
NSMutableDictionary<NSString *, NSObject<ClientCommunicationProtocol>*> *const clientCommServices = NSMutableDictionary.dictionary;
|
NSMutableDictionary<NSString *, NSObject<ClientCommunicationProtocol>*> *const clientCommServices = NSMutableDictionary.dictionary;
|
||||||
|
@ -95,7 +100,12 @@ void FileProviderXPC::start()
|
||||||
[clientCommServices setObject:clientCommService forKey:extensionNcAccount];
|
[clientCommServices setObject:clientCommService forKey:extensionNcAccount];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NSString *const extensionNcAccount in clientCommServices) {
|
_clientCommServices = clientCommServices.copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileProviderXPC::configureExtensions()
|
||||||
|
{
|
||||||
|
for (NSString *const extensionNcAccount in _clientCommServices) {
|
||||||
qCInfo(lcFileProviderXPC) << "Sending message to client communication service";
|
qCInfo(lcFileProviderXPC) << "Sending message to client communication service";
|
||||||
|
|
||||||
const auto qExtensionNcAccount = QString::fromNSString(extensionNcAccount);
|
const auto qExtensionNcAccount = QString::fromNSString(extensionNcAccount);
|
||||||
|
@ -116,7 +126,7 @@ void FileProviderXPC::start()
|
||||||
NSString *const serverUrl = account->url().toString().toNSString();
|
NSString *const serverUrl = account->url().toString().toNSString();
|
||||||
NSString *const password = credentials->password().toNSString();
|
NSString *const password = credentials->password().toNSString();
|
||||||
|
|
||||||
NSObject<ClientCommunicationProtocol> *const clientCommService = [clientCommServices objectForKey:extensionNcAccount];
|
NSObject<ClientCommunicationProtocol> *const clientCommService = [_clientCommServices objectForKey:extensionNcAccount];
|
||||||
[clientCommService configureAccountWithUser:user
|
[clientCommService configureAccountWithUser:user
|
||||||
serverUrl:serverUrl
|
serverUrl:serverUrl
|
||||||
password:password];
|
password:password];
|
||||||
|
|
Loading…
Reference in a new issue