Skip to content
Permalink
Browse files

Upgraded to Swift 5.0

  • Loading branch information...
bear101 committed Mar 30, 2019
1 parent 17aac3c commit 7c0024106dd0e8e43b192d610ed415356fd578c3
@@ -333,7 +333,7 @@
254B7A461B98BAA300BE0DEF = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = QF4DLGWC27;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
@@ -342,14 +342,14 @@
};
254B7A5B1B98BAA400BE0DEF = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
TestTargetID = 254B7A461B98BAA300BE0DEF;
};
};
};
buildConfigurationList = 254B7A421B98BAA300BE0DEF /* Build configuration list for PBXProject "iTeamTalk" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -641,8 +641,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "iTeamTalk/iTeamTalk-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -666,8 +665,7 @@
PRODUCT_BUNDLE_IDENTIFIER = BearWare.dk.iTeamTalk5;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "iTeamTalk/iTeamTalk-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -686,8 +684,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "BearWare.dk.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iTeamTalk.app/iTeamTalk";
};
name = Debug;
@@ -702,8 +699,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "BearWare.dk.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iTeamTalk.app/iTeamTalk";
};
name = Release;
@@ -31,9 +31,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

let backgroundQueue = DispatchQueue.global(qos: DispatchQoS.QoSClass.background)
var backgroundRunning: Bool = false
var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid
var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
TT_SetLicenseInformation(REGISTRATION_NAME, REGISTRATION_KEY)
@@ -88,7 +88,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ app: UIApplication,
open url: URL,
options opt: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
options opt: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

let urlStr = url.absoluteString
// print ("URL: " + url.absoluteString)
@@ -149,12 +149,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
[unowned self] in
self.endBackgroundTask()
})
assert(backgroundTask != UIBackgroundTaskInvalid)
assert(backgroundTask != UIBackgroundTaskIdentifier.invalid)
}

func endBackgroundTask() {
UIApplication.shared.endBackgroundTask(backgroundTask)
backgroundTask = UIBackgroundTaskInvalid
UIApplication.shared.endBackgroundTask(convertToUIBackgroundTaskIdentifier(backgroundTask.rawValue))
backgroundTask = UIBackgroundTaskIdentifier.invalid
}
}


// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIBackgroundTaskIdentifier(_ input: Int) -> UIBackgroundTaskIdentifier {
return UIBackgroundTaskIdentifier(rawValue: input)
}
@@ -149,14 +149,14 @@ class AudioCodecViewController : UITableViewController {
let opus_savecell = tableView.dequeueReusableCell(withIdentifier: "Use OPUS")!
opus_items.append(opus_savecell)

if let i = opus_applications.index(of: opuscodec.nApplication) {
if let i = opus_applications.firstIndex(of: opuscodec.nApplication) {
opus_appSegCtrl!.selectedSegmentIndex = i
}
else {
opus_appSegCtrl!.selectedSegmentIndex = 0
}

if let i = opus_samplerates.index(of: opuscodec.nSampleRate) {
if let i = opus_samplerates.firstIndex(of: opuscodec.nSampleRate) {
opus_srSegCtrl!.selectedSegmentIndex = i
}
else {
@@ -215,8 +215,8 @@ class ChannelDetailViewController :
var errmsg = getClientErrorMsg(&m).pointee
let s = String(cString: getClientErrorMsgString(ERRMESSAGE, &errmsg))
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog message"), message: s, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog message"), style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog message"), message: s, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog message"), style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)

} else {
@@ -420,7 +420,7 @@ class ChannelListViewController :
actions.append(action_edit)
}
else {
cell.editBtn.setTitle(NSLocalizedString("View", comment: "channel list"), for: UIControlState())
cell.editBtn.setTitle(NSLocalizedString("View", comment: "channel list"), for: UIControl.State())
let action_view = MyCustomAction(name: NSLocalizedString("View properties", comment: "channel list"), target: self, selector: #selector(ChannelListViewController.editChannel(_:)), tag: cell.tag)
actions.append(action_view)
}
@@ -764,14 +764,14 @@ class ChannelListViewController :
if unreadmessages.contains(INT32(c.tag)) {
let time = Int(Date().timeIntervalSince1970)
if time % 2 == 0 {
cell.messageBtn.setImage(UIImage(named: "message_red"), for: UIControlState())
cell.messageBtn.setImage(UIImage(named: "message_red"), for: UIControl.State())
}
else {
cell.messageBtn.setImage(UIImage(named: "message_blue"), for: UIControlState())
cell.messageBtn.setImage(UIImage(named: "message_blue"), for: UIControl.State())
}
}
else {
cell.messageBtn.setImage(UIImage(named: "message_blue"), for: UIControlState())
cell.messageBtn.setImage(UIImage(named: "message_blue"), for: UIControl.State())
}
}
}
@@ -812,8 +812,8 @@ class ChannelListViewController :
var errmsg = getClientErrorMsg(&m).pointee
let s = String(cString: getClientErrorMsgString(ERRMESSAGE, &errmsg))
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog"), message: s, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog"), style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog"), message: s, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog"), style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
} else {
// Fallback on earlier versions
@@ -1025,8 +1025,8 @@ class ChannelListViewController :
var errmsg = getClientErrorMsg(&m).pointee
let s = String(cString: getClientErrorMsgString(ERRMESSAGE, &errmsg))
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog message"), message: s, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog message"), style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "Dialog message"), message: s, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Dialog message"), style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
} else {
// Fallback on earlier versions
@@ -154,7 +154,7 @@ func newTableCellBtn(_ cell: UITableViewCell, label: String, btntext: String) ->
cell.selectionStyle = .none
cell.textLabel?.text = label
let buttonfield = UIButton(frame: CGRect(x: 40, y: 0, width: 150, height: 31))
buttonfield.setTitle(btntext, for: UIControlState())
buttonfield.setTitle(btntext, for: UIControl.State())
cell.accessoryView = buttonfield

return buttonfield
@@ -492,17 +492,15 @@ func enableSpeakerOutput(_ on: Bool) {
let session = AVAudioSession.sharedInstance()

do {
print("preset: " + session.mode)
print("preset: " + convertFromAVAudioSessionMode(session.mode))
if on {
try session.setMode(AVAudioSessionModeVideoChat)
try session.setMode(AVAudioSession.Mode.videoChat)
}
else {
try session.setMode(AVAudioSessionModeDefault)
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
// try session.overrideOutputAudioPort(AVAudioSessionPortOverride.None)
try session.setMode(AVAudioSession.Mode.default)
try session.setCategory(AVAudioSession.Category.playAndRecord, options: AVAudioSession.CategoryOptions.allowBluetooth)
}
// try session.setActive(true)
print("post set: " + session.mode)
print("post set: " + convertFromAVAudioSessionMode(session.mode))
}
catch {
print("Failed to set mode")
@@ -713,3 +711,13 @@ func toTTString(_ src: String, dst: inout (TTCHAR, TTCHAR, TTCHAR, TTCHAR, TTCHA
convertTuple(src, &c)
dst = c.buf
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromAVAudioSessionMode(_ input: AVAudioSession.Mode) -> String {
return input.rawValue
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromAVAudioSessionCategory(_ input: AVAudioSession.Category) -> String {
return input.rawValue
}
@@ -96,12 +96,12 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv
let device = UIDevice.current

let center = NotificationCenter.default
center.addObserver(self, selector: #selector(MainTabBarController.proximityChanged(_:)), name: NSNotification.Name.UIDeviceProximityStateDidChange, object: device)
center.addObserver(self, selector: #selector(MainTabBarController.proximityChanged(_:)), name: UIDevice.proximityStateDidChangeNotification, object: device)

// detect device changes, e.g. headset plugged in
center.addObserver(self, selector: #selector(MainTabBarController.audioRouteChange(_:)), name: NSNotification.Name.AVAudioSessionRouteChange, object: nil)
center.addObserver(self, selector: #selector(MainTabBarController.audioRouteChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)

center.addObserver(self, selector: #selector(MainTabBarController.audioInterruption(_:)), name: NSNotification.Name.AVAudioSessionInterruption, object: nil)
center.addObserver(self, selector: #selector(MainTabBarController.audioInterruption(_:)), name: AVAudioSession.interruptionNotification, object: nil)

if server.username == AppInfo.WEBLOGIN_FACEBOOK {
facebookLogin()
@@ -140,7 +140,7 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

if self.isMovingFromParentViewController {
if self.isMovingFromParent {
polltimer?.invalidate()
reconnecttimer?.invalidate()
TT_CloseTeamTalk(ttInst)
@@ -248,30 +248,30 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv
if let reason = notification.userInfo![AVAudioSessionRouteChangeReasonKey] {

switch reason as! UInt {
case AVAudioSessionRouteChangeReason.unknown.rawValue :
case AVAudioSession.RouteChangeReason.unknown.rawValue :
//print("ChangeReason Unknown")
break
case AVAudioSessionRouteChangeReason.newDeviceAvailable.rawValue :
case AVAudioSession.RouteChangeReason.newDeviceAvailable.rawValue :
//print("ChangeReason NewDeviceAvailable")
break
case AVAudioSessionRouteChangeReason.oldDeviceUnavailable.rawValue:
case AVAudioSession.RouteChangeReason.oldDeviceUnavailable.rawValue:
// print("ChangeReason Unknown")
setupSpeakerOutput()
case AVAudioSessionRouteChangeReason.categoryChange.rawValue:
case AVAudioSession.RouteChangeReason.categoryChange.rawValue:
// let session = AVAudioSession.sharedInstance()
// print("ChangeReason CategoryChange, new category: " + session.category)
break
case AVAudioSessionRouteChangeReason.override.rawValue :
case AVAudioSession.RouteChangeReason.override.rawValue :
// let session = AVAudioSession.sharedInstance()
// print("ChangeReason Override, new route: " + session.currentRoute.description)
break
case AVAudioSessionRouteChangeReason.routeConfigurationChange.rawValue :
case AVAudioSession.RouteChangeReason.routeConfigurationChange.rawValue :
// print("ChangeReason RouteConfigurationChange")
break
case AVAudioSessionRouteChangeReason.wakeFromSleep.rawValue:
case AVAudioSession.RouteChangeReason.wakeFromSleep.rawValue:
// print("ChangeReason WakeFromSleep")
break
case AVAudioSessionRouteChangeReason.noSuitableRouteForCategory.rawValue:
case AVAudioSession.RouteChangeReason.noSuitableRouteForCategory.rawValue:
// print("ChangeReason NoSuitableRouteForCategory")
break
default :
@@ -287,10 +287,10 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv
if let reason = notification.userInfo![AVAudioSessionInterruptionTypeKey] {

switch reason as! UInt {
case AVAudioSessionInterruptionType.began.rawValue :
case AVAudioSession.InterruptionType.began.rawValue :
//print("Audio interruption begin")
break
case AVAudioSessionInterruptionType.ended.rawValue :
case AVAudioSession.InterruptionType.ended.rawValue :
//print("Audio interruption ended")
break
default :
@@ -302,7 +302,7 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv

// when phone call is complete we restart the sound devices
switch reason as! UInt {
case AVAudioSessionInterruptionOptions.shouldResume.rawValue :
case AVAudioSession.InterruptionOptions.shouldResume.rawValue :
//print("Audio session can now resume")
TT_CloseSoundInputDevice(ttInst)
@@ -378,8 +378,8 @@ class MainTabBarController : UITabBarController, UIAlertViewDelegate, TeamTalkEv
var errmsg = getClientErrorMsg(&m).pointee
let s = String(cString: getClientErrorMsgString(ERRMESSAGE, &errmsg))
if #available(iOS 8.0, *) {
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "message dialog"), message: s, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "message dialog"), style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: NSLocalizedString("Error", comment: "message dialog"), message: s, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "message dialog"), style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
} else {
// Fallback on earlier versions
@@ -265,7 +265,7 @@ class ServerListViewController : UITableViewController,
vc.saveServerDetail()
let name = vc.server.name

if let found = servers.map({$0.name}).index(of: name) {
if let found = servers.map({$0.name}).firstIndex(of: name) {
servers[found] = vc.server
}
else {
@@ -439,10 +439,10 @@ class ServerParser : NSObject, XMLParserDelegate {
case "username" :
currentServer.username = string
case "password" :
if elementStack.index(of: "auth") != nil {
if elementStack.firstIndex(of: "auth") != nil {
currentServer.password = string
}
else if elementStack.index(of: "join") != nil {
else if elementStack.firstIndex(of: "join") != nil {
currentServer.chanpasswd = string
}
case "channel" :
Oops, something went wrong.

0 comments on commit 7c00241

Please sign in to comment.
You can’t perform that action at this time.