unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

ViewController.swift (2191B)

      1 //
      2 //  ViewController.swift
      3 //  UnrealIRCd
      4 //
      5 //  Created by Travis McArthur on 6/26/15.
      6 //  Copyright (c) 2015 UnrealIRCd Team. All rights reserved.
      7 //
      8 
      9 import Cocoa
     10 import AppKit
     11 
     12 class ViewController: NSViewController, ChangeNotifierDelegate {
     13     
     14     @IBOutlet private weak var autoStartAgentCheckbox : NSButton?
     15     @IBOutlet private weak var autoStartDaemonCheckbox : NSButton?
     16     @IBOutlet private weak var startStopButton : NSButton?
     17     static let stopButtonString = "Stop"
     18     static let startButtonString = "Start"
     19     var configModel : ConfigurationModel?
     20     {
     21         didSet {
     22             updateConfigurationOptions()
     23             configModel?.attachChangeDelegate(self)
     24         }
     25     }
     26     
     27     var daemonModel : DaemonModel?
     28     {
     29         didSet {
     30             updateDaemonButton()
     31             daemonModel?.attachChangeDelegate(self)
     32         }
     33     }
     34     
     35     func updateDaemonButton()
     36     {
     37         startStopButton?.title = daemonModel!.isRunning ? ViewController.stopButtonString : ViewController.startButtonString
     38     }
     39     
     40     func updateConfigurationOptions()
     41     {
     42         autoStartAgentCheckbox?.state = configModel!.shouldAutoStartAgent ? NSOnState : NSOffState
     43         autoStartDaemonCheckbox?.state = configModel!.shouldAutoStartDaemon ? NSOnState : NSOffState
     44     }
     45     
     46     override func viewWillDisappear() {
     47         saveConfigurationOptions()
     48     }
     49     
     50     func saveConfigurationOptions()
     51     {
     52         configModel?.shouldAutoStartAgent = autoStartAgentCheckbox?.state == NSOnState ? true : false
     53         configModel?.shouldAutoStartDaemon = autoStartAgentCheckbox?.state == NSOnState ? true : false
     54     }
     55     
     56     @IBAction func startStopServer(sender: AnyObject)
     57     {
     58         if daemonModel!.isRunning
     59         {
     60             daemonModel?.stop()
     61         }
     62         else
     63         {
     64             daemonModel?.start()
     65         }
     66     }
     67     
     68     func modelChanged(model: ChangeNotifier) {
     69         if model === daemonModel
     70         {
     71             updateDaemonButton()
     72         }
     73         
     74         else if model === configModel
     75         {
     76             updateConfigurationOptions()
     77         }
     78     }
     79     
     80     @IBAction func configure(sender: AnyObject)
     81     {
     82         
     83     }
     84 
     85 
     86 }
     87