Skip to content

Commit

Permalink
Merge branch 'release/0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Mar 17, 2017
2 parents 7ffcb6f + ffe2eb7 commit 852a0b8
Show file tree
Hide file tree
Showing 21 changed files with 204 additions and 171 deletions.
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
target 'pass' do
pod 'ObjectivePGP'
pod 'ObjectivePGP', :git => 'https://github.com/mssun/ObjectivePGP.git'
end
4 changes: 4 additions & 0 deletions pass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
94BA784B85E071D25EE89B59 /* libPods-pass.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */; };
A262A58D1E68749C006B0890 /* Base32.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A262A58C1E68749C006B0890 /* Base32.framework */; };
A27424D91E7C35960093F436 /* NotificationNames.swift in Sources */ = {isa = PBXBuildFile; fileRef = A27424D81E7C35960093F436 /* NotificationNames.swift */; };
A2802BF91E70813A00879216 /* SliderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2802BF71E70813A00879216 /* SliderTableViewCell.swift */; };
A2802BFA1E70813A00879216 /* SliderTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2802BF81E70813A00879216 /* SliderTableViewCell.xib */; };
DC037CA61E4B883900609409 /* OpenSourceComponentsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA51E4B883900609409 /* OpenSourceComponentsTableViewController.swift */; };
Expand Down Expand Up @@ -69,6 +70,7 @@
/* Begin PBXFileReference section */
274CCFCF32444A2FF46BE7F4 /* Pods-pass.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.debug.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.debug.xcconfig"; sourceTree = "<group>"; };
A262A58C1E68749C006B0890 /* Base32.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Base32.framework; path = Carthage/Build/iOS/Base32.framework; sourceTree = "<group>"; };
A27424D81E7C35960093F436 /* NotificationNames.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationNames.swift; sourceTree = "<group>"; };
A2802BF71E70813A00879216 /* SliderTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderTableViewCell.swift; sourceTree = "<group>"; };
A2802BF81E70813A00879216 /* SliderTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SliderTableViewCell.xib; sourceTree = "<group>"; };
ADCE7A5C3CCC67D7D21BB3C4 /* libPods-pass.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-pass.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -204,6 +206,7 @@
DC4A746D1E30FBDE00E8EB18 /* Objective-CBridgingHeader.h */,
DCA049971E33586A00522E8F /* DefaultsKeys.swift */,
DC19400A1E4B36B60077E0A3 /* Utils.swift */,
A27424D81E7C35960093F436 /* NotificationNames.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -447,6 +450,7 @@
DC7E6EEA1E432E48006C2443 /* Password.swift in Sources */,
DC4914961E434301007FF592 /* LabelTableViewCell.swift in Sources */,
DC5F385B1E56AADB00C69ACA /* PGPKeyArmorSettingTableViewController.swift in Sources */,
A27424D91E7C35960093F436 /* NotificationNames.swift in Sources */,
DCAAF7451E2FA66800AB94BC /* SettingsTableViewController.swift in Sources */,
DCE6C2671E71261C003038C6 /* PasswordWithFolderTableViewCell.swift in Sources */,
DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion pass/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func postSearchNotification() {
NotificationCenter.default.post(Notification(name: Notification.Name("search")))
NotificationCenter.default.post(name: .passwordSearch, object: nil)
}

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
Expand Down
20 changes: 9 additions & 11 deletions pass/Controllers/AboutRepositoryTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
var needRefresh = false
var indicatorLabel: UILabel!
var indicator: UIActivityIndicatorView!
let passwordStore = PasswordStore.shared

override func viewDidLoad() {
navigationItemTitle = "About Repository"
Expand All @@ -31,7 +32,9 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
tableView.addSubview(indicatorLabel)

setTableData()
addNotificationObservers()

// all password store updates (including erase, discard) will trigger the refresh
NotificationCenter.default.addObserver(self, selector: #selector(setNeedRefresh), name: .passwordStoreUpdated, object: nil)
}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -57,20 +60,20 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
numberFormatter.numberStyle = NumberFormatter.Style.decimal
let fm = FileManager.default

let passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData(withDir: false)
let passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
let numberOfPasswords = numberFormatter.string(from: NSNumber(value: passwordEntities.count))!

var size = UInt64(0)
do {
if fm.fileExists(atPath: PasswordStore.shared.storeURL.path) {
size = try fm.allocatedSizeOfDirectoryAtURL(directoryURL: PasswordStore.shared.storeURL)
if fm.fileExists(atPath: self.passwordStore.storeURL.path) {
size = try fm.allocatedSizeOfDirectoryAtURL(directoryURL: self.passwordStore.storeURL)
}
} catch {
print(error)
}
let sizeOfRepository = ByteCountFormatter.string(fromByteCount: Int64(size), countStyle: ByteCountFormatter.CountStyle.file)

let numberOfCommits = PasswordStore.shared.storeRepository?.numberOfCommits(inCurrentBranch: NSErrorPointer(nilLiteral: ())) ?? 0
let numberOfCommits = self.passwordStore.storeRepository?.numberOfCommits(inCurrentBranch: NSErrorPointer(nilLiteral: ())) ?? 0
let numberOfCommitsString = numberFormatter.string(from: NSNumber(value: numberOfCommits))!


Expand All @@ -79,7 +82,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
self?.tableData = [
// section 0
[[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords", .detailText: numberOfPasswords],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepository], [.style: CellDataStyle.value1, .accessoryType: type, .title: "Unsynced", .detailText: String(PasswordStore.shared.getNumberOfUnsyncedPasswords())],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepository], [.style: CellDataStyle.value1, .accessoryType: type, .title: "Unsynced", .detailText: String(self?.passwordStore.getNumberOfUnsyncedPasswords() ?? 0)],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Last Synced", .detailText: Utils.getLastUpdatedTimeString()],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString],
[.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"],
Expand All @@ -91,11 +94,6 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
}
}
}

private func addNotificationObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(setNeedRefresh), name: NSNotification.Name(rawValue: "passwordUpdated"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(setNeedRefresh), name: NSNotification.Name(rawValue: "passwordStoreErased"), object: nil)
}

func setNeedRefresh() {
needRefresh = true
Expand Down
3 changes: 2 additions & 1 deletion pass/Controllers/AddPasswordTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {

var password: Password?
var tempContent: String = ""
let passwordStore = PasswordStore.shared

override func viewDidLoad() {
tableData = [
Expand All @@ -27,7 +28,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "saveAddPasswordSegue" {
// check PGP key
if Defaults[.pgpKeyID] == nil {
if passwordStore.privateKey == nil {
let alertTitle = "Cannot Add Password"
let alertMessage = "PGP Key is not set. Please set your PGP Key first."
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)
Expand Down
14 changes: 5 additions & 9 deletions pass/Controllers/AdvancedSettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class AdvancedSettingsTableViewController: UITableViewController {

@IBOutlet weak var eraseDataTableViewCell: UITableViewCell!
@IBOutlet weak var discardChangesTableViewCell: UITableViewCell!

let passwordStore = PasswordStore.shared

override func viewDidLoad() {
super.viewDidLoad()
}
Expand All @@ -24,8 +25,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
let alert = UIAlertController(title: "Erase Password Store Data?", message: "This will delete all local data and settings. Password store data on your remote server will not be affected.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Erase Password Data", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in
SVProgressHUD.show(withStatus: "Erasing ...")
PasswordStore.shared.erase()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreErased")))
self.passwordStore.erase()
self.navigationController!.popViewController(animated: true)
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
Expand All @@ -40,10 +40,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
SVProgressHUD.show(withStatus: "Resetting ...")
DispatchQueue.main.async {
do {
let numberDiscarded = try PasswordStore.shared.reset()
if numberDiscarded > 0 {
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded")))
}
let numberDiscarded = try self.passwordStore.reset()
self.navigationController!.popViewController(animated: true)
switch numberDiscarded {
case 0:
Expand All @@ -56,8 +53,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
SVProgressHUD.dismiss(withDelay: 1)
} catch {
DispatchQueue.main.async {
SVProgressHUD.showError(withStatus: error.localizedDescription)
SVProgressHUD.dismiss(withDelay: 1)
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pass/Controllers/CommitLogsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import ObjectiveGit

class CommitLogsTableViewController: UITableViewController {
var commits: [GTCommit] = []
let passwordStore = PasswordStore.shared

override func viewDidLoad() {
super.viewDidLoad()
commits = PasswordStore.shared.getRecentCommits(count: 20)
commits = passwordStore.getRecentCommits(count: 20)
navigationItem.title = "Recent Commit Logs"
navigationController!.navigationBar.topItem!.title = "About"
}
Expand Down
7 changes: 4 additions & 3 deletions pass/Controllers/GeneralSettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import UIKit
import SwiftyUserDefaults

class GeneralSettingsTableViewController: BasicStaticTableViewController {

let passwordStore = PasswordStore.shared

let hideUnknownSwitch: UISwitch = {
let uiSwitch = UISwitch()
uiSwitch.onTintColor = Globals.blue
Expand Down Expand Up @@ -177,13 +178,13 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
func rememberPassphraseSwitchAction(_ sender: Any?) {
Defaults[.isRememberPassphraseOn] = rememberPassphraseSwitch.isOn
if rememberPassphraseSwitch.isOn == false {
PasswordStore.shared.pgpKeyPassphrase = nil
passwordStore.pgpKeyPassphrase = nil
}
}

func showFolderSwitchAction(_ sender: Any?) {
Defaults[.isShowFolderOn] = showFolderSwitch.isOn
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
}

}
3 changes: 2 additions & 1 deletion pass/Controllers/GitServerSettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class GitServerSettingTableViewController: UITableViewController {
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var authSSHKeyCell: UITableViewCell!
@IBOutlet weak var authPasswordCell: UITableViewCell!
let passwordStore = PasswordStore.shared
var password: String?

var authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
Expand All @@ -41,7 +42,7 @@ class GitServerSettingTableViewController: UITableViewController {
gitRepositoryURLTextField.text = url.absoluteString
}
usernameTextField.text = Defaults[.gitRepositoryUsername]
password = PasswordStore.shared.gitRepositoryPassword
password = passwordStore.gitRepositoryPassword
authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]

// Grey out ssh option if ssh_key and ssh_key.pub are not present
Expand Down
3 changes: 2 additions & 1 deletion pass/Controllers/PGPKeyArmorSettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ class PGPKeyArmorSettingTableViewController: UITableViewController {
@IBOutlet weak var armorPublicKeyTextView: UITextView!
@IBOutlet weak var armorPrivateKeyTextView: UITextView!
var pgpPassphrase: String?
let passwordStore = PasswordStore.shared

override func viewDidLoad() {
super.viewDidLoad()
armorPublicKeyTextView.text = Defaults[.pgpPublicKeyArmor]
armorPrivateKeyTextView.text = Defaults[.pgpPrivateKeyArmor]
pgpPassphrase = PasswordStore.shared.pgpKeyPassphrase
pgpPassphrase = passwordStore.pgpKeyPassphrase
}

private func createSavePassphraseAlert() -> UIAlertController {
Expand Down
3 changes: 2 additions & 1 deletion pass/Controllers/PGPKeySettingTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ class PGPKeySettingTableViewController: UITableViewController {
@IBOutlet weak var pgpPublicKeyURLTextField: UITextField!
@IBOutlet weak var pgpPrivateKeyURLTextField: UITextField!
var pgpPassphrase: String?
let passwordStore = PasswordStore.shared

override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableViewAutomaticDimension
pgpPublicKeyURLTextField.text = Defaults[.pgpPublicKeyURL]?.absoluteString
pgpPrivateKeyURLTextField.text = Defaults[.pgpPrivateKeyURL]?.absoluteString
pgpPassphrase = PasswordStore.shared.pgpKeyPassphrase
pgpPassphrase = passwordStore.pgpKeyPassphrase
}

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
Expand Down
Loading

0 comments on commit 852a0b8

Please sign in to comment.