diff --git a/AnotherIM/xmpp/XMPPClient.swift b/AnotherIM/xmpp/XMPPClient.swift index f528668..35ba221 100644 --- a/AnotherIM/xmpp/XMPPClient.swift +++ b/AnotherIM/xmpp/XMPPClient.swift @@ -93,7 +93,8 @@ final class XMPPClient { ParserModule(self.fire), SessionModule(), AuthorizationModule(self.storage), - StanzaModule(self.storage) + StanzaModule(self.storage), + DiscoveryModule() ] init(storage: any XMPPClientStorageProtocol, userAgent: UserAgent) { diff --git a/AnotherIM/xmpp/models/Stanza.swift b/AnotherIM/xmpp/models/Stanza.swift index 5ae7200..85a89e3 100644 --- a/AnotherIM/xmpp/models/Stanza.swift +++ b/AnotherIM/xmpp/models/Stanza.swift @@ -1,14 +1,14 @@ import Foundation -enum StanzaType { - enum IqType: String { +enum StanzaType: Codable & Equatable { + enum IqType: String, Codable & Equatable { case get case set case result case error } - enum MessageType: String { + enum MessageType: String, Codable & Equatable { case chat case groupchat case headline @@ -17,7 +17,7 @@ enum StanzaType { case none } - enum PresenceType: String { + enum PresenceType: String, Codable & Equatable { case subscribe case unsubscribe case subscribed diff --git a/AnotherIM/xmpp/modules/disco/DiscoveryModule.swift b/AnotherIM/xmpp/modules/disco/DiscoveryModule.swift new file mode 100644 index 0000000..9253b8c --- /dev/null +++ b/AnotherIM/xmpp/modules/disco/DiscoveryModule.swift @@ -0,0 +1,35 @@ +// XEP-0030 +import Foundation + +// TODO: Implement +final class DiscoveryModule: XmppModule { + let id = "Discovery module" + + private let reqId = "" + + func reduce(oldState: ClientState, with _: Event) -> ClientState { + oldState + } + + func process(state _: ClientState, with _: Event) async -> Event? { + // switch event { + // case .streamReady: + // let req = Stanza.iqGet(payload: XMLElement(name: "query", xmlns: "http://jabber.org/protocol/disco#info", attributes: [:], content: nil, nodes: [])) + // if let req { + // return .stanzaOutbound(req) + // } else { + // return nil + // } + // + // case .stanzaInbound(let stanza): + // if stanza.id == reqId && stanza.type == .iq(.result) { + // print(stanza) + // return nil + // } + // + // default: + // return nil + // } + nil + } +}