Merge pull request #8 from cs17899219/develop
Use a singleton ServerProfileManager
This commit is contained in:
@ -81,7 +81,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
if let userInfo = note.userInfo {
|
||||
let urls: [NSURL] = userInfo["urls"] as! [NSURL]
|
||||
|
||||
let mgr = ServerProfileManager()
|
||||
let mgr = ServerProfileManager.instance
|
||||
var isChanged = false
|
||||
|
||||
for url in urls {
|
||||
@ -191,8 +191,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
@IBAction func showQRCodeForCurrentServer(sender: NSMenuItem) {
|
||||
var errMsg: String?
|
||||
let mgr = ServerProfileManager()
|
||||
if let profile = mgr.getActiveProfile() {
|
||||
if let profile = ServerProfileManager.instance.getActiveProfile() {
|
||||
if profile.isValid() {
|
||||
// Show window
|
||||
if qrcodeWinCtrl != nil{
|
||||
@ -275,7 +274,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
|
||||
@IBAction func selectServer(sender: NSMenuItem) {
|
||||
let index = sender.tag
|
||||
let spMgr = ServerProfileManager()
|
||||
let spMgr = ServerProfileManager.instance
|
||||
let newProfile = spMgr.profiles[index]
|
||||
if newProfile.uuid != spMgr.activeProfileId {
|
||||
spMgr.setActiveProfiledId(newProfile.uuid)
|
||||
@ -345,7 +344,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
}
|
||||
|
||||
func updateServersMenu() {
|
||||
let mgr = ServerProfileManager()
|
||||
let mgr = ServerProfileManager.instance
|
||||
serversMenuItem.submenu?.removeAllItems()
|
||||
let preferencesItem = serversPreferencesMenuItem
|
||||
|
||||
|
@ -147,7 +147,7 @@ func removeSSLocalConfFile() {
|
||||
func SyncSSLocal() {
|
||||
var changed: Bool = false
|
||||
changed = changed || generateSSLocalLauchAgentPlist()
|
||||
let mgr = ServerProfileManager()
|
||||
let mgr = ServerProfileManager.instance
|
||||
if mgr.activeProfileId != nil {
|
||||
changed = changed || writeSSLocalConfFile((mgr.getActiveProfile()?.toJsonConfig())!)
|
||||
|
||||
|
@ -36,7 +36,7 @@ class PreferencesWindowController: NSWindowController
|
||||
|
||||
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
|
||||
defaults = NSUserDefaults.standardUserDefaults()
|
||||
profileMgr = ServerProfileManager()
|
||||
profileMgr = ServerProfileManager.instance
|
||||
|
||||
methodTextField.addItemsWithObjectValues([
|
||||
"aes-128-cfb",
|
||||
|
@ -10,10 +10,12 @@ import Cocoa
|
||||
|
||||
class ServerProfileManager: NSObject {
|
||||
|
||||
static let instance:ServerProfileManager = ServerProfileManager()
|
||||
|
||||
var profiles:[ServerProfile]
|
||||
var activeProfileId: String?
|
||||
|
||||
override init() {
|
||||
private override init() {
|
||||
profiles = [ServerProfile]()
|
||||
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
|
Reference in New Issue
Block a user