40 lines
1,021 B
Swift
40 lines
1,021 B
Swift
import Foundation
|
|
|
|
enum AccountsAvailability {
|
|
case noAccounts
|
|
case allDisabled
|
|
case someEnabled
|
|
}
|
|
|
|
struct Account: Identifiable {
|
|
let id: Int
|
|
let local: String
|
|
let domain: String
|
|
let resource: String
|
|
let isEnabled: Bool
|
|
|
|
var jid: String {
|
|
"\(local)@\(domain)"
|
|
}
|
|
|
|
init?(_ dict: NSDictionary) {
|
|
guard let id = dict.value(forKey: "account_id") as? Int else { return nil }
|
|
guard let local = dict.value(forKey: "username") as? String else { return nil }
|
|
guard let domain = dict.value(forKey: "domain") as? String else { return nil }
|
|
guard let resource = dict.value(forKey: "resource") as? String else { return nil }
|
|
guard let isEnabled = dict.value(forKey: "enabled") as? Bool else { return nil }
|
|
|
|
self.id = id
|
|
self.local = local
|
|
self.domain = domain
|
|
self.resource = resource
|
|
self.isEnabled = isEnabled
|
|
}
|
|
}
|
|
|
|
struct Contact: Identifiable {
|
|
let jid: String
|
|
|
|
var id: String { jid }
|
|
}
|