diff --git a/JustUsed/Base.lproj/Main.storyboard b/JustUsed/Base.lproj/Main.storyboard index 7e6ed64..c70c04b 100644 --- a/JustUsed/Base.lproj/Main.storyboard +++ b/JustUsed/Base.lproj/Main.storyboard @@ -776,12 +776,25 @@ - + + + + + + + + + + + + + + @@ -861,7 +874,7 @@ - + @@ -1018,11 +1031,11 @@ - + - + @@ -1030,7 +1043,7 @@ - + @@ -1038,7 +1051,7 @@ - + @@ -1046,7 +1059,7 @@ - + @@ -1057,7 +1070,7 @@ - + @@ -1068,7 +1081,7 @@ - + @@ -1079,7 +1092,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1132,10 +1270,11 @@ - + + @@ -1147,8 +1286,10 @@ + + @@ -1158,21 +1299,37 @@ + + + + + + + + + + + + + + - + + + diff --git a/JustUsed/DiMe Data/HistoryManager.swift b/JustUsed/DiMe Data/HistoryManager.swift index 44cdaa6..449a4ad 100644 --- a/JustUsed/DiMe Data/HistoryManager.swift +++ b/JustUsed/DiMe Data/HistoryManager.swift @@ -79,9 +79,11 @@ class HistoryManager: NSObject, RecentDocumentUpdateDelegate, BrowserHistoryUpda func newHistoryItems(newURLs: [BrowserHistItem]) { for newURL in newURLs { - let infoElem = DocumentInformationElement(fromSafariHist: newURL) - let event = DesktopEvent(infoElem: infoElem, ofType: TrackingType.Browser(newURL.browser), withDate: newURL.date, andLocation: newURL.location) - sendToDiMe(event) + if !newURL.excludedFromDiMe { + let infoElem = DocumentInformationElement(fromSafariHist: newURL) + let event = DesktopEvent(infoElem: infoElem, ofType: TrackingType.Browser(newURL.browser), withDate: newURL.date, andLocation: newURL.location) + sendToDiMe(event) + } } } diff --git a/JustUsed/Model/AppDelegate.swift b/JustUsed/Model/AppDelegate.swift index a7f8766..998c63c 100644 --- a/JustUsed/Model/AppDelegate.swift +++ b/JustUsed/Model/AppDelegate.swift @@ -41,6 +41,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { defaultPrefs[JustUsedConstants.prefDiMeServerURL] = "http://localhost:8080/api" defaultPrefs[JustUsedConstants.prefDiMeServerUserName] = "Test1" defaultPrefs[JustUsedConstants.prefDiMeServerPassword] = "123456" + let defaultExcludeDomains = ["localhost", "talkgadget.google.com"] + defaultPrefs[JustUsedConstants.prefExcludeDomains] = defaultExcludeDomains defaultPrefs[JustUsedConstants.prefSendPlainTexts] = 1 defaultPrefs[JustUsedConstants.prefSendSafariHistory] = 1 NSUserDefaults.standardUserDefaults().registerDefaults(defaultPrefs) diff --git a/JustUsed/Model/GenericBrowserHistory.swift b/JustUsed/Model/GenericBrowserHistory.swift index 5f4affa..3027641 100644 --- a/JustUsed/Model/GenericBrowserHistory.swift +++ b/JustUsed/Model/GenericBrowserHistory.swift @@ -26,6 +26,28 @@ struct BrowserHistItem: Equatable { let url: String let title: String? let location: Location? + let excludedFromDiMe: Bool + + init(browser: BrowserType, date: NSDate, url: String, title: String?, location: Location?) { + self.browser = browser + self.date = date + self.url = url + self.title = title + self.location = location + + // Set excluded property if url's domain is in exclude list + if let url = NSURL(string: self.url), domain = url.host { + let excludeDomains = NSUserDefaults.standardUserDefaults().valueForKey(JustUsedConstants.prefExcludeDomains) as! [String] + let filteredDomains = excludeDomains.filter({domain.rangeOfString($0) != nil}) + if filteredDomains.count > 0 { + excludedFromDiMe = true + } else { + excludedFromDiMe = false + } + } else { + excludedFromDiMe = false + } + } } func ==(lhs: BrowserHistItem, rhs: BrowserHistItem) -> Bool { diff --git a/JustUsed/UI/DiMePreferencesViewController.swift b/JustUsed/UI/DiMePreferencesViewController.swift index c54ec88..749c90d 100644 --- a/JustUsed/UI/DiMePreferencesViewController.swift +++ b/JustUsed/UI/DiMePreferencesViewController.swift @@ -39,7 +39,29 @@ class DiMePreferencesViewController: NSViewController { // similar set here sendSafariHistCell.bind("value", toObject: NSUserDefaultsController.sharedUserDefaultsController(), withKeyPath: "values." + JustUsedConstants.prefSendSafariHistory, options: options) - logsPathLabel.stringValue = AppSingleton.logsURL.path ?? "" + logsPathLabel.stringValue = AppSingleton.logsURL.path ?? "" } + + /// Domain names + @IBOutlet weak var userDefaultsAC: NSArrayController! + @IBOutlet weak var domainsTable: NSTableView! + @IBOutlet weak var newDomainField: NSTextField! + + @IBAction func removeButtonPress(sender: NSButton) { + if domainsTable.selectedRow != -1 { + userDefaultsAC.removeObjectAtArrangedObjectIndex(domainsTable.selectedRow) + } + } + + @IBAction func addButtonPress(sender: NSButton) { + let newVal = newDomainField.stringValue.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) + if newVal.characters.count > 0 { + let cont = userDefaultsAC.content as! [String] + if cont.indexOf(newVal) == nil { + userDefaultsAC.addObject(newVal) + } + newDomainField.stringValue = "" + } + } } diff --git a/JustUsed/UI/ViewController.swift b/JustUsed/UI/ViewController.swift index 98a2c33..cb45e34 100644 --- a/JustUsed/UI/ViewController.swift +++ b/JustUsed/UI/ViewController.swift @@ -127,6 +127,8 @@ class BrowserTrackerDataSource: NSObject, NSTableViewDataSource { } else { return JustUsedConstants.kUnkownLocationString } + } else if tableColumn!.identifier == JustUsedConstants.kBHistoryExcluded { + return allHistory[row].excludedFromDiMe ? "Yes" : "No" } else { return allHistory[row].url } diff --git a/JustUsed/Utils/JustUsedConstants.swift b/JustUsed/Utils/JustUsedConstants.swift index c320794..309c655 100644 --- a/JustUsed/Utils/JustUsedConstants.swift +++ b/JustUsed/Utils/JustUsedConstants.swift @@ -18,6 +18,7 @@ class JustUsedConstants { static let kMimeType = "Mime type" static let kLocTitle = "Location description" static let kBHistoryBrowser = "Browser" + static let kBHistoryExcluded = "Excluded" static let kBHistoryDate = "URL Visit time" static let kBHistoryURL = "Visited URL" static let kBHistoryTitle = "Page title" @@ -25,6 +26,10 @@ class JustUsedConstants { // MARK: - Preference identifiers + /// Preference index representing list of excluded domains. + /// - Note: changing this requires manual change in the preferences' array controller + static let prefExcludeDomains = "pref.excludeDomains" + /// URL of the DiMe server (bound in the preferences window) static let prefDiMeServerURL = "dime.serverinfo.url" diff --git a/Stuff/dmg/makedmg b/Stuff/dmg/makedmg index 5b0999b..5dc983e 100755 --- a/Stuff/dmg/makedmg +++ b/Stuff/dmg/makedmg @@ -7,4 +7,4 @@ # requires PeyeDF.app in the current folder (latest binary) -appdmg appdmg.json PeyeDF.dmg +appdmg appdmg.json "Mac Desktop Tracker.dmg"