Extract file provider connection configuration into separate util function

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-01-02 14:41:02 +08:00
parent 5ed456f30c
commit 595c23cf76
3 changed files with 16 additions and 9 deletions

View file

@ -50,15 +50,9 @@ void FileProviderXPC::processConnections(NSArray *const connections)
NSMutableDictionary<NSString *, NSObject<ClientCommunicationProtocol>*> *const clientCommServices = NSMutableDictionary.dictionary;
for (NSXPCConnection * const connection in connections) {
Q_ASSERT(connection != nil);
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(ClientCommunicationProtocol)];
connection.interruptionHandler = ^{
qCInfo(lcFileProviderXPC) << "File provider connection interrupted";
};
connection.invalidationHandler = ^{
qCInfo(lcFileProviderXPC) << "File provider connection invalidated";
};
[connection resume];
const auto remoteObjectInterfaceProtocol = @protocol(ClientCommunicationProtocol);
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:remoteObjectInterfaceProtocol];
FileProviderXPCUtils::configureFileProviderConnection(connection);
const id remoteServiceObject = [connection remoteObjectProxyWithErrorHandler:^(NSError *const error){
qCWarning(lcFileProviderXPC) << "Error getting remote object proxy" << error;

View file

@ -25,6 +25,7 @@ NSArray<NSFileProviderManager *> *getDomainManagers();
NSArray<NSURL *> *getDomainUrlsForManagers(NSArray<NSFileProviderManager *> *managers);
NSArray<NSDictionary<NSFileProviderServiceName, NSFileProviderService *> *> *getFileProviderServicesAtUrls(NSArray<NSURL *> *urls);
NSArray<NSXPCConnection *> *connectToFileProviderServices(NSArray<NSDictionary<NSFileProviderServiceName, NSFileProviderService *> *> *fpServices);
void configureFileProviderConnection(NSXPCConnection *connection);
}
}

View file

@ -178,6 +178,18 @@ NSArray<NSXPCConnection *> *connectToFileProviderServices(NSArray<NSDictionary<N
return connections.copy;
}
void configureFileProviderConnection(NSXPCConnection *const connection)
{
Q_ASSERT(connection != nil);
connection.interruptionHandler = ^{
qCInfo(lcFileProviderXPCUtils) << "File provider connection interrupted";
};
connection.invalidationHandler = ^{
qCInfo(lcFileProviderXPCUtils) << "File provider connection invalidated";
};
[connection resume];
}
}
}