92 lines
2.6 KiB
Swift
92 lines
2.6 KiB
Swift
|
import SwiftUI
|
||
|
|
||
|
// let login = "kudahtk@conversations.im"
|
||
|
// let pass = "derevo77!"
|
||
|
|
||
|
// let login = "testmon4@test.anal.company"
|
||
|
// let pass = "12345"
|
||
|
|
||
|
let login = "testmon3@test.anal.company"
|
||
|
let pass = "12345"
|
||
|
|
||
|
struct StartScreen: View {
|
||
|
var body: some View {
|
||
|
ZStack {
|
||
|
Color.Material.Background.light
|
||
|
Image.logo
|
||
|
.resizable()
|
||
|
.aspectRatio(contentMode: .fit)
|
||
|
.frame(width: 200, height: 200)
|
||
|
}
|
||
|
.ignoresSafeArea()
|
||
|
.onAppear {
|
||
|
// doTestA()
|
||
|
doMainTest()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func doMainTest() {
|
||
|
let userAgent = UserAgent(
|
||
|
uuid: "aaa65fa7-5555-4749-d1a5-740edbf81764",
|
||
|
software: "another.im",
|
||
|
device: "iOS"
|
||
|
)
|
||
|
let cls = XMPPClient(storage: TestStorage(), userAgent: userAgent)
|
||
|
|
||
|
// swiftlint:disable:next force_try
|
||
|
let jid = try! JID(login)
|
||
|
cls.tryLogin(jid: jid, credentialsId: UUID())
|
||
|
}
|
||
|
|
||
|
func doTestA() {
|
||
|
let xml = XMLElement(
|
||
|
name: "test-me",
|
||
|
xmlns: "urn:test:me",
|
||
|
attributes: ["some1": "some-val-1", "type": "test-req"],
|
||
|
content: "asdffweqfqefq34234t2tergfsagewr",
|
||
|
nodes: [
|
||
|
XMLElement(
|
||
|
name: "sub-test-me",
|
||
|
xmlns: "urn:test:me",
|
||
|
attributes: ["some1": "some-val-1"],
|
||
|
content: "asdffweqfqefq34234t2tergfsagewr",
|
||
|
nodes: [
|
||
|
XMLElement(
|
||
|
name: "sub2-test-me",
|
||
|
xmlns: "urn:test:me",
|
||
|
attributes: [:],
|
||
|
content: nil,
|
||
|
nodes: []
|
||
|
)
|
||
|
]
|
||
|
)
|
||
|
]
|
||
|
)
|
||
|
print("before")
|
||
|
print(xml, "\n")
|
||
|
print("after:")
|
||
|
let encoded = try? JSONEncoder().encode(xml)
|
||
|
if let encoded {
|
||
|
print(String(decoding: encoded, as: UTF8.self))
|
||
|
let xml2 = try? JSONDecoder().decode(XMLElement.self, from: encoded)
|
||
|
if let xml2 {
|
||
|
print("\n\n\n")
|
||
|
print(xml2)
|
||
|
}
|
||
|
print("after all\n")
|
||
|
print("\(encoded as NSData)")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
final class TestStorage: XMPPClientStorageProtocol {
|
||
|
func updateCredentialsByUUID(_ uuid: UUID, _ credentials: XMPPClientCredentials) async {
|
||
|
print(uuid, credentials)
|
||
|
}
|
||
|
|
||
|
func getCredentialsByUUID(_ uuid: UUID) async -> XMPPClientCredentials? {
|
||
|
print(uuid)
|
||
|
return ["password": pass]
|
||
|
}
|
||
|
}
|