Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Pods/
build/

xcuserdata/
.idea/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode9.1
osx_image: xcode11
language: objective-c
xcode_workspace: Noti.xcworkspace
xcode_scheme: Noti
Expand Down
17 changes: 7 additions & 10 deletions Noti.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
499DD0F81D2D7BBF00BB759D /* Ephemerals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499DD0F71D2D7BBF00BB759D /* Ephemerals.swift */; };
499DD0FC1D2D8FAC00BB759D /* RoundedImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499DD0FB1D2D8FAC00BB759D /* RoundedImage.swift */; };
49B43B0C1D1ADFB200A24585 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B43B0B1D1ADFB200A24585 /* AppDelegate.swift */; };
49B43B0E1D1ADFB200A24585 /* AuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B43B0D1D1ADFB200A24585 /* AuthViewController.swift */; };
49B43B101D1ADFB200A24585 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 49B43B0F1D1ADFB200A24585 /* Assets.xcassets */; };
49B43B131D1ADFB200A24585 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 49B43B111D1ADFB200A24585 /* Main.storyboard */; };
49B43B1B1D1AE0F200A24585 /* Podfile in Resources */ = {isa = PBXBuildFile; fileRef = 49B43B1A1D1AE0F200A24585 /* Podfile */; };
Expand All @@ -37,7 +36,6 @@
49AE29531DB4D86E00B61843 /* SwCrypt.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwCrypt.framework; path = SwCrypt/build/Debug/SwCrypt.framework; sourceTree = "<group>"; };
49B43B081D1ADFB200A24585 /* Noti.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Noti.app; sourceTree = BUILT_PRODUCTS_DIR; };
49B43B0B1D1ADFB200A24585 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
49B43B0D1D1ADFB200A24585 /* AuthViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthViewController.swift; sourceTree = "<group>"; };
49B43B0F1D1ADFB200A24585 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
49B43B121D1ADFB200A24585 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
49B43B141D1ADFB200A24585 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -82,7 +80,6 @@
isa = PBXGroup;
children = (
49B43B0B1D1ADFB200A24585 /* AppDelegate.swift */,
49B43B0D1D1ADFB200A24585 /* AuthViewController.swift */,
49B43B0F1D1ADFB200A24585 /* Assets.xcassets */,
49B43B111D1ADFB200A24585 /* Main.storyboard */,
4901D3D21D23E6AB005F1641 /* IntroViewController.swift */,
Expand Down Expand Up @@ -160,6 +157,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -194,7 +192,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Noti/Pods-Noti-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-Noti/Pods-Noti-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
"${BUILT_PRODUCTS_DIR}/EMCLoginItem/EMCLoginItem.framework",
Expand All @@ -219,7 +217,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Noti/Pods-Noti-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Noti/Pods-Noti-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
C46969CE10D5230F33E29F6C /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -251,7 +249,6 @@
499DD0FC1D2D8FAC00BB759D /* RoundedImage.swift in Sources */,
491E887B1FC588F70048215F /* PreferencesViewController.swift in Sources */,
498499FE1D1BE46F007FC963 /* PushManager.swift in Sources */,
49B43B0E1D1ADFB200A24585 /* AuthViewController.swift in Sources */,
4901D3CF1D1C121D005F1641 /* StatusMenuController.swift in Sources */,
49B43B0C1D1ADFB200A24585 /* AppDelegate.swift in Sources */,
499DD0F81D2D7BBF00BB759D /* Ephemerals.swift in Sources */,
Expand Down Expand Up @@ -390,11 +387,11 @@
"$(inherited)",
"$(PROJECT_DIR)/SwCrypt/build/Debug",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = io.jari.Noti;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -416,11 +413,11 @@
"$(inherited)",
"$(PROJECT_DIR)/SwCrypt/build/Debug",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_BUNDLE_IDENTIFIER = io.jari.Noti;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
50 changes: 34 additions & 16 deletions Noti/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,52 @@ let log = SwiftyBeaver.self

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

var pushManager: PushManager?
let userDefaults: UserDefaults = UserDefaults.standard
var iwc:NSWindowController?;
var pwc:NSWindowController?;

var nonce: String? = nil;

func setPassword(password: String) {
pushManager?.setPassword(password: password)
}

func loadPushManager() {
let token = userDefaults.string(forKey: "token")

if(token != nil) {
pushManager = PushManager(token: token!)
} else {
print("WARN: PushManager not initialized because of missing token. Displaying Intro")

if(pushManager != nil) {
pushManager!.disconnect()
}
let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil)
iwc = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "IntroWindowController")) as? NSWindowController

let storyboard = NSStoryboard(name: "Main", bundle: nil)
iwc = storyboard.instantiateController(withIdentifier: "IntroWindowController") as? NSWindowController
NSApplication.shared.activate(ignoringOtherApps: true)
iwc!.showWindow(self)
iwc!.window?.makeKeyAndOrderFront(self)
}
}

func displayPreferencesWindow() {
if(pushManager == nil) {
let alert = NSAlert()
alert.messageText = "Please authorize Noti before changing it's preferences."
alert.runModal()
return;
}
let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil)
pwc = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "PreferencesWindowController")) as? NSWindowController

let storyboard = NSStoryboard(name: "Main", bundle: nil)
pwc = storyboard.instantiateController(withIdentifier: "PreferencesWindowController") as? NSWindowController
NSApplication.shared.activate(ignoringOtherApps: true)
pwc!.showWindow(self)
pwc!.window?.makeKeyAndOrderFront(self)
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
let file = FileDestination() // Adding file destination of log output
let console = ConsoleDestination() // log to Xcode Console
Expand All @@ -73,11 +74,28 @@ class AppDelegate: NSObject, NSApplicationDelegate {
log.addDestination(console)
loadPushManager()
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
log.info("Going to terminate Noti.")
}



func application(_ application: NSApplication, open urls: [URL]) {
// Extract access token from redirect uri
guard let url = URLComponents(url: urls.first!, resolvingAgainstBaseURL: true) else { return }
guard let token = url.fragment?.split(separator: "=")[1] else { return }
guard let receivedNonce = url.queryItems?.first(where: { $0.name == "nonce" })?.value else { return }

// Verify nonce
if receivedNonce != nonce {
return
}

// Dispose to prevent replays
nonce = nil

userDefaults.setValue(token, forKeyPath: "token")
loadPushManager()
NotificationCenter.default.post(name: Notification.Name(rawValue: "AuthSuccess"), object: nil)
}
}
55 changes: 0 additions & 55 deletions Noti/AuthViewController.swift

This file was deleted.

Loading