Bugzilla – Attachment 151470 Details for
Bug 124970
iOS: Wrong File when Opening from Nextcloud-App
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP patch
TDF#124970-FIX-ATTEMPT.DIFF (text/plain), 9.46 KB, created by
How can I remove my account?
on 2019-05-16 20:35:47 UTC
(
hide
)
Description:
WIP patch
Filename:
MIME Type:
Creator:
How can I remove my account?
Created:
2019-05-16 20:35:47 UTC
Size:
9.46 KB
patch
obsolete
>diff --git a/ios/Mobile/AppDelegate.h b/ios/Mobile/AppDelegate.h >index 58c09bf46..48d519f5c 100644 >--- a/ios/Mobile/AppDelegate.h >+++ b/ios/Mobile/AppDelegate.h >@@ -10,8 +10,12 @@ > > #import <LibreOfficeKit/LibreOfficeKit.h> > >+#import "DocumentBrowserViewController.h" >+ > @interface AppDelegate : UIResponder <UIApplicationDelegate> > >+- (void)revealAndPresent:(NSURL *)inputUrl inController:(DocumentBrowserViewController *)documentBrowserViewController; >+ > @property (strong, nonatomic) UIWindow *window; > > @end >diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm >index b9836f5d4..52688dd1a 100644 >--- a/ios/Mobile/AppDelegate.mm >+++ b/ios/Mobile/AppDelegate.mm >@@ -12,6 +12,8 @@ > #import <cstdlib> > #import <cstring> > >+#define LOK_USE_UNSTABLE_API >+ > #import <LibreOfficeKit/LibreOfficeKitInit.h> > > #import "AppDelegate.h" >@@ -19,6 +21,8 @@ > #import "DocumentViewController.h" > #import "Document.h" > >+#import "ios.h" >+ > #import "FakeSocket.hpp" > #import "Log.hpp" > #import "LOOLWSD.hpp" >@@ -184,6 +188,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( > Log::initialize("Mobile", trace, false, false, {}); > Util::setThreadName("main"); > >+ // If we are asked to empty the tile cache, do that now. >+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"emptyTileCache"]) { >+ LOG_WRN("Emptying tile cache"); >+ [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithUTF8String:LOOLWSD_CACHEDIR] error:nil]; >+ LOG_WRN("Did empty tile cache"); >+ } >+ > // 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. >@@ -265,6 +276,19 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)inputURL options:(NSDi > > // Reveal / import the document at the URL > DocumentBrowserViewController *documentBrowserViewController = (DocumentBrowserViewController *)self.window.rootViewController; >+ if (documentBrowserViewController.presentedViewController != nil) { >+ DocumentViewController *documentViewController = (DocumentViewController*)documentBrowserViewController.presentedViewController; >+ [documentViewController closeAndDismissWithCompletion:^() { >+ [self revealAndPresent:inputURL inController:documentBrowserViewController]; >+ }]; >+ } else { >+ [self revealAndPresent:inputURL inController:documentBrowserViewController]; >+ } >+ >+ return YES; >+} >+ >+- (void)revealAndPresent:(NSURL *)inputURL inController:(DocumentBrowserViewController *)documentBrowserViewController { > [documentBrowserViewController revealDocumentAtURL:inputURL importIfNeeded:YES completion:^(NSURL * _Nullable revealedDocumentURL, NSError * _Nullable error) { > if (error) { > LOG_ERR("Failed to reveal the document at URL " << [[inputURL description] UTF8String] << " with error: " << [[error description] UTF8String]); >@@ -274,7 +298,6 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)inputURL options:(NSDi > // Present the Document View Controller for the revealed URL > [documentBrowserViewController presentDocumentAtURL:revealedDocumentURL]; > }]; >- return YES; > } > > @end >diff --git a/ios/Mobile/Document.h b/ios/Mobile/Document.h >index a843dc7f1..34d71c23b 100644 >--- a/ios/Mobile/Document.h >+++ b/ios/Mobile/Document.h >@@ -6,6 +6,7 @@ > // License, v. 2.0. If a copy of the MPL was not distributed with this > // file, You can obtain one at http://mozilla.org/MPL/2.0/. > >+#import <mutex> > #import <string> > > #import <UIKit/UIKit.h> >@@ -26,4 +27,6 @@ > > @end > >+extern std::mutex docMutex; >+ > // vim:set shiftwidth=4 softtabstop=4 expandtab: >diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm >index 5dcea04f3..2ad38dadb 100644 >--- a/ios/Mobile/Document.mm >+++ b/ios/Mobile/Document.mm >@@ -34,6 +34,8 @@ > #import "LOOLWSD.hpp" > #import "Protocol.hpp" > >+std::mutex docMutex; >+ > @implementation Document > > - (id)contentsForType:(NSString*)typeName error:(NSError **)errorPtr { >@@ -54,10 +56,9 @@ - (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError > if (fakeClientFd >= 0) > return YES; > >- // 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]; >- } >+ LOG_WRN("loadFromContents"); >+ >+ // docMutex.lock(); > > fakeClientFd = fakeSocketSocket(); > NSString *uri = [[self fileURL] absoluteString]; >diff --git a/ios/Mobile/DocumentBrowserViewController.mm b/ios/Mobile/DocumentBrowserViewController.mm >index bea28774a..510717505 100644 >--- a/ios/Mobile/DocumentBrowserViewController.mm >+++ b/ios/Mobile/DocumentBrowserViewController.mm >@@ -70,6 +70,8 @@ - (void)presentDocumentAtURL:(NSURL *)documentURL { > documentViewController.document = [[Document alloc] initWithFileURL:documentURL]; > documentViewController.document->fakeClientFd = -1; > documentViewController.document.viewController = documentViewController; >+ >+ assert(self.presentedViewController == nil); > [self presentViewController:documentViewController animated:YES completion:nil]; > } > >diff --git a/ios/Mobile/DocumentViewController.h b/ios/Mobile/DocumentViewController.h >index 8f4d97b43..b6649bd7a 100644 >--- a/ios/Mobile/DocumentViewController.h >+++ b/ios/Mobile/DocumentViewController.h >@@ -19,6 +19,8 @@ > @property std::string slideshowFile; > @property (strong) NSURL *slideshowURL; > >+- (void)closeAndDismissWithCompletion:(void (^)(void))completion; >+ > @end > > // vim:set shiftwidth=4 softtabstop=4 expandtab: >diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm >index 76e64d0d8..9e7ff0092 100644 >--- a/ios/Mobile/DocumentViewController.mm >+++ b/ios/Mobile/DocumentViewController.mm >@@ -80,16 +80,31 @@ - (void)viewWillAppear:(BOOL)animated { > }]; > } > >-- (IBAction)dismissDocumentViewController { >+- (void)closeAndDismissWithCompletion:(void (^)(void))completion { >+ >+ LOG_WRN("closeAndDismissWithCompletion"); >+ >+ // Close one end of the socket pair, that will wake up the forwarding thread above >+ fakeSocketClose(closeNotificationPipeForForwardingThread[0]); >+ >+ [self.document saveToURL:[self.document fileURL] >+ forSaveOperation:UIDocumentSaveForOverwriting >+ completionHandler:^(BOOL success) { >+ LOG_TRC("save completion handler gets " << (success?"YES":"NO")); >+ }]; >+ > [self dismissViewControllerAnimated:YES completion:^ { > [self.document closeWithCompletionHandler:^(BOOL success){ >+ LOG_WRN("close completion"); > LOG_TRC("close completion handler gets " << (success?"YES":"NO")); > [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"debug"]; > [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"lool"]; > [self.webView.configuration.userContentController removeScriptMessageHandlerForName:@"error"]; >- self.webView.configuration.userContentController = nil; > [self.webView removeFromSuperview]; > self.webView = nil; >+ // docMutex.unlock(); >+ if (success && completion != nil) >+ completion(); > }]; > }]; > } >@@ -240,16 +255,8 @@ - (void)userContentController:(WKUserContentController *)userContentController d > } else if ([message.body isEqualToString:@"BYE"]) { > LOG_TRC("Document window terminating on JavaScript side. Closing our end of the socket."); > >- // Close one end of the socket pair, that will wake up the forwarding thread above >- fakeSocketClose(closeNotificationPipeForForwardingThread[0]); >- >- [self.document saveToURL:[self.document fileURL] >- forSaveOperation:UIDocumentSaveForOverwriting >- completionHandler:^(BOOL success) { >- LOG_TRC("save completion handler gets " << (success?"YES":"NO")); >- }]; >+ [self closeAndDismissWithCompletion:nil]; > >- [self dismissDocumentViewController]; > return; > } else if ([message.body isEqualToString:@"SLIDESHOW"]) { > >diff --git a/ios/ios.h b/ios/ios.h >index 8bf7e147d..2edd90f17 100644 >--- a/ios/ios.h >+++ b/ios/ios.h >@@ -7,6 +7,7 @@ > * file, You can obtain one at http://mozilla.org/MPL/2.0/. > */ > >+#define LOK_USE_UNSTABLE_API > #include <LibreOfficeKit/LibreOfficeKit.hxx> > > extern const char *lo_ios_app_getCacheDir(); >diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp >index 6a5a6e36f..2b08d91f6 100644 >--- a/wsd/TileCache.cpp >+++ b/wsd/TileCache.cpp >@@ -69,7 +69,9 @@ TileCache::TileCache(const std::string& docURL, > completeCleanup(); > } > >+ LOG_WRN("Creating " << _cacheDir); > File(_cacheDir).createDirectories(); >+ LOG_WRN("Did create " << _cacheDir); > > saveLastModified(modifiedTime); > } >@@ -85,7 +87,7 @@ TileCache::~TileCache() > void TileCache::completeCleanup() const > { > FileUtil::removeFile(_cacheDir, true); >- LOG_INF("Completely cleared tile cache: " << _cacheDir); >+ LOG_WRN("Completely cleared tile cache: " << _cacheDir); > } > > /// Tracks the rendering of a given tile
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 124970
: 151470 |
154899