From 38759d66701c24fa7c0d2fd7767f4a3116cf932c Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sun, 24 Sep 2023 00:45:38 +0400 Subject: [PATCH] Experiment with settings --- Telegram/BUILD | 6 +++--- build-system/Make/Make.py | 6 +++--- .../Sources/BuildConfigExtra.m | 12 ++++++----- submodules/Postbox/Sources/Database.swift | 8 +++++++ .../ApiUtils/TelegramMediaWebFile.swift | 10 --------- .../SyncCore/SyncCore_PixelDimensions.swift | 16 ++++++-------- .../SyncCore_TelegramMediaWebFile.swift | 8 +++++++ .../ChatRecentActionsHistoryTransition.swift | 21 ++++++++++++++----- 8 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Telegram/BUILD b/Telegram/BUILD index 468c3ce4ed..027ec3a72c 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -2015,9 +2015,9 @@ xcodeproj( "Debug": { "//command_line_option:compilation_mode": "dbg", }, - #"Release": { - # "//command_line_option:compilation_mode": "opt", - #}, + "Release": { + "//command_line_option:compilation_mode": "opt", + }, }, default_xcode_configuration = "Debug" diff --git a/build-system/Make/Make.py b/build-system/Make/Make.py index 15aedfe343..ddbc5ba5b1 100644 --- a/build-system/Make/Make.py +++ b/build-system/Make/Make.py @@ -100,7 +100,7 @@ class BazelCommandLine: # https://github.com/bazelbuild/rules_swift # Use -Osize instead of -O when building swift modules. - '--features=swift.opt_uses_osize', + #'--features=swift.opt_uses_osize', # --num-threads 0 forces swiftc to generate one object file per module; it: # 1. resolves issues with the linker caused by the swift-objc mixing. @@ -109,8 +109,8 @@ class BazelCommandLine: '--swiftcopt=-j1', # Strip unsused code. - '--features=dead_strip', - '--objc_enable_binary_stripping', + #'--features=dead_strip', + #'--objc_enable_binary_stripping', # Always embed bitcode into Watch binaries. This is required by the App Store. '--apple_bitcode=watchos=embedded', diff --git a/submodules/BuildConfigExtra/Sources/BuildConfigExtra.m b/submodules/BuildConfigExtra/Sources/BuildConfigExtra.m index fcad93dc2a..4ebc2303d6 100644 --- a/submodules/BuildConfigExtra/Sources/BuildConfigExtra.m +++ b/submodules/BuildConfigExtra/Sources/BuildConfigExtra.m @@ -104,16 +104,18 @@ static MTPKCS * _Nullable parseSignature(const char* buffer, size_t size) { { uint32_t offset = OSSwapBigToHostInt32(sb->index[i].offset); - const CS_Blob* blob = (const CS_Blob*)(buffer + offset); + const CS_Blob* blobMem = (const CS_Blob*)(buffer + offset); + CS_Blob blob; + memcpy(&blob, blobMem, sizeof(CS_Blob)); - if (OSSwapBigToHostInt32(blob->magic) == 0xfade0b01) // signature + if (OSSwapBigToHostInt32(blob.magic) == 0xfade0b01) // signature { - printf("Embedded signature, length: %d\n", OSSwapBigToHostInt32(blob->length)); + printf("Embedded signature, length: %d\n", OSSwapBigToHostInt32(blob.length)); - if (OSSwapBigToHostInt32(blob->length) != 8) + if (OSSwapBigToHostInt32(blob.length) != 8) { const unsigned char* message = (const unsigned char*)buffer + offset + 8; - MTPKCS *result = [MTPKCS parse:message size:(OSSwapBigToHostInt32(blob->length) - 8)]; + MTPKCS *result = [MTPKCS parse:message size:(OSSwapBigToHostInt32(blob.length) - 8)]; return result; } } diff --git a/submodules/Postbox/Sources/Database.swift b/submodules/Postbox/Sources/Database.swift index 82f25ccc43..c7ad76d3b4 100644 --- a/submodules/Postbox/Sources/Database.swift +++ b/submodules/Postbox/Sources/Database.swift @@ -25,10 +25,18 @@ import Foundation import sqlcipher +private let ensureInitialized: Void = { + sqlite3_initialize() + + return Void() +}() + public final class Database { internal var handle: OpaquePointer? = nil public init?(_ location: String, readOnly: Bool) { + let _ = ensureInitialized + if location != ":memory:" { let _ = open(location + "-guard", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR) } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebFile.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebFile.swift index eeb275febb..8b13789179 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebFile.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebFile.swift @@ -1,11 +1 @@ -import Postbox -public extension TelegramMediaWebFile { - var dimensions: PixelDimensions? { - return dimensionsForFileAttributes(self.attributes) - } - - var duration: Double? { - return durationForFileAttributes(self.attributes) - } -} diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_PixelDimensions.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_PixelDimensions.swift index 34f5ae0953..f834f54fdc 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_PixelDimensions.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_PixelDimensions.swift @@ -10,18 +10,14 @@ public struct PixelDimensions: Equatable { self.width = width self.height = height } -} - + #if os(iOS) - -public extension PixelDimensions { - init(_ size: CGSize) { + public init(_ size: CGSize) { self.init(width: Int32(size.width), height: Int32(size.height)) } - var cgSize: CGSize { - return CGSize(width: CGFloat(self.width), height: CGFloat(self.height)) - } -} - + public var cgSize: CGSize { + return CGSize(width: CGFloat(self.width), height: CGFloat(self.height)) + } #endif +} diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebFile.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebFile.swift index fa80508fc7..321494cf64 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebFile.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaWebFile.swift @@ -86,4 +86,12 @@ public class TelegramMediaWebFile: Media, Codable, Equatable { public func isSemanticallyEqual(to other: Media) -> Bool { return self.isEqual(to: other) } + + public var dimensions: PixelDimensions? { + return dimensionsForFileAttributes(self.attributes) + } + + public var duration: Double? { + return durationForFileAttributes(self.attributes) + } } diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index 91e798f645..71948a35e4 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -1354,7 +1354,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] - let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_DeletedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link?.replacingOccurrences(of: "https://", with: "") ?? "") + let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_DeletedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link_?.replacingOccurrences(of: "https://", with: "") ?? "") appendAttributedText(text: rawText, generateEntities: { index in if index == 0, let author = author { @@ -1380,7 +1380,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] - let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_RevokedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link?.replacingOccurrences(of: "https://", with: "") ?? "") + let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_RevokedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link_?.replacingOccurrences(of: "https://", with: "") ?? "") appendAttributedText(text: rawText, generateEntities: { index in if index == 0, let author = author { @@ -1406,7 +1406,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] - let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_EditedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", updatedInvite.link?.replacingOccurrences(of: "https://", with: "") ?? "") + let rawText: PresentationStrings.FormattedString = self.presentationData.strings.Channel_AdminLog_EditedInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", updatedInvite.link_?.replacingOccurrences(of: "https://", with: "") ?? "") appendAttributedText(text: rawText, generateEntities: { index in if index == 0, let author = author { @@ -1434,9 +1434,9 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { let rawText: PresentationStrings.FormattedString if joinedViaFolderLink { - rawText = self.presentationData.strings.Channel_AdminLog_JoinedViaFolderInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link?.replacingOccurrences(of: "https://", with: "") ?? "") + rawText = self.presentationData.strings.Channel_AdminLog_JoinedViaFolderInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link_?.replacingOccurrences(of: "https://", with: "") ?? "") } else { - rawText = self.presentationData.strings.Channel_AdminLog_JoinedViaInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link?.replacingOccurrences(of: "https://", with: "") ?? "") + rawText = self.presentationData.strings.Channel_AdminLog_JoinedViaInviteLink(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", invite.link_?.replacingOccurrences(of: "https://", with: "") ?? "") } appendAttributedText(text: rawText, generateEntities: { index in @@ -1902,3 +1902,14 @@ func chatRecentActionsHistoryPreparedTransition(from fromEntries: [ChatRecentAct return ChatRecentActionsHistoryTransition(filteredEntries: toEntries, type: type, deletions: deletions, insertions: insertions, updates: updates, canLoadEarlier: canLoadEarlier, displayingResults: displayingResults, isEmpty: toEntries.isEmpty) } + +private extension ExportedInvitation { + var link_: String? { + switch self { + case let .link(link, _, _, _, _, _, _, _, _, _, _, _): + return link + case .publicJoinRequest: + return nil + } + } +}