kit/ChildSession.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
New commits: commit 59fc10bcd65bfbc8a30b613bc17e83aacc9e06cd Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Wed Apr 1 13:41:31 2020 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Apr 1 13:42:54 2020 +0300 Add some (ifdeffed-out) experimentation with file service providers Kept in #if 0 in case some similar experimentation needed in the future. It might be interesting to be able to tweak behaviour based on knowing on what kind of storage the doument is located, but alas, that seems not possible. Change-Id: I877c96fcea3a350faa58a934485714d15b01141d diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 2f2f1c20a..1289c862c 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -917,7 +917,39 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const Stri } #ifdef IOS - NSArray<NSString *> *pathComponents = [[NSURL URLWithString:[NSString stringWithUTF8String:getDocURL().c_str()]] pathComponents]; + NSURL *docURL = [NSURL URLWithString:[NSString stringWithUTF8String:getDocURL().c_str()]]; + +#if 0 + // Experimentation + + // Check if we can figure out the name of the file provider service the document is on. (No, the + // services dictionary passed to the completion handler is always empty, except for On My iPad + // and iCloud Drive.) + [NSFileManager.defaultManager + getFileProviderServicesForItemAtURL:docURL + completionHandler:^(NSDictionary<NSFileProviderServiceName,NSFileProviderService *> *services, + NSError *error) { + if (services == nil) { + LOG_TRC("Could not get file provider services for " << [[docURL absoluteString] UTF8String]); + } else if ([services count] == 0) { + LOG_TRC("No file provider services returned for " << [[docURL absoluteString] UTF8String]); + } else { + LOG_TRC("File provider services for " << [[docURL absoluteString] UTF8String]); + NSEnumerator *keyEnumerator = [services keyEnumerator]; + NSString *key; + while ((key = (NSString*)[keyEnumerator nextObject])) { + LOG_TRC(" " << key); + } + } + }]; + + // Check if we can figure out the "ubiquitous item container" name, which apparently means the file provider extension name. + // Alas, this seems to work only for documents on iCloud Drive. + NSError *error; + auto resources = [docURL promisedItemResourceValuesForKeys:@[NSURLUbiquitousItemContainerDisplayNameKey] error:&error]; +#endif + + NSArray<NSString *> *pathComponents = [docURL pathComponents]; NSString *baseName = [[pathComponents lastObject] stringByDeletingPathExtension]; NSURL *documentDirectory = [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0]; NSString *dotFormat = [@"." stringByAppendingString:[NSString stringWithUTF8String:format.c_str()]]; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits