-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
488 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
// | ||
|
||
import UIKit | ||
|
||
class ActionButton: UIButton { | ||
var primaryAction: ((UIButton) -> Void)? | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import Combine | ||
import Foundation | ||
|
||
class Bindable<Value> { | ||
@Published var value: Value | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
// | ||
|
||
import Foundation | ||
|
||
protocol VaultPasswordVerifying { | ||
func verifiedVaultPassword() | ||
func cancel() | ||
|
130 changes: 130 additions & 0 deletions
130
CryptomatorCommon/Sources/CryptomatorCommonCore/LocalizedCloudProviderDecorator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// | ||
// LocalizedCloudProviderDecorator.swift | ||
// CryptomatorCommonCore | ||
// | ||
// Created by Tobias Hagemann on 19.08.21. | ||
// Copyright © 2020 Skymatic GmbH. All rights reserved. | ||
// | ||
|
||
import CryptomatorCloudAccessCore | ||
import Foundation | ||
import Promises | ||
|
||
public class LocalizedCloudProviderDecorator: CloudProvider { | ||
// swiftlint:disable:next weak_delegate | ||
public let delegate: CloudProvider | ||
|
||
public init(delegate: CloudProvider) { | ||
self.delegate = delegate | ||
} | ||
|
||
public func fetchItemMetadata(at cloudPath: CloudPath) -> Promise<CloudItemMetadata> { | ||
return delegate.fetchItemMetadata(at: cloudPath).recover { error -> CloudItemMetadata in | ||
if let error = error as? CloudProviderError { | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func fetchItemList(forFolderAt cloudPath: CloudPath, withPageToken pageToken: String?) -> Promise<CloudItemList> { | ||
return delegate.fetchItemList(forFolderAt: cloudPath, withPageToken: pageToken).recover { error -> CloudItemList in | ||
if let error = error as? CloudProviderError { | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func downloadFile(from cloudPath: CloudPath, to localURL: URL) -> Promise<Void> { | ||
return delegate.downloadFile(from: cloudPath, to: localURL).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
switch error { | ||
case .itemAlreadyExists: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: CloudPath(localURL.path)) | ||
default: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func uploadFile(from localURL: URL, to cloudPath: CloudPath, replaceExisting: Bool) -> Promise<CloudItemMetadata> { | ||
return delegate.uploadFile(from: localURL, to: cloudPath, replaceExisting: replaceExisting).recover { error -> CloudItemMetadata in | ||
if let error = error as? CloudProviderError { | ||
switch error { | ||
case .itemNotFound, .itemTypeMismatch: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: CloudPath(localURL.path)) | ||
default: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func createFolder(at cloudPath: CloudPath) -> Promise<Void> { | ||
return delegate.createFolder(at: cloudPath).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func deleteFile(at cloudPath: CloudPath) -> Promise<Void> { | ||
return delegate.deleteFile(at: cloudPath).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func deleteFolder(at cloudPath: CloudPath) -> Promise<Void> { | ||
return delegate.deleteFolder(at: cloudPath).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: cloudPath) | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func moveFile(from sourceCloudPath: CloudPath, to targetCloudPath: CloudPath) -> Promise<Void> { | ||
return delegate.moveFile(from: sourceCloudPath, to: targetCloudPath).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
switch error { | ||
case .itemAlreadyExists, .parentFolderDoesNotExist: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: targetCloudPath) | ||
default: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: sourceCloudPath) | ||
} | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
public func moveFolder(from sourceCloudPath: CloudPath, to targetCloudPath: CloudPath) -> Promise<Void> { | ||
return delegate.moveFolder(from: sourceCloudPath, to: targetCloudPath).recover { error -> Void in | ||
if let error = error as? CloudProviderError { | ||
switch error { | ||
case .itemAlreadyExists, .parentFolderDoesNotExist: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: targetCloudPath) | ||
default: | ||
throw LocalizedCloudProviderError.convertToLocalized(error, cloudPath: sourceCloudPath) | ||
} | ||
} else { | ||
throw error | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.