mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-07 14:53:35 +00:00
API update
This commit is contained in:
parent
487dd0d9b6
commit
467c08e44c
@ -16,6 +16,8 @@
|
|||||||
0962E66F21B6147600245FD9 /* AppConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E66E21B6147600245FD9 /* AppConfiguration.swift */; };
|
0962E66F21B6147600245FD9 /* AppConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E66E21B6147600245FD9 /* AppConfiguration.swift */; };
|
||||||
0962E67521B6437600245FD9 /* SplitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E67421B6437600245FD9 /* SplitTest.swift */; };
|
0962E67521B6437600245FD9 /* SplitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E67421B6437600245FD9 /* SplitTest.swift */; };
|
||||||
0962E68121BAA20E00245FD9 /* SearchBotsConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */; };
|
0962E68121BAA20E00245FD9 /* SearchBotsConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */; };
|
||||||
|
09EDAD382213120C0012A50B /* AutodownloadSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09EDAD372213120C0012A50B /* AutodownloadSettings.swift */; };
|
||||||
|
09EDAD3A22131D010012A50B /* ManagedAutodownloadSettingsUpdates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09EDAD3922131D010012A50B /* ManagedAutodownloadSettingsUpdates.swift */; };
|
||||||
9F06831021A40DEC001D8EDB /* NotificationExceptionsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */; };
|
9F06831021A40DEC001D8EDB /* NotificationExceptionsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */; };
|
||||||
9F06831121A40DEC001D8EDB /* NotificationExceptionsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */; };
|
9F06831121A40DEC001D8EDB /* NotificationExceptionsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */; };
|
||||||
9F10CE8B20613C78002DD61A /* SecretApiLayer73.swift in Sources */ = {isa = PBXBuildFile; fileRef = D018EDFF2044939F00CBB130 /* SecretApiLayer73.swift */; };
|
9F10CE8B20613C78002DD61A /* SecretApiLayer73.swift in Sources */ = {isa = PBXBuildFile; fileRef = D018EDFF2044939F00CBB130 /* SecretApiLayer73.swift */; };
|
||||||
@ -808,6 +810,8 @@
|
|||||||
0962E66E21B6147600245FD9 /* AppConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfiguration.swift; sourceTree = "<group>"; };
|
0962E66E21B6147600245FD9 /* AppConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfiguration.swift; sourceTree = "<group>"; };
|
||||||
0962E67421B6437600245FD9 /* SplitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitTest.swift; sourceTree = "<group>"; };
|
0962E67421B6437600245FD9 /* SplitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitTest.swift; sourceTree = "<group>"; };
|
||||||
0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBotsConfiguration.swift; sourceTree = "<group>"; };
|
0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBotsConfiguration.swift; sourceTree = "<group>"; };
|
||||||
|
09EDAD372213120C0012A50B /* AutodownloadSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutodownloadSettings.swift; sourceTree = "<group>"; };
|
||||||
|
09EDAD3922131D010012A50B /* ManagedAutodownloadSettingsUpdates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagedAutodownloadSettingsUpdates.swift; sourceTree = "<group>"; };
|
||||||
9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationExceptionsList.swift; sourceTree = "<group>"; };
|
9F06830F21A40DEC001D8EDB /* NotificationExceptionsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationExceptionsList.swift; sourceTree = "<group>"; };
|
||||||
9FC8ADAA206BBFF10094F7B4 /* RecentWebSessions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentWebSessions.swift; sourceTree = "<group>"; };
|
9FC8ADAA206BBFF10094F7B4 /* RecentWebSessions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentWebSessions.swift; sourceTree = "<group>"; };
|
||||||
C205FEA71EB3B75900455808 /* ExportMessageLink.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportMessageLink.swift; sourceTree = "<group>"; };
|
C205FEA71EB3B75900455808 /* ExportMessageLink.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExportMessageLink.swift; sourceTree = "<group>"; };
|
||||||
@ -1280,6 +1284,7 @@
|
|||||||
D051DB13215EC5A300F30F92 /* AppChangelogState.swift */,
|
D051DB13215EC5A300F30F92 /* AppChangelogState.swift */,
|
||||||
0962E66E21B6147600245FD9 /* AppConfiguration.swift */,
|
0962E66E21B6147600245FD9 /* AppConfiguration.swift */,
|
||||||
0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */,
|
0962E68021BAA20E00245FD9 /* SearchBotsConfiguration.swift */,
|
||||||
|
09EDAD372213120C0012A50B /* AutodownloadSettings.swift */,
|
||||||
);
|
);
|
||||||
name = Settings;
|
name = Settings;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1545,6 +1550,7 @@
|
|||||||
0962E66621B59BAA00245FD9 /* ManagedAppConfigurationUpdates.swift */,
|
0962E66621B59BAA00245FD9 /* ManagedAppConfigurationUpdates.swift */,
|
||||||
0962E66821B5A11100245FD9 /* SynchronizeAppLogEventsOperation.swift */,
|
0962E66821B5A11100245FD9 /* SynchronizeAppLogEventsOperation.swift */,
|
||||||
0962E66A21B5A41C00245FD9 /* ManagedSynchronizeAppLogEventsOperations.swift */,
|
0962E66A21B5A41C00245FD9 /* ManagedSynchronizeAppLogEventsOperations.swift */,
|
||||||
|
09EDAD3922131D010012A50B /* ManagedAutodownloadSettingsUpdates.swift */,
|
||||||
);
|
);
|
||||||
name = State;
|
name = State;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2196,6 +2202,7 @@
|
|||||||
D03B0CBD1D62234300955575 /* Regex.swift in Sources */,
|
D03B0CBD1D62234300955575 /* Regex.swift in Sources */,
|
||||||
D00BDA191EE593D600C64C5E /* TelegramChannelAdminRights.swift in Sources */,
|
D00BDA191EE593D600C64C5E /* TelegramChannelAdminRights.swift in Sources */,
|
||||||
D0B843B91DA7FF30005F29E1 /* NBMetadataCoreTest.m in Sources */,
|
D0B843B91DA7FF30005F29E1 /* NBMetadataCoreTest.m in Sources */,
|
||||||
|
09EDAD3A22131D010012A50B /* ManagedAutodownloadSettingsUpdates.swift in Sources */,
|
||||||
D0EA188220D3D2B1001AEE19 /* RemoteStorageConfiguration.swift in Sources */,
|
D0EA188220D3D2B1001AEE19 /* RemoteStorageConfiguration.swift in Sources */,
|
||||||
D018EE002044939F00CBB130 /* SecretApiLayer73.swift in Sources */,
|
D018EE002044939F00CBB130 /* SecretApiLayer73.swift in Sources */,
|
||||||
D09A2FE61D7CD4940018FB72 /* TelegramChannel.swift in Sources */,
|
D09A2FE61D7CD4940018FB72 /* TelegramChannel.swift in Sources */,
|
||||||
@ -2499,6 +2506,7 @@
|
|||||||
D018EE0220458E1E00CBB130 /* SecretChatLayerNegotiation.swift in Sources */,
|
D018EE0220458E1E00CBB130 /* SecretChatLayerNegotiation.swift in Sources */,
|
||||||
D0C48F391E8138DF0075317D /* ArchivedStickerPacksInfo.swift in Sources */,
|
D0C48F391E8138DF0075317D /* ArchivedStickerPacksInfo.swift in Sources */,
|
||||||
C239BE971E62EE1E00C2C453 /* LoadMessagesIfNecessary.swift in Sources */,
|
C239BE971E62EE1E00C2C453 /* LoadMessagesIfNecessary.swift in Sources */,
|
||||||
|
09EDAD382213120C0012A50B /* AutodownloadSettings.swift in Sources */,
|
||||||
D08984F22114B97400918162 /* ClearCloudDrafts.swift in Sources */,
|
D08984F22114B97400918162 /* ClearCloudDrafts.swift in Sources */,
|
||||||
D03B0CC11D62235000955575 /* StringFormat.swift in Sources */,
|
D03B0CC11D62235000955575 /* StringFormat.swift in Sources */,
|
||||||
D0B85AC51F6B2B9400B8B5CE /* RecentlyUsedHashtags.swift in Sources */,
|
D0B85AC51F6B2B9400B8B5CE /* RecentlyUsedHashtags.swift in Sources */,
|
||||||
|
|||||||
@ -1189,6 +1189,7 @@ public class Account {
|
|||||||
self.managedOperationsDisposable.add(managedConfigurationUpdates(accountManager: accountManager, postbox: self.postbox, network: self.network).start())
|
self.managedOperationsDisposable.add(managedConfigurationUpdates(accountManager: accountManager, postbox: self.postbox, network: self.network).start())
|
||||||
self.managedOperationsDisposable.add(managedVoipConfigurationUpdates(postbox: self.postbox, network: self.network).start())
|
self.managedOperationsDisposable.add(managedVoipConfigurationUpdates(postbox: self.postbox, network: self.network).start())
|
||||||
self.managedOperationsDisposable.add(managedAppConfigurationUpdates(postbox: self.postbox, network: self.network).start())
|
self.managedOperationsDisposable.add(managedAppConfigurationUpdates(postbox: self.postbox, network: self.network).start())
|
||||||
|
self.managedOperationsDisposable.add(managedAutodownloadSettingsUpdates(accountManager: accountManager, network: self.network).start())
|
||||||
self.managedOperationsDisposable.add(managedTermsOfServiceUpdates(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
|
self.managedOperationsDisposable.add(managedTermsOfServiceUpdates(postbox: self.postbox, network: self.network, stateManager: self.stateManager).start())
|
||||||
self.managedOperationsDisposable.add(managedAppChangelog(postbox: self.postbox, network: self.network, stateManager: self.stateManager, appVersion: self.networkArguments.appVersion).start())
|
self.managedOperationsDisposable.add(managedAppChangelog(postbox: self.postbox, network: self.network, stateManager: self.stateManager, appVersion: self.networkArguments.appVersion).start())
|
||||||
self.managedOperationsDisposable.add(managedProxyInfoUpdates(postbox: self.postbox, network: self.network, viewTracker: self.viewTracker).start())
|
self.managedOperationsDisposable.add(managedProxyInfoUpdates(postbox: self.postbox, network: self.network, viewTracker: self.viewTracker).start())
|
||||||
|
|||||||
@ -128,6 +128,7 @@ private var declaredEncodables: Void = {
|
|||||||
declareEncodable(AppConfiguration.self, f: { AppConfiguration(decoder: $0) })
|
declareEncodable(AppConfiguration.self, f: { AppConfiguration(decoder: $0) })
|
||||||
declareEncodable(JSON.self, f: { JSON(decoder: $0) })
|
declareEncodable(JSON.self, f: { JSON(decoder: $0) })
|
||||||
declareEncodable(SearchBotsConfiguration.self, f: { SearchBotsConfiguration(decoder: $0) })
|
declareEncodable(SearchBotsConfiguration.self, f: { SearchBotsConfiguration(decoder: $0) })
|
||||||
|
declareEncodable(AutodownloadSettings.self, f: { AutodownloadSettings(decoder: $0 )})
|
||||||
declareEncodable(TelegramMediaPoll.self, f: { TelegramMediaPoll(decoder: $0) })
|
declareEncodable(TelegramMediaPoll.self, f: { TelegramMediaPoll(decoder: $0) })
|
||||||
declareEncodable(TelegramMediaUnsupported.self, f: { TelegramMediaUnsupported(decoder: $0) })
|
declareEncodable(TelegramMediaUnsupported.self, f: { TelegramMediaUnsupported(decoder: $0) })
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) }
|
dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) }
|
||||||
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
|
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
|
||||||
dict[-613092008] = { return Api.ChatInvite.parse_chatInvite($0) }
|
dict[-613092008] = { return Api.ChatInvite.parse_chatInvite($0) }
|
||||||
|
dict[-767099577] = { return Api.AutoDownloadSettings.parse_autoDownloadSettings($0) }
|
||||||
dict[1678812626] = { return Api.StickerSetCovered.parse_stickerSetCovered($0) }
|
dict[1678812626] = { return Api.StickerSetCovered.parse_stickerSetCovered($0) }
|
||||||
dict[872932635] = { return Api.StickerSetCovered.parse_stickerSetMultiCovered($0) }
|
dict[872932635] = { return Api.StickerSetCovered.parse_stickerSetMultiCovered($0) }
|
||||||
dict[1189204285] = { return Api.RecentMeUrl.parse_recentMeUrlUnknown($0) }
|
dict[1189204285] = { return Api.RecentMeUrl.parse_recentMeUrlUnknown($0) }
|
||||||
@ -664,6 +665,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-419832333] = { return Api.PhoneCall.parse_phoneCall($0) }
|
dict[-419832333] = { return Api.PhoneCall.parse_phoneCall($0) }
|
||||||
dict[-483352705] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdateEmpty($0) }
|
dict[-483352705] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdateEmpty($0) }
|
||||||
dict[686618977] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdate($0) }
|
dict[686618977] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdate($0) }
|
||||||
|
dict[1674235686] = { return Api.account.AutoDownloadSettings.parse_autoDownloadSettings($0) }
|
||||||
dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) }
|
dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) }
|
||||||
dict[1599050311] = { return Api.ContactLink.parse_contactLinkUnknown($0) }
|
dict[1599050311] = { return Api.ContactLink.parse_contactLinkUnknown($0) }
|
||||||
dict[-17968211] = { return Api.ContactLink.parse_contactLinkNone($0) }
|
dict[-17968211] = { return Api.ContactLink.parse_contactLinkNone($0) }
|
||||||
@ -814,6 +816,8 @@ struct Api {
|
|||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.ChatInvite:
|
case let _1 as Api.ChatInvite:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
|
case let _1 as Api.AutoDownloadSettings:
|
||||||
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.StickerSetCovered:
|
case let _1 as Api.StickerSetCovered:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.RecentMeUrl:
|
case let _1 as Api.RecentMeUrl:
|
||||||
@ -1222,6 +1226,8 @@ struct Api {
|
|||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.help.TermsOfServiceUpdate:
|
case let _1 as Api.help.TermsOfServiceUpdate:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
|
case let _1 as Api.account.AutoDownloadSettings:
|
||||||
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.DialogPeer:
|
case let _1 as Api.DialogPeer:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.ContactLink:
|
case let _1 as Api.ContactLink:
|
||||||
|
|||||||
@ -1866,6 +1866,52 @@ extension Api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
enum AutoDownloadSettings: TypeConstructorDescription {
|
||||||
|
case autoDownloadSettings(flags: Int32, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32)
|
||||||
|
|
||||||
|
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
|
switch self {
|
||||||
|
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-767099577)
|
||||||
|
}
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
serializeInt32(photoSizeMax, buffer: buffer, boxed: false)
|
||||||
|
serializeInt32(videoSizeMax, buffer: buffer, boxed: false)
|
||||||
|
serializeInt32(fileSizeMax, buffer: buffer, boxed: false)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
|
switch self {
|
||||||
|
case .autoDownloadSettings(let flags, let photoSizeMax, let videoSizeMax, let fileSizeMax):
|
||||||
|
return ("autoDownloadSettings", [("flags", flags), ("photoSizeMax", photoSizeMax), ("videoSizeMax", videoSizeMax), ("fileSizeMax", fileSizeMax)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func parse_autoDownloadSettings(_ reader: BufferReader) -> AutoDownloadSettings? {
|
||||||
|
var _1: Int32?
|
||||||
|
_1 = reader.readInt32()
|
||||||
|
var _2: Int32?
|
||||||
|
_2 = reader.readInt32()
|
||||||
|
var _3: Int32?
|
||||||
|
_3 = reader.readInt32()
|
||||||
|
var _4: Int32?
|
||||||
|
_4 = reader.readInt32()
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
let _c3 = _3 != nil
|
||||||
|
let _c4 = _4 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 {
|
||||||
|
return Api.AutoDownloadSettings.autoDownloadSettings(flags: _1!, photoSizeMax: _2!, videoSizeMax: _3!, fileSizeMax: _4!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
enum StickerSetCovered: TypeConstructorDescription {
|
enum StickerSetCovered: TypeConstructorDescription {
|
||||||
case stickerSetCovered(set: Api.StickerSet, cover: Api.Document)
|
case stickerSetCovered(set: Api.StickerSet, cover: Api.Document)
|
||||||
|
|||||||
@ -858,6 +858,54 @@ struct account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
enum AutoDownloadSettings: TypeConstructorDescription {
|
||||||
|
case autoDownloadSettings(low: Api.AutoDownloadSettings, medium: Api.AutoDownloadSettings, high: Api.AutoDownloadSettings)
|
||||||
|
|
||||||
|
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
|
switch self {
|
||||||
|
case .autoDownloadSettings(let low, let medium, let high):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(1674235686)
|
||||||
|
}
|
||||||
|
low.serialize(buffer, true)
|
||||||
|
medium.serialize(buffer, true)
|
||||||
|
high.serialize(buffer, true)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
|
switch self {
|
||||||
|
case .autoDownloadSettings(let low, let medium, let high):
|
||||||
|
return ("autoDownloadSettings", [("low", low), ("medium", medium), ("high", high)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func parse_autoDownloadSettings(_ reader: BufferReader) -> AutoDownloadSettings? {
|
||||||
|
var _1: Api.AutoDownloadSettings?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_1 = Api.parse(reader, signature: signature) as? Api.AutoDownloadSettings
|
||||||
|
}
|
||||||
|
var _2: Api.AutoDownloadSettings?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_2 = Api.parse(reader, signature: signature) as? Api.AutoDownloadSettings
|
||||||
|
}
|
||||||
|
var _3: Api.AutoDownloadSettings?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_3 = Api.parse(reader, signature: signature) as? Api.AutoDownloadSettings
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
let _c3 = _3 != nil
|
||||||
|
if _c1 && _c2 && _c3 {
|
||||||
|
return Api.account.AutoDownloadSettings.autoDownloadSettings(low: _1!, medium: _2!, high: _3!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extension Api {
|
extension Api {
|
||||||
@ -5167,6 +5215,35 @@ extension Api {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func getAutoDownloadSettings() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.account.AutoDownloadSettings>) {
|
||||||
|
let buffer = Buffer()
|
||||||
|
buffer.appendInt32(1457130303)
|
||||||
|
|
||||||
|
return (FunctionDescription(name: "account.getAutoDownloadSettings", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.AutoDownloadSettings? in
|
||||||
|
let reader = BufferReader(buffer)
|
||||||
|
var result: Api.account.AutoDownloadSettings?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
result = Api.parse(reader, signature: signature) as? Api.account.AutoDownloadSettings
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
static func saveAutoDownloadSettings(flags: Int32, settings: Api.AutoDownloadSettings) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||||
|
let buffer = Buffer()
|
||||||
|
buffer.appendInt32(1995661875)
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
settings.serialize(buffer, true)
|
||||||
|
return (FunctionDescription(name: "account.saveAutoDownloadSettings", parameters: [("flags", flags), ("settings", settings)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||||
|
let reader = BufferReader(buffer)
|
||||||
|
var result: Api.Bool?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
struct langpack {
|
struct langpack {
|
||||||
static func getLangPack(langPack: String, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.LangPackDifference>) {
|
static func getLangPack(langPack: String, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.LangPackDifference>) {
|
||||||
|
|||||||
121
TelegramCore/AutodownloadSettings.swift
Normal file
121
TelegramCore/AutodownloadSettings.swift
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import Foundation
|
||||||
|
#if os(macOS)
|
||||||
|
import PostboxMac
|
||||||
|
import SwiftSignalKitMac
|
||||||
|
#else
|
||||||
|
import Postbox
|
||||||
|
import SwiftSignalKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public enum AutodownloadPreset {
|
||||||
|
case low
|
||||||
|
case medium
|
||||||
|
case high
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AutodownloadPresetSettings: PostboxCoding, Equatable {
|
||||||
|
public let disabled: Bool
|
||||||
|
public let photoSizeMax: Int32
|
||||||
|
public let videoSizeMax: Int32
|
||||||
|
public let fileSizeMax: Int32
|
||||||
|
public let preloadLargeVideo: Bool
|
||||||
|
|
||||||
|
init(disabled: Bool, photoSizeMax: Int32, videoSizeMax: Int32, fileSizeMax: Int32, preloadLargeVideo: Bool) {
|
||||||
|
self.disabled = disabled
|
||||||
|
self.photoSizeMax = photoSizeMax
|
||||||
|
self.videoSizeMax = videoSizeMax
|
||||||
|
self.fileSizeMax = fileSizeMax
|
||||||
|
self.preloadLargeVideo = preloadLargeVideo
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(decoder: PostboxDecoder) {
|
||||||
|
self.disabled = decoder.decodeInt32ForKey("disabled", orElse: 0) != 0
|
||||||
|
self.photoSizeMax = decoder.decodeInt32ForKey("photoSizeMax", orElse: 0)
|
||||||
|
self.videoSizeMax = decoder.decodeInt32ForKey("videoSizeMax", orElse: 0)
|
||||||
|
self.fileSizeMax = decoder.decodeInt32ForKey("fileSizeMax", orElse: 0)
|
||||||
|
self.preloadLargeVideo = decoder.decodeInt32ForKey("preloadLargeVideo", orElse: 0) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
|
encoder.encodeInt32(self.disabled ? 1 : 0, forKey: "disabled")
|
||||||
|
encoder.encodeInt32(self.photoSizeMax, forKey: "photoSizeMax")
|
||||||
|
encoder.encodeInt32(self.videoSizeMax, forKey: "videoSizeMax")
|
||||||
|
encoder.encodeInt32(self.fileSizeMax, forKey: "fileSizeMax")
|
||||||
|
encoder.encodeInt32(self.preloadLargeVideo ? 1 : 0, forKey: "preloadLargeVideo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AutodownloadSettings: PreferencesEntry, Equatable {
|
||||||
|
public let lowPreset: AutodownloadPresetSettings
|
||||||
|
public let mediumPreset: AutodownloadPresetSettings
|
||||||
|
public let highPreset: AutodownloadPresetSettings
|
||||||
|
|
||||||
|
public static var defaultSettings: AutodownloadSettings {
|
||||||
|
return AutodownloadSettings(lowPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 0, fileSizeMax: 0, preloadLargeVideo: false),
|
||||||
|
mediumPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: Int32(2.5 * 1024 * 1024), fileSizeMax: 1 * 1024 * 1024, preloadLargeVideo: false),
|
||||||
|
highPreset: AutodownloadPresetSettings(disabled: false, photoSizeMax: 1 * 1024 * 1024, videoSizeMax: 10 * 1024 * 1024, fileSizeMax: 3 * 1024 * 1024, preloadLargeVideo: false))
|
||||||
|
}
|
||||||
|
|
||||||
|
init(lowPreset: AutodownloadPresetSettings, mediumPreset: AutodownloadPresetSettings, highPreset: AutodownloadPresetSettings) {
|
||||||
|
self.lowPreset = lowPreset
|
||||||
|
self.mediumPreset = mediumPreset
|
||||||
|
self.highPreset = highPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(decoder: PostboxDecoder) {
|
||||||
|
self.lowPreset = decoder.decodeObjectForKey("lowPreset", decoder: AutodownloadPresetSettings.init(decoder:)) as! AutodownloadPresetSettings
|
||||||
|
self.mediumPreset = decoder.decodeObjectForKey("mediumPreset", decoder: AutodownloadPresetSettings.init(decoder:)) as! AutodownloadPresetSettings
|
||||||
|
self.highPreset = decoder.decodeObjectForKey("highPreset", decoder: AutodownloadPresetSettings.init(decoder:)) as! AutodownloadPresetSettings
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
|
encoder.encodeObject(self.lowPreset, forKey: "lowPreset")
|
||||||
|
encoder.encodeObject(self.mediumPreset, forKey: "mediumPreset")
|
||||||
|
encoder.encodeObject(self.highPreset, forKey: "highPreset")
|
||||||
|
}
|
||||||
|
|
||||||
|
public func isEqual(to: PreferencesEntry) -> Bool {
|
||||||
|
if let to = to as? AutodownloadSettings {
|
||||||
|
return self == to
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func ==(lhs: AutodownloadSettings, rhs: AutodownloadSettings) -> Bool {
|
||||||
|
return lhs.lowPreset == rhs.lowPreset && lhs.mediumPreset == rhs.mediumPreset && lhs.highPreset == rhs.highPreset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateAutodownloadSettingsInteractively(accountManager: AccountManager, _ f: @escaping (AutodownloadSettings) -> AutodownloadSettings) -> Signal<Void, NoError> {
|
||||||
|
return accountManager.transaction { transaction -> Void in
|
||||||
|
transaction.updateSharedData(SharedDataKeys.autodownloadSettings, { entry in
|
||||||
|
let currentSettings: AutodownloadSettings
|
||||||
|
if let entry = entry as? AutodownloadSettings {
|
||||||
|
currentSettings = entry
|
||||||
|
} else {
|
||||||
|
currentSettings = AutodownloadSettings.defaultSettings
|
||||||
|
}
|
||||||
|
return f(currentSettings)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AutodownloadPresetSettings {
|
||||||
|
init(apiAutodownloadSettings: Api.AutoDownloadSettings) {
|
||||||
|
switch apiAutodownloadSettings {
|
||||||
|
case let .autoDownloadSettings(flags, photoSizeMax, videoSizeMax, fileSizeMax):
|
||||||
|
self.init(disabled: (flags & (1 << 0)) != 0, photoSizeMax: photoSizeMax, videoSizeMax: videoSizeMax, fileSizeMax: fileSizeMax, preloadLargeVideo: (flags & (1 << 1)) != 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AutodownloadSettings {
|
||||||
|
init(apiAutodownloadSettings: Api.account.AutoDownloadSettings) {
|
||||||
|
switch apiAutodownloadSettings {
|
||||||
|
case let .autoDownloadSettings(low, medium, high):
|
||||||
|
self.init(lowPreset: AutodownloadPresetSettings(apiAutodownloadSettings: low), mediumPreset: AutodownloadPresetSettings(apiAutodownloadSettings: medium), highPreset: AutodownloadPresetSettings(apiAutodownloadSettings: high))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
25
TelegramCore/ManagedAutodownloadSettingsUpdates.swift
Normal file
25
TelegramCore/ManagedAutodownloadSettingsUpdates.swift
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import Foundation
|
||||||
|
#if os(macOS)
|
||||||
|
import PostboxMac
|
||||||
|
import SwiftSignalKitMac
|
||||||
|
import MtProtoKitMac
|
||||||
|
#else
|
||||||
|
import Postbox
|
||||||
|
import SwiftSignalKit
|
||||||
|
import MtProtoKitDynamic
|
||||||
|
#endif
|
||||||
|
|
||||||
|
func managedAutodownloadSettingsUpdates(accountManager: AccountManager, network: Network) -> Signal<Void, NoError> {
|
||||||
|
let poll = Signal<Void, NoError> { subscriber in
|
||||||
|
return (network.request(Api.functions.account.getAutoDownloadSettings())
|
||||||
|
|> retryRequest
|
||||||
|
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||||
|
return accountManager.transaction { transaction -> Void in
|
||||||
|
return updateAutodownloadSettingsInteractively(accountManager: accountManager, { _ -> AutodownloadSettings in
|
||||||
|
return AutodownloadSettings(apiAutodownloadSettings: result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
return (poll |> then(.complete() |> suspendAwareDelay(24.0 * 60.0 * 60.0, queue: Queue.concurrentDefaultQueue()))) |> restart
|
||||||
|
}
|
||||||
@ -244,6 +244,7 @@ private enum SharedDataKeyValues: Int32 {
|
|||||||
case cacheStorageSettings = 2
|
case cacheStorageSettings = 2
|
||||||
case localizationSettings = 3
|
case localizationSettings = 3
|
||||||
case proxySettings = 4
|
case proxySettings = 4
|
||||||
|
case autodownloadSettings = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct SharedDataKeys {
|
public struct SharedDataKeys {
|
||||||
@ -270,6 +271,12 @@ public struct SharedDataKeys {
|
|||||||
key.setInt32(0, value: SharedDataKeyValues.proxySettings.rawValue)
|
key.setInt32(0, value: SharedDataKeyValues.proxySettings.rawValue)
|
||||||
return key
|
return key
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
public static let autodownloadSettings: ValueBoxKey = {
|
||||||
|
let key = ValueBoxKey(length: 4)
|
||||||
|
key.setInt32(0, value: SharedDataKeyValues.autodownloadSettings.rawValue)
|
||||||
|
return key
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func applicationSpecificItemCacheCollectionId(_ value: Int8) -> Int8 {
|
public func applicationSpecificItemCacheCollectionId(_ value: Int8) -> Int8 {
|
||||||
|
|||||||
@ -202,7 +202,7 @@ public class BoxedMessage: NSObject {
|
|||||||
|
|
||||||
public class Serialization: NSObject, MTSerialization {
|
public class Serialization: NSObject, MTSerialization {
|
||||||
public func currentLayer() -> UInt {
|
public func currentLayer() -> UInt {
|
||||||
return 95
|
return 96
|
||||||
}
|
}
|
||||||
|
|
||||||
public func parseMessage(_ data: Data!) -> Any! {
|
public func parseMessage(_ data: Data!) -> Any! {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user