Commit 0f090668 authored by Karel Slaný's avatar Karel Slaný

Merge branch 'fix-ios-file-path' into 'develop'

Fixed some file paths and file names for iOS

See merge request !151
parents 10bdd9e9 5cde52ec
......@@ -40,10 +40,19 @@
- (void)openExportDocumentPicker:(NSArray<NSURL *> *)exportUrls {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURLs:exportUrls inMode:UIDocumentPickerModeExportToService];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
if (@available(iOS 11.0, *)) {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURLs:exportUrls inMode:UIDocumentPickerModeExportToService];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
} else {
for (NSURL *url in exportUrls) {
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURL:url inMode:UIDocumentPickerModeExportToService];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
}
}
}
- (void)openImportDocumentPicker:(NSArray<NSString *> *)allowedUtis {
......@@ -78,6 +87,24 @@
}
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url {
if (controller.documentPickerMode == UIDocumentPickerModeImport) {
NSLog(@"SELECTED FILE URL: %@", url);
QList<QUrl> qUrls;
// Convert NSURL on QUrl
QUrl tmpUrl = QUrl::fromNSURL(url);
qUrls.append(tmpUrl);
if (Q_NULLPTR != GlobInstcs::iOSHelperPtr) {
GlobInstcs::iOSHelperPtr->importFilesToAppInbox(qUrls);
}
} else if (controller.documentPickerMode == UIDocumentPickerModeExportToService) {
NSLog(@"STORAGE FILE URL: %@", url);
}
}
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
Q_UNUSED(controller);
if (Q_NULLPTR != GlobInstcs::iOSHelperPtr) {
......
......@@ -137,7 +137,7 @@ QString IosHelper::getShortSendFilePath(const QString &sandBoxFilePath)
// Get short local send file path
QString pattern(SEND_FILE_PATH_PREFIX);
int pos = sandBoxFilePath.indexOf(pattern) + pattern.length();
return QUrl::fromPercentEncoding(sandBoxFilePath.mid(pos).toUtf8());
return sandBoxFilePath.mid(pos);
#else
Q_UNUSED(sandBoxFilePath);
......@@ -260,7 +260,7 @@ QString IosHelper::moveFileToTargetPath(const QUrl &sourceFileUrl,
QUrl targetFileUrl(ICloudIo::moveFile(sourceFileUrl, targetPath));
if (targetFileUrl.isValid()) {
targetFileUrl.setScheme(QString());
return targetFileUrl.toString();
return QUrl::fromPercentEncoding(targetFileUrl.toString().toUtf8());
}
#else /* !Q_OS_IOS */
......
......@@ -25,6 +25,7 @@
#include "src/datovka_shared/log/log.h"
#include "src/global.h"
#include "src/io/filesystem.h"
#include "src/models/accountmodel.h"
#include "src/net/isds_const.h"
#include "src/net/isds_session.h"
......@@ -87,6 +88,16 @@ bool IsdsSession::setCertDataToCtx(IsdsContext &ctx, const QString &certPath)
debugFuncCall();
QFile certFile(certPath);
#if defined Q_OS_IOS
// iOS base sandbox path is different after application was updated.
// We cannot use static path for certificate on iOS like Android.
QFileInfo fi(certFile);
certFile.setFileName(joinDirs(appCertDirPath(), fi.fileName()));
#endif
if (!certFile.open(QIODevice::ReadOnly)) {
logErrorNL("Cannot open certificate from '%s'.",
certPath.toUtf8().constData());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment