Send a system notification when not found valid qrcode of ss profile.
This commit is contained in:
@ -138,6 +138,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
)
|
)
|
||||||
notifyCenter.addObserver(forName: NSNotification.Name(rawValue: "NOTIFY_FOUND_SS_URL"), object: nil, queue: nil) {
|
notifyCenter.addObserver(forName: NSNotification.Name(rawValue: "NOTIFY_FOUND_SS_URL"), object: nil, queue: nil) {
|
||||||
(note: Notification) in
|
(note: Notification) in
|
||||||
|
|
||||||
|
let sendNotify = {
|
||||||
|
(title: String, subtitle: String, infoText: String) in
|
||||||
|
|
||||||
|
let userNote = NSUserNotification()
|
||||||
|
userNote.title = title
|
||||||
|
userNote.subtitle = subtitle
|
||||||
|
userNote.informativeText = infoText
|
||||||
|
userNote.soundName = NSUserNotificationDefaultSoundName
|
||||||
|
|
||||||
|
NSUserNotificationCenter.default
|
||||||
|
.deliver(userNote);
|
||||||
|
}
|
||||||
|
|
||||||
if let userInfo = (note as NSNotification).userInfo {
|
if let userInfo = (note as NSNotification).userInfo {
|
||||||
let urls: [URL] = userInfo["urls"] as! [URL]
|
let urls: [URL] = userInfo["urls"] as! [URL]
|
||||||
|
|
||||||
@ -149,26 +163,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
mgr.profiles.append(profile)
|
mgr.profiles.append(profile)
|
||||||
isChanged = true
|
isChanged = true
|
||||||
|
|
||||||
let userNote = NSUserNotification()
|
var subtitle: String = ""
|
||||||
userNote.title = "Add Shadowsocks Server Profile".localized
|
|
||||||
if userInfo["source"] as! String == "qrcode" {
|
if userInfo["source"] as! String == "qrcode" {
|
||||||
userNote.subtitle = "By scan QR Code".localized
|
subtitle = "By scan QR Code".localized
|
||||||
} else if userInfo["source"] as! String == "url" {
|
} else if userInfo["source"] as! String == "url" {
|
||||||
userNote.subtitle = "By Handle SS URL".localized
|
subtitle = "By Handle SS URL".localized
|
||||||
}
|
}
|
||||||
userNote.informativeText = "Host: \(profile.serverHost)"
|
|
||||||
//" Port: \(profile.serverPort)"
|
|
||||||
//" Encription Method: \(profile.method)".localized
|
|
||||||
userNote.soundName = NSUserNotificationDefaultSoundName
|
|
||||||
|
|
||||||
NSUserNotificationCenter.default
|
sendNotify("Add Shadowsocks Server Profile".localized, subtitle, "Host: \(profile.serverHost)")
|
||||||
.deliver(userNote);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isChanged {
|
if isChanged {
|
||||||
mgr.save()
|
mgr.save()
|
||||||
self.updateServersMenu()
|
self.updateServersMenu()
|
||||||
|
} else {
|
||||||
|
sendNotify("Not found valid qrcode of shadowsocks profile.", "", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user