[Libreoffice-commits] online.git: ios/ios.mm ios/Mobile ios/Mobile.xcodeproj wsd/LOOLWSD.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 17 20:56:47 UTC 2018


 ios/Mobile.xcodeproj/project.pbxproj                       |    4 
 ios/Mobile/AppDelegate.h                                   |    3 
 ios/Mobile/AppDelegate.mm                                  |  150 ++++++++++++-
 ios/Mobile/Document.mm                                     |    7 
 ios/Mobile/DocumentBrowserViewController.mm                |    4 
 ios/Mobile/Resources/Settings.bundle/Root.plist            |   49 ++++
 ios/Mobile/Resources/Settings.bundle/en.lproj/Root.strings |binary
 ios/Mobile/TemplateCollectionViewController.h              |    3 
 ios/Mobile/TemplateCollectionViewController.mm             |   40 ++-
 ios/ios.mm                                                 |    2 
 wsd/LOOLWSD.cpp                                            |    2 
 11 files changed, 245 insertions(+), 19 deletions(-)

New commits:
commit 61bd04fefb4cbcca34b81e88991eed5a1ccfcfd2
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Mon Dec 17 22:18:49 2018 +0200
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Mon Dec 17 22:56:14 2018 +0200

    Add a way to have templates specific to a customer deployment
    
    Add two settings: One setting "Template list URL" is a string that
    should either be empty (the typical case for a random user of the
    app), or contain a https: URL. If this setting is empty, only the
    templates bundled in the app are provided.
    
    If the "Template list URL" is non-empty, it should be a https: URL
    pointing to a text file (or dynamically generated text resource). That
    file is downloaded and read when the app starts. Each line in the file
    should either be a comment (starting with a hash '#'), or a https: URL
    pointing to a template document, that is of type .ott, .ots, or .otp.
    That document is downloaded if it hasn't been downloaded already, or
    if its time stamp is newer than that of the already downloaded copy.
    Also a thumbnail image for the template, formed by appending ".png" to
    its URL, is downloaded, if available.
    
    Any previously downloaded templates that aren't mentioned in the list
    file are removed.
    
    The intent is that in some managed mass deployment environment, the
    mobile device management software would set up this setting, so that
    the end-user devices would see the same templates.
    
    Obviously, this URL does not have to point to a static file on a web
    server, but could point to some dynamically generated resource on a
    web server, that enumerates the templates available on the server and
    returns their URLs as a text document.
    
    Another setting is "Empty tile cache next time". This is a toggle. If
    toggled on, the next time a document is opened in the app, the tile
    cache is emptied (and the toggle is reset off). This is mostly for
    potential problem solving, and might be removd later.
    
    Various refactoring to support the new functionality.
    
    Change-Id: Ie2ebf032acb9e43bb1c6f7ae4d0c449ae66eaa05

diff --git a/ios/Mobile.xcodeproj/project.pbxproj b/ios/Mobile.xcodeproj/project.pbxproj
index 7fcce4ae4..cdb1af4b8 100644
--- a/ios/Mobile.xcodeproj/project.pbxproj
+++ b/ios/Mobile.xcodeproj/project.pbxproj
@@ -63,6 +63,7 @@
 		BEA2835D21498AD400848631 /* Socket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEA2835C21498AD400848631 /* Socket.cpp */; };
 		BEA28360214ACA8500848631 /* FakeSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEA2835F214ACA8500848631 /* FakeSocket.cpp */; };
 		BEA28377214FFD8C00848631 /* Unit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEA28376214FFD8C00848631 /* Unit.cpp */; };
+		BEB0E5D921C7CA800085A0CF /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = BEB0E5D821C7CA800085A0CF /* Settings.bundle */; };
 		BEFB1EE121C29CC70081D757 /* L10n.mm in Sources */ = {isa = PBXBuildFile; fileRef = BEFB1EE021C29CC70081D757 /* L10n.mm */; };
 /* End PBXBuildFile section */
 
@@ -502,6 +503,7 @@
 		BEA8CDC32199AC9D009FE17E /* lok.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = lok.cxx; path = "../../ios-device/comphelper/source/misc/lok.cxx"; sourceTree = "<group>"; };
 		BEA8CDC52199E621009FE17E /* languagetagicu.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = languagetagicu.cxx; path = "../../ios-device/i18nlangtag/source/languagetag/languagetagicu.cxx"; sourceTree = "<group>"; };
 		BEA8CDC62199E621009FE17E /* languagetag.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = languagetag.cxx; path = "../../ios-device/i18nlangtag/source/languagetag/languagetag.cxx"; sourceTree = "<group>"; };
+		BEB0E5D821C7CA800085A0CF /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
 		BEB6521C216F5D8B00B8C09A /* file_path_helper.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = file_path_helper.hxx; path = "../../ios-device/sal/osl/unx/file_path_helper.hxx"; sourceTree = "<group>"; };
 		BEB6521D216F5D8B00B8C09A /* file_error_transl.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = file_error_transl.hxx; path = "../../ios-device/sal/osl/unx/file_error_transl.hxx"; sourceTree = "<group>"; };
 		BEB6521E216F5D8B00B8C09A /* nlsupport.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = nlsupport.hxx; path = "../../ios-device/sal/osl/unx/nlsupport.hxx"; sourceTree = "<group>"; };
@@ -575,6 +577,7 @@
 		BE00F8922139494E001CE2D4 /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				BEB0E5D821C7CA800085A0CF /* Settings.bundle */,
 				BE80E46721B7066C00859C97 /* Templates */,
 				BE80E43121AD92F600859C97 /* Fonts */,
 				BE8D85BE214055F2009F1860 /* config */,
@@ -1445,6 +1448,7 @@
 				BE8D85D2214055F3009F1860 /* program in Resources */,
 				BE8D85CB214055F3009F1860 /* share in Resources */,
 				BE80E46821B7066D00859C97 /* Templates in Resources */,
+				BEB0E5D921C7CA800085A0CF /* Settings.bundle in Resources */,
 				BE00F8A621396585001CE2D4 /* loading.html in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
diff --git a/ios/Mobile/AppDelegate.h b/ios/Mobile/AppDelegate.h
index cc6d4a629..d9c6c00cc 100644
--- a/ios/Mobile/AppDelegate.h
+++ b/ios/Mobile/AppDelegate.h
@@ -8,6 +8,8 @@
 
 #import <UIKit/UIKit.h>
 
+#import <LibreOfficeKit/LibreOfficeKit.h>
+
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 
 @property (strong, nonatomic) UIWindow *window;
@@ -15,6 +17,7 @@
 @end
 
 extern NSString *app_locale;
+extern LibreOfficeKit *lo_kit;
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
 
diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index 99cf64d5c..eadcda6a1 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -12,6 +12,8 @@
 #import <cstdlib>
 #import <cstring>
 
+#import <LibreOfficeKit/LibreOfficeKitInit.h>
+
 #import "AppDelegate.h"
 #import "DocumentBrowserViewController.h"
 #import "DocumentViewController.h"
@@ -25,6 +27,127 @@
 static LOOLWSD *loolwsd = nullptr;
 
 NSString *app_locale;
+LibreOfficeKit *lo_kit;
+
+static void download(NSURL *source, NSURL *destination) {
+    [[[NSURLSession sharedSession] downloadTaskWithURL:source
+                                     completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
+                if (error == nil  && [(NSHTTPURLResponse*)response statusCode] == 200) {
+                    NSError *error = nil;
+                    NSURL *resultingItem = nil;
+                    if ([[NSFileManager defaultManager] replaceItemAtURL:destination
+                                                           withItemAtURL:location
+                                                          backupItemName:nil
+                                                                 options:NSFileManagerItemReplacementUsingNewMetadataOnly
+                                                        resultingItemURL:&resultingItem
+                                                                error:&error]) {
+                        LOG_INF("Downloaded " <<
+                                [[source absoluteString] UTF8String] <<
+                                " as " << [[destination absoluteString] UTF8String]);
+                    } else {
+                        LOG_ERR("Failed to replace " <<
+                                [[destination absoluteString] UTF8String] <<
+                                " with " << [[location absoluteString] UTF8String] <<
+                                ": " << [[error description] UTF8String]);
+                    }
+                } else if (error != nil) {
+                    LOG_ERR("Failed to download " <<
+                            [[source absoluteString] UTF8String] <<
+                            ": " << [[error description] UTF8String]);
+                } else {
+                    LOG_ERR("Failed to download " <<
+                            [[source absoluteString] UTF8String]);
+                }
+            }] resume];
+}
+
+static void downloadTemplate(NSURL *source, NSURL *destination) {
+    download(source, destination);
+    // Download also a thumbnail
+    download([NSURL URLWithString:[[source absoluteString] stringByAppendingString:@".png"]],
+             [NSURL URLWithString:[[destination absoluteString] stringByAppendingString:@".png"]]);
+}
+
+static void updateTemplates(NSData *data, NSURLResponse *response)
+{
+    static NSString *downloadedTemplates = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/downloadedTemplates/"];
+
+    // The data downloaded is a template list file, and should have one URL per line, corresponding
+    // to a template document. For each URL, we check whether we have the corresponding template
+    // document, and whether it is the same version (timestamp is older or the same). If not, we
+    // download the new version. Finally we remove any earlier downloaded templates not mentioned in the list
+    // file.
+
+    NSMutableSet<NSString *> *urlHashes = [NSMutableSet setWithCapacity:10];
+
+    const char *p = static_cast<const char*>([data bytes]);
+    const char *endOfData = p + [data length];
+    while (p < endOfData) {
+        const char *endOfLine = static_cast<const char*>(std::memchr(p, '\n', [data length]));
+        if (endOfLine == NULL)
+            endOfLine = endOfData;
+
+        // Allow comment lines staring with a hash sign.
+        if (*p != '#') {
+            const int length = endOfLine - p;
+            std::vector<char> buf(length+1);
+            std::memcpy(buf.data(), p, length);
+            buf[length] = 0;
+
+            NSString *line = [NSString stringWithUTF8String:buf.data()];
+
+            NSURL *url = [NSURL URLWithString:line];
+            NSString *baseName = [url lastPathComponent];
+
+            NSString *hash = [[NSData dataWithBytes:buf.data() length:length] base64EncodedStringWithOptions:0];
+            [urlHashes addObject:hash];
+
+            NSString *directoryForTemplate = [downloadedTemplates stringByAppendingString:hash];
+
+            NSURL *fileForTemplate = [NSURL fileURLWithPath:[directoryForTemplate stringByAppendingString:[@"/" stringByAppendingString:baseName]]];
+
+            // If we have that template, check whether it is up-to-date
+            BOOL isDirectory;
+            if ([[NSFileManager defaultManager] fileExistsAtPath:directoryForTemplate isDirectory:&isDirectory] &&
+                isDirectory) {
+                NSMutableURLRequest *req = [[NSURLRequest requestWithURL:url] mutableCopy];
+                [req setHTTPMethod:@"HEAD"];
+                [[[NSURLSession sharedSession] dataTaskWithRequest:req
+                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
+                            if (error == nil && [(NSHTTPURLResponse*)response statusCode] == 200) {
+                                NSString *lastModified = [[(NSHTTPURLResponse*)response allHeaderFields] objectForKey:@"Last-Modified"];
+                                NSDateFormatter *df = [[NSDateFormatter alloc] init];
+                                df.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z";
+                                NSDate *templateDate = [df dateFromString:lastModified];
+
+                                NSDate *cachedTemplateDate = [[[NSFileManager defaultManager] attributesOfItemAtPath:[fileForTemplate path] error:nil] objectForKey:NSFileModificationDate];
+
+                                if ([templateDate compare:cachedTemplateDate] == NSOrderedDescending) {
+                                    downloadTemplate(url, fileForTemplate);
+                                }
+                            }
+                        }] resume];
+            } else {
+                // Else download it.
+                [[NSFileManager defaultManager] createDirectoryAtPath:directoryForTemplate withIntermediateDirectories:YES attributes:nil error:nil];
+                downloadTemplate(url, fileForTemplate);
+            }
+        }
+        if (endOfLine < endOfData)
+            p = endOfLine + 1;
+        else
+            p = endOfData;
+    }
+
+    // Remove templates that are no longer mentioned in the list file.
+    NSArray<NSString *> *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:downloadedTemplates error:nil];
+    for (int i = 0; i < [dirContents count]; i++) {
+        if (![urlHashes containsObject:[dirContents objectAtIndex:i]]) {
+            [[NSFileManager defaultManager] removeItemAtPath:[downloadedTemplates stringByAppendingString:[@"/" stringByAppendingString:[dirContents objectAtIndex:i]]]
+                                                       error:nil];
+        }
+    }
+}
 
 @implementation AppDelegate
 
@@ -33,6 +156,9 @@ NSString *app_locale;
     if (!trace)
         trace = strdup("warning");
 
+    Log::initialize("Mobile", trace, false, false, {});
+    Util::setThreadName("main");
+
     // Having LANG in the environment is expected to happen only when debugging from Xcode. When
     // testing some language one doesn't know it might be risky to simply set one's iPad to that
     // language, as it might be hard to find the way to set it back to a known language.
@@ -43,8 +169,26 @@ NSString *app_locale;
     else
         app_locale = [[NSLocale preferredLanguages] firstObject];
 
-    Log::initialize("Mobile", trace, false, false, {});
-    Util::setThreadName("main");
+    // Look for the setting indicating the URL for a file containing a list of URLs for template
+    // documents to download. If set, start a task to download it, and then to download the listed
+    // templates.
+    NSString *templateListURL = [[NSUserDefaults standardUserDefaults] stringForKey:@"templateListURL"];
+    if (templateListURL != nil) {
+        NSURL *url = [NSURL URLWithString:templateListURL];
+        if (url != nil) {
+            [[[NSURLSession sharedSession] dataTaskWithURL:url
+                                         completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
+                        if (error == nil)
+                            updateTemplates(data, response);
+                    }] resume];
+        }
+    }
+
+    // Initialize LibreOfficeKit.
+
+    lo_kit = lok_init_2(nullptr, nullptr);
+    lo_kit->pClass->registerCallback(lo_kit, [](int, const char *, void*){}, nullptr);
+
     fakeSocketSetLoggingCallback([](const std::string& line)
                                  {
                                      LOG_TRC_NOFILE(line);
@@ -110,6 +254,8 @@ NSString *app_locale;
     return YES;
 }
 
+// NSURLSessionDataDelegate methods
+
 @end
 
 // vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index 1a0ccdcde..285e660d9 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -48,6 +48,13 @@
 }
 
 - (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError **)errorPtr {
+
+    // If we are asked to empty the tile cache, do that now.
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"emptyTileCache"]) {
+        [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithUTF8String:LOOLWSD_CACHEDIR] error:nil];
+        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"emptyTileCache"];
+    }
+
     fakeClientFd = fakeSocketSocket();
     NSString *uri = [[self fileURL] absoluteString];
 
diff --git a/ios/Mobile/DocumentBrowserViewController.mm b/ios/Mobile/DocumentBrowserViewController.mm
index 4e7c5c31b..bea28774a 100644
--- a/ios/Mobile/DocumentBrowserViewController.mm
+++ b/ios/Mobile/DocumentBrowserViewController.mm
@@ -8,6 +8,7 @@
 
 #import "config.h"
 
+#import "AppDelegate.h"
 #import "DocumentBrowserViewController.h"
 #import "Document.h"
 #import "DocumentViewController.h"
@@ -21,6 +22,7 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
+
     self.delegate = self;
     self.allowsDocumentCreation = YES;
     self.allowsPickingMultipleItems = NO;
@@ -42,7 +44,7 @@
     [self presentViewController:templateCollectionViewController animated:YES completion:nil];
 }
 
--(void)documentBrowser:(UIDocumentBrowserViewController *)controller didPickDocumentURLs:(NSArray<NSURL *> *)documentURLs {
+-(void)documentBrowser:(UIDocumentBrowserViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)documentURLs {
     NSURL *sourceURL = documentURLs.firstObject;
     if (!sourceURL) {
         return;
diff --git a/ios/Mobile/Resources/Settings.bundle/Root.plist b/ios/Mobile/Resources/Settings.bundle/Root.plist
new file mode 100644
index 000000000..03f175818
--- /dev/null
+++ b/ios/Mobile/Resources/Settings.bundle/Root.plist
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>StringsTable</key>
+	<string>Root</string>
+	<key>PreferenceSpecifiers</key>
+	<array>
+		<dict>
+			<key>Type</key>
+			<string>PSGroupSpecifier</string>
+			<key>Title</key>
+			<string>App info</string>
+		</dict>
+		<dict>
+			<key>Type</key>
+			<string>PSTitleValueSpecifier</string>
+			<key>Title</key>
+			<string>Version</string>
+			<key>Key</key>
+			<string>version</string>
+		</dict>
+		<dict>
+			<key>Type</key>
+			<string>PSGroupSpecifier</string>
+			<key>Title</key>
+			<string>Settings</string>
+		</dict>
+		<dict>
+			<key>Type</key>
+			<string>PSToggleSwitchSpecifier</string>
+			<key>Title</key>
+			<string>Empty tile cache next time</string>
+			<key>Key</key>
+			<string>emptyTileCache</string>
+			<key>DefaultValue</key>
+			<false/>
+		</dict>
+		<dict>
+			<key>Type</key>
+			<string>PSTextFieldSpecifier</string>
+			<key>Title</key>
+			<string>Template list URL</string>
+			<key>Key</key>
+			<string>templateListURL</string>
+		</dict>
+	</array>
+</dict>
+</plist>
diff --git a/ios/Mobile/Resources/Settings.bundle/en.lproj/Root.strings b/ios/Mobile/Resources/Settings.bundle/en.lproj/Root.strings
new file mode 100644
index 000000000..8cd87b9d6
Binary files /dev/null and b/ios/Mobile/Resources/Settings.bundle/en.lproj/Root.strings differ
diff --git a/ios/Mobile/TemplateCollectionViewController.h b/ios/Mobile/TemplateCollectionViewController.h
index dd166cb0c..02801bef1 100644
--- a/ios/Mobile/TemplateCollectionViewController.h
+++ b/ios/Mobile/TemplateCollectionViewController.h
@@ -9,8 +9,7 @@
 #import <UIKit/UIKit.h>
 
 @interface TemplateCollectionViewController : UICollectionViewController<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout> {
-    NSArray<NSURL*> *templates[3];
-    LibreOfficeKit *kit;
+    NSMutableArray<NSURL*> *templates[3];
 }
 
 @property (copy) void (^ _Nullable importHandler)(NSURL * _Nullable, UIDocumentBrowserImportMode);
diff --git a/ios/Mobile/TemplateCollectionViewController.mm b/ios/Mobile/TemplateCollectionViewController.mm
index ca2890e3d..c5da8ef05 100644
--- a/ios/Mobile/TemplateCollectionViewController.mm
+++ b/ios/Mobile/TemplateCollectionViewController.mm
@@ -8,9 +8,6 @@
 
 #import "svtools/strings.hrc"
 
-#import <LibreOfficeKit/LibreOfficeKit.h>
-#import <LibreOfficeKit/LibreOfficeKitInit.h>
-
 #import "AppDelegate.h"
 #import "L10n.h"
 #import "TemplateCollectionViewController.h"
@@ -34,13 +31,33 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
 
 - (void)viewDidLoad {
 
-    kit = lok_init_2(nullptr, nullptr);
-
-    // Scan for available templates.
-
-    templates[0] = [[NSBundle mainBundle] URLsForResourcesWithExtension:@".ott" subdirectory:@"Templates"];
-    templates[1] = [[NSBundle mainBundle] URLsForResourcesWithExtension:@".ots" subdirectory:@"Templates"];
-    templates[2] = [[NSBundle mainBundle] URLsForResourcesWithExtension:@".otp" subdirectory:@"Templates"];
+    static NSString *downloadedTemplates = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/downloadedTemplates/"];
+
+    // Scan for available templates. First downloaded ones.
+    NSDirectoryEnumerator<NSString *> *e = [[NSFileManager defaultManager] enumeratorAtPath:downloadedTemplates];
+
+    templates[0] = [@[] mutableCopy];
+    templates[1] = [@[] mutableCopy];
+    templates[2] = [@[] mutableCopy];
+
+    NSString *subPath;
+    while ((subPath = [e nextObject]) != nil) {
+        NSString *path = [downloadedTemplates stringByAppendingString:subPath];
+        if ([[path pathExtension] isEqualToString:@"ott"]) {
+            [templates[0] addObject:[NSURL fileURLWithPath:path]];
+        } else if ([[path pathExtension] isEqualToString:@"ots"]) {
+            [templates[1] addObject:[NSURL fileURLWithPath:path]];
+        } else if ([[path pathExtension] isEqualToString:@"otp"]) {
+            [templates[2] addObject:[NSURL fileURLWithPath:path]];
+        }
+    }
+
+    if ([templates[0] count] == 0)
+        templates[0] = [[[NSBundle mainBundle] URLsForResourcesWithExtension:@".ott" subdirectory:@"Templates"] mutableCopy];
+    if ([templates[1] count] == 0)
+        templates[1] = [[[NSBundle mainBundle] URLsForResourcesWithExtension:@".ots" subdirectory:@"Templates"] mutableCopy];
+    if ([templates[2] count] == 0)
+        templates[2] = [[[NSBundle mainBundle] URLsForResourcesWithExtension:@".otp" subdirectory:@"Templates"] mutableCopy];
 }
 
 - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
@@ -121,8 +138,7 @@ static NSString *mapTemplateExtensionToActual(NSString *templateName) {
 
     // Load the template into LibreOffice core, save as the corresponding document type (with the
     // same basename), and then proceed to edit that.
-    kit->pClass->registerCallback(kit, [](int, const char *, void*){}, nullptr);
-    LibreOfficeKitDocument *doc = kit->pClass->documentLoad(kit, [[selectedTemplate absoluteString] UTF8String]);
+    LibreOfficeKitDocument *doc = lo_kit->pClass->documentLoad(lo_kit, [[selectedTemplate absoluteString] UTF8String]);
     doc->pClass->saveAs(doc, [[newURL absoluteString] UTF8String], nullptr, nullptr);
     doc->pClass->destroy(doc);
 
diff --git a/ios/ios.mm b/ios/ios.mm
index b9afc0299..08ebb15cd 100644
--- a/ios/ios.mm
+++ b/ios/ios.mm
@@ -19,7 +19,7 @@ int loolwsd_server_socket_fd = -1;
 
 const char* lo_ios_app_getCacheDir()
 {
-    static NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+    static NSString *cachePath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"/tilecache"];
     static const char* result = strdup([cachePath UTF8String]);
 
     return result;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7907fbf3d..b52241785 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3089,6 +3089,7 @@ int LOOLWSD::innerMain()
     ::setenv("LC_ALL", "en_US.UTF-8", 1);
     setlocale(LC_ALL, "en_US.UTF-8");
 
+#ifndef MOBILEAPP
     if (access(Cache.c_str(), R_OK | W_OK | X_OK) != 0)
     {
         const auto err = "Unable to access cache [" + Cache +
@@ -3098,7 +3099,6 @@ int LOOLWSD::innerMain()
         return Application::EXIT_SOFTWARE;
     }
 
-#ifndef MOBILEAPP
     // We use the same option set for both parent and child loolwsd,
     // so must check options required in the parent (but not in the
     // child) separately now. Also check for options that are


More information about the Libreoffice-commits mailing list