From f5a27b9f3b76eb6afd4d357fbacbb88eeb9c02f7 Mon Sep 17 00:00:00 2001 From: Harry <109690906+harry-signal@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:12:46 -0800 Subject: [PATCH] Flesh out CloudBackupManager sub-components: Recipient handling --- Signal.xcodeproj/project.pbxproj | 132 +- .../CloudBackupAccountDataArchiver.swift | 10 + .../Call/CloudBackupCallArchiver.swift | 10 + .../Chat/CloudBackupChatArchiver.swift | 10 + .../CloudBackupChatItemArchiver.swift | 10 + .../Archivers/CloudBackupProtoArchiver.swift | 93 + .../CloudBackupContactRecipientArchiver.swift | 209 ++ .../CloudBackupGroupRecipientArchiver.swift | 185 + ...oudBackupNoteToSelfRecipientArchiver.swift | 53 + .../CloudBackupRecipientArchiver.swift | 135 + ...udBackupRecipientDestinationArchiver.swift | 19 + .../Recipient/RecipientContexts.swift | 108 + .../CloudBackup/Archivers/SharedMap.swift | 36 + .../CloudBackupStickerPackArchiver.swift | 10 + .../CloudBackupManager+Shims.swift | 2 + .../CloudBackup/CloudBackupManagerImpl.swift | 626 ++-- .../CloudBackupProtoFileStreams.swift | 233 -- .../CloudBackupProtoInputStream.swift | 112 + .../CloudBackupProtoOutputStream.swift | 101 + .../CloudBackupProtoStreamProvider.swift | 110 + .../Dependencies/DependenciesBridge.swift | 18 +- SignalServiceKit/protobuf/Backup.proto | 377 +- .../src/Protos/Generated/Backup.pb.swift | 3247 ++++++++--------- .../src/Protos/Generated/BackupProto.swift | 2503 +++++++------ 24 files changed, 4724 insertions(+), 3625 deletions(-) create mode 100644 SignalServiceKit/CloudBackup/Archivers/AccountData/CloudBackupAccountDataArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Call/CloudBackupCallArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Chat/CloudBackupChatArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/ChatItem/CloudBackupChatItemArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/CloudBackupProtoArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupContactRecipientArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupGroupRecipientArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupNoteToSelfRecipientArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientDestinationArchiver.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/Recipient/RecipientContexts.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/SharedMap.swift create mode 100644 SignalServiceKit/CloudBackup/Archivers/StickerPack/CloudBackupStickerPackArchiver.swift delete mode 100644 SignalServiceKit/CloudBackup/CloudBackupProtoFileStreams.swift create mode 100644 SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoInputStream.swift create mode 100644 SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoOutputStream.swift create mode 100644 SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoStreamProvider.swift diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 8422a97363f..8e7d505604c 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -861,7 +861,7 @@ 665C0D5C2ADF538100539A37 /* CloudBackupManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D5B2ADF538100539A37 /* CloudBackupManager.swift */; }; 665C0D5E2ADF53E200539A37 /* CloudBackupManagerImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D5D2ADF53E200539A37 /* CloudBackupManagerImpl.swift */; }; 665C0D602ADF57D000539A37 /* CloudBackupManager+Shims.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D5F2ADF57D000539A37 /* CloudBackupManager+Shims.swift */; }; - 665C0D622AE0552900539A37 /* CloudBackupProtoFileStreams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D612AE0552900539A37 /* CloudBackupProtoFileStreams.swift */; }; + 665C0D622AE0552900539A37 /* CloudBackupProtoStreamProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D612AE0552900539A37 /* CloudBackupProtoStreamProvider.swift */; }; 665C0D6C2AE0776700539A37 /* Backup.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D6B2AE0776700539A37 /* Backup.pb.swift */; }; 665C0D6E2AE07A8A00539A37 /* BackupProto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665C0D6D2AE07A8A00539A37 /* BackupProto.swift */; }; 665EF86D290C385B00F490D2 /* OWSNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 665EF86C290C385B00F490D2 /* OWSNavigationController.swift */; }; @@ -936,6 +936,21 @@ 66C2B1562A1400E8008DDE72 /* SVR2WebsocketConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C2B1552A1400E8008DDE72 /* SVR2WebsocketConfigurator.swift */; }; 66C336D12A994B97000F4F50 /* FailedStorySendDisplayController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C336D02A994B97000F4F50 /* FailedStorySendDisplayController.swift */; }; 66C3887E29CA537400E6DC00 /* RegistrationTransferProgressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66C3887D29CA537400E6DC00 /* RegistrationTransferProgressViewController.swift */; }; + 66CD25592B0685E000139E17 /* CloudBackupProtoArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25582B0685E000139E17 /* CloudBackupProtoArchiver.swift */; }; + 66CD25622B06948900139E17 /* CloudBackupRecipientArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25612B06948900139E17 /* CloudBackupRecipientArchiver.swift */; }; + 66CD25642B06949C00139E17 /* CloudBackupAccountDataArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25632B06949C00139E17 /* CloudBackupAccountDataArchiver.swift */; }; + 66CD25662B0695F400139E17 /* CloudBackupChatArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25652B0695F400139E17 /* CloudBackupChatArchiver.swift */; }; + 66CD25682B06960F00139E17 /* CloudBackupChatItemArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25672B06960F00139E17 /* CloudBackupChatItemArchiver.swift */; }; + 66CD256A2B06963200139E17 /* CloudBackupStickerPackArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25692B06963200139E17 /* CloudBackupStickerPackArchiver.swift */; }; + 66CD256C2B06967900139E17 /* CloudBackupCallArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD256B2B06967900139E17 /* CloudBackupCallArchiver.swift */; }; + 66CD256E2B06E14F00139E17 /* CloudBackupContactRecipientArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD256D2B06E14F00139E17 /* CloudBackupContactRecipientArchiver.swift */; }; + 66CD25702B06E29B00139E17 /* CloudBackupRecipientDestinationArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD256F2B06E29B00139E17 /* CloudBackupRecipientDestinationArchiver.swift */; }; + 66CD25722B07EE3A00139E17 /* SharedMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25712B07EE3A00139E17 /* SharedMap.swift */; }; + 66CD25752B0807BC00139E17 /* CloudBackupProtoInputStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25742B0807BC00139E17 /* CloudBackupProtoInputStream.swift */; }; + 66CD25772B0807C700139E17 /* CloudBackupProtoOutputStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25762B0807C700139E17 /* CloudBackupProtoOutputStream.swift */; }; + 66CD25792B0832A400139E17 /* CloudBackupNoteToSelfRecipientArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD25782B0832A400139E17 /* CloudBackupNoteToSelfRecipientArchiver.swift */; }; + 66CD257B2B08374600139E17 /* CloudBackupGroupRecipientArchiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD257A2B08374600139E17 /* CloudBackupGroupRecipientArchiver.swift */; }; + 66CD257D2B0C1DAA00139E17 /* RecipientContexts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CD257C2B0C1DAA00139E17 /* RecipientContexts.swift */; }; 66CDB7522AF9D117009A36EC /* MessageFetchBGRefreshTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CDB7512AF9D117009A36EC /* MessageFetchBGRefreshTask.swift */; }; 66CDB7552AFC3F1F009A36EC /* ProvisioningCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CDB7542AFC3F1F009A36EC /* ProvisioningCoordinator.swift */; }; 66CDB7572AFC40BE009A36EC /* ProvisioningCoordinatorImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66CDB7562AFC40BE009A36EC /* ProvisioningCoordinatorImpl.swift */; }; @@ -3460,7 +3475,7 @@ 665C0D5B2ADF538100539A37 /* CloudBackupManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupManager.swift; sourceTree = ""; }; 665C0D5D2ADF53E200539A37 /* CloudBackupManagerImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupManagerImpl.swift; sourceTree = ""; }; 665C0D5F2ADF57D000539A37 /* CloudBackupManager+Shims.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CloudBackupManager+Shims.swift"; sourceTree = ""; }; - 665C0D612AE0552900539A37 /* CloudBackupProtoFileStreams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupProtoFileStreams.swift; sourceTree = ""; }; + 665C0D612AE0552900539A37 /* CloudBackupProtoStreamProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupProtoStreamProvider.swift; sourceTree = ""; }; 665C0D6B2AE0776700539A37 /* Backup.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Backup.pb.swift; sourceTree = ""; }; 665C0D6D2AE07A8A00539A37 /* BackupProto.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackupProto.swift; sourceTree = ""; }; 665EF86C290C385B00F490D2 /* OWSNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OWSNavigationController.swift; sourceTree = ""; }; @@ -3537,6 +3552,21 @@ 66C2B1552A1400E8008DDE72 /* SVR2WebsocketConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SVR2WebsocketConfigurator.swift; sourceTree = ""; }; 66C336D02A994B97000F4F50 /* FailedStorySendDisplayController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FailedStorySendDisplayController.swift; sourceTree = ""; }; 66C3887D29CA537400E6DC00 /* RegistrationTransferProgressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistrationTransferProgressViewController.swift; sourceTree = ""; }; + 66CD25582B0685E000139E17 /* CloudBackupProtoArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupProtoArchiver.swift; sourceTree = ""; }; + 66CD25612B06948900139E17 /* CloudBackupRecipientArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupRecipientArchiver.swift; sourceTree = ""; }; + 66CD25632B06949C00139E17 /* CloudBackupAccountDataArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupAccountDataArchiver.swift; sourceTree = ""; }; + 66CD25652B0695F400139E17 /* CloudBackupChatArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupChatArchiver.swift; sourceTree = ""; }; + 66CD25672B06960F00139E17 /* CloudBackupChatItemArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupChatItemArchiver.swift; sourceTree = ""; }; + 66CD25692B06963200139E17 /* CloudBackupStickerPackArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupStickerPackArchiver.swift; sourceTree = ""; }; + 66CD256B2B06967900139E17 /* CloudBackupCallArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupCallArchiver.swift; sourceTree = ""; }; + 66CD256D2B06E14F00139E17 /* CloudBackupContactRecipientArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupContactRecipientArchiver.swift; sourceTree = ""; }; + 66CD256F2B06E29B00139E17 /* CloudBackupRecipientDestinationArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupRecipientDestinationArchiver.swift; sourceTree = ""; }; + 66CD25712B07EE3A00139E17 /* SharedMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedMap.swift; sourceTree = ""; }; + 66CD25742B0807BC00139E17 /* CloudBackupProtoInputStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupProtoInputStream.swift; sourceTree = ""; }; + 66CD25762B0807C700139E17 /* CloudBackupProtoOutputStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupProtoOutputStream.swift; sourceTree = ""; }; + 66CD25782B0832A400139E17 /* CloudBackupNoteToSelfRecipientArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupNoteToSelfRecipientArchiver.swift; sourceTree = ""; }; + 66CD257A2B08374600139E17 /* CloudBackupGroupRecipientArchiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudBackupGroupRecipientArchiver.swift; sourceTree = ""; }; + 66CD257C2B0C1DAA00139E17 /* RecipientContexts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipientContexts.swift; sourceTree = ""; }; 66CDB7512AF9D117009A36EC /* MessageFetchBGRefreshTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageFetchBGRefreshTask.swift; sourceTree = ""; }; 66CDB7542AFC3F1F009A36EC /* ProvisioningCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProvisioningCoordinator.swift; sourceTree = ""; }; 66CDB7562AFC40BE009A36EC /* ProvisioningCoordinatorImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProvisioningCoordinatorImpl.swift; sourceTree = ""; }; @@ -6971,10 +7001,11 @@ 665C0D5A2ADF537000539A37 /* CloudBackup */ = { isa = PBXGroup; children = ( + 66CD25572B0685CF00139E17 /* Archivers */, + 66CD25732B08079C00139E17 /* FileStreams */, 665C0D5F2ADF57D000539A37 /* CloudBackupManager+Shims.swift */, 665C0D5B2ADF538100539A37 /* CloudBackupManager.swift */, 665C0D5D2ADF53E200539A37 /* CloudBackupManagerImpl.swift */, - 665C0D612AE0552900539A37 /* CloudBackupProtoFileStreams.swift */, ); path = CloudBackup; sourceTree = ""; @@ -7150,6 +7181,84 @@ path = Stories; sourceTree = ""; }; + 66CD25572B0685CF00139E17 /* Archivers */ = { + isa = PBXGroup; + children = ( + 66CD255B2B06885400139E17 /* AccountData */, + 66CD25602B0688DB00139E17 /* Call */, + 66CD255C2B06885F00139E17 /* Chat */, + 66CD255D2B06886800139E17 /* ChatItem */, + 66CD255A2B06884700139E17 /* Recipient */, + 66CD255F2B06888800139E17 /* StickerPack */, + 66CD25582B0685E000139E17 /* CloudBackupProtoArchiver.swift */, + 66CD25712B07EE3A00139E17 /* SharedMap.swift */, + ); + path = Archivers; + sourceTree = ""; + }; + 66CD255A2B06884700139E17 /* Recipient */ = { + isa = PBXGroup; + children = ( + 66CD256D2B06E14F00139E17 /* CloudBackupContactRecipientArchiver.swift */, + 66CD257A2B08374600139E17 /* CloudBackupGroupRecipientArchiver.swift */, + 66CD25782B0832A400139E17 /* CloudBackupNoteToSelfRecipientArchiver.swift */, + 66CD25612B06948900139E17 /* CloudBackupRecipientArchiver.swift */, + 66CD256F2B06E29B00139E17 /* CloudBackupRecipientDestinationArchiver.swift */, + 66CD257C2B0C1DAA00139E17 /* RecipientContexts.swift */, + ); + path = Recipient; + sourceTree = ""; + }; + 66CD255B2B06885400139E17 /* AccountData */ = { + isa = PBXGroup; + children = ( + 66CD25632B06949C00139E17 /* CloudBackupAccountDataArchiver.swift */, + ); + path = AccountData; + sourceTree = ""; + }; + 66CD255C2B06885F00139E17 /* Chat */ = { + isa = PBXGroup; + children = ( + 66CD25652B0695F400139E17 /* CloudBackupChatArchiver.swift */, + ); + path = Chat; + sourceTree = ""; + }; + 66CD255D2B06886800139E17 /* ChatItem */ = { + isa = PBXGroup; + children = ( + 66CD25672B06960F00139E17 /* CloudBackupChatItemArchiver.swift */, + ); + path = ChatItem; + sourceTree = ""; + }; + 66CD255F2B06888800139E17 /* StickerPack */ = { + isa = PBXGroup; + children = ( + 66CD25692B06963200139E17 /* CloudBackupStickerPackArchiver.swift */, + ); + path = StickerPack; + sourceTree = ""; + }; + 66CD25602B0688DB00139E17 /* Call */ = { + isa = PBXGroup; + children = ( + 66CD256B2B06967900139E17 /* CloudBackupCallArchiver.swift */, + ); + path = Call; + sourceTree = ""; + }; + 66CD25732B08079C00139E17 /* FileStreams */ = { + isa = PBXGroup; + children = ( + 66CD25742B0807BC00139E17 /* CloudBackupProtoInputStream.swift */, + 66CD25762B0807C700139E17 /* CloudBackupProtoOutputStream.swift */, + 665C0D612AE0552900539A37 /* CloudBackupProtoStreamProvider.swift */, + ); + path = FileStreams; + sourceTree = ""; + }; 66CDB7532AFC3EFB009A36EC /* Provisioning */ = { isa = PBXGroup; children = ( @@ -12495,10 +12604,23 @@ 500AEE072A4DF48700371F05 /* ChatColorSettingStore.swift in Sources */, 664160D029A6D60A00F5BA85 /* ChatServiceAuth.swift in Sources */, F9C5CCF2289453B300548EEE /* ChunkedInputStream.swift in Sources */, + 66CD25642B06949C00139E17 /* CloudBackupAccountDataArchiver.swift in Sources */, + 66CD256C2B06967900139E17 /* CloudBackupCallArchiver.swift in Sources */, + 66CD25662B0695F400139E17 /* CloudBackupChatArchiver.swift in Sources */, + 66CD25682B06960F00139E17 /* CloudBackupChatItemArchiver.swift in Sources */, + 66CD256E2B06E14F00139E17 /* CloudBackupContactRecipientArchiver.swift in Sources */, + 66CD257B2B08374600139E17 /* CloudBackupGroupRecipientArchiver.swift in Sources */, 665C0D602ADF57D000539A37 /* CloudBackupManager+Shims.swift in Sources */, 665C0D5C2ADF538100539A37 /* CloudBackupManager.swift in Sources */, 665C0D5E2ADF53E200539A37 /* CloudBackupManagerImpl.swift in Sources */, - 665C0D622AE0552900539A37 /* CloudBackupProtoFileStreams.swift in Sources */, + 66CD25792B0832A400139E17 /* CloudBackupNoteToSelfRecipientArchiver.swift in Sources */, + 66CD25592B0685E000139E17 /* CloudBackupProtoArchiver.swift in Sources */, + 66CD25752B0807BC00139E17 /* CloudBackupProtoInputStream.swift in Sources */, + 66CD25772B0807C700139E17 /* CloudBackupProtoOutputStream.swift in Sources */, + 665C0D622AE0552900539A37 /* CloudBackupProtoStreamProvider.swift in Sources */, + 66CD25622B06948900139E17 /* CloudBackupRecipientArchiver.swift in Sources */, + 66CD25702B06E29B00139E17 /* CloudBackupRecipientDestinationArchiver.swift in Sources */, + 66CD256A2B06963200139E17 /* CloudBackupStickerPackArchiver.swift in Sources */, F9C5CDFC289453B400548EEE /* Collection+OWS.swift in Sources */, F9C5CCE5289453B300548EEE /* Contact+Swift.swift in Sources */, F9C5CCB5289453B300548EEE /* Contact.m in Sources */, @@ -12917,6 +13039,7 @@ F9C5CC3C289453B300548EEE /* ReactionFinder.swift in Sources */, F9C5CC3D289453B300548EEE /* ReactionManager.swift in Sources */, F9C5CE14289453B400548EEE /* ReadyFlag.swift in Sources */, + 66CD257D2B0C1DAA00139E17 /* RecipientContexts.swift in Sources */, 506695E529C29C2F00B6D8D0 /* RecipientDatabaseTable.swift in Sources */, 50AA3EC329F1C4B900EC50A3 /* RecipientFetcher.swift in Sources */, 66D13F0A2A731E590092D47B /* RecipientHidingManager+SignalServiceAddress.swift in Sources */, @@ -12985,6 +13108,7 @@ 66C2B14D2A13E2C7008DDE72 /* SgxWebsocketConfigurator.swift in Sources */, 66C2B14B2A13E2AC008DDE72 /* SgxWebsocketConnection.swift in Sources */, 66C2B1492A13E2A0008DDE72 /* SgxWebsocketConnectionFactory.swift in Sources */, + 66CD25722B07EE3A00139E17 /* SharedMap.swift in Sources */, F9C5CCC5289453B300548EEE /* SignalAccount.swift in Sources */, F9C5CCDD289453B300548EEE /* SignalAccountFinder.swift in Sources */, 50EF8DD52A1FE55D00A00935 /* SignalAccountMergeObserver.swift in Sources */, diff --git a/SignalServiceKit/CloudBackup/Archivers/AccountData/CloudBackupAccountDataArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/AccountData/CloudBackupAccountDataArchiver.swift new file mode 100644 index 00000000000..b40cba814c0 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/AccountData/CloudBackupAccountDataArchiver.swift @@ -0,0 +1,10 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +public protocol CloudBackupAccountDataArchiver: CloudBackupProtoArchiver { + +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Call/CloudBackupCallArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Call/CloudBackupCallArchiver.swift new file mode 100644 index 00000000000..1a2b9e3db29 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Call/CloudBackupCallArchiver.swift @@ -0,0 +1,10 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +public protocol CloudBackupCallArchiver: CloudBackupProtoArchiver { + +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Chat/CloudBackupChatArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Chat/CloudBackupChatArchiver.swift new file mode 100644 index 00000000000..651f95dd8b4 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Chat/CloudBackupChatArchiver.swift @@ -0,0 +1,10 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +public protocol CloudBackupChatArchiver: CloudBackupProtoArchiver { + +} diff --git a/SignalServiceKit/CloudBackup/Archivers/ChatItem/CloudBackupChatItemArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/ChatItem/CloudBackupChatItemArchiver.swift new file mode 100644 index 00000000000..0ad4e030191 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/ChatItem/CloudBackupChatItemArchiver.swift @@ -0,0 +1,10 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +public protocol CloudBackupChatItemArchiver: CloudBackupProtoArchiver { + +} diff --git a/SignalServiceKit/CloudBackup/Archivers/CloudBackupProtoArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/CloudBackupProtoArchiver.swift new file mode 100644 index 00000000000..ba5aeabd548 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/CloudBackupProtoArchiver.swift @@ -0,0 +1,93 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +extension CloudBackup { + public enum ArchiveFrameError: Error { + case protoSerializationError(Error) + case fileIOError(Error) + + /// An error generating the master key for a group, causing the group to be skipped. + case groupMasterKeyError(Error) + } + + /// Note the plural; covers the archiving of multiple frames, typically + /// batched by type. + public enum ArchiveFramesResult { + public struct Error { + public let objectId: AppIdType + public let error: ArchiveFrameError + } + + case success + /// We managed to write some frames, but failed for others. + /// Note that some errors _may_ be terminal; the caller should check. + case partialSuccess([Error]) + /// Catastrophic failure, e.g. we failed to read from the database at all + /// for an entire category of frame. + case completeFailure(Swift.Error) + } + + public enum RestoringFrameError: Error { + case identifierNotFound + /// The proto contained invalid or self-contradictory data, e.g an invalid ACI. + case invalidProtoData + case databaseInsertionFailed(Error) + /// The contents of the frame are not recognized by any archiver and were ignored. + case unknownFrameType + } + + public enum RestoreFrameResult { + case success + case failure(ProtoIdType, RestoringFrameError) + } +} + +public protocol CloudBackupProtoArchiver { + +} + +extension CloudBackupProtoArchiver { + + /** + * Helper function to build a frame and write the proto to the backup file in one action + * with standard error handling. + * + * WARNING: any errors thrown in the ``frameBuilder`` function will become + * ``CloudBackup.ArchiveFrameError.protoSerializationError``s. The closure + * should only be used to build the frame proto and any sub protos, and not to capture errors encountered + * reading the information required to build the proto. + */ + internal static func writeFrameToStream( + _ stream: CloudBackupProtoOutputStream, + frameBuilder: (BackupProtoFrameBuilder) throws -> BackupProtoFrame + ) -> CloudBackup.ArchiveFrameError? { + let frame: BackupProtoFrame + do { + frame = try frameBuilder(BackupProtoFrame.builder()) + } catch { + return .protoSerializationError(error) + } + switch stream.writeFrame(frame) { + case .success: + return nil + case .fileIOError(let error): + return .fileIOError(error) + case .protoSerializationError(let error): + return .protoSerializationError(error) + } + } +} + +extension CloudBackup.ArchiveFrameError { + + func asArchiveFramesError( + objectId: AppIdType + ) -> CloudBackup.ArchiveFramesResult.Error { + return .init(objectId: objectId, error: self) + } + +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupContactRecipientArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupContactRecipientArchiver.swift new file mode 100644 index 00000000000..c8daad80830 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupContactRecipientArchiver.swift @@ -0,0 +1,209 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation +import LibSignalClient + +/** + * Archives a contact (``SignalRecipient``) as a ``BackupProtoContact``, which is a type of + * ``BackupProtoRecipient``. + */ +public class CloudBackupContactRecipientArchiver: CloudBackupRecipientDestinationArchiver { + + private let blockingManager: CloudBackup.Shims.BlockingManager + private let profileManager: CloudBackup.Shims.ProfileManager + private let recipientHidingManager: RecipientHidingManager + private let signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher + private let storyFinder: CloudBackup.Shims.StoryFinder + private let tsAccountManager: TSAccountManager + + public init( + blockingManager: CloudBackup.Shims.BlockingManager, + profileManager: CloudBackup.Shims.ProfileManager, + recipientHidingManager: RecipientHidingManager, + signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher, + storyFinder: CloudBackup.Shims.StoryFinder, + tsAccountManager: TSAccountManager + ) { + self.blockingManager = blockingManager + self.profileManager = profileManager + self.recipientHidingManager = recipientHidingManager + self.signalRecipientFetcher = signalRecipientFetcher + self.storyFinder = storyFinder + self.tsAccountManager = tsAccountManager + } + + private typealias ArchivingAddress = CloudBackup.RecipientArchivingContext.Address + + public func archiveRecipients( + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + tx: DBReadTransaction + ) -> ArchiveFramesResult { + let whitelistedAddresses = Set(profileManager.allWhitelistedRegisteredAddresses(tx: tx)) + let blockedAddresses = blockingManager.blockedAddresses(tx: tx) + + var errors = [ArchiveFramesResult.Error]() + + signalRecipientFetcher.enumerateAll(tx: tx) { recipient in + let recipientAddress: ArchivingAddress + if let aci = recipient.aci { + recipientAddress = .contactAci(aci) + } else if let pni = recipient.pni { + recipientAddress = .contactPni(pni) + } else if let e164 = E164(recipient.phoneNumber) { + recipientAddress = .contactE164(e164) + } else { + // Skip but don't add to the list of errors. + Logger.warn("Skipping empty recipient") + return + } + + let recipientId = context.assignRecipientId(to: recipientAddress) + + let recipientBuilder = BackupProtoRecipient.builder( + id: recipientId.value + ) + + var unregisteredAtTimestamp: UInt64 = 0 + if !recipient.isRegistered { + unregisteredAtTimestamp = ( + recipient.unregisteredAtTimestamp ?? SignalRecipient.Constants.distantPastUnregisteredTimestamp + ) + } + + // TODO: instead of doing per-recipient fetches, we should bulk load + // some of these fetched fields into memory to avoid db round trips. + let contactBuilder = BackupProtoContact.builder( + blocked: blockedAddresses.contains(recipient.address), + hidden: self.recipientHidingManager.isHiddenRecipient(recipient, tx: tx), + unregisteredTimestamp: unregisteredAtTimestamp, + profileSharing: whitelistedAddresses.contains(recipient.address), + hideStory: recipient.aci.map { self.storyFinder.isStoryHidden(forAci: $0, tx: tx) ?? false } ?? false + ) + + contactBuilder.setRegistered(recipient.isRegistered ? .registered : .notRegistered) + + recipient.aci.map(\.rawUUID.data).map(contactBuilder.setAci) + recipient.pni.map(\.rawUUID.data).map(contactBuilder.setPni) + recipient.address.e164.map(\.uint64Value).map(contactBuilder.setE164) + // TODO: username? + + let profile = self.profileManager.getUserProfile(for: recipient.address, tx: tx) + profile?.profileKey.map(\.keyData).map(contactBuilder.setProfileKey(_:)) + profile?.unfilteredGivenName.map(contactBuilder.setProfileGivenName(_:)) + profile?.unfilteredFamilyName.map(contactBuilder.setProfileFamilyName(_:)) + // TODO: joined name? + + Self.writeFrameToStream(stream, frameBuilder: { frameBuilder in + let contact = try contactBuilder.build() + recipientBuilder.setContact(contact) + let protoRecipient = try recipientBuilder.build() + frameBuilder.setRecipient(protoRecipient) + return try frameBuilder.build() + }).map { errors.append($0.asArchiveFramesError(objectId: recipientId)) } + } + + if errors.isEmpty { + return .success + } else { + return .partialSuccess(errors) + } + } + + static func canRestore(_ recipient: BackupProtoRecipient) -> Bool { + return recipient.contact != nil + } + + public func restore( + _ recipientProto: BackupProtoRecipient, + context: CloudBackup.RecipientRestoringContext, + tx: DBWriteTransaction + ) -> RestoreFrameResult { + guard let contactProto = recipientProto.contact else { + owsFail("Invalid proto for class") + } + + let isRegistered: Bool? + let unregisteredTimestamp: UInt64? + switch contactProto.registered { + case .none, .unknown: + isRegistered = nil + unregisteredTimestamp = nil + case .registered: + isRegistered = true + unregisteredTimestamp = nil + case .notRegistered: + isRegistered = false + unregisteredTimestamp = contactProto.unregisteredTimestamp + } + + let aci: Aci? = contactProto.aci.map(UUID.from(data:))?.map(\.0).map(Aci.init(fromUUID:)) + let pni: Pni? = contactProto.pni.map(UUID.from(data:))?.map(\.0).map(Pni.init(fromUUID:)) + let e164: E164? = E164(contactProto.e164) + guard aci != nil || pni != nil || e164 != nil else { + // Need at least one identifier! + return .failure(recipientProto.recipientId, .invalidProtoData) + } + context[recipientProto.recipientId] = .contact(aci: aci, pni: pni, e164: e164) + + // TODO: make this a real method. + var recipient = SignalRecipient.proofOfConcept_forBackup( + aci: aci, + pni: pni, + phoneNumber: e164, + isRegistered: isRegistered, + unregisteredAtTimestamp: unregisteredTimestamp + ) + + // TODO: remove this check; we should be starting with an empty database. + if let existingRecipient = signalRecipientFetcher.recipient(for: recipient.address, tx: tx) { + recipient = existingRecipient + if isRegistered == true, !recipient.isRegistered { + signalRecipientFetcher.markAsRegisteredAndSave(recipient, tx: tx) + } else if isRegistered == false, recipient.isRegistered, let unregisteredTimestamp { + signalRecipientFetcher.markAsUnregisteredAndSave(recipient, at: unregisteredTimestamp, tx: tx) + } + } else { + do { + try signalRecipientFetcher.insert(recipient, tx: tx) + } catch let error { + return .failure(recipientProto.recipientId, .databaseInsertionFailed(error)) + } + } + + if contactProto.profileSharing { + // Add to the whitelist. + profileManager.addToWhitelist(recipient.address, tx: tx) + } + + if contactProto.blocked { + blockingManager.addBlockedAddress(recipient.address, tx: tx) + } + + if contactProto.hidden { + do { + try recipientHidingManager.addHiddenRecipient(recipient, wasLocallyInitiated: false, tx: tx) + } catch let error { + return .failure(recipientProto.recipientId, .databaseInsertionFailed(error)) + } + } + + if contactProto.hideStory, let aci { + let storyContext = storyFinder.getOrCreateStoryContextAssociatedData(for: aci, tx: tx) + storyFinder.setStoryContextHidden(storyContext, tx: tx) + } + + profileManager.setProfileGivenName( + givenName: contactProto.profileGivenName, + familyName: contactProto.profileFamilyName, + profileKey: contactProto.profileKey, + address: recipient.address, + tx: tx + ) + + return .success + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupGroupRecipientArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupGroupRecipientArchiver.swift new file mode 100644 index 00000000000..8a536c6ee16 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupGroupRecipientArchiver.swift @@ -0,0 +1,185 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation +import LibSignalClient + +/** + * Archives a group (``TSGroupThread``) as a ``BackupProtoGroup``, which is a type of + * ``BackupProtoRecipient``. + * + * This is a bit confusing, because ``TSThread`` mostly corresponds to ``BackupProtoChat``, + * and there will in fact _also_ be a ``BackupProtoChat`` for the group thread. Its just that our + * ``TSGroupThread`` contains all the metadata from both the Chat and Recipient representations + * in the proto. + */ +public class CloudBackupGroupRecipientArchiver: CloudBackupRecipientDestinationArchiver { + + private let groupsV2: GroupsV2 + private let profileManager: CloudBackup.Shims.ProfileManager + private let storyFinder: CloudBackup.Shims.StoryFinder + private let tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher + + public init( + groupsV2: GroupsV2, + profileManager: CloudBackup.Shims.ProfileManager, + storyFinder: CloudBackup.Shims.StoryFinder, + tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher + ) { + self.groupsV2 = groupsV2 + self.profileManager = profileManager + self.storyFinder = storyFinder + self.tsThreadFetcher = tsThreadFetcher + } + + private typealias GroupId = CloudBackup.RecipientArchivingContext.Address.GroupId + + public func archiveRecipients( + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + tx: DBReadTransaction + ) -> ArchiveFramesResult { + var errors = [ArchiveFramesResult.Error]() + + do { + try tsThreadFetcher.enumerateAllGroupThreads(tx: tx) { groupThread in + self.archiveGroupThread( + groupThread, + stream: stream, + context: context, + errors: &errors, + tx: tx + ) + } + } catch { + // The enumeration of threads failed, not the processing of one single thread. + return .completeFailure(error) + } + + if errors.isEmpty { + return .success + } else { + return .partialSuccess(errors) + } + } + + private func archiveGroupThread( + _ groupThread: TSGroupThread, + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + errors: inout [ArchiveFramesResult.Error], + tx: DBReadTransaction + ) { + guard + groupThread.isGroupV2Thread, + let groupsV2Model = groupThread.groupModel as? TSGroupModelV2 + else { + return + } + + let groupId: GroupId = groupThread.groupId + let recipientId = context.assignRecipientId(to: .group(groupId)) + + let groupMasterKey: Data + do { + let groupSecretParams = try GroupSecretParams(contents: [UInt8](groupsV2Model.secretParamsData)) + groupMasterKey = try groupSecretParams.getMasterKey().serialize().asData + } catch { + errors.append(.init(objectId: recipientId, error: .groupMasterKeyError(error))) + return + } + + // TODO: instead of doing per-thread fetches, we should bulk load + // some of these fetched fields into memory to avoid db round trips. + let groupBuilder = BackupProtoGroup.builder( + masterKey: groupMasterKey, + whitelisted: self.profileManager.isThread(inProfileWhitelist: groupThread, tx: tx), + hideStory: self.storyFinder.isStoryHidden(forGroupThread: groupThread, tx: tx) ?? false + ) + switch groupThread.storyViewMode { + case .disabled: + groupBuilder.setStorySendMode(.disabled) + case .explicit: + groupBuilder.setStorySendMode(.enabled) + default: + groupBuilder.setStorySendMode(.default) + } + + let recipientBuilder = BackupProtoRecipient.builder(id: recipientId.value) + + Self.writeFrameToStream(stream, frameBuilder: { frameBuilder in + let groupProto = try groupBuilder.build() + recipientBuilder.setGroup(groupProto) + let recipientProto = try recipientBuilder.build() + frameBuilder.setRecipient(recipientProto) + return try frameBuilder.build() + }).map { errors.append($0.asArchiveFramesError(objectId: recipientId)) } + } + + static func canRestore(_ recipient: BackupProtoRecipient) -> Bool { + return recipient.group != nil + } + + public func restore( + _ recipient: BackupProtoRecipient, + context: CloudBackup.RecipientRestoringContext, + tx: DBWriteTransaction + ) -> RestoreFrameResult { + guard let groupProto = recipient.group else { + owsFail("Invalid proto for class") + } + + let masterKey = groupProto.masterKey + + guard groupsV2.isValidGroupV2MasterKey(masterKey) else { + owsFailDebug("Invalid master key.") + return .failure(recipient.recipientId, .invalidProtoData) + } + + let groupContextInfo: GroupV2ContextInfo + do { + groupContextInfo = try groupsV2.groupV2ContextInfo(forMasterKeyData: masterKey) + } catch { + owsFailDebug("Invalid master key.") + return .failure(recipient.recipientId, .invalidProtoData) + } + let groupId = groupContextInfo.groupId + + var needsUpdate = false + + // TODO: support group creation. + // group creation as written is async, and therefore needs refactoring + // before it can be triggered from here (and waited on). + // For now, assume this is called from the debug UI after we have synced + // with storage service and have all the groups locally. + guard let localThread = tsThreadFetcher.fetch(groupId: groupId, tx: tx) else { + return .failure(recipient.recipientId, .databaseInsertionFailed(OWSAssertionError("Unimplemented"))) + } + let localStorySendMode = localThread.storyViewMode.storageServiceMode + switch (groupProto.storySendMode, localThread.storyViewMode) { + case (.disabled, .disabled), (.enabled, .explicit), (.default, _), (nil, _): + // Nothing to change. + break + case (.disabled, _): + tsThreadFetcher.updateWithStorySendEnabled(false, groupThread: localThread, tx: tx) + case (.enabled, _): + tsThreadFetcher.updateWithStorySendEnabled(true, groupThread: localThread, tx: tx) + } + let groupThread = localThread + + context[recipient.recipientId] = .group(groupId) + + if groupProto.whitelisted { + profileManager.addToWhitelist(groupThread, tx: tx) + } + + if groupProto.hideStory { + let storyContext = storyFinder.getOrCreateStoryContextAssociatedData(forGroupThread: groupThread, tx: tx) + storyFinder.setStoryContextHidden(storyContext, tx: tx) + } + + return .success + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupNoteToSelfRecipientArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupNoteToSelfRecipientArchiver.swift new file mode 100644 index 00000000000..4b9caa57ca5 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupNoteToSelfRecipientArchiver.swift @@ -0,0 +1,53 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +/** + * Archiver for the ``BackupProtoSelfRecipient`` recipient, a.k.a. Note To Self. + */ +public class CloudBackupNoteToSelfRecipientArchiver: CloudBackupRecipientDestinationArchiver { + + public func archiveRecipients( + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + tx: DBReadTransaction + ) -> ArchiveFramesResult { + let recipientId = context.assignRecipientId(to: .noteToSelf) + let selfRecipientBuilder = BackupProtoSelfRecipient.builder() + let recipientBuilder = BackupProtoRecipient.builder(id: recipientId.value) + + let error = Self.writeFrameToStream(stream) { frameBuilder in + let selfRecipientProto = try selfRecipientBuilder.build() + recipientBuilder.setSelfRecipient(selfRecipientProto) + let recipientProto = try recipientBuilder.build() + frameBuilder.setRecipient(recipientProto) + return try frameBuilder.build() + } + if let error { + return .partialSuccess([error.asArchiveFramesError(objectId: recipientId)]) + } else { + return .success + } + } + + static func canRestore(_ recipient: BackupProtoRecipient) -> Bool { + return recipient.selfRecipient != nil + } + + public func restore( + _ recipient: BackupProtoRecipient, + context: CloudBackup.RecipientRestoringContext, + tx: DBWriteTransaction + ) -> RestoreFrameResult { + guard let noteToSelfRecipient = recipient.selfRecipient else { + owsFail("Invalid proto for class") + } + + context[recipient.recipientId] = .noteToSelf + + return .success + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientArchiver.swift new file mode 100644 index 00000000000..6dcda8a9f5f --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientArchiver.swift @@ -0,0 +1,135 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +/** + * Archives all ``BackupProtoRecipient`` frames, fanning out to per-recipient-type + * ``CloudBackupRecipientDestinationArchiver`` concrete classes to do the actual frame creation and writing. + */ +public protocol CloudBackupRecipientArchiver: CloudBackupProtoArchiver { + + typealias RecipientId = CloudBackup.RecipientId + + typealias ArchiveFramesResult = CloudBackup.ArchiveFramesResult + + /// Archive all recipients. + /// + /// - Returns: ``ArchiveFramesResult.success`` if all frames were written without error, or either + /// partial or complete failure otherwise. + /// How to handle ``ArchiveFramesResult.partialSuccess`` is up to the caller, + /// but typically an error will be shown to the user, but the backup will be allowed to proceed. + /// ``ArchiveFramesResult.completeFailure``, on the other hand, will stop the entire backup, + /// and should be used if some critical or category-wide failure occurs. + func archiveRecipients( + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + tx: DBReadTransaction + ) -> ArchiveFramesResult + + typealias RestoreFrameResult = CloudBackup.RestoreFrameResult + + /// Restore a single ``BackupProtoRecipient`` frame. + /// + /// - Returns: ``RestoreFrameResult.success`` if all frames were read without error. + /// How to handle ``RestoreFrameResult.failure`` is up to the caller, + /// but typically an error will be shown to the user, but the restore will be allowed to proceed. + func restore( + _ recipient: BackupProtoRecipient, + context: CloudBackup.RecipientRestoringContext, + tx: DBWriteTransaction + ) -> RestoreFrameResult +} + +internal class CloudBackupRecipientArchiverImpl: CloudBackupRecipientArchiver { + + private let blockingManager: CloudBackup.Shims.BlockingManager + private let groupsV2: GroupsV2 + private let profileManager: CloudBackup.Shims.ProfileManager + private let recipientHidingManager: RecipientHidingManager + private let signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher + private let storyFinder: CloudBackup.Shims.StoryFinder + private let tsAccountManager: TSAccountManager + private let tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher + + public init( + blockingManager: CloudBackup.Shims.BlockingManager, + groupsV2: GroupsV2, + profileManager: CloudBackup.Shims.ProfileManager, + recipientHidingManager: RecipientHidingManager, + signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher, + storyFinder: CloudBackup.Shims.StoryFinder, + tsAccountManager: TSAccountManager, + tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher + ) { + self.blockingManager = blockingManager + self.groupsV2 = groupsV2 + self.profileManager = profileManager + self.recipientHidingManager = recipientHidingManager + self.signalRecipientFetcher = signalRecipientFetcher + self.storyFinder = storyFinder + self.tsAccountManager = tsAccountManager + self.tsThreadFetcher = tsThreadFetcher + } + + private lazy var destinationArchivers: [CloudBackupRecipientDestinationArchiver] = [ + CloudBackupContactRecipientArchiver( + blockingManager: blockingManager, + profileManager: profileManager, + recipientHidingManager: recipientHidingManager, + signalRecipientFetcher: signalRecipientFetcher, + storyFinder: storyFinder, + tsAccountManager: tsAccountManager + ), + CloudBackupGroupRecipientArchiver( + groupsV2: groupsV2, + profileManager: profileManager, + storyFinder: storyFinder, + tsThreadFetcher: tsThreadFetcher + ), + CloudBackupNoteToSelfRecipientArchiver() + // TODO: add missing archivers: + // * story distribution list (BackupDistributionList) + // * release notes thread (BackupReleaseNotes) + ] + + func archiveRecipients( + stream: CloudBackupProtoOutputStream, + context: CloudBackup.RecipientArchivingContext, + tx: DBReadTransaction + ) -> ArchiveFramesResult { + var partialErrors = [ArchiveFramesResult.Error]() + for archiver in destinationArchivers { + let archiverResults = archiver.archiveRecipients( + stream: stream, + context: context, + tx: tx + ) + switch archiverResults { + case .success: + continue + case .completeFailure(let error): + return .completeFailure(error) + case .partialSuccess(let newErrors): + partialErrors.append(contentsOf: newErrors) + } + } + return partialErrors.isEmpty ? .success : .partialSuccess(partialErrors) + } + + func restore( + _ recipient: BackupProtoRecipient, + context: CloudBackup.RecipientRestoringContext, + tx: DBWriteTransaction + ) -> RestoreFrameResult { + for archiver in destinationArchivers { + guard type(of: archiver).canRestore(recipient) else { + continue + } + return archiver.restore(recipient, context: context, tx: tx) + } + return .failure(recipient.recipientId, .unknownFrameType) + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientDestinationArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientDestinationArchiver.swift new file mode 100644 index 00000000000..f3f06567267 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/CloudBackupRecipientDestinationArchiver.swift @@ -0,0 +1,19 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation +import LibSignalClient + +/** + * Writes and reads ``BackupProtoRecipient`` frames to/from the backup proto. + * + * Different types of recipient objects are fanned out to the different concrete implementations of this protocol. + */ +internal protocol CloudBackupRecipientDestinationArchiver: CloudBackupRecipientArchiver { + + /// This method will be called to determine which archiver to use to restore a particular ``BackupProtoRecipient`` frame. + /// These should be mutually exclusive among all concrete subclasses; typically just presence of a oneOf field. + static func canRestore(_ recipient: BackupProtoRecipient) -> Bool +} diff --git a/SignalServiceKit/CloudBackup/Archivers/Recipient/RecipientContexts.swift b/SignalServiceKit/CloudBackup/Archivers/Recipient/RecipientContexts.swift new file mode 100644 index 00000000000..52e3a87c696 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/Recipient/RecipientContexts.swift @@ -0,0 +1,108 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation +import LibSignalClient + +extension CloudBackup { + + public struct RecipientId: ExpressibleByIntegerLiteral, Hashable { + + public typealias IntegerLiteralType = UInt64 + + internal let value: UInt64 + + public init(integerLiteral value: UInt64) { + self.value = value + } + + fileprivate init(_ value: UInt64) { + self.value = value + } + } + + /** + * As we go archiving recipients, we use this object to track mappings from the addressing we use in the app + * to the ID addressing system of the backup protos. + * + * For example, we will assign a ``BackupRecipientId`` to each ``SignalRecipient`` as we + * insert them. Later, when we create the ``BackupProtoChat`` corresponding to the ``TSContactThread`` + * for that recipient, we will need to add the corresponding ``BackupRecipientId``, which we look up + * using the contact's Aci/Pni/e164, from the map this context keeps. + */ + public class RecipientArchivingContext { + public enum Address: Hashable { + public typealias GroupId = Data + + case noteToSelf + case contactAci(Aci) + case contactPni(Pni) + case contactE164(E164) + case group(GroupId) + } + + internal let localIdentifiers: LocalIdentifiers + + private var currentRecipientId: RecipientId = 0 + private let map = SharedMap() + + internal init(localIdentifiers: LocalIdentifiers) { + self.localIdentifiers = localIdentifiers + } + + internal func assignRecipientId(to address: Address) -> RecipientId { + defer { + currentRecipientId = RecipientId(currentRecipientId.value + 1) + } + map[address] = currentRecipientId + return currentRecipientId + } + + internal subscript(_ address: Address) -> RecipientId? { + // swiftlint:disable:next implicit_getter + get { map[address] } + } + } + + public class RecipientRestoringContext { + public enum Address { + public typealias GroupId = RecipientArchivingContext.Address.GroupId + + case noteToSelf + case contact(aci: Aci?, pni: Pni?, e164: E164?) + case group(GroupId) + } + + private let map = SharedMap() + + internal init() {} + + internal subscript(_ id: RecipientId) -> Address? { + get { map[id] } + set(newValue) { map[id] = newValue } + } + } +} + +extension BackupProtoRecipient { + + public var recipientId: CloudBackup.RecipientId { + return .init(id) + } +} + +extension BackupProtoChat { + + public var recipientId: CloudBackup.RecipientId { + return .init(self.recipientID) + } +} + +extension BackupProtoChatItem { + + public var authorRecipientId: CloudBackup.RecipientId { + return .init(authorID) + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/SharedMap.swift b/SignalServiceKit/CloudBackup/Archivers/SharedMap.swift new file mode 100644 index 00000000000..88aa02d3d67 --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/SharedMap.swift @@ -0,0 +1,36 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +extension CloudBackup { + + /** + * When creating and restoring from a cloud backup, we need to map to/from + * the backup-scoped identifers to their equivalents in our codebase. + * For example, we need to map a TSThread.uniqueId to and from the BackupProto's + * Chat.id. + * + * This class is an abstraction over a dictionary that does two things: + * 1. Allows us to swap out an in-memory implementation for an on-disk implementation, + * if in practice there are too many identifiers to keep in memory. + * 2. Ensures we use pass-by-reference instead of pass-by-value that could result + * in copies (using more memory) and requiring the `inout` keyword. + * + * MOST of the time, you should not worry about copying when passing by value; + * the compiler is smart and only actually copies on write. In this case, though, we + * really do want a single in-memory (or on-disk) map shared throughout a single + * backup pass, and we want to modify it as we go. + */ + internal class SharedMap { + + private var map = [K: V]() + + subscript(_ key: K) -> V? { + get { map[key] } + set(value) { map[key] = value } + } + } +} diff --git a/SignalServiceKit/CloudBackup/Archivers/StickerPack/CloudBackupStickerPackArchiver.swift b/SignalServiceKit/CloudBackup/Archivers/StickerPack/CloudBackupStickerPackArchiver.swift new file mode 100644 index 00000000000..39f3117d19a --- /dev/null +++ b/SignalServiceKit/CloudBackup/Archivers/StickerPack/CloudBackupStickerPackArchiver.swift @@ -0,0 +1,10 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +public protocol CloudBackupStickerPackArchiver: CloudBackupProtoArchiver { + +} diff --git a/SignalServiceKit/CloudBackup/CloudBackupManager+Shims.swift b/SignalServiceKit/CloudBackup/CloudBackupManager+Shims.swift index c556c5c4c79..afbaa6b3b07 100644 --- a/SignalServiceKit/CloudBackup/CloudBackupManager+Shims.swift +++ b/SignalServiceKit/CloudBackup/CloudBackupManager+Shims.swift @@ -365,6 +365,8 @@ public class _CloudBackup_TSInteractionWrapper: _CloudBackup_TSInteractionShim { ) case .skipped: message.update(withSkippedRecipient: address, transaction: tx) + case .unknown: + return } } } diff --git a/SignalServiceKit/CloudBackup/CloudBackupManagerImpl.swift b/SignalServiceKit/CloudBackup/CloudBackupManagerImpl.swift index 62b4886331b..af53233947e 100644 --- a/SignalServiceKit/CloudBackup/CloudBackupManagerImpl.swift +++ b/SignalServiceKit/CloudBackup/CloudBackupManagerImpl.swift @@ -10,44 +10,29 @@ public class NotImplementedError: Error {} public class CloudBackupManagerImpl: CloudBackupManager { - private let blockingManager: CloudBackup.Shims.BlockingManager private let dateProvider: DateProvider private let db: DB private let dmConfigurationStore: DisappearingMessagesConfigurationStore - private let groupsV2: GroupsV2 - private let profileManager: CloudBackup.Shims.ProfileManager - private let recipientHidingManager: RecipientHidingManager - private let signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher - private let storyFinder: CloudBackup.Shims.StoryFinder - private let streamProvider: CloudBackupOutputStreamProvider + private let recipientArchiver: CloudBackupRecipientArchiver + private let streamProvider: CloudBackupProtoStreamProvider private let tsAccountManager: TSAccountManager private let tsInteractionFetcher: CloudBackup.Shims.TSInteractionFetcher private let tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher public init( - blockingManager: CloudBackup.Shims.BlockingManager, dateProvider: @escaping DateProvider, db: DB, dmConfigurationStore: DisappearingMessagesConfigurationStore, - groupsV2: GroupsV2, - profileManager: CloudBackup.Shims.ProfileManager, - recipientHidingManager: RecipientHidingManager, - signalRecipientFetcher: CloudBackup.Shims.SignalRecipientFetcher, - storyFinder: CloudBackup.Shims.StoryFinder, - streamProvider: CloudBackupOutputStreamProvider, + recipientArchiver: CloudBackupRecipientArchiver, + streamProvider: CloudBackupProtoStreamProvider, tsAccountManager: TSAccountManager, tsInteractionFetcher: CloudBackup.Shims.TSInteractionFetcher, tsThreadFetcher: CloudBackup.Shims.TSThreadFetcher ) { - self.blockingManager = blockingManager self.dateProvider = dateProvider self.db = db self.dmConfigurationStore = dmConfigurationStore - self.groupsV2 = groupsV2 - self.profileManager = profileManager - self.recipientHidingManager = recipientHidingManager - self.signalRecipientFetcher = signalRecipientFetcher - self.storyFinder = storyFinder + self.recipientArchiver = recipientArchiver self.streamProvider = streamProvider self.tsAccountManager = tsAccountManager self.tsInteractionFetcher = tsInteractionFetcher @@ -87,188 +72,68 @@ public class CloudBackupManagerImpl: CloudBackupManager { } private func _createBackup(tx: DBWriteTransaction) throws -> URL { - let stream: CloudBackupOutputStream + let stream: CloudBackupProtoOutputStream switch streamProvider.openOutputFileStream() { case .success(let streamResult): stream = streamResult - case .failure(let error): - throw error + case .unableToOpenFileStream: + throw OWSAssertionError("Unable to open output stream") } + guard let localIdentifiers = tsAccountManager.localIdentifiers(tx: tx) else { + throw OWSAssertionError("No local identifiers!") + } + let recipientArchivingContext = CloudBackup.RecipientArchivingContext( + localIdentifiers: localIdentifiers + ) + try writeHeader(stream: stream, tx: tx) - let (nextRecipientProtoId, addressMap) = try writeRecipients(stream: stream, tx: tx) - let groupIdMap = try writeGroups(nextRecipientProtoId: nextRecipientProtoId, stream: stream, tx: tx) - let chatIdMap = try writeThreads(addressMap: addressMap, groupIdMap: groupIdMap, stream: stream, tx: tx) - try writeMessages(chatMap: chatIdMap, addressMap: addressMap, stream: stream, tx: tx) + let recipientArchiveResult = recipientArchiver.archiveRecipients( + stream: stream, + context: recipientArchivingContext, + tx: tx + ) + switch recipientArchiveResult { + case .success: + break + case .partialSuccess(let partialFailures): + // TODO: how many failures is too many? + Logger.warn("Failed to serialize \(partialFailures.count) recipients") + case .completeFailure(let error): + throw error + } + let chatIdMap = try writeThreads( + recipientContext: recipientArchivingContext, + stream: stream, + tx: tx + ) + try writeMessages( + recipientContext: recipientArchivingContext, + chatMap: chatIdMap, + stream: stream, + tx: tx + ) return stream.closeFileStream() } - private func writeHeader(stream: CloudBackupOutputStream, tx: DBWriteTransaction) throws { + private func writeHeader(stream: CloudBackupProtoOutputStream, tx: DBWriteTransaction) throws { let backupInfo = try BackupProtoBackupInfo.builder( version: 1, - backupTime: dateProvider().ows_millisecondsSince1970 + backupTimeMs: dateProvider().ows_millisecondsSince1970 ).build() - try stream.writeHeader(backupInfo) - } - - private func writeRecipients( - stream: CloudBackupOutputStream, - tx: DBReadTransaction - ) throws -> (UInt64, [SignalServiceAddress: UInt64]) { - var currentRecipientProtoId: UInt64 = 1 - var addressMap = [SignalServiceAddress: UInt64]() - - let whitelistedAddresses = Set(profileManager.allWhitelistedRegisteredAddresses(tx: tx)) - let blockedAddresses = blockingManager.blockedAddresses(tx: tx) - - var firstError: Error? - - guard let localAddress = tsAccountManager.localIdentifiers(tx: tx)?.aciAddress else { - throw OWSAssertionError("No local address!") - } - // Write the local recipient first. - let selfBuilder = BackupProtoSelfRecipient.builder() - let selfProto = try selfBuilder.build() - let selfRecipientBuilder = BackupProtoRecipient.builder(id: currentRecipientProtoId) - addressMap[localAddress] = currentRecipientProtoId - currentRecipientProtoId += 1 - selfRecipientBuilder.setSelfRecipient(selfProto) - let selfRecipientProto = try selfRecipientBuilder.build() - let selfFrameBuilder = BackupProtoFrame.builder() - selfFrameBuilder.setRecipient(selfRecipientProto) - let selfFrame = try selfFrameBuilder.build() - try stream.writeFrame(selfFrame) - - signalRecipientFetcher.enumerateAll(tx: tx) { recipient in - do { - let recipientAddress = recipient.address - - let recipientBuilder = BackupProtoRecipient.builder( - id: currentRecipientProtoId - ) - addressMap[recipient.address] = currentRecipientProtoId - currentRecipientProtoId += 1 - - var unregisteredAtTimestamp: UInt64 = 0 - if !recipient.isRegistered { - unregisteredAtTimestamp = ( - recipient.unregisteredAtTimestamp ?? SignalRecipient.Constants.distantPastUnregisteredTimestamp - ) - } - - // TODO: instead of doing per-recipient fetches, we should bulk load - // some of these fetched fields into memory to avoid db round trips. - let contactBuilder = BackupProtoContact.builder( - blocked: blockedAddresses.contains(recipientAddress), - hidden: self.recipientHidingManager.isHiddenRecipient(recipient, tx: tx), - unregisteredTimestamp: unregisteredAtTimestamp, - profileSharing: whitelistedAddresses.contains(recipient.address), - hideStory: recipient.aci.map { self.storyFinder.isStoryHidden(forAci: $0, tx: tx) ?? false } ?? false - ) - - contactBuilder.setRegistered(recipient.isRegistered ? .registered : .notRegistered) - - recipient.aci.map(\.rawUUID.data).map(contactBuilder.setAci) - recipient.pni.map(\.rawUUID.data).map(contactBuilder.setPni) - recipient.address.e164.map(\.uint64Value).map(contactBuilder.setE164) - // TODO: username? - - let profile = self.profileManager.getUserProfile(for: recipientAddress, tx: tx) - profile?.profileKey.map(\.keyData).map(contactBuilder.setProfileKey(_:)) - profile?.unfilteredGivenName.map(contactBuilder.setProfileGivenName(_:)) - profile?.unfilteredFamilyName.map(contactBuilder.setProfileFamilyName(_:)) - // TODO: joined name? - - let contact = try contactBuilder.build() - recipientBuilder.setContact(contact) - let protoRecipient = try recipientBuilder.build() - let frameBuilder = BackupProtoFrame.builder() - frameBuilder.setRecipient(protoRecipient) - let frame = try frameBuilder.build() - try stream.writeFrame(frame) - } catch let error { - owsFailDebug("Failed to write recipient!") - firstError = firstError ?? error - } - } - - if let firstError { - throw firstError - } - - return (currentRecipientProtoId, addressMap) - } - - private func writeGroups( - nextRecipientProtoId: UInt64, - stream: CloudBackupOutputStream, - tx: DBReadTransaction - ) throws -> [Data: UInt64] { - var currentRecipientProtoId = nextRecipientProtoId - var idMap = [Data: UInt64]() - - var firstError: Error? - - try tsThreadFetcher.enumerateAllGroupThreads(tx: tx) { groupThread in - do { - guard groupThread.isGroupV2Thread, let groupsV2Model = groupThread.groupModel as? TSGroupModelV2 else { - return - } - let groupSecretParams = try GroupSecretParams(contents: [UInt8](groupsV2Model.secretParamsData)) - let groupMasterKey = try groupSecretParams.getMasterKey().serialize().asData - - // TODO: instead of doing per-thread fetches, we should bulk load - // some of these fetched fields into memory to avoid db round trips. - let groupBuilder = BackupProtoGroup.builder( - masterKey: groupMasterKey, - whitelisted: self.profileManager.isThread(inProfileWhitelist: groupThread, tx: tx), - hideStory: self.storyFinder.isStoryHidden(forGroupThread: groupThread, tx: tx) ?? false - ) - switch groupThread.storyViewMode { - case .disabled: - groupBuilder.setStorySendMode(.disabled) - case .explicit: - groupBuilder.setStorySendMode(.enabled) - default: - groupBuilder.setStorySendMode(.default) - } - - let groupProto = try groupBuilder.build() - let recipientBuilder = BackupProtoRecipient.builder( - id: currentRecipientProtoId - ) - idMap[groupThread.groupId] = currentRecipientProtoId - currentRecipientProtoId += 1 - - recipientBuilder.setGroup(groupProto) - - let recipientProto = try recipientBuilder.build() - - let frameBuilder = BackupProtoFrame.builder() - frameBuilder.setRecipient(recipientProto) - let frame = try frameBuilder.build() - - try stream.writeFrame(frame) - - } catch let error { - owsFailDebug("Failed to write recipient!") - firstError = firstError ?? error - } - } - - if let firstError { - throw firstError + switch stream.writeHeader(backupInfo) { + case .success: + break + case .fileIOError(let error), .protoSerializationError(let error): + throw error } - - return idMap } private func writeThreads( - addressMap: [SignalServiceAddress: UInt64], - groupIdMap: [Data: UInt64], - stream: CloudBackupOutputStream, + recipientContext: CloudBackup.RecipientArchivingContext, + stream: CloudBackupProtoOutputStream, tx: DBReadTransaction ) throws -> [String: UInt64] { var currentChatId: UInt64 = 1 @@ -276,21 +141,24 @@ public class CloudBackupManagerImpl: CloudBackupManager { var firstError: Error? + var pinnedOrder: UInt32 = 0 + tsThreadFetcher.enumerateAll(tx: tx) { thread in do { guard thread is TSGroupThread || thread is TSContactThread else { return } + let contactAddress = (thread as? TSContactThread)?.contactAddress - let recipientProtoId: UInt64 + let recipientProtoId: CloudBackup.RecipientId if let groupId = (thread as? TSGroupThread)?.groupId, - let id = groupIdMap[groupId] + let id = recipientContext[.group(groupId)] { recipientProtoId = id } else if let contactAddress = (thread as? TSContactThread)?.contactAddress, - let id = addressMap[contactAddress] + let id = recipientContext[contactAddress] { recipientProtoId = id } else { @@ -300,14 +168,24 @@ public class CloudBackupManagerImpl: CloudBackupManager { let threadAssociatedData = self.tsThreadFetcher.fetchOrDefaultThreadAssociatedData(for: thread, tx: tx) + let thisThreadPinnedOrder: UInt32 + if self.tsThreadFetcher.isThreadPinned(thread) { + pinnedOrder += 1 + thisThreadPinnedOrder = pinnedOrder + } else { + // Hardcoded 0 for unpinned. + thisThreadPinnedOrder = 0 + } + let chatBuilder = BackupProtoChat.builder( id: currentChatId, - recipientID: recipientProtoId, + recipientID: recipientProtoId.value, archived: threadAssociatedData.isArchived, - pinned: self.tsThreadFetcher.isThreadPinned(thread), + // TODO: proper pinned thread ordering + pinnedOrder: thisThreadPinnedOrder, // TODO: should this be millis? or seconds? - expirationTimer: UInt64(self.dmConfigurationStore.durationSeconds(for: thread, tx: tx)), - muteUntil: threadAssociatedData.mutedUntilTimestamp, + expirationTimerMs: UInt64(self.dmConfigurationStore.durationSeconds(for: thread, tx: tx)), + muteUntilMs: threadAssociatedData.mutedUntilTimestamp, markedUnread: threadAssociatedData.isMarkedUnread, // TODO: this is commented out on storageService? ignoring for now. dontNotifyForMentionsIfMuted: false @@ -320,7 +198,12 @@ public class CloudBackupManagerImpl: CloudBackupManager { frameBuilder.setChat(chatProto) let frame = try frameBuilder.build() - try stream.writeFrame(frame) + switch stream.writeFrame(frame) { + case .success: + break + case .fileIOError(let error), .protoSerializationError(let error): + throw error + } } catch let error { firstError = firstError ?? error @@ -335,9 +218,9 @@ public class CloudBackupManagerImpl: CloudBackupManager { } private func writeMessages( + recipientContext: CloudBackup.RecipientArchivingContext, chatMap: [String: UInt64], - addressMap: [SignalServiceAddress: UInt64], - stream: CloudBackupOutputStream, + stream: CloudBackupProtoOutputStream, tx: DBReadTransaction ) throws { guard let localAddress = tsAccountManager.localIdentifiers(tx: tx)?.aciAddress else { @@ -358,24 +241,23 @@ public class CloudBackupManagerImpl: CloudBackupManager { return } let authorAddress = (message as? TSIncomingMessage)?.authorAddress ?? localAddress - guard let authorId = addressMap[authorAddress] else { + guard let authorId = recipientContext[authorAddress] else { owsFailDebug("missing author id!") return } let chatItemBuilder = BackupProtoChatItem.builder( chatID: chatId, - authorID: authorId, + authorID: authorId.value, dateSent: message.timestamp, - dateReceived: message.receivedAtTimestamp, sms: false ) // TODO: don't include messages expiring within 24hr if message.expireStartedAt > 0 { - chatItemBuilder.setExpireStart(message.expireStartedAt) + chatItemBuilder.setExpireStartMs(message.expireStartedAt) } if message.expiresAt > 0 { - chatItemBuilder.setExpiresIn(message.expiresAt) + chatItemBuilder.setExpiresInMs(message.expiresAt) } switch message.editState { case .latestRevisionRead, .latestRevisionUnread, .none: @@ -387,9 +269,10 @@ public class CloudBackupManagerImpl: CloudBackupManager { if let incomingMessage = message as? TSIncomingMessage { let incomingMessageProtoBuilder = BackupProtoChatItemIncomingMessageDetails.builder( + dateReceived: incomingMessage.receivedAtTimestamp, dateServerSent: incomingMessage.serverDeliveryTimestamp, read: incomingMessage.wasRead, - sealedSender: incomingMessage.wasReceivedByUD + sealedSender: incomingMessage.wasReceivedByUD.negated ) let incomingMessageProto = try incomingMessageProtoBuilder.build() chatItemBuilder.setIncoming(incomingMessageProto) @@ -400,7 +283,7 @@ public class CloudBackupManagerImpl: CloudBackupManager { guard let sendState = outgoingMessage.recipientState(for: address) else { return } - guard let recipientId = addressMap[address] else { + guard let recipientId = recipientContext[address] else { owsFailDebug("Missing recipient for message!") return } @@ -438,7 +321,7 @@ public class CloudBackupManagerImpl: CloudBackupManager { } let sendStatusBuilder: BackupProtoSendStatusBuilder = BackupProtoSendStatus.builder( - recipientID: recipientId, + recipientID: recipientId.value, networkFailure: isNetworkFailure, identityKeyMismatch: isIdentityKeyMismatchFailure, sealedSender: sendState.wasSentByUD.negated, @@ -464,8 +347,11 @@ public class CloudBackupManagerImpl: CloudBackupManager { let bodyRangeProtoBuilder = BackupProtoBodyRange.builder() bodyRangeProtoBuilder.setStart(bodyRange.start) bodyRangeProtoBuilder.setLength(bodyRange.length) - if let mentionAci = bodyRange.mentionAci { - bodyRangeProtoBuilder.setMentionAci(mentionAci) + if + let rawMentionAci = bodyRange.mentionAci, + let mentionUuid = UUID(uuidString: rawMentionAci) + { + bodyRangeProtoBuilder.setMentionAci(Aci(fromUUID: mentionUuid).serviceIdBinary.asData) } else if let style = bodyRange.style { switch style { case .none: @@ -496,7 +382,12 @@ public class CloudBackupManagerImpl: CloudBackupManager { let frameBuilder = BackupProtoFrame.builder() frameBuilder.setChatItem(chatItemProto) let frame = try frameBuilder.build() - try stream.writeFrame(frame) + switch stream.writeFrame(frame) { + case .success: + break + case .fileIOError(let error), .protoSerializationError(let error): + throw error + } } catch let error { firstError = firstError ?? error @@ -509,66 +400,84 @@ public class CloudBackupManagerImpl: CloudBackupManager { } private func _importBackup(_ fileUrl: URL, tx: DBWriteTransaction) throws { - let stream: CloudBackupInputStream + let stream: CloudBackupProtoInputStream switch streamProvider.openInputFileStream(fileURL: fileUrl) { case .success(let streamResult): stream = streamResult - case .failure(let error): - throw error + case .fileNotFound: + throw OWSAssertionError("file not found!") + case .unableToOpenFileStream: + throw OWSAssertionError("unable to open input stream") } defer { stream.closeFileStream() } - let header = try stream.readHeader() - guard let backupInfo = header.object else { - return + let backupInfo: BackupProtoBackupInfo + var hasMoreFrames = false + switch stream.readHeader() { + case .success(let header, let moreBytesAvailable): + backupInfo = header + hasMoreFrames = moreBytesAvailable + case .invalidByteLengthDelimiter: + throw OWSAssertionError("invalid byte length delimiter on header") + case .protoDeserializationError(let error): + // Fail if we fail to deserialize the header. + throw error } - Logger.info("Reading backup with version: \(backupInfo.version) backed up at \(backupInfo.backupTime)") + Logger.info("Reading backup with version: \(backupInfo.version) backed up at \(backupInfo.backupTimeMs)") - var aciMap = [UInt64: Aci]() - var pniMap = [UInt64: Pni]() - var addressMap = [UInt64: SignalServiceAddress]() - var groupIdMap = [UInt64: Data]() + let recipientContext = CloudBackup.RecipientRestoringContext() var threadUniqueIdMap = [UInt64: String]() - var hasMoreFrames = header.moreBytesAvailable while hasMoreFrames { - let frame = try stream.readFrame() - hasMoreFrames = frame.moreBytesAvailable - if let recipient = frame.object?.recipient { - if let contact = recipient.contact { - try handleReadContact( - contact, - recipientProtoId: recipient.id, - aciMap: &aciMap, - pniMap: &pniMap, - addressMap: &addressMap, - tx: tx - ) - } else if let group = recipient.group { - try handleReadGroup( - group, - recipientProtoId: recipient.id, - groupIdMap: &groupIdMap, - tx: tx - ) + let frame: BackupProtoFrame + switch stream.readFrame() { + case let .success(_frame, moreBytesAvailable): + frame = _frame + hasMoreFrames = moreBytesAvailable + case .invalidByteLengthDelimiter: + throw OWSAssertionError("invalid byte length delimiter on header") + case .protoDeserializationError(let error): + // TODO: should we fail the whole thing if we fail to deserialize one frame? + throw error + } + if let recipient = frame.recipient { + let recipientResult = recipientArchiver.restore( + recipient, + context: recipientContext, + tx: tx + ) + switch recipientResult { + case .success: + continue + case .failure(_, let error): + // TODO: maybe track which IDs failed to attribute later failures + // that reference this ID. + switch error { + case .databaseInsertionFailed(let dbError): + throw dbError + case .invalidProtoData: + throw OWSAssertionError("Invalid proto data!") + case .identifierNotFound: + throw OWSAssertionError("Recipients are the root objects, should be impossible!") + case .unknownFrameType: + throw OWSAssertionError("Found unrecognized frame type") + } } - } else if let chat = frame.object?.chat { + } else if let chat = frame.chat { try handleReadChat( chat, - addressMap: addressMap, - groupIdMap: groupIdMap, + recipientContext: recipientContext, threadUniqueIdMap: &threadUniqueIdMap, tx: tx ) - } else if let chatItem = frame.object?.chatItem { + } else if let chatItem = frame.chatItem { try handleReadChatItem( chatItem: chatItem, - aciMap: aciMap, - pniMap: pniMap, + recipientContext: recipientContext, threadUniqueIdMap: threadUniqueIdMap, tx: tx ) @@ -578,163 +487,30 @@ public class CloudBackupManagerImpl: CloudBackupManager { return stream.closeFileStream() } - private func handleReadContact( - _ contactProto: BackupProtoContact, - recipientProtoId: UInt64, - aciMap: inout [UInt64: Aci], - pniMap: inout [UInt64: Pni], - addressMap: inout [UInt64: SignalServiceAddress], - tx: DBWriteTransaction - ) throws { - let isRegistered: Bool? - let unregisteredTimestamp: UInt64? - switch contactProto.registered { - case .none, .unknown: - isRegistered = nil - unregisteredTimestamp = nil - case .registered: - isRegistered = true - unregisteredTimestamp = nil - case .notRegistered: - isRegistered = false - unregisteredTimestamp = contactProto.unregisteredTimestamp - } - - let aci: Aci? = contactProto.aci.map(UUID.from(data:))?.map(\.0).map(Aci.init(fromUUID:)) - let pni: Pni? = contactProto.pni.map(UUID.from(data:))?.map(\.0).map(Pni.init(fromUUID:)) - if let aci { - aciMap[recipientProtoId] = aci - } - if let pni { - pniMap[recipientProtoId] = pni - } - - var recipient = SignalRecipient.proofOfConcept_forBackup( - aci: aci, - pni: pni, - phoneNumber: E164(contactProto.e164), - isRegistered: isRegistered, - unregisteredAtTimestamp: unregisteredTimestamp - ) - - // This is bad, but needed because the import can happen at any time - // and we don't wipe the db. in the future, we will only do this restore - // during registration/linking, with an empty database. - if let existingRecipient = signalRecipientFetcher.recipient(for: recipient.address, tx: tx) { - recipient = existingRecipient - if isRegistered == true, !recipient.isRegistered { - signalRecipientFetcher.markAsRegisteredAndSave(recipient, tx: tx) - } else if isRegistered == false, recipient.isRegistered, let unregisteredTimestamp { - signalRecipientFetcher.markAsUnregisteredAndSave(recipient, at: unregisteredTimestamp, tx: tx) - } - } else { - try signalRecipientFetcher.insert(recipient, tx: tx) - } - - addressMap[recipientProtoId] = recipient.address - - if contactProto.profileSharing { - // Add to the whitelist. - profileManager.addToWhitelist(recipient.address, tx: tx) - } - - if contactProto.blocked { - blockingManager.addBlockedAddress(recipient.address, tx: tx) - } - - if contactProto.hidden { - try recipientHidingManager.addHiddenRecipient(recipient, wasLocallyInitiated: false, tx: tx) - } - - if contactProto.hideStory, let aci { - let storyContext = storyFinder.getOrCreateStoryContextAssociatedData(for: aci, tx: tx) - storyFinder.setStoryContextHidden(storyContext, tx: tx) - } - - profileManager.setProfileGivenName( - givenName: contactProto.profileGivenName, - familyName: contactProto.profileFamilyName, - profileKey: contactProto.profileKey, - address: recipient.address, - tx: tx - ) - } - - private func handleReadGroup( - _ groupProto: BackupProtoGroup, - recipientProtoId: UInt64, - groupIdMap: inout [UInt64: Data], - tx: DBWriteTransaction - ) throws { - let masterKey = groupProto.masterKey - - guard groupsV2.isValidGroupV2MasterKey(masterKey) else { - owsFailDebug("Invalid master key.") - return - } - - let groupContextInfo: GroupV2ContextInfo - do { - groupContextInfo = try groupsV2.groupV2ContextInfo(forMasterKeyData: masterKey) - } catch { - owsFailDebug("Invalid master key.") - return - } - let groupId = groupContextInfo.groupId - - var needsUpdate = false - - let groupThread: TSGroupThread - - if let localThread = tsThreadFetcher.fetch(groupId: groupId, tx: tx) { - let localStorySendMode = localThread.storyViewMode.storageServiceMode - switch (groupProto.storySendMode, localThread.storyViewMode) { - case (.disabled, .disabled), (.enabled, .explicit), (.default, _), (nil, _): - // Nothing to change. - break - case (.disabled, _): - tsThreadFetcher.updateWithStorySendEnabled(false, groupThread: localThread, tx: tx) - case (.enabled, _): - tsThreadFetcher.updateWithStorySendEnabled(true, groupThread: localThread, tx: tx) - } - groupThread = localThread - } else { - // TODO: creating groups is async and scheduled in GroupsV2. Punt for now. - return - } - - groupIdMap[recipientProtoId] = groupId - - if groupProto.whitelisted { - profileManager.addToWhitelist(groupThread, tx: tx) - } - - if groupProto.hideStory { - let storyContext = storyFinder.getOrCreateStoryContextAssociatedData(forGroupThread: groupThread, tx: tx) - storyFinder.setStoryContextHidden(storyContext, tx: tx) - } - } - private func handleReadChat( _ chatProto: BackupProtoChat, - addressMap: [UInt64: SignalServiceAddress], - groupIdMap: [UInt64: Data], + recipientContext: CloudBackup.RecipientRestoringContext, threadUniqueIdMap: inout [UInt64: String], tx: DBWriteTransaction ) throws { let thread: TSThread - if let groupId = groupIdMap[chatProto.recipientID] { + switch recipientContext[chatProto.recipientId] { + case .none: + owsFailDebug("Missing recipient for chat!") + return + case .noteToSelf: + // TODO: handle note to self chat, create the tsThread + return + case .group(let groupId): // We don't create the group thread here; that happened when parsing the Group. // Instead, just set metadata. guard let groupThread = tsThreadFetcher.fetch(groupId: groupId, tx: tx) else { return } thread = groupThread - } else if let address = addressMap[chatProto.recipientID] { + case let .contact(aci, pni, e164): + let address = SignalServiceAddress(serviceId: aci ?? pni, phoneNumber: e164?.stringValue) thread = tsThreadFetcher.getOrCreateContactThread(with: address, tx: tx) - } else { - owsFailDebug("Missing recipient for chat!") - return } threadUniqueIdMap[chatProto.id] = thread.uniqueId @@ -753,9 +529,9 @@ public class CloudBackupManagerImpl: CloudBackupManager { associatedDataNeedsUpdate = true isMarkedUnread = true } - if chatProto.muteUntil != 0 { + if chatProto.muteUntilMs != 0 { associatedDataNeedsUpdate = true - mutedUntilTimestamp = chatProto.muteUntil + mutedUntilTimestamp = chatProto.muteUntilMs } if associatedDataNeedsUpdate { @@ -768,7 +544,8 @@ public class CloudBackupManagerImpl: CloudBackupManager { tx: tx ) } - if chatProto.pinned { + // TODO: recover pinned chat ordering + if chatProto.pinnedOrder != 0 { do { try tsThreadFetcher.pinThread(thread, tx: tx) } catch { @@ -777,10 +554,10 @@ public class CloudBackupManagerImpl: CloudBackupManager { } } - if chatProto.expirationTimer != 0 { + if chatProto.expirationTimerMs != 0 { // TODO: should this be millis? or seconds? dmConfigurationStore.set( - token: .init(isEnabled: true, durationSeconds: UInt32(chatProto.expirationTimer)), + token: .init(isEnabled: true, durationSeconds: UInt32(chatProto.expirationTimerMs)), for: .thread(thread), tx: tx ) @@ -789,8 +566,7 @@ public class CloudBackupManagerImpl: CloudBackupManager { private func handleReadChatItem( chatItem: BackupProtoChatItem, - aciMap: [UInt64: Aci], - pniMap: [UInt64: Pni], + recipientContext: CloudBackup.RecipientRestoringContext, threadUniqueIdMap: [UInt64: String], tx: DBWriteTransaction ) throws { @@ -814,7 +590,10 @@ public class CloudBackupManagerImpl: CloudBackupManager { var bodyStyles = [NSRangedValue]() for bodyRange in bodyRangesProto { let range = NSRange(location: Int(bodyRange.start), length: Int(bodyRange.length)) - if bodyRange.hasMentionAci, let mentionAci = Aci.parseFrom(aciString: bodyRange.mentionAci) { + if + let rawMentionAci = bodyRange.mentionAci, + let mentionAci = try? Aci.parseFrom(serviceIdBinary: rawMentionAci) + { bodyMentions[range] = mentionAci } else if bodyRange.hasStyle { let swiftStyle: MessageBodyRanges.SingleStyle @@ -842,14 +621,22 @@ public class CloudBackupManagerImpl: CloudBackupManager { if let incomingMessage = chatItem.incoming { - guard let authorAci = aciMap[chatItem.authorID] else { + let authorAci: Aci + switch recipientContext[chatItem.authorRecipientId] { + case .contact(let aci, _, _): + guard let aci else { + fallthrough + } + authorAci = aci + default: + // Messages can only come from Acis. owsFailDebug("Missing author for message!") return } let messageBuilder = TSIncomingMessageBuilder.builder( thread: thread, - timestamp: chatItem.dateReceived, + timestamp: incomingMessage.dateReceived, authorAci: .init(authorAci), // TODO: this needs to be added to the proto sourceDeviceId: 1, @@ -859,7 +646,7 @@ public class CloudBackupManagerImpl: CloudBackupManager { // TODO: handle edit states editState: .none, // TODO: expose + set expire start time - expiresInSeconds: UInt32(chatItem.expiresIn), + expiresInSeconds: UInt32(chatItem.expiresInMs), quotedMessage: nil, contactShare: nil, linkPreview: nil, @@ -887,8 +674,8 @@ public class CloudBackupManagerImpl: CloudBackupManager { bodyRanges: bodyRanges, attachmentIds: nil, // TODO: is this seconds or ms? - expiresInSeconds: UInt32(chatItem.expiresIn), - expireStartedAt: chatItem.expireStart, + expiresInSeconds: UInt32(chatItem.expiresInMs), + expireStartedAt: chatItem.expireStartMs, isVoiceMessage: false, groupMetaMessage: .unspecified, quotedMessage: nil, @@ -909,11 +696,15 @@ public class CloudBackupManagerImpl: CloudBackupManager { for sendStatus in outgoingMessage.sendStatus { let recipient: ServiceId - if let aci = aciMap[sendStatus.recipientID] { - recipient = aci - } else if let pni = pniMap[sendStatus.recipientID] { - recipient = pni - } else { + switch recipientContext[chatItem.authorRecipientId] { + case .contact(let aci, let pni, _): + guard let serviceId: ServiceId = aci ?? pni else { + fallthrough + } + recipient = serviceId + default: + // Recipients can only be Acis or Pnis. + // TODO: what about e164s? continue } @@ -933,3 +724,30 @@ public class CloudBackupManagerImpl: CloudBackupManager { } } } + +fileprivate extension CloudBackup.RecipientArchivingContext { + + subscript(address: SignalServiceAddress) -> CloudBackup.RecipientId? { + // swiftlint:disable:next implicit_getter + get { + if + let aci = address.serviceId as? Aci, + let id = self[.contactAci(aci)] + { + return id + } else if + let pni = address.serviceId as? Pni, + let id = self[.contactPni(pni)] + { + return id + } else if + let e164 = address.e164, + let id = self[.contactE164(e164)] + { + return id + } else { + return nil + } + } + } +} diff --git a/SignalServiceKit/CloudBackup/CloudBackupProtoFileStreams.swift b/SignalServiceKit/CloudBackup/CloudBackupProtoFileStreams.swift deleted file mode 100644 index c483095d4a5..00000000000 --- a/SignalServiceKit/CloudBackup/CloudBackupProtoFileStreams.swift +++ /dev/null @@ -1,233 +0,0 @@ -// -// Copyright 2023 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only -// - -import Foundation - -public enum CloudBackupOutputStreamOpenError: Error { - case unableToOpenFileStream -} - -public enum CloudBackupInputStreamOpenError: Error { - case fileMissing - case unableToOpenFileStream -} - -public protocol CloudBackupOutputStreamProvider { - - func openOutputFileStream() -> Result - - func openInputFileStream(fileURL: URL) -> Result -} - -public protocol CloudBackupOutputStream { - - func writeHeader(_ header: BackupProtoBackupInfo) throws - - func writeFrame(_ frame: BackupProtoFrame) throws - - // Returns URL of the file written to. - func closeFileStream() -> URL -} - -extension CloudBackup { - public struct InputStreamReadResult { - let object: T? - let moreBytesAvailable: Bool - } -} - -public protocol CloudBackupInputStream { - - func readHeader() throws -> CloudBackup.InputStreamReadResult - - func readFrame() throws -> CloudBackup.InputStreamReadResult - - func closeFileStream() -} - -public class CloudBackupOutputStreamProviderImpl: CloudBackupOutputStreamProvider { - - public init() {} - - public func openOutputFileStream() -> Result { - let fileUrl = OWSFileSystem.temporaryFileUrl(isAvailableWhileDeviceLocked: true) - guard let outputStream = OutputStream(url: fileUrl, append: false) else { - owsFailDebug("Could not open outputStream.") - return .failure(.unableToOpenFileStream) - } - let outputStreamDelegate = StreamDelegate() - outputStream.delegate = outputStreamDelegate - let streamRunloop = RunLoop.current - outputStream.schedule(in: streamRunloop, forMode: .default) - outputStream.open() - guard outputStream.streamStatus == .open else { - owsFailDebug("Could not open outputStream.") - return .failure(.unableToOpenFileStream) - } - - let cloudBackupOutputStream = CloudBackupOutputStreamImpl( - outputStream: outputStream, - streamRunloop: streamRunloop, - outputStreamDelegate: outputStreamDelegate, - fileURL: fileUrl - ) - return .success(cloudBackupOutputStream) - } - - public func openInputFileStream(fileURL: URL) -> Result { - guard OWSFileSystem.fileOrFolderExists(url: fileURL) else { - owsFailDebug("Missing file!") - return .failure(.fileMissing) - } - guard let inputStream = InputStream(url: fileURL) else { - owsFailDebug("Unable to open input stream") - return .failure(.unableToOpenFileStream) - } - let inputStreamDelegate = StreamDelegate() - inputStream.delegate = inputStreamDelegate - let streamRunloop = RunLoop.current - inputStream.schedule(in: streamRunloop, forMode: .default) - inputStream.open() - guard inputStream.streamStatus == .open else { - owsFailDebug("Could not open input stream.") - return .failure(.unableToOpenFileStream) - } - - let cloudBackupInputStream = CloudBackupInputStreamImpl( - inputStream: inputStream, - streamRunloop: streamRunloop, - inputStreamDelegate: inputStreamDelegate - ) - return .success(cloudBackupInputStream) - } - - fileprivate class StreamDelegate: NSObject, Foundation.StreamDelegate { - private let _hadError = AtomicBool(false) - public var hadError: Bool { _hadError.get() } - - @objc - public func stream(_ stream: Stream, handle eventCode: Stream.Event) { - if eventCode == .errorOccurred { - _hadError.set(true) - } - } - } -} - -internal class CloudBackupOutputStreamImpl: OWSChunkedOutputStream, CloudBackupOutputStream { - - private var outputStream: OutputStream - private var streamRunloop: RunLoop - private var outputStreamDelegate: StreamDelegate - private var fileUrl: URL - - internal init( - outputStream: OutputStream, - streamRunloop: RunLoop, - outputStreamDelegate: StreamDelegate, - fileURL: URL - ) { - self.outputStream = outputStream - self.streamRunloop = streamRunloop - self.outputStreamDelegate = outputStreamDelegate - self.fileUrl = fileURL - super.init(outputStream: outputStream) - } - - internal func writeHeader(_ header: BackupProtoBackupInfo) throws { - let bytes = try header.serializedData() - let byteLength = UInt32(bytes.count) - try writeVariableLengthUInt32(byteLength) - try writeData(bytes) - } - - internal func writeFrame(_ frame: BackupProtoFrame) throws { - let bytes = try frame.serializedData() - let byteLength = UInt32(bytes.count) - try writeVariableLengthUInt32(byteLength) - try writeData(bytes) - } - - public func closeFileStream() -> URL { - outputStream.remove(from: streamRunloop, forMode: .default) - outputStream.close() - return fileUrl - } -} - -internal class CloudBackupInputStreamImpl: CloudBackupInputStream { - - private var inputStream: InputStream - private var streamRunloop: RunLoop - private var inputStreamDelegate: StreamDelegate - - internal init( - inputStream: InputStream, - streamRunloop: RunLoop, - inputStreamDelegate: StreamDelegate - ) { - self.inputStream = inputStream - self.streamRunloop = streamRunloop - self.inputStreamDelegate = inputStreamDelegate - } - - enum ReadError: Error { - case invalidByteLengthDelimiter - case fileTruncated - } - - internal func readHeader() throws -> CloudBackup.InputStreamReadResult { - return try readProto(BackupProtoBackupInfo.init(serializedData:)) - } - - internal func readFrame() throws -> CloudBackup.InputStreamReadResult { - return try readProto(BackupProtoFrame.init(serializedData:)) - } - - public func closeFileStream() { - inputStream.remove(from: streamRunloop, forMode: .default) - inputStream.close() - } - - private func readProto( - _ initializer: (Data) throws -> T - ) throws -> CloudBackup.InputStreamReadResult { - let protoByteLength = Int(try decodeVarint()) - let bytes = UnsafeMutablePointer.allocate(capacity: protoByteLength) - let actualByteLength = inputStream.read(bytes, maxLength: protoByteLength) - guard actualByteLength == protoByteLength else { - throw ReadError.fileTruncated - } - let protoBytes = Data(bytes: bytes, count: protoByteLength) - let protoObject = try initializer(protoBytes) - return .init(object: protoObject, moreBytesAvailable: inputStream.hasBytesAvailable) - } - - /// Private: Parse the next raw varint from the input. - /// - /// Based on SwiftProtobuf.BinaryDecoder.decodeVarint() - private func decodeVarint() throws -> UInt64 { - let nextByte = UnsafeMutablePointer.allocate(capacity: 1) - inputStream.read(nextByte, maxLength: 1) - var c = nextByte[0] - if c & 0x80 == 0 { - return UInt64(c) - } - var value = UInt64(c & 0x7f) - var shift = UInt64(7) - while true { - if !inputStream.hasBytesAvailable || shift > 63 { - throw ReadError.invalidByteLengthDelimiter - } - inputStream.read(nextByte, maxLength: 1) - c = nextByte[0] - value |= UInt64(c & 0x7f) << shift - if c & 0x80 == 0 { - return value - } - shift += 7 - } - } -} diff --git a/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoInputStream.swift b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoInputStream.swift new file mode 100644 index 00000000000..68d10d48fa4 --- /dev/null +++ b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoInputStream.swift @@ -0,0 +1,112 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +extension CloudBackup { + public enum ProtoInputStreamReadResult { + case success(T, moreBytesAvailable: Bool) + case invalidByteLengthDelimiter + case protoDeserializationError(Error) + } +} + +/** + * Input stream for reading and writing a backup file on disk. + * + * The backup file is just a sequence of serialized proto bytes, back to back, delimited by varint + * byte sizes so we know how much to read into memory to deserialize the next proto. + * The input stream abstracts over this, and allows callers to just think in terms of "frames", + * the individual proto objects that we read one at a time. + */ +public protocol CloudBackupProtoInputStream { + + /// Read the single header object at the start of every backup file. + /// If this header is missing or invalid, the backup should be discarded. + func readHeader() -> CloudBackup.ProtoInputStreamReadResult + + /// Read a the next frame from the backup file. + func readFrame() -> CloudBackup.ProtoInputStreamReadResult + + /// Close the stream. Attempting to read after closing will result in failures. + func closeFileStream() +} + +internal class CloudBackupProtoInputStreamImpl: CloudBackupProtoInputStream { + + private var inputStream: InputStream + private var streamRunloop: RunLoop + private var inputStreamDelegate: StreamDelegate + + internal init( + inputStream: InputStream, + streamRunloop: RunLoop, + inputStreamDelegate: StreamDelegate + ) { + self.inputStream = inputStream + self.streamRunloop = streamRunloop + self.inputStreamDelegate = inputStreamDelegate + } + + internal func readHeader() -> CloudBackup.ProtoInputStreamReadResult { + return readProto(BackupProtoBackupInfo.init(serializedData:)) + } + + internal func readFrame() -> CloudBackup.ProtoInputStreamReadResult { + return readProto(BackupProtoFrame.init(serializedData:)) + } + + public func closeFileStream() { + inputStream.remove(from: streamRunloop, forMode: .default) + inputStream.close() + } + + private func readProto( + _ initializer: (Data) throws -> T + ) -> CloudBackup.ProtoInputStreamReadResult { + guard let protoByteLengthRaw = decodeVarint() else { + return .invalidByteLengthDelimiter + } + let protoByteLength = Int(protoByteLengthRaw) + let bytes = UnsafeMutablePointer.allocate(capacity: protoByteLength) + let actualByteLength = inputStream.read(bytes, maxLength: protoByteLength) + guard actualByteLength == protoByteLength else { + return .invalidByteLengthDelimiter + } + let protoBytes = Data(bytes: bytes, count: protoByteLength) + do { + let protoObject = try initializer(protoBytes) + return .success(protoObject, moreBytesAvailable: inputStream.hasBytesAvailable) + } catch { + return .protoDeserializationError(error) + } + } + + /// Private: Parse the next raw varint from the input. + /// + /// Based on SwiftProtobuf.BinaryDecoder.decodeVarint() + private func decodeVarint() -> UInt64? { + let nextByte = UnsafeMutablePointer.allocate(capacity: 1) + inputStream.read(nextByte, maxLength: 1) + var c = nextByte[0] + if c & 0x80 == 0 { + return UInt64(c) + } + var value = UInt64(c & 0x7f) + var shift = UInt64(7) + while true { + if !inputStream.hasBytesAvailable || shift > 63 { + return nil + } + inputStream.read(nextByte, maxLength: 1) + c = nextByte[0] + value |= UInt64(c & 0x7f) << shift + if c & 0x80 == 0 { + return value + } + shift += 7 + } + } +} diff --git a/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoOutputStream.swift b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoOutputStream.swift new file mode 100644 index 00000000000..12e6a094e06 --- /dev/null +++ b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoOutputStream.swift @@ -0,0 +1,101 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +extension CloudBackup { + public enum ProtoOutputStreamWriteResult { + case success + /// Unable to serialize the provided proto object. + /// Should never happen, and catastrophic if it does. + case protoSerializationError(Error) + /// Failure writing at file I/O level. + case fileIOError(Error) + } +} + +/** + * Output stream for reading and writing a backup file on disk. + * + * The backup file is just a sequence of serialized proto bytes, back to back, delimited by varint + * byte sizes so we know how much to read into memory to deserialize the next proto. + * The output stream abstracts over this, and allows callers to just think in terms of "frames", + * the individual proto objects that we write one at a time. + */ +public protocol CloudBackupProtoOutputStream { + + /// Write a header (BakckupInfo) to the backup file. + /// It is the caller's responsibility to ensure this is always written, and is the first thing written, + /// in order to produce a valid backup file. + func writeHeader(_ header: BackupProtoBackupInfo) -> CloudBackup.ProtoOutputStreamWriteResult + + /// Write a frame to the backup file. + func writeFrame(_ frame: BackupProtoFrame) -> CloudBackup.ProtoOutputStreamWriteResult + + /// Closes the output stream. + /// - Returns: URL of the file written to. + func closeFileStream() -> URL +} + +internal class CloudBackupProtoOutputStreamImpl: OWSChunkedOutputStream, CloudBackupProtoOutputStream { + + private var outputStream: OutputStream + private var streamRunloop: RunLoop + private var outputStreamDelegate: StreamDelegate + private var fileUrl: URL + + internal init( + outputStream: OutputStream, + streamRunloop: RunLoop, + outputStreamDelegate: StreamDelegate, + fileURL: URL + ) { + self.outputStream = outputStream + self.streamRunloop = streamRunloop + self.outputStreamDelegate = outputStreamDelegate + self.fileUrl = fileURL + super.init(outputStream: outputStream) + } + + internal func writeHeader(_ header: BackupProtoBackupInfo) -> CloudBackup.ProtoOutputStreamWriteResult { + let bytes: Data + do { + bytes = try header.serializedData() + } catch { + return .protoSerializationError(error) + } + let byteLength = UInt32(bytes.count) + do { + try writeVariableLengthUInt32(byteLength) + try writeData(bytes) + } catch { + return .fileIOError(error) + } + return .success + } + + internal func writeFrame(_ frame: BackupProtoFrame) -> CloudBackup.ProtoOutputStreamWriteResult { + let bytes: Data + do { + bytes = try frame.serializedData() + } catch { + return .protoSerializationError(error) + } + let byteLength = UInt32(bytes.count) + do { + try writeVariableLengthUInt32(byteLength) + try writeData(bytes) + } catch { + return .fileIOError(error) + } + return .success + } + + public func closeFileStream() -> URL { + outputStream.remove(from: streamRunloop, forMode: .default) + outputStream.close() + return fileUrl + } +} diff --git a/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoStreamProvider.swift b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoStreamProvider.swift new file mode 100644 index 00000000000..1aaa31dbbdf --- /dev/null +++ b/SignalServiceKit/CloudBackup/FileStreams/CloudBackupProtoStreamProvider.swift @@ -0,0 +1,110 @@ +// +// Copyright 2023 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only +// + +import Foundation + +extension CloudBackup { + public enum OpenProtoOutputStreamResult { + case success(CloudBackupProtoOutputStream) + /// Unable to open a file stream due to file I/O errors. + case unableToOpenFileStream + } + + public enum OpenProtoInputStreamResult { + case success(CloudBackupProtoInputStream) + /// The provided target file was not found on disk. + case fileNotFound + /// Unable to open a file stream due to file I/O errors. + case unableToOpenFileStream + } +} + +/** + * Creates input and output streams for reading and writing to the backup file on disk. + * + * The backup file is just a sequence of serialized proto bytes, back to back, delimited by varint + * byte sizes so we know how much to read into memory to deserialize the next proto. + * The input and output streams abstract over this, and allow callers to just think in terms of "frames", + * the individual proto objects that we read and write one at a time. + */ +public protocol CloudBackupProtoStreamProvider { + + /// Open an output stream to write a backup to a file on disk. + /// The caller becomes the owner of the stream, and is responsible for closing it once finished. + func openOutputFileStream() -> CloudBackup.OpenProtoOutputStreamResult + + /// Open an input stream to read a backup from a file on disk. + /// The caller becomes the owner of the stream, and is responsible for closing it once finished. + func openInputFileStream(fileURL: URL) -> CloudBackup.OpenProtoInputStreamResult +} + +public class CloudBackupProtoStreamProviderImpl: CloudBackupProtoStreamProvider { + + public init() {} + + public func openOutputFileStream() -> CloudBackup.OpenProtoOutputStreamResult { + let fileUrl = OWSFileSystem.temporaryFileUrl(isAvailableWhileDeviceLocked: true) + guard let outputStream = OutputStream(url: fileUrl, append: false) else { + owsFailDebug("Could not open outputStream.") + return .unableToOpenFileStream + } + let outputStreamDelegate = StreamDelegate() + outputStream.delegate = outputStreamDelegate + let streamRunloop = RunLoop.current + outputStream.schedule(in: streamRunloop, forMode: .default) + outputStream.open() + guard outputStream.streamStatus == .open else { + owsFailDebug("Could not open outputStream.") + return .unableToOpenFileStream + } + + let cloudBackupOutputStream = CloudBackupProtoOutputStreamImpl( + outputStream: outputStream, + streamRunloop: streamRunloop, + outputStreamDelegate: outputStreamDelegate, + fileURL: fileUrl + ) + return .success(cloudBackupOutputStream) + } + + public func openInputFileStream(fileURL: URL) -> CloudBackup.OpenProtoInputStreamResult { + guard OWSFileSystem.fileOrFolderExists(url: fileURL) else { + owsFailDebug("Missing file!") + return .fileNotFound + } + guard let inputStream = InputStream(url: fileURL) else { + owsFailDebug("Unable to open input stream") + return .unableToOpenFileStream + } + let inputStreamDelegate = StreamDelegate() + inputStream.delegate = inputStreamDelegate + let streamRunloop = RunLoop.current + inputStream.schedule(in: streamRunloop, forMode: .default) + inputStream.open() + guard inputStream.streamStatus == .open else { + owsFailDebug("Could not open input stream.") + return .unableToOpenFileStream + } + + let cloudBackupInputStream = CloudBackupProtoInputStreamImpl( + inputStream: inputStream, + streamRunloop: streamRunloop, + inputStreamDelegate: inputStreamDelegate + ) + return .success(cloudBackupInputStream) + } + + fileprivate class StreamDelegate: NSObject, Foundation.StreamDelegate { + private let _hadError = AtomicBool(false) + public var hadError: Bool { _hadError.get() } + + @objc + public func stream(_ stream: Stream, handle eventCode: Stream.Event) { + if eventCode == .errorOccurred { + _hadError.set(true) + } + } + } +} diff --git a/SignalServiceKit/Dependencies/DependenciesBridge.swift b/SignalServiceKit/Dependencies/DependenciesBridge.swift index ac9dc195254..e8e0cc8b981 100644 --- a/SignalServiceKit/Dependencies/DependenciesBridge.swift +++ b/SignalServiceKit/Dependencies/DependenciesBridge.swift @@ -584,16 +584,20 @@ public class DependenciesBridge { ) self.cloudBackupManager = CloudBackupManagerImpl( - blockingManager: CloudBackup.Wrappers.BlockingManager(blockingManager), dateProvider: dateProvider, db: db, dmConfigurationStore: disappearingMessagesConfigurationStore, - groupsV2: groupsV2, - profileManager: CloudBackup.Wrappers.ProfileManager(profileManager), - recipientHidingManager: recipientHidingManager, - signalRecipientFetcher: CloudBackup.Wrappers.SignalRecipientFetcher(), - storyFinder: CloudBackup.Wrappers.StoryFinder(), - streamProvider: CloudBackupOutputStreamProviderImpl(), + recipientArchiver: CloudBackupRecipientArchiverImpl( + blockingManager: CloudBackup.Wrappers.BlockingManager(blockingManager), + groupsV2: groupsV2, + profileManager: CloudBackup.Wrappers.ProfileManager(profileManager), + recipientHidingManager: recipientHidingManager, + signalRecipientFetcher: CloudBackup.Wrappers.SignalRecipientFetcher(), + storyFinder: CloudBackup.Wrappers.StoryFinder(), + tsAccountManager: tsAccountManager, + tsThreadFetcher: CloudBackup.Wrappers.TSThreadFetcher() + ), + streamProvider: CloudBackupProtoStreamProviderImpl(), tsAccountManager: tsAccountManager, tsInteractionFetcher: CloudBackup.Wrappers.TSInteractionFetcher(), tsThreadFetcher: CloudBackup.Wrappers.TSThreadFetcher() diff --git a/SignalServiceKit/protobuf/Backup.proto b/SignalServiceKit/protobuf/Backup.proto index 0fbeaebe997..5bcc4e64e17 100644 --- a/SignalServiceKit/protobuf/Backup.proto +++ b/SignalServiceKit/protobuf/Backup.proto @@ -14,7 +14,7 @@ message BackupInfo { // @required optional uint64 version = 1; // @required - optional uint64 backupTime = 2; + optional uint64 backupTimeMs = 2; } message Frame { @@ -30,8 +30,8 @@ message Frame { message AccountData { enum PhoneNumberSharingMode { - EVERYBODY = 0; - CONTACTS_ONLY = 1; + UNKNOWN = 0; + EVERYBODY = 1; NOBODY = 2; } message UsernameLink { @@ -56,79 +56,59 @@ message AccountData { message AccountSettings { // @required - optional bool noteToSelfArchived = 1; - // @required - optional bool readReceipts = 2; - // @required - optional bool sealedSenderIndicators = 3; + optional bool readReceipts = 1; // @required - optional bool typingIndicators = 4; + optional bool sealedSenderIndicators = 2; // @required - optional bool proxiedLinkPreviews = 5; + optional bool typingIndicators = 3; // @required - optional bool noteToSelfMarkedUnread = 6; + optional bool noteToSelfMarkedUnread = 4; // @required - optional bool linkPreviews = 7; + optional bool linkPreviews = 5; // @required - optional bool unlistedPhoneNumber = 8; + optional bool unlistedPhoneeumber = 6; // @required - optional bool preferContactAvatars = 9; + optional bool preferContactAvatars = 7; // @required - optional uint32 universalExpireTimer = 10; - repeated string preferredReactionEmoji = 11; + optional uint32 universalExpireTimer = 8; + repeated string preferredReactionEmoji = 9; // @required - optional bool displayBadgesOnProfile = 12; + optional bool displayBadgesOnProfile = 10; // @required - optional bool keepMutedChatsArchived = 13; + optional bool keepMutedChatsArchived = 11; // @required - optional bool myStoriesPrivacyHasBeenSet = 14; // Removed 'has' prefix on spec definition to avoid name conflict. + optional bool myStoriesPrivacyHasBeenSet = 12; // Removed 'has' prefix on spec definition to avoid name conflict. // @required - optional bool onboardingStoryHasBeenViewed = 15; // Removed 'has' prefix on spec definition to avoid name conflict. + optional bool onboardingStoryHasBeenViewed = 13; // Removed 'has' prefix on spec definition to avoid name conflict. // @required - optional bool storiesDisabled = 16; - optional bool storyViewReceiptsEnabled = 17; + optional bool storiesDisabled = 14; + optional bool storyViewReceiptsEnabled = 15; // @required - optional bool onboardingStoryHasBeenRead = 18; // Removed 'has' prefix on spec definition to avoid name conflict. + optional bool groupStoryEducationSheetHasBeenSeen = 16; // Removed 'has' prefix on spec definition to avoid name conflict. // @required - optional bool groupStoryEducationSheetHasBeenSet = 19; // Removed 'has' prefix on spec definition to avoid name conflict. - // @required - optional bool usernameOnboardingHasBeenCompleted = 20; // Removed 'has' prefix on spec definition to avoid name conflict. - optional PhoneNumberSharingMode phoneNumberSharingMode = 21; + optional bool usernameOnboardingHasBeenCompleted = 17; // Removed 'has' prefix on spec definition to avoid name conflict. + optional PhoneNumberSharingMode phoneNumberSharingMode = 18; } // @required - optional bytes aciIdentityPublicKey = 1; - // @required - optional bytes aciIdentityPrivateKey = 2; - // @required - optional bytes pniIdentityPublicKey = 3; - // @required - optional bytes pniIdentityPrivateKey = 4; - // @required - optional bytes profileKey = 5; - optional string username = 6; - // @required - optional UsernameLink usernameLink = 7; - // @required - optional string givenName = 8; + optional bytes profileKey = 1; + optional string username = 2; // @required - optional string familyName = 9; + optional UsernameLink usernameLink = 3; // @required - optional string avatarPath = 10; + optional string givenName = 4; // @required - optional bytes subscriberId = 11; + optional string familyName = 5; // @required - optional string subscriberCurrencyCode = 12; + optional string avatarPath = 6; // @required - optional bool subscriptionManuallyCancelled = 13; + optional bytes subscriberId = 7; // @required - optional AccountSettings accountSettings = 14; + optional string subscriberCurrencyCode = 8; // @required - optional bytes aci = 15; + optional bool subscriptionManuallyCancelled = 9; // @required - optional bytes pni = 16; - // @required - optional uint64 e164 = 17; + optional AccountSettings accountSettings = 10; } message Recipient { @@ -139,10 +119,17 @@ message Recipient { optional Group group = 3; optional DistributionList distributionList = 4; optional SelfRecipient selfRecipient = 5; + optional ReleaseNotes releaseNotes = 6; // } } message Contact { + enum Registered { + UNKNOWN = 0; + REGISTERED = 1; + NOT_REGISTERED = 2; + } + optional bytes aci = 1; // should be 16 bytes optional bytes pni = 2; // should be 16 bytes optional string username = 3; @@ -151,11 +138,6 @@ message Contact { optional bool blocked = 5; // @required optional bool hidden = 6; - enum Registered { - UNKNOWN = 0; - REGISTERED = 1; - NOT_REGISTERED = 2; - } optional Registered registered = 7; // @required optional uint64 unregisteredTimestamp = 8; @@ -164,9 +146,8 @@ message Contact { optional bool profileSharing = 10; optional string profileGivenName = 11; optional string profileFamilyName = 12; - optional string profileJoinedName = 13; // @required - optional bool hideStory = 14; + optional bool hideStory = 13; } message Group { @@ -188,6 +169,9 @@ message Group { message SelfRecipient { } +message ReleaseNotes { +} + message Chat { // @required optional uint64 id = 1; // generated id for reference only within this file @@ -196,18 +180,26 @@ message Chat { // @required optional bool archived = 3; // @required - optional bool pinned = 4; + optional uint32 pinnedOrder = 4; // 0 = unpinned, otherwise chat is considered pinned and will be displayed in ascending order // @required - optional uint64 expirationTimer = 5; + optional uint64 expirationTimerMs = 5; // @required - optional uint64 muteUntil = 6; + optional uint64 muteUntilMs = 6; // @required optional bool markedUnread = 7; // @required optional bool dontNotifyForMentionsIfMuted = 8; + optional FilePointer wallpaper = 9; } message DistributionList { + enum PrivacyMode { + UNKNOWN = 0; + ONLY_WITH = 1; + ALL_EXCEPT = 2; + ALL = 3; + } + // @required optional string name = 1; // @required @@ -216,15 +208,8 @@ message DistributionList { optional bool allowReplies = 3; // @required optional uint64 deletionTimestamp = 4; - // @required - optional bool isUnknown = 5; - enum PrivacyMode { - ONLY_WITH = 0; - ALL_EXCEPT = 1; - ALL = 2; - } - optional PrivacyMode privacyMode = 6; - repeated uint64 memberRecipientIds = 7; // generated recipient id + optional PrivacyMode privacyMode = 5; + repeated uint64 memberRecipientIds = 6; // generated recipient id } message Identity { @@ -243,16 +228,31 @@ message Identity { } message Call { + enum Type { + UNKNOWN_TYPE = 0; + AUDIO_CALL = 1; + VIDEO_CALL = 2; + GROUP_CALL = 3; + AD_HOC_CALL = 4; + } + + enum Event { + UNKNOWN_EVENT = 0; + OUTGOING = 1; // 1:1 calls only + ACCEPTED = 2; // 1:1 and group calls. Group calls: You accepted a ring. + NOT_ACCEPTED = 3; // 1:1 calls only, + MISSED = 4; // 1:1 and group. Group calls: The remote ring has expired or was cancelled by the ringer. + DELETE = 5; // 1:1 and Group/Ad-Hoc Calls. + GENERIC_GROUP_CALL = 6; // Group/Ad-Hoc Calls only. Initial state + JOINED = 7; // Group Calls: User has joined the group call. + DECLINED = 8; // Group Calls: If you declined a ring. + OUTGOING_RING = 9; // Group Calls: If you are ringing a group. + } + // @required optional uint64 callId = 1; // @required - optional uint64 peerRecipientId = 2; - enum Type { - AUDIO_CALL = 0; - VIDEO_CALL = 1; - GROUP_CALL = 2; - AD_HOC_CALL = 3; - } + optional uint64 conversationRecipientId = 2; optional Type type = 3; // @required optional bool outgoing = 4; @@ -260,29 +260,19 @@ message Call { optional uint64 timestamp = 5; // @required optional uint64 ringerRecipientId = 6; - enum Event { - OUTGOING = 0; // 1:1 calls only - ACCEPTED = 1; // 1:1 and group calls. Group calls: You accepted a ring. - NOT_ACCEPTED = 2; // 1:1 calls only, - MISSED = 3; // 1:1 and group/ad-hoc calls. Group calls: The remote ring has expired or was cancelled by the ringer. - DELETE = 4; // 1:1 and Group/Ad-Hoc Calls. - GENERIC_GROUP_CALL = 5; // Group/Ad-Hoc Calls only. Initial state - JOINED = 6; // Group Calls: User has joined the group call. - RINGING = 7; // Group Calls: If a ring was requested by another user. - DECLINED = 8; // Group Calls: If you declined a ring. - OUTGOING_RING = 9; // Group Calls: If you are ringing a group. - } optional Event event = 7; } message ChatItem { message IncomingMessageDetails { // @required - optional uint64 dateServerSent = 1; + optional uint64 dateReceived = 1; // @required - optional bool read = 2; + optional uint64 dateServerSent = 2; // @required - optional bool sealedSender = 3; + optional bool read = 3; + // @required + optional bool sealedSender = 4; } message OutgoingMessageDetails { @@ -295,38 +285,37 @@ message ChatItem { optional uint64 authorId = 2; // recipient id // @required optional uint64 dateSent = 3; + optional uint64 expireStartMs = 4; // timestamp of when expiration timer started ticking down + optional uint64 expiresInMs = 5; // how long timer of message is (ms) + repeated ChatItem revisions = 6; // ordered from oldest to newest // @required - optional uint64 dateReceived = 4; - optional uint64 expireStart = 5; // timestamp of when expiration timer started ticking down - optional uint64 expiresIn = 6; // how long timer of message is (ms) - repeated ChatItem revisions = 7; - // @required - optional bool sms = 8; + optional bool sms = 7; // oneof directionalDetails { - optional IncomingMessageDetails incoming = 9; - optional OutgoingMessageDetails outgoing = 10; + optional IncomingMessageDetails incoming = 8; + optional OutgoingMessageDetails outgoing = 9; // } // oneof item { - optional StandardMessage standardMessage = 11; - optional ContactMessage contactMessage = 12; - optional VoiceMessage voiceMessage = 13; - optional StickerMessage stickerMessage = 14; - optional RemoteDeletedMessage remoteDeletedMessage = 15; - optional UpdateMessage updateMessage = 16; + optional StandardMessage standardMessage = 10; + optional ContactMessage contactMessage = 11; + optional VoiceMessage voiceMessage = 12; + optional StickerMessage stickerMessage = 13; + optional RemoteDeletedMessage remoteDeletedMessage = 14; + optional UpdateMessage updateMessage = 15; // } } message SendStatus { enum Status { - FAILED = 0; - PENDING = 1; - SENT = 2; - DELIVERED = 3; - READ = 4; - VIEWED = 5; - SKIPPED = 6; // e.g. user in group was blocked, so we skipped sending to them + UNKNOWN = 0; + FAILED = 1; + PENDING = 2; + SENT = 3; + DELIVERED = 4; + READ = 5; + VIEWED = 6; + SKIPPED = 7; // e.g. user in group was blocked, so we skipped sending to them } // @required optional uint64 recipientId = 1; @@ -350,9 +339,9 @@ message Text { message StandardMessage { optional Quote quote = 1; optional Text text = 2; - repeated AttachmentPointer attachments = 3; - optional LinkPreview linkPreview = 4; - optional AttachmentPointer longText = 5; + repeated FilePointer attachments = 3; + repeated LinkPreview linkPreview = 4; + optional FilePointer longText = 5; repeated Reaction reactions = 6; } @@ -373,10 +362,11 @@ message ContactAttachment { message Phone { enum Type { - HOME = 0; - MOBILE = 1; - WORK = 2; - CUSTOM = 3; + UNKNOWN = 0; + HOME = 1; + MOBILE = 2; + WORK = 3; + CUSTOM = 4; } optional string value = 1; @@ -386,10 +376,11 @@ message ContactAttachment { message Email { enum Type { - HOME = 0; - MOBILE = 1; - WORK = 2; - CUSTOM = 3; + UNKNOWN = 0; + HOME = 1; + MOBILE = 2; + WORK = 3; + CUSTOM = 4; } optional string value = 1; @@ -399,9 +390,10 @@ message ContactAttachment { message PostalAddress { enum Type { - HOME = 0; - WORK = 1; - CUSTOM = 2; + UNKNOWN = 0; + HOME = 1; + WORK = 2; + CUSTOM = 3; } optional Type type = 1; @@ -416,8 +408,8 @@ message ContactAttachment { } message Avatar { - optional AttachmentPointer avatar = 1; - optional bool isProfile = 2; + // @required + optional FilePointer avatar = 1; } optional Name name = 1; @@ -432,14 +424,14 @@ message DocumentMessage { // @required optional Text text = 1; // @required - optional AttachmentPointer document = 2; + optional FilePointer document = 2; repeated Reaction reactions = 3; } message VoiceMessage { optional Quote quote = 1; // @required - optional AttachmentPointer audio = 2; + optional FilePointer audio = 2; repeated Reaction reactions = 3; } @@ -461,62 +453,85 @@ message ScheduledMessage { } message Sticker { + // @required optional bytes packId = 1; + // @required optional bytes packKey = 2; + // @required optional uint32 stickerId = 3; - optional AttachmentPointer data = 4; - optional string emoji = 5; + optional string emoji = 4; } message LinkPreview { + // @required optional string url = 1; optional string title = 2; - optional AttachmentPointer image = 3; + optional FilePointer image = 3; optional string descriptionText = 4; optional uint64 date = 5; } -message AttachmentPointer { +message FilePointer { + message BackupLocator { + // @required + optional string mediaName = 1; + // @required + optional uint32 cdnNumber = 2; + } + + message AttachmentLocator { + // @required + optional string cdnKey = 1; + // @required + optional uint32 cdnNumber = 2; + // @required + optional uint64 uploadTimestamp = 3; + } + + message LegacyAttachmentLocator { + } + enum Flags { VOICE_MESSAGE = 0; BORDERLESS = 1; GIF = 2; } - // oneof attachmentIdentifier { - optional fixed64 cdnId = 1; - optional string cdnKey = 2; + // oneof locator { + optional BackupLocator backupLocator = 1; + optional AttachmentLocator attachmentLocator= 2; + optional LegacyAttachmentLocator legacyAttachmentLocator = 3; // } - optional string contentType = 3; optional bytes key = 4; - optional uint32 size = 5; - optional bytes digest = 6; - optional bytes incrementalMac = 7; - optional bytes incrementalMacChunkSize = 8; - optional string fileName = 9; - optional uint32 flags = 10; - optional uint32 width = 11; - optional uint32 height = 12; - optional string caption = 13; - optional string blurHash = 14; - optional uint64 uploadTimestamp = 15; - optional uint32 cdnNumber = 16; + optional string contentType = 5; + optional uint32 size = 6; + optional bytes digest = 7; + optional bytes incrementalMac = 8; + optional bytes incrementalMacChunkSize = 9; + optional string fileName = 10; + optional uint32 flags = 11; + optional uint32 width = 12; + optional uint32 height = 13; + optional string caption = 14; + optional string blurHash = 15; } message Quote { enum Type { - NORMAL = 0; - GIFTBADGE = 1; + UNKNOWN = 0; + NORMAL = 1; + GIFTBADGE = 2; } message QuotedAttachment { optional string contentType = 1; optional string fileName = 2; - optional AttachmentPointer thumbnail = 3; + optional FilePointer thumbnail = 3; } - optional uint64 id = 1; + optional uint64 targetSentTimestamp = 1; // null if the target message could not be found at time of quote insert + // @required optional uint64 authorId = 2; optional string text = 3; repeated QuotedAttachment attachments = 4; @@ -538,7 +553,7 @@ message BodyRange { optional uint32 length = 2; // oneof associatedValue { - optional string mentionAci = 3; + optional bytes mentionAci = 3; optional Style style = 4; // } } @@ -576,49 +591,51 @@ message CallingMessage { message CallMessage { enum Type { - INCOMING_AUDIO_CALL = 0; - INCOMING_VIDEO_CALL = 1; - OUTGOING_AUDIO_CALL = 2; - OUTGOING_VIDEO_CALL = 3; - MISSED_AUDIO_CALL = 4; - MISSED_VIDEO_CALL = 5; + UNKNOWN = 0; + INCOMING_AUDIO_CALL = 1; + INCOMING_VIDEO_CALL = 2; + OUTGOING_AUDIO_CALL = 3; + OUTGOING_VIDEO_CALL = 4; + MISSED_AUDIO_CALL = 5; + MISSED_VIDEO_CALL = 6; } } message GroupCallMessage { // @required - optional bytes startedCallUuid = 1; + optional bytes startedCallAci = 1; // @required optional uint64 startedCallTimestamp = 2; - repeated bytes inCallUuids = 3; - // @required - optional bool isCallFull = 4; + repeated bytes inCallAcis = 3; } message SimpleUpdate { enum Type { - JOINED_SIGNAL = 0; - IDENTITY_UPDATE = 1; - IDENTITY_VERIFIED = 2; - IDENTITY_DEFAULT = 3; // marking as unverified - CHANGE_NUMBER = 4; - BOOST_REQUEST = 5; - END_SESSION = 6; - CHAT_SESSION_REFRESH = 7; - BAD_DECRYPT = 8; - PAYMENTS_ACTIVATED = 9; - PAYMENT_ACTIVATION_REQUEST = 10; + UNKNOWN = 0; + JOINED_SIGNAL = 1; + IDENTITY_UPDATE = 2; + IDENTITY_VERIFIED = 3; + IDENTITY_DEFAULT = 4; // marking as unverified + CHANGE_NUMBER = 5; + BOOST_REQUEST = 6; + END_SESSION = 7; + CHAT_SESSION_REFRESH = 8; + BAD_DECRYPT = 9; + PAYMENTS_ACTIVATED = 10; + PAYMENT_ACTIVATION_REQUEST = 11; } + + optional Type type = 1; } message GroupDescriptionUpdate { // @required - optional string body = 1; + optional string newDescription = 1; } message ExpirationTimerChange { // @required - optional uint32 expiresIn = 1; + optional uint32 expiresInMs = 1; } message ProfileChange { @@ -652,7 +669,7 @@ message StickerPack { message StickerPackSticker { // @required - optional AttachmentPointer data = 1; + optional FilePointer data = 1; // @required optional string emoji = 2; } diff --git a/SignalServiceKit/src/Protos/Generated/Backup.pb.swift b/SignalServiceKit/src/Protos/Generated/Backup.pb.swift index b1657e08d83..94ff6a3103a 100644 --- a/SignalServiceKit/src/Protos/Generated/Backup.pb.swift +++ b/SignalServiceKit/src/Protos/Generated/Backup.pb.swift @@ -48,21 +48,21 @@ struct BackupProtos_BackupInfo { mutating func clearVersion() {self._version = nil} /// @required - var backupTime: UInt64 { - get {return _backupTime ?? 0} - set {_backupTime = newValue} + var backupTimeMs: UInt64 { + get {return _backupTimeMs ?? 0} + set {_backupTimeMs = newValue} } - /// Returns true if `backupTime` has been explicitly set. - var hasBackupTime: Bool {return self._backupTime != nil} - /// Clears the value of `backupTime`. Subsequent reads from it will return its default value. - mutating func clearBackupTime() {self._backupTime = nil} + /// Returns true if `backupTimeMs` has been explicitly set. + var hasBackupTimeMs: Bool {return self._backupTimeMs != nil} + /// Clears the value of `backupTimeMs`. Subsequent reads from it will return its default value. + mutating func clearBackupTimeMs() {self._backupTimeMs = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} fileprivate var _version: UInt64? = nil - fileprivate var _backupTime: UInt64? = nil + fileprivate var _backupTimeMs: UInt64? = nil } struct BackupProtos_Frame { @@ -138,191 +138,121 @@ struct BackupProtos_AccountData { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// @required - var aciIdentityPublicKey: Data { - get {return _storage._aciIdentityPublicKey ?? Data()} - set {_uniqueStorage()._aciIdentityPublicKey = newValue} - } - /// Returns true if `aciIdentityPublicKey` has been explicitly set. - var hasAciIdentityPublicKey: Bool {return _storage._aciIdentityPublicKey != nil} - /// Clears the value of `aciIdentityPublicKey`. Subsequent reads from it will return its default value. - mutating func clearAciIdentityPublicKey() {_uniqueStorage()._aciIdentityPublicKey = nil} - - /// @required - var aciIdentityPrivateKey: Data { - get {return _storage._aciIdentityPrivateKey ?? Data()} - set {_uniqueStorage()._aciIdentityPrivateKey = newValue} - } - /// Returns true if `aciIdentityPrivateKey` has been explicitly set. - var hasAciIdentityPrivateKey: Bool {return _storage._aciIdentityPrivateKey != nil} - /// Clears the value of `aciIdentityPrivateKey`. Subsequent reads from it will return its default value. - mutating func clearAciIdentityPrivateKey() {_uniqueStorage()._aciIdentityPrivateKey = nil} - - /// @required - var pniIdentityPublicKey: Data { - get {return _storage._pniIdentityPublicKey ?? Data()} - set {_uniqueStorage()._pniIdentityPublicKey = newValue} - } - /// Returns true if `pniIdentityPublicKey` has been explicitly set. - var hasPniIdentityPublicKey: Bool {return _storage._pniIdentityPublicKey != nil} - /// Clears the value of `pniIdentityPublicKey`. Subsequent reads from it will return its default value. - mutating func clearPniIdentityPublicKey() {_uniqueStorage()._pniIdentityPublicKey = nil} - - /// @required - var pniIdentityPrivateKey: Data { - get {return _storage._pniIdentityPrivateKey ?? Data()} - set {_uniqueStorage()._pniIdentityPrivateKey = newValue} - } - /// Returns true if `pniIdentityPrivateKey` has been explicitly set. - var hasPniIdentityPrivateKey: Bool {return _storage._pniIdentityPrivateKey != nil} - /// Clears the value of `pniIdentityPrivateKey`. Subsequent reads from it will return its default value. - mutating func clearPniIdentityPrivateKey() {_uniqueStorage()._pniIdentityPrivateKey = nil} - /// @required var profileKey: Data { - get {return _storage._profileKey ?? Data()} - set {_uniqueStorage()._profileKey = newValue} + get {return _profileKey ?? Data()} + set {_profileKey = newValue} } /// Returns true if `profileKey` has been explicitly set. - var hasProfileKey: Bool {return _storage._profileKey != nil} + var hasProfileKey: Bool {return self._profileKey != nil} /// Clears the value of `profileKey`. Subsequent reads from it will return its default value. - mutating func clearProfileKey() {_uniqueStorage()._profileKey = nil} + mutating func clearProfileKey() {self._profileKey = nil} var username: String { - get {return _storage._username ?? String()} - set {_uniqueStorage()._username = newValue} + get {return _username ?? String()} + set {_username = newValue} } /// Returns true if `username` has been explicitly set. - var hasUsername: Bool {return _storage._username != nil} + var hasUsername: Bool {return self._username != nil} /// Clears the value of `username`. Subsequent reads from it will return its default value. - mutating func clearUsername() {_uniqueStorage()._username = nil} + mutating func clearUsername() {self._username = nil} /// @required var usernameLink: BackupProtos_AccountData.UsernameLink { - get {return _storage._usernameLink ?? BackupProtos_AccountData.UsernameLink()} - set {_uniqueStorage()._usernameLink = newValue} + get {return _usernameLink ?? BackupProtos_AccountData.UsernameLink()} + set {_usernameLink = newValue} } /// Returns true if `usernameLink` has been explicitly set. - var hasUsernameLink: Bool {return _storage._usernameLink != nil} + var hasUsernameLink: Bool {return self._usernameLink != nil} /// Clears the value of `usernameLink`. Subsequent reads from it will return its default value. - mutating func clearUsernameLink() {_uniqueStorage()._usernameLink = nil} + mutating func clearUsernameLink() {self._usernameLink = nil} /// @required var givenName: String { - get {return _storage._givenName ?? String()} - set {_uniqueStorage()._givenName = newValue} + get {return _givenName ?? String()} + set {_givenName = newValue} } /// Returns true if `givenName` has been explicitly set. - var hasGivenName: Bool {return _storage._givenName != nil} + var hasGivenName: Bool {return self._givenName != nil} /// Clears the value of `givenName`. Subsequent reads from it will return its default value. - mutating func clearGivenName() {_uniqueStorage()._givenName = nil} + mutating func clearGivenName() {self._givenName = nil} /// @required var familyName: String { - get {return _storage._familyName ?? String()} - set {_uniqueStorage()._familyName = newValue} + get {return _familyName ?? String()} + set {_familyName = newValue} } /// Returns true if `familyName` has been explicitly set. - var hasFamilyName: Bool {return _storage._familyName != nil} + var hasFamilyName: Bool {return self._familyName != nil} /// Clears the value of `familyName`. Subsequent reads from it will return its default value. - mutating func clearFamilyName() {_uniqueStorage()._familyName = nil} + mutating func clearFamilyName() {self._familyName = nil} /// @required var avatarPath: String { - get {return _storage._avatarPath ?? String()} - set {_uniqueStorage()._avatarPath = newValue} + get {return _avatarPath ?? String()} + set {_avatarPath = newValue} } /// Returns true if `avatarPath` has been explicitly set. - var hasAvatarPath: Bool {return _storage._avatarPath != nil} + var hasAvatarPath: Bool {return self._avatarPath != nil} /// Clears the value of `avatarPath`. Subsequent reads from it will return its default value. - mutating func clearAvatarPath() {_uniqueStorage()._avatarPath = nil} + mutating func clearAvatarPath() {self._avatarPath = nil} /// @required var subscriberID: Data { - get {return _storage._subscriberID ?? Data()} - set {_uniqueStorage()._subscriberID = newValue} + get {return _subscriberID ?? Data()} + set {_subscriberID = newValue} } /// Returns true if `subscriberID` has been explicitly set. - var hasSubscriberID: Bool {return _storage._subscriberID != nil} + var hasSubscriberID: Bool {return self._subscriberID != nil} /// Clears the value of `subscriberID`. Subsequent reads from it will return its default value. - mutating func clearSubscriberID() {_uniqueStorage()._subscriberID = nil} + mutating func clearSubscriberID() {self._subscriberID = nil} /// @required var subscriberCurrencyCode: String { - get {return _storage._subscriberCurrencyCode ?? String()} - set {_uniqueStorage()._subscriberCurrencyCode = newValue} + get {return _subscriberCurrencyCode ?? String()} + set {_subscriberCurrencyCode = newValue} } /// Returns true if `subscriberCurrencyCode` has been explicitly set. - var hasSubscriberCurrencyCode: Bool {return _storage._subscriberCurrencyCode != nil} + var hasSubscriberCurrencyCode: Bool {return self._subscriberCurrencyCode != nil} /// Clears the value of `subscriberCurrencyCode`. Subsequent reads from it will return its default value. - mutating func clearSubscriberCurrencyCode() {_uniqueStorage()._subscriberCurrencyCode = nil} + mutating func clearSubscriberCurrencyCode() {self._subscriberCurrencyCode = nil} /// @required var subscriptionManuallyCancelled: Bool { - get {return _storage._subscriptionManuallyCancelled ?? false} - set {_uniqueStorage()._subscriptionManuallyCancelled = newValue} + get {return _subscriptionManuallyCancelled ?? false} + set {_subscriptionManuallyCancelled = newValue} } /// Returns true if `subscriptionManuallyCancelled` has been explicitly set. - var hasSubscriptionManuallyCancelled: Bool {return _storage._subscriptionManuallyCancelled != nil} + var hasSubscriptionManuallyCancelled: Bool {return self._subscriptionManuallyCancelled != nil} /// Clears the value of `subscriptionManuallyCancelled`. Subsequent reads from it will return its default value. - mutating func clearSubscriptionManuallyCancelled() {_uniqueStorage()._subscriptionManuallyCancelled = nil} + mutating func clearSubscriptionManuallyCancelled() {self._subscriptionManuallyCancelled = nil} /// @required var accountSettings: BackupProtos_AccountData.AccountSettings { - get {return _storage._accountSettings ?? BackupProtos_AccountData.AccountSettings()} - set {_uniqueStorage()._accountSettings = newValue} + get {return _accountSettings ?? BackupProtos_AccountData.AccountSettings()} + set {_accountSettings = newValue} } /// Returns true if `accountSettings` has been explicitly set. - var hasAccountSettings: Bool {return _storage._accountSettings != nil} + var hasAccountSettings: Bool {return self._accountSettings != nil} /// Clears the value of `accountSettings`. Subsequent reads from it will return its default value. - mutating func clearAccountSettings() {_uniqueStorage()._accountSettings = nil} - - /// @required - var aci: Data { - get {return _storage._aci ?? Data()} - set {_uniqueStorage()._aci = newValue} - } - /// Returns true if `aci` has been explicitly set. - var hasAci: Bool {return _storage._aci != nil} - /// Clears the value of `aci`. Subsequent reads from it will return its default value. - mutating func clearAci() {_uniqueStorage()._aci = nil} - - /// @required - var pni: Data { - get {return _storage._pni ?? Data()} - set {_uniqueStorage()._pni = newValue} - } - /// Returns true if `pni` has been explicitly set. - var hasPni: Bool {return _storage._pni != nil} - /// Clears the value of `pni`. Subsequent reads from it will return its default value. - mutating func clearPni() {_uniqueStorage()._pni = nil} - - /// @required - var e164: UInt64 { - get {return _storage._e164 ?? 0} - set {_uniqueStorage()._e164 = newValue} - } - /// Returns true if `e164` has been explicitly set. - var hasE164: Bool {return _storage._e164 != nil} - /// Clears the value of `e164`. Subsequent reads from it will return its default value. - mutating func clearE164() {_uniqueStorage()._e164 = nil} + mutating func clearAccountSettings() {self._accountSettings = nil} var unknownFields = SwiftProtobuf.UnknownStorage() enum PhoneNumberSharingMode: SwiftProtobuf.Enum { typealias RawValue = Int - case everybody // = 0 - case contactsOnly // = 1 + case unknown // = 0 + case everybody // = 1 case nobody // = 2 init() { - self = .everybody + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .everybody - case 1: self = .contactsOnly + case 0: self = .unknown + case 1: self = .everybody case 2: self = .nobody default: return nil } @@ -330,8 +260,8 @@ struct BackupProtos_AccountData { var rawValue: Int { switch self { - case .everybody: return 0 - case .contactsOnly: return 1 + case .unknown: return 0 + case .everybody: return 1 case .nobody: return 2 } } @@ -433,16 +363,6 @@ struct BackupProtos_AccountData { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// @required - var noteToSelfArchived: Bool { - get {return _storage._noteToSelfArchived ?? false} - set {_uniqueStorage()._noteToSelfArchived = newValue} - } - /// Returns true if `noteToSelfArchived` has been explicitly set. - var hasNoteToSelfArchived: Bool {return _storage._noteToSelfArchived != nil} - /// Clears the value of `noteToSelfArchived`. Subsequent reads from it will return its default value. - mutating func clearNoteToSelfArchived() {_uniqueStorage()._noteToSelfArchived = nil} - /// @required var readReceipts: Bool { get {return _storage._readReceipts ?? false} @@ -473,16 +393,6 @@ struct BackupProtos_AccountData { /// Clears the value of `typingIndicators`. Subsequent reads from it will return its default value. mutating func clearTypingIndicators() {_uniqueStorage()._typingIndicators = nil} - /// @required - var proxiedLinkPreviews: Bool { - get {return _storage._proxiedLinkPreviews ?? false} - set {_uniqueStorage()._proxiedLinkPreviews = newValue} - } - /// Returns true if `proxiedLinkPreviews` has been explicitly set. - var hasProxiedLinkPreviews: Bool {return _storage._proxiedLinkPreviews != nil} - /// Clears the value of `proxiedLinkPreviews`. Subsequent reads from it will return its default value. - mutating func clearProxiedLinkPreviews() {_uniqueStorage()._proxiedLinkPreviews = nil} - /// @required var noteToSelfMarkedUnread: Bool { get {return _storage._noteToSelfMarkedUnread ?? false} @@ -504,14 +414,14 @@ struct BackupProtos_AccountData { mutating func clearLinkPreviews() {_uniqueStorage()._linkPreviews = nil} /// @required - var unlistedPhoneNumber: Bool { - get {return _storage._unlistedPhoneNumber ?? false} - set {_uniqueStorage()._unlistedPhoneNumber = newValue} + var unlistedPhoneeumber: Bool { + get {return _storage._unlistedPhoneeumber ?? false} + set {_uniqueStorage()._unlistedPhoneeumber = newValue} } - /// Returns true if `unlistedPhoneNumber` has been explicitly set. - var hasUnlistedPhoneNumber: Bool {return _storage._unlistedPhoneNumber != nil} - /// Clears the value of `unlistedPhoneNumber`. Subsequent reads from it will return its default value. - mutating func clearUnlistedPhoneNumber() {_uniqueStorage()._unlistedPhoneNumber = nil} + /// Returns true if `unlistedPhoneeumber` has been explicitly set. + var hasUnlistedPhoneeumber: Bool {return _storage._unlistedPhoneeumber != nil} + /// Clears the value of `unlistedPhoneeumber`. Subsequent reads from it will return its default value. + mutating func clearUnlistedPhoneeumber() {_uniqueStorage()._unlistedPhoneeumber = nil} /// @required var preferContactAvatars: Bool { @@ -598,24 +508,14 @@ struct BackupProtos_AccountData { mutating func clearStoryViewReceiptsEnabled() {_uniqueStorage()._storyViewReceiptsEnabled = nil} /// @required - var onboardingStoryHasBeenRead: Bool { - get {return _storage._onboardingStoryHasBeenRead ?? false} - set {_uniqueStorage()._onboardingStoryHasBeenRead = newValue} + var groupStoryEducationSheetHasBeenSeen: Bool { + get {return _storage._groupStoryEducationSheetHasBeenSeen ?? false} + set {_uniqueStorage()._groupStoryEducationSheetHasBeenSeen = newValue} } - /// Returns true if `onboardingStoryHasBeenRead` has been explicitly set. - var hasOnboardingStoryHasBeenRead: Bool {return _storage._onboardingStoryHasBeenRead != nil} - /// Clears the value of `onboardingStoryHasBeenRead`. Subsequent reads from it will return its default value. - mutating func clearOnboardingStoryHasBeenRead() {_uniqueStorage()._onboardingStoryHasBeenRead = nil} - - /// @required - var groupStoryEducationSheetHasBeenSet: Bool { - get {return _storage._groupStoryEducationSheetHasBeenSet ?? false} - set {_uniqueStorage()._groupStoryEducationSheetHasBeenSet = newValue} - } - /// Returns true if `groupStoryEducationSheetHasBeenSet` has been explicitly set. - var hasGroupStoryEducationSheetHasBeenSet: Bool {return _storage._groupStoryEducationSheetHasBeenSet != nil} - /// Clears the value of `groupStoryEducationSheetHasBeenSet`. Subsequent reads from it will return its default value. - mutating func clearGroupStoryEducationSheetHasBeenSet() {_uniqueStorage()._groupStoryEducationSheetHasBeenSet = nil} + /// Returns true if `groupStoryEducationSheetHasBeenSeen` has been explicitly set. + var hasGroupStoryEducationSheetHasBeenSeen: Bool {return _storage._groupStoryEducationSheetHasBeenSeen != nil} + /// Clears the value of `groupStoryEducationSheetHasBeenSeen`. Subsequent reads from it will return its default value. + mutating func clearGroupStoryEducationSheetHasBeenSeen() {_uniqueStorage()._groupStoryEducationSheetHasBeenSeen = nil} /// @required var usernameOnboardingHasBeenCompleted: Bool { @@ -628,7 +528,7 @@ struct BackupProtos_AccountData { mutating func clearUsernameOnboardingHasBeenCompleted() {_uniqueStorage()._usernameOnboardingHasBeenCompleted = nil} var phoneNumberSharingMode: BackupProtos_AccountData.PhoneNumberSharingMode { - get {return _storage._phoneNumberSharingMode ?? .everybody} + get {return _storage._phoneNumberSharingMode ?? .unknown} set {_uniqueStorage()._phoneNumberSharingMode = newValue} } /// Returns true if `phoneNumberSharingMode` has been explicitly set. @@ -645,7 +545,16 @@ struct BackupProtos_AccountData { init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _profileKey: Data? = nil + fileprivate var _username: String? = nil + fileprivate var _usernameLink: BackupProtos_AccountData.UsernameLink? = nil + fileprivate var _givenName: String? = nil + fileprivate var _familyName: String? = nil + fileprivate var _avatarPath: String? = nil + fileprivate var _subscriberID: Data? = nil + fileprivate var _subscriberCurrencyCode: String? = nil + fileprivate var _subscriptionManuallyCancelled: Bool? = nil + fileprivate var _accountSettings: BackupProtos_AccountData.AccountSettings? = nil } #if swift(>=4.2) @@ -703,7 +612,6 @@ struct BackupProtos_Recipient { /// Clears the value of `distributionList`. Subsequent reads from it will return its default value. mutating func clearDistributionList() {_uniqueStorage()._distributionList = nil} - /// } var selfRecipient: BackupProtos_SelfRecipient { get {return _storage._selfRecipient ?? BackupProtos_SelfRecipient()} set {_uniqueStorage()._selfRecipient = newValue} @@ -713,6 +621,16 @@ struct BackupProtos_Recipient { /// Clears the value of `selfRecipient`. Subsequent reads from it will return its default value. mutating func clearSelfRecipient() {_uniqueStorage()._selfRecipient = nil} + /// } + var releaseNotes: BackupProtos_ReleaseNotes { + get {return _storage._releaseNotes ?? BackupProtos_ReleaseNotes()} + set {_uniqueStorage()._releaseNotes = newValue} + } + /// Returns true if `releaseNotes` has been explicitly set. + var hasReleaseNotes: Bool {return _storage._releaseNotes != nil} + /// Clears the value of `releaseNotes`. Subsequent reads from it will return its default value. + mutating func clearReleaseNotes() {_uniqueStorage()._releaseNotes = nil} + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -839,15 +757,6 @@ struct BackupProtos_Contact { /// Clears the value of `profileFamilyName`. Subsequent reads from it will return its default value. mutating func clearProfileFamilyName() {self._profileFamilyName = nil} - var profileJoinedName: String { - get {return _profileJoinedName ?? String()} - set {_profileJoinedName = newValue} - } - /// Returns true if `profileJoinedName` has been explicitly set. - var hasProfileJoinedName: Bool {return self._profileJoinedName != nil} - /// Clears the value of `profileJoinedName`. Subsequent reads from it will return its default value. - mutating func clearProfileJoinedName() {self._profileJoinedName = nil} - /// @required var hideStory: Bool { get {return _hideStory ?? false} @@ -903,7 +812,6 @@ struct BackupProtos_Contact { fileprivate var _profileSharing: Bool? = nil fileprivate var _profileGivenName: String? = nil fileprivate var _profileFamilyName: String? = nil - fileprivate var _profileJoinedName: String? = nil fileprivate var _hideStory: Bool? = nil } @@ -1016,6 +924,16 @@ struct BackupProtos_SelfRecipient { init() {} } +struct BackupProtos_ReleaseNotes { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + struct BackupProtos_Chat { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -1052,34 +970,34 @@ struct BackupProtos_Chat { mutating func clearArchived() {self._archived = nil} /// @required - var pinned: Bool { - get {return _pinned ?? false} - set {_pinned = newValue} + var pinnedOrder: UInt32 { + get {return _pinnedOrder ?? 0} + set {_pinnedOrder = newValue} } - /// Returns true if `pinned` has been explicitly set. - var hasPinned: Bool {return self._pinned != nil} - /// Clears the value of `pinned`. Subsequent reads from it will return its default value. - mutating func clearPinned() {self._pinned = nil} + /// Returns true if `pinnedOrder` has been explicitly set. + var hasPinnedOrder: Bool {return self._pinnedOrder != nil} + /// Clears the value of `pinnedOrder`. Subsequent reads from it will return its default value. + mutating func clearPinnedOrder() {self._pinnedOrder = nil} /// @required - var expirationTimer: UInt64 { - get {return _expirationTimer ?? 0} - set {_expirationTimer = newValue} + var expirationTimerMs: UInt64 { + get {return _expirationTimerMs ?? 0} + set {_expirationTimerMs = newValue} } - /// Returns true if `expirationTimer` has been explicitly set. - var hasExpirationTimer: Bool {return self._expirationTimer != nil} - /// Clears the value of `expirationTimer`. Subsequent reads from it will return its default value. - mutating func clearExpirationTimer() {self._expirationTimer = nil} + /// Returns true if `expirationTimerMs` has been explicitly set. + var hasExpirationTimerMs: Bool {return self._expirationTimerMs != nil} + /// Clears the value of `expirationTimerMs`. Subsequent reads from it will return its default value. + mutating func clearExpirationTimerMs() {self._expirationTimerMs = nil} /// @required - var muteUntil: UInt64 { - get {return _muteUntil ?? 0} - set {_muteUntil = newValue} + var muteUntilMs: UInt64 { + get {return _muteUntilMs ?? 0} + set {_muteUntilMs = newValue} } - /// Returns true if `muteUntil` has been explicitly set. - var hasMuteUntil: Bool {return self._muteUntil != nil} - /// Clears the value of `muteUntil`. Subsequent reads from it will return its default value. - mutating func clearMuteUntil() {self._muteUntil = nil} + /// Returns true if `muteUntilMs` has been explicitly set. + var hasMuteUntilMs: Bool {return self._muteUntilMs != nil} + /// Clears the value of `muteUntilMs`. Subsequent reads from it will return its default value. + mutating func clearMuteUntilMs() {self._muteUntilMs = nil} /// @required var markedUnread: Bool { @@ -1101,6 +1019,15 @@ struct BackupProtos_Chat { /// Clears the value of `dontNotifyForMentionsIfMuted`. Subsequent reads from it will return its default value. mutating func clearDontNotifyForMentionsIfMuted() {self._dontNotifyForMentionsIfMuted = nil} + var wallpaper: BackupProtos_FilePointer { + get {return _wallpaper ?? BackupProtos_FilePointer()} + set {_wallpaper = newValue} + } + /// Returns true if `wallpaper` has been explicitly set. + var hasWallpaper: Bool {return self._wallpaper != nil} + /// Clears the value of `wallpaper`. Subsequent reads from it will return its default value. + mutating func clearWallpaper() {self._wallpaper = nil} + var unknownFields = SwiftProtobuf.UnknownStorage() init() {} @@ -1108,11 +1035,12 @@ struct BackupProtos_Chat { fileprivate var _id: UInt64? = nil fileprivate var _recipientID: UInt64? = nil fileprivate var _archived: Bool? = nil - fileprivate var _pinned: Bool? = nil - fileprivate var _expirationTimer: UInt64? = nil - fileprivate var _muteUntil: UInt64? = nil + fileprivate var _pinnedOrder: UInt32? = nil + fileprivate var _expirationTimerMs: UInt64? = nil + fileprivate var _muteUntilMs: UInt64? = nil fileprivate var _markedUnread: Bool? = nil fileprivate var _dontNotifyForMentionsIfMuted: Bool? = nil + fileprivate var _wallpaper: BackupProtos_FilePointer? = nil } struct BackupProtos_DistributionList { @@ -1160,18 +1088,8 @@ struct BackupProtos_DistributionList { /// Clears the value of `deletionTimestamp`. Subsequent reads from it will return its default value. mutating func clearDeletionTimestamp() {self._deletionTimestamp = nil} - /// @required - var isUnknown: Bool { - get {return _isUnknown ?? false} - set {_isUnknown = newValue} - } - /// Returns true if `isUnknown` has been explicitly set. - var hasIsUnknown: Bool {return self._isUnknown != nil} - /// Clears the value of `isUnknown`. Subsequent reads from it will return its default value. - mutating func clearIsUnknown() {self._isUnknown = nil} - var privacyMode: BackupProtos_DistributionList.PrivacyMode { - get {return _privacyMode ?? .onlyWith} + get {return _privacyMode ?? .unknown} set {_privacyMode = newValue} } /// Returns true if `privacyMode` has been explicitly set. @@ -1186,28 +1104,31 @@ struct BackupProtos_DistributionList { enum PrivacyMode: SwiftProtobuf.Enum { typealias RawValue = Int - case onlyWith // = 0 - case allExcept // = 1 - case all // = 2 + case unknown // = 0 + case onlyWith // = 1 + case allExcept // = 2 + case all // = 3 init() { - self = .onlyWith + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .onlyWith - case 1: self = .allExcept - case 2: self = .all + case 0: self = .unknown + case 1: self = .onlyWith + case 2: self = .allExcept + case 3: self = .all default: return nil } } var rawValue: Int { switch self { - case .onlyWith: return 0 - case .allExcept: return 1 - case .all: return 2 + case .unknown: return 0 + case .onlyWith: return 1 + case .allExcept: return 2 + case .all: return 3 } } @@ -1219,7 +1140,6 @@ struct BackupProtos_DistributionList { fileprivate var _distributionID: Data? = nil fileprivate var _allowReplies: Bool? = nil fileprivate var _deletionTimestamp: UInt64? = nil - fileprivate var _isUnknown: Bool? = nil fileprivate var _privacyMode: BackupProtos_DistributionList.PrivacyMode? = nil } @@ -1324,17 +1244,17 @@ struct BackupProtos_Call { mutating func clearCallID() {self._callID = nil} /// @required - var peerRecipientID: UInt64 { - get {return _peerRecipientID ?? 0} - set {_peerRecipientID = newValue} + var conversationRecipientID: UInt64 { + get {return _conversationRecipientID ?? 0} + set {_conversationRecipientID = newValue} } - /// Returns true if `peerRecipientID` has been explicitly set. - var hasPeerRecipientID: Bool {return self._peerRecipientID != nil} - /// Clears the value of `peerRecipientID`. Subsequent reads from it will return its default value. - mutating func clearPeerRecipientID() {self._peerRecipientID = nil} + /// Returns true if `conversationRecipientID` has been explicitly set. + var hasConversationRecipientID: Bool {return self._conversationRecipientID != nil} + /// Clears the value of `conversationRecipientID`. Subsequent reads from it will return its default value. + mutating func clearConversationRecipientID() {self._conversationRecipientID = nil} var type: BackupProtos_Call.TypeEnum { - get {return _type ?? .audioCall} + get {return _type ?? .unknownType} set {_type = newValue} } /// Returns true if `type` has been explicitly set. @@ -1373,7 +1293,7 @@ struct BackupProtos_Call { mutating func clearRingerRecipientID() {self._ringerRecipientID = nil} var event: BackupProtos_Call.Event { - get {return _event ?? .outgoing} + get {return _event ?? .unknownEvent} set {_event = newValue} } /// Returns true if `event` has been explicitly set. @@ -1385,31 +1305,34 @@ struct BackupProtos_Call { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case audioCall // = 0 - case videoCall // = 1 - case groupCall // = 2 - case adHocCall // = 3 + case unknownType // = 0 + case audioCall // = 1 + case videoCall // = 2 + case groupCall // = 3 + case adHocCall // = 4 init() { - self = .audioCall + self = .unknownType } init?(rawValue: Int) { switch rawValue { - case 0: self = .audioCall - case 1: self = .videoCall - case 2: self = .groupCall - case 3: self = .adHocCall + case 0: self = .unknownType + case 1: self = .audioCall + case 2: self = .videoCall + case 3: self = .groupCall + case 4: self = .adHocCall default: return nil } } var rawValue: Int { switch self { - case .audioCall: return 0 - case .videoCall: return 1 - case .groupCall: return 2 - case .adHocCall: return 3 + case .unknownType: return 0 + case .audioCall: return 1 + case .videoCall: return 2 + case .groupCall: return 3 + case .adHocCall: return 4 } } @@ -1417,30 +1340,28 @@ struct BackupProtos_Call { enum Event: SwiftProtobuf.Enum { typealias RawValue = Int + case unknownEvent // = 0 /// 1:1 calls only - case outgoing // = 0 + case outgoing // = 1 /// 1:1 and group calls. Group calls: You accepted a ring. - case accepted // = 1 + case accepted // = 2 /// 1:1 calls only, - case notAccepted // = 2 + case notAccepted // = 3 - /// 1:1 and group/ad-hoc calls. Group calls: The remote ring has expired or was cancelled by the ringer. - case missed // = 3 + /// 1:1 and group. Group calls: The remote ring has expired or was cancelled by the ringer. + case missed // = 4 /// 1:1 and Group/Ad-Hoc Calls. - case delete // = 4 + case delete // = 5 /// Group/Ad-Hoc Calls only. Initial state - case genericGroupCall // = 5 + case genericGroupCall // = 6 /// Group Calls: User has joined the group call. - case joined // = 6 - - /// Group Calls: If a ring was requested by another user. - case ringing // = 7 + case joined // = 7 /// Group Calls: If you declined a ring. case declined // = 8 @@ -1449,19 +1370,19 @@ struct BackupProtos_Call { case outgoingRing // = 9 init() { - self = .outgoing + self = .unknownEvent } init?(rawValue: Int) { switch rawValue { - case 0: self = .outgoing - case 1: self = .accepted - case 2: self = .notAccepted - case 3: self = .missed - case 4: self = .delete - case 5: self = .genericGroupCall - case 6: self = .joined - case 7: self = .ringing + case 0: self = .unknownEvent + case 1: self = .outgoing + case 2: self = .accepted + case 3: self = .notAccepted + case 4: self = .missed + case 5: self = .delete + case 6: self = .genericGroupCall + case 7: self = .joined case 8: self = .declined case 9: self = .outgoingRing default: return nil @@ -1470,14 +1391,14 @@ struct BackupProtos_Call { var rawValue: Int { switch self { - case .outgoing: return 0 - case .accepted: return 1 - case .notAccepted: return 2 - case .missed: return 3 - case .delete: return 4 - case .genericGroupCall: return 5 - case .joined: return 6 - case .ringing: return 7 + case .unknownEvent: return 0 + case .outgoing: return 1 + case .accepted: return 2 + case .notAccepted: return 3 + case .missed: return 4 + case .delete: return 5 + case .genericGroupCall: return 6 + case .joined: return 7 case .declined: return 8 case .outgoingRing: return 9 } @@ -1488,7 +1409,7 @@ struct BackupProtos_Call { init() {} fileprivate var _callID: UInt64? = nil - fileprivate var _peerRecipientID: UInt64? = nil + fileprivate var _conversationRecipientID: UInt64? = nil fileprivate var _type: BackupProtos_Call.TypeEnum? = nil fileprivate var _outgoing: Bool? = nil fileprivate var _timestamp: UInt64? = nil @@ -1543,36 +1464,27 @@ struct BackupProtos_ChatItem { /// Clears the value of `dateSent`. Subsequent reads from it will return its default value. mutating func clearDateSent() {_uniqueStorage()._dateSent = nil} - /// @required - var dateReceived: UInt64 { - get {return _storage._dateReceived ?? 0} - set {_uniqueStorage()._dateReceived = newValue} - } - /// Returns true if `dateReceived` has been explicitly set. - var hasDateReceived: Bool {return _storage._dateReceived != nil} - /// Clears the value of `dateReceived`. Subsequent reads from it will return its default value. - mutating func clearDateReceived() {_uniqueStorage()._dateReceived = nil} - /// timestamp of when expiration timer started ticking down - var expireStart: UInt64 { - get {return _storage._expireStart ?? 0} - set {_uniqueStorage()._expireStart = newValue} + var expireStartMs: UInt64 { + get {return _storage._expireStartMs ?? 0} + set {_uniqueStorage()._expireStartMs = newValue} } - /// Returns true if `expireStart` has been explicitly set. - var hasExpireStart: Bool {return _storage._expireStart != nil} - /// Clears the value of `expireStart`. Subsequent reads from it will return its default value. - mutating func clearExpireStart() {_uniqueStorage()._expireStart = nil} + /// Returns true if `expireStartMs` has been explicitly set. + var hasExpireStartMs: Bool {return _storage._expireStartMs != nil} + /// Clears the value of `expireStartMs`. Subsequent reads from it will return its default value. + mutating func clearExpireStartMs() {_uniqueStorage()._expireStartMs = nil} /// how long timer of message is (ms) - var expiresIn: UInt64 { - get {return _storage._expiresIn ?? 0} - set {_uniqueStorage()._expiresIn = newValue} + var expiresInMs: UInt64 { + get {return _storage._expiresInMs ?? 0} + set {_uniqueStorage()._expiresInMs = newValue} } - /// Returns true if `expiresIn` has been explicitly set. - var hasExpiresIn: Bool {return _storage._expiresIn != nil} - /// Clears the value of `expiresIn`. Subsequent reads from it will return its default value. - mutating func clearExpiresIn() {_uniqueStorage()._expiresIn = nil} + /// Returns true if `expiresInMs` has been explicitly set. + var hasExpiresInMs: Bool {return _storage._expiresInMs != nil} + /// Clears the value of `expiresInMs`. Subsequent reads from it will return its default value. + mutating func clearExpiresInMs() {_uniqueStorage()._expiresInMs = nil} + /// ordered from oldest to newest var revisions: [BackupProtos_ChatItem] { get {return _storage._revisions} set {_uniqueStorage()._revisions = newValue} @@ -1671,6 +1583,16 @@ struct BackupProtos_ChatItem { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required + var dateReceived: UInt64 { + get {return _dateReceived ?? 0} + set {_dateReceived = newValue} + } + /// Returns true if `dateReceived` has been explicitly set. + var hasDateReceived: Bool {return self._dateReceived != nil} + /// Clears the value of `dateReceived`. Subsequent reads from it will return its default value. + mutating func clearDateReceived() {self._dateReceived = nil} + /// @required var dateServerSent: UInt64 { get {return _dateServerSent ?? 0} @@ -1705,6 +1627,7 @@ struct BackupProtos_ChatItem { init() {} + fileprivate var _dateReceived: UInt64? = nil fileprivate var _dateServerSent: UInt64? = nil fileprivate var _read: Bool? = nil fileprivate var _sealedSender: Bool? = nil @@ -1743,7 +1666,7 @@ struct BackupProtos_SendStatus { mutating func clearRecipientID() {self._recipientID = nil} var deliveryStatus: BackupProtos_SendStatus.Status { - get {return _deliveryStatus ?? .failed} + get {return _deliveryStatus ?? .unknown} set {_deliveryStatus = newValue} } /// Returns true if `deliveryStatus` has been explicitly set. @@ -1795,42 +1718,45 @@ struct BackupProtos_SendStatus { enum Status: SwiftProtobuf.Enum { typealias RawValue = Int - case failed // = 0 - case pending // = 1 - case sent // = 2 - case delivered // = 3 - case read // = 4 - case viewed // = 5 + case unknown // = 0 + case failed // = 1 + case pending // = 2 + case sent // = 3 + case delivered // = 4 + case read // = 5 + case viewed // = 6 /// e.g. user in group was blocked, so we skipped sending to them - case skipped // = 6 + case skipped // = 7 init() { - self = .failed + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .failed - case 1: self = .pending - case 2: self = .sent - case 3: self = .delivered - case 4: self = .read - case 5: self = .viewed - case 6: self = .skipped + case 0: self = .unknown + case 1: self = .failed + case 2: self = .pending + case 3: self = .sent + case 4: self = .delivered + case 5: self = .read + case 6: self = .viewed + case 7: self = .skipped default: return nil } } var rawValue: Int { switch self { - case .failed: return 0 - case .pending: return 1 - case .sent: return 2 - case .delivered: return 3 - case .read: return 4 - case .viewed: return 5 - case .skipped: return 6 + case .unknown: return 0 + case .failed: return 1 + case .pending: return 2 + case .sent: return 3 + case .delivered: return 4 + case .read: return 5 + case .viewed: return 6 + case .skipped: return 7 } } @@ -1884,56 +1810,45 @@ struct BackupProtos_StandardMessage { // methods supported on all messages. var quote: BackupProtos_Quote { - get {return _storage._quote ?? BackupProtos_Quote()} - set {_uniqueStorage()._quote = newValue} + get {return _quote ?? BackupProtos_Quote()} + set {_quote = newValue} } /// Returns true if `quote` has been explicitly set. - var hasQuote: Bool {return _storage._quote != nil} + var hasQuote: Bool {return self._quote != nil} /// Clears the value of `quote`. Subsequent reads from it will return its default value. - mutating func clearQuote() {_uniqueStorage()._quote = nil} + mutating func clearQuote() {self._quote = nil} var text: BackupProtos_Text { - get {return _storage._text ?? BackupProtos_Text()} - set {_uniqueStorage()._text = newValue} + get {return _text ?? BackupProtos_Text()} + set {_text = newValue} } /// Returns true if `text` has been explicitly set. - var hasText: Bool {return _storage._text != nil} + var hasText: Bool {return self._text != nil} /// Clears the value of `text`. Subsequent reads from it will return its default value. - mutating func clearText() {_uniqueStorage()._text = nil} + mutating func clearText() {self._text = nil} - var attachments: [BackupProtos_AttachmentPointer] { - get {return _storage._attachments} - set {_uniqueStorage()._attachments = newValue} - } + var attachments: [BackupProtos_FilePointer] = [] - var linkPreview: BackupProtos_LinkPreview { - get {return _storage._linkPreview ?? BackupProtos_LinkPreview()} - set {_uniqueStorage()._linkPreview = newValue} - } - /// Returns true if `linkPreview` has been explicitly set. - var hasLinkPreview: Bool {return _storage._linkPreview != nil} - /// Clears the value of `linkPreview`. Subsequent reads from it will return its default value. - mutating func clearLinkPreview() {_uniqueStorage()._linkPreview = nil} + var linkPreview: [BackupProtos_LinkPreview] = [] - var longText: BackupProtos_AttachmentPointer { - get {return _storage._longText ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._longText = newValue} + var longText: BackupProtos_FilePointer { + get {return _longText ?? BackupProtos_FilePointer()} + set {_longText = newValue} } /// Returns true if `longText` has been explicitly set. - var hasLongText: Bool {return _storage._longText != nil} + var hasLongText: Bool {return self._longText != nil} /// Clears the value of `longText`. Subsequent reads from it will return its default value. - mutating func clearLongText() {_uniqueStorage()._longText = nil} + mutating func clearLongText() {self._longText = nil} - var reactions: [BackupProtos_Reaction] { - get {return _storage._reactions} - set {_uniqueStorage()._reactions = newValue} - } + var reactions: [BackupProtos_Reaction] = [] var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _quote: BackupProtos_Quote? = nil + fileprivate var _text: BackupProtos_Text? = nil + fileprivate var _longText: BackupProtos_FilePointer? = nil } struct BackupProtos_ContactMessage { @@ -2076,7 +1991,7 @@ struct BackupProtos_ContactAttachment { mutating func clearValue() {self._value = nil} var type: BackupProtos_ContactAttachment.Phone.TypeEnum { - get {return _type ?? .home} + get {return _type ?? .unknown} set {_type = newValue} } /// Returns true if `type` has been explicitly set. @@ -2097,31 +2012,34 @@ struct BackupProtos_ContactAttachment { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case home // = 0 - case mobile // = 1 - case work // = 2 - case custom // = 3 + case unknown // = 0 + case home // = 1 + case mobile // = 2 + case work // = 3 + case custom // = 4 init() { - self = .home + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .home - case 1: self = .mobile - case 2: self = .work - case 3: self = .custom + case 0: self = .unknown + case 1: self = .home + case 2: self = .mobile + case 3: self = .work + case 4: self = .custom default: return nil } } var rawValue: Int { switch self { - case .home: return 0 - case .mobile: return 1 - case .work: return 2 - case .custom: return 3 + case .unknown: return 0 + case .home: return 1 + case .mobile: return 2 + case .work: return 3 + case .custom: return 4 } } @@ -2149,7 +2067,7 @@ struct BackupProtos_ContactAttachment { mutating func clearValue() {self._value = nil} var type: BackupProtos_ContactAttachment.Email.TypeEnum { - get {return _type ?? .home} + get {return _type ?? .unknown} set {_type = newValue} } /// Returns true if `type` has been explicitly set. @@ -2170,31 +2088,34 @@ struct BackupProtos_ContactAttachment { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case home // = 0 - case mobile // = 1 - case work // = 2 - case custom // = 3 + case unknown // = 0 + case home // = 1 + case mobile // = 2 + case work // = 3 + case custom // = 4 init() { - self = .home + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .home - case 1: self = .mobile - case 2: self = .work - case 3: self = .custom + case 0: self = .unknown + case 1: self = .home + case 2: self = .mobile + case 3: self = .work + case 4: self = .custom default: return nil } } var rawValue: Int { switch self { - case .home: return 0 - case .mobile: return 1 - case .work: return 2 - case .custom: return 3 + case .unknown: return 0 + case .home: return 1 + case .mobile: return 2 + case .work: return 3 + case .custom: return 4 } } @@ -2213,7 +2134,7 @@ struct BackupProtos_ContactAttachment { // methods supported on all messages. var type: BackupProtos_ContactAttachment.PostalAddress.TypeEnum { - get {return _type ?? .home} + get {return _type ?? .unknown} set {_type = newValue} } /// Returns true if `type` has been explicitly set. @@ -2297,28 +2218,31 @@ struct BackupProtos_ContactAttachment { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case home // = 0 - case work // = 1 - case custom // = 2 + case unknown // = 0 + case home // = 1 + case work // = 2 + case custom // = 3 init() { - self = .home + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .home - case 1: self = .work - case 2: self = .custom + case 0: self = .unknown + case 1: self = .home + case 2: self = .work + case 3: self = .custom default: return nil } } var rawValue: Int { switch self { - case .home: return 0 - case .work: return 1 - case .custom: return 2 + case .unknown: return 0 + case .home: return 1 + case .work: return 2 + case .custom: return 3 } } @@ -2342,29 +2266,21 @@ struct BackupProtos_ContactAttachment { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - var avatar: BackupProtos_AttachmentPointer { - get {return _storage._avatar ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._avatar = newValue} + /// @required + var avatar: BackupProtos_FilePointer { + get {return _avatar ?? BackupProtos_FilePointer()} + set {_avatar = newValue} } /// Returns true if `avatar` has been explicitly set. - var hasAvatar: Bool {return _storage._avatar != nil} + var hasAvatar: Bool {return self._avatar != nil} /// Clears the value of `avatar`. Subsequent reads from it will return its default value. - mutating func clearAvatar() {_uniqueStorage()._avatar = nil} - - var isProfile: Bool { - get {return _storage._isProfile ?? false} - set {_uniqueStorage()._isProfile = newValue} - } - /// Returns true if `isProfile` has been explicitly set. - var hasIsProfile: Bool {return _storage._isProfile != nil} - /// Clears the value of `isProfile`. Subsequent reads from it will return its default value. - mutating func clearIsProfile() {_uniqueStorage()._isProfile = nil} + mutating func clearAvatar() {self._avatar = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _avatar: BackupProtos_FilePointer? = nil } init() {} @@ -2397,34 +2313,32 @@ struct BackupProtos_DocumentMessage { /// @required var text: BackupProtos_Text { - get {return _storage._text ?? BackupProtos_Text()} - set {_uniqueStorage()._text = newValue} + get {return _text ?? BackupProtos_Text()} + set {_text = newValue} } /// Returns true if `text` has been explicitly set. - var hasText: Bool {return _storage._text != nil} + var hasText: Bool {return self._text != nil} /// Clears the value of `text`. Subsequent reads from it will return its default value. - mutating func clearText() {_uniqueStorage()._text = nil} + mutating func clearText() {self._text = nil} /// @required - var document: BackupProtos_AttachmentPointer { - get {return _storage._document ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._document = newValue} + var document: BackupProtos_FilePointer { + get {return _document ?? BackupProtos_FilePointer()} + set {_document = newValue} } /// Returns true if `document` has been explicitly set. - var hasDocument: Bool {return _storage._document != nil} + var hasDocument: Bool {return self._document != nil} /// Clears the value of `document`. Subsequent reads from it will return its default value. - mutating func clearDocument() {_uniqueStorage()._document = nil} + mutating func clearDocument() {self._document = nil} - var reactions: [BackupProtos_Reaction] { - get {return _storage._reactions} - set {_uniqueStorage()._reactions = newValue} - } + var reactions: [BackupProtos_Reaction] = [] var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _text: BackupProtos_Text? = nil + fileprivate var _document: BackupProtos_FilePointer? = nil } struct BackupProtos_VoiceMessage { @@ -2433,34 +2347,32 @@ struct BackupProtos_VoiceMessage { // methods supported on all messages. var quote: BackupProtos_Quote { - get {return _storage._quote ?? BackupProtos_Quote()} - set {_uniqueStorage()._quote = newValue} + get {return _quote ?? BackupProtos_Quote()} + set {_quote = newValue} } /// Returns true if `quote` has been explicitly set. - var hasQuote: Bool {return _storage._quote != nil} + var hasQuote: Bool {return self._quote != nil} /// Clears the value of `quote`. Subsequent reads from it will return its default value. - mutating func clearQuote() {_uniqueStorage()._quote = nil} + mutating func clearQuote() {self._quote = nil} /// @required - var audio: BackupProtos_AttachmentPointer { - get {return _storage._audio ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._audio = newValue} + var audio: BackupProtos_FilePointer { + get {return _audio ?? BackupProtos_FilePointer()} + set {_audio = newValue} } /// Returns true if `audio` has been explicitly set. - var hasAudio: Bool {return _storage._audio != nil} + var hasAudio: Bool {return self._audio != nil} /// Clears the value of `audio`. Subsequent reads from it will return its default value. - mutating func clearAudio() {_uniqueStorage()._audio = nil} + mutating func clearAudio() {self._audio = nil} - var reactions: [BackupProtos_Reaction] { - get {return _storage._reactions} - set {_uniqueStorage()._reactions = newValue} - } + var reactions: [BackupProtos_Reaction] = [] var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _quote: BackupProtos_Quote? = nil + fileprivate var _audio: BackupProtos_FilePointer? = nil } struct BackupProtos_StickerMessage { @@ -2536,56 +2448,53 @@ struct BackupProtos_Sticker { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var packID: Data { - get {return _storage._packID ?? Data()} - set {_uniqueStorage()._packID = newValue} + get {return _packID ?? Data()} + set {_packID = newValue} } /// Returns true if `packID` has been explicitly set. - var hasPackID: Bool {return _storage._packID != nil} + var hasPackID: Bool {return self._packID != nil} /// Clears the value of `packID`. Subsequent reads from it will return its default value. - mutating func clearPackID() {_uniqueStorage()._packID = nil} + mutating func clearPackID() {self._packID = nil} + /// @required var packKey: Data { - get {return _storage._packKey ?? Data()} - set {_uniqueStorage()._packKey = newValue} + get {return _packKey ?? Data()} + set {_packKey = newValue} } /// Returns true if `packKey` has been explicitly set. - var hasPackKey: Bool {return _storage._packKey != nil} + var hasPackKey: Bool {return self._packKey != nil} /// Clears the value of `packKey`. Subsequent reads from it will return its default value. - mutating func clearPackKey() {_uniqueStorage()._packKey = nil} + mutating func clearPackKey() {self._packKey = nil} + /// @required var stickerID: UInt32 { - get {return _storage._stickerID ?? 0} - set {_uniqueStorage()._stickerID = newValue} + get {return _stickerID ?? 0} + set {_stickerID = newValue} } /// Returns true if `stickerID` has been explicitly set. - var hasStickerID: Bool {return _storage._stickerID != nil} + var hasStickerID: Bool {return self._stickerID != nil} /// Clears the value of `stickerID`. Subsequent reads from it will return its default value. - mutating func clearStickerID() {_uniqueStorage()._stickerID = nil} - - var data: BackupProtos_AttachmentPointer { - get {return _storage._data ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._data = newValue} - } - /// Returns true if `data` has been explicitly set. - var hasData: Bool {return _storage._data != nil} - /// Clears the value of `data`. Subsequent reads from it will return its default value. - mutating func clearData() {_uniqueStorage()._data = nil} + mutating func clearStickerID() {self._stickerID = nil} var emoji: String { - get {return _storage._emoji ?? String()} - set {_uniqueStorage()._emoji = newValue} + get {return _emoji ?? String()} + set {_emoji = newValue} } /// Returns true if `emoji` has been explicitly set. - var hasEmoji: Bool {return _storage._emoji != nil} + var hasEmoji: Bool {return self._emoji != nil} /// Clears the value of `emoji`. Subsequent reads from it will return its default value. - mutating func clearEmoji() {_uniqueStorage()._emoji = nil} + mutating func clearEmoji() {self._emoji = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _packID: Data? = nil + fileprivate var _packKey: Data? = nil + fileprivate var _stickerID: UInt32? = nil + fileprivate var _emoji: String? = nil } struct BackupProtos_LinkPreview { @@ -2593,208 +2502,204 @@ struct BackupProtos_LinkPreview { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + /// @required var url: String { - get {return _storage._url ?? String()} - set {_uniqueStorage()._url = newValue} + get {return _url ?? String()} + set {_url = newValue} } /// Returns true if `url` has been explicitly set. - var hasURL: Bool {return _storage._url != nil} + var hasURL: Bool {return self._url != nil} /// Clears the value of `url`. Subsequent reads from it will return its default value. - mutating func clearURL() {_uniqueStorage()._url = nil} + mutating func clearURL() {self._url = nil} var title: String { - get {return _storage._title ?? String()} - set {_uniqueStorage()._title = newValue} + get {return _title ?? String()} + set {_title = newValue} } /// Returns true if `title` has been explicitly set. - var hasTitle: Bool {return _storage._title != nil} + var hasTitle: Bool {return self._title != nil} /// Clears the value of `title`. Subsequent reads from it will return its default value. - mutating func clearTitle() {_uniqueStorage()._title = nil} + mutating func clearTitle() {self._title = nil} - var image: BackupProtos_AttachmentPointer { - get {return _storage._image ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._image = newValue} + var image: BackupProtos_FilePointer { + get {return _image ?? BackupProtos_FilePointer()} + set {_image = newValue} } /// Returns true if `image` has been explicitly set. - var hasImage: Bool {return _storage._image != nil} + var hasImage: Bool {return self._image != nil} /// Clears the value of `image`. Subsequent reads from it will return its default value. - mutating func clearImage() {_uniqueStorage()._image = nil} + mutating func clearImage() {self._image = nil} var descriptionText: String { - get {return _storage._descriptionText ?? String()} - set {_uniqueStorage()._descriptionText = newValue} + get {return _descriptionText ?? String()} + set {_descriptionText = newValue} } /// Returns true if `descriptionText` has been explicitly set. - var hasDescriptionText: Bool {return _storage._descriptionText != nil} + var hasDescriptionText: Bool {return self._descriptionText != nil} /// Clears the value of `descriptionText`. Subsequent reads from it will return its default value. - mutating func clearDescriptionText() {_uniqueStorage()._descriptionText = nil} + mutating func clearDescriptionText() {self._descriptionText = nil} var date: UInt64 { - get {return _storage._date ?? 0} - set {_uniqueStorage()._date = newValue} + get {return _date ?? 0} + set {_date = newValue} } /// Returns true if `date` has been explicitly set. - var hasDate: Bool {return _storage._date != nil} + var hasDate: Bool {return self._date != nil} /// Clears the value of `date`. Subsequent reads from it will return its default value. - mutating func clearDate() {_uniqueStorage()._date = nil} + mutating func clearDate() {self._date = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _url: String? = nil + fileprivate var _title: String? = nil + fileprivate var _image: BackupProtos_FilePointer? = nil + fileprivate var _descriptionText: String? = nil + fileprivate var _date: UInt64? = nil } -struct BackupProtos_AttachmentPointer { +struct BackupProtos_FilePointer { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// oneof attachmentIdentifier { - var cdnID: UInt64 { - get {return _cdnID ?? 0} - set {_cdnID = newValue} + /// oneof locator { + var backupLocator: BackupProtos_FilePointer.BackupLocator { + get {return _storage._backupLocator ?? BackupProtos_FilePointer.BackupLocator()} + set {_uniqueStorage()._backupLocator = newValue} } - /// Returns true if `cdnID` has been explicitly set. - var hasCdnID: Bool {return self._cdnID != nil} - /// Clears the value of `cdnID`. Subsequent reads from it will return its default value. - mutating func clearCdnID() {self._cdnID = nil} + /// Returns true if `backupLocator` has been explicitly set. + var hasBackupLocator: Bool {return _storage._backupLocator != nil} + /// Clears the value of `backupLocator`. Subsequent reads from it will return its default value. + mutating func clearBackupLocator() {_uniqueStorage()._backupLocator = nil} - /// } - var cdnKey: String { - get {return _cdnKey ?? String()} - set {_cdnKey = newValue} + var attachmentLocator: BackupProtos_FilePointer.AttachmentLocator { + get {return _storage._attachmentLocator ?? BackupProtos_FilePointer.AttachmentLocator()} + set {_uniqueStorage()._attachmentLocator = newValue} } - /// Returns true if `cdnKey` has been explicitly set. - var hasCdnKey: Bool {return self._cdnKey != nil} - /// Clears the value of `cdnKey`. Subsequent reads from it will return its default value. - mutating func clearCdnKey() {self._cdnKey = nil} + /// Returns true if `attachmentLocator` has been explicitly set. + var hasAttachmentLocator: Bool {return _storage._attachmentLocator != nil} + /// Clears the value of `attachmentLocator`. Subsequent reads from it will return its default value. + mutating func clearAttachmentLocator() {_uniqueStorage()._attachmentLocator = nil} - var contentType: String { - get {return _contentType ?? String()} - set {_contentType = newValue} + /// } + var legacyAttachmentLocator: BackupProtos_FilePointer.LegacyAttachmentLocator { + get {return _storage._legacyAttachmentLocator ?? BackupProtos_FilePointer.LegacyAttachmentLocator()} + set {_uniqueStorage()._legacyAttachmentLocator = newValue} } - /// Returns true if `contentType` has been explicitly set. - var hasContentType: Bool {return self._contentType != nil} - /// Clears the value of `contentType`. Subsequent reads from it will return its default value. - mutating func clearContentType() {self._contentType = nil} + /// Returns true if `legacyAttachmentLocator` has been explicitly set. + var hasLegacyAttachmentLocator: Bool {return _storage._legacyAttachmentLocator != nil} + /// Clears the value of `legacyAttachmentLocator`. Subsequent reads from it will return its default value. + mutating func clearLegacyAttachmentLocator() {_uniqueStorage()._legacyAttachmentLocator = nil} var key: Data { - get {return _key ?? Data()} - set {_key = newValue} + get {return _storage._key ?? Data()} + set {_uniqueStorage()._key = newValue} } /// Returns true if `key` has been explicitly set. - var hasKey: Bool {return self._key != nil} + var hasKey: Bool {return _storage._key != nil} /// Clears the value of `key`. Subsequent reads from it will return its default value. - mutating func clearKey() {self._key = nil} + mutating func clearKey() {_uniqueStorage()._key = nil} + + var contentType: String { + get {return _storage._contentType ?? String()} + set {_uniqueStorage()._contentType = newValue} + } + /// Returns true if `contentType` has been explicitly set. + var hasContentType: Bool {return _storage._contentType != nil} + /// Clears the value of `contentType`. Subsequent reads from it will return its default value. + mutating func clearContentType() {_uniqueStorage()._contentType = nil} var size: UInt32 { - get {return _size ?? 0} - set {_size = newValue} + get {return _storage._size ?? 0} + set {_uniqueStorage()._size = newValue} } /// Returns true if `size` has been explicitly set. - var hasSize: Bool {return self._size != nil} + var hasSize: Bool {return _storage._size != nil} /// Clears the value of `size`. Subsequent reads from it will return its default value. - mutating func clearSize() {self._size = nil} + mutating func clearSize() {_uniqueStorage()._size = nil} var digest: Data { - get {return _digest ?? Data()} - set {_digest = newValue} + get {return _storage._digest ?? Data()} + set {_uniqueStorage()._digest = newValue} } /// Returns true if `digest` has been explicitly set. - var hasDigest: Bool {return self._digest != nil} + var hasDigest: Bool {return _storage._digest != nil} /// Clears the value of `digest`. Subsequent reads from it will return its default value. - mutating func clearDigest() {self._digest = nil} + mutating func clearDigest() {_uniqueStorage()._digest = nil} var incrementalMac: Data { - get {return _incrementalMac ?? Data()} - set {_incrementalMac = newValue} + get {return _storage._incrementalMac ?? Data()} + set {_uniqueStorage()._incrementalMac = newValue} } /// Returns true if `incrementalMac` has been explicitly set. - var hasIncrementalMac: Bool {return self._incrementalMac != nil} + var hasIncrementalMac: Bool {return _storage._incrementalMac != nil} /// Clears the value of `incrementalMac`. Subsequent reads from it will return its default value. - mutating func clearIncrementalMac() {self._incrementalMac = nil} + mutating func clearIncrementalMac() {_uniqueStorage()._incrementalMac = nil} var incrementalMacChunkSize: Data { - get {return _incrementalMacChunkSize ?? Data()} - set {_incrementalMacChunkSize = newValue} + get {return _storage._incrementalMacChunkSize ?? Data()} + set {_uniqueStorage()._incrementalMacChunkSize = newValue} } /// Returns true if `incrementalMacChunkSize` has been explicitly set. - var hasIncrementalMacChunkSize: Bool {return self._incrementalMacChunkSize != nil} + var hasIncrementalMacChunkSize: Bool {return _storage._incrementalMacChunkSize != nil} /// Clears the value of `incrementalMacChunkSize`. Subsequent reads from it will return its default value. - mutating func clearIncrementalMacChunkSize() {self._incrementalMacChunkSize = nil} + mutating func clearIncrementalMacChunkSize() {_uniqueStorage()._incrementalMacChunkSize = nil} var fileName: String { - get {return _fileName ?? String()} - set {_fileName = newValue} + get {return _storage._fileName ?? String()} + set {_uniqueStorage()._fileName = newValue} } /// Returns true if `fileName` has been explicitly set. - var hasFileName: Bool {return self._fileName != nil} + var hasFileName: Bool {return _storage._fileName != nil} /// Clears the value of `fileName`. Subsequent reads from it will return its default value. - mutating func clearFileName() {self._fileName = nil} + mutating func clearFileName() {_uniqueStorage()._fileName = nil} var flags: UInt32 { - get {return _flags ?? 0} - set {_flags = newValue} + get {return _storage._flags ?? 0} + set {_uniqueStorage()._flags = newValue} } /// Returns true if `flags` has been explicitly set. - var hasFlags: Bool {return self._flags != nil} + var hasFlags: Bool {return _storage._flags != nil} /// Clears the value of `flags`. Subsequent reads from it will return its default value. - mutating func clearFlags() {self._flags = nil} + mutating func clearFlags() {_uniqueStorage()._flags = nil} var width: UInt32 { - get {return _width ?? 0} - set {_width = newValue} + get {return _storage._width ?? 0} + set {_uniqueStorage()._width = newValue} } /// Returns true if `width` has been explicitly set. - var hasWidth: Bool {return self._width != nil} + var hasWidth: Bool {return _storage._width != nil} /// Clears the value of `width`. Subsequent reads from it will return its default value. - mutating func clearWidth() {self._width = nil} + mutating func clearWidth() {_uniqueStorage()._width = nil} var height: UInt32 { - get {return _height ?? 0} - set {_height = newValue} + get {return _storage._height ?? 0} + set {_uniqueStorage()._height = newValue} } /// Returns true if `height` has been explicitly set. - var hasHeight: Bool {return self._height != nil} + var hasHeight: Bool {return _storage._height != nil} /// Clears the value of `height`. Subsequent reads from it will return its default value. - mutating func clearHeight() {self._height = nil} + mutating func clearHeight() {_uniqueStorage()._height = nil} var caption: String { - get {return _caption ?? String()} - set {_caption = newValue} + get {return _storage._caption ?? String()} + set {_uniqueStorage()._caption = newValue} } /// Returns true if `caption` has been explicitly set. - var hasCaption: Bool {return self._caption != nil} + var hasCaption: Bool {return _storage._caption != nil} /// Clears the value of `caption`. Subsequent reads from it will return its default value. - mutating func clearCaption() {self._caption = nil} + mutating func clearCaption() {_uniqueStorage()._caption = nil} var blurHash: String { - get {return _blurHash ?? String()} - set {_blurHash = newValue} + get {return _storage._blurHash ?? String()} + set {_uniqueStorage()._blurHash = newValue} } /// Returns true if `blurHash` has been explicitly set. - var hasBlurHash: Bool {return self._blurHash != nil} + var hasBlurHash: Bool {return _storage._blurHash != nil} /// Clears the value of `blurHash`. Subsequent reads from it will return its default value. - mutating func clearBlurHash() {self._blurHash = nil} - - var uploadTimestamp: UInt64 { - get {return _uploadTimestamp ?? 0} - set {_uploadTimestamp = newValue} - } - /// Returns true if `uploadTimestamp` has been explicitly set. - var hasUploadTimestamp: Bool {return self._uploadTimestamp != nil} - /// Clears the value of `uploadTimestamp`. Subsequent reads from it will return its default value. - mutating func clearUploadTimestamp() {self._uploadTimestamp = nil} - - var cdnNumber: UInt32 { - get {return _cdnNumber ?? 0} - set {_cdnNumber = newValue} - } - /// Returns true if `cdnNumber` has been explicitly set. - var hasCdnNumber: Bool {return self._cdnNumber != nil} - /// Clears the value of `cdnNumber`. Subsequent reads from it will return its default value. - mutating func clearCdnNumber() {self._cdnNumber = nil} + mutating func clearBlurHash() {_uniqueStorage()._blurHash = nil} var unknownFields = SwiftProtobuf.UnknownStorage() @@ -2827,29 +2732,101 @@ struct BackupProtos_AttachmentPointer { } + struct BackupLocator { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// @required + var mediaName: String { + get {return _mediaName ?? String()} + set {_mediaName = newValue} + } + /// Returns true if `mediaName` has been explicitly set. + var hasMediaName: Bool {return self._mediaName != nil} + /// Clears the value of `mediaName`. Subsequent reads from it will return its default value. + mutating func clearMediaName() {self._mediaName = nil} + + /// @required + var cdnNumber: UInt32 { + get {return _cdnNumber ?? 0} + set {_cdnNumber = newValue} + } + /// Returns true if `cdnNumber` has been explicitly set. + var hasCdnNumber: Bool {return self._cdnNumber != nil} + /// Clears the value of `cdnNumber`. Subsequent reads from it will return its default value. + mutating func clearCdnNumber() {self._cdnNumber = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _mediaName: String? = nil + fileprivate var _cdnNumber: UInt32? = nil + } + + struct AttachmentLocator { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// @required + var cdnKey: String { + get {return _cdnKey ?? String()} + set {_cdnKey = newValue} + } + /// Returns true if `cdnKey` has been explicitly set. + var hasCdnKey: Bool {return self._cdnKey != nil} + /// Clears the value of `cdnKey`. Subsequent reads from it will return its default value. + mutating func clearCdnKey() {self._cdnKey = nil} + + /// @required + var cdnNumber: UInt32 { + get {return _cdnNumber ?? 0} + set {_cdnNumber = newValue} + } + /// Returns true if `cdnNumber` has been explicitly set. + var hasCdnNumber: Bool {return self._cdnNumber != nil} + /// Clears the value of `cdnNumber`. Subsequent reads from it will return its default value. + mutating func clearCdnNumber() {self._cdnNumber = nil} + + /// @required + var uploadTimestamp: UInt64 { + get {return _uploadTimestamp ?? 0} + set {_uploadTimestamp = newValue} + } + /// Returns true if `uploadTimestamp` has been explicitly set. + var hasUploadTimestamp: Bool {return self._uploadTimestamp != nil} + /// Clears the value of `uploadTimestamp`. Subsequent reads from it will return its default value. + mutating func clearUploadTimestamp() {self._uploadTimestamp = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _cdnKey: String? = nil + fileprivate var _cdnNumber: UInt32? = nil + fileprivate var _uploadTimestamp: UInt64? = nil + } + + struct LegacyAttachmentLocator { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + init() {} - fileprivate var _cdnID: UInt64? = nil - fileprivate var _cdnKey: String? = nil - fileprivate var _contentType: String? = nil - fileprivate var _key: Data? = nil - fileprivate var _size: UInt32? = nil - fileprivate var _digest: Data? = nil - fileprivate var _incrementalMac: Data? = nil - fileprivate var _incrementalMacChunkSize: Data? = nil - fileprivate var _fileName: String? = nil - fileprivate var _flags: UInt32? = nil - fileprivate var _width: UInt32? = nil - fileprivate var _height: UInt32? = nil - fileprivate var _caption: String? = nil - fileprivate var _blurHash: String? = nil - fileprivate var _uploadTimestamp: UInt64? = nil - fileprivate var _cdnNumber: UInt32? = nil + fileprivate var _storage = _StorageClass.defaultInstance } #if swift(>=4.2) -extension BackupProtos_AttachmentPointer.Flags: CaseIterable { +extension BackupProtos_FilePointer.Flags: CaseIterable { // Support synthesized by the compiler. } @@ -2860,15 +2837,17 @@ struct BackupProtos_Quote { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - var id: UInt64 { - get {return _id ?? 0} - set {_id = newValue} + /// null if the target message could not be found at time of quote insert + var targetSentTimestamp: UInt64 { + get {return _targetSentTimestamp ?? 0} + set {_targetSentTimestamp = newValue} } - /// Returns true if `id` has been explicitly set. - var hasID: Bool {return self._id != nil} - /// Clears the value of `id`. Subsequent reads from it will return its default value. - mutating func clearID() {self._id = nil} + /// Returns true if `targetSentTimestamp` has been explicitly set. + var hasTargetSentTimestamp: Bool {return self._targetSentTimestamp != nil} + /// Clears the value of `targetSentTimestamp`. Subsequent reads from it will return its default value. + mutating func clearTargetSentTimestamp() {self._targetSentTimestamp = nil} + /// @required var authorID: UInt64 { get {return _authorID ?? 0} set {_authorID = newValue} @@ -2892,7 +2871,7 @@ struct BackupProtos_Quote { var bodyRanges: [BackupProtos_BodyRange] = [] var type: BackupProtos_Quote.TypeEnum { - get {return _type ?? .normal} + get {return _type ?? .unknown} set {_type = newValue} } /// Returns true if `type` has been explicitly set. @@ -2904,25 +2883,28 @@ struct BackupProtos_Quote { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case normal // = 0 - case giftbadge // = 1 + case unknown // = 0 + case normal // = 1 + case giftbadge // = 2 init() { - self = .normal + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .normal - case 1: self = .giftbadge + case 0: self = .unknown + case 1: self = .normal + case 2: self = .giftbadge default: return nil } } var rawValue: Int { switch self { - case .normal: return 0 - case .giftbadge: return 1 + case .unknown: return 0 + case .normal: return 1 + case .giftbadge: return 2 } } @@ -2934,42 +2916,44 @@ struct BackupProtos_Quote { // methods supported on all messages. var contentType: String { - get {return _storage._contentType ?? String()} - set {_uniqueStorage()._contentType = newValue} + get {return _contentType ?? String()} + set {_contentType = newValue} } /// Returns true if `contentType` has been explicitly set. - var hasContentType: Bool {return _storage._contentType != nil} + var hasContentType: Bool {return self._contentType != nil} /// Clears the value of `contentType`. Subsequent reads from it will return its default value. - mutating func clearContentType() {_uniqueStorage()._contentType = nil} + mutating func clearContentType() {self._contentType = nil} var fileName: String { - get {return _storage._fileName ?? String()} - set {_uniqueStorage()._fileName = newValue} + get {return _fileName ?? String()} + set {_fileName = newValue} } /// Returns true if `fileName` has been explicitly set. - var hasFileName: Bool {return _storage._fileName != nil} + var hasFileName: Bool {return self._fileName != nil} /// Clears the value of `fileName`. Subsequent reads from it will return its default value. - mutating func clearFileName() {_uniqueStorage()._fileName = nil} + mutating func clearFileName() {self._fileName = nil} - var thumbnail: BackupProtos_AttachmentPointer { - get {return _storage._thumbnail ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._thumbnail = newValue} + var thumbnail: BackupProtos_FilePointer { + get {return _thumbnail ?? BackupProtos_FilePointer()} + set {_thumbnail = newValue} } /// Returns true if `thumbnail` has been explicitly set. - var hasThumbnail: Bool {return _storage._thumbnail != nil} + var hasThumbnail: Bool {return self._thumbnail != nil} /// Clears the value of `thumbnail`. Subsequent reads from it will return its default value. - mutating func clearThumbnail() {_uniqueStorage()._thumbnail = nil} + mutating func clearThumbnail() {self._thumbnail = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _contentType: String? = nil + fileprivate var _fileName: String? = nil + fileprivate var _thumbnail: BackupProtos_FilePointer? = nil } init() {} - fileprivate var _id: UInt64? = nil + fileprivate var _targetSentTimestamp: UInt64? = nil fileprivate var _authorID: UInt64? = nil fileprivate var _text: String? = nil fileprivate var _type: BackupProtos_Quote.TypeEnum? = nil @@ -3007,8 +2991,8 @@ struct BackupProtos_BodyRange { mutating func clearLength() {self._length = nil} /// oneof associatedValue { - var mentionAci: String { - get {return _mentionAci ?? String()} + var mentionAci: Data { + get {return _mentionAci ?? Data()} set {_mentionAci = newValue} } /// Returns true if `mentionAci` has been explicitly set. @@ -3070,7 +3054,7 @@ struct BackupProtos_BodyRange { fileprivate var _start: UInt32? = nil fileprivate var _length: UInt32? = nil - fileprivate var _mentionAci: String? = nil + fileprivate var _mentionAci: Data? = nil fileprivate var _style: BackupProtos_BodyRange.Style? = nil } @@ -3272,37 +3256,40 @@ struct BackupProtos_CallMessage { enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case incomingAudioCall // = 0 - case incomingVideoCall // = 1 - case outgoingAudioCall // = 2 - case outgoingVideoCall // = 3 - case missedAudioCall // = 4 - case missedVideoCall // = 5 + case unknown // = 0 + case incomingAudioCall // = 1 + case incomingVideoCall // = 2 + case outgoingAudioCall // = 3 + case outgoingVideoCall // = 4 + case missedAudioCall // = 5 + case missedVideoCall // = 6 init() { - self = .incomingAudioCall + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .incomingAudioCall - case 1: self = .incomingVideoCall - case 2: self = .outgoingAudioCall - case 3: self = .outgoingVideoCall - case 4: self = .missedAudioCall - case 5: self = .missedVideoCall + case 0: self = .unknown + case 1: self = .incomingAudioCall + case 2: self = .incomingVideoCall + case 3: self = .outgoingAudioCall + case 4: self = .outgoingVideoCall + case 5: self = .missedAudioCall + case 6: self = .missedVideoCall default: return nil } } var rawValue: Int { switch self { - case .incomingAudioCall: return 0 - case .incomingVideoCall: return 1 - case .outgoingAudioCall: return 2 - case .outgoingVideoCall: return 3 - case .missedAudioCall: return 4 - case .missedVideoCall: return 5 + case .unknown: return 0 + case .incomingAudioCall: return 1 + case .incomingVideoCall: return 2 + case .outgoingAudioCall: return 3 + case .outgoingVideoCall: return 4 + case .missedAudioCall: return 5 + case .missedVideoCall: return 6 } } @@ -3325,14 +3312,14 @@ struct BackupProtos_GroupCallMessage { // methods supported on all messages. /// @required - var startedCallUuid: Data { - get {return _startedCallUuid ?? Data()} - set {_startedCallUuid = newValue} + var startedCallAci: Data { + get {return _startedCallAci ?? Data()} + set {_startedCallAci = newValue} } - /// Returns true if `startedCallUuid` has been explicitly set. - var hasStartedCallUuid: Bool {return self._startedCallUuid != nil} - /// Clears the value of `startedCallUuid`. Subsequent reads from it will return its default value. - mutating func clearStartedCallUuid() {self._startedCallUuid = nil} + /// Returns true if `startedCallAci` has been explicitly set. + var hasStartedCallAci: Bool {return self._startedCallAci != nil} + /// Clears the value of `startedCallAci`. Subsequent reads from it will return its default value. + mutating func clearStartedCallAci() {self._startedCallAci = nil} /// @required var startedCallTimestamp: UInt64 { @@ -3344,25 +3331,14 @@ struct BackupProtos_GroupCallMessage { /// Clears the value of `startedCallTimestamp`. Subsequent reads from it will return its default value. mutating func clearStartedCallTimestamp() {self._startedCallTimestamp = nil} - var inCallUuids: [Data] = [] - - /// @required - var isCallFull: Bool { - get {return _isCallFull ?? false} - set {_isCallFull = newValue} - } - /// Returns true if `isCallFull` has been explicitly set. - var hasIsCallFull: Bool {return self._isCallFull != nil} - /// Clears the value of `isCallFull`. Subsequent reads from it will return its default value. - mutating func clearIsCallFull() {self._isCallFull = nil} + var inCallAcis: [Data] = [] var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _startedCallUuid: Data? = nil + fileprivate var _startedCallAci: Data? = nil fileprivate var _startedCallTimestamp: UInt64? = nil - fileprivate var _isCallFull: Bool? = nil } struct BackupProtos_SimpleUpdate { @@ -3370,64 +3346,78 @@ struct BackupProtos_SimpleUpdate { // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. + var type: BackupProtos_SimpleUpdate.TypeEnum { + get {return _type ?? .unknown} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + var unknownFields = SwiftProtobuf.UnknownStorage() enum TypeEnum: SwiftProtobuf.Enum { typealias RawValue = Int - case joinedSignal // = 0 - case identityUpdate // = 1 - case identityVerified // = 2 + case unknown // = 0 + case joinedSignal // = 1 + case identityUpdate // = 2 + case identityVerified // = 3 /// marking as unverified - case identityDefault // = 3 - case changeNumber // = 4 - case boostRequest // = 5 - case endSession // = 6 - case chatSessionRefresh // = 7 - case badDecrypt // = 8 - case paymentsActivated // = 9 - case paymentActivationRequest // = 10 + case identityDefault // = 4 + case changeNumber // = 5 + case boostRequest // = 6 + case endSession // = 7 + case chatSessionRefresh // = 8 + case badDecrypt // = 9 + case paymentsActivated // = 10 + case paymentActivationRequest // = 11 init() { - self = .joinedSignal + self = .unknown } init?(rawValue: Int) { switch rawValue { - case 0: self = .joinedSignal - case 1: self = .identityUpdate - case 2: self = .identityVerified - case 3: self = .identityDefault - case 4: self = .changeNumber - case 5: self = .boostRequest - case 6: self = .endSession - case 7: self = .chatSessionRefresh - case 8: self = .badDecrypt - case 9: self = .paymentsActivated - case 10: self = .paymentActivationRequest + case 0: self = .unknown + case 1: self = .joinedSignal + case 2: self = .identityUpdate + case 3: self = .identityVerified + case 4: self = .identityDefault + case 5: self = .changeNumber + case 6: self = .boostRequest + case 7: self = .endSession + case 8: self = .chatSessionRefresh + case 9: self = .badDecrypt + case 10: self = .paymentsActivated + case 11: self = .paymentActivationRequest default: return nil } } var rawValue: Int { switch self { - case .joinedSignal: return 0 - case .identityUpdate: return 1 - case .identityVerified: return 2 - case .identityDefault: return 3 - case .changeNumber: return 4 - case .boostRequest: return 5 - case .endSession: return 6 - case .chatSessionRefresh: return 7 - case .badDecrypt: return 8 - case .paymentsActivated: return 9 - case .paymentActivationRequest: return 10 + case .unknown: return 0 + case .joinedSignal: return 1 + case .identityUpdate: return 2 + case .identityVerified: return 3 + case .identityDefault: return 4 + case .changeNumber: return 5 + case .boostRequest: return 6 + case .endSession: return 7 + case .chatSessionRefresh: return 8 + case .badDecrypt: return 9 + case .paymentsActivated: return 10 + case .paymentActivationRequest: return 11 } } } init() {} + + fileprivate var _type: BackupProtos_SimpleUpdate.TypeEnum? = nil } #if swift(>=4.2) @@ -3444,20 +3434,20 @@ struct BackupProtos_GroupDescriptionUpdate { // methods supported on all messages. /// @required - var body: String { - get {return _body ?? String()} - set {_body = newValue} + var newDescription: String { + get {return _newDescription ?? String()} + set {_newDescription = newValue} } - /// Returns true if `body` has been explicitly set. - var hasBody: Bool {return self._body != nil} - /// Clears the value of `body`. Subsequent reads from it will return its default value. - mutating func clearBody() {self._body = nil} + /// Returns true if `newDescription` has been explicitly set. + var hasNewDescription: Bool {return self._newDescription != nil} + /// Clears the value of `newDescription`. Subsequent reads from it will return its default value. + mutating func clearNewDescription() {self._newDescription = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _body: String? = nil + fileprivate var _newDescription: String? = nil } struct BackupProtos_ExpirationTimerChange { @@ -3466,20 +3456,20 @@ struct BackupProtos_ExpirationTimerChange { // methods supported on all messages. /// @required - var expiresIn: UInt32 { - get {return _expiresIn ?? 0} - set {_expiresIn = newValue} + var expiresInMs: UInt32 { + get {return _expiresInMs ?? 0} + set {_expiresInMs = newValue} } - /// Returns true if `expiresIn` has been explicitly set. - var hasExpiresIn: Bool {return self._expiresIn != nil} - /// Clears the value of `expiresIn`. Subsequent reads from it will return its default value. - mutating func clearExpiresIn() {self._expiresIn = nil} + /// Returns true if `expiresInMs` has been explicitly set. + var hasExpiresInMs: Bool {return self._expiresInMs != nil} + /// Clears the value of `expiresInMs`. Subsequent reads from it will return its default value. + mutating func clearExpiresInMs() {self._expiresInMs = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _expiresIn: UInt32? = nil + fileprivate var _expiresInMs: UInt32? = nil } struct BackupProtos_ProfileChange { @@ -3623,30 +3613,31 @@ struct BackupProtos_StickerPackSticker { // methods supported on all messages. /// @required - var data: BackupProtos_AttachmentPointer { - get {return _storage._data ?? BackupProtos_AttachmentPointer()} - set {_uniqueStorage()._data = newValue} + var data: BackupProtos_FilePointer { + get {return _data ?? BackupProtos_FilePointer()} + set {_data = newValue} } /// Returns true if `data` has been explicitly set. - var hasData: Bool {return _storage._data != nil} + var hasData: Bool {return self._data != nil} /// Clears the value of `data`. Subsequent reads from it will return its default value. - mutating func clearData() {_uniqueStorage()._data = nil} + mutating func clearData() {self._data = nil} /// @required var emoji: String { - get {return _storage._emoji ?? String()} - set {_uniqueStorage()._emoji = newValue} + get {return _emoji ?? String()} + set {_emoji = newValue} } /// Returns true if `emoji` has been explicitly set. - var hasEmoji: Bool {return _storage._emoji != nil} + var hasEmoji: Bool {return self._emoji != nil} /// Clears the value of `emoji`. Subsequent reads from it will return its default value. - mutating func clearEmoji() {_uniqueStorage()._emoji = nil} + mutating func clearEmoji() {self._emoji = nil} var unknownFields = SwiftProtobuf.UnknownStorage() init() {} - fileprivate var _storage = _StorageClass.defaultInstance + fileprivate var _data: BackupProtos_FilePointer? = nil + fileprivate var _emoji: String? = nil } #if swift(>=5.5) && canImport(_Concurrency) @@ -3663,6 +3654,7 @@ extension BackupProtos_Contact.Registered: @unchecked Sendable {} extension BackupProtos_Group: @unchecked Sendable {} extension BackupProtos_Group.StorySendMode: @unchecked Sendable {} extension BackupProtos_SelfRecipient: @unchecked Sendable {} +extension BackupProtos_ReleaseNotes: @unchecked Sendable {} extension BackupProtos_Chat: @unchecked Sendable {} extension BackupProtos_DistributionList: @unchecked Sendable {} extension BackupProtos_DistributionList.PrivacyMode: @unchecked Sendable {} @@ -3694,8 +3686,11 @@ extension BackupProtos_RemoteDeletedMessage: @unchecked Sendable {} extension BackupProtos_ScheduledMessage: @unchecked Sendable {} extension BackupProtos_Sticker: @unchecked Sendable {} extension BackupProtos_LinkPreview: @unchecked Sendable {} -extension BackupProtos_AttachmentPointer: @unchecked Sendable {} -extension BackupProtos_AttachmentPointer.Flags: @unchecked Sendable {} +extension BackupProtos_FilePointer: @unchecked Sendable {} +extension BackupProtos_FilePointer.Flags: @unchecked Sendable {} +extension BackupProtos_FilePointer.BackupLocator: @unchecked Sendable {} +extension BackupProtos_FilePointer.AttachmentLocator: @unchecked Sendable {} +extension BackupProtos_FilePointer.LegacyAttachmentLocator: @unchecked Sendable {} extension BackupProtos_Quote: @unchecked Sendable {} extension BackupProtos_Quote.TypeEnum: @unchecked Sendable {} extension BackupProtos_Quote.QuotedAttachment: @unchecked Sendable {} @@ -3726,7 +3721,7 @@ extension BackupProtos_BackupInfo: SwiftProtobuf.Message, SwiftProtobuf._Message static let protoMessageName: String = _protobuf_package + ".BackupInfo" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "version"), - 2: .same(proto: "backupTime"), + 2: .same(proto: "backupTimeMs"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -3736,7 +3731,7 @@ extension BackupProtos_BackupInfo: SwiftProtobuf.Message, SwiftProtobuf._Message // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeSingularUInt64Field(value: &self._version) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self._backupTime) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self._backupTimeMs) }() default: break } } @@ -3750,7 +3745,7 @@ extension BackupProtos_BackupInfo: SwiftProtobuf.Message, SwiftProtobuf._Message try { if let v = self._version { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1) } }() - try { if let v = self._backupTime { + try { if let v = self._backupTimeMs { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 2) } }() try unknownFields.traverse(visitor: &visitor) @@ -3758,7 +3753,7 @@ extension BackupProtos_BackupInfo: SwiftProtobuf.Message, SwiftProtobuf._Message static func ==(lhs: BackupProtos_BackupInfo, rhs: BackupProtos_BackupInfo) -> Bool { if lhs._version != rhs._version {return false} - if lhs._backupTime != rhs._backupTime {return false} + if lhs._backupTimeMs != rhs._backupTimeMs {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -3875,194 +3870,88 @@ extension BackupProtos_Frame: SwiftProtobuf.Message, SwiftProtobuf._MessageImple extension BackupProtos_AccountData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".AccountData" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "aciIdentityPublicKey"), - 2: .same(proto: "aciIdentityPrivateKey"), - 3: .same(proto: "pniIdentityPublicKey"), - 4: .same(proto: "pniIdentityPrivateKey"), - 5: .same(proto: "profileKey"), - 6: .same(proto: "username"), - 7: .same(proto: "usernameLink"), - 8: .same(proto: "givenName"), - 9: .same(proto: "familyName"), - 10: .same(proto: "avatarPath"), - 11: .same(proto: "subscriberId"), - 12: .same(proto: "subscriberCurrencyCode"), - 13: .same(proto: "subscriptionManuallyCancelled"), - 14: .same(proto: "accountSettings"), - 15: .same(proto: "aci"), - 16: .same(proto: "pni"), - 17: .same(proto: "e164"), + 1: .same(proto: "profileKey"), + 2: .same(proto: "username"), + 3: .same(proto: "usernameLink"), + 4: .same(proto: "givenName"), + 5: .same(proto: "familyName"), + 6: .same(proto: "avatarPath"), + 7: .same(proto: "subscriberId"), + 8: .same(proto: "subscriberCurrencyCode"), + 9: .same(proto: "subscriptionManuallyCancelled"), + 10: .same(proto: "accountSettings"), ] - fileprivate class _StorageClass { - var _aciIdentityPublicKey: Data? = nil - var _aciIdentityPrivateKey: Data? = nil - var _pniIdentityPublicKey: Data? = nil - var _pniIdentityPrivateKey: Data? = nil - var _profileKey: Data? = nil - var _username: String? = nil - var _usernameLink: BackupProtos_AccountData.UsernameLink? = nil - var _givenName: String? = nil - var _familyName: String? = nil - var _avatarPath: String? = nil - var _subscriberID: Data? = nil - var _subscriberCurrencyCode: String? = nil - var _subscriptionManuallyCancelled: Bool? = nil - var _accountSettings: BackupProtos_AccountData.AccountSettings? = nil - var _aci: Data? = nil - var _pni: Data? = nil - var _e164: UInt64? = nil - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _aciIdentityPublicKey = source._aciIdentityPublicKey - _aciIdentityPrivateKey = source._aciIdentityPrivateKey - _pniIdentityPublicKey = source._pniIdentityPublicKey - _pniIdentityPrivateKey = source._pniIdentityPrivateKey - _profileKey = source._profileKey - _username = source._username - _usernameLink = source._usernameLink - _givenName = source._givenName - _familyName = source._familyName - _avatarPath = source._avatarPath - _subscriberID = source._subscriberID - _subscriberCurrencyCode = source._subscriberCurrencyCode - _subscriptionManuallyCancelled = source._subscriptionManuallyCancelled - _accountSettings = source._accountSettings - _aci = source._aci - _pni = source._pni - _e164 = source._e164 - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &_storage._aciIdentityPublicKey) }() - case 2: try { try decoder.decodeSingularBytesField(value: &_storage._aciIdentityPrivateKey) }() - case 3: try { try decoder.decodeSingularBytesField(value: &_storage._pniIdentityPublicKey) }() - case 4: try { try decoder.decodeSingularBytesField(value: &_storage._pniIdentityPrivateKey) }() - case 5: try { try decoder.decodeSingularBytesField(value: &_storage._profileKey) }() - case 6: try { try decoder.decodeSingularStringField(value: &_storage._username) }() - case 7: try { try decoder.decodeSingularMessageField(value: &_storage._usernameLink) }() - case 8: try { try decoder.decodeSingularStringField(value: &_storage._givenName) }() - case 9: try { try decoder.decodeSingularStringField(value: &_storage._familyName) }() - case 10: try { try decoder.decodeSingularStringField(value: &_storage._avatarPath) }() - case 11: try { try decoder.decodeSingularBytesField(value: &_storage._subscriberID) }() - case 12: try { try decoder.decodeSingularStringField(value: &_storage._subscriberCurrencyCode) }() - case 13: try { try decoder.decodeSingularBoolField(value: &_storage._subscriptionManuallyCancelled) }() - case 14: try { try decoder.decodeSingularMessageField(value: &_storage._accountSettings) }() - case 15: try { try decoder.decodeSingularBytesField(value: &_storage._aci) }() - case 16: try { try decoder.decodeSingularBytesField(value: &_storage._pni) }() - case 17: try { try decoder.decodeSingularUInt64Field(value: &_storage._e164) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._profileKey) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._username) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._usernameLink) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._givenName) }() + case 5: try { try decoder.decodeSingularStringField(value: &self._familyName) }() + case 6: try { try decoder.decodeSingularStringField(value: &self._avatarPath) }() + case 7: try { try decoder.decodeSingularBytesField(value: &self._subscriberID) }() + case 8: try { try decoder.decodeSingularStringField(value: &self._subscriberCurrencyCode) }() + case 9: try { try decoder.decodeSingularBoolField(value: &self._subscriptionManuallyCancelled) }() + case 10: try { try decoder.decodeSingularMessageField(value: &self._accountSettings) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._aciIdentityPublicKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._aciIdentityPrivateKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try { if let v = _storage._pniIdentityPublicKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 3) - } }() - try { if let v = _storage._pniIdentityPrivateKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 4) - } }() - try { if let v = _storage._profileKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 5) - } }() - try { if let v = _storage._username { - try visitor.visitSingularStringField(value: v, fieldNumber: 6) - } }() - try { if let v = _storage._usernameLink { - try visitor.visitSingularMessageField(value: v, fieldNumber: 7) - } }() - try { if let v = _storage._givenName { - try visitor.visitSingularStringField(value: v, fieldNumber: 8) - } }() - try { if let v = _storage._familyName { - try visitor.visitSingularStringField(value: v, fieldNumber: 9) - } }() - try { if let v = _storage._avatarPath { - try visitor.visitSingularStringField(value: v, fieldNumber: 10) - } }() - try { if let v = _storage._subscriberID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 11) - } }() - try { if let v = _storage._subscriberCurrencyCode { - try visitor.visitSingularStringField(value: v, fieldNumber: 12) - } }() - try { if let v = _storage._subscriptionManuallyCancelled { - try visitor.visitSingularBoolField(value: v, fieldNumber: 13) - } }() - try { if let v = _storage._accountSettings { - try visitor.visitSingularMessageField(value: v, fieldNumber: 14) - } }() - try { if let v = _storage._aci { - try visitor.visitSingularBytesField(value: v, fieldNumber: 15) - } }() - try { if let v = _storage._pni { - try visitor.visitSingularBytesField(value: v, fieldNumber: 16) - } }() - try { if let v = _storage._e164 { - try visitor.visitSingularUInt64Field(value: v, fieldNumber: 17) - } }() - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._profileKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._username { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._usernameLink { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._givenName { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() + try { if let v = self._familyName { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try { if let v = self._avatarPath { + try visitor.visitSingularStringField(value: v, fieldNumber: 6) + } }() + try { if let v = self._subscriberID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 7) + } }() + try { if let v = self._subscriberCurrencyCode { + try visitor.visitSingularStringField(value: v, fieldNumber: 8) + } }() + try { if let v = self._subscriptionManuallyCancelled { + try visitor.visitSingularBoolField(value: v, fieldNumber: 9) + } }() + try { if let v = self._accountSettings { + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_AccountData, rhs: BackupProtos_AccountData) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._aciIdentityPublicKey != rhs_storage._aciIdentityPublicKey {return false} - if _storage._aciIdentityPrivateKey != rhs_storage._aciIdentityPrivateKey {return false} - if _storage._pniIdentityPublicKey != rhs_storage._pniIdentityPublicKey {return false} - if _storage._pniIdentityPrivateKey != rhs_storage._pniIdentityPrivateKey {return false} - if _storage._profileKey != rhs_storage._profileKey {return false} - if _storage._username != rhs_storage._username {return false} - if _storage._usernameLink != rhs_storage._usernameLink {return false} - if _storage._givenName != rhs_storage._givenName {return false} - if _storage._familyName != rhs_storage._familyName {return false} - if _storage._avatarPath != rhs_storage._avatarPath {return false} - if _storage._subscriberID != rhs_storage._subscriberID {return false} - if _storage._subscriberCurrencyCode != rhs_storage._subscriberCurrencyCode {return false} - if _storage._subscriptionManuallyCancelled != rhs_storage._subscriptionManuallyCancelled {return false} - if _storage._accountSettings != rhs_storage._accountSettings {return false} - if _storage._aci != rhs_storage._aci {return false} - if _storage._pni != rhs_storage._pni {return false} - if _storage._e164 != rhs_storage._e164 {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._profileKey != rhs._profileKey {return false} + if lhs._username != rhs._username {return false} + if lhs._usernameLink != rhs._usernameLink {return false} + if lhs._givenName != rhs._givenName {return false} + if lhs._familyName != rhs._familyName {return false} + if lhs._avatarPath != rhs._avatarPath {return false} + if lhs._subscriberID != rhs._subscriberID {return false} + if lhs._subscriberCurrencyCode != rhs._subscriberCurrencyCode {return false} + if lhs._subscriptionManuallyCancelled != rhs._subscriptionManuallyCancelled {return false} + if lhs._accountSettings != rhs._accountSettings {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -4070,8 +3959,8 @@ extension BackupProtos_AccountData: SwiftProtobuf.Message, SwiftProtobuf._Messag extension BackupProtos_AccountData.PhoneNumberSharingMode: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "EVERYBODY"), - 1: .same(proto: "CONTACTS_ONLY"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "EVERYBODY"), 2: .same(proto: "NOBODY"), ] } @@ -4141,38 +4030,33 @@ extension BackupProtos_AccountData.UsernameLink.Color: SwiftProtobuf._ProtoNameP extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = BackupProtos_AccountData.protoMessageName + ".AccountSettings" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "noteToSelfArchived"), - 2: .same(proto: "readReceipts"), - 3: .same(proto: "sealedSenderIndicators"), - 4: .same(proto: "typingIndicators"), - 5: .same(proto: "proxiedLinkPreviews"), - 6: .same(proto: "noteToSelfMarkedUnread"), - 7: .same(proto: "linkPreviews"), - 8: .same(proto: "unlistedPhoneNumber"), - 9: .same(proto: "preferContactAvatars"), - 10: .same(proto: "universalExpireTimer"), - 11: .same(proto: "preferredReactionEmoji"), - 12: .same(proto: "displayBadgesOnProfile"), - 13: .same(proto: "keepMutedChatsArchived"), - 14: .same(proto: "myStoriesPrivacyHasBeenSet"), - 15: .same(proto: "onboardingStoryHasBeenViewed"), - 16: .same(proto: "storiesDisabled"), - 17: .same(proto: "storyViewReceiptsEnabled"), - 18: .same(proto: "onboardingStoryHasBeenRead"), - 19: .same(proto: "groupStoryEducationSheetHasBeenSet"), - 20: .same(proto: "usernameOnboardingHasBeenCompleted"), - 21: .same(proto: "phoneNumberSharingMode"), + 1: .same(proto: "readReceipts"), + 2: .same(proto: "sealedSenderIndicators"), + 3: .same(proto: "typingIndicators"), + 4: .same(proto: "noteToSelfMarkedUnread"), + 5: .same(proto: "linkPreviews"), + 6: .same(proto: "unlistedPhoneeumber"), + 7: .same(proto: "preferContactAvatars"), + 8: .same(proto: "universalExpireTimer"), + 9: .same(proto: "preferredReactionEmoji"), + 10: .same(proto: "displayBadgesOnProfile"), + 11: .same(proto: "keepMutedChatsArchived"), + 12: .same(proto: "myStoriesPrivacyHasBeenSet"), + 13: .same(proto: "onboardingStoryHasBeenViewed"), + 14: .same(proto: "storiesDisabled"), + 15: .same(proto: "storyViewReceiptsEnabled"), + 16: .same(proto: "groupStoryEducationSheetHasBeenSeen"), + 17: .same(proto: "usernameOnboardingHasBeenCompleted"), + 18: .same(proto: "phoneNumberSharingMode"), ] fileprivate class _StorageClass { - var _noteToSelfArchived: Bool? = nil var _readReceipts: Bool? = nil var _sealedSenderIndicators: Bool? = nil var _typingIndicators: Bool? = nil - var _proxiedLinkPreviews: Bool? = nil var _noteToSelfMarkedUnread: Bool? = nil var _linkPreviews: Bool? = nil - var _unlistedPhoneNumber: Bool? = nil + var _unlistedPhoneeumber: Bool? = nil var _preferContactAvatars: Bool? = nil var _universalExpireTimer: UInt32? = nil var _preferredReactionEmoji: [String] = [] @@ -4182,8 +4066,7 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift var _onboardingStoryHasBeenViewed: Bool? = nil var _storiesDisabled: Bool? = nil var _storyViewReceiptsEnabled: Bool? = nil - var _onboardingStoryHasBeenRead: Bool? = nil - var _groupStoryEducationSheetHasBeenSet: Bool? = nil + var _groupStoryEducationSheetHasBeenSeen: Bool? = nil var _usernameOnboardingHasBeenCompleted: Bool? = nil var _phoneNumberSharingMode: BackupProtos_AccountData.PhoneNumberSharingMode? = nil @@ -4192,14 +4075,12 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift private init() {} init(copying source: _StorageClass) { - _noteToSelfArchived = source._noteToSelfArchived _readReceipts = source._readReceipts _sealedSenderIndicators = source._sealedSenderIndicators _typingIndicators = source._typingIndicators - _proxiedLinkPreviews = source._proxiedLinkPreviews _noteToSelfMarkedUnread = source._noteToSelfMarkedUnread _linkPreviews = source._linkPreviews - _unlistedPhoneNumber = source._unlistedPhoneNumber + _unlistedPhoneeumber = source._unlistedPhoneeumber _preferContactAvatars = source._preferContactAvatars _universalExpireTimer = source._universalExpireTimer _preferredReactionEmoji = source._preferredReactionEmoji @@ -4209,8 +4090,7 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift _onboardingStoryHasBeenViewed = source._onboardingStoryHasBeenViewed _storiesDisabled = source._storiesDisabled _storyViewReceiptsEnabled = source._storyViewReceiptsEnabled - _onboardingStoryHasBeenRead = source._onboardingStoryHasBeenRead - _groupStoryEducationSheetHasBeenSet = source._groupStoryEducationSheetHasBeenSet + _groupStoryEducationSheetHasBeenSeen = source._groupStoryEducationSheetHasBeenSeen _usernameOnboardingHasBeenCompleted = source._usernameOnboardingHasBeenCompleted _phoneNumberSharingMode = source._phoneNumberSharingMode } @@ -4231,27 +4111,24 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularBoolField(value: &_storage._noteToSelfArchived) }() - case 2: try { try decoder.decodeSingularBoolField(value: &_storage._readReceipts) }() - case 3: try { try decoder.decodeSingularBoolField(value: &_storage._sealedSenderIndicators) }() - case 4: try { try decoder.decodeSingularBoolField(value: &_storage._typingIndicators) }() - case 5: try { try decoder.decodeSingularBoolField(value: &_storage._proxiedLinkPreviews) }() - case 6: try { try decoder.decodeSingularBoolField(value: &_storage._noteToSelfMarkedUnread) }() - case 7: try { try decoder.decodeSingularBoolField(value: &_storage._linkPreviews) }() - case 8: try { try decoder.decodeSingularBoolField(value: &_storage._unlistedPhoneNumber) }() - case 9: try { try decoder.decodeSingularBoolField(value: &_storage._preferContactAvatars) }() - case 10: try { try decoder.decodeSingularUInt32Field(value: &_storage._universalExpireTimer) }() - case 11: try { try decoder.decodeRepeatedStringField(value: &_storage._preferredReactionEmoji) }() - case 12: try { try decoder.decodeSingularBoolField(value: &_storage._displayBadgesOnProfile) }() - case 13: try { try decoder.decodeSingularBoolField(value: &_storage._keepMutedChatsArchived) }() - case 14: try { try decoder.decodeSingularBoolField(value: &_storage._myStoriesPrivacyHasBeenSet) }() - case 15: try { try decoder.decodeSingularBoolField(value: &_storage._onboardingStoryHasBeenViewed) }() - case 16: try { try decoder.decodeSingularBoolField(value: &_storage._storiesDisabled) }() - case 17: try { try decoder.decodeSingularBoolField(value: &_storage._storyViewReceiptsEnabled) }() - case 18: try { try decoder.decodeSingularBoolField(value: &_storage._onboardingStoryHasBeenRead) }() - case 19: try { try decoder.decodeSingularBoolField(value: &_storage._groupStoryEducationSheetHasBeenSet) }() - case 20: try { try decoder.decodeSingularBoolField(value: &_storage._usernameOnboardingHasBeenCompleted) }() - case 21: try { try decoder.decodeSingularEnumField(value: &_storage._phoneNumberSharingMode) }() + case 1: try { try decoder.decodeSingularBoolField(value: &_storage._readReceipts) }() + case 2: try { try decoder.decodeSingularBoolField(value: &_storage._sealedSenderIndicators) }() + case 3: try { try decoder.decodeSingularBoolField(value: &_storage._typingIndicators) }() + case 4: try { try decoder.decodeSingularBoolField(value: &_storage._noteToSelfMarkedUnread) }() + case 5: try { try decoder.decodeSingularBoolField(value: &_storage._linkPreviews) }() + case 6: try { try decoder.decodeSingularBoolField(value: &_storage._unlistedPhoneeumber) }() + case 7: try { try decoder.decodeSingularBoolField(value: &_storage._preferContactAvatars) }() + case 8: try { try decoder.decodeSingularUInt32Field(value: &_storage._universalExpireTimer) }() + case 9: try { try decoder.decodeRepeatedStringField(value: &_storage._preferredReactionEmoji) }() + case 10: try { try decoder.decodeSingularBoolField(value: &_storage._displayBadgesOnProfile) }() + case 11: try { try decoder.decodeSingularBoolField(value: &_storage._keepMutedChatsArchived) }() + case 12: try { try decoder.decodeSingularBoolField(value: &_storage._myStoriesPrivacyHasBeenSet) }() + case 13: try { try decoder.decodeSingularBoolField(value: &_storage._onboardingStoryHasBeenViewed) }() + case 14: try { try decoder.decodeSingularBoolField(value: &_storage._storiesDisabled) }() + case 15: try { try decoder.decodeSingularBoolField(value: &_storage._storyViewReceiptsEnabled) }() + case 16: try { try decoder.decodeSingularBoolField(value: &_storage._groupStoryEducationSheetHasBeenSeen) }() + case 17: try { try decoder.decodeSingularBoolField(value: &_storage._usernameOnboardingHasBeenCompleted) }() + case 18: try { try decoder.decodeSingularEnumField(value: &_storage._phoneNumberSharingMode) }() default: break } } @@ -4264,68 +4141,59 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._noteToSelfArchived { + try { if let v = _storage._readReceipts { try visitor.visitSingularBoolField(value: v, fieldNumber: 1) } }() - try { if let v = _storage._readReceipts { + try { if let v = _storage._sealedSenderIndicators { try visitor.visitSingularBoolField(value: v, fieldNumber: 2) } }() - try { if let v = _storage._sealedSenderIndicators { + try { if let v = _storage._typingIndicators { try visitor.visitSingularBoolField(value: v, fieldNumber: 3) } }() - try { if let v = _storage._typingIndicators { + try { if let v = _storage._noteToSelfMarkedUnread { try visitor.visitSingularBoolField(value: v, fieldNumber: 4) } }() - try { if let v = _storage._proxiedLinkPreviews { + try { if let v = _storage._linkPreviews { try visitor.visitSingularBoolField(value: v, fieldNumber: 5) } }() - try { if let v = _storage._noteToSelfMarkedUnread { + try { if let v = _storage._unlistedPhoneeumber { try visitor.visitSingularBoolField(value: v, fieldNumber: 6) } }() - try { if let v = _storage._linkPreviews { - try visitor.visitSingularBoolField(value: v, fieldNumber: 7) - } }() - try { if let v = _storage._unlistedPhoneNumber { - try visitor.visitSingularBoolField(value: v, fieldNumber: 8) - } }() try { if let v = _storage._preferContactAvatars { - try visitor.visitSingularBoolField(value: v, fieldNumber: 9) + try visitor.visitSingularBoolField(value: v, fieldNumber: 7) } }() try { if let v = _storage._universalExpireTimer { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 10) + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 8) } }() if !_storage._preferredReactionEmoji.isEmpty { - try visitor.visitRepeatedStringField(value: _storage._preferredReactionEmoji, fieldNumber: 11) + try visitor.visitRepeatedStringField(value: _storage._preferredReactionEmoji, fieldNumber: 9) } try { if let v = _storage._displayBadgesOnProfile { - try visitor.visitSingularBoolField(value: v, fieldNumber: 12) + try visitor.visitSingularBoolField(value: v, fieldNumber: 10) } }() try { if let v = _storage._keepMutedChatsArchived { - try visitor.visitSingularBoolField(value: v, fieldNumber: 13) + try visitor.visitSingularBoolField(value: v, fieldNumber: 11) } }() try { if let v = _storage._myStoriesPrivacyHasBeenSet { - try visitor.visitSingularBoolField(value: v, fieldNumber: 14) + try visitor.visitSingularBoolField(value: v, fieldNumber: 12) } }() try { if let v = _storage._onboardingStoryHasBeenViewed { - try visitor.visitSingularBoolField(value: v, fieldNumber: 15) + try visitor.visitSingularBoolField(value: v, fieldNumber: 13) } }() try { if let v = _storage._storiesDisabled { - try visitor.visitSingularBoolField(value: v, fieldNumber: 16) + try visitor.visitSingularBoolField(value: v, fieldNumber: 14) } }() try { if let v = _storage._storyViewReceiptsEnabled { - try visitor.visitSingularBoolField(value: v, fieldNumber: 17) - } }() - try { if let v = _storage._onboardingStoryHasBeenRead { - try visitor.visitSingularBoolField(value: v, fieldNumber: 18) + try visitor.visitSingularBoolField(value: v, fieldNumber: 15) } }() - try { if let v = _storage._groupStoryEducationSheetHasBeenSet { - try visitor.visitSingularBoolField(value: v, fieldNumber: 19) + try { if let v = _storage._groupStoryEducationSheetHasBeenSeen { + try visitor.visitSingularBoolField(value: v, fieldNumber: 16) } }() try { if let v = _storage._usernameOnboardingHasBeenCompleted { - try visitor.visitSingularBoolField(value: v, fieldNumber: 20) + try visitor.visitSingularBoolField(value: v, fieldNumber: 17) } }() try { if let v = _storage._phoneNumberSharingMode { - try visitor.visitSingularEnumField(value: v, fieldNumber: 21) + try visitor.visitSingularEnumField(value: v, fieldNumber: 18) } }() } try unknownFields.traverse(visitor: &visitor) @@ -4336,14 +4204,12 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in let _storage = _args.0 let rhs_storage = _args.1 - if _storage._noteToSelfArchived != rhs_storage._noteToSelfArchived {return false} if _storage._readReceipts != rhs_storage._readReceipts {return false} if _storage._sealedSenderIndicators != rhs_storage._sealedSenderIndicators {return false} if _storage._typingIndicators != rhs_storage._typingIndicators {return false} - if _storage._proxiedLinkPreviews != rhs_storage._proxiedLinkPreviews {return false} if _storage._noteToSelfMarkedUnread != rhs_storage._noteToSelfMarkedUnread {return false} if _storage._linkPreviews != rhs_storage._linkPreviews {return false} - if _storage._unlistedPhoneNumber != rhs_storage._unlistedPhoneNumber {return false} + if _storage._unlistedPhoneeumber != rhs_storage._unlistedPhoneeumber {return false} if _storage._preferContactAvatars != rhs_storage._preferContactAvatars {return false} if _storage._universalExpireTimer != rhs_storage._universalExpireTimer {return false} if _storage._preferredReactionEmoji != rhs_storage._preferredReactionEmoji {return false} @@ -4353,8 +4219,7 @@ extension BackupProtos_AccountData.AccountSettings: SwiftProtobuf.Message, Swift if _storage._onboardingStoryHasBeenViewed != rhs_storage._onboardingStoryHasBeenViewed {return false} if _storage._storiesDisabled != rhs_storage._storiesDisabled {return false} if _storage._storyViewReceiptsEnabled != rhs_storage._storyViewReceiptsEnabled {return false} - if _storage._onboardingStoryHasBeenRead != rhs_storage._onboardingStoryHasBeenRead {return false} - if _storage._groupStoryEducationSheetHasBeenSet != rhs_storage._groupStoryEducationSheetHasBeenSet {return false} + if _storage._groupStoryEducationSheetHasBeenSeen != rhs_storage._groupStoryEducationSheetHasBeenSeen {return false} if _storage._usernameOnboardingHasBeenCompleted != rhs_storage._usernameOnboardingHasBeenCompleted {return false} if _storage._phoneNumberSharingMode != rhs_storage._phoneNumberSharingMode {return false} return true @@ -4374,6 +4239,7 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI 3: .same(proto: "group"), 4: .same(proto: "distributionList"), 5: .same(proto: "selfRecipient"), + 6: .same(proto: "releaseNotes"), ] fileprivate class _StorageClass { @@ -4382,6 +4248,7 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI var _group: BackupProtos_Group? = nil var _distributionList: BackupProtos_DistributionList? = nil var _selfRecipient: BackupProtos_SelfRecipient? = nil + var _releaseNotes: BackupProtos_ReleaseNotes? = nil static let defaultInstance = _StorageClass() @@ -4393,6 +4260,7 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI _group = source._group _distributionList = source._distributionList _selfRecipient = source._selfRecipient + _releaseNotes = source._releaseNotes } } @@ -4416,6 +4284,7 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI case 3: try { try decoder.decodeSingularMessageField(value: &_storage._group) }() case 4: try { try decoder.decodeSingularMessageField(value: &_storage._distributionList) }() case 5: try { try decoder.decodeSingularMessageField(value: &_storage._selfRecipient) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._releaseNotes) }() default: break } } @@ -4443,6 +4312,9 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI try { if let v = _storage._selfRecipient { try visitor.visitSingularMessageField(value: v, fieldNumber: 5) } }() + try { if let v = _storage._releaseNotes { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() } try unknownFields.traverse(visitor: &visitor) } @@ -4457,6 +4329,7 @@ extension BackupProtos_Recipient: SwiftProtobuf.Message, SwiftProtobuf._MessageI if _storage._group != rhs_storage._group {return false} if _storage._distributionList != rhs_storage._distributionList {return false} if _storage._selfRecipient != rhs_storage._selfRecipient {return false} + if _storage._releaseNotes != rhs_storage._releaseNotes {return false} return true } if !storagesAreEqual {return false} @@ -4481,8 +4354,7 @@ extension BackupProtos_Contact: SwiftProtobuf.Message, SwiftProtobuf._MessageImp 10: .same(proto: "profileSharing"), 11: .same(proto: "profileGivenName"), 12: .same(proto: "profileFamilyName"), - 13: .same(proto: "profileJoinedName"), - 14: .same(proto: "hideStory"), + 13: .same(proto: "hideStory"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -4503,8 +4375,7 @@ extension BackupProtos_Contact: SwiftProtobuf.Message, SwiftProtobuf._MessageImp case 10: try { try decoder.decodeSingularBoolField(value: &self._profileSharing) }() case 11: try { try decoder.decodeSingularStringField(value: &self._profileGivenName) }() case 12: try { try decoder.decodeSingularStringField(value: &self._profileFamilyName) }() - case 13: try { try decoder.decodeSingularStringField(value: &self._profileJoinedName) }() - case 14: try { try decoder.decodeSingularBoolField(value: &self._hideStory) }() + case 13: try { try decoder.decodeSingularBoolField(value: &self._hideStory) }() default: break } } @@ -4551,11 +4422,8 @@ extension BackupProtos_Contact: SwiftProtobuf.Message, SwiftProtobuf._MessageImp try { if let v = self._profileFamilyName { try visitor.visitSingularStringField(value: v, fieldNumber: 12) } }() - try { if let v = self._profileJoinedName { - try visitor.visitSingularStringField(value: v, fieldNumber: 13) - } }() try { if let v = self._hideStory { - try visitor.visitSingularBoolField(value: v, fieldNumber: 14) + try visitor.visitSingularBoolField(value: v, fieldNumber: 13) } }() try unknownFields.traverse(visitor: &visitor) } @@ -4573,7 +4441,6 @@ extension BackupProtos_Contact: SwiftProtobuf.Message, SwiftProtobuf._MessageImp if lhs._profileSharing != rhs._profileSharing {return false} if lhs._profileGivenName != rhs._profileGivenName {return false} if lhs._profileFamilyName != rhs._profileFamilyName {return false} - if lhs._profileJoinedName != rhs._profileJoinedName {return false} if lhs._hideStory != rhs._hideStory {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true @@ -4669,17 +4536,37 @@ extension BackupProtos_SelfRecipient: SwiftProtobuf.Message, SwiftProtobuf._Mess } } +extension BackupProtos_ReleaseNotes: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ReleaseNotes" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: BackupProtos_ReleaseNotes, rhs: BackupProtos_ReleaseNotes) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension BackupProtos_Chat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".Chat" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "id"), 2: .same(proto: "recipientId"), 3: .same(proto: "archived"), - 4: .same(proto: "pinned"), - 5: .same(proto: "expirationTimer"), - 6: .same(proto: "muteUntil"), + 4: .same(proto: "pinnedOrder"), + 5: .same(proto: "expirationTimerMs"), + 6: .same(proto: "muteUntilMs"), 7: .same(proto: "markedUnread"), 8: .same(proto: "dontNotifyForMentionsIfMuted"), + 9: .same(proto: "wallpaper"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -4691,11 +4578,12 @@ extension BackupProtos_Chat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem case 1: try { try decoder.decodeSingularUInt64Field(value: &self._id) }() case 2: try { try decoder.decodeSingularUInt64Field(value: &self._recipientID) }() case 3: try { try decoder.decodeSingularBoolField(value: &self._archived) }() - case 4: try { try decoder.decodeSingularBoolField(value: &self._pinned) }() - case 5: try { try decoder.decodeSingularUInt64Field(value: &self._expirationTimer) }() - case 6: try { try decoder.decodeSingularUInt64Field(value: &self._muteUntil) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self._pinnedOrder) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self._expirationTimerMs) }() + case 6: try { try decoder.decodeSingularUInt64Field(value: &self._muteUntilMs) }() case 7: try { try decoder.decodeSingularBoolField(value: &self._markedUnread) }() case 8: try { try decoder.decodeSingularBoolField(value: &self._dontNotifyForMentionsIfMuted) }() + case 9: try { try decoder.decodeSingularMessageField(value: &self._wallpaper) }() default: break } } @@ -4715,13 +4603,13 @@ extension BackupProtos_Chat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem try { if let v = self._archived { try visitor.visitSingularBoolField(value: v, fieldNumber: 3) } }() - try { if let v = self._pinned { - try visitor.visitSingularBoolField(value: v, fieldNumber: 4) + try { if let v = self._pinnedOrder { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 4) } }() - try { if let v = self._expirationTimer { + try { if let v = self._expirationTimerMs { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 5) } }() - try { if let v = self._muteUntil { + try { if let v = self._muteUntilMs { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 6) } }() try { if let v = self._markedUnread { @@ -4730,6 +4618,9 @@ extension BackupProtos_Chat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem try { if let v = self._dontNotifyForMentionsIfMuted { try visitor.visitSingularBoolField(value: v, fieldNumber: 8) } }() + try { if let v = self._wallpaper { + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + } }() try unknownFields.traverse(visitor: &visitor) } @@ -4737,11 +4628,12 @@ extension BackupProtos_Chat: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem if lhs._id != rhs._id {return false} if lhs._recipientID != rhs._recipientID {return false} if lhs._archived != rhs._archived {return false} - if lhs._pinned != rhs._pinned {return false} - if lhs._expirationTimer != rhs._expirationTimer {return false} - if lhs._muteUntil != rhs._muteUntil {return false} + if lhs._pinnedOrder != rhs._pinnedOrder {return false} + if lhs._expirationTimerMs != rhs._expirationTimerMs {return false} + if lhs._muteUntilMs != rhs._muteUntilMs {return false} if lhs._markedUnread != rhs._markedUnread {return false} if lhs._dontNotifyForMentionsIfMuted != rhs._dontNotifyForMentionsIfMuted {return false} + if lhs._wallpaper != rhs._wallpaper {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -4754,9 +4646,8 @@ extension BackupProtos_DistributionList: SwiftProtobuf.Message, SwiftProtobuf._M 2: .same(proto: "distributionId"), 3: .same(proto: "allowReplies"), 4: .same(proto: "deletionTimestamp"), - 5: .same(proto: "isUnknown"), - 6: .same(proto: "privacyMode"), - 7: .same(proto: "memberRecipientIds"), + 5: .same(proto: "privacyMode"), + 6: .same(proto: "memberRecipientIds"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -4769,9 +4660,8 @@ extension BackupProtos_DistributionList: SwiftProtobuf.Message, SwiftProtobuf._M case 2: try { try decoder.decodeSingularBytesField(value: &self._distributionID) }() case 3: try { try decoder.decodeSingularBoolField(value: &self._allowReplies) }() case 4: try { try decoder.decodeSingularUInt64Field(value: &self._deletionTimestamp) }() - case 5: try { try decoder.decodeSingularBoolField(value: &self._isUnknown) }() - case 6: try { try decoder.decodeSingularEnumField(value: &self._privacyMode) }() - case 7: try { try decoder.decodeRepeatedUInt64Field(value: &self.memberRecipientIds) }() + case 5: try { try decoder.decodeSingularEnumField(value: &self._privacyMode) }() + case 6: try { try decoder.decodeRepeatedUInt64Field(value: &self.memberRecipientIds) }() default: break } } @@ -4794,14 +4684,11 @@ extension BackupProtos_DistributionList: SwiftProtobuf.Message, SwiftProtobuf._M try { if let v = self._deletionTimestamp { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 4) } }() - try { if let v = self._isUnknown { - try visitor.visitSingularBoolField(value: v, fieldNumber: 5) - } }() try { if let v = self._privacyMode { - try visitor.visitSingularEnumField(value: v, fieldNumber: 6) + try visitor.visitSingularEnumField(value: v, fieldNumber: 5) } }() if !self.memberRecipientIds.isEmpty { - try visitor.visitRepeatedUInt64Field(value: self.memberRecipientIds, fieldNumber: 7) + try visitor.visitRepeatedUInt64Field(value: self.memberRecipientIds, fieldNumber: 6) } try unknownFields.traverse(visitor: &visitor) } @@ -4811,7 +4698,6 @@ extension BackupProtos_DistributionList: SwiftProtobuf.Message, SwiftProtobuf._M if lhs._distributionID != rhs._distributionID {return false} if lhs._allowReplies != rhs._allowReplies {return false} if lhs._deletionTimestamp != rhs._deletionTimestamp {return false} - if lhs._isUnknown != rhs._isUnknown {return false} if lhs._privacyMode != rhs._privacyMode {return false} if lhs.memberRecipientIds != rhs.memberRecipientIds {return false} if lhs.unknownFields != rhs.unknownFields {return false} @@ -4821,9 +4707,10 @@ extension BackupProtos_DistributionList: SwiftProtobuf.Message, SwiftProtobuf._M extension BackupProtos_DistributionList.PrivacyMode: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "ONLY_WITH"), - 1: .same(proto: "ALL_EXCEPT"), - 2: .same(proto: "ALL"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "ONLY_WITH"), + 2: .same(proto: "ALL_EXCEPT"), + 3: .same(proto: "ALL"), ] } @@ -4897,7 +4784,7 @@ extension BackupProtos_Call: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem static let protoMessageName: String = _protobuf_package + ".Call" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "callId"), - 2: .same(proto: "peerRecipientId"), + 2: .same(proto: "conversationRecipientId"), 3: .same(proto: "type"), 4: .same(proto: "outgoing"), 5: .same(proto: "timestamp"), @@ -4912,7 +4799,7 @@ extension BackupProtos_Call: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeSingularUInt64Field(value: &self._callID) }() - case 2: try { try decoder.decodeSingularUInt64Field(value: &self._peerRecipientID) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self._conversationRecipientID) }() case 3: try { try decoder.decodeSingularEnumField(value: &self._type) }() case 4: try { try decoder.decodeSingularBoolField(value: &self._outgoing) }() case 5: try { try decoder.decodeSingularUInt64Field(value: &self._timestamp) }() @@ -4931,7 +4818,7 @@ extension BackupProtos_Call: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem try { if let v = self._callID { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1) } }() - try { if let v = self._peerRecipientID { + try { if let v = self._conversationRecipientID { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 2) } }() try { if let v = self._type { @@ -4954,7 +4841,7 @@ extension BackupProtos_Call: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem static func ==(lhs: BackupProtos_Call, rhs: BackupProtos_Call) -> Bool { if lhs._callID != rhs._callID {return false} - if lhs._peerRecipientID != rhs._peerRecipientID {return false} + if lhs._conversationRecipientID != rhs._conversationRecipientID {return false} if lhs._type != rhs._type {return false} if lhs._outgoing != rhs._outgoing {return false} if lhs._timestamp != rhs._timestamp {return false} @@ -4967,23 +4854,24 @@ extension BackupProtos_Call: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem extension BackupProtos_Call.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "AUDIO_CALL"), - 1: .same(proto: "VIDEO_CALL"), - 2: .same(proto: "GROUP_CALL"), - 3: .same(proto: "AD_HOC_CALL"), + 0: .same(proto: "UNKNOWN_TYPE"), + 1: .same(proto: "AUDIO_CALL"), + 2: .same(proto: "VIDEO_CALL"), + 3: .same(proto: "GROUP_CALL"), + 4: .same(proto: "AD_HOC_CALL"), ] } extension BackupProtos_Call.Event: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "OUTGOING"), - 1: .same(proto: "ACCEPTED"), - 2: .same(proto: "NOT_ACCEPTED"), - 3: .same(proto: "MISSED"), - 4: .same(proto: "DELETE"), - 5: .same(proto: "GENERIC_GROUP_CALL"), - 6: .same(proto: "JOINED"), - 7: .same(proto: "RINGING"), + 0: .same(proto: "UNKNOWN_EVENT"), + 1: .same(proto: "OUTGOING"), + 2: .same(proto: "ACCEPTED"), + 3: .same(proto: "NOT_ACCEPTED"), + 4: .same(proto: "MISSED"), + 5: .same(proto: "DELETE"), + 6: .same(proto: "GENERIC_GROUP_CALL"), + 7: .same(proto: "JOINED"), 8: .same(proto: "DECLINED"), 9: .same(proto: "OUTGOING_RING"), ] @@ -4995,28 +4883,26 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm 1: .same(proto: "chatId"), 2: .same(proto: "authorId"), 3: .same(proto: "dateSent"), - 4: .same(proto: "dateReceived"), - 5: .same(proto: "expireStart"), - 6: .same(proto: "expiresIn"), - 7: .same(proto: "revisions"), - 8: .same(proto: "sms"), - 9: .same(proto: "incoming"), - 10: .same(proto: "outgoing"), - 11: .same(proto: "standardMessage"), - 12: .same(proto: "contactMessage"), - 13: .same(proto: "voiceMessage"), - 14: .same(proto: "stickerMessage"), - 15: .same(proto: "remoteDeletedMessage"), - 16: .same(proto: "updateMessage"), + 4: .same(proto: "expireStartMs"), + 5: .same(proto: "expiresInMs"), + 6: .same(proto: "revisions"), + 7: .same(proto: "sms"), + 8: .same(proto: "incoming"), + 9: .same(proto: "outgoing"), + 10: .same(proto: "standardMessage"), + 11: .same(proto: "contactMessage"), + 12: .same(proto: "voiceMessage"), + 13: .same(proto: "stickerMessage"), + 14: .same(proto: "remoteDeletedMessage"), + 15: .same(proto: "updateMessage"), ] fileprivate class _StorageClass { var _chatID: UInt64? = nil var _authorID: UInt64? = nil var _dateSent: UInt64? = nil - var _dateReceived: UInt64? = nil - var _expireStart: UInt64? = nil - var _expiresIn: UInt64? = nil + var _expireStartMs: UInt64? = nil + var _expiresInMs: UInt64? = nil var _revisions: [BackupProtos_ChatItem] = [] var _sms: Bool? = nil var _incoming: BackupProtos_ChatItem.IncomingMessageDetails? = nil @@ -5036,9 +4922,8 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm _chatID = source._chatID _authorID = source._authorID _dateSent = source._dateSent - _dateReceived = source._dateReceived - _expireStart = source._expireStart - _expiresIn = source._expiresIn + _expireStartMs = source._expireStartMs + _expiresInMs = source._expiresInMs _revisions = source._revisions _sms = source._sms _incoming = source._incoming @@ -5070,19 +4955,18 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm case 1: try { try decoder.decodeSingularUInt64Field(value: &_storage._chatID) }() case 2: try { try decoder.decodeSingularUInt64Field(value: &_storage._authorID) }() case 3: try { try decoder.decodeSingularUInt64Field(value: &_storage._dateSent) }() - case 4: try { try decoder.decodeSingularUInt64Field(value: &_storage._dateReceived) }() - case 5: try { try decoder.decodeSingularUInt64Field(value: &_storage._expireStart) }() - case 6: try { try decoder.decodeSingularUInt64Field(value: &_storage._expiresIn) }() - case 7: try { try decoder.decodeRepeatedMessageField(value: &_storage._revisions) }() - case 8: try { try decoder.decodeSingularBoolField(value: &_storage._sms) }() - case 9: try { try decoder.decodeSingularMessageField(value: &_storage._incoming) }() - case 10: try { try decoder.decodeSingularMessageField(value: &_storage._outgoing) }() - case 11: try { try decoder.decodeSingularMessageField(value: &_storage._standardMessage) }() - case 12: try { try decoder.decodeSingularMessageField(value: &_storage._contactMessage) }() - case 13: try { try decoder.decodeSingularMessageField(value: &_storage._voiceMessage) }() - case 14: try { try decoder.decodeSingularMessageField(value: &_storage._stickerMessage) }() - case 15: try { try decoder.decodeSingularMessageField(value: &_storage._remoteDeletedMessage) }() - case 16: try { try decoder.decodeSingularMessageField(value: &_storage._updateMessage) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &_storage._expireStartMs) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &_storage._expiresInMs) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &_storage._revisions) }() + case 7: try { try decoder.decodeSingularBoolField(value: &_storage._sms) }() + case 8: try { try decoder.decodeSingularMessageField(value: &_storage._incoming) }() + case 9: try { try decoder.decodeSingularMessageField(value: &_storage._outgoing) }() + case 10: try { try decoder.decodeSingularMessageField(value: &_storage._standardMessage) }() + case 11: try { try decoder.decodeSingularMessageField(value: &_storage._contactMessage) }() + case 12: try { try decoder.decodeSingularMessageField(value: &_storage._voiceMessage) }() + case 13: try { try decoder.decodeSingularMessageField(value: &_storage._stickerMessage) }() + case 14: try { try decoder.decodeSingularMessageField(value: &_storage._remoteDeletedMessage) }() + case 15: try { try decoder.decodeSingularMessageField(value: &_storage._updateMessage) }() default: break } } @@ -5104,44 +4988,41 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm try { if let v = _storage._dateSent { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 3) } }() - try { if let v = _storage._dateReceived { + try { if let v = _storage._expireStartMs { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 4) } }() - try { if let v = _storage._expireStart { + try { if let v = _storage._expiresInMs { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 5) } }() - try { if let v = _storage._expiresIn { - try visitor.visitSingularUInt64Field(value: v, fieldNumber: 6) - } }() if !_storage._revisions.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._revisions, fieldNumber: 7) + try visitor.visitRepeatedMessageField(value: _storage._revisions, fieldNumber: 6) } try { if let v = _storage._sms { - try visitor.visitSingularBoolField(value: v, fieldNumber: 8) + try visitor.visitSingularBoolField(value: v, fieldNumber: 7) } }() try { if let v = _storage._incoming { - try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + try visitor.visitSingularMessageField(value: v, fieldNumber: 8) } }() try { if let v = _storage._outgoing { - try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) } }() try { if let v = _storage._standardMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) } }() try { if let v = _storage._contactMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) } }() try { if let v = _storage._voiceMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) } }() try { if let v = _storage._stickerMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) } }() try { if let v = _storage._remoteDeletedMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) } }() try { if let v = _storage._updateMessage { - try visitor.visitSingularMessageField(value: v, fieldNumber: 16) + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) } }() } try unknownFields.traverse(visitor: &visitor) @@ -5155,9 +5036,8 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm if _storage._chatID != rhs_storage._chatID {return false} if _storage._authorID != rhs_storage._authorID {return false} if _storage._dateSent != rhs_storage._dateSent {return false} - if _storage._dateReceived != rhs_storage._dateReceived {return false} - if _storage._expireStart != rhs_storage._expireStart {return false} - if _storage._expiresIn != rhs_storage._expiresIn {return false} + if _storage._expireStartMs != rhs_storage._expireStartMs {return false} + if _storage._expiresInMs != rhs_storage._expiresInMs {return false} if _storage._revisions != rhs_storage._revisions {return false} if _storage._sms != rhs_storage._sms {return false} if _storage._incoming != rhs_storage._incoming {return false} @@ -5180,9 +5060,10 @@ extension BackupProtos_ChatItem: SwiftProtobuf.Message, SwiftProtobuf._MessageIm extension BackupProtos_ChatItem.IncomingMessageDetails: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = BackupProtos_ChatItem.protoMessageName + ".IncomingMessageDetails" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "dateServerSent"), - 2: .same(proto: "read"), - 3: .same(proto: "sealedSender"), + 1: .same(proto: "dateReceived"), + 2: .same(proto: "dateServerSent"), + 3: .same(proto: "read"), + 4: .same(proto: "sealedSender"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -5191,9 +5072,10 @@ extension BackupProtos_ChatItem.IncomingMessageDetails: SwiftProtobuf.Message, S // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self._dateServerSent) }() - case 2: try { try decoder.decodeSingularBoolField(value: &self._read) }() - case 3: try { try decoder.decodeSingularBoolField(value: &self._sealedSender) }() + case 1: try { try decoder.decodeSingularUInt64Field(value: &self._dateReceived) }() + case 2: try { try decoder.decodeSingularUInt64Field(value: &self._dateServerSent) }() + case 3: try { try decoder.decodeSingularBoolField(value: &self._read) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self._sealedSender) }() default: break } } @@ -5204,19 +5086,23 @@ extension BackupProtos_ChatItem.IncomingMessageDetails: SwiftProtobuf.Message, S // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._dateServerSent { + try { if let v = self._dateReceived { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1) } }() + try { if let v = self._dateServerSent { + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 2) + } }() try { if let v = self._read { - try visitor.visitSingularBoolField(value: v, fieldNumber: 2) + try visitor.visitSingularBoolField(value: v, fieldNumber: 3) } }() try { if let v = self._sealedSender { - try visitor.visitSingularBoolField(value: v, fieldNumber: 3) + try visitor.visitSingularBoolField(value: v, fieldNumber: 4) } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_ChatItem.IncomingMessageDetails, rhs: BackupProtos_ChatItem.IncomingMessageDetails) -> Bool { + if lhs._dateReceived != rhs._dateReceived {return false} if lhs._dateServerSent != rhs._dateServerSent {return false} if lhs._read != rhs._read {return false} if lhs._sealedSender != rhs._sealedSender {return false} @@ -5325,13 +5211,14 @@ extension BackupProtos_SendStatus: SwiftProtobuf.Message, SwiftProtobuf._Message extension BackupProtos_SendStatus.Status: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "FAILED"), - 1: .same(proto: "PENDING"), - 2: .same(proto: "SENT"), - 3: .same(proto: "DELIVERED"), - 4: .same(proto: "READ"), - 5: .same(proto: "VIEWED"), - 6: .same(proto: "SKIPPED"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "FAILED"), + 2: .same(proto: "PENDING"), + 3: .same(proto: "SENT"), + 4: .same(proto: "DELIVERED"), + 5: .same(proto: "READ"), + 6: .same(proto: "VIEWED"), + 7: .same(proto: "SKIPPED"), ] } @@ -5388,98 +5275,56 @@ extension BackupProtos_StandardMessage: SwiftProtobuf.Message, SwiftProtobuf._Me 6: .same(proto: "reactions"), ] - fileprivate class _StorageClass { - var _quote: BackupProtos_Quote? = nil - var _text: BackupProtos_Text? = nil - var _attachments: [BackupProtos_AttachmentPointer] = [] - var _linkPreview: BackupProtos_LinkPreview? = nil - var _longText: BackupProtos_AttachmentPointer? = nil - var _reactions: [BackupProtos_Reaction] = [] - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _quote = source._quote - _text = source._text - _attachments = source._attachments - _linkPreview = source._linkPreview - _longText = source._longText - _reactions = source._reactions - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &_storage._quote) }() - case 2: try { try decoder.decodeSingularMessageField(value: &_storage._text) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &_storage._attachments) }() - case 4: try { try decoder.decodeSingularMessageField(value: &_storage._linkPreview) }() - case 5: try { try decoder.decodeSingularMessageField(value: &_storage._longText) }() - case 6: try { try decoder.decodeRepeatedMessageField(value: &_storage._reactions) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._quote) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._text) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.attachments) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.linkPreview) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._longText) }() + case 6: try { try decoder.decodeRepeatedMessageField(value: &self.reactions) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._quote { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._text { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !_storage._attachments.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._attachments, fieldNumber: 3) - } - try { if let v = _storage._linkPreview { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } }() - try { if let v = _storage._longText { - try visitor.visitSingularMessageField(value: v, fieldNumber: 5) - } }() - if !_storage._reactions.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._reactions, fieldNumber: 6) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._quote { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._text { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.attachments.isEmpty { + try visitor.visitRepeatedMessageField(value: self.attachments, fieldNumber: 3) + } + if !self.linkPreview.isEmpty { + try visitor.visitRepeatedMessageField(value: self.linkPreview, fieldNumber: 4) + } + try { if let v = self._longText { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + if !self.reactions.isEmpty { + try visitor.visitRepeatedMessageField(value: self.reactions, fieldNumber: 6) } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_StandardMessage, rhs: BackupProtos_StandardMessage) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._quote != rhs_storage._quote {return false} - if _storage._text != rhs_storage._text {return false} - if _storage._attachments != rhs_storage._attachments {return false} - if _storage._linkPreview != rhs_storage._linkPreview {return false} - if _storage._longText != rhs_storage._longText {return false} - if _storage._reactions != rhs_storage._reactions {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._quote != rhs._quote {return false} + if lhs._text != rhs._text {return false} + if lhs.attachments != rhs.attachments {return false} + if lhs.linkPreview != rhs.linkPreview {return false} + if lhs._longText != rhs._longText {return false} + if lhs.reactions != rhs.reactions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -5705,10 +5550,11 @@ extension BackupProtos_ContactAttachment.Phone: SwiftProtobuf.Message, SwiftProt extension BackupProtos_ContactAttachment.Phone.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "HOME"), - 1: .same(proto: "MOBILE"), - 2: .same(proto: "WORK"), - 3: .same(proto: "CUSTOM"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "HOME"), + 2: .same(proto: "MOBILE"), + 3: .same(proto: "WORK"), + 4: .same(proto: "CUSTOM"), ] } @@ -5762,10 +5608,11 @@ extension BackupProtos_ContactAttachment.Email: SwiftProtobuf.Message, SwiftProt extension BackupProtos_ContactAttachment.Email.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "HOME"), - 1: .same(proto: "MOBILE"), - 2: .same(proto: "WORK"), - 3: .same(proto: "CUSTOM"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "HOME"), + 2: .same(proto: "MOBILE"), + 3: .same(proto: "WORK"), + 4: .same(proto: "CUSTOM"), ] } @@ -5855,9 +5702,10 @@ extension BackupProtos_ContactAttachment.PostalAddress: SwiftProtobuf.Message, S extension BackupProtos_ContactAttachment.PostalAddress.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "HOME"), - 1: .same(proto: "WORK"), - 2: .same(proto: "CUSTOM"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "HOME"), + 2: .same(proto: "WORK"), + 3: .same(proto: "CUSTOM"), ] } @@ -5865,73 +5713,33 @@ extension BackupProtos_ContactAttachment.Avatar: SwiftProtobuf.Message, SwiftPro static let protoMessageName: String = BackupProtos_ContactAttachment.protoMessageName + ".Avatar" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "avatar"), - 2: .same(proto: "isProfile"), ] - fileprivate class _StorageClass { - var _avatar: BackupProtos_AttachmentPointer? = nil - var _isProfile: Bool? = nil - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _avatar = source._avatar - _isProfile = source._isProfile - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &_storage._avatar) }() - case 2: try { try decoder.decodeSingularBoolField(value: &_storage._isProfile) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._avatar) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._avatar { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._isProfile { - try visitor.visitSingularBoolField(value: v, fieldNumber: 2) - } }() - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._avatar { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_ContactAttachment.Avatar, rhs: BackupProtos_ContactAttachment.Avatar) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._avatar != rhs_storage._avatar {return false} - if _storage._isProfile != rhs_storage._isProfile {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._avatar != rhs._avatar {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -5945,77 +5753,41 @@ extension BackupProtos_DocumentMessage: SwiftProtobuf.Message, SwiftProtobuf._Me 3: .same(proto: "reactions"), ] - fileprivate class _StorageClass { - var _text: BackupProtos_Text? = nil - var _document: BackupProtos_AttachmentPointer? = nil - var _reactions: [BackupProtos_Reaction] = [] - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _text = source._text - _document = source._document - _reactions = source._reactions - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &_storage._text) }() - case 2: try { try decoder.decodeSingularMessageField(value: &_storage._document) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &_storage._reactions) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._text) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._document) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.reactions) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._text { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._document { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !_storage._reactions.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._reactions, fieldNumber: 3) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._text { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._document { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.reactions.isEmpty { + try visitor.visitRepeatedMessageField(value: self.reactions, fieldNumber: 3) } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_DocumentMessage, rhs: BackupProtos_DocumentMessage) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._text != rhs_storage._text {return false} - if _storage._document != rhs_storage._document {return false} - if _storage._reactions != rhs_storage._reactions {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._text != rhs._text {return false} + if lhs._document != rhs._document {return false} + if lhs.reactions != rhs.reactions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -6029,77 +5801,41 @@ extension BackupProtos_VoiceMessage: SwiftProtobuf.Message, SwiftProtobuf._Messa 3: .same(proto: "reactions"), ] - fileprivate class _StorageClass { - var _quote: BackupProtos_Quote? = nil - var _audio: BackupProtos_AttachmentPointer? = nil - var _reactions: [BackupProtos_Reaction] = [] - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _quote = source._quote - _audio = source._audio - _reactions = source._reactions - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &_storage._quote) }() - case 2: try { try decoder.decodeSingularMessageField(value: &_storage._audio) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &_storage._reactions) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._quote) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._audio) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.reactions) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._quote { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._audio { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() - if !_storage._reactions.isEmpty { - try visitor.visitRepeatedMessageField(value: _storage._reactions, fieldNumber: 3) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._quote { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._audio { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.reactions.isEmpty { + try visitor.visitRepeatedMessageField(value: self.reactions, fieldNumber: 3) } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_VoiceMessage, rhs: BackupProtos_VoiceMessage) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._quote != rhs_storage._quote {return false} - if _storage._audio != rhs_storage._audio {return false} - if _storage._reactions != rhs_storage._reactions {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._quote != rhs._quote {return false} + if lhs._audio != rhs._audio {return false} + if lhs.reactions != rhs.reactions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -6214,95 +5950,49 @@ extension BackupProtos_Sticker: SwiftProtobuf.Message, SwiftProtobuf._MessageImp 1: .same(proto: "packId"), 2: .same(proto: "packKey"), 3: .same(proto: "stickerId"), - 4: .same(proto: "data"), - 5: .same(proto: "emoji"), + 4: .same(proto: "emoji"), ] - fileprivate class _StorageClass { - var _packID: Data? = nil - var _packKey: Data? = nil - var _stickerID: UInt32? = nil - var _data: BackupProtos_AttachmentPointer? = nil - var _emoji: String? = nil - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _packID = source._packID - _packKey = source._packKey - _stickerID = source._stickerID - _data = source._data - _emoji = source._emoji - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &_storage._packID) }() - case 2: try { try decoder.decodeSingularBytesField(value: &_storage._packKey) }() - case 3: try { try decoder.decodeSingularUInt32Field(value: &_storage._stickerID) }() - case 4: try { try decoder.decodeSingularMessageField(value: &_storage._data) }() - case 5: try { try decoder.decodeSingularStringField(value: &_storage._emoji) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._packID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._packKey) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self._stickerID) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._emoji) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._packID { - try visitor.visitSingularBytesField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._packKey { - try visitor.visitSingularBytesField(value: v, fieldNumber: 2) - } }() - try { if let v = _storage._stickerID { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3) - } }() - try { if let v = _storage._data { - try visitor.visitSingularMessageField(value: v, fieldNumber: 4) - } }() - try { if let v = _storage._emoji { - try visitor.visitSingularStringField(value: v, fieldNumber: 5) - } }() - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._packID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._packKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._stickerID { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._emoji { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_Sticker, rhs: BackupProtos_Sticker) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._packID != rhs_storage._packID {return false} - if _storage._packKey != rhs_storage._packKey {return false} - if _storage._stickerID != rhs_storage._stickerID {return false} - if _storage._data != rhs_storage._data {return false} - if _storage._emoji != rhs_storage._emoji {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._packID != rhs._packID {return false} + if lhs._packKey != rhs._packKey {return false} + if lhs._stickerID != rhs._stickerID {return false} + if lhs._emoji != rhs._emoji {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -6318,23 +6008,113 @@ extension BackupProtos_LinkPreview: SwiftProtobuf.Message, SwiftProtobuf._Messag 5: .same(proto: "date"), ] + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._url) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._title) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._image) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._descriptionText) }() + case 5: try { try decoder.decodeSingularUInt64Field(value: &self._date) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._url { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._title { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._image { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._descriptionText { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() + try { if let v = self._date { + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 5) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: BackupProtos_LinkPreview, rhs: BackupProtos_LinkPreview) -> Bool { + if lhs._url != rhs._url {return false} + if lhs._title != rhs._title {return false} + if lhs._image != rhs._image {return false} + if lhs._descriptionText != rhs._descriptionText {return false} + if lhs._date != rhs._date {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension BackupProtos_FilePointer: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".FilePointer" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "backupLocator"), + 2: .same(proto: "attachmentLocator"), + 3: .same(proto: "legacyAttachmentLocator"), + 4: .same(proto: "key"), + 5: .same(proto: "contentType"), + 6: .same(proto: "size"), + 7: .same(proto: "digest"), + 8: .same(proto: "incrementalMac"), + 9: .same(proto: "incrementalMacChunkSize"), + 10: .same(proto: "fileName"), + 11: .same(proto: "flags"), + 12: .same(proto: "width"), + 13: .same(proto: "height"), + 14: .same(proto: "caption"), + 15: .same(proto: "blurHash"), + ] + fileprivate class _StorageClass { - var _url: String? = nil - var _title: String? = nil - var _image: BackupProtos_AttachmentPointer? = nil - var _descriptionText: String? = nil - var _date: UInt64? = nil + var _backupLocator: BackupProtos_FilePointer.BackupLocator? = nil + var _attachmentLocator: BackupProtos_FilePointer.AttachmentLocator? = nil + var _legacyAttachmentLocator: BackupProtos_FilePointer.LegacyAttachmentLocator? = nil + var _key: Data? = nil + var _contentType: String? = nil + var _size: UInt32? = nil + var _digest: Data? = nil + var _incrementalMac: Data? = nil + var _incrementalMacChunkSize: Data? = nil + var _fileName: String? = nil + var _flags: UInt32? = nil + var _width: UInt32? = nil + var _height: UInt32? = nil + var _caption: String? = nil + var _blurHash: String? = nil static let defaultInstance = _StorageClass() private init() {} init(copying source: _StorageClass) { - _url = source._url - _title = source._title - _image = source._image - _descriptionText = source._descriptionText - _date = source._date + _backupLocator = source._backupLocator + _attachmentLocator = source._attachmentLocator + _legacyAttachmentLocator = source._legacyAttachmentLocator + _key = source._key + _contentType = source._contentType + _size = source._size + _digest = source._digest + _incrementalMac = source._incrementalMac + _incrementalMacChunkSize = source._incrementalMacChunkSize + _fileName = source._fileName + _flags = source._flags + _width = source._width + _height = source._height + _caption = source._caption + _blurHash = source._blurHash } } @@ -6353,11 +6133,21 @@ extension BackupProtos_LinkPreview: SwiftProtobuf.Message, SwiftProtobuf._Messag // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &_storage._url) }() - case 2: try { try decoder.decodeSingularStringField(value: &_storage._title) }() - case 3: try { try decoder.decodeSingularMessageField(value: &_storage._image) }() - case 4: try { try decoder.decodeSingularStringField(value: &_storage._descriptionText) }() - case 5: try { try decoder.decodeSingularUInt64Field(value: &_storage._date) }() + case 1: try { try decoder.decodeSingularMessageField(value: &_storage._backupLocator) }() + case 2: try { try decoder.decodeSingularMessageField(value: &_storage._attachmentLocator) }() + case 3: try { try decoder.decodeSingularMessageField(value: &_storage._legacyAttachmentLocator) }() + case 4: try { try decoder.decodeSingularBytesField(value: &_storage._key) }() + case 5: try { try decoder.decodeSingularStringField(value: &_storage._contentType) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &_storage._size) }() + case 7: try { try decoder.decodeSingularBytesField(value: &_storage._digest) }() + case 8: try { try decoder.decodeSingularBytesField(value: &_storage._incrementalMac) }() + case 9: try { try decoder.decodeSingularBytesField(value: &_storage._incrementalMacChunkSize) }() + case 10: try { try decoder.decodeSingularStringField(value: &_storage._fileName) }() + case 11: try { try decoder.decodeSingularUInt32Field(value: &_storage._flags) }() + case 12: try { try decoder.decodeSingularUInt32Field(value: &_storage._width) }() + case 13: try { try decoder.decodeSingularUInt32Field(value: &_storage._height) }() + case 14: try { try decoder.decodeSingularStringField(value: &_storage._caption) }() + case 15: try { try decoder.decodeSingularStringField(value: &_storage._blurHash) }() default: break } } @@ -6370,35 +6160,75 @@ extension BackupProtos_LinkPreview: SwiftProtobuf.Message, SwiftProtobuf._Messag // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._url { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) + try { if let v = _storage._backupLocator { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) } }() - try { if let v = _storage._title { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) + try { if let v = _storage._attachmentLocator { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) } }() - try { if let v = _storage._image { + try { if let v = _storage._legacyAttachmentLocator { try visitor.visitSingularMessageField(value: v, fieldNumber: 3) } }() - try { if let v = _storage._descriptionText { - try visitor.visitSingularStringField(value: v, fieldNumber: 4) + try { if let v = _storage._key { + try visitor.visitSingularBytesField(value: v, fieldNumber: 4) } }() - try { if let v = _storage._date { - try visitor.visitSingularUInt64Field(value: v, fieldNumber: 5) + try { if let v = _storage._contentType { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try { if let v = _storage._size { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 6) + } }() + try { if let v = _storage._digest { + try visitor.visitSingularBytesField(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._incrementalMac { + try visitor.visitSingularBytesField(value: v, fieldNumber: 8) + } }() + try { if let v = _storage._incrementalMacChunkSize { + try visitor.visitSingularBytesField(value: v, fieldNumber: 9) + } }() + try { if let v = _storage._fileName { + try visitor.visitSingularStringField(value: v, fieldNumber: 10) + } }() + try { if let v = _storage._flags { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 11) + } }() + try { if let v = _storage._width { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 12) + } }() + try { if let v = _storage._height { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 13) + } }() + try { if let v = _storage._caption { + try visitor.visitSingularStringField(value: v, fieldNumber: 14) + } }() + try { if let v = _storage._blurHash { + try visitor.visitSingularStringField(value: v, fieldNumber: 15) } }() } try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: BackupProtos_LinkPreview, rhs: BackupProtos_LinkPreview) -> Bool { + static func ==(lhs: BackupProtos_FilePointer, rhs: BackupProtos_FilePointer) -> Bool { if lhs._storage !== rhs._storage { let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in let _storage = _args.0 let rhs_storage = _args.1 - if _storage._url != rhs_storage._url {return false} - if _storage._title != rhs_storage._title {return false} - if _storage._image != rhs_storage._image {return false} - if _storage._descriptionText != rhs_storage._descriptionText {return false} - if _storage._date != rhs_storage._date {return false} + if _storage._backupLocator != rhs_storage._backupLocator {return false} + if _storage._attachmentLocator != rhs_storage._attachmentLocator {return false} + if _storage._legacyAttachmentLocator != rhs_storage._legacyAttachmentLocator {return false} + if _storage._key != rhs_storage._key {return false} + if _storage._contentType != rhs_storage._contentType {return false} + if _storage._size != rhs_storage._size {return false} + if _storage._digest != rhs_storage._digest {return false} + if _storage._incrementalMac != rhs_storage._incrementalMac {return false} + if _storage._incrementalMacChunkSize != rhs_storage._incrementalMacChunkSize {return false} + if _storage._fileName != rhs_storage._fileName {return false} + if _storage._flags != rhs_storage._flags {return false} + if _storage._width != rhs_storage._width {return false} + if _storage._height != rhs_storage._height {return false} + if _storage._caption != rhs_storage._caption {return false} + if _storage._blurHash != rhs_storage._blurHash {return false} return true } if !storagesAreEqual {return false} @@ -6408,25 +6238,19 @@ extension BackupProtos_LinkPreview: SwiftProtobuf.Message, SwiftProtobuf._Messag } } -extension BackupProtos_AttachmentPointer: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - static let protoMessageName: String = _protobuf_package + ".AttachmentPointer" +extension BackupProtos_FilePointer.Flags: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "cdnId"), - 2: .same(proto: "cdnKey"), - 3: .same(proto: "contentType"), - 4: .same(proto: "key"), - 5: .same(proto: "size"), - 6: .same(proto: "digest"), - 7: .same(proto: "incrementalMac"), - 8: .same(proto: "incrementalMacChunkSize"), - 9: .same(proto: "fileName"), - 10: .same(proto: "flags"), - 11: .same(proto: "width"), - 12: .same(proto: "height"), - 13: .same(proto: "caption"), - 14: .same(proto: "blurHash"), - 15: .same(proto: "uploadTimestamp"), - 16: .same(proto: "cdnNumber"), + 0: .same(proto: "VOICE_MESSAGE"), + 1: .same(proto: "BORDERLESS"), + 2: .same(proto: "GIF"), + ] +} + +extension BackupProtos_FilePointer.BackupLocator: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = BackupProtos_FilePointer.protoMessageName + ".BackupLocator" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "mediaName"), + 2: .same(proto: "cdnNumber"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -6435,22 +6259,8 @@ extension BackupProtos_AttachmentPointer: SwiftProtobuf.Message, SwiftProtobuf._ // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularFixed64Field(value: &self._cdnID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self._cdnKey) }() - case 3: try { try decoder.decodeSingularStringField(value: &self._contentType) }() - case 4: try { try decoder.decodeSingularBytesField(value: &self._key) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self._size) }() - case 6: try { try decoder.decodeSingularBytesField(value: &self._digest) }() - case 7: try { try decoder.decodeSingularBytesField(value: &self._incrementalMac) }() - case 8: try { try decoder.decodeSingularBytesField(value: &self._incrementalMacChunkSize) }() - case 9: try { try decoder.decodeSingularStringField(value: &self._fileName) }() - case 10: try { try decoder.decodeSingularUInt32Field(value: &self._flags) }() - case 11: try { try decoder.decodeSingularUInt32Field(value: &self._width) }() - case 12: try { try decoder.decodeSingularUInt32Field(value: &self._height) }() - case 13: try { try decoder.decodeSingularStringField(value: &self._caption) }() - case 14: try { try decoder.decodeSingularStringField(value: &self._blurHash) }() - case 15: try { try decoder.decodeSingularUInt64Field(value: &self._uploadTimestamp) }() - case 16: try { try decoder.decodeSingularUInt32Field(value: &self._cdnNumber) }() + case 1: try { try decoder.decodeSingularStringField(value: &self._mediaName) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self._cdnNumber) }() default: break } } @@ -6461,91 +6271,94 @@ extension BackupProtos_AttachmentPointer: SwiftProtobuf.Message, SwiftProtobuf._ // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._cdnID { - try visitor.visitSingularFixed64Field(value: v, fieldNumber: 1) - } }() - try { if let v = self._cdnKey { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - try { if let v = self._contentType { - try visitor.visitSingularStringField(value: v, fieldNumber: 3) - } }() - try { if let v = self._key { - try visitor.visitSingularBytesField(value: v, fieldNumber: 4) - } }() - try { if let v = self._size { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 5) - } }() - try { if let v = self._digest { - try visitor.visitSingularBytesField(value: v, fieldNumber: 6) - } }() - try { if let v = self._incrementalMac { - try visitor.visitSingularBytesField(value: v, fieldNumber: 7) - } }() - try { if let v = self._incrementalMacChunkSize { - try visitor.visitSingularBytesField(value: v, fieldNumber: 8) - } }() - try { if let v = self._fileName { - try visitor.visitSingularStringField(value: v, fieldNumber: 9) - } }() - try { if let v = self._flags { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 10) - } }() - try { if let v = self._width { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 11) + try { if let v = self._mediaName { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) } }() - try { if let v = self._height { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 12) + try { if let v = self._cdnNumber { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 2) } }() - try { if let v = self._caption { - try visitor.visitSingularStringField(value: v, fieldNumber: 13) + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: BackupProtos_FilePointer.BackupLocator, rhs: BackupProtos_FilePointer.BackupLocator) -> Bool { + if lhs._mediaName != rhs._mediaName {return false} + if lhs._cdnNumber != rhs._cdnNumber {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension BackupProtos_FilePointer.AttachmentLocator: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = BackupProtos_FilePointer.protoMessageName + ".AttachmentLocator" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "cdnKey"), + 2: .same(proto: "cdnNumber"), + 3: .same(proto: "uploadTimestamp"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._cdnKey) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self._cdnNumber) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self._uploadTimestamp) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._cdnKey { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) } }() - try { if let v = self._blurHash { - try visitor.visitSingularStringField(value: v, fieldNumber: 14) + try { if let v = self._cdnNumber { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 2) } }() try { if let v = self._uploadTimestamp { - try visitor.visitSingularUInt64Field(value: v, fieldNumber: 15) - } }() - try { if let v = self._cdnNumber { - try visitor.visitSingularUInt32Field(value: v, fieldNumber: 16) + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 3) } }() try unknownFields.traverse(visitor: &visitor) } - static func ==(lhs: BackupProtos_AttachmentPointer, rhs: BackupProtos_AttachmentPointer) -> Bool { - if lhs._cdnID != rhs._cdnID {return false} + static func ==(lhs: BackupProtos_FilePointer.AttachmentLocator, rhs: BackupProtos_FilePointer.AttachmentLocator) -> Bool { if lhs._cdnKey != rhs._cdnKey {return false} - if lhs._contentType != rhs._contentType {return false} - if lhs._key != rhs._key {return false} - if lhs._size != rhs._size {return false} - if lhs._digest != rhs._digest {return false} - if lhs._incrementalMac != rhs._incrementalMac {return false} - if lhs._incrementalMacChunkSize != rhs._incrementalMacChunkSize {return false} - if lhs._fileName != rhs._fileName {return false} - if lhs._flags != rhs._flags {return false} - if lhs._width != rhs._width {return false} - if lhs._height != rhs._height {return false} - if lhs._caption != rhs._caption {return false} - if lhs._blurHash != rhs._blurHash {return false} - if lhs._uploadTimestamp != rhs._uploadTimestamp {return false} if lhs._cdnNumber != rhs._cdnNumber {return false} + if lhs._uploadTimestamp != rhs._uploadTimestamp {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension BackupProtos_AttachmentPointer.Flags: SwiftProtobuf._ProtoNameProviding { - static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "VOICE_MESSAGE"), - 1: .same(proto: "BORDERLESS"), - 2: .same(proto: "GIF"), - ] +extension BackupProtos_FilePointer.LegacyAttachmentLocator: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = BackupProtos_FilePointer.protoMessageName + ".LegacyAttachmentLocator" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: BackupProtos_FilePointer.LegacyAttachmentLocator, rhs: BackupProtos_FilePointer.LegacyAttachmentLocator) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } } extension BackupProtos_Quote: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".Quote" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "id"), + 1: .same(proto: "targetSentTimestamp"), 2: .same(proto: "authorId"), 3: .same(proto: "text"), 4: .same(proto: "attachments"), @@ -6559,7 +6372,7 @@ extension BackupProtos_Quote: SwiftProtobuf.Message, SwiftProtobuf._MessageImple // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt64Field(value: &self._id) }() + case 1: try { try decoder.decodeSingularUInt64Field(value: &self._targetSentTimestamp) }() case 2: try { try decoder.decodeSingularUInt64Field(value: &self._authorID) }() case 3: try { try decoder.decodeSingularStringField(value: &self._text) }() case 4: try { try decoder.decodeRepeatedMessageField(value: &self.attachments) }() @@ -6575,7 +6388,7 @@ extension BackupProtos_Quote: SwiftProtobuf.Message, SwiftProtobuf._MessageImple // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._id { + try { if let v = self._targetSentTimestamp { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1) } }() try { if let v = self._authorID { @@ -6597,7 +6410,7 @@ extension BackupProtos_Quote: SwiftProtobuf.Message, SwiftProtobuf._MessageImple } static func ==(lhs: BackupProtos_Quote, rhs: BackupProtos_Quote) -> Bool { - if lhs._id != rhs._id {return false} + if lhs._targetSentTimestamp != rhs._targetSentTimestamp {return false} if lhs._authorID != rhs._authorID {return false} if lhs._text != rhs._text {return false} if lhs.attachments != rhs.attachments {return false} @@ -6610,8 +6423,9 @@ extension BackupProtos_Quote: SwiftProtobuf.Message, SwiftProtobuf._MessageImple extension BackupProtos_Quote.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "NORMAL"), - 1: .same(proto: "GIFTBADGE"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "NORMAL"), + 2: .same(proto: "GIFTBADGE"), ] } @@ -6623,77 +6437,41 @@ extension BackupProtos_Quote.QuotedAttachment: SwiftProtobuf.Message, SwiftProto 3: .same(proto: "thumbnail"), ] - fileprivate class _StorageClass { - var _contentType: String? = nil - var _fileName: String? = nil - var _thumbnail: BackupProtos_AttachmentPointer? = nil - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _contentType = source._contentType - _fileName = source._fileName - _thumbnail = source._thumbnail - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &_storage._contentType) }() - case 2: try { try decoder.decodeSingularStringField(value: &_storage._fileName) }() - case 3: try { try decoder.decodeSingularMessageField(value: &_storage._thumbnail) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._contentType) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._fileName) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._thumbnail) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._contentType { - try visitor.visitSingularStringField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._fileName { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - try { if let v = _storage._thumbnail { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._contentType { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._fileName { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._thumbnail { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_Quote.QuotedAttachment, rhs: BackupProtos_Quote.QuotedAttachment) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._contentType != rhs_storage._contentType {return false} - if _storage._fileName != rhs_storage._fileName {return false} - if _storage._thumbnail != rhs_storage._thumbnail {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._contentType != rhs._contentType {return false} + if lhs._fileName != rhs._fileName {return false} + if lhs._thumbnail != rhs._thumbnail {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -6716,7 +6494,7 @@ extension BackupProtos_BodyRange: SwiftProtobuf.Message, SwiftProtobuf._MessageI switch fieldNumber { case 1: try { try decoder.decodeSingularUInt32Field(value: &self._start) }() case 2: try { try decoder.decodeSingularUInt32Field(value: &self._length) }() - case 3: try { try decoder.decodeSingularStringField(value: &self._mentionAci) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._mentionAci) }() case 4: try { try decoder.decodeSingularEnumField(value: &self._style) }() default: break } @@ -6735,7 +6513,7 @@ extension BackupProtos_BodyRange: SwiftProtobuf.Message, SwiftProtobuf._MessageI try visitor.visitSingularUInt32Field(value: v, fieldNumber: 2) } }() try { if let v = self._mentionAci { - try visitor.visitSingularStringField(value: v, fieldNumber: 3) + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) } }() try { if let v = self._style { try visitor.visitSingularEnumField(value: v, fieldNumber: 4) @@ -6959,22 +6737,22 @@ extension BackupProtos_CallMessage: SwiftProtobuf.Message, SwiftProtobuf._Messag extension BackupProtos_CallMessage.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "INCOMING_AUDIO_CALL"), - 1: .same(proto: "INCOMING_VIDEO_CALL"), - 2: .same(proto: "OUTGOING_AUDIO_CALL"), - 3: .same(proto: "OUTGOING_VIDEO_CALL"), - 4: .same(proto: "MISSED_AUDIO_CALL"), - 5: .same(proto: "MISSED_VIDEO_CALL"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "INCOMING_AUDIO_CALL"), + 2: .same(proto: "INCOMING_VIDEO_CALL"), + 3: .same(proto: "OUTGOING_AUDIO_CALL"), + 4: .same(proto: "OUTGOING_VIDEO_CALL"), + 5: .same(proto: "MISSED_AUDIO_CALL"), + 6: .same(proto: "MISSED_VIDEO_CALL"), ] } extension BackupProtos_GroupCallMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".GroupCallMessage" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "startedCallUuid"), + 1: .same(proto: "startedCallAci"), 2: .same(proto: "startedCallTimestamp"), - 3: .same(proto: "inCallUuids"), - 4: .same(proto: "isCallFull"), + 3: .same(proto: "inCallAcis"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -6983,10 +6761,9 @@ extension BackupProtos_GroupCallMessage: SwiftProtobuf.Message, SwiftProtobuf._M // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularBytesField(value: &self._startedCallUuid) }() + case 1: try { try decoder.decodeSingularBytesField(value: &self._startedCallAci) }() case 2: try { try decoder.decodeSingularUInt64Field(value: &self._startedCallTimestamp) }() - case 3: try { try decoder.decodeRepeatedBytesField(value: &self.inCallUuids) }() - case 4: try { try decoder.decodeSingularBoolField(value: &self._isCallFull) }() + case 3: try { try decoder.decodeRepeatedBytesField(value: &self.inCallAcis) }() default: break } } @@ -6997,26 +6774,22 @@ extension BackupProtos_GroupCallMessage: SwiftProtobuf.Message, SwiftProtobuf._M // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._startedCallUuid { + try { if let v = self._startedCallAci { try visitor.visitSingularBytesField(value: v, fieldNumber: 1) } }() try { if let v = self._startedCallTimestamp { try visitor.visitSingularUInt64Field(value: v, fieldNumber: 2) } }() - if !self.inCallUuids.isEmpty { - try visitor.visitRepeatedBytesField(value: self.inCallUuids, fieldNumber: 3) + if !self.inCallAcis.isEmpty { + try visitor.visitRepeatedBytesField(value: self.inCallAcis, fieldNumber: 3) } - try { if let v = self._isCallFull { - try visitor.visitSingularBoolField(value: v, fieldNumber: 4) - } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_GroupCallMessage, rhs: BackupProtos_GroupCallMessage) -> Bool { - if lhs._startedCallUuid != rhs._startedCallUuid {return false} + if lhs._startedCallAci != rhs._startedCallAci {return false} if lhs._startedCallTimestamp != rhs._startedCallTimestamp {return false} - if lhs.inCallUuids != rhs.inCallUuids {return false} - if lhs._isCallFull != rhs._isCallFull {return false} + if lhs.inCallAcis != rhs.inCallAcis {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -7024,18 +6797,35 @@ extension BackupProtos_GroupCallMessage: SwiftProtobuf.Message, SwiftProtobuf._M extension BackupProtos_SimpleUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".SimpleUpdate" - static let _protobuf_nameMap = SwiftProtobuf._NameMap() + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + ] mutating func decodeMessage(decoder: inout D) throws { - while let _ = try decoder.nextFieldNumber() { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + default: break + } } } func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_SimpleUpdate, rhs: BackupProtos_SimpleUpdate) -> Bool { + if lhs._type != rhs._type {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -7043,24 +6833,25 @@ extension BackupProtos_SimpleUpdate: SwiftProtobuf.Message, SwiftProtobuf._Messa extension BackupProtos_SimpleUpdate.TypeEnum: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "JOINED_SIGNAL"), - 1: .same(proto: "IDENTITY_UPDATE"), - 2: .same(proto: "IDENTITY_VERIFIED"), - 3: .same(proto: "IDENTITY_DEFAULT"), - 4: .same(proto: "CHANGE_NUMBER"), - 5: .same(proto: "BOOST_REQUEST"), - 6: .same(proto: "END_SESSION"), - 7: .same(proto: "CHAT_SESSION_REFRESH"), - 8: .same(proto: "BAD_DECRYPT"), - 9: .same(proto: "PAYMENTS_ACTIVATED"), - 10: .same(proto: "PAYMENT_ACTIVATION_REQUEST"), + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "JOINED_SIGNAL"), + 2: .same(proto: "IDENTITY_UPDATE"), + 3: .same(proto: "IDENTITY_VERIFIED"), + 4: .same(proto: "IDENTITY_DEFAULT"), + 5: .same(proto: "CHANGE_NUMBER"), + 6: .same(proto: "BOOST_REQUEST"), + 7: .same(proto: "END_SESSION"), + 8: .same(proto: "CHAT_SESSION_REFRESH"), + 9: .same(proto: "BAD_DECRYPT"), + 10: .same(proto: "PAYMENTS_ACTIVATED"), + 11: .same(proto: "PAYMENT_ACTIVATION_REQUEST"), ] } extension BackupProtos_GroupDescriptionUpdate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".GroupDescriptionUpdate" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "body"), + 1: .same(proto: "newDescription"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -7069,7 +6860,7 @@ extension BackupProtos_GroupDescriptionUpdate: SwiftProtobuf.Message, SwiftProto // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self._body) }() + case 1: try { try decoder.decodeSingularStringField(value: &self._newDescription) }() default: break } } @@ -7080,14 +6871,14 @@ extension BackupProtos_GroupDescriptionUpdate: SwiftProtobuf.Message, SwiftProto // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._body { + try { if let v = self._newDescription { try visitor.visitSingularStringField(value: v, fieldNumber: 1) } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_GroupDescriptionUpdate, rhs: BackupProtos_GroupDescriptionUpdate) -> Bool { - if lhs._body != rhs._body {return false} + if lhs._newDescription != rhs._newDescription {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -7096,7 +6887,7 @@ extension BackupProtos_GroupDescriptionUpdate: SwiftProtobuf.Message, SwiftProto extension BackupProtos_ExpirationTimerChange: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = _protobuf_package + ".ExpirationTimerChange" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "expiresIn"), + 1: .same(proto: "expiresInMs"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -7105,7 +6896,7 @@ extension BackupProtos_ExpirationTimerChange: SwiftProtobuf.Message, SwiftProtob // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self._expiresIn) }() + case 1: try { try decoder.decodeSingularUInt32Field(value: &self._expiresInMs) }() default: break } } @@ -7116,14 +6907,14 @@ extension BackupProtos_ExpirationTimerChange: SwiftProtobuf.Message, SwiftProtob // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._expiresIn { + try { if let v = self._expiresInMs { try visitor.visitSingularUInt32Field(value: v, fieldNumber: 1) } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_ExpirationTimerChange, rhs: BackupProtos_ExpirationTimerChange) -> Bool { - if lhs._expiresIn != rhs._expiresIn {return false} + if lhs._expiresInMs != rhs._expiresInMs {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -7310,70 +7101,36 @@ extension BackupProtos_StickerPackSticker: SwiftProtobuf.Message, SwiftProtobuf. 2: .same(proto: "emoji"), ] - fileprivate class _StorageClass { - var _data: BackupProtos_AttachmentPointer? = nil - var _emoji: String? = nil - - static let defaultInstance = _StorageClass() - - private init() {} - - init(copying source: _StorageClass) { - _data = source._data - _emoji = source._emoji - } - } - - fileprivate mutating func _uniqueStorage() -> _StorageClass { - if !isKnownUniquelyReferenced(&_storage) { - _storage = _StorageClass(copying: _storage) - } - return _storage - } - mutating func decodeMessage(decoder: inout D) throws { - _ = _uniqueStorage() - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &_storage._data) }() - case 2: try { try decoder.decodeSingularStringField(value: &_storage._emoji) }() - default: break - } + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._data) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._emoji) }() + default: break } } } func traverse(visitor: inout V) throws { - try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = _storage._data { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = _storage._emoji { - try visitor.visitSingularStringField(value: v, fieldNumber: 2) - } }() - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._data { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._emoji { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: BackupProtos_StickerPackSticker, rhs: BackupProtos_StickerPackSticker) -> Bool { - if lhs._storage !== rhs._storage { - let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in - let _storage = _args.0 - let rhs_storage = _args.1 - if _storage._data != rhs_storage._data {return false} - if _storage._emoji != rhs_storage._emoji {return false} - return true - } - if !storagesAreEqual {return false} - } + if lhs._data != rhs._data {return false} + if lhs._emoji != rhs._emoji {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/SignalServiceKit/src/Protos/Generated/BackupProto.swift b/SignalServiceKit/src/Protos/Generated/BackupProto.swift index fda9f573d6b..238b88cd389 100644 --- a/SignalServiceKit/src/Protos/Generated/BackupProto.swift +++ b/SignalServiceKit/src/Protos/Generated/BackupProto.swift @@ -24,7 +24,7 @@ public class BackupProtoBackupInfo: NSObject, Codable, NSSecureCoding { public let version: UInt64 @objc - public let backupTime: UInt64 + public let backupTimeMs: UInt64 public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty @@ -36,10 +36,10 @@ public class BackupProtoBackupInfo: NSObject, Codable, NSSecureCoding { private init(proto: BackupProtos_BackupInfo, version: UInt64, - backupTime: UInt64) { + backupTimeMs: UInt64) { self.proto = proto self.version = version - self.backupTime = backupTime + self.backupTimeMs = backupTimeMs } @objc @@ -59,14 +59,14 @@ public class BackupProtoBackupInfo: NSObject, Codable, NSSecureCoding { } let version = proto.version - guard proto.hasBackupTime else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: backupTime") + guard proto.hasBackupTimeMs else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: backupTimeMs") } - let backupTime = proto.backupTime + let backupTimeMs = proto.backupTimeMs self.init(proto: proto, version: version, - backupTime: backupTime) + backupTimeMs: backupTimeMs) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -107,14 +107,14 @@ public class BackupProtoBackupInfo: NSObject, Codable, NSSecureCoding { extension BackupProtoBackupInfo { @objc - public static func builder(version: UInt64, backupTime: UInt64) -> BackupProtoBackupInfoBuilder { - return BackupProtoBackupInfoBuilder(version: version, backupTime: backupTime) + public static func builder(version: UInt64, backupTimeMs: UInt64) -> BackupProtoBackupInfoBuilder { + return BackupProtoBackupInfoBuilder(version: version, backupTimeMs: backupTimeMs) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoBackupInfoBuilder { - let builder = BackupProtoBackupInfoBuilder(version: version, backupTime: backupTime) + let builder = BackupProtoBackupInfoBuilder(version: version, backupTimeMs: backupTimeMs) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -131,11 +131,11 @@ public class BackupProtoBackupInfoBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(version: UInt64, backupTime: UInt64) { + fileprivate init(version: UInt64, backupTimeMs: UInt64) { super.init() setVersion(version) - setBackupTime(backupTime) + setBackupTimeMs(backupTimeMs) } @objc @@ -144,8 +144,8 @@ public class BackupProtoBackupInfoBuilder: NSObject { } @objc - public func setBackupTime(_ valueParam: UInt64) { - proto.backupTime = valueParam + public func setBackupTimeMs(_ valueParam: UInt64) { + proto.backupTimeMs = valueParam } public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { @@ -717,9 +717,6 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC fileprivate let proto: BackupProtos_AccountData.AccountSettings - @objc - public let noteToSelfArchived: Bool - @objc public let readReceipts: Bool @@ -729,9 +726,6 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC @objc public let typingIndicators: Bool - @objc - public let proxiedLinkPreviews: Bool - @objc public let noteToSelfMarkedUnread: Bool @@ -739,7 +733,7 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC public let linkPreviews: Bool @objc - public let unlistedPhoneNumber: Bool + public let unlistedPhoneeumber: Bool @objc public let preferContactAvatars: Bool @@ -763,10 +757,7 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC public let storiesDisabled: Bool @objc - public let onboardingStoryHasBeenRead: Bool - - @objc - public let groupStoryEducationSheetHasBeenSet: Bool + public let groupStoryEducationSheetHasBeenSeen: Bool @objc public let usernameOnboardingHasBeenCompleted: Bool @@ -814,14 +805,12 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC } private init(proto: BackupProtos_AccountData.AccountSettings, - noteToSelfArchived: Bool, readReceipts: Bool, sealedSenderIndicators: Bool, typingIndicators: Bool, - proxiedLinkPreviews: Bool, noteToSelfMarkedUnread: Bool, linkPreviews: Bool, - unlistedPhoneNumber: Bool, + unlistedPhoneeumber: Bool, preferContactAvatars: Bool, universalExpireTimer: UInt32, displayBadgesOnProfile: Bool, @@ -829,18 +818,15 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC myStoriesPrivacyHasBeenSet: Bool, onboardingStoryHasBeenViewed: Bool, storiesDisabled: Bool, - onboardingStoryHasBeenRead: Bool, - groupStoryEducationSheetHasBeenSet: Bool, + groupStoryEducationSheetHasBeenSeen: Bool, usernameOnboardingHasBeenCompleted: Bool) { self.proto = proto - self.noteToSelfArchived = noteToSelfArchived self.readReceipts = readReceipts self.sealedSenderIndicators = sealedSenderIndicators self.typingIndicators = typingIndicators - self.proxiedLinkPreviews = proxiedLinkPreviews self.noteToSelfMarkedUnread = noteToSelfMarkedUnread self.linkPreviews = linkPreviews - self.unlistedPhoneNumber = unlistedPhoneNumber + self.unlistedPhoneeumber = unlistedPhoneeumber self.preferContactAvatars = preferContactAvatars self.universalExpireTimer = universalExpireTimer self.displayBadgesOnProfile = displayBadgesOnProfile @@ -848,8 +834,7 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC self.myStoriesPrivacyHasBeenSet = myStoriesPrivacyHasBeenSet self.onboardingStoryHasBeenViewed = onboardingStoryHasBeenViewed self.storiesDisabled = storiesDisabled - self.onboardingStoryHasBeenRead = onboardingStoryHasBeenRead - self.groupStoryEducationSheetHasBeenSet = groupStoryEducationSheetHasBeenSet + self.groupStoryEducationSheetHasBeenSeen = groupStoryEducationSheetHasBeenSeen self.usernameOnboardingHasBeenCompleted = usernameOnboardingHasBeenCompleted } @@ -865,11 +850,6 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC } fileprivate convenience init(_ proto: BackupProtos_AccountData.AccountSettings) throws { - guard proto.hasNoteToSelfArchived else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: noteToSelfArchived") - } - let noteToSelfArchived = proto.noteToSelfArchived - guard proto.hasReadReceipts else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: readReceipts") } @@ -885,11 +865,6 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC } let typingIndicators = proto.typingIndicators - guard proto.hasProxiedLinkPreviews else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: proxiedLinkPreviews") - } - let proxiedLinkPreviews = proto.proxiedLinkPreviews - guard proto.hasNoteToSelfMarkedUnread else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: noteToSelfMarkedUnread") } @@ -900,10 +875,10 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC } let linkPreviews = proto.linkPreviews - guard proto.hasUnlistedPhoneNumber else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: unlistedPhoneNumber") + guard proto.hasUnlistedPhoneeumber else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: unlistedPhoneeumber") } - let unlistedPhoneNumber = proto.unlistedPhoneNumber + let unlistedPhoneeumber = proto.unlistedPhoneeumber guard proto.hasPreferContactAvatars else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: preferContactAvatars") @@ -940,15 +915,10 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC } let storiesDisabled = proto.storiesDisabled - guard proto.hasOnboardingStoryHasBeenRead else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: onboardingStoryHasBeenRead") - } - let onboardingStoryHasBeenRead = proto.onboardingStoryHasBeenRead - - guard proto.hasGroupStoryEducationSheetHasBeenSet else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: groupStoryEducationSheetHasBeenSet") + guard proto.hasGroupStoryEducationSheetHasBeenSeen else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: groupStoryEducationSheetHasBeenSeen") } - let groupStoryEducationSheetHasBeenSet = proto.groupStoryEducationSheetHasBeenSet + let groupStoryEducationSheetHasBeenSeen = proto.groupStoryEducationSheetHasBeenSeen guard proto.hasUsernameOnboardingHasBeenCompleted else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: usernameOnboardingHasBeenCompleted") @@ -956,14 +926,12 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC let usernameOnboardingHasBeenCompleted = proto.usernameOnboardingHasBeenCompleted self.init(proto: proto, - noteToSelfArchived: noteToSelfArchived, readReceipts: readReceipts, sealedSenderIndicators: sealedSenderIndicators, typingIndicators: typingIndicators, - proxiedLinkPreviews: proxiedLinkPreviews, noteToSelfMarkedUnread: noteToSelfMarkedUnread, linkPreviews: linkPreviews, - unlistedPhoneNumber: unlistedPhoneNumber, + unlistedPhoneeumber: unlistedPhoneeumber, preferContactAvatars: preferContactAvatars, universalExpireTimer: universalExpireTimer, displayBadgesOnProfile: displayBadgesOnProfile, @@ -971,8 +939,7 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC myStoriesPrivacyHasBeenSet: myStoriesPrivacyHasBeenSet, onboardingStoryHasBeenViewed: onboardingStoryHasBeenViewed, storiesDisabled: storiesDisabled, - onboardingStoryHasBeenRead: onboardingStoryHasBeenRead, - groupStoryEducationSheetHasBeenSet: groupStoryEducationSheetHasBeenSet, + groupStoryEducationSheetHasBeenSeen: groupStoryEducationSheetHasBeenSeen, usernameOnboardingHasBeenCompleted: usernameOnboardingHasBeenCompleted) } @@ -1014,14 +981,14 @@ public class BackupProtoAccountDataAccountSettings: NSObject, Codable, NSSecureC extension BackupProtoAccountDataAccountSettings { @objc - public static func builder(noteToSelfArchived: Bool, readReceipts: Bool, sealedSenderIndicators: Bool, typingIndicators: Bool, proxiedLinkPreviews: Bool, noteToSelfMarkedUnread: Bool, linkPreviews: Bool, unlistedPhoneNumber: Bool, preferContactAvatars: Bool, universalExpireTimer: UInt32, displayBadgesOnProfile: Bool, keepMutedChatsArchived: Bool, myStoriesPrivacyHasBeenSet: Bool, onboardingStoryHasBeenViewed: Bool, storiesDisabled: Bool, onboardingStoryHasBeenRead: Bool, groupStoryEducationSheetHasBeenSet: Bool, usernameOnboardingHasBeenCompleted: Bool) -> BackupProtoAccountDataAccountSettingsBuilder { - return BackupProtoAccountDataAccountSettingsBuilder(noteToSelfArchived: noteToSelfArchived, readReceipts: readReceipts, sealedSenderIndicators: sealedSenderIndicators, typingIndicators: typingIndicators, proxiedLinkPreviews: proxiedLinkPreviews, noteToSelfMarkedUnread: noteToSelfMarkedUnread, linkPreviews: linkPreviews, unlistedPhoneNumber: unlistedPhoneNumber, preferContactAvatars: preferContactAvatars, universalExpireTimer: universalExpireTimer, displayBadgesOnProfile: displayBadgesOnProfile, keepMutedChatsArchived: keepMutedChatsArchived, myStoriesPrivacyHasBeenSet: myStoriesPrivacyHasBeenSet, onboardingStoryHasBeenViewed: onboardingStoryHasBeenViewed, storiesDisabled: storiesDisabled, onboardingStoryHasBeenRead: onboardingStoryHasBeenRead, groupStoryEducationSheetHasBeenSet: groupStoryEducationSheetHasBeenSet, usernameOnboardingHasBeenCompleted: usernameOnboardingHasBeenCompleted) + public static func builder(readReceipts: Bool, sealedSenderIndicators: Bool, typingIndicators: Bool, noteToSelfMarkedUnread: Bool, linkPreviews: Bool, unlistedPhoneeumber: Bool, preferContactAvatars: Bool, universalExpireTimer: UInt32, displayBadgesOnProfile: Bool, keepMutedChatsArchived: Bool, myStoriesPrivacyHasBeenSet: Bool, onboardingStoryHasBeenViewed: Bool, storiesDisabled: Bool, groupStoryEducationSheetHasBeenSeen: Bool, usernameOnboardingHasBeenCompleted: Bool) -> BackupProtoAccountDataAccountSettingsBuilder { + return BackupProtoAccountDataAccountSettingsBuilder(readReceipts: readReceipts, sealedSenderIndicators: sealedSenderIndicators, typingIndicators: typingIndicators, noteToSelfMarkedUnread: noteToSelfMarkedUnread, linkPreviews: linkPreviews, unlistedPhoneeumber: unlistedPhoneeumber, preferContactAvatars: preferContactAvatars, universalExpireTimer: universalExpireTimer, displayBadgesOnProfile: displayBadgesOnProfile, keepMutedChatsArchived: keepMutedChatsArchived, myStoriesPrivacyHasBeenSet: myStoriesPrivacyHasBeenSet, onboardingStoryHasBeenViewed: onboardingStoryHasBeenViewed, storiesDisabled: storiesDisabled, groupStoryEducationSheetHasBeenSeen: groupStoryEducationSheetHasBeenSeen, usernameOnboardingHasBeenCompleted: usernameOnboardingHasBeenCompleted) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoAccountDataAccountSettingsBuilder { - let builder = BackupProtoAccountDataAccountSettingsBuilder(noteToSelfArchived: noteToSelfArchived, readReceipts: readReceipts, sealedSenderIndicators: sealedSenderIndicators, typingIndicators: typingIndicators, proxiedLinkPreviews: proxiedLinkPreviews, noteToSelfMarkedUnread: noteToSelfMarkedUnread, linkPreviews: linkPreviews, unlistedPhoneNumber: unlistedPhoneNumber, preferContactAvatars: preferContactAvatars, universalExpireTimer: universalExpireTimer, displayBadgesOnProfile: displayBadgesOnProfile, keepMutedChatsArchived: keepMutedChatsArchived, myStoriesPrivacyHasBeenSet: myStoriesPrivacyHasBeenSet, onboardingStoryHasBeenViewed: onboardingStoryHasBeenViewed, storiesDisabled: storiesDisabled, onboardingStoryHasBeenRead: onboardingStoryHasBeenRead, groupStoryEducationSheetHasBeenSet: groupStoryEducationSheetHasBeenSet, usernameOnboardingHasBeenCompleted: usernameOnboardingHasBeenCompleted) + let builder = BackupProtoAccountDataAccountSettingsBuilder(readReceipts: readReceipts, sealedSenderIndicators: sealedSenderIndicators, typingIndicators: typingIndicators, noteToSelfMarkedUnread: noteToSelfMarkedUnread, linkPreviews: linkPreviews, unlistedPhoneeumber: unlistedPhoneeumber, preferContactAvatars: preferContactAvatars, universalExpireTimer: universalExpireTimer, displayBadgesOnProfile: displayBadgesOnProfile, keepMutedChatsArchived: keepMutedChatsArchived, myStoriesPrivacyHasBeenSet: myStoriesPrivacyHasBeenSet, onboardingStoryHasBeenViewed: onboardingStoryHasBeenViewed, storiesDisabled: storiesDisabled, groupStoryEducationSheetHasBeenSeen: groupStoryEducationSheetHasBeenSeen, usernameOnboardingHasBeenCompleted: usernameOnboardingHasBeenCompleted) builder.setPreferredReactionEmoji(preferredReactionEmoji) if hasStoryViewReceiptsEnabled { builder.setStoryViewReceiptsEnabled(storyViewReceiptsEnabled) @@ -1045,17 +1012,15 @@ public class BackupProtoAccountDataAccountSettingsBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(noteToSelfArchived: Bool, readReceipts: Bool, sealedSenderIndicators: Bool, typingIndicators: Bool, proxiedLinkPreviews: Bool, noteToSelfMarkedUnread: Bool, linkPreviews: Bool, unlistedPhoneNumber: Bool, preferContactAvatars: Bool, universalExpireTimer: UInt32, displayBadgesOnProfile: Bool, keepMutedChatsArchived: Bool, myStoriesPrivacyHasBeenSet: Bool, onboardingStoryHasBeenViewed: Bool, storiesDisabled: Bool, onboardingStoryHasBeenRead: Bool, groupStoryEducationSheetHasBeenSet: Bool, usernameOnboardingHasBeenCompleted: Bool) { + fileprivate init(readReceipts: Bool, sealedSenderIndicators: Bool, typingIndicators: Bool, noteToSelfMarkedUnread: Bool, linkPreviews: Bool, unlistedPhoneeumber: Bool, preferContactAvatars: Bool, universalExpireTimer: UInt32, displayBadgesOnProfile: Bool, keepMutedChatsArchived: Bool, myStoriesPrivacyHasBeenSet: Bool, onboardingStoryHasBeenViewed: Bool, storiesDisabled: Bool, groupStoryEducationSheetHasBeenSeen: Bool, usernameOnboardingHasBeenCompleted: Bool) { super.init() - setNoteToSelfArchived(noteToSelfArchived) setReadReceipts(readReceipts) setSealedSenderIndicators(sealedSenderIndicators) setTypingIndicators(typingIndicators) - setProxiedLinkPreviews(proxiedLinkPreviews) setNoteToSelfMarkedUnread(noteToSelfMarkedUnread) setLinkPreviews(linkPreviews) - setUnlistedPhoneNumber(unlistedPhoneNumber) + setUnlistedPhoneeumber(unlistedPhoneeumber) setPreferContactAvatars(preferContactAvatars) setUniversalExpireTimer(universalExpireTimer) setDisplayBadgesOnProfile(displayBadgesOnProfile) @@ -1063,16 +1028,10 @@ public class BackupProtoAccountDataAccountSettingsBuilder: NSObject { setMyStoriesPrivacyHasBeenSet(myStoriesPrivacyHasBeenSet) setOnboardingStoryHasBeenViewed(onboardingStoryHasBeenViewed) setStoriesDisabled(storiesDisabled) - setOnboardingStoryHasBeenRead(onboardingStoryHasBeenRead) - setGroupStoryEducationSheetHasBeenSet(groupStoryEducationSheetHasBeenSet) + setGroupStoryEducationSheetHasBeenSeen(groupStoryEducationSheetHasBeenSeen) setUsernameOnboardingHasBeenCompleted(usernameOnboardingHasBeenCompleted) } - @objc - public func setNoteToSelfArchived(_ valueParam: Bool) { - proto.noteToSelfArchived = valueParam - } - @objc public func setReadReceipts(_ valueParam: Bool) { proto.readReceipts = valueParam @@ -1088,11 +1047,6 @@ public class BackupProtoAccountDataAccountSettingsBuilder: NSObject { proto.typingIndicators = valueParam } - @objc - public func setProxiedLinkPreviews(_ valueParam: Bool) { - proto.proxiedLinkPreviews = valueParam - } - @objc public func setNoteToSelfMarkedUnread(_ valueParam: Bool) { proto.noteToSelfMarkedUnread = valueParam @@ -1104,8 +1058,8 @@ public class BackupProtoAccountDataAccountSettingsBuilder: NSObject { } @objc - public func setUnlistedPhoneNumber(_ valueParam: Bool) { - proto.unlistedPhoneNumber = valueParam + public func setUnlistedPhoneeumber(_ valueParam: Bool) { + proto.unlistedPhoneeumber = valueParam } @objc @@ -1159,13 +1113,8 @@ public class BackupProtoAccountDataAccountSettingsBuilder: NSObject { } @objc - public func setOnboardingStoryHasBeenRead(_ valueParam: Bool) { - proto.onboardingStoryHasBeenRead = valueParam - } - - @objc - public func setGroupStoryEducationSheetHasBeenSet(_ valueParam: Bool) { - proto.groupStoryEducationSheetHasBeenSet = valueParam + public func setGroupStoryEducationSheetHasBeenSeen(_ valueParam: Bool) { + proto.groupStoryEducationSheetHasBeenSeen = valueParam } @objc @@ -1215,23 +1164,23 @@ extension BackupProtoAccountDataAccountSettingsBuilder { @objc public enum BackupProtoAccountDataPhoneNumberSharingMode: Int32 { - case everybody = 0 - case contactsOnly = 1 + case unknown = 0 + case everybody = 1 case nobody = 2 } private func BackupProtoAccountDataPhoneNumberSharingModeWrap(_ value: BackupProtos_AccountData.PhoneNumberSharingMode) -> BackupProtoAccountDataPhoneNumberSharingMode { switch value { + case .unknown: return .unknown case .everybody: return .everybody - case .contactsOnly: return .contactsOnly case .nobody: return .nobody } } private func BackupProtoAccountDataPhoneNumberSharingModeUnwrap(_ value: BackupProtoAccountDataPhoneNumberSharingMode) -> BackupProtos_AccountData.PhoneNumberSharingMode { switch value { + case .unknown: return .unknown case .everybody: return .everybody - case .contactsOnly: return .contactsOnly case .nobody: return .nobody } } @@ -1243,18 +1192,6 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_AccountData - @objc - public let aciIdentityPublicKey: Data - - @objc - public let aciIdentityPrivateKey: Data - - @objc - public let pniIdentityPublicKey: Data - - @objc - public let pniIdentityPrivateKey: Data - @objc public let profileKey: Data @@ -1282,15 +1219,6 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { @objc public let accountSettings: BackupProtoAccountDataAccountSettings - @objc - public let aci: Data - - @objc - public let pni: Data - - @objc - public let e164: UInt64 - @objc public var username: String? { guard hasUsername else { @@ -1312,10 +1240,6 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { } private init(proto: BackupProtos_AccountData, - aciIdentityPublicKey: Data, - aciIdentityPrivateKey: Data, - pniIdentityPublicKey: Data, - pniIdentityPrivateKey: Data, profileKey: Data, usernameLink: BackupProtoAccountDataUsernameLink, givenName: String, @@ -1324,15 +1248,8 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { subscriberID: Data, subscriberCurrencyCode: String, subscriptionManuallyCancelled: Bool, - accountSettings: BackupProtoAccountDataAccountSettings, - aci: Data, - pni: Data, - e164: UInt64) { + accountSettings: BackupProtoAccountDataAccountSettings) { self.proto = proto - self.aciIdentityPublicKey = aciIdentityPublicKey - self.aciIdentityPrivateKey = aciIdentityPrivateKey - self.pniIdentityPublicKey = pniIdentityPublicKey - self.pniIdentityPrivateKey = pniIdentityPrivateKey self.profileKey = profileKey self.usernameLink = usernameLink self.givenName = givenName @@ -1342,9 +1259,6 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { self.subscriberCurrencyCode = subscriberCurrencyCode self.subscriptionManuallyCancelled = subscriptionManuallyCancelled self.accountSettings = accountSettings - self.aci = aci - self.pni = pni - self.e164 = e164 } @objc @@ -1359,26 +1273,6 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { } fileprivate convenience init(_ proto: BackupProtos_AccountData) throws { - guard proto.hasAciIdentityPublicKey else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: aciIdentityPublicKey") - } - let aciIdentityPublicKey = proto.aciIdentityPublicKey - - guard proto.hasAciIdentityPrivateKey else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: aciIdentityPrivateKey") - } - let aciIdentityPrivateKey = proto.aciIdentityPrivateKey - - guard proto.hasPniIdentityPublicKey else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: pniIdentityPublicKey") - } - let pniIdentityPublicKey = proto.pniIdentityPublicKey - - guard proto.hasPniIdentityPrivateKey else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: pniIdentityPrivateKey") - } - let pniIdentityPrivateKey = proto.pniIdentityPrivateKey - guard proto.hasProfileKey else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: profileKey") } @@ -1424,26 +1318,7 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { } let accountSettings = try BackupProtoAccountDataAccountSettings(proto.accountSettings) - guard proto.hasAci else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: aci") - } - let aci = proto.aci - - guard proto.hasPni else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: pni") - } - let pni = proto.pni - - guard proto.hasE164 else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: e164") - } - let e164 = proto.e164 - self.init(proto: proto, - aciIdentityPublicKey: aciIdentityPublicKey, - aciIdentityPrivateKey: aciIdentityPrivateKey, - pniIdentityPublicKey: pniIdentityPublicKey, - pniIdentityPrivateKey: pniIdentityPrivateKey, profileKey: profileKey, usernameLink: usernameLink, givenName: givenName, @@ -1452,10 +1327,7 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { subscriberID: subscriberID, subscriberCurrencyCode: subscriberCurrencyCode, subscriptionManuallyCancelled: subscriptionManuallyCancelled, - accountSettings: accountSettings, - aci: aci, - pni: pni, - e164: e164) + accountSettings: accountSettings) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -1496,14 +1368,14 @@ public class BackupProtoAccountData: NSObject, Codable, NSSecureCoding { extension BackupProtoAccountData { @objc - public static func builder(aciIdentityPublicKey: Data, aciIdentityPrivateKey: Data, pniIdentityPublicKey: Data, pniIdentityPrivateKey: Data, profileKey: Data, usernameLink: BackupProtoAccountDataUsernameLink, givenName: String, familyName: String, avatarPath: String, subscriberID: Data, subscriberCurrencyCode: String, subscriptionManuallyCancelled: Bool, accountSettings: BackupProtoAccountDataAccountSettings, aci: Data, pni: Data, e164: UInt64) -> BackupProtoAccountDataBuilder { - return BackupProtoAccountDataBuilder(aciIdentityPublicKey: aciIdentityPublicKey, aciIdentityPrivateKey: aciIdentityPrivateKey, pniIdentityPublicKey: pniIdentityPublicKey, pniIdentityPrivateKey: pniIdentityPrivateKey, profileKey: profileKey, usernameLink: usernameLink, givenName: givenName, familyName: familyName, avatarPath: avatarPath, subscriberID: subscriberID, subscriberCurrencyCode: subscriberCurrencyCode, subscriptionManuallyCancelled: subscriptionManuallyCancelled, accountSettings: accountSettings, aci: aci, pni: pni, e164: e164) + public static func builder(profileKey: Data, usernameLink: BackupProtoAccountDataUsernameLink, givenName: String, familyName: String, avatarPath: String, subscriberID: Data, subscriberCurrencyCode: String, subscriptionManuallyCancelled: Bool, accountSettings: BackupProtoAccountDataAccountSettings) -> BackupProtoAccountDataBuilder { + return BackupProtoAccountDataBuilder(profileKey: profileKey, usernameLink: usernameLink, givenName: givenName, familyName: familyName, avatarPath: avatarPath, subscriberID: subscriberID, subscriberCurrencyCode: subscriberCurrencyCode, subscriptionManuallyCancelled: subscriptionManuallyCancelled, accountSettings: accountSettings) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoAccountDataBuilder { - let builder = BackupProtoAccountDataBuilder(aciIdentityPublicKey: aciIdentityPublicKey, aciIdentityPrivateKey: aciIdentityPrivateKey, pniIdentityPublicKey: pniIdentityPublicKey, pniIdentityPrivateKey: pniIdentityPrivateKey, profileKey: profileKey, usernameLink: usernameLink, givenName: givenName, familyName: familyName, avatarPath: avatarPath, subscriberID: subscriberID, subscriberCurrencyCode: subscriberCurrencyCode, subscriptionManuallyCancelled: subscriptionManuallyCancelled, accountSettings: accountSettings, aci: aci, pni: pni, e164: e164) + let builder = BackupProtoAccountDataBuilder(profileKey: profileKey, usernameLink: usernameLink, givenName: givenName, familyName: familyName, avatarPath: avatarPath, subscriberID: subscriberID, subscriberCurrencyCode: subscriberCurrencyCode, subscriptionManuallyCancelled: subscriptionManuallyCancelled, accountSettings: accountSettings) if let _value = username { builder.setUsername(_value) } @@ -1523,13 +1395,9 @@ public class BackupProtoAccountDataBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(aciIdentityPublicKey: Data, aciIdentityPrivateKey: Data, pniIdentityPublicKey: Data, pniIdentityPrivateKey: Data, profileKey: Data, usernameLink: BackupProtoAccountDataUsernameLink, givenName: String, familyName: String, avatarPath: String, subscriberID: Data, subscriberCurrencyCode: String, subscriptionManuallyCancelled: Bool, accountSettings: BackupProtoAccountDataAccountSettings, aci: Data, pni: Data, e164: UInt64) { + fileprivate init(profileKey: Data, usernameLink: BackupProtoAccountDataUsernameLink, givenName: String, familyName: String, avatarPath: String, subscriberID: Data, subscriberCurrencyCode: String, subscriptionManuallyCancelled: Bool, accountSettings: BackupProtoAccountDataAccountSettings) { super.init() - setAciIdentityPublicKey(aciIdentityPublicKey) - setAciIdentityPrivateKey(aciIdentityPrivateKey) - setPniIdentityPublicKey(pniIdentityPublicKey) - setPniIdentityPrivateKey(pniIdentityPrivateKey) setProfileKey(profileKey) setUsernameLink(usernameLink) setGivenName(givenName) @@ -1539,53 +1407,6 @@ public class BackupProtoAccountDataBuilder: NSObject { setSubscriberCurrencyCode(subscriberCurrencyCode) setSubscriptionManuallyCancelled(subscriptionManuallyCancelled) setAccountSettings(accountSettings) - setAci(aci) - setPni(pni) - setE164(e164) - } - - @objc - @available(swift, obsoleted: 1.0) - public func setAciIdentityPublicKey(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.aciIdentityPublicKey = valueParam - } - - public func setAciIdentityPublicKey(_ valueParam: Data) { - proto.aciIdentityPublicKey = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setAciIdentityPrivateKey(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.aciIdentityPrivateKey = valueParam - } - - public func setAciIdentityPrivateKey(_ valueParam: Data) { - proto.aciIdentityPrivateKey = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setPniIdentityPublicKey(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.pniIdentityPublicKey = valueParam - } - - public func setPniIdentityPublicKey(_ valueParam: Data) { - proto.pniIdentityPublicKey = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setPniIdentityPrivateKey(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.pniIdentityPrivateKey = valueParam - } - - public func setPniIdentityPrivateKey(_ valueParam: Data) { - proto.pniIdentityPrivateKey = valueParam } @objc @@ -1692,33 +1513,6 @@ public class BackupProtoAccountDataBuilder: NSObject { proto.accountSettings = valueParam.proto } - @objc - @available(swift, obsoleted: 1.0) - public func setAci(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.aci = valueParam - } - - public func setAci(_ valueParam: Data) { - proto.aci = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setPni(_ valueParam: Data?) { - guard let valueParam = valueParam else { return } - proto.pni = valueParam - } - - public func setPni(_ valueParam: Data) { - proto.pni = valueParam - } - - @objc - public func setE164(_ valueParam: UInt64) { - proto.e164 = valueParam - } - public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @@ -1774,6 +1568,9 @@ public class BackupProtoRecipient: NSObject, Codable, NSSecureCoding { @objc public let selfRecipient: BackupProtoSelfRecipient? + @objc + public let releaseNotes: BackupProtoReleaseNotes? + public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty } @@ -1787,13 +1584,15 @@ public class BackupProtoRecipient: NSObject, Codable, NSSecureCoding { contact: BackupProtoContact?, group: BackupProtoGroup?, distributionList: BackupProtoDistributionList?, - selfRecipient: BackupProtoSelfRecipient?) { + selfRecipient: BackupProtoSelfRecipient?, + releaseNotes: BackupProtoReleaseNotes?) { self.proto = proto self.id = id self.contact = contact self.group = group self.distributionList = distributionList self.selfRecipient = selfRecipient + self.releaseNotes = releaseNotes } @objc @@ -1833,12 +1632,18 @@ public class BackupProtoRecipient: NSObject, Codable, NSSecureCoding { selfRecipient = BackupProtoSelfRecipient(proto.selfRecipient) } + var releaseNotes: BackupProtoReleaseNotes? + if proto.hasReleaseNotes { + releaseNotes = BackupProtoReleaseNotes(proto.releaseNotes) + } + self.init(proto: proto, id: id, contact: contact, group: group, distributionList: distributionList, - selfRecipient: selfRecipient) + selfRecipient: selfRecipient, + releaseNotes: releaseNotes) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -1899,6 +1704,9 @@ extension BackupProtoRecipient { if let _value = selfRecipient { builder.setSelfRecipient(_value) } + if let _value = releaseNotes { + builder.setReleaseNotes(_value) + } if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -1970,6 +1778,17 @@ public class BackupProtoRecipientBuilder: NSObject { proto.selfRecipient = valueParam.proto } + @objc + @available(swift, obsoleted: 1.0) + public func setReleaseNotes(_ valueParam: BackupProtoReleaseNotes?) { + guard let valueParam = valueParam else { return } + proto.releaseNotes = valueParam.proto + } + + public func setReleaseNotes(_ valueParam: BackupProtoReleaseNotes) { + proto.releaseNotes = valueParam.proto + } + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @@ -2151,18 +1970,6 @@ public class BackupProtoContact: NSObject, Codable, NSSecureCoding { return proto.hasProfileFamilyName } - @objc - public var profileJoinedName: String? { - guard hasProfileJoinedName else { - return nil - } - return proto.profileJoinedName - } - @objc - public var hasProfileJoinedName: Bool { - return proto.hasProfileJoinedName - } - public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty } @@ -2300,9 +2107,6 @@ extension BackupProtoContact { if let _value = profileFamilyName { builder.setProfileFamilyName(_value) } - if let _value = profileJoinedName { - builder.setProfileJoinedName(_value) - } if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -2425,17 +2229,6 @@ public class BackupProtoContactBuilder: NSObject { proto.profileFamilyName = valueParam } - @objc - @available(swift, obsoleted: 1.0) - public func setProfileJoinedName(_ valueParam: String?) { - guard let valueParam = valueParam else { return } - proto.profileJoinedName = valueParam - } - - public func setProfileJoinedName(_ valueParam: String) { - proto.profileJoinedName = valueParam - } - @objc public func setHideStory(_ valueParam: Bool) { proto.hideStory = valueParam @@ -2851,36 +2644,12 @@ extension BackupProtoSelfRecipientBuilder { #endif -// MARK: - BackupProtoChat +// MARK: - BackupProtoReleaseNotes @objc -public class BackupProtoChat: NSObject, Codable, NSSecureCoding { - - fileprivate let proto: BackupProtos_Chat - - @objc - public let id: UInt64 - - @objc - public let recipientID: UInt64 - - @objc - public let archived: Bool - - @objc - public let pinned: Bool - - @objc - public let expirationTimer: UInt64 - - @objc - public let muteUntil: UInt64 - - @objc - public let markedUnread: Bool +public class BackupProtoReleaseNotes: NSObject, Codable, NSSecureCoding { - @objc - public let dontNotifyForMentionsIfMuted: Bool + fileprivate let proto: BackupProtos_ReleaseNotes public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty @@ -2890,24 +2659,8 @@ public class BackupProtoChat: NSObject, Codable, NSSecureCoding { return proto.unknownFields } - private init(proto: BackupProtos_Chat, - id: UInt64, - recipientID: UInt64, - archived: Bool, - pinned: Bool, - expirationTimer: UInt64, - muteUntil: UInt64, - markedUnread: Bool, - dontNotifyForMentionsIfMuted: Bool) { + private init(proto: BackupProtos_ReleaseNotes) { self.proto = proto - self.id = id - self.recipientID = recipientID - self.archived = archived - self.pinned = pinned - self.expirationTimer = expirationTimer - self.muteUntil = muteUntil - self.markedUnread = markedUnread - self.dontNotifyForMentionsIfMuted = dontNotifyForMentionsIfMuted } @objc @@ -2917,60 +2670,12 @@ public class BackupProtoChat: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { - let proto = try BackupProtos_Chat(serializedData: serializedData) - try self.init(proto) + let proto = try BackupProtos_ReleaseNotes(serializedData: serializedData) + self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_Chat) throws { - guard proto.hasID else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: id") - } - let id = proto.id - - guard proto.hasRecipientID else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: recipientID") - } - let recipientID = proto.recipientID - - guard proto.hasArchived else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: archived") - } - let archived = proto.archived - - guard proto.hasPinned else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: pinned") - } - let pinned = proto.pinned - - guard proto.hasExpirationTimer else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: expirationTimer") - } - let expirationTimer = proto.expirationTimer - - guard proto.hasMuteUntil else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: muteUntil") - } - let muteUntil = proto.muteUntil - - guard proto.hasMarkedUnread else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: markedUnread") - } - let markedUnread = proto.markedUnread - - guard proto.hasDontNotifyForMentionsIfMuted else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: dontNotifyForMentionsIfMuted") - } - let dontNotifyForMentionsIfMuted = proto.dontNotifyForMentionsIfMuted - - self.init(proto: proto, - id: id, - recipientID: recipientID, - archived: archived, - pinned: pinned, - expirationTimer: expirationTimer, - muteUntil: muteUntil, - markedUnread: markedUnread, - dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted) + fileprivate convenience init(_ proto: BackupProtos_ReleaseNotes) { + self.init(proto: proto) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -3009,16 +2714,16 @@ public class BackupProtoChat: NSObject, Codable, NSSecureCoding { } } -extension BackupProtoChat { +extension BackupProtoReleaseNotes { @objc - public static func builder(id: UInt64, recipientID: UInt64, archived: Bool, pinned: Bool, expirationTimer: UInt64, muteUntil: UInt64, markedUnread: Bool, dontNotifyForMentionsIfMuted: Bool) -> BackupProtoChatBuilder { - return BackupProtoChatBuilder(id: id, recipientID: recipientID, archived: archived, pinned: pinned, expirationTimer: expirationTimer, muteUntil: muteUntil, markedUnread: markedUnread, dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted) + public static func builder() -> BackupProtoReleaseNotesBuilder { + return BackupProtoReleaseNotesBuilder() } // asBuilder() constructs a builder that reflects the proto's contents. @objc - public func asBuilder() -> BackupProtoChatBuilder { - let builder = BackupProtoChatBuilder(id: id, recipientID: recipientID, archived: archived, pinned: pinned, expirationTimer: expirationTimer, muteUntil: muteUntil, markedUnread: markedUnread, dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted) + public func asBuilder() -> BackupProtoReleaseNotesBuilder { + let builder = BackupProtoReleaseNotesBuilder() if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -3027,66 +2732,312 @@ extension BackupProtoChat { } @objc -public class BackupProtoChatBuilder: NSObject { +public class BackupProtoReleaseNotesBuilder: NSObject { - private var proto = BackupProtos_Chat() + private var proto = BackupProtos_ReleaseNotes() @objc fileprivate override init() {} - @objc - fileprivate init(id: UInt64, recipientID: UInt64, archived: Bool, pinned: Bool, expirationTimer: UInt64, muteUntil: UInt64, markedUnread: Bool, dontNotifyForMentionsIfMuted: Bool) { - super.init() - - setId(id) - setRecipientID(recipientID) - setArchived(archived) - setPinned(pinned) - setExpirationTimer(expirationTimer) - setMuteUntil(muteUntil) - setMarkedUnread(markedUnread) - setDontNotifyForMentionsIfMuted(dontNotifyForMentionsIfMuted) + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { + proto.unknownFields = unknownFields } @objc - public func setId(_ valueParam: UInt64) { - proto.id = valueParam + public func build() throws -> BackupProtoReleaseNotes { + return BackupProtoReleaseNotes(proto) } @objc - public func setRecipientID(_ valueParam: UInt64) { - proto.recipientID = valueParam + public func buildInfallibly() -> BackupProtoReleaseNotes { + return BackupProtoReleaseNotes(proto) } @objc - public func setArchived(_ valueParam: Bool) { - proto.archived = valueParam + public func buildSerializedData() throws -> Data { + return try BackupProtoReleaseNotes(proto).serializedData() } +} - @objc - public func setPinned(_ valueParam: Bool) { - proto.pinned = valueParam - } +#if TESTABLE_BUILD +extension BackupProtoReleaseNotes { @objc - public func setExpirationTimer(_ valueParam: UInt64) { - proto.expirationTimer = valueParam + public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() } +} +extension BackupProtoReleaseNotesBuilder { @objc - public func setMuteUntil(_ valueParam: UInt64) { - proto.muteUntil = valueParam + public func buildIgnoringErrors() -> BackupProtoReleaseNotes? { + return self.buildInfallibly() } +} - @objc - public func setMarkedUnread(_ valueParam: Bool) { - proto.markedUnread = valueParam - } +#endif - @objc - public func setDontNotifyForMentionsIfMuted(_ valueParam: Bool) { - proto.dontNotifyForMentionsIfMuted = valueParam - } +// MARK: - BackupProtoChat + +@objc +public class BackupProtoChat: NSObject, Codable, NSSecureCoding { + + fileprivate let proto: BackupProtos_Chat + + @objc + public let id: UInt64 + + @objc + public let recipientID: UInt64 + + @objc + public let archived: Bool + + @objc + public let pinnedOrder: UInt32 + + @objc + public let expirationTimerMs: UInt64 + + @objc + public let muteUntilMs: UInt64 + + @objc + public let markedUnread: Bool + + @objc + public let dontNotifyForMentionsIfMuted: Bool + + @objc + public let wallpaper: BackupProtoFilePointer? + + public var hasUnknownFields: Bool { + return !proto.unknownFields.data.isEmpty + } + public var unknownFields: SwiftProtobuf.UnknownStorage? { + guard hasUnknownFields else { return nil } + return proto.unknownFields + } + + private init(proto: BackupProtos_Chat, + id: UInt64, + recipientID: UInt64, + archived: Bool, + pinnedOrder: UInt32, + expirationTimerMs: UInt64, + muteUntilMs: UInt64, + markedUnread: Bool, + dontNotifyForMentionsIfMuted: Bool, + wallpaper: BackupProtoFilePointer?) { + self.proto = proto + self.id = id + self.recipientID = recipientID + self.archived = archived + self.pinnedOrder = pinnedOrder + self.expirationTimerMs = expirationTimerMs + self.muteUntilMs = muteUntilMs + self.markedUnread = markedUnread + self.dontNotifyForMentionsIfMuted = dontNotifyForMentionsIfMuted + self.wallpaper = wallpaper + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc + public convenience init(serializedData: Data) throws { + let proto = try BackupProtos_Chat(serializedData: serializedData) + try self.init(proto) + } + + fileprivate convenience init(_ proto: BackupProtos_Chat) throws { + guard proto.hasID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: id") + } + let id = proto.id + + guard proto.hasRecipientID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: recipientID") + } + let recipientID = proto.recipientID + + guard proto.hasArchived else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: archived") + } + let archived = proto.archived + + guard proto.hasPinnedOrder else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: pinnedOrder") + } + let pinnedOrder = proto.pinnedOrder + + guard proto.hasExpirationTimerMs else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: expirationTimerMs") + } + let expirationTimerMs = proto.expirationTimerMs + + guard proto.hasMuteUntilMs else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: muteUntilMs") + } + let muteUntilMs = proto.muteUntilMs + + guard proto.hasMarkedUnread else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: markedUnread") + } + let markedUnread = proto.markedUnread + + guard proto.hasDontNotifyForMentionsIfMuted else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: dontNotifyForMentionsIfMuted") + } + let dontNotifyForMentionsIfMuted = proto.dontNotifyForMentionsIfMuted + + var wallpaper: BackupProtoFilePointer? + if proto.hasWallpaper { + wallpaper = try BackupProtoFilePointer(proto.wallpaper) + } + + self.init(proto: proto, + id: id, + recipientID: recipientID, + archived: archived, + pinnedOrder: pinnedOrder, + expirationTimerMs: expirationTimerMs, + muteUntilMs: muteUntilMs, + markedUnread: markedUnread, + dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted, + wallpaper: wallpaper) + } + + public required convenience init(from decoder: Swift.Decoder) throws { + let singleValueContainer = try decoder.singleValueContainer() + let serializedData = try singleValueContainer.decode(Data.self) + try self.init(serializedData: serializedData) + } + public func encode(to encoder: Swift.Encoder) throws { + var singleValueContainer = encoder.singleValueContainer() + try singleValueContainer.encode(try serializedData()) + } + + public static var supportsSecureCoding: Bool { true } + + public required convenience init?(coder: NSCoder) { + guard let serializedData = coder.decodeData() else { return nil } + do { + try self.init(serializedData: serializedData) + } catch { + owsFailDebug("Failed to decode serialized data \(error)") + return nil + } + } + + public func encode(with coder: NSCoder) { + do { + coder.encode(try serializedData()) + } catch { + owsFailDebug("Failed to encode serialized data \(error)") + } + } + + @objc + public override var debugDescription: String { + return "\(proto)" + } +} + +extension BackupProtoChat { + @objc + public static func builder(id: UInt64, recipientID: UInt64, archived: Bool, pinnedOrder: UInt32, expirationTimerMs: UInt64, muteUntilMs: UInt64, markedUnread: Bool, dontNotifyForMentionsIfMuted: Bool) -> BackupProtoChatBuilder { + return BackupProtoChatBuilder(id: id, recipientID: recipientID, archived: archived, pinnedOrder: pinnedOrder, expirationTimerMs: expirationTimerMs, muteUntilMs: muteUntilMs, markedUnread: markedUnread, dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted) + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc + public func asBuilder() -> BackupProtoChatBuilder { + let builder = BackupProtoChatBuilder(id: id, recipientID: recipientID, archived: archived, pinnedOrder: pinnedOrder, expirationTimerMs: expirationTimerMs, muteUntilMs: muteUntilMs, markedUnread: markedUnread, dontNotifyForMentionsIfMuted: dontNotifyForMentionsIfMuted) + if let _value = wallpaper { + builder.setWallpaper(_value) + } + if let _value = unknownFields { + builder.setUnknownFields(_value) + } + return builder + } +} + +@objc +public class BackupProtoChatBuilder: NSObject { + + private var proto = BackupProtos_Chat() + + @objc + fileprivate override init() {} + + @objc + fileprivate init(id: UInt64, recipientID: UInt64, archived: Bool, pinnedOrder: UInt32, expirationTimerMs: UInt64, muteUntilMs: UInt64, markedUnread: Bool, dontNotifyForMentionsIfMuted: Bool) { + super.init() + + setId(id) + setRecipientID(recipientID) + setArchived(archived) + setPinnedOrder(pinnedOrder) + setExpirationTimerMs(expirationTimerMs) + setMuteUntilMs(muteUntilMs) + setMarkedUnread(markedUnread) + setDontNotifyForMentionsIfMuted(dontNotifyForMentionsIfMuted) + } + + @objc + public func setId(_ valueParam: UInt64) { + proto.id = valueParam + } + + @objc + public func setRecipientID(_ valueParam: UInt64) { + proto.recipientID = valueParam + } + + @objc + public func setArchived(_ valueParam: Bool) { + proto.archived = valueParam + } + + @objc + public func setPinnedOrder(_ valueParam: UInt32) { + proto.pinnedOrder = valueParam + } + + @objc + public func setExpirationTimerMs(_ valueParam: UInt64) { + proto.expirationTimerMs = valueParam + } + + @objc + public func setMuteUntilMs(_ valueParam: UInt64) { + proto.muteUntilMs = valueParam + } + + @objc + public func setMarkedUnread(_ valueParam: Bool) { + proto.markedUnread = valueParam + } + + @objc + public func setDontNotifyForMentionsIfMuted(_ valueParam: Bool) { + proto.dontNotifyForMentionsIfMuted = valueParam + } + + @objc + @available(swift, obsoleted: 1.0) + public func setWallpaper(_ valueParam: BackupProtoFilePointer?) { + guard let valueParam = valueParam else { return } + proto.wallpaper = valueParam.proto + } + + public func setWallpaper(_ valueParam: BackupProtoFilePointer) { + proto.wallpaper = valueParam.proto + } public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields @@ -3125,13 +3076,15 @@ extension BackupProtoChatBuilder { @objc public enum BackupProtoDistributionListPrivacyMode: Int32 { - case onlyWith = 0 - case allExcept = 1 - case all = 2 + case unknown = 0 + case onlyWith = 1 + case allExcept = 2 + case all = 3 } private func BackupProtoDistributionListPrivacyModeWrap(_ value: BackupProtos_DistributionList.PrivacyMode) -> BackupProtoDistributionListPrivacyMode { switch value { + case .unknown: return .unknown case .onlyWith: return .onlyWith case .allExcept: return .allExcept case .all: return .all @@ -3140,6 +3093,7 @@ private func BackupProtoDistributionListPrivacyModeWrap(_ value: BackupProtos_Di private func BackupProtoDistributionListPrivacyModeUnwrap(_ value: BackupProtoDistributionListPrivacyMode) -> BackupProtos_DistributionList.PrivacyMode { switch value { + case .unknown: return .unknown case .onlyWith: return .onlyWith case .allExcept: return .allExcept case .all: return .all @@ -3165,9 +3119,6 @@ public class BackupProtoDistributionList: NSObject, Codable, NSSecureCoding { @objc public let deletionTimestamp: UInt64 - @objc - public let isUnknown: Bool - public var privacyMode: BackupProtoDistributionListPrivacyMode? { guard hasPrivacyMode else { return nil @@ -3205,14 +3156,12 @@ public class BackupProtoDistributionList: NSObject, Codable, NSSecureCoding { name: String, distributionID: Data, allowReplies: Bool, - deletionTimestamp: UInt64, - isUnknown: Bool) { + deletionTimestamp: UInt64) { self.proto = proto self.name = name self.distributionID = distributionID self.allowReplies = allowReplies self.deletionTimestamp = deletionTimestamp - self.isUnknown = isUnknown } @objc @@ -3247,17 +3196,11 @@ public class BackupProtoDistributionList: NSObject, Codable, NSSecureCoding { } let deletionTimestamp = proto.deletionTimestamp - guard proto.hasIsUnknown else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: isUnknown") - } - let isUnknown = proto.isUnknown - self.init(proto: proto, name: name, distributionID: distributionID, allowReplies: allowReplies, - deletionTimestamp: deletionTimestamp, - isUnknown: isUnknown) + deletionTimestamp: deletionTimestamp) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -3298,14 +3241,14 @@ public class BackupProtoDistributionList: NSObject, Codable, NSSecureCoding { extension BackupProtoDistributionList { @objc - public static func builder(name: String, distributionID: Data, allowReplies: Bool, deletionTimestamp: UInt64, isUnknown: Bool) -> BackupProtoDistributionListBuilder { - return BackupProtoDistributionListBuilder(name: name, distributionID: distributionID, allowReplies: allowReplies, deletionTimestamp: deletionTimestamp, isUnknown: isUnknown) + public static func builder(name: String, distributionID: Data, allowReplies: Bool, deletionTimestamp: UInt64) -> BackupProtoDistributionListBuilder { + return BackupProtoDistributionListBuilder(name: name, distributionID: distributionID, allowReplies: allowReplies, deletionTimestamp: deletionTimestamp) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoDistributionListBuilder { - let builder = BackupProtoDistributionListBuilder(name: name, distributionID: distributionID, allowReplies: allowReplies, deletionTimestamp: deletionTimestamp, isUnknown: isUnknown) + let builder = BackupProtoDistributionListBuilder(name: name, distributionID: distributionID, allowReplies: allowReplies, deletionTimestamp: deletionTimestamp) if let _value = privacyMode { builder.setPrivacyMode(_value) } @@ -3326,14 +3269,13 @@ public class BackupProtoDistributionListBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(name: String, distributionID: Data, allowReplies: Bool, deletionTimestamp: UInt64, isUnknown: Bool) { + fileprivate init(name: String, distributionID: Data, allowReplies: Bool, deletionTimestamp: UInt64) { super.init() setName(name) setDistributionID(distributionID) setAllowReplies(allowReplies) setDeletionTimestamp(deletionTimestamp) - setIsUnknown(isUnknown) } @objc @@ -3368,11 +3310,6 @@ public class BackupProtoDistributionListBuilder: NSObject { proto.deletionTimestamp = valueParam } - @objc - public func setIsUnknown(_ valueParam: Bool) { - proto.isUnknown = valueParam - } - @objc public func setPrivacyMode(_ valueParam: BackupProtoDistributionListPrivacyMode) { proto.privacyMode = BackupProtoDistributionListPrivacyModeUnwrap(valueParam) @@ -3673,14 +3610,16 @@ extension BackupProtoIdentityBuilder { @objc public enum BackupProtoCallType: Int32 { - case audioCall = 0 - case videoCall = 1 - case groupCall = 2 - case adHocCall = 3 + case unknownType = 0 + case audioCall = 1 + case videoCall = 2 + case groupCall = 3 + case adHocCall = 4 } private func BackupProtoCallTypeWrap(_ value: BackupProtos_Call.TypeEnum) -> BackupProtoCallType { switch value { + case .unknownType: return .unknownType case .audioCall: return .audioCall case .videoCall: return .videoCall case .groupCall: return .groupCall @@ -3690,6 +3629,7 @@ private func BackupProtoCallTypeWrap(_ value: BackupProtos_Call.TypeEnum) -> Bac private func BackupProtoCallTypeUnwrap(_ value: BackupProtoCallType) -> BackupProtos_Call.TypeEnum { switch value { + case .unknownType: return .unknownType case .audioCall: return .audioCall case .videoCall: return .videoCall case .groupCall: return .groupCall @@ -3701,20 +3641,21 @@ private func BackupProtoCallTypeUnwrap(_ value: BackupProtoCallType) -> BackupPr @objc public enum BackupProtoCallEvent: Int32 { - case outgoing = 0 - case accepted = 1 - case notAccepted = 2 - case missed = 3 - case delete = 4 - case genericGroupCall = 5 - case joined = 6 - case ringing = 7 + case unknownEvent = 0 + case outgoing = 1 + case accepted = 2 + case notAccepted = 3 + case missed = 4 + case delete = 5 + case genericGroupCall = 6 + case joined = 7 case declined = 8 case outgoingRing = 9 } private func BackupProtoCallEventWrap(_ value: BackupProtos_Call.Event) -> BackupProtoCallEvent { switch value { + case .unknownEvent: return .unknownEvent case .outgoing: return .outgoing case .accepted: return .accepted case .notAccepted: return .notAccepted @@ -3722,7 +3663,6 @@ private func BackupProtoCallEventWrap(_ value: BackupProtos_Call.Event) -> Backu case .delete: return .delete case .genericGroupCall: return .genericGroupCall case .joined: return .joined - case .ringing: return .ringing case .declined: return .declined case .outgoingRing: return .outgoingRing } @@ -3730,6 +3670,7 @@ private func BackupProtoCallEventWrap(_ value: BackupProtos_Call.Event) -> Backu private func BackupProtoCallEventUnwrap(_ value: BackupProtoCallEvent) -> BackupProtos_Call.Event { switch value { + case .unknownEvent: return .unknownEvent case .outgoing: return .outgoing case .accepted: return .accepted case .notAccepted: return .notAccepted @@ -3737,7 +3678,6 @@ private func BackupProtoCallEventUnwrap(_ value: BackupProtoCallEvent) -> Backup case .delete: return .delete case .genericGroupCall: return .genericGroupCall case .joined: return .joined - case .ringing: return .ringing case .declined: return .declined case .outgoingRing: return .outgoingRing } @@ -3754,7 +3694,7 @@ public class BackupProtoCall: NSObject, Codable, NSSecureCoding { public let callID: UInt64 @objc - public let peerRecipientID: UInt64 + public let conversationRecipientID: UInt64 @objc public let outgoing: Bool @@ -3815,13 +3755,13 @@ public class BackupProtoCall: NSObject, Codable, NSSecureCoding { private init(proto: BackupProtos_Call, callID: UInt64, - peerRecipientID: UInt64, + conversationRecipientID: UInt64, outgoing: Bool, timestamp: UInt64, ringerRecipientID: UInt64) { self.proto = proto self.callID = callID - self.peerRecipientID = peerRecipientID + self.conversationRecipientID = conversationRecipientID self.outgoing = outgoing self.timestamp = timestamp self.ringerRecipientID = ringerRecipientID @@ -3844,10 +3784,10 @@ public class BackupProtoCall: NSObject, Codable, NSSecureCoding { } let callID = proto.callID - guard proto.hasPeerRecipientID else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: peerRecipientID") + guard proto.hasConversationRecipientID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: conversationRecipientID") } - let peerRecipientID = proto.peerRecipientID + let conversationRecipientID = proto.conversationRecipientID guard proto.hasOutgoing else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: outgoing") @@ -3866,7 +3806,7 @@ public class BackupProtoCall: NSObject, Codable, NSSecureCoding { self.init(proto: proto, callID: callID, - peerRecipientID: peerRecipientID, + conversationRecipientID: conversationRecipientID, outgoing: outgoing, timestamp: timestamp, ringerRecipientID: ringerRecipientID) @@ -3910,14 +3850,14 @@ public class BackupProtoCall: NSObject, Codable, NSSecureCoding { extension BackupProtoCall { @objc - public static func builder(callID: UInt64, peerRecipientID: UInt64, outgoing: Bool, timestamp: UInt64, ringerRecipientID: UInt64) -> BackupProtoCallBuilder { - return BackupProtoCallBuilder(callID: callID, peerRecipientID: peerRecipientID, outgoing: outgoing, timestamp: timestamp, ringerRecipientID: ringerRecipientID) + public static func builder(callID: UInt64, conversationRecipientID: UInt64, outgoing: Bool, timestamp: UInt64, ringerRecipientID: UInt64) -> BackupProtoCallBuilder { + return BackupProtoCallBuilder(callID: callID, conversationRecipientID: conversationRecipientID, outgoing: outgoing, timestamp: timestamp, ringerRecipientID: ringerRecipientID) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoCallBuilder { - let builder = BackupProtoCallBuilder(callID: callID, peerRecipientID: peerRecipientID, outgoing: outgoing, timestamp: timestamp, ringerRecipientID: ringerRecipientID) + let builder = BackupProtoCallBuilder(callID: callID, conversationRecipientID: conversationRecipientID, outgoing: outgoing, timestamp: timestamp, ringerRecipientID: ringerRecipientID) if let _value = type { builder.setType(_value) } @@ -3940,11 +3880,11 @@ public class BackupProtoCallBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(callID: UInt64, peerRecipientID: UInt64, outgoing: Bool, timestamp: UInt64, ringerRecipientID: UInt64) { + fileprivate init(callID: UInt64, conversationRecipientID: UInt64, outgoing: Bool, timestamp: UInt64, ringerRecipientID: UInt64) { super.init() setCallID(callID) - setPeerRecipientID(peerRecipientID) + setConversationRecipientID(conversationRecipientID) setOutgoing(outgoing) setTimestamp(timestamp) setRingerRecipientID(ringerRecipientID) @@ -3956,8 +3896,8 @@ public class BackupProtoCallBuilder: NSObject { } @objc - public func setPeerRecipientID(_ valueParam: UInt64) { - proto.peerRecipientID = valueParam + public func setConversationRecipientID(_ valueParam: UInt64) { + proto.conversationRecipientID = valueParam } @objc @@ -4025,6 +3965,9 @@ public class BackupProtoChatItemIncomingMessageDetails: NSObject, Codable, NSSec fileprivate let proto: BackupProtos_ChatItem.IncomingMessageDetails + @objc + public let dateReceived: UInt64 + @objc public let dateServerSent: UInt64 @@ -4043,10 +3986,12 @@ public class BackupProtoChatItemIncomingMessageDetails: NSObject, Codable, NSSec } private init(proto: BackupProtos_ChatItem.IncomingMessageDetails, + dateReceived: UInt64, dateServerSent: UInt64, read: Bool, sealedSender: Bool) { self.proto = proto + self.dateReceived = dateReceived self.dateServerSent = dateServerSent self.read = read self.sealedSender = sealedSender @@ -4064,6 +4009,11 @@ public class BackupProtoChatItemIncomingMessageDetails: NSObject, Codable, NSSec } fileprivate convenience init(_ proto: BackupProtos_ChatItem.IncomingMessageDetails) throws { + guard proto.hasDateReceived else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: dateReceived") + } + let dateReceived = proto.dateReceived + guard proto.hasDateServerSent else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: dateServerSent") } @@ -4080,6 +4030,7 @@ public class BackupProtoChatItemIncomingMessageDetails: NSObject, Codable, NSSec let sealedSender = proto.sealedSender self.init(proto: proto, + dateReceived: dateReceived, dateServerSent: dateServerSent, read: read, sealedSender: sealedSender) @@ -4123,14 +4074,14 @@ public class BackupProtoChatItemIncomingMessageDetails: NSObject, Codable, NSSec extension BackupProtoChatItemIncomingMessageDetails { @objc - public static func builder(dateServerSent: UInt64, read: Bool, sealedSender: Bool) -> BackupProtoChatItemIncomingMessageDetailsBuilder { - return BackupProtoChatItemIncomingMessageDetailsBuilder(dateServerSent: dateServerSent, read: read, sealedSender: sealedSender) + public static func builder(dateReceived: UInt64, dateServerSent: UInt64, read: Bool, sealedSender: Bool) -> BackupProtoChatItemIncomingMessageDetailsBuilder { + return BackupProtoChatItemIncomingMessageDetailsBuilder(dateReceived: dateReceived, dateServerSent: dateServerSent, read: read, sealedSender: sealedSender) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoChatItemIncomingMessageDetailsBuilder { - let builder = BackupProtoChatItemIncomingMessageDetailsBuilder(dateServerSent: dateServerSent, read: read, sealedSender: sealedSender) + let builder = BackupProtoChatItemIncomingMessageDetailsBuilder(dateReceived: dateReceived, dateServerSent: dateServerSent, read: read, sealedSender: sealedSender) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -4147,14 +4098,20 @@ public class BackupProtoChatItemIncomingMessageDetailsBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(dateServerSent: UInt64, read: Bool, sealedSender: Bool) { + fileprivate init(dateReceived: UInt64, dateServerSent: UInt64, read: Bool, sealedSender: Bool) { super.init() + setDateReceived(dateReceived) setDateServerSent(dateServerSent) setRead(read) setSealedSender(sealedSender) } + @objc + public func setDateReceived(_ valueParam: UInt64) { + proto.dateReceived = valueParam + } + @objc public func setDateServerSent(_ valueParam: UInt64) { proto.dateServerSent = valueParam @@ -4367,9 +4324,6 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { @objc public let dateSent: UInt64 - @objc - public let dateReceived: UInt64 - @objc public let revisions: [BackupProtoChatItem] @@ -4401,21 +4355,21 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { public let updateMessage: BackupProtoUpdateMessage? @objc - public var expireStart: UInt64 { - return proto.expireStart + public var expireStartMs: UInt64 { + return proto.expireStartMs } @objc - public var hasExpireStart: Bool { - return proto.hasExpireStart + public var hasExpireStartMs: Bool { + return proto.hasExpireStartMs } @objc - public var expiresIn: UInt64 { - return proto.expiresIn + public var expiresInMs: UInt64 { + return proto.expiresInMs } @objc - public var hasExpiresIn: Bool { - return proto.hasExpiresIn + public var hasExpiresInMs: Bool { + return proto.hasExpiresInMs } public var hasUnknownFields: Bool { @@ -4430,7 +4384,6 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { chatID: UInt64, authorID: UInt64, dateSent: UInt64, - dateReceived: UInt64, revisions: [BackupProtoChatItem], sms: Bool, incoming: BackupProtoChatItemIncomingMessageDetails?, @@ -4445,7 +4398,6 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { self.chatID = chatID self.authorID = authorID self.dateSent = dateSent - self.dateReceived = dateReceived self.revisions = revisions self.sms = sms self.incoming = incoming @@ -4485,11 +4437,6 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { } let dateSent = proto.dateSent - guard proto.hasDateReceived else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: dateReceived") - } - let dateReceived = proto.dateReceived - var revisions: [BackupProtoChatItem] = [] revisions = try proto.revisions.map { try BackupProtoChatItem($0) } @@ -4542,7 +4489,6 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { chatID: chatID, authorID: authorID, dateSent: dateSent, - dateReceived: dateReceived, revisions: revisions, sms: sms, incoming: incoming, @@ -4593,19 +4539,19 @@ public class BackupProtoChatItem: NSObject, Codable, NSSecureCoding { extension BackupProtoChatItem { @objc - public static func builder(chatID: UInt64, authorID: UInt64, dateSent: UInt64, dateReceived: UInt64, sms: Bool) -> BackupProtoChatItemBuilder { - return BackupProtoChatItemBuilder(chatID: chatID, authorID: authorID, dateSent: dateSent, dateReceived: dateReceived, sms: sms) + public static func builder(chatID: UInt64, authorID: UInt64, dateSent: UInt64, sms: Bool) -> BackupProtoChatItemBuilder { + return BackupProtoChatItemBuilder(chatID: chatID, authorID: authorID, dateSent: dateSent, sms: sms) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoChatItemBuilder { - let builder = BackupProtoChatItemBuilder(chatID: chatID, authorID: authorID, dateSent: dateSent, dateReceived: dateReceived, sms: sms) - if hasExpireStart { - builder.setExpireStart(expireStart) + let builder = BackupProtoChatItemBuilder(chatID: chatID, authorID: authorID, dateSent: dateSent, sms: sms) + if hasExpireStartMs { + builder.setExpireStartMs(expireStartMs) } - if hasExpiresIn { - builder.setExpiresIn(expiresIn) + if hasExpiresInMs { + builder.setExpiresInMs(expiresInMs) } builder.setRevisions(revisions) if let _value = incoming { @@ -4648,13 +4594,12 @@ public class BackupProtoChatItemBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(chatID: UInt64, authorID: UInt64, dateSent: UInt64, dateReceived: UInt64, sms: Bool) { + fileprivate init(chatID: UInt64, authorID: UInt64, dateSent: UInt64, sms: Bool) { super.init() setChatID(chatID) setAuthorID(authorID) setDateSent(dateSent) - setDateReceived(dateReceived) setSms(sms) } @@ -4674,18 +4619,13 @@ public class BackupProtoChatItemBuilder: NSObject { } @objc - public func setDateReceived(_ valueParam: UInt64) { - proto.dateReceived = valueParam - } - - @objc - public func setExpireStart(_ valueParam: UInt64) { - proto.expireStart = valueParam + public func setExpireStartMs(_ valueParam: UInt64) { + proto.expireStartMs = valueParam } @objc - public func setExpiresIn(_ valueParam: UInt64) { - proto.expiresIn = valueParam + public func setExpiresInMs(_ valueParam: UInt64) { + proto.expiresInMs = valueParam } @objc @@ -4828,17 +4768,19 @@ extension BackupProtoChatItemBuilder { @objc public enum BackupProtoSendStatusStatus: Int32 { - case failed = 0 - case pending = 1 - case sent = 2 - case delivered = 3 - case read = 4 - case viewed = 5 - case skipped = 6 + case unknown = 0 + case failed = 1 + case pending = 2 + case sent = 3 + case delivered = 4 + case read = 5 + case viewed = 6 + case skipped = 7 } private func BackupProtoSendStatusStatusWrap(_ value: BackupProtos_SendStatus.Status) -> BackupProtoSendStatusStatus { switch value { + case .unknown: return .unknown case .failed: return .failed case .pending: return .pending case .sent: return .sent @@ -4851,6 +4793,7 @@ private func BackupProtoSendStatusStatusWrap(_ value: BackupProtos_SendStatus.St private func BackupProtoSendStatusStatusUnwrap(_ value: BackupProtoSendStatusStatus) -> BackupProtos_SendStatus.Status { switch value { + case .unknown: return .unknown case .failed: return .failed case .pending: return .pending case .sent: return .sent @@ -5299,13 +5242,13 @@ public class BackupProtoStandardMessage: NSObject, Codable, NSSecureCoding { public let text: BackupProtoText? @objc - public let attachments: [BackupProtoAttachmentPointer] + public let attachments: [BackupProtoFilePointer] @objc - public let linkPreview: BackupProtoLinkPreview? + public let linkPreview: [BackupProtoLinkPreview] @objc - public let longText: BackupProtoAttachmentPointer? + public let longText: BackupProtoFilePointer? @objc public let reactions: [BackupProtoReaction] @@ -5321,9 +5264,9 @@ public class BackupProtoStandardMessage: NSObject, Codable, NSSecureCoding { private init(proto: BackupProtos_StandardMessage, quote: BackupProtoQuote?, text: BackupProtoText?, - attachments: [BackupProtoAttachmentPointer], - linkPreview: BackupProtoLinkPreview?, - longText: BackupProtoAttachmentPointer?, + attachments: [BackupProtoFilePointer], + linkPreview: [BackupProtoLinkPreview], + longText: BackupProtoFilePointer?, reactions: [BackupProtoReaction]) { self.proto = proto self.quote = quote @@ -5348,7 +5291,7 @@ public class BackupProtoStandardMessage: NSObject, Codable, NSSecureCoding { fileprivate convenience init(_ proto: BackupProtos_StandardMessage) throws { var quote: BackupProtoQuote? if proto.hasQuote { - quote = BackupProtoQuote(proto.quote) + quote = try BackupProtoQuote(proto.quote) } var text: BackupProtoText? @@ -5356,17 +5299,15 @@ public class BackupProtoStandardMessage: NSObject, Codable, NSSecureCoding { text = try BackupProtoText(proto.text) } - var attachments: [BackupProtoAttachmentPointer] = [] - attachments = proto.attachments.map { BackupProtoAttachmentPointer($0) } + var attachments: [BackupProtoFilePointer] = [] + attachments = try proto.attachments.map { try BackupProtoFilePointer($0) } - var linkPreview: BackupProtoLinkPreview? - if proto.hasLinkPreview { - linkPreview = BackupProtoLinkPreview(proto.linkPreview) - } + var linkPreview: [BackupProtoLinkPreview] = [] + linkPreview = try proto.linkPreview.map { try BackupProtoLinkPreview($0) } - var longText: BackupProtoAttachmentPointer? + var longText: BackupProtoFilePointer? if proto.hasLongText { - longText = BackupProtoAttachmentPointer(proto.longText) + longText = try BackupProtoFilePointer(proto.longText) } var reactions: [BackupProtoReaction] = [] @@ -5434,9 +5375,7 @@ extension BackupProtoStandardMessage { builder.setText(_value) } builder.setAttachments(attachments) - if let _value = linkPreview { - builder.setLinkPreview(_value) - } + builder.setLinkPreview(linkPreview) if let _value = longText { builder.setLongText(_value) } @@ -5479,34 +5418,33 @@ public class BackupProtoStandardMessageBuilder: NSObject { } @objc - public func addAttachments(_ valueParam: BackupProtoAttachmentPointer) { + public func addAttachments(_ valueParam: BackupProtoFilePointer) { proto.attachments.append(valueParam.proto) } @objc - public func setAttachments(_ wrappedItems: [BackupProtoAttachmentPointer]) { + public func setAttachments(_ wrappedItems: [BackupProtoFilePointer]) { proto.attachments = wrappedItems.map { $0.proto } } @objc - @available(swift, obsoleted: 1.0) - public func setLinkPreview(_ valueParam: BackupProtoLinkPreview?) { - guard let valueParam = valueParam else { return } - proto.linkPreview = valueParam.proto + public func addLinkPreview(_ valueParam: BackupProtoLinkPreview) { + proto.linkPreview.append(valueParam.proto) } - public func setLinkPreview(_ valueParam: BackupProtoLinkPreview) { - proto.linkPreview = valueParam.proto + @objc + public func setLinkPreview(_ wrappedItems: [BackupProtoLinkPreview]) { + proto.linkPreview = wrappedItems.map { $0.proto } } @objc @available(swift, obsoleted: 1.0) - public func setLongText(_ valueParam: BackupProtoAttachmentPointer?) { + public func setLongText(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.longText = valueParam.proto } - public func setLongText(_ valueParam: BackupProtoAttachmentPointer) { + public func setLongText(_ valueParam: BackupProtoFilePointer) { proto.longText = valueParam.proto } @@ -5595,7 +5533,7 @@ public class BackupProtoContactMessage: NSObject, Codable, NSSecureCoding { fileprivate convenience init(_ proto: BackupProtos_ContactMessage) throws { var contact: [BackupProtoContactAttachment] = [] - contact = proto.contact.map { BackupProtoContactAttachment($0) } + contact = try proto.contact.map { try BackupProtoContactAttachment($0) } var reactions: [BackupProtoReaction] = [] reactions = try proto.reactions.map { try BackupProtoReaction($0) } @@ -6014,14 +5952,16 @@ extension BackupProtoContactAttachmentNameBuilder { @objc public enum BackupProtoContactAttachmentPhoneType: Int32 { - case home = 0 - case mobile = 1 - case work = 2 - case custom = 3 + case unknown = 0 + case home = 1 + case mobile = 2 + case work = 3 + case custom = 4 } private func BackupProtoContactAttachmentPhoneTypeWrap(_ value: BackupProtos_ContactAttachment.Phone.TypeEnum) -> BackupProtoContactAttachmentPhoneType { switch value { + case .unknown: return .unknown case .home: return .home case .mobile: return .mobile case .work: return .work @@ -6031,6 +5971,7 @@ private func BackupProtoContactAttachmentPhoneTypeWrap(_ value: BackupProtos_Con private func BackupProtoContactAttachmentPhoneTypeUnwrap(_ value: BackupProtoContactAttachmentPhoneType) -> BackupProtos_ContactAttachment.Phone.TypeEnum { switch value { + case .unknown: return .unknown case .home: return .home case .mobile: return .mobile case .work: return .work @@ -6255,14 +6196,16 @@ extension BackupProtoContactAttachmentPhoneBuilder { @objc public enum BackupProtoContactAttachmentEmailType: Int32 { - case home = 0 - case mobile = 1 - case work = 2 - case custom = 3 + case unknown = 0 + case home = 1 + case mobile = 2 + case work = 3 + case custom = 4 } private func BackupProtoContactAttachmentEmailTypeWrap(_ value: BackupProtos_ContactAttachment.Email.TypeEnum) -> BackupProtoContactAttachmentEmailType { switch value { + case .unknown: return .unknown case .home: return .home case .mobile: return .mobile case .work: return .work @@ -6272,6 +6215,7 @@ private func BackupProtoContactAttachmentEmailTypeWrap(_ value: BackupProtos_Con private func BackupProtoContactAttachmentEmailTypeUnwrap(_ value: BackupProtoContactAttachmentEmailType) -> BackupProtos_ContactAttachment.Email.TypeEnum { switch value { + case .unknown: return .unknown case .home: return .home case .mobile: return .mobile case .work: return .work @@ -6496,13 +6440,15 @@ extension BackupProtoContactAttachmentEmailBuilder { @objc public enum BackupProtoContactAttachmentPostalAddressType: Int32 { - case home = 0 - case work = 1 - case custom = 2 + case unknown = 0 + case home = 1 + case work = 2 + case custom = 3 } private func BackupProtoContactAttachmentPostalAddressTypeWrap(_ value: BackupProtos_ContactAttachment.PostalAddress.TypeEnum) -> BackupProtoContactAttachmentPostalAddressType { switch value { + case .unknown: return .unknown case .home: return .home case .work: return .work case .custom: return .custom @@ -6511,6 +6457,7 @@ private func BackupProtoContactAttachmentPostalAddressTypeWrap(_ value: BackupPr private func BackupProtoContactAttachmentPostalAddressTypeUnwrap(_ value: BackupProtoContactAttachmentPostalAddressType) -> BackupProtos_ContactAttachment.PostalAddress.TypeEnum { switch value { + case .unknown: return .unknown case .home: return .home case .work: return .work case .custom: return .custom @@ -6894,16 +6841,7 @@ public class BackupProtoContactAttachmentAvatar: NSObject, Codable, NSSecureCodi fileprivate let proto: BackupProtos_ContactAttachment.Avatar @objc - public let avatar: BackupProtoAttachmentPointer? - - @objc - public var isProfile: Bool { - return proto.isProfile - } - @objc - public var hasIsProfile: Bool { - return proto.hasIsProfile - } + public let avatar: BackupProtoFilePointer public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty @@ -6914,7 +6852,7 @@ public class BackupProtoContactAttachmentAvatar: NSObject, Codable, NSSecureCodi } private init(proto: BackupProtos_ContactAttachment.Avatar, - avatar: BackupProtoAttachmentPointer?) { + avatar: BackupProtoFilePointer) { self.proto = proto self.avatar = avatar } @@ -6927,14 +6865,14 @@ public class BackupProtoContactAttachmentAvatar: NSObject, Codable, NSSecureCodi @objc public convenience init(serializedData: Data) throws { let proto = try BackupProtos_ContactAttachment.Avatar(serializedData: serializedData) - self.init(proto) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_ContactAttachment.Avatar) { - var avatar: BackupProtoAttachmentPointer? - if proto.hasAvatar { - avatar = BackupProtoAttachmentPointer(proto.avatar) + fileprivate convenience init(_ proto: BackupProtos_ContactAttachment.Avatar) throws { + guard proto.hasAvatar else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: avatar") } + let avatar = try BackupProtoFilePointer(proto.avatar) self.init(proto: proto, avatar: avatar) @@ -6978,20 +6916,14 @@ public class BackupProtoContactAttachmentAvatar: NSObject, Codable, NSSecureCodi extension BackupProtoContactAttachmentAvatar { @objc - public static func builder() -> BackupProtoContactAttachmentAvatarBuilder { - return BackupProtoContactAttachmentAvatarBuilder() + public static func builder(avatar: BackupProtoFilePointer) -> BackupProtoContactAttachmentAvatarBuilder { + return BackupProtoContactAttachmentAvatarBuilder(avatar: avatar) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoContactAttachmentAvatarBuilder { - let builder = BackupProtoContactAttachmentAvatarBuilder() - if let _value = avatar { - builder.setAvatar(_value) - } - if hasIsProfile { - builder.setIsProfile(isProfile) - } + let builder = BackupProtoContactAttachmentAvatarBuilder(avatar: avatar) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -7007,34 +6939,31 @@ public class BackupProtoContactAttachmentAvatarBuilder: NSObject { @objc fileprivate override init() {} + @objc + fileprivate init(avatar: BackupProtoFilePointer) { + super.init() + + setAvatar(avatar) + } + @objc @available(swift, obsoleted: 1.0) - public func setAvatar(_ valueParam: BackupProtoAttachmentPointer?) { + public func setAvatar(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.avatar = valueParam.proto } - public func setAvatar(_ valueParam: BackupProtoAttachmentPointer) { + public func setAvatar(_ valueParam: BackupProtoFilePointer) { proto.avatar = valueParam.proto } - @objc - public func setIsProfile(_ valueParam: Bool) { - proto.isProfile = valueParam - } - public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @objc public func build() throws -> BackupProtoContactAttachmentAvatar { - return BackupProtoContactAttachmentAvatar(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoContactAttachmentAvatar { - return BackupProtoContactAttachmentAvatar(proto) + return try BackupProtoContactAttachmentAvatar(proto) } @objc @@ -7055,7 +6984,7 @@ extension BackupProtoContactAttachmentAvatar { extension BackupProtoContactAttachmentAvatarBuilder { @objc public func buildIgnoringErrors() -> BackupProtoContactAttachmentAvatar? { - return self.buildInfallibly() + return try! self.build() } } @@ -7125,10 +7054,10 @@ public class BackupProtoContactAttachment: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { let proto = try BackupProtos_ContactAttachment(serializedData: serializedData) - self.init(proto) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_ContactAttachment) { + fileprivate convenience init(_ proto: BackupProtos_ContactAttachment) throws { var name: BackupProtoContactAttachmentName? if proto.hasName { name = BackupProtoContactAttachmentName(proto.name) @@ -7145,7 +7074,7 @@ public class BackupProtoContactAttachment: NSObject, Codable, NSSecureCoding { var avatar: BackupProtoContactAttachmentAvatar? if proto.hasAvatar { - avatar = BackupProtoContactAttachmentAvatar(proto.avatar) + avatar = try BackupProtoContactAttachmentAvatar(proto.avatar) } self.init(proto: proto, @@ -7298,12 +7227,7 @@ public class BackupProtoContactAttachmentBuilder: NSObject { @objc public func build() throws -> BackupProtoContactAttachment { - return BackupProtoContactAttachment(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoContactAttachment { - return BackupProtoContactAttachment(proto) + return try BackupProtoContactAttachment(proto) } @objc @@ -7324,7 +7248,7 @@ extension BackupProtoContactAttachment { extension BackupProtoContactAttachmentBuilder { @objc public func buildIgnoringErrors() -> BackupProtoContactAttachment? { - return self.buildInfallibly() + return try! self.build() } } @@ -7341,7 +7265,7 @@ public class BackupProtoDocumentMessage: NSObject, Codable, NSSecureCoding { public let text: BackupProtoText @objc - public let document: BackupProtoAttachmentPointer + public let document: BackupProtoFilePointer @objc public let reactions: [BackupProtoReaction] @@ -7356,7 +7280,7 @@ public class BackupProtoDocumentMessage: NSObject, Codable, NSSecureCoding { private init(proto: BackupProtos_DocumentMessage, text: BackupProtoText, - document: BackupProtoAttachmentPointer, + document: BackupProtoFilePointer, reactions: [BackupProtoReaction]) { self.proto = proto self.text = text @@ -7384,7 +7308,7 @@ public class BackupProtoDocumentMessage: NSObject, Codable, NSSecureCoding { guard proto.hasDocument else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: document") } - let document = BackupProtoAttachmentPointer(proto.document) + let document = try BackupProtoFilePointer(proto.document) var reactions: [BackupProtoReaction] = [] reactions = try proto.reactions.map { try BackupProtoReaction($0) } @@ -7433,7 +7357,7 @@ public class BackupProtoDocumentMessage: NSObject, Codable, NSSecureCoding { extension BackupProtoDocumentMessage { @objc - public static func builder(text: BackupProtoText, document: BackupProtoAttachmentPointer) -> BackupProtoDocumentMessageBuilder { + public static func builder(text: BackupProtoText, document: BackupProtoFilePointer) -> BackupProtoDocumentMessageBuilder { return BackupProtoDocumentMessageBuilder(text: text, document: document) } @@ -7458,7 +7382,7 @@ public class BackupProtoDocumentMessageBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(text: BackupProtoText, document: BackupProtoAttachmentPointer) { + fileprivate init(text: BackupProtoText, document: BackupProtoFilePointer) { super.init() setText(text) @@ -7478,12 +7402,12 @@ public class BackupProtoDocumentMessageBuilder: NSObject { @objc @available(swift, obsoleted: 1.0) - public func setDocument(_ valueParam: BackupProtoAttachmentPointer?) { + public func setDocument(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.document = valueParam.proto } - public func setDocument(_ valueParam: BackupProtoAttachmentPointer) { + public func setDocument(_ valueParam: BackupProtoFilePointer) { proto.document = valueParam.proto } @@ -7541,7 +7465,7 @@ public class BackupProtoVoiceMessage: NSObject, Codable, NSSecureCoding { public let quote: BackupProtoQuote? @objc - public let audio: BackupProtoAttachmentPointer + public let audio: BackupProtoFilePointer @objc public let reactions: [BackupProtoReaction] @@ -7556,7 +7480,7 @@ public class BackupProtoVoiceMessage: NSObject, Codable, NSSecureCoding { private init(proto: BackupProtos_VoiceMessage, quote: BackupProtoQuote?, - audio: BackupProtoAttachmentPointer, + audio: BackupProtoFilePointer, reactions: [BackupProtoReaction]) { self.proto = proto self.quote = quote @@ -7578,13 +7502,13 @@ public class BackupProtoVoiceMessage: NSObject, Codable, NSSecureCoding { fileprivate convenience init(_ proto: BackupProtos_VoiceMessage) throws { var quote: BackupProtoQuote? if proto.hasQuote { - quote = BackupProtoQuote(proto.quote) + quote = try BackupProtoQuote(proto.quote) } guard proto.hasAudio else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: audio") } - let audio = BackupProtoAttachmentPointer(proto.audio) + let audio = try BackupProtoFilePointer(proto.audio) var reactions: [BackupProtoReaction] = [] reactions = try proto.reactions.map { try BackupProtoReaction($0) } @@ -7633,7 +7557,7 @@ public class BackupProtoVoiceMessage: NSObject, Codable, NSSecureCoding { extension BackupProtoVoiceMessage { @objc - public static func builder(audio: BackupProtoAttachmentPointer) -> BackupProtoVoiceMessageBuilder { + public static func builder(audio: BackupProtoFilePointer) -> BackupProtoVoiceMessageBuilder { return BackupProtoVoiceMessageBuilder(audio: audio) } @@ -7661,7 +7585,7 @@ public class BackupProtoVoiceMessageBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(audio: BackupProtoAttachmentPointer) { + fileprivate init(audio: BackupProtoFilePointer) { super.init() setAudio(audio) @@ -7680,12 +7604,12 @@ public class BackupProtoVoiceMessageBuilder: NSObject { @objc @available(swift, obsoleted: 1.0) - public func setAudio(_ valueParam: BackupProtoAttachmentPointer?) { + public func setAudio(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.audio = valueParam.proto } - public func setAudio(_ valueParam: BackupProtoAttachmentPointer) { + public func setAudio(_ valueParam: BackupProtoFilePointer) { proto.audio = valueParam.proto } @@ -7776,7 +7700,7 @@ public class BackupProtoStickerMessage: NSObject, Codable, NSSecureCoding { guard proto.hasSticker else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: sticker") } - let sticker = BackupProtoSticker(proto.sticker) + let sticker = try BackupProtoSticker(proto.sticker) var reactions: [BackupProtoReaction] = [] reactions = try proto.reactions.map { try BackupProtoReaction($0) } @@ -8224,40 +8148,13 @@ public class BackupProtoSticker: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_Sticker @objc - public let data: BackupProtoAttachmentPointer? - - @objc - public var packID: Data? { - guard hasPackID else { - return nil - } - return proto.packID - } - @objc - public var hasPackID: Bool { - return proto.hasPackID - } + public let packID: Data @objc - public var packKey: Data? { - guard hasPackKey else { - return nil - } - return proto.packKey - } - @objc - public var hasPackKey: Bool { - return proto.hasPackKey - } + public let packKey: Data @objc - public var stickerID: UInt32 { - return proto.stickerID - } - @objc - public var hasStickerID: Bool { - return proto.hasStickerID - } + public let stickerID: UInt32 @objc public var emoji: String? { @@ -8280,9 +8177,13 @@ public class BackupProtoSticker: NSObject, Codable, NSSecureCoding { } private init(proto: BackupProtos_Sticker, - data: BackupProtoAttachmentPointer?) { + packID: Data, + packKey: Data, + stickerID: UInt32) { self.proto = proto - self.data = data + self.packID = packID + self.packKey = packKey + self.stickerID = stickerID } @objc @@ -8293,17 +8194,29 @@ public class BackupProtoSticker: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { let proto = try BackupProtos_Sticker(serializedData: serializedData) - self.init(proto) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_Sticker) { - var data: BackupProtoAttachmentPointer? - if proto.hasData { - data = BackupProtoAttachmentPointer(proto.data) + fileprivate convenience init(_ proto: BackupProtos_Sticker) throws { + guard proto.hasPackID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: packID") + } + let packID = proto.packID + + guard proto.hasPackKey else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: packKey") + } + let packKey = proto.packKey + + guard proto.hasStickerID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: stickerID") } + let stickerID = proto.stickerID self.init(proto: proto, - data: data) + packID: packID, + packKey: packKey, + stickerID: stickerID) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -8344,26 +8257,14 @@ public class BackupProtoSticker: NSObject, Codable, NSSecureCoding { extension BackupProtoSticker { @objc - public static func builder() -> BackupProtoStickerBuilder { - return BackupProtoStickerBuilder() + public static func builder(packID: Data, packKey: Data, stickerID: UInt32) -> BackupProtoStickerBuilder { + return BackupProtoStickerBuilder(packID: packID, packKey: packKey, stickerID: stickerID) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoStickerBuilder { - let builder = BackupProtoStickerBuilder() - if let _value = packID { - builder.setPackID(_value) - } - if let _value = packKey { - builder.setPackKey(_value) - } - if hasStickerID { - builder.setStickerID(stickerID) - } - if let _value = data { - builder.setData(_value) - } + let builder = BackupProtoStickerBuilder(packID: packID, packKey: packKey, stickerID: stickerID) if let _value = emoji { builder.setEmoji(_value) } @@ -8382,6 +8283,15 @@ public class BackupProtoStickerBuilder: NSObject { @objc fileprivate override init() {} + @objc + fileprivate init(packID: Data, packKey: Data, stickerID: UInt32) { + super.init() + + setPackID(packID) + setPackKey(packKey) + setStickerID(stickerID) + } + @objc @available(swift, obsoleted: 1.0) public func setPackID(_ valueParam: Data?) { @@ -8409,17 +8319,6 @@ public class BackupProtoStickerBuilder: NSObject { proto.stickerID = valueParam } - @objc - @available(swift, obsoleted: 1.0) - public func setData(_ valueParam: BackupProtoAttachmentPointer?) { - guard let valueParam = valueParam else { return } - proto.data = valueParam.proto - } - - public func setData(_ valueParam: BackupProtoAttachmentPointer) { - proto.data = valueParam.proto - } - @objc @available(swift, obsoleted: 1.0) public func setEmoji(_ valueParam: String?) { @@ -8437,12 +8336,7 @@ public class BackupProtoStickerBuilder: NSObject { @objc public func build() throws -> BackupProtoSticker { - return BackupProtoSticker(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoSticker { - return BackupProtoSticker(proto) + return try BackupProtoSticker(proto) } @objc @@ -8463,7 +8357,7 @@ extension BackupProtoSticker { extension BackupProtoStickerBuilder { @objc public func buildIgnoringErrors() -> BackupProtoSticker? { - return self.buildInfallibly() + return try! self.build() } } @@ -8477,19 +8371,10 @@ public class BackupProtoLinkPreview: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_LinkPreview @objc - public let image: BackupProtoAttachmentPointer? + public let url: String @objc - public var url: String? { - guard hasURL else { - return nil - } - return proto.url - } - @objc - public var hasURL: Bool { - return proto.hasURL - } + public let image: BackupProtoFilePointer? @objc public var title: String? { @@ -8532,10 +8417,585 @@ public class BackupProtoLinkPreview: NSObject, Codable, NSSecureCoding { return proto.unknownFields } - private init(proto: BackupProtos_LinkPreview, - image: BackupProtoAttachmentPointer?) { + private init(proto: BackupProtos_LinkPreview, + url: String, + image: BackupProtoFilePointer?) { + self.proto = proto + self.url = url + self.image = image + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc + public convenience init(serializedData: Data) throws { + let proto = try BackupProtos_LinkPreview(serializedData: serializedData) + try self.init(proto) + } + + fileprivate convenience init(_ proto: BackupProtos_LinkPreview) throws { + guard proto.hasURL else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: url") + } + let url = proto.url + + var image: BackupProtoFilePointer? + if proto.hasImage { + image = try BackupProtoFilePointer(proto.image) + } + + self.init(proto: proto, + url: url, + image: image) + } + + public required convenience init(from decoder: Swift.Decoder) throws { + let singleValueContainer = try decoder.singleValueContainer() + let serializedData = try singleValueContainer.decode(Data.self) + try self.init(serializedData: serializedData) + } + public func encode(to encoder: Swift.Encoder) throws { + var singleValueContainer = encoder.singleValueContainer() + try singleValueContainer.encode(try serializedData()) + } + + public static var supportsSecureCoding: Bool { true } + + public required convenience init?(coder: NSCoder) { + guard let serializedData = coder.decodeData() else { return nil } + do { + try self.init(serializedData: serializedData) + } catch { + owsFailDebug("Failed to decode serialized data \(error)") + return nil + } + } + + public func encode(with coder: NSCoder) { + do { + coder.encode(try serializedData()) + } catch { + owsFailDebug("Failed to encode serialized data \(error)") + } + } + + @objc + public override var debugDescription: String { + return "\(proto)" + } +} + +extension BackupProtoLinkPreview { + @objc + public static func builder(url: String) -> BackupProtoLinkPreviewBuilder { + return BackupProtoLinkPreviewBuilder(url: url) + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc + public func asBuilder() -> BackupProtoLinkPreviewBuilder { + let builder = BackupProtoLinkPreviewBuilder(url: url) + if let _value = title { + builder.setTitle(_value) + } + if let _value = image { + builder.setImage(_value) + } + if let _value = descriptionText { + builder.setDescriptionText(_value) + } + if hasDate { + builder.setDate(date) + } + if let _value = unknownFields { + builder.setUnknownFields(_value) + } + return builder + } +} + +@objc +public class BackupProtoLinkPreviewBuilder: NSObject { + + private var proto = BackupProtos_LinkPreview() + + @objc + fileprivate override init() {} + + @objc + fileprivate init(url: String) { + super.init() + + setUrl(url) + } + + @objc + @available(swift, obsoleted: 1.0) + public func setUrl(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.url = valueParam + } + + public func setUrl(_ valueParam: String) { + proto.url = valueParam + } + + @objc + @available(swift, obsoleted: 1.0) + public func setTitle(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.title = valueParam + } + + public func setTitle(_ valueParam: String) { + proto.title = valueParam + } + + @objc + @available(swift, obsoleted: 1.0) + public func setImage(_ valueParam: BackupProtoFilePointer?) { + guard let valueParam = valueParam else { return } + proto.image = valueParam.proto + } + + public func setImage(_ valueParam: BackupProtoFilePointer) { + proto.image = valueParam.proto + } + + @objc + @available(swift, obsoleted: 1.0) + public func setDescriptionText(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.descriptionText = valueParam + } + + public func setDescriptionText(_ valueParam: String) { + proto.descriptionText = valueParam + } + + @objc + public func setDate(_ valueParam: UInt64) { + proto.date = valueParam + } + + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { + proto.unknownFields = unknownFields + } + + @objc + public func build() throws -> BackupProtoLinkPreview { + return try BackupProtoLinkPreview(proto) + } + + @objc + public func buildSerializedData() throws -> Data { + return try BackupProtoLinkPreview(proto).serializedData() + } +} + +#if TESTABLE_BUILD + +extension BackupProtoLinkPreview { + @objc + public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() + } +} + +extension BackupProtoLinkPreviewBuilder { + @objc + public func buildIgnoringErrors() -> BackupProtoLinkPreview? { + return try! self.build() + } +} + +#endif + +// MARK: - BackupProtoFilePointerBackupLocator + +@objc +public class BackupProtoFilePointerBackupLocator: NSObject, Codable, NSSecureCoding { + + fileprivate let proto: BackupProtos_FilePointer.BackupLocator + + @objc + public let mediaName: String + + @objc + public let cdnNumber: UInt32 + + public var hasUnknownFields: Bool { + return !proto.unknownFields.data.isEmpty + } + public var unknownFields: SwiftProtobuf.UnknownStorage? { + guard hasUnknownFields else { return nil } + return proto.unknownFields + } + + private init(proto: BackupProtos_FilePointer.BackupLocator, + mediaName: String, + cdnNumber: UInt32) { + self.proto = proto + self.mediaName = mediaName + self.cdnNumber = cdnNumber + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc + public convenience init(serializedData: Data) throws { + let proto = try BackupProtos_FilePointer.BackupLocator(serializedData: serializedData) + try self.init(proto) + } + + fileprivate convenience init(_ proto: BackupProtos_FilePointer.BackupLocator) throws { + guard proto.hasMediaName else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: mediaName") + } + let mediaName = proto.mediaName + + guard proto.hasCdnNumber else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: cdnNumber") + } + let cdnNumber = proto.cdnNumber + + self.init(proto: proto, + mediaName: mediaName, + cdnNumber: cdnNumber) + } + + public required convenience init(from decoder: Swift.Decoder) throws { + let singleValueContainer = try decoder.singleValueContainer() + let serializedData = try singleValueContainer.decode(Data.self) + try self.init(serializedData: serializedData) + } + public func encode(to encoder: Swift.Encoder) throws { + var singleValueContainer = encoder.singleValueContainer() + try singleValueContainer.encode(try serializedData()) + } + + public static var supportsSecureCoding: Bool { true } + + public required convenience init?(coder: NSCoder) { + guard let serializedData = coder.decodeData() else { return nil } + do { + try self.init(serializedData: serializedData) + } catch { + owsFailDebug("Failed to decode serialized data \(error)") + return nil + } + } + + public func encode(with coder: NSCoder) { + do { + coder.encode(try serializedData()) + } catch { + owsFailDebug("Failed to encode serialized data \(error)") + } + } + + @objc + public override var debugDescription: String { + return "\(proto)" + } +} + +extension BackupProtoFilePointerBackupLocator { + @objc + public static func builder(mediaName: String, cdnNumber: UInt32) -> BackupProtoFilePointerBackupLocatorBuilder { + return BackupProtoFilePointerBackupLocatorBuilder(mediaName: mediaName, cdnNumber: cdnNumber) + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc + public func asBuilder() -> BackupProtoFilePointerBackupLocatorBuilder { + let builder = BackupProtoFilePointerBackupLocatorBuilder(mediaName: mediaName, cdnNumber: cdnNumber) + if let _value = unknownFields { + builder.setUnknownFields(_value) + } + return builder + } +} + +@objc +public class BackupProtoFilePointerBackupLocatorBuilder: NSObject { + + private var proto = BackupProtos_FilePointer.BackupLocator() + + @objc + fileprivate override init() {} + + @objc + fileprivate init(mediaName: String, cdnNumber: UInt32) { + super.init() + + setMediaName(mediaName) + setCdnNumber(cdnNumber) + } + + @objc + @available(swift, obsoleted: 1.0) + public func setMediaName(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.mediaName = valueParam + } + + public func setMediaName(_ valueParam: String) { + proto.mediaName = valueParam + } + + @objc + public func setCdnNumber(_ valueParam: UInt32) { + proto.cdnNumber = valueParam + } + + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { + proto.unknownFields = unknownFields + } + + @objc + public func build() throws -> BackupProtoFilePointerBackupLocator { + return try BackupProtoFilePointerBackupLocator(proto) + } + + @objc + public func buildSerializedData() throws -> Data { + return try BackupProtoFilePointerBackupLocator(proto).serializedData() + } +} + +#if TESTABLE_BUILD + +extension BackupProtoFilePointerBackupLocator { + @objc + public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() + } +} + +extension BackupProtoFilePointerBackupLocatorBuilder { + @objc + public func buildIgnoringErrors() -> BackupProtoFilePointerBackupLocator? { + return try! self.build() + } +} + +#endif + +// MARK: - BackupProtoFilePointerAttachmentLocator + +@objc +public class BackupProtoFilePointerAttachmentLocator: NSObject, Codable, NSSecureCoding { + + fileprivate let proto: BackupProtos_FilePointer.AttachmentLocator + + @objc + public let cdnKey: String + + @objc + public let cdnNumber: UInt32 + + @objc + public let uploadTimestamp: UInt64 + + public var hasUnknownFields: Bool { + return !proto.unknownFields.data.isEmpty + } + public var unknownFields: SwiftProtobuf.UnknownStorage? { + guard hasUnknownFields else { return nil } + return proto.unknownFields + } + + private init(proto: BackupProtos_FilePointer.AttachmentLocator, + cdnKey: String, + cdnNumber: UInt32, + uploadTimestamp: UInt64) { + self.proto = proto + self.cdnKey = cdnKey + self.cdnNumber = cdnNumber + self.uploadTimestamp = uploadTimestamp + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc + public convenience init(serializedData: Data) throws { + let proto = try BackupProtos_FilePointer.AttachmentLocator(serializedData: serializedData) + try self.init(proto) + } + + fileprivate convenience init(_ proto: BackupProtos_FilePointer.AttachmentLocator) throws { + guard proto.hasCdnKey else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: cdnKey") + } + let cdnKey = proto.cdnKey + + guard proto.hasCdnNumber else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: cdnNumber") + } + let cdnNumber = proto.cdnNumber + + guard proto.hasUploadTimestamp else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: uploadTimestamp") + } + let uploadTimestamp = proto.uploadTimestamp + + self.init(proto: proto, + cdnKey: cdnKey, + cdnNumber: cdnNumber, + uploadTimestamp: uploadTimestamp) + } + + public required convenience init(from decoder: Swift.Decoder) throws { + let singleValueContainer = try decoder.singleValueContainer() + let serializedData = try singleValueContainer.decode(Data.self) + try self.init(serializedData: serializedData) + } + public func encode(to encoder: Swift.Encoder) throws { + var singleValueContainer = encoder.singleValueContainer() + try singleValueContainer.encode(try serializedData()) + } + + public static var supportsSecureCoding: Bool { true } + + public required convenience init?(coder: NSCoder) { + guard let serializedData = coder.decodeData() else { return nil } + do { + try self.init(serializedData: serializedData) + } catch { + owsFailDebug("Failed to decode serialized data \(error)") + return nil + } + } + + public func encode(with coder: NSCoder) { + do { + coder.encode(try serializedData()) + } catch { + owsFailDebug("Failed to encode serialized data \(error)") + } + } + + @objc + public override var debugDescription: String { + return "\(proto)" + } +} + +extension BackupProtoFilePointerAttachmentLocator { + @objc + public static func builder(cdnKey: String, cdnNumber: UInt32, uploadTimestamp: UInt64) -> BackupProtoFilePointerAttachmentLocatorBuilder { + return BackupProtoFilePointerAttachmentLocatorBuilder(cdnKey: cdnKey, cdnNumber: cdnNumber, uploadTimestamp: uploadTimestamp) + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc + public func asBuilder() -> BackupProtoFilePointerAttachmentLocatorBuilder { + let builder = BackupProtoFilePointerAttachmentLocatorBuilder(cdnKey: cdnKey, cdnNumber: cdnNumber, uploadTimestamp: uploadTimestamp) + if let _value = unknownFields { + builder.setUnknownFields(_value) + } + return builder + } +} + +@objc +public class BackupProtoFilePointerAttachmentLocatorBuilder: NSObject { + + private var proto = BackupProtos_FilePointer.AttachmentLocator() + + @objc + fileprivate override init() {} + + @objc + fileprivate init(cdnKey: String, cdnNumber: UInt32, uploadTimestamp: UInt64) { + super.init() + + setCdnKey(cdnKey) + setCdnNumber(cdnNumber) + setUploadTimestamp(uploadTimestamp) + } + + @objc + @available(swift, obsoleted: 1.0) + public func setCdnKey(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.cdnKey = valueParam + } + + public func setCdnKey(_ valueParam: String) { + proto.cdnKey = valueParam + } + + @objc + public func setCdnNumber(_ valueParam: UInt32) { + proto.cdnNumber = valueParam + } + + @objc + public func setUploadTimestamp(_ valueParam: UInt64) { + proto.uploadTimestamp = valueParam + } + + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { + proto.unknownFields = unknownFields + } + + @objc + public func build() throws -> BackupProtoFilePointerAttachmentLocator { + return try BackupProtoFilePointerAttachmentLocator(proto) + } + + @objc + public func buildSerializedData() throws -> Data { + return try BackupProtoFilePointerAttachmentLocator(proto).serializedData() + } +} + +#if TESTABLE_BUILD + +extension BackupProtoFilePointerAttachmentLocator { + @objc + public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() + } +} + +extension BackupProtoFilePointerAttachmentLocatorBuilder { + @objc + public func buildIgnoringErrors() -> BackupProtoFilePointerAttachmentLocator? { + return try! self.build() + } +} + +#endif + +// MARK: - BackupProtoFilePointerLegacyAttachmentLocator + +@objc +public class BackupProtoFilePointerLegacyAttachmentLocator: NSObject, Codable, NSSecureCoding { + + fileprivate let proto: BackupProtos_FilePointer.LegacyAttachmentLocator + + public var hasUnknownFields: Bool { + return !proto.unknownFields.data.isEmpty + } + public var unknownFields: SwiftProtobuf.UnknownStorage? { + guard hasUnknownFields else { return nil } + return proto.unknownFields + } + + private init(proto: BackupProtos_FilePointer.LegacyAttachmentLocator) { self.proto = proto - self.image = image } @objc @@ -8545,18 +9005,12 @@ public class BackupProtoLinkPreview: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { - let proto = try BackupProtos_LinkPreview(serializedData: serializedData) + let proto = try BackupProtos_FilePointer.LegacyAttachmentLocator(serializedData: serializedData) self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_LinkPreview) { - var image: BackupProtoAttachmentPointer? - if proto.hasImage { - image = BackupProtoAttachmentPointer(proto.image) - } - - self.init(proto: proto, - image: image) + fileprivate convenience init(_ proto: BackupProtos_FilePointer.LegacyAttachmentLocator) { + self.init(proto: proto) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -8595,31 +9049,16 @@ public class BackupProtoLinkPreview: NSObject, Codable, NSSecureCoding { } } -extension BackupProtoLinkPreview { +extension BackupProtoFilePointerLegacyAttachmentLocator { @objc - public static func builder() -> BackupProtoLinkPreviewBuilder { - return BackupProtoLinkPreviewBuilder() + public static func builder() -> BackupProtoFilePointerLegacyAttachmentLocatorBuilder { + return BackupProtoFilePointerLegacyAttachmentLocatorBuilder() } // asBuilder() constructs a builder that reflects the proto's contents. @objc - public func asBuilder() -> BackupProtoLinkPreviewBuilder { - let builder = BackupProtoLinkPreviewBuilder() - if let _value = url { - builder.setUrl(_value) - } - if let _value = title { - builder.setTitle(_value) - } - if let _value = image { - builder.setImage(_value) - } - if let _value = descriptionText { - builder.setDescriptionText(_value) - } - if hasDate { - builder.setDate(date) - } + public func asBuilder() -> BackupProtoFilePointerLegacyAttachmentLocatorBuilder { + let builder = BackupProtoFilePointerLegacyAttachmentLocatorBuilder() if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -8628,110 +9067,61 @@ extension BackupProtoLinkPreview { } @objc -public class BackupProtoLinkPreviewBuilder: NSObject { +public class BackupProtoFilePointerLegacyAttachmentLocatorBuilder: NSObject { - private var proto = BackupProtos_LinkPreview() + private var proto = BackupProtos_FilePointer.LegacyAttachmentLocator() @objc fileprivate override init() {} - @objc - @available(swift, obsoleted: 1.0) - public func setUrl(_ valueParam: String?) { - guard let valueParam = valueParam else { return } - proto.url = valueParam - } - - public func setUrl(_ valueParam: String) { - proto.url = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setTitle(_ valueParam: String?) { - guard let valueParam = valueParam else { return } - proto.title = valueParam - } - - public func setTitle(_ valueParam: String) { - proto.title = valueParam - } - - @objc - @available(swift, obsoleted: 1.0) - public func setImage(_ valueParam: BackupProtoAttachmentPointer?) { - guard let valueParam = valueParam else { return } - proto.image = valueParam.proto - } - - public func setImage(_ valueParam: BackupProtoAttachmentPointer) { - proto.image = valueParam.proto - } - - @objc - @available(swift, obsoleted: 1.0) - public func setDescriptionText(_ valueParam: String?) { - guard let valueParam = valueParam else { return } - proto.descriptionText = valueParam - } - - public func setDescriptionText(_ valueParam: String) { - proto.descriptionText = valueParam - } - - @objc - public func setDate(_ valueParam: UInt64) { - proto.date = valueParam - } - public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @objc - public func build() throws -> BackupProtoLinkPreview { - return BackupProtoLinkPreview(proto) + public func build() throws -> BackupProtoFilePointerLegacyAttachmentLocator { + return BackupProtoFilePointerLegacyAttachmentLocator(proto) } @objc - public func buildInfallibly() -> BackupProtoLinkPreview { - return BackupProtoLinkPreview(proto) + public func buildInfallibly() -> BackupProtoFilePointerLegacyAttachmentLocator { + return BackupProtoFilePointerLegacyAttachmentLocator(proto) } @objc public func buildSerializedData() throws -> Data { - return try BackupProtoLinkPreview(proto).serializedData() + return try BackupProtoFilePointerLegacyAttachmentLocator(proto).serializedData() } } #if TESTABLE_BUILD -extension BackupProtoLinkPreview { +extension BackupProtoFilePointerLegacyAttachmentLocator { @objc public func serializedDataIgnoringErrors() -> Data? { return try! self.serializedData() } } -extension BackupProtoLinkPreviewBuilder { +extension BackupProtoFilePointerLegacyAttachmentLocatorBuilder { @objc - public func buildIgnoringErrors() -> BackupProtoLinkPreview? { + public func buildIgnoringErrors() -> BackupProtoFilePointerLegacyAttachmentLocator? { return self.buildInfallibly() } } #endif -// MARK: - BackupProtoAttachmentPointerFlags +// MARK: - BackupProtoFilePointerFlags @objc -public enum BackupProtoAttachmentPointerFlags: Int32 { +public enum BackupProtoFilePointerFlags: Int32 { case voiceMessage = 0 case borderless = 1 case gif = 2 } -private func BackupProtoAttachmentPointerFlagsWrap(_ value: BackupProtos_AttachmentPointer.Flags) -> BackupProtoAttachmentPointerFlags { +private func BackupProtoFilePointerFlagsWrap(_ value: BackupProtos_FilePointer.Flags) -> BackupProtoFilePointerFlags { switch value { case .voiceMessage: return .voiceMessage case .borderless: return .borderless @@ -8739,7 +9129,7 @@ private func BackupProtoAttachmentPointerFlagsWrap(_ value: BackupProtos_Attachm } } -private func BackupProtoAttachmentPointerFlagsUnwrap(_ value: BackupProtoAttachmentPointerFlags) -> BackupProtos_AttachmentPointer.Flags { +private func BackupProtoFilePointerFlagsUnwrap(_ value: BackupProtoFilePointerFlags) -> BackupProtos_FilePointer.Flags { switch value { case .voiceMessage: return .voiceMessage case .borderless: return .borderless @@ -8747,32 +9137,32 @@ private func BackupProtoAttachmentPointerFlagsUnwrap(_ value: BackupProtoAttachm } } -// MARK: - BackupProtoAttachmentPointer +// MARK: - BackupProtoFilePointer @objc -public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { +public class BackupProtoFilePointer: NSObject, Codable, NSSecureCoding { - fileprivate let proto: BackupProtos_AttachmentPointer + fileprivate let proto: BackupProtos_FilePointer @objc - public var cdnID: UInt64 { - return proto.cdnID - } + public let backupLocator: BackupProtoFilePointerBackupLocator? + @objc - public var hasCdnID: Bool { - return proto.hasCdnID - } + public let attachmentLocator: BackupProtoFilePointerAttachmentLocator? + + @objc + public let legacyAttachmentLocator: BackupProtoFilePointerLegacyAttachmentLocator? @objc - public var cdnKey: String? { - guard hasCdnKey else { + public var key: Data? { + guard hasKey else { return nil } - return proto.cdnKey + return proto.key } @objc - public var hasCdnKey: Bool { - return proto.hasCdnKey + public var hasKey: Bool { + return proto.hasKey } @objc @@ -8787,18 +9177,6 @@ public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { return proto.hasContentType } - @objc - public var key: Data? { - guard hasKey else { - return nil - } - return proto.key - } - @objc - public var hasKey: Bool { - return proto.hasKey - } - @objc public var size: UInt32 { return proto.size @@ -8907,24 +9285,6 @@ public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { return proto.hasBlurHash } - @objc - public var uploadTimestamp: UInt64 { - return proto.uploadTimestamp - } - @objc - public var hasUploadTimestamp: Bool { - return proto.hasUploadTimestamp - } - - @objc - public var cdnNumber: UInt32 { - return proto.cdnNumber - } - @objc - public var hasCdnNumber: Bool { - return proto.hasCdnNumber - } - public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty } @@ -8933,8 +9293,14 @@ public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { return proto.unknownFields } - private init(proto: BackupProtos_AttachmentPointer) { + private init(proto: BackupProtos_FilePointer, + backupLocator: BackupProtoFilePointerBackupLocator?, + attachmentLocator: BackupProtoFilePointerAttachmentLocator?, + legacyAttachmentLocator: BackupProtoFilePointerLegacyAttachmentLocator?) { self.proto = proto + self.backupLocator = backupLocator + self.attachmentLocator = attachmentLocator + self.legacyAttachmentLocator = legacyAttachmentLocator } @objc @@ -8944,12 +9310,30 @@ public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { - let proto = try BackupProtos_AttachmentPointer(serializedData: serializedData) - self.init(proto) + let proto = try BackupProtos_FilePointer(serializedData: serializedData) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_AttachmentPointer) { - self.init(proto: proto) + fileprivate convenience init(_ proto: BackupProtos_FilePointer) throws { + var backupLocator: BackupProtoFilePointerBackupLocator? + if proto.hasBackupLocator { + backupLocator = try BackupProtoFilePointerBackupLocator(proto.backupLocator) + } + + var attachmentLocator: BackupProtoFilePointerAttachmentLocator? + if proto.hasAttachmentLocator { + attachmentLocator = try BackupProtoFilePointerAttachmentLocator(proto.attachmentLocator) + } + + var legacyAttachmentLocator: BackupProtoFilePointerLegacyAttachmentLocator? + if proto.hasLegacyAttachmentLocator { + legacyAttachmentLocator = BackupProtoFilePointerLegacyAttachmentLocator(proto.legacyAttachmentLocator) + } + + self.init(proto: proto, + backupLocator: backupLocator, + attachmentLocator: attachmentLocator, + legacyAttachmentLocator: legacyAttachmentLocator) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -8988,28 +9372,31 @@ public class BackupProtoAttachmentPointer: NSObject, Codable, NSSecureCoding { } } -extension BackupProtoAttachmentPointer { +extension BackupProtoFilePointer { @objc - public static func builder() -> BackupProtoAttachmentPointerBuilder { - return BackupProtoAttachmentPointerBuilder() + public static func builder() -> BackupProtoFilePointerBuilder { + return BackupProtoFilePointerBuilder() } // asBuilder() constructs a builder that reflects the proto's contents. @objc - public func asBuilder() -> BackupProtoAttachmentPointerBuilder { - let builder = BackupProtoAttachmentPointerBuilder() - if hasCdnID { - builder.setCdnID(cdnID) + public func asBuilder() -> BackupProtoFilePointerBuilder { + let builder = BackupProtoFilePointerBuilder() + if let _value = backupLocator { + builder.setBackupLocator(_value) } - if let _value = cdnKey { - builder.setCdnKey(_value) + if let _value = attachmentLocator { + builder.setAttachmentLocator(_value) } - if let _value = contentType { - builder.setContentType(_value) + if let _value = legacyAttachmentLocator { + builder.setLegacyAttachmentLocator(_value) } if let _value = key { builder.setKey(_value) } + if let _value = contentType { + builder.setContentType(_value) + } if hasSize { builder.setSize(size) } @@ -9040,12 +9427,6 @@ extension BackupProtoAttachmentPointer { if let _value = blurHash { builder.setBlurHash(_value) } - if hasUploadTimestamp { - builder.setUploadTimestamp(uploadTimestamp) - } - if hasCdnNumber { - builder.setCdnNumber(cdnNumber) - } if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -9054,38 +9435,44 @@ extension BackupProtoAttachmentPointer { } @objc -public class BackupProtoAttachmentPointerBuilder: NSObject { +public class BackupProtoFilePointerBuilder: NSObject { - private var proto = BackupProtos_AttachmentPointer() + private var proto = BackupProtos_FilePointer() @objc fileprivate override init() {} @objc - public func setCdnID(_ valueParam: UInt64) { - proto.cdnID = valueParam + @available(swift, obsoleted: 1.0) + public func setBackupLocator(_ valueParam: BackupProtoFilePointerBackupLocator?) { + guard let valueParam = valueParam else { return } + proto.backupLocator = valueParam.proto + } + + public func setBackupLocator(_ valueParam: BackupProtoFilePointerBackupLocator) { + proto.backupLocator = valueParam.proto } @objc @available(swift, obsoleted: 1.0) - public func setCdnKey(_ valueParam: String?) { + public func setAttachmentLocator(_ valueParam: BackupProtoFilePointerAttachmentLocator?) { guard let valueParam = valueParam else { return } - proto.cdnKey = valueParam + proto.attachmentLocator = valueParam.proto } - public func setCdnKey(_ valueParam: String) { - proto.cdnKey = valueParam + public func setAttachmentLocator(_ valueParam: BackupProtoFilePointerAttachmentLocator) { + proto.attachmentLocator = valueParam.proto } @objc @available(swift, obsoleted: 1.0) - public func setContentType(_ valueParam: String?) { + public func setLegacyAttachmentLocator(_ valueParam: BackupProtoFilePointerLegacyAttachmentLocator?) { guard let valueParam = valueParam else { return } - proto.contentType = valueParam + proto.legacyAttachmentLocator = valueParam.proto } - public func setContentType(_ valueParam: String) { - proto.contentType = valueParam + public func setLegacyAttachmentLocator(_ valueParam: BackupProtoFilePointerLegacyAttachmentLocator) { + proto.legacyAttachmentLocator = valueParam.proto } @objc @@ -9099,6 +9486,17 @@ public class BackupProtoAttachmentPointerBuilder: NSObject { proto.key = valueParam } + @objc + @available(swift, obsoleted: 1.0) + public func setContentType(_ valueParam: String?) { + guard let valueParam = valueParam else { return } + proto.contentType = valueParam + } + + public func setContentType(_ valueParam: String) { + proto.contentType = valueParam + } + @objc public func setSize(_ valueParam: UInt32) { proto.size = valueParam @@ -9185,49 +9583,34 @@ public class BackupProtoAttachmentPointerBuilder: NSObject { proto.blurHash = valueParam } - @objc - public func setUploadTimestamp(_ valueParam: UInt64) { - proto.uploadTimestamp = valueParam - } - - @objc - public func setCdnNumber(_ valueParam: UInt32) { - proto.cdnNumber = valueParam - } - public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @objc - public func build() throws -> BackupProtoAttachmentPointer { - return BackupProtoAttachmentPointer(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoAttachmentPointer { - return BackupProtoAttachmentPointer(proto) + public func build() throws -> BackupProtoFilePointer { + return try BackupProtoFilePointer(proto) } @objc public func buildSerializedData() throws -> Data { - return try BackupProtoAttachmentPointer(proto).serializedData() + return try BackupProtoFilePointer(proto).serializedData() } } #if TESTABLE_BUILD -extension BackupProtoAttachmentPointer { +extension BackupProtoFilePointer { @objc public func serializedDataIgnoringErrors() -> Data? { return try! self.serializedData() } } -extension BackupProtoAttachmentPointerBuilder { +extension BackupProtoFilePointerBuilder { @objc - public func buildIgnoringErrors() -> BackupProtoAttachmentPointer? { - return self.buildInfallibly() + public func buildIgnoringErrors() -> BackupProtoFilePointer? { + return try! self.build() } } @@ -9241,7 +9624,7 @@ public class BackupProtoQuoteQuotedAttachment: NSObject, Codable, NSSecureCoding fileprivate let proto: BackupProtos_Quote.QuotedAttachment @objc - public let thumbnail: BackupProtoAttachmentPointer? + public let thumbnail: BackupProtoFilePointer? @objc public var contentType: String? { @@ -9276,7 +9659,7 @@ public class BackupProtoQuoteQuotedAttachment: NSObject, Codable, NSSecureCoding } private init(proto: BackupProtos_Quote.QuotedAttachment, - thumbnail: BackupProtoAttachmentPointer?) { + thumbnail: BackupProtoFilePointer?) { self.proto = proto self.thumbnail = thumbnail } @@ -9289,13 +9672,13 @@ public class BackupProtoQuoteQuotedAttachment: NSObject, Codable, NSSecureCoding @objc public convenience init(serializedData: Data) throws { let proto = try BackupProtos_Quote.QuotedAttachment(serializedData: serializedData) - self.init(proto) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_Quote.QuotedAttachment) { - var thumbnail: BackupProtoAttachmentPointer? + fileprivate convenience init(_ proto: BackupProtos_Quote.QuotedAttachment) throws { + var thumbnail: BackupProtoFilePointer? if proto.hasThumbnail { - thumbnail = BackupProtoAttachmentPointer(proto.thumbnail) + thumbnail = try BackupProtoFilePointer(proto.thumbnail) } self.init(proto: proto, @@ -9396,12 +9779,12 @@ public class BackupProtoQuoteQuotedAttachmentBuilder: NSObject { @objc @available(swift, obsoleted: 1.0) - public func setThumbnail(_ valueParam: BackupProtoAttachmentPointer?) { + public func setThumbnail(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.thumbnail = valueParam.proto } - public func setThumbnail(_ valueParam: BackupProtoAttachmentPointer) { + public func setThumbnail(_ valueParam: BackupProtoFilePointer) { proto.thumbnail = valueParam.proto } @@ -9411,12 +9794,7 @@ public class BackupProtoQuoteQuotedAttachmentBuilder: NSObject { @objc public func build() throws -> BackupProtoQuoteQuotedAttachment { - return BackupProtoQuoteQuotedAttachment(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoQuoteQuotedAttachment { - return BackupProtoQuoteQuotedAttachment(proto) + return try BackupProtoQuoteQuotedAttachment(proto) } @objc @@ -9437,7 +9815,7 @@ extension BackupProtoQuoteQuotedAttachment { extension BackupProtoQuoteQuotedAttachmentBuilder { @objc public func buildIgnoringErrors() -> BackupProtoQuoteQuotedAttachment? { - return self.buildInfallibly() + return try! self.build() } } @@ -9447,12 +9825,14 @@ extension BackupProtoQuoteQuotedAttachmentBuilder { @objc public enum BackupProtoQuoteType: Int32 { - case normal = 0 - case giftbadge = 1 + case unknown = 0 + case normal = 1 + case giftbadge = 2 } private func BackupProtoQuoteTypeWrap(_ value: BackupProtos_Quote.TypeEnum) -> BackupProtoQuoteType { switch value { + case .unknown: return .unknown case .normal: return .normal case .giftbadge: return .giftbadge } @@ -9460,6 +9840,7 @@ private func BackupProtoQuoteTypeWrap(_ value: BackupProtos_Quote.TypeEnum) -> B private func BackupProtoQuoteTypeUnwrap(_ value: BackupProtoQuoteType) -> BackupProtos_Quote.TypeEnum { switch value { + case .unknown: return .unknown case .normal: return .normal case .giftbadge: return .giftbadge } @@ -9473,27 +9854,21 @@ public class BackupProtoQuote: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_Quote @objc - public let attachments: [BackupProtoQuoteQuotedAttachment] + public let authorID: UInt64 @objc - public let bodyRanges: [BackupProtoBodyRange] + public let attachments: [BackupProtoQuoteQuotedAttachment] @objc - public var id: UInt64 { - return proto.id - } - @objc - public var hasID: Bool { - return proto.hasID - } + public let bodyRanges: [BackupProtoBodyRange] @objc - public var authorID: UInt64 { - return proto.authorID + public var targetSentTimestamp: UInt64 { + return proto.targetSentTimestamp } @objc - public var hasAuthorID: Bool { - return proto.hasAuthorID + public var hasTargetSentTimestamp: Bool { + return proto.hasTargetSentTimestamp } @objc @@ -9537,9 +9912,11 @@ public class BackupProtoQuote: NSObject, Codable, NSSecureCoding { } private init(proto: BackupProtos_Quote, + authorID: UInt64, attachments: [BackupProtoQuoteQuotedAttachment], bodyRanges: [BackupProtoBodyRange]) { self.proto = proto + self.authorID = authorID self.attachments = attachments self.bodyRanges = bodyRanges } @@ -9552,17 +9929,23 @@ public class BackupProtoQuote: NSObject, Codable, NSSecureCoding { @objc public convenience init(serializedData: Data) throws { let proto = try BackupProtos_Quote(serializedData: serializedData) - self.init(proto) + try self.init(proto) } - fileprivate convenience init(_ proto: BackupProtos_Quote) { + fileprivate convenience init(_ proto: BackupProtos_Quote) throws { + guard proto.hasAuthorID else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: authorID") + } + let authorID = proto.authorID + var attachments: [BackupProtoQuoteQuotedAttachment] = [] - attachments = proto.attachments.map { BackupProtoQuoteQuotedAttachment($0) } + attachments = try proto.attachments.map { try BackupProtoQuoteQuotedAttachment($0) } var bodyRanges: [BackupProtoBodyRange] = [] bodyRanges = proto.bodyRanges.map { BackupProtoBodyRange($0) } self.init(proto: proto, + authorID: authorID, attachments: attachments, bodyRanges: bodyRanges) } @@ -9605,19 +9988,16 @@ public class BackupProtoQuote: NSObject, Codable, NSSecureCoding { extension BackupProtoQuote { @objc - public static func builder() -> BackupProtoQuoteBuilder { - return BackupProtoQuoteBuilder() + public static func builder(authorID: UInt64) -> BackupProtoQuoteBuilder { + return BackupProtoQuoteBuilder(authorID: authorID) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoQuoteBuilder { - let builder = BackupProtoQuoteBuilder() - if hasID { - builder.setId(id) - } - if hasAuthorID { - builder.setAuthorID(authorID) + let builder = BackupProtoQuoteBuilder(authorID: authorID) + if hasTargetSentTimestamp { + builder.setTargetSentTimestamp(targetSentTimestamp) } if let _value = text { builder.setText(_value) @@ -9643,8 +10023,15 @@ public class BackupProtoQuoteBuilder: NSObject { fileprivate override init() {} @objc - public func setId(_ valueParam: UInt64) { - proto.id = valueParam + fileprivate init(authorID: UInt64) { + super.init() + + setAuthorID(authorID) + } + + @objc + public func setTargetSentTimestamp(_ valueParam: UInt64) { + proto.targetSentTimestamp = valueParam } @objc @@ -9694,12 +10081,7 @@ public class BackupProtoQuoteBuilder: NSObject { @objc public func build() throws -> BackupProtoQuote { - return BackupProtoQuote(proto) - } - - @objc - public func buildInfallibly() -> BackupProtoQuote { - return BackupProtoQuote(proto) + return try BackupProtoQuote(proto) } @objc @@ -9720,7 +10102,7 @@ extension BackupProtoQuote { extension BackupProtoQuoteBuilder { @objc public func buildIgnoringErrors() -> BackupProtoQuote? { - return self.buildInfallibly() + return try! self.build() } } @@ -9786,7 +10168,7 @@ public class BackupProtoBodyRange: NSObject, Codable, NSSecureCoding { } @objc - public var mentionAci: String? { + public var mentionAci: Data? { guard hasMentionAci else { return nil } @@ -9929,12 +10311,12 @@ public class BackupProtoBodyRangeBuilder: NSObject { @objc @available(swift, obsoleted: 1.0) - public func setMentionAci(_ valueParam: String?) { + public func setMentionAci(_ valueParam: Data?) { guard let valueParam = valueParam else { return } proto.mentionAci = valueParam } - public func setMentionAci(_ valueParam: String) { + public func setMentionAci(_ valueParam: Data) { proto.mentionAci = valueParam } @@ -10691,16 +11073,18 @@ extension BackupProtoCallingMessageBuilder { @objc public enum BackupProtoCallMessageType: Int32 { - case incomingAudioCall = 0 - case incomingVideoCall = 1 - case outgoingAudioCall = 2 - case outgoingVideoCall = 3 - case missedAudioCall = 4 - case missedVideoCall = 5 + case unknown = 0 + case incomingAudioCall = 1 + case incomingVideoCall = 2 + case outgoingAudioCall = 3 + case outgoingVideoCall = 4 + case missedAudioCall = 5 + case missedVideoCall = 6 } private func BackupProtoCallMessageTypeWrap(_ value: BackupProtos_CallMessage.TypeEnum) -> BackupProtoCallMessageType { switch value { + case .unknown: return .unknown case .incomingAudioCall: return .incomingAudioCall case .incomingVideoCall: return .incomingVideoCall case .outgoingAudioCall: return .outgoingAudioCall @@ -10712,6 +11096,7 @@ private func BackupProtoCallMessageTypeWrap(_ value: BackupProtos_CallMessage.Ty private func BackupProtoCallMessageTypeUnwrap(_ value: BackupProtoCallMessageType) -> BackupProtos_CallMessage.TypeEnum { switch value { + case .unknown: return .unknown case .incomingAudioCall: return .incomingAudioCall case .incomingVideoCall: return .incomingVideoCall case .outgoingAudioCall: return .outgoingAudioCall @@ -10862,17 +11247,14 @@ public class BackupProtoGroupCallMessage: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_GroupCallMessage @objc - public let startedCallUuid: Data + public let startedCallAci: Data @objc public let startedCallTimestamp: UInt64 @objc - public let isCallFull: Bool - - @objc - public var inCallUuids: [Data] { - return proto.inCallUuids + public var inCallAcis: [Data] { + return proto.inCallAcis } public var hasUnknownFields: Bool { @@ -10884,13 +11266,11 @@ public class BackupProtoGroupCallMessage: NSObject, Codable, NSSecureCoding { } private init(proto: BackupProtos_GroupCallMessage, - startedCallUuid: Data, - startedCallTimestamp: UInt64, - isCallFull: Bool) { + startedCallAci: Data, + startedCallTimestamp: UInt64) { self.proto = proto - self.startedCallUuid = startedCallUuid + self.startedCallAci = startedCallAci self.startedCallTimestamp = startedCallTimestamp - self.isCallFull = isCallFull } @objc @@ -10905,25 +11285,19 @@ public class BackupProtoGroupCallMessage: NSObject, Codable, NSSecureCoding { } fileprivate convenience init(_ proto: BackupProtos_GroupCallMessage) throws { - guard proto.hasStartedCallUuid else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: startedCallUuid") + guard proto.hasStartedCallAci else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: startedCallAci") } - let startedCallUuid = proto.startedCallUuid + let startedCallAci = proto.startedCallAci guard proto.hasStartedCallTimestamp else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: startedCallTimestamp") } let startedCallTimestamp = proto.startedCallTimestamp - guard proto.hasIsCallFull else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: isCallFull") - } - let isCallFull = proto.isCallFull - self.init(proto: proto, - startedCallUuid: startedCallUuid, - startedCallTimestamp: startedCallTimestamp, - isCallFull: isCallFull) + startedCallAci: startedCallAci, + startedCallTimestamp: startedCallTimestamp) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -10964,15 +11338,15 @@ public class BackupProtoGroupCallMessage: NSObject, Codable, NSSecureCoding { extension BackupProtoGroupCallMessage { @objc - public static func builder(startedCallUuid: Data, startedCallTimestamp: UInt64, isCallFull: Bool) -> BackupProtoGroupCallMessageBuilder { - return BackupProtoGroupCallMessageBuilder(startedCallUuid: startedCallUuid, startedCallTimestamp: startedCallTimestamp, isCallFull: isCallFull) + public static func builder(startedCallAci: Data, startedCallTimestamp: UInt64) -> BackupProtoGroupCallMessageBuilder { + return BackupProtoGroupCallMessageBuilder(startedCallAci: startedCallAci, startedCallTimestamp: startedCallTimestamp) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoGroupCallMessageBuilder { - let builder = BackupProtoGroupCallMessageBuilder(startedCallUuid: startedCallUuid, startedCallTimestamp: startedCallTimestamp, isCallFull: isCallFull) - builder.setInCallUuids(inCallUuids) + let builder = BackupProtoGroupCallMessageBuilder(startedCallAci: startedCallAci, startedCallTimestamp: startedCallTimestamp) + builder.setInCallAcis(inCallAcis) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -10989,23 +11363,22 @@ public class BackupProtoGroupCallMessageBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(startedCallUuid: Data, startedCallTimestamp: UInt64, isCallFull: Bool) { + fileprivate init(startedCallAci: Data, startedCallTimestamp: UInt64) { super.init() - setStartedCallUuid(startedCallUuid) + setStartedCallAci(startedCallAci) setStartedCallTimestamp(startedCallTimestamp) - setIsCallFull(isCallFull) } @objc @available(swift, obsoleted: 1.0) - public func setStartedCallUuid(_ valueParam: Data?) { + public func setStartedCallAci(_ valueParam: Data?) { guard let valueParam = valueParam else { return } - proto.startedCallUuid = valueParam + proto.startedCallAci = valueParam } - public func setStartedCallUuid(_ valueParam: Data) { - proto.startedCallUuid = valueParam + public func setStartedCallAci(_ valueParam: Data) { + proto.startedCallAci = valueParam } @objc @@ -11014,18 +11387,13 @@ public class BackupProtoGroupCallMessageBuilder: NSObject { } @objc - public func addInCallUuids(_ valueParam: Data) { - proto.inCallUuids.append(valueParam) - } - - @objc - public func setInCallUuids(_ wrappedItems: [Data]) { - proto.inCallUuids = wrappedItems + public func addInCallAcis(_ valueParam: Data) { + proto.inCallAcis.append(valueParam) } @objc - public func setIsCallFull(_ valueParam: Bool) { - proto.isCallFull = valueParam + public func setInCallAcis(_ wrappedItems: [Data]) { + proto.inCallAcis = wrappedItems } public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { @@ -11065,21 +11433,23 @@ extension BackupProtoGroupCallMessageBuilder { @objc public enum BackupProtoSimpleUpdateType: Int32 { - case joinedSignal = 0 - case identityUpdate = 1 - case identityVerified = 2 - case identityDefault = 3 - case changeNumber = 4 - case boostRequest = 5 - case endSession = 6 - case chatSessionRefresh = 7 - case badDecrypt = 8 - case paymentsActivated = 9 - case paymentActivationRequest = 10 + case unknown = 0 + case joinedSignal = 1 + case identityUpdate = 2 + case identityVerified = 3 + case identityDefault = 4 + case changeNumber = 5 + case boostRequest = 6 + case endSession = 7 + case chatSessionRefresh = 8 + case badDecrypt = 9 + case paymentsActivated = 10 + case paymentActivationRequest = 11 } private func BackupProtoSimpleUpdateTypeWrap(_ value: BackupProtos_SimpleUpdate.TypeEnum) -> BackupProtoSimpleUpdateType { switch value { + case .unknown: return .unknown case .joinedSignal: return .joinedSignal case .identityUpdate: return .identityUpdate case .identityVerified: return .identityVerified @@ -11096,6 +11466,7 @@ private func BackupProtoSimpleUpdateTypeWrap(_ value: BackupProtos_SimpleUpdate. private func BackupProtoSimpleUpdateTypeUnwrap(_ value: BackupProtoSimpleUpdateType) -> BackupProtos_SimpleUpdate.TypeEnum { switch value { + case .unknown: return .unknown case .joinedSignal: return .joinedSignal case .identityUpdate: return .identityUpdate case .identityVerified: return .identityVerified @@ -11117,6 +11488,26 @@ public class BackupProtoSimpleUpdate: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_SimpleUpdate + public var type: BackupProtoSimpleUpdateType? { + guard hasType else { + return nil + } + return BackupProtoSimpleUpdateTypeWrap(proto.type) + } + // This "unwrapped" accessor should only be used if the "has value" accessor has already been checked. + @objc + public var unwrappedType: BackupProtoSimpleUpdateType { + if !hasType { + // TODO: We could make this a crashing assert. + owsFailDebug("Unsafe unwrap of missing optional: SimpleUpdate.type.") + } + return BackupProtoSimpleUpdateTypeWrap(proto.type) + } + @objc + public var hasType: Bool { + return proto.hasType + } + public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty } @@ -11190,6 +11581,9 @@ extension BackupProtoSimpleUpdate { @objc public func asBuilder() -> BackupProtoSimpleUpdateBuilder { let builder = BackupProtoSimpleUpdateBuilder() + if let _value = type { + builder.setType(_value) + } if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -11205,6 +11599,11 @@ public class BackupProtoSimpleUpdateBuilder: NSObject { @objc fileprivate override init() {} + @objc + public func setType(_ valueParam: BackupProtoSimpleUpdateType) { + proto.type = BackupProtoSimpleUpdateTypeUnwrap(valueParam) + } + public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { proto.unknownFields = unknownFields } @@ -11251,7 +11650,7 @@ public class BackupProtoGroupDescriptionUpdate: NSObject, Codable, NSSecureCodin fileprivate let proto: BackupProtos_GroupDescriptionUpdate @objc - public let body: String + public let newDescription: String public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty @@ -11262,9 +11661,9 @@ public class BackupProtoGroupDescriptionUpdate: NSObject, Codable, NSSecureCodin } private init(proto: BackupProtos_GroupDescriptionUpdate, - body: String) { + newDescription: String) { self.proto = proto - self.body = body + self.newDescription = newDescription } @objc @@ -11279,13 +11678,13 @@ public class BackupProtoGroupDescriptionUpdate: NSObject, Codable, NSSecureCodin } fileprivate convenience init(_ proto: BackupProtos_GroupDescriptionUpdate) throws { - guard proto.hasBody else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: body") + guard proto.hasNewDescription else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: newDescription") } - let body = proto.body + let newDescription = proto.newDescription self.init(proto: proto, - body: body) + newDescription: newDescription) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -11326,14 +11725,14 @@ public class BackupProtoGroupDescriptionUpdate: NSObject, Codable, NSSecureCodin extension BackupProtoGroupDescriptionUpdate { @objc - public static func builder(body: String) -> BackupProtoGroupDescriptionUpdateBuilder { - return BackupProtoGroupDescriptionUpdateBuilder(body: body) + public static func builder(newDescription: String) -> BackupProtoGroupDescriptionUpdateBuilder { + return BackupProtoGroupDescriptionUpdateBuilder(newDescription: newDescription) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoGroupDescriptionUpdateBuilder { - let builder = BackupProtoGroupDescriptionUpdateBuilder(body: body) + let builder = BackupProtoGroupDescriptionUpdateBuilder(newDescription: newDescription) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -11350,21 +11749,21 @@ public class BackupProtoGroupDescriptionUpdateBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(body: String) { + fileprivate init(newDescription: String) { super.init() - setBody(body) + setNewDescription(newDescription) } @objc @available(swift, obsoleted: 1.0) - public func setBody(_ valueParam: String?) { + public func setNewDescription(_ valueParam: String?) { guard let valueParam = valueParam else { return } - proto.body = valueParam + proto.newDescription = valueParam } - public func setBody(_ valueParam: String) { - proto.body = valueParam + public func setNewDescription(_ valueParam: String) { + proto.newDescription = valueParam } public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { @@ -11408,7 +11807,7 @@ public class BackupProtoExpirationTimerChange: NSObject, Codable, NSSecureCoding fileprivate let proto: BackupProtos_ExpirationTimerChange @objc - public let expiresIn: UInt32 + public let expiresInMs: UInt32 public var hasUnknownFields: Bool { return !proto.unknownFields.data.isEmpty @@ -11419,9 +11818,9 @@ public class BackupProtoExpirationTimerChange: NSObject, Codable, NSSecureCoding } private init(proto: BackupProtos_ExpirationTimerChange, - expiresIn: UInt32) { + expiresInMs: UInt32) { self.proto = proto - self.expiresIn = expiresIn + self.expiresInMs = expiresInMs } @objc @@ -11436,13 +11835,13 @@ public class BackupProtoExpirationTimerChange: NSObject, Codable, NSSecureCoding } fileprivate convenience init(_ proto: BackupProtos_ExpirationTimerChange) throws { - guard proto.hasExpiresIn else { - throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: expiresIn") + guard proto.hasExpiresInMs else { + throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: expiresInMs") } - let expiresIn = proto.expiresIn + let expiresInMs = proto.expiresInMs self.init(proto: proto, - expiresIn: expiresIn) + expiresInMs: expiresInMs) } public required convenience init(from decoder: Swift.Decoder) throws { @@ -11483,14 +11882,14 @@ public class BackupProtoExpirationTimerChange: NSObject, Codable, NSSecureCoding extension BackupProtoExpirationTimerChange { @objc - public static func builder(expiresIn: UInt32) -> BackupProtoExpirationTimerChangeBuilder { - return BackupProtoExpirationTimerChangeBuilder(expiresIn: expiresIn) + public static func builder(expiresInMs: UInt32) -> BackupProtoExpirationTimerChangeBuilder { + return BackupProtoExpirationTimerChangeBuilder(expiresInMs: expiresInMs) } // asBuilder() constructs a builder that reflects the proto's contents. @objc public func asBuilder() -> BackupProtoExpirationTimerChangeBuilder { - let builder = BackupProtoExpirationTimerChangeBuilder(expiresIn: expiresIn) + let builder = BackupProtoExpirationTimerChangeBuilder(expiresInMs: expiresInMs) if let _value = unknownFields { builder.setUnknownFields(_value) } @@ -11507,15 +11906,15 @@ public class BackupProtoExpirationTimerChangeBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(expiresIn: UInt32) { + fileprivate init(expiresInMs: UInt32) { super.init() - setExpiresIn(expiresIn) + setExpiresInMs(expiresInMs) } @objc - public func setExpiresIn(_ valueParam: UInt32) { - proto.expiresIn = valueParam + public func setExpiresInMs(_ valueParam: UInt32) { + proto.expiresInMs = valueParam } public func setUnknownFields(_ unknownFields: SwiftProtobuf.UnknownStorage) { @@ -12287,7 +12686,7 @@ public class BackupProtoStickerPackSticker: NSObject, Codable, NSSecureCoding { fileprivate let proto: BackupProtos_StickerPackSticker @objc - public let data: BackupProtoAttachmentPointer + public let data: BackupProtoFilePointer @objc public let emoji: String @@ -12301,7 +12700,7 @@ public class BackupProtoStickerPackSticker: NSObject, Codable, NSSecureCoding { } private init(proto: BackupProtos_StickerPackSticker, - data: BackupProtoAttachmentPointer, + data: BackupProtoFilePointer, emoji: String) { self.proto = proto self.data = data @@ -12323,7 +12722,7 @@ public class BackupProtoStickerPackSticker: NSObject, Codable, NSSecureCoding { guard proto.hasData else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: data") } - let data = BackupProtoAttachmentPointer(proto.data) + let data = try BackupProtoFilePointer(proto.data) guard proto.hasEmoji else { throw BackupProtoError.invalidProtobuf(description: "\(Self.logTag()) missing required field: emoji") @@ -12373,7 +12772,7 @@ public class BackupProtoStickerPackSticker: NSObject, Codable, NSSecureCoding { extension BackupProtoStickerPackSticker { @objc - public static func builder(data: BackupProtoAttachmentPointer, emoji: String) -> BackupProtoStickerPackStickerBuilder { + public static func builder(data: BackupProtoFilePointer, emoji: String) -> BackupProtoStickerPackStickerBuilder { return BackupProtoStickerPackStickerBuilder(data: data, emoji: emoji) } @@ -12397,7 +12796,7 @@ public class BackupProtoStickerPackStickerBuilder: NSObject { fileprivate override init() {} @objc - fileprivate init(data: BackupProtoAttachmentPointer, emoji: String) { + fileprivate init(data: BackupProtoFilePointer, emoji: String) { super.init() setData(data) @@ -12406,12 +12805,12 @@ public class BackupProtoStickerPackStickerBuilder: NSObject { @objc @available(swift, obsoleted: 1.0) - public func setData(_ valueParam: BackupProtoAttachmentPointer?) { + public func setData(_ valueParam: BackupProtoFilePointer?) { guard let valueParam = valueParam else { return } proto.data = valueParam.proto } - public func setData(_ valueParam: BackupProtoAttachmentPointer) { + public func setData(_ valueParam: BackupProtoFilePointer) { proto.data = valueParam.proto }