|
@@ -23,9 +23,9 @@ import Cocoa
|
|
@IBOutlet weak var progressIndicator: NSProgressIndicator!
|
|
@IBOutlet weak var progressIndicator: NSProgressIndicator!
|
|
|
|
|
|
var _isFileList: Bool = false
|
|
var _isFileList: Bool = false
|
|
- var currentModel: KMDSignatureModel!
|
|
|
|
|
|
+ var currentModel: KMDSignatureModel?
|
|
|
|
|
|
- private var signatureArrays: NSArray!
|
|
|
|
|
|
+ private var signatureArrays: NSArray?
|
|
|
|
|
|
var actionBlock: ((_ fileListVC: DSignatureFileListViewController, _ type: DSignatureActionType)->Void)?
|
|
var actionBlock: ((_ fileListVC: DSignatureFileListViewController, _ type: DSignatureActionType)->Void)?
|
|
var viewCertDetailBlock: ((_ fileListVC: DSignatureFileListViewController, _ certificate: CPDFSignatureCertificate, _ isDigitalFile: Bool)->Void)?
|
|
var viewCertDetailBlock: ((_ fileListVC: DSignatureFileListViewController, _ certificate: CPDFSignatureCertificate, _ isDigitalFile: Bool)->Void)?
|
|
@@ -105,9 +105,9 @@ import Cocoa
|
|
func reloadData() {
|
|
func reloadData() {
|
|
self.signatureArrays = KMDSignatureManager.default().signatures
|
|
self.signatureArrays = KMDSignatureManager.default().signatures
|
|
self.tableView.reloadData()
|
|
self.tableView.reloadData()
|
|
- if self.signatureArrays.count > 0 {
|
|
|
|
|
|
+ if let cnt = self.signatureArrays?.count, cnt > 0 {
|
|
self.tableView.selectRowIndexes([0], byExtendingSelection: true)
|
|
self.tableView.selectRowIndexes([0], byExtendingSelection: true)
|
|
- self.currentModel = self.signatureArrays.firstObject as? KMDSignatureModel
|
|
|
|
|
|
+ self.currentModel = self.signatureArrays?.firstObject as? KMDSignatureModel
|
|
self.continueButton.isEnabled = true
|
|
self.continueButton.isEnabled = true
|
|
} else {
|
|
} else {
|
|
self.continueButton.isEnabled = false
|
|
self.continueButton.isEnabled = false
|
|
@@ -119,11 +119,11 @@ import Cocoa
|
|
|
|
|
|
for index in 0...self.tableView.numberOfRows-1 {
|
|
for index in 0...self.tableView.numberOfRows-1 {
|
|
let rowView = self.tableView.rowView(atRow: index, makeIfNecessary: true)
|
|
let rowView = self.tableView.rowView(atRow: index, makeIfNecessary: true)
|
|
- let cellView: DSignatureFileListCellView = rowView?.view(atColumn: 0) as! DSignatureFileListCellView
|
|
|
|
|
|
+ let cellView = rowView?.view(atColumn: 0) as? DSignatureFileListCellView
|
|
if (index == selectRow) {
|
|
if (index == selectRow) {
|
|
- cellView.radioBtn.state = .on
|
|
|
|
|
|
+ cellView?.radioBtn.state = .on
|
|
} else {
|
|
} else {
|
|
- cellView.radioBtn.state = .off
|
|
|
|
|
|
+ cellView?.radioBtn.state = .off
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -131,10 +131,12 @@ import Cocoa
|
|
func menuItemClick_Delete() {
|
|
func menuItemClick_Delete() {
|
|
let row = self.tableView.clickedRow
|
|
let row = self.tableView.clickedRow
|
|
|
|
|
|
- if row > -1 && row < self.signatureArrays.count {
|
|
|
|
- let model = self.signatureArrays[row] as! KMDSignatureModel
|
|
|
|
- if self.isFileList == false && model.isFormKeyChain == false {
|
|
|
|
- KMDSignatureManager.default().removeSignatureCertPath(model.filePath)
|
|
|
|
|
|
+ let cnt = self.signatureArrays?.count ?? 0
|
|
|
|
+ if row > -1 && row < cnt {
|
|
|
|
+ let model = self.signatureArrays?[row] as? KMDSignatureModel
|
|
|
|
+ let isFormKeyChain = model?.isFormKeyChain ?? true
|
|
|
|
+ if self.isFileList == false && isFormKeyChain == false {
|
|
|
|
+ KMDSignatureManager.default().removeSignatureCertPath(model?.filePath ?? "")
|
|
}
|
|
}
|
|
self.reloadData()
|
|
self.reloadData()
|
|
}
|
|
}
|
|
@@ -204,8 +206,9 @@ import Cocoa
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
let cellView = DSignatureFileListCellView()
|
|
let cellView = DSignatureFileListCellView()
|
|
cellView.itemIndex = row
|
|
cellView.itemIndex = row
|
|
- if (self.signatureArrays.count > row) {
|
|
|
|
- let model = self.signatureArrays[row] as! KMDSignatureModel
|
|
|
|
|
|
+ let cnt = self.signatureArrays?.count ?? 0
|
|
|
|
+ if (cnt > row) {
|
|
|
|
+ let model = self.signatureArrays?[row] as? KMDSignatureModel
|
|
cellView.signModel = model
|
|
cellView.signModel = model
|
|
}
|
|
}
|
|
if (cellView.signModel == self.currentModel) {
|
|
if (cellView.signModel == self.currentModel) {
|
|
@@ -217,13 +220,13 @@ import Cocoa
|
|
weak var weakSelf = self
|
|
weak var weakSelf = self
|
|
cellView.radioActionHandle = {_ in
|
|
cellView.radioActionHandle = {_ in
|
|
if weakSelf!.tableView.numberOfRows > cellView.itemIndex {
|
|
if weakSelf!.tableView.numberOfRows > cellView.itemIndex {
|
|
- weakSelf!.tableView.selectRowIndexes([cellView.itemIndex], byExtendingSelection: false)
|
|
|
|
|
|
+ weakSelf?.tableView.selectRowIndexes([cellView.itemIndex], byExtendingSelection: false)
|
|
}
|
|
}
|
|
- weakSelf!.currentModel = weakSelf!.signatureArrays[weakSelf!.tableView.selectedRow] as? KMDSignatureModel
|
|
|
|
- weakSelf!.refreshSelectedState()
|
|
|
|
|
|
+ weakSelf?.currentModel = weakSelf!.signatureArrays?[weakSelf!.tableView.selectedRow] as? KMDSignatureModel
|
|
|
|
+ weakSelf?.refreshSelectedState()
|
|
}
|
|
}
|
|
cellView.viewDetailBlock = {cellView in
|
|
cellView.viewDetailBlock = {cellView in
|
|
- var filePath: NSString!
|
|
|
|
|
|
+ var filePath: NSString?
|
|
var save: Bool = true
|
|
var save: Bool = true
|
|
var password: String = ""
|
|
var password: String = ""
|
|
|
|
|
|
@@ -240,7 +243,7 @@ import Cocoa
|
|
cellView.signModel?.filePath = filePath as? String
|
|
cellView.signModel?.filePath = filePath as? String
|
|
} else {
|
|
} else {
|
|
if cellView.signModel?.password != nil {
|
|
if cellView.signModel?.password != nil {
|
|
- password = (cellView.signModel?.password)!
|
|
|
|
|
|
+ password = (cellView.signModel?.password) ?? ""
|
|
}
|
|
}
|
|
if cellView.signModel?.filePath != nil {
|
|
if cellView.signModel?.filePath != nil {
|
|
filePath = cellView.signModel?.filePath as? NSString
|
|
filePath = cellView.signModel?.filePath as? NSString
|
|
@@ -248,13 +251,13 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
if save {
|
|
if save {
|
|
- var certificate: CPDFSignatureCertificate!
|
|
|
|
|
|
+ var certificate: CPDFSignatureCertificate?
|
|
certificate = CPDFSignatureCertificate(pkcs12Path: filePath as String?, password: password as String?)
|
|
certificate = CPDFSignatureCertificate(pkcs12Path: filePath as String?, password: password as String?)
|
|
if certificate != nil {
|
|
if certificate != nil {
|
|
guard let callBack = self.viewCertDetailBlock else {
|
|
guard let callBack = self.viewCertDetailBlock else {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- callBack(self, certificate, !cellView.signModel!.isFormKeyChain)
|
|
|
|
|
|
+ callBack(self, certificate!, !(cellView.signModel?.isFormKeyChain ?? false))
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
let alert = NSAlert.init()
|
|
let alert = NSAlert.init()
|
|
@@ -267,9 +270,9 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
-
|
|
|
|
- if (self.signatureArrays.count > self.tableView.selectedRow) {
|
|
|
|
- self.currentModel = self.signatureArrays[self.tableView.selectedRow] as? KMDSignatureModel
|
|
|
|
|
|
+ let cnt = self.signatureArrays?.count ?? 0
|
|
|
|
+ if (cnt > self.tableView.selectedRow) {
|
|
|
|
+ self.currentModel = self.signatureArrays?[self.tableView.selectedRow] as? KMDSignatureModel
|
|
|
|
|
|
self.refreshSelectedState()
|
|
self.refreshSelectedState()
|
|
}
|
|
}
|
|
@@ -280,9 +283,11 @@ import Cocoa
|
|
menu.removeAllItems()
|
|
menu.removeAllItems()
|
|
|
|
|
|
let row = self.tableView.clickedRow
|
|
let row = self.tableView.clickedRow
|
|
- if row > -1 && row < self.signatureArrays.count {
|
|
|
|
- let model = self.signatureArrays[row] as! KMDSignatureModel
|
|
|
|
- if self.isFileList == false && model.isFormKeyChain == false {
|
|
|
|
|
|
+ let cnt = self.signatureArrays?.count ?? 0
|
|
|
|
+ if row > -1 && row < cnt {
|
|
|
|
+ let model = self.signatureArrays?[row] as? KMDSignatureModel
|
|
|
|
+ let isFormKeyChain = model?.isFormKeyChain ?? true
|
|
|
|
+ if self.isFileList == false && isFormKeyChain == false {
|
|
menu.addItem(withTitle: NSLocalizedString("Delete", comment: ""), action: #selector(menuItemClick_Delete), keyEquivalent: "")
|
|
menu.addItem(withTitle: NSLocalizedString("Delete", comment: ""), action: #selector(menuItemClick_Delete), keyEquivalent: "")
|
|
}
|
|
}
|
|
}
|
|
}
|