2017-08-11 15:13:54 +02:00
|
|
|
//
|
2018-02-13 02:18:37 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-08-11 15:13:54 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2017-11-28 00:17:46 +01:00
|
|
|
import SignalServiceKit
|
2017-12-01 16:48:18 +01:00
|
|
|
import SignalMessaging
|
2017-08-11 15:13:54 +02:00
|
|
|
|
|
|
|
class DebugUICalling: DebugUIPage {
|
|
|
|
|
|
|
|
// MARK: Dependencies
|
|
|
|
|
|
|
|
var messageSender: MessageSender {
|
2017-12-04 16:35:47 +01:00
|
|
|
return Environment.current().messageSender
|
2017-08-11 15:13:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: Overrides
|
|
|
|
|
|
|
|
override func name() -> String {
|
|
|
|
return "Calling"
|
|
|
|
}
|
|
|
|
|
|
|
|
override func section(thread aThread: TSThread?) -> OWSTableSection? {
|
|
|
|
guard let thread = aThread as? TSContactThread else {
|
|
|
|
owsFail("Calling is only valid for contact thread, got thread: \(String(describing: aThread))")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
let sectionItems = [
|
2018-03-20 18:02:10 +01:00
|
|
|
OWSTableItem(title: "Send 'hangup' for old call") { [weak self] in
|
|
|
|
guard let strongSelf = self else { return }
|
|
|
|
|
2017-08-11 15:13:54 +02:00
|
|
|
let kFakeCallId = UInt64(12345)
|
|
|
|
let hangupMessage = OWSCallHangupMessage(callId: kFakeCallId)
|
|
|
|
let callMessage = OWSOutgoingCallMessage(thread: thread, hangupMessage: hangupMessage)
|
|
|
|
|
2018-03-20 18:02:10 +01:00
|
|
|
strongSelf.messageSender.sendPromise(message: callMessage).then {
|
|
|
|
Logger.debug("\(strongSelf.logTag) Successfully sent hangup call message to \(thread.contactIdentifier())")
|
2017-08-11 15:13:54 +02:00
|
|
|
}.catch { error in
|
2018-03-20 18:02:10 +01:00
|
|
|
Logger.error("\(strongSelf.logTag) failed to send hangup call message to \(thread.contactIdentifier()) with error: \(error)")
|
2017-08-11 15:13:54 +02:00
|
|
|
}
|
|
|
|
},
|
2018-03-20 18:02:10 +01:00
|
|
|
OWSTableItem(title: "Send 'busy' for old call") { [weak self] in
|
|
|
|
guard let strongSelf = self else { return }
|
|
|
|
|
2017-08-11 15:13:54 +02:00
|
|
|
let kFakeCallId = UInt64(12345)
|
|
|
|
let busyMessage = OWSCallBusyMessage(callId: kFakeCallId)
|
|
|
|
let callMessage = OWSOutgoingCallMessage(thread: thread, busyMessage: busyMessage)
|
|
|
|
|
2018-03-20 18:02:10 +01:00
|
|
|
strongSelf.messageSender.sendPromise(message: callMessage).then {
|
|
|
|
Logger.debug("\(strongSelf.logTag) Successfully sent busy call message to \(thread.contactIdentifier())")
|
2017-08-11 15:13:54 +02:00
|
|
|
}.catch { error in
|
2018-03-20 18:02:10 +01:00
|
|
|
Logger.error("\(strongSelf.logTag) failed to send busy call message to \(thread.contactIdentifier()) with error: \(error)")
|
2017-08-11 15:13:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2018-02-13 02:18:37 +01:00
|
|
|
return OWSTableSection(title: "Call Debug", items: sectionItems)
|
2017-08-11 15:13:54 +02:00
|
|
|
}
|
|
|
|
}
|