mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 05:51:42 +00:00
Fixed int overflow on auto-download preset comparison
This commit is contained in:
parent
34324b5fe7
commit
31a1a69d2b
@ -5465,6 +5465,10 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
|||||||
}
|
}
|
||||||
|
|
||||||
func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
||||||
|
guard let view = self.chatDisplayNode.view.hitTest(location, with: nil), view.isDescendant(of: self.chatDisplayNode.historyNode.view) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
let historyPoint = sourceView.convert(location, to: self.chatDisplayNode.historyNode.view)
|
let historyPoint = sourceView.convert(location, to: self.chatDisplayNode.historyNode.view)
|
||||||
var result: (Message, ChatMessagePeekPreviewContent)?
|
var result: (Message, ChatMessagePeekPreviewContent)?
|
||||||
self.chatDisplayNode.historyNode.forEachItemNode { itemNode in
|
self.chatDisplayNode.historyNode.forEachItemNode { itemNode in
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
|
|
||||||
private var item: ChatMessageBubbleContentItem?
|
private var item: ChatMessageBubbleContentItem?
|
||||||
private var automaticDownload: Bool?
|
private var automaticDownload: Bool?
|
||||||
var telegramFile: TelegramMediaFile?
|
var media: TelegramMediaFile?
|
||||||
private var secretProgressIcon: UIImage?
|
private var secretProgressIcon: UIImage?
|
||||||
|
|
||||||
private let fetchDisposable = MetaDisposable()
|
private let fetchDisposable = MetaDisposable()
|
||||||
@ -112,7 +112,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func asyncLayout() -> (_ item: ChatMessageBubbleContentItem, _ width: CGFloat, _ displaySize: CGSize, _ statusType: ChatMessageInteractiveInstantVideoNodeStatusType, _ automaticDownload: Bool) -> (ChatMessageInstantVideoItemLayoutResult, (ChatMessageInstantVideoItemLayoutData, ContainedViewLayoutTransition) -> Void) {
|
func asyncLayout() -> (_ item: ChatMessageBubbleContentItem, _ width: CGFloat, _ displaySize: CGSize, _ statusType: ChatMessageInteractiveInstantVideoNodeStatusType, _ automaticDownload: Bool) -> (ChatMessageInstantVideoItemLayoutResult, (ChatMessageInstantVideoItemLayoutData, ContainedViewLayoutTransition) -> Void) {
|
||||||
let previousFile = self.telegramFile
|
let previousFile = self.media
|
||||||
|
|
||||||
let currentItem = self.item
|
let currentItem = self.item
|
||||||
let previousAutomaticDownload = self.automaticDownload
|
let previousAutomaticDownload = self.automaticDownload
|
||||||
@ -283,7 +283,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
strongSelf.secretVideoPlaceholderBackground.image = secretVideoPlaceholderBackgroundImage
|
strongSelf.secretVideoPlaceholderBackground.image = secretVideoPlaceholderBackgroundImage
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.telegramFile = updatedFile
|
strongSelf.media = updatedFile
|
||||||
|
|
||||||
if let infoBackgroundImage = strongSelf.infoBackgroundNode.image, let muteImage = strongSelf.muteIconNode.image {
|
if let infoBackgroundImage = strongSelf.infoBackgroundNode.image, let muteImage = strongSelf.muteIconNode.image {
|
||||||
let infoWidth = muteImage.size.width
|
let infoWidth = muteImage.size.width
|
||||||
@ -603,10 +603,16 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if self.infoBackgroundNode.alpha.isZero {
|
if self.infoBackgroundNode.alpha.isZero {
|
||||||
item.context.sharedContext.mediaManager.playlistControl(.playback(.togglePlayPause), type: .voice)
|
if let status = self.status, case let .fetchStatus(fetchStatus) = status, case .Remote = fetchStatus {
|
||||||
|
item.context.sharedContext.mediaManager.playlistControl(.playback(.pause), type: .voice)
|
||||||
|
self.videoNode?.fetchControl(.fetch)
|
||||||
|
} else {
|
||||||
|
item.context.sharedContext.mediaManager.playlistControl(.playback(.togglePlayPause), type: .voice)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = item.controllerInteraction.openMessage(item.message, .default)
|
let _ = item.controllerInteraction.openMessage(item.message, .default)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
@ -623,7 +629,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func progressPressed() {
|
private func progressPressed() {
|
||||||
guard let item = self.item, let file = self.telegramFile else {
|
guard let item = self.item, let file = self.media else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let status = self.status {
|
if let status = self.status {
|
||||||
|
|||||||
@ -16,14 +16,6 @@ const uint8_t ID3v3Artwork[4] = {0x41, 0x50, 0x49, 0x43};
|
|||||||
const uint8_t JPGMagic[3] = {0xff, 0xd8, 0xff};
|
const uint8_t JPGMagic[3] = {0xff, 0xd8, 0xff};
|
||||||
const uint8_t PNGMagic[4] = {0x89, 0x50, 0x4e, 0x47};
|
const uint8_t PNGMagic[4] = {0x89, 0x50, 0x4e, 0x47};
|
||||||
|
|
||||||
uint32_t getSize(const uint8_t *bytes) {
|
|
||||||
uint32_t size = CFSwapInt32HostToBig(*(const uint32_t *)(bytes + ID3SizeOffset));
|
|
||||||
uint32_t b1 = (size & 0x7F000000) >> 3;
|
|
||||||
uint32_t b2 = (size & 0x007F0000) >> 2;
|
|
||||||
uint32_t b3 = (size & 0x00007F00) >> 1;
|
|
||||||
uint32_t b4 = size & 0x0000007F;
|
|
||||||
return b1 + b2 + b3 + b4;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t frameOffsetForVersion(uint8_t version) {
|
uint32_t frameOffsetForVersion(uint8_t version) {
|
||||||
return version == 2 ? ID3v2FrameOffset : ID3v3FrameOffset;
|
return version == 2 ? ID3v2FrameOffset : ID3v3FrameOffset;
|
||||||
|
|||||||
@ -112,10 +112,10 @@ final class InstantVideoRadialStatusNode: ASDisplayNode {
|
|||||||
if let (timestamp, duration, baseRate) = timestampAndDuration, let statusValue = self.statusValue {
|
if let (timestamp, duration, baseRate) = timestampAndDuration, let statusValue = self.statusValue {
|
||||||
let progress = CGFloat(timestamp / duration)
|
let progress = CGFloat(timestamp / duration)
|
||||||
|
|
||||||
if progress.isNaN || !progress.isFinite || statusValue.generationTimestamp.isZero {
|
if progress.isNaN || !progress.isFinite {
|
||||||
self.pop_removeAnimation(forKey: "progress")
|
self.pop_removeAnimation(forKey: "progress")
|
||||||
self.effectiveProgress = 0.0
|
self.effectiveProgress = 0.0
|
||||||
} else if statusValue.status != .playing {
|
} else if statusValue.status != .playing || statusValue.generationTimestamp.isZero {
|
||||||
self.pop_removeAnimation(forKey: "progress")
|
self.pop_removeAnimation(forKey: "progress")
|
||||||
self.effectiveProgress = progress
|
self.effectiveProgress = progress
|
||||||
} else {
|
} else {
|
||||||
@ -130,14 +130,11 @@ final class InstantVideoRadialStatusNode: ASDisplayNode {
|
|||||||
(node as! InstantVideoRadialStatusNode).effectiveProgress = values!.pointee
|
(node as! InstantVideoRadialStatusNode).effectiveProgress = values!.pointee
|
||||||
}
|
}
|
||||||
property?.threshold = 0.01
|
property?.threshold = 0.01
|
||||||
}) as! POPAnimatableProperty
|
}) as? POPAnimatableProperty
|
||||||
animation.fromValue = progress as NSNumber
|
animation.fromValue = progress as NSNumber
|
||||||
animation.toValue = 1.0 as NSNumber
|
animation.toValue = 1.0 as NSNumber
|
||||||
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
|
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
|
||||||
animation.duration = max(0.0, duration - timestamp) / baseRate
|
animation.duration = max(0.0, duration - timestamp) / baseRate
|
||||||
animation.completionBlock = { [weak self] _, _ in
|
|
||||||
|
|
||||||
}
|
|
||||||
animation.beginTime = statusValue.generationTimestamp
|
animation.beginTime = statusValue.generationTimestamp
|
||||||
self.pop_add(animation, forKey: "progress")
|
self.pop_add(animation, forKey: "progress")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,8 +95,8 @@ public struct MediaAutoDownloadCategories: PostboxCoding, Equatable, Comparable
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func < (lhs: MediaAutoDownloadCategories, rhs: MediaAutoDownloadCategories) -> Bool {
|
public static func < (lhs: MediaAutoDownloadCategories, rhs: MediaAutoDownloadCategories) -> Bool {
|
||||||
let lhsSizeLimit = (isAutodownloadEnabledForAnyPeerType(category: lhs.video) ? lhs.video.sizeLimit : 0) + (isAutodownloadEnabledForAnyPeerType(category: lhs.file) ? lhs.file.sizeLimit : 0)
|
let lhsSizeLimit: Int64 = Int64((isAutodownloadEnabledForAnyPeerType(category: lhs.video) ? lhs.video.sizeLimit : 0)) + Int64((isAutodownloadEnabledForAnyPeerType(category: lhs.file) ? lhs.file.sizeLimit : 0))
|
||||||
let rhsSizeLimit = (isAutodownloadEnabledForAnyPeerType(category: rhs.video) ? rhs.video.sizeLimit : 0) + (isAutodownloadEnabledForAnyPeerType(category: rhs.file) ? rhs.file.sizeLimit : 0)
|
let rhsSizeLimit: Int64 = Int64((isAutodownloadEnabledForAnyPeerType(category: rhs.video) ? rhs.video.sizeLimit : 0)) + Int64((isAutodownloadEnabledForAnyPeerType(category: rhs.file) ? rhs.file.sizeLimit : 0))
|
||||||
return lhsSizeLimit < rhsSizeLimit
|
return lhsSizeLimit < rhsSizeLimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user