another.im-ios/AnotherIM/View/StartScreen.swift
2024-12-17 09:34:44 +01:00

98 lines
2.7 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: XMPPStorage {
private var rosterVer: [String: String] = [:]
func getRosterVersion(jid: JID) async -> String? {
rosterVer[jid.bare]
}
func setRosterVersion(jid: JID, ver: String) async {
rosterVer[jid.bare] = ver
}
func getCredentialsByUUID(_ uuid: UUID) async -> Credentials? {
print(uuid)
return ["password": pass]
}
}