mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
ios: advanced server configuration (#1388)
* ios: advanced server configuration * UI is mostly working, QR code scan * refactor * error alerts * fixes * remove old view * rename view * translations * only show valid QR code, spinner during server test * update tested status on edit * space wtf Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * moar space * translation Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * translations * translations Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7544d2f9e7
commit
7e3d53b621
@@ -89,6 +89,26 @@ struct ParsedMarkdown: Decodable {
|
||||
var formattedText: [FormattedText]?
|
||||
}
|
||||
|
||||
public func parseServerAddress(_ s: String) -> ServerAddress? {
|
||||
var c = s.cString(using: .utf8)!
|
||||
if let cjson = chat_parse_server(&c) {
|
||||
if let d = fromCString(cjson).data(using: .utf8) {
|
||||
do {
|
||||
let r = try jsonDecoder.decode(ParsedServerAddress.self, from: d)
|
||||
return r.serverAddress
|
||||
} catch {
|
||||
logger.error("parseServerAddress jsonDecoder.decode error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
struct ParsedServerAddress: Decodable {
|
||||
var serverAddress: ServerAddress?
|
||||
var parseError: String
|
||||
}
|
||||
|
||||
private func fromCString(_ c: UnsafeMutablePointer<CChar>) -> String {
|
||||
let s = String.init(cString: c)
|
||||
free(c)
|
||||
|
||||
Reference in New Issue
Block a user