NCEntoToEndInterface.swift 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. //
  2. // NCEntoToEndInterface.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 03/04/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. class NCEntoToEndInterface : NSObject, OCNetworkingDelegate {
  25. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  26. override init() {
  27. }
  28. // --------------------------------------------------------------------------------------------
  29. // MARK: Initialize
  30. // --------------------------------------------------------------------------------------------
  31. @objc func initEndToEndEncryption() {
  32. // Clear all keys
  33. CCUtility.clearAllKeysEnd(toEnd: appDelegate.activeAccount)
  34. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  35. metadataNet.action = actionGetEndToEndPublicKeys
  36. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  37. }
  38. func getPrivateKeyCipher() {
  39. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  40. metadataNet.action = actionGetEndToEndPrivateKeyCipher
  41. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  42. }
  43. func getPublicKeyServer() {
  44. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  45. metadataNet.action = actionGetEndToEndServerPublicKey
  46. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  47. }
  48. // --------------------------------------------------------------------------------------------
  49. // MARK: Manage PublicKey
  50. // --------------------------------------------------------------------------------------------
  51. func getEndToEndPublicKeysSuccess(_ metadataNet: CCMetadataNet!) {
  52. CCUtility.setEndToEndPublicKey(appDelegate.activeAccount, publicKey: metadataNet.key)
  53. // Request PrivateKey chiper to Server
  54. getPrivateKeyCipher()
  55. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: "E2E PublicKey present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  56. }
  57. func getEndToEndPublicKeysFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  58. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  59. switch errorCode {
  60. case 400:
  61. appDelegate.messageNotification("E2E publicKey", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  62. case 404:
  63. guard let csr = NCEndToEndEncryption.sharedManager().createCSR(appDelegate.activeUserID, directoryUser: appDelegate.directoryUser) else {
  64. appDelegate.messageNotification("E2E Csr", description: "Error to create Csr", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  65. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPublicKeys, note: "E2E Error to create Csr", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  66. return
  67. }
  68. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  69. metadataNet.action = actionSignEndToEndPublicKey;
  70. metadataNet.key = csr;
  71. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  72. case 409:
  73. appDelegate.messageNotification("E2E publicKey", description: "forbidden: the user can't access the public keys", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  74. default:
  75. appDelegate.messageNotification("E2E publicKey", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  76. }
  77. }
  78. func signEnd(toEndPublicKeySuccess metadataNet: CCMetadataNet!) {
  79. CCUtility.setEndToEndPublicKey(appDelegate.activeAccount, publicKey: metadataNet.key)
  80. // Request PrivateKey chiper to Server
  81. getPrivateKeyCipher()
  82. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionSignEndToEndPublicKey, note: "E2E Csr - publicKey sign on Server and stored publicKey locally", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  83. }
  84. func signEnd(toEndPublicKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  85. appDelegate.messageNotification("E2E sign Csr - publicKey", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  86. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionSignEndToEndPublicKey, note: message, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  87. }
  88. func deleteEnd(toEndPublicKeySuccess metadataNet: CCMetadataNet!) {
  89. appDelegate.messageNotification("E2E delete publicKey", description: "Success", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.success, errorCode: 0)
  90. }
  91. func deleteEnd(toEndPublicKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  92. appDelegate.messageNotification("E2E delete publicKey", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  93. }
  94. // --------------------------------------------------------------------------------------------
  95. // MARK: Manage PrivateKey
  96. // --------------------------------------------------------------------------------------------
  97. func getEndToEndPrivateKeyCipherSuccess(_ metadataNet: CCMetadataNet!) {
  98. // request Passphrase
  99. var passphraseTextField: UITextField?
  100. let alertController = UIAlertController(title: NSLocalizedString("_e2e_passphrase_request_title_", comment: ""), message: NSLocalizedString("_e2e_passphrase_request_message_", comment: ""), preferredStyle: .alert)
  101. //TEST
  102. /*
  103. if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
  104. let fileURL = dir.appendingPathComponent("privatekey.txt")
  105. //writing
  106. do {
  107. try metadataNet.key.write(to: fileURL, atomically: false, encoding: .utf8)
  108. }
  109. catch {/* error handling here */}
  110. }
  111. */
  112. //
  113. let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
  114. let passphrase = passphraseTextField?.text
  115. let publicKey = CCUtility.getEndToEndPublicKey(self.appDelegate.activeAccount)
  116. guard let privateKey = (NCEndToEndEncryption.sharedManager().decryptPrivateKey(metadataNet.key, passphrase: passphrase, publicKey: publicKey)) else {
  117. self.appDelegate.messageNotification("E2E decrypt privateKey", description: "Error to decrypt Private Key", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
  118. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E Error to decrypt PrivateKey", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  119. return
  120. }
  121. // privateKey
  122. print(privateKey)
  123. // Save to keychain
  124. CCUtility.setEndToEndPrivateKeyCipher(self.appDelegate.activeAccount, privateKeyCipher: metadataNet.key)
  125. CCUtility.setEndToEndPassphrase(self.appDelegate.activeAccount, passphrase:passphrase)
  126. // request publicKey Server()
  127. self.getPublicKeyServer()
  128. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E PrivateKey present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  129. })
  130. let cancel = UIAlertAction(title: "Cancel", style: .cancel) { (action) -> Void in
  131. }
  132. alertController.addAction(ok)
  133. alertController.addAction(cancel)
  134. alertController.addTextField { (textField) -> Void in
  135. passphraseTextField = textField
  136. passphraseTextField?.placeholder = "Enter passphrase (12 words)"
  137. }
  138. appDelegate.activeMain.present(alertController, animated: true)
  139. }
  140. func getEndToEndPrivateKeyCipherFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  141. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  142. switch errorCode {
  143. case 400:
  144. appDelegate.messageNotification("E2E privateKey", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  145. case 404:
  146. // message
  147. let e2ePassphrase = NYMnemonic.generateString(128, language: "english")
  148. let message = "\n" + NSLocalizedString("_e2e_settings_view_passphrase_", comment: "") + "\n\n" + e2ePassphrase!
  149. let alertController = UIAlertController(title: NSLocalizedString("_e2e_settings_title_", comment: ""), message: NSLocalizedString(message, comment: ""), preferredStyle: .alert)
  150. let OKAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
  151. guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().encryptPrivateKey(self.appDelegate.activeUserID, directoryUser: self.appDelegate.directoryUser, passphrase: e2ePassphrase) else {
  152. self.appDelegate.messageNotification("E2E privateKey", description: "Error to create PrivateKey chiper", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  153. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndPrivateKeyCipher, note: "E2E Error to create PrivateKey chiper", type: k_activityTypeFailure, verbose: false, activeUrl: "")
  154. return
  155. }
  156. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: self.appDelegate.activeAccount)
  157. metadataNet.action = actionStoreEndToEndPrivateKeyCipher
  158. metadataNet.key = privateKeyChiper
  159. metadataNet.password = e2ePassphrase
  160. self.appDelegate.addNetworkingOperationQueue(self.appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  161. }
  162. alertController.addAction(OKAction)
  163. appDelegate.activeMain.present(alertController, animated: true)
  164. case 409:
  165. appDelegate.messageNotification("E2E privateKey", description: "forbidden: the user can't access the private key", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  166. default:
  167. appDelegate.messageNotification("E2E privateKey", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  168. }
  169. }
  170. func storeEnd(toEndPrivateKeyCipherSuccess metadataNet: CCMetadataNet!) {
  171. CCUtility.setEndToEndPrivateKeyCipher(appDelegate.activeAccount, privateKeyCipher: metadataNet.key)
  172. CCUtility.setEndToEndPassphrase(appDelegate.activeAccount, passphrase:metadataNet.password)
  173. // request publicKey Server()
  174. self.getPublicKeyServer()
  175. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionStoreEndToEndPrivateKeyCipher, note: "E2E PrivateKey stored on Server and stored locally", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  176. }
  177. func storeEnd(toEndPrivateKeyCipherFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  178. appDelegate.messageNotification("E2E sign privateKey", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  179. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionStoreEndToEndPrivateKeyCipher, note: message, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  180. }
  181. func deleteEnd(toEndPrivateKeySuccess metadataNet: CCMetadataNet!) {
  182. appDelegate.messageNotification("E2E delete privateKey", description: "Success", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.success, errorCode: 0)
  183. }
  184. func deleteEnd(toEndPrivateKeyFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  185. appDelegate.messageNotification("E2E delete privateKey", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  186. }
  187. // --------------------------------------------------------------------------------------------
  188. // MARK: Manage Server PublicKey
  189. // --------------------------------------------------------------------------------------------
  190. func getEndToEndServerPublicKeySuccess(_ metadataNet: CCMetadataNet!) {
  191. CCUtility.setEndToEndPublicKeyServer(appDelegate.activeAccount, publicKey: metadataNet.key)
  192. // All OK Activated flsg on Manage EndToEnd Encryption
  193. NotificationCenter.default.post(name: Notification.Name("reloadManageEndToEndEncryption"), object: nil)
  194. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndServerPublicKey, note: "E2E Server PublicKey present on Server and stored to keychain", type: k_activityTypeSuccess, verbose: false, activeUrl: "")
  195. }
  196. func getEndToEndServerPublicKeyFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  197. NCManageDatabase.sharedInstance.addActivityClient("", fileID: "", action: k_activityDebugActionEndToEndEncryption, selector: actionGetEndToEndServerPublicKey, note: message as String!, type: k_activityTypeFailure, verbose: false, activeUrl: "")
  198. switch (errorCode) {
  199. case 400:
  200. appDelegate.messageNotification("E2E Server publicKey", description: "bad request: unpredictable internal error", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  201. case 404:
  202. appDelegate.messageNotification("E2E Server publicKey", description: "Server publickey doesn't exists", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  203. case 409:
  204. appDelegate.messageNotification("E2E Server publicKey", description: "forbidden: the user can't access the Server publickey", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  205. default:
  206. appDelegate.messageNotification("E2E Server publicKey", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  207. }
  208. }
  209. // --------------------------------------------------------------------------------------------
  210. // MARK: Mark/Delete Encrypted Folder
  211. // --------------------------------------------------------------------------------------------
  212. func markEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  213. print("E2E mark folder success")
  214. }
  215. func markEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  216. // Unauthorized
  217. if (errorCode == kOCErrorServerUnauthorized) {
  218. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  219. }
  220. if (errorCode != kOCErrorServerUnauthorized) {
  221. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  222. }
  223. }
  224. @objc func markEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  225. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  226. metadataNet.action = actionMarkEndToEndFolderEncrypted;
  227. metadataNet.fileID = metadata.fileID;
  228. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  229. }
  230. func deletemarkEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  231. print("E2E delete mark folder success")
  232. }
  233. func deletemarkEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  234. // Unauthorized
  235. if (errorCode == kOCErrorServerUnauthorized) {
  236. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  237. }
  238. if (errorCode != kOCErrorServerUnauthorized) {
  239. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  240. }
  241. }
  242. @objc func deletemarkEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  243. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  244. metadataNet.action = actionDeletemarkEndToEndFolderEncrypted;
  245. metadataNet.fileID = metadata.fileID;
  246. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  247. }
  248. // --------------------------------------------------------------------------------------------
  249. // MARK: Lock/Unlock Encrypted Folder
  250. // --------------------------------------------------------------------------------------------
  251. func unlockEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  252. print("E2E lock file success")
  253. }
  254. func unlockEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  255. // Unauthorized
  256. if (errorCode == kOCErrorServerUnauthorized) {
  257. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  258. }
  259. if (errorCode != kOCErrorServerUnauthorized) {
  260. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  261. }
  262. }
  263. @objc func unlockEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  264. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  265. metadataNet.action = actionUnlockEndToEndFolderEncrypted;
  266. metadataNet.fileID = metadata.fileID;
  267. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  268. }
  269. func lockEnd(toEndFolderEncryptedSuccess metadataNet: CCMetadataNet!) {
  270. print("E2E lock file success")
  271. }
  272. func lockEnd(toEndFolderEncryptedFailure metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  273. // Unauthorized
  274. if (errorCode == kOCErrorServerUnauthorized) {
  275. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  276. }
  277. if (errorCode != kOCErrorServerUnauthorized) {
  278. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  279. }
  280. }
  281. @objc func lockEndToEndFolderEncrypted(_ metadata: tableMetadata) {
  282. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  283. metadataNet.action = actionLockEndToEndFolderEncrypted;
  284. metadataNet.fileID = metadata.fileID;
  285. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  286. }
  287. // --------------------------------------------------------------------------------------------
  288. // MARK: Manage Metadata
  289. // --------------------------------------------------------------------------------------------
  290. func getEndToEndMetadataSuccess(_ metadataNet: CCMetadataNet!) {
  291. print("E2E get metadata file success")
  292. }
  293. func getEndToEndMetadataFailure(_ metadataNet: CCMetadataNet!, message: String!, errorCode: Int) {
  294. // Unauthorized
  295. if (errorCode == kOCErrorServerUnauthorized) {
  296. appDelegate.openLoginView(appDelegate.activeMain, loginType: loginModifyPasswordUser)
  297. }
  298. if (errorCode != kOCErrorServerUnauthorized) {
  299. appDelegate.messageNotification("_error_", description: message as String!, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
  300. }
  301. }
  302. @objc func getEndToEndMetadata(_ metadata: tableMetadata) {
  303. let metadataNet: CCMetadataNet = CCMetadataNet.init(account: appDelegate.activeAccount)
  304. metadataNet.action = actionGetEndToEndMetadata;
  305. metadataNet.fileID = metadata.fileID;
  306. appDelegate.addNetworkingOperationQueue(appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
  307. }
  308. }