wireguard-apple/WireGuard/AppDelegate.swift

46 lines
1.4 KiB
Swift
Raw Normal View History

2018-05-23 19:49:10 +00:00
//
// AppDelegate.swift
// WireGuard
2018-05-23 19:49:10 +00:00
//
// Created by Jeroen Leenarts on 23-05-18.
2018-07-15 09:55:41 +00:00
// Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All rights reserved.
2018-05-23 19:49:10 +00:00
//
import UIKit
2018-08-31 21:06:40 +00:00
import os.log
2018-05-23 19:49:10 +00:00
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appCoordinator: AppCoordinator!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
self.appCoordinator = AppCoordinator(window: self.window!)
self.appCoordinator.start()
return true
}
2018-08-31 21:06:40 +00:00
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
defer {
do {
try FileManager.default.removeItem(at: url)
} catch {
os_log("Failed to remove item from Inbox: %{public}@", log: Log.general, type: .error, url.absoluteString)
}
}
guard url.pathExtension == "conf" else { return false }
do {
try appCoordinator.importConfig(config: url)
} catch {
os_log("Unable to import config: %{public}@", log: Log.general, type: .error, url.absoluteString)
return false
}
return true
}
2018-05-23 19:49:10 +00:00
}