|
@@ -95,7 +95,7 @@ import NCCommunication
|
|
|
|
|
|
let _ = NCManageDatabase.sharedInstance.addE2eEncryption(object)
|
|
|
|
|
|
- self.sendE2EMetadata(account: account, serverUrl: serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: nil, url: url, unlock: true) { (errorCode, errorDescription) in
|
|
|
+ self.sendE2EMetadata(account: account, serverUrl: serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: nil, url: url, unlock: true) { (e2eToken, errorCode, errorDescription) in
|
|
|
self.NotificationPost(name: k_notificationCenter_createFolder, serverUrl: serverUrl, userInfo: ["fileName": fileName, "serverUrl": serverUrl, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
|
}
|
|
|
} else {
|
|
@@ -124,7 +124,7 @@ import NCCommunication
|
|
|
if errorCode == 0 && e2eToken != nil && directory != nil {
|
|
|
let deleteE2eEncryption = NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameIdentifier == %@", metadata.account, metadata.serverUrl, metadata.fileName)
|
|
|
NCNetworking.sharedInstance.deleteMetadataPlain(metadata, addCustomHeaders: ["e2e-token" :e2eToken!]) { (errorCode, errorDescription) in
|
|
|
- self.sendE2EMetadata(account: metadata.account, serverUrl: metadata.serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: deleteE2eEncryption, url: url, unlock: true) { (errorCode, errorDescription) in
|
|
|
+ self.sendE2EMetadata(account: metadata.account, serverUrl: metadata.serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: deleteE2eEncryption, url: url, unlock: true) { (e2eToken, errorCode, errorDescription) in
|
|
|
self.NotificationPost(name: k_notificationCenter_deleteFile, serverUrl: metadata.serverUrl, userInfo: ["metadata": metadata, "errorCode": errorCode], errorDescription: errorDescription, completion: completion)
|
|
|
}
|
|
|
}
|
|
@@ -145,7 +145,7 @@ import NCCommunication
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- self.sendE2EMetadata(account: metadata.account, serverUrl: metadata.serverUrl, fileNameRename: metadata.fileName, fileNameNewRename: fileNameNew, deleteE2eEncryption: nil, url: url, unlock: true) { (errorCode, errorDescription) in
|
|
|
+ self.sendE2EMetadata(account: metadata.account, serverUrl: metadata.serverUrl, fileNameRename: metadata.fileName, fileNameNewRename: fileNameNew, deleteE2eEncryption: nil, url: url, unlock: true) { (e2eToken, errorCode, errorDescription) in
|
|
|
|
|
|
if errorCode == 0 {
|
|
|
NCManageDatabase.sharedInstance.setMetadataFileNameView(serverUrl: metadata.serverUrl, fileName: metadata.fileName, newFileNameView: fileNameNew, account: metadata.account)
|
|
@@ -191,12 +191,12 @@ import NCCommunication
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @objc func unlock(account:String, serverUrl: String, completion: @escaping (_ errorCode: Int, _ errorDescription: String?)->()) {
|
|
|
+ @objc func unlock(account:String, serverUrl: String, completion: @escaping (_ direcrtory: tableDirectory?, _ e2eToken: String?, _ errorCode: Int, _ errorDescription: String?)->()) {
|
|
|
|
|
|
var e2eToken: String?
|
|
|
|
|
|
guard let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)) else {
|
|
|
- completion(0, "")
|
|
|
+ completion(nil, nil, 0, "")
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -208,12 +208,12 @@ import NCCommunication
|
|
|
if errorCode == 0 {
|
|
|
NCManageDatabase.sharedInstance.deteleE2ETokenLock(serverUrl: serverUrl)
|
|
|
}
|
|
|
- completion(errorCode, errorDescription)
|
|
|
+ completion(directory, e2eToken, errorCode, errorDescription)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @objc func sendE2EMetadata(account: String, serverUrl: String, fileNameRename: String?, fileNameNewRename: String?, deleteE2eEncryption : NSPredicate?, url: String, unlock: Bool, completion: @escaping (_ errorCode: Int, _ errorDescription: String?)->()) {
|
|
|
-
|
|
|
+ @objc func sendE2EMetadata(account: String, serverUrl: String, fileNameRename: String?, fileNameNewRename: String?, deleteE2eEncryption : NSPredicate?, url: String, unlock: Bool, completion: @escaping (_ e2eToken: String?, _ errorCode: Int, _ errorDescription: String?)->()) {
|
|
|
+
|
|
|
self.lock(account: account, serverUrl: serverUrl) { (directory, e2eToken, errorCode, errorDescription) in
|
|
|
if errorCode == 0 && e2eToken != nil && directory != nil {
|
|
|
|
|
@@ -223,7 +223,7 @@ import NCCommunication
|
|
|
|
|
|
if errorCode == 0 && metadata != nil {
|
|
|
if !NCEndToEndMetadata.sharedInstance.decoderMetadata(metadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: serverUrl, account: account, url: url) {
|
|
|
- completion(Int(k_CCErrorInternalError), NSLocalizedString("_e2e_error_encode_metadata_", comment: ""))
|
|
|
+ completion(e2eToken, Int(k_CCErrorInternalError), NSLocalizedString("_e2e_error_encode_metadata_", comment: ""))
|
|
|
return
|
|
|
}
|
|
|
method = "PUT"
|
|
@@ -249,12 +249,12 @@ import NCCommunication
|
|
|
|
|
|
if unlock {
|
|
|
|
|
|
- self.unlock(account: account, serverUrl: serverUrl) { (_, _) in
|
|
|
+ self.unlock(account: account, serverUrl: serverUrl) { (_, e2eToken, _, _) in
|
|
|
|
|
|
if errorCode == 0 && metadata != nil {
|
|
|
NCEndToEndMetadata.sharedInstance.decoderMetadata(metadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: serverUrl, account: account, url: url)
|
|
|
}
|
|
|
- completion(errorCode, errorDescription)
|
|
|
+ completion(e2eToken, errorCode, errorDescription)
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -262,13 +262,13 @@ import NCCommunication
|
|
|
if errorCode == 0 && metadata != nil {
|
|
|
NCEndToEndMetadata.sharedInstance.decoderMetadata(metadata!, privateKey: CCUtility.getEndToEndPrivateKey(account), serverUrl: serverUrl, account: account, url: url)
|
|
|
}
|
|
|
- completion(errorCode, errorDescription)
|
|
|
+ completion(e2eToken, errorCode, errorDescription)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
- completion(errorCode, errorDescription)
|
|
|
+ completion(e2eToken, errorCode, errorDescription)
|
|
|
}
|
|
|
}
|
|
|
}
|