mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-24 11:56:18 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
47 lines
1.5 KiB
Swift
47 lines
1.5 KiB
Swift
import Foundation
|
|
|
|
final class DeviceContactImportInfoTable: Table {
|
|
static func tableSpec(_ id: Int32) -> ValueBoxTable {
|
|
return ValueBoxTable(id: id, keyType: .binary, compactValuesOnCreation: true)
|
|
}
|
|
|
|
func get(_ identifier: ValueBoxKey) -> PostboxCoding? {
|
|
if let value = self.valueBox.get(self.table, key: identifier), let object = PostboxDecoder(buffer: value).decodeRootObject() {
|
|
return object
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func set(_ identifier: ValueBoxKey, value: PostboxCoding?) {
|
|
if let value = value {
|
|
let encoder = PostboxEncoder()
|
|
encoder.encodeRootObject(value)
|
|
withExtendedLifetime(encoder, {
|
|
self.valueBox.set(self.table, key: identifier, value: encoder.readBufferNoCopy())
|
|
})
|
|
} else {
|
|
self.valueBox.remove(self.table, key: identifier, secure: false)
|
|
}
|
|
}
|
|
|
|
func getIdentifiers() -> [ValueBoxKey] {
|
|
var result: [ValueBoxKey] = []
|
|
self.valueBox.scan(self.table, keys: { key in
|
|
result.append(key)
|
|
return true
|
|
})
|
|
return result
|
|
}
|
|
|
|
func enumerateDeviceContactImportInfoItems(_ f: (ValueBoxKey, PostboxCoding) -> Bool) {
|
|
self.valueBox.scan(self.table, values: { key, value in
|
|
if let object = PostboxDecoder(buffer: value).decodeRootObject() {
|
|
return f(key, object)
|
|
} else {
|
|
return true
|
|
}
|
|
})
|
|
}
|
|
}
|