GUI
This commit is contained in:
parent
0752fe0547
commit
baba7de448
@ -13,6 +13,9 @@
|
||||
ECEBE1991BA0639500E5B4E3 /* ipbc_ClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1981BA0639500E5B4E3 /* ipbc_ClientTests.swift */; };
|
||||
ECEBE1A41BA0690B00E5B4E3 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1A21BA0690B00E5B4E3 /* MainViewController.swift */; };
|
||||
ECEBE1A51BA0690B00E5B4E3 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = ECEBE1A31BA0690B00E5B4E3 /* MainViewController.xib */; };
|
||||
ECEBE1A91BA0752600E5B4E3 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1A81BA0752600E5B4E3 /* EventMonitor.swift */; };
|
||||
ECEBE1AB1BA07DD600E5B4E3 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1AA1BA07DD600E5B4E3 /* Constants.swift */; };
|
||||
ECEBE1AE1BA0C61100E5B4E3 /* WebserviceClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -36,6 +39,9 @@
|
||||
ECEBE1981BA0639500E5B4E3 /* ipbc_ClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ipbc_ClientTests.swift; sourceTree = "<group>"; };
|
||||
ECEBE1A21BA0690B00E5B4E3 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MainViewController.swift; path = Controller/MainViewController.swift; sourceTree = "<group>"; };
|
||||
ECEBE1A31BA0690B00E5B4E3 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MainViewController.xib; path = Controller/MainViewController.xib; sourceTree = "<group>"; };
|
||||
ECEBE1A81BA0752600E5B4E3 /* EventMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = "<group>"; };
|
||||
ECEBE1AA1BA07DD600E5B4E3 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
|
||||
ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebserviceClient.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -77,11 +83,14 @@
|
||||
ECEBE1841BA0639500E5B4E3 /* ipbc-Client */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ECEBE1AC1BA0C60000E5B4E3 /* WebService */,
|
||||
ECEBE1A71BA0693200E5B4E3 /* control */,
|
||||
ECEBE1A61BA0692000E5B4E3 /* view */,
|
||||
ECEBE1871BA0639500E5B4E3 /* AppDelegate.swift */,
|
||||
ECEBE1891BA0639500E5B4E3 /* Images.xcassets */,
|
||||
ECEBE1851BA0639500E5B4E3 /* Supporting Files */,
|
||||
ECEBE1A81BA0752600E5B4E3 /* EventMonitor.swift */,
|
||||
ECEBE1AA1BA07DD600E5B4E3 /* Constants.swift */,
|
||||
);
|
||||
path = "ipbc-Client";
|
||||
sourceTree = "<group>";
|
||||
@ -128,6 +137,14 @@
|
||||
name = control;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
ECEBE1AC1BA0C60000E5B4E3 /* WebService */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ECEBE1AD1BA0C61100E5B4E3 /* WebserviceClient.swift */,
|
||||
);
|
||||
name = WebService;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@ -228,8 +245,11 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
ECEBE1A91BA0752600E5B4E3 /* EventMonitor.swift in Sources */,
|
||||
ECEBE1AE1BA0C61100E5B4E3 /* WebserviceClient.swift in Sources */,
|
||||
ECEBE1881BA0639500E5B4E3 /* AppDelegate.swift in Sources */,
|
||||
ECEBE1A41BA0690B00E5B4E3 /* MainViewController.swift in Sources */,
|
||||
ECEBE1AB1BA07DD600E5B4E3 /* Constants.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -420,6 +440,7 @@
|
||||
ECEBE19E1BA0639500E5B4E3 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
ECEBE19F1BA0639500E5B4E3 /* Build configuration list for PBXNativeTarget "ipbc-ClientTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
@ -428,6 +449,7 @@
|
||||
ECEBE1A11BA0639500E5B4E3 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
<key>IDESourceControlProjectIdentifier</key>
|
||||
<string>B4996E80-3257-4F7C-86EA-7424113FB751</string>
|
||||
<key>IDESourceControlProjectName</key>
|
||||
<string>project</string>
|
||||
<string>ipbc-Client</string>
|
||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||
<dict>
|
||||
<key>41A46EC74341898613642098E6535621FD117950</key>
|
||||
<string>ssh://services.adawim.com:7999/ipbc/statusbar-app-osx.git</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectPath</key>
|
||||
<string>ipbc-Client/ipbc-Client.xcodeproj/project.xcworkspace</string>
|
||||
<string>ipbc-Client/ipbc-Client.xcodeproj</string>
|
||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||
<dict>
|
||||
<key>41A46EC74341898613642098E6535621FD117950</key>
|
||||
|
||||
Binary file not shown.
@ -12,19 +12,31 @@ import Cocoa
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2)
|
||||
|
||||
let popover = NSPopover()
|
||||
var eventMonitor: EventMonitor?
|
||||
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-2)
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
// Insert code here to initialize your application
|
||||
|
||||
|
||||
// Icon
|
||||
if let button = statusItem.button {
|
||||
button.image = NSImage(named: "statusbar-icon")
|
||||
button.action = Selector("togglePopover:")
|
||||
}
|
||||
|
||||
popover.contentViewController = MainViewController(nibName: "MainViewController", bundle: nil)
|
||||
|
||||
|
||||
// EventMonitor
|
||||
eventMonitor = EventMonitor(mask: .LeftMouseDownMask | .RightMouseDownMask) { [unowned self] event in
|
||||
if self.popover.shown {
|
||||
self.closePopover(event)
|
||||
}
|
||||
}
|
||||
eventMonitor?.start()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
|
||||
26
ipbc-Client/ipbc-Client/Constants.swift
Normal file
26
ipbc-Client/ipbc-Client/Constants.swift
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Constants.swift
|
||||
// ipbc-Client
|
||||
//
|
||||
// Created by Gerrit Linnemann on 09.09.15.
|
||||
// Copyright (c) 2015 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct Constants {
|
||||
struct Web {
|
||||
static let REGISTER = "https://www.ip-bc.org/login.xhtml"
|
||||
}
|
||||
|
||||
struct WebService {
|
||||
static let BASE = "www.ip-bc.org"
|
||||
static let UPDATE = "https://www.ip-bc.org/ws/update/ip"
|
||||
static let GET_USERS_IP = "https://www.ip-bc.org/ws/info/ip"
|
||||
}
|
||||
|
||||
struct UserDefaults {
|
||||
static let HOST = "USERDEFAULT_HOST"
|
||||
static let TOKEN = "USERDEFAULT_TOKEN"
|
||||
}
|
||||
}
|
||||
@ -9,10 +9,44 @@
|
||||
import Cocoa
|
||||
|
||||
class MainViewController: NSViewController {
|
||||
|
||||
@IBOutlet weak var btnQuit: NSButton!
|
||||
@IBOutlet weak var btnRegister: NSButton!
|
||||
@IBOutlet weak var btnSave: NSButton!
|
||||
@IBOutlet weak var btnCancel: NSButton!
|
||||
@IBOutlet weak var lblCurrentIP: NSTextField!
|
||||
@IBOutlet weak var txtName: NSTextField!
|
||||
@IBOutlet weak var txtToken: NSTextField!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do view setup here.
|
||||
|
||||
self.lblCurrentIP.stringValue = ""
|
||||
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
if let udHost = defaults.stringForKey(Constants.UserDefaults.HOST) {
|
||||
txtName.stringValue = udHost
|
||||
}
|
||||
if let udToken = defaults.stringForKey(Constants.UserDefaults.TOKEN) {
|
||||
txtToken.stringValue = udToken
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func actionQuit(sender: NSButton) {
|
||||
NSApplication.sharedApplication().terminate(self)
|
||||
}
|
||||
|
||||
@IBAction func actionOpenRegister(sender: NSButton) {
|
||||
|
||||
}
|
||||
|
||||
@IBAction func actionSaveSettings(sender: NSButton) {
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
|
||||
defaults.setObject(txtName.stringValue, forKey: Constants.UserDefaults.HOST)
|
||||
defaults.setObject(txtToken.stringValue, forKey: Constants.UserDefaults.TOKEN)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5023"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MainViewController" customModuleProvider="target">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MainViewController" customModule="ipbc_Client" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="btnCancel" destination="jbP-qx-AVu" id="8Kt-SW-cho"/>
|
||||
<outlet property="btnQuit" destination="PD1-7B-cXi" id="nZP-fa-Wgn"/>
|
||||
<outlet property="btnRegister" destination="1iz-w3-phH" id="SJg-gH-Plq"/>
|
||||
<outlet property="btnSave" destination="ypT-pC-8JJ" id="db6-84-UOc"/>
|
||||
<outlet property="lblCurrentIP" destination="xnC-6n-NBZ" id="uc5-yd-nbs"/>
|
||||
<outlet property="txtName" destination="kFw-34-cr2" id="v6N-Nf-bKE"/>
|
||||
<outlet property="txtToken" destination="RhG-a4-uFI" id="OhO-HR-fDd"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="597" height="343"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zgv-WW-lzf">
|
||||
<rect key="frame" x="20" y="275" width="48" height="48"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSInfo" id="69M-w8-Yqu"/>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5ZC-Az-Hgm">
|
||||
<rect key="frame" x="74" y="261" width="505" height="62"/>
|
||||
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="5sC-hz-jDG">
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="title">This is an application that updates your hostnames with the latest IP address of your computer assuring that you will always have an updated hostname allowing you to connect to your computer from everywhere.</string>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gIr-Nl-sTM">
|
||||
<rect key="frame" x="21" y="190" width="41" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Name" id="Yz3-k0-ZM4">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kFw-34-cr2">
|
||||
<rect key="frame" x="76" y="187" width="501" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="cz0-SV-1Tq">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RhG-a4-uFI">
|
||||
<rect key="frame" x="76" y="155" width="501" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="kEe-YG-kxT">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fP5-Fr-0oH">
|
||||
<rect key="frame" x="22" y="158" width="41" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Token" id="ORa-Yu-LTZ">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xnC-6n-NBZ">
|
||||
<rect key="frame" x="20" y="20" width="17" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="IP" id="GON-6q-6yN">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1iz-w3-phH">
|
||||
<rect key="frame" x="127" y="94" width="343" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Get your always free ip-breadcrump.org account!" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="HTL-vW-GVk">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="actionOpenRegister:" target="-2" id="WZH-Tf-a4j"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zRh-L1-zB5">
|
||||
<rect key="frame" x="290" y="130" width="17" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="or" id="GCF-L7-vwQ">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PD1-7B-cXi">
|
||||
<rect key="frame" x="517" y="13" width="66" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Quit" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vSc-pb-WWX">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="actionQuit:" target="-2" id="Sjv-pX-H2r"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="jbP-qx-AVu">
|
||||
<rect key="frame" x="434" y="13" width="83" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="noM-tn-LGF">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ypT-pC-8JJ">
|
||||
<rect key="frame" x="363" y="13" width="71" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Save" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="aQB-ul-YJ5">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="actionSaveSettings:" target="-2" id="cG5-OX-aEb"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="503.5" y="515.5"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSInfo" width="32" height="32"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
37
ipbc-Client/ipbc-Client/EventMonitor.swift
Normal file
37
ipbc-Client/ipbc-Client/EventMonitor.swift
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// EventMonitor.swift
|
||||
// ipbc-Client
|
||||
//
|
||||
// Created by Gerrit Linnemann on 09.09.15.
|
||||
// Copyright (c) 2015 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
// More infos to EventMonitor: http://www.raywenderlich.com/98178/os-x-tutorial-menus-popovers-menu-bar-apps
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
public class EventMonitor {
|
||||
private var monitor: AnyObject?
|
||||
private let mask: NSEventMask
|
||||
private let handler: NSEvent? -> ()
|
||||
|
||||
public init(mask: NSEventMask, handler: NSEvent? -> ()) {
|
||||
self.mask = mask
|
||||
self.handler = handler
|
||||
}
|
||||
|
||||
deinit {
|
||||
stop()
|
||||
}
|
||||
|
||||
public func start() {
|
||||
monitor = NSEvent.addGlobalMonitorForEventsMatchingMask(mask, handler: handler)
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
if monitor != nil {
|
||||
NSEvent.removeMonitor(monitor!)
|
||||
monitor = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
26
ipbc-Client/ipbc-Client/WebserviceClient.swift
Normal file
26
ipbc-Client/ipbc-Client/WebserviceClient.swift
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// WebserviceClient.swift
|
||||
// ipbc-Client
|
||||
//
|
||||
// Created by Gerrit Linnemann on 09.09.15.
|
||||
// Copyright (c) 2015 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
private let x_SomeManagerSharedInstance = WebserviceClient()
|
||||
|
||||
|
||||
class WebserviceClient {
|
||||
private var isNetworkAvailable : Bool = false
|
||||
private var isRequestRunning : Bool = false
|
||||
|
||||
class var sharedInstance: WebserviceClient {
|
||||
return x_SomeManagerSharedInstance
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user