Merge branch 'beta' into bazel

This commit is contained in:
Ali 2019-11-04 16:45:45 +04:00
commit f15c474757
937 changed files with 3829 additions and 71502 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ DerivedData
*/xcuserdata/*
buck-out/*
.buckd/*
tools/buck
AppBinary.xcworkspace/*
Project.xcodeproj/*
Watch/Watch.xcodeproj/*

View File

@ -1,5 +1,6 @@
stages:
- build
- deploy
variables:
LANG: "en_US.UTF-8"
@ -16,6 +17,7 @@ internal:
- tags
script:
- bash buildbox/build-telegram.sh hockeyapp
- bash buildbox/deploy-telegram.sh hockeyapp
environment:
name: internal
@ -31,3 +33,20 @@ beta_testflight:
- bash buildbox/build-telegram.sh appstore
environment:
name: testflight_llc
artifacts:
paths:
- build/artifacts
expire_in: 1 week
deploy_beta_testflight:
tags:
- ios_beta
stage: deploy
only:
- beta
except:
- tags
script:
- bash buildbox/deploy-telegram.sh appstore
environment:
name: testflight_llc

View File

@ -146,7 +146,7 @@ def intents_extension_configs():
def watch_extension_binary_configs():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "4.0",
"WATCHOS_DEPLOYMENT_TARGET": "5.0",
"TARGETED_DEVICE_FAMILY": "4",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp.watchkitextension"),
"DEVELOPMENT_TEAM": get_development_team(),
@ -168,7 +168,7 @@ def watch_extension_binary_configs():
def watch_binary_configs():
config = {
"SDKROOT": "watchos",
"WATCHOS_DEPLOYMENT_TARGET": "4.0",
"WATCHOS_DEPLOYMENT_TARGET": "5.0",
"TARGETED_DEVICE_FAMILY": "4",
"PRODUCT_BUNDLE_IDENTIFIER": bundle_identifier(suffix=".watchkitapp"),
"DEVELOPMENT_TEAM": get_development_team(),

View File

@ -226,13 +226,16 @@ static void reportMemory() {
silent = [silentString intValue] != 0;
}
NSString *attachmentDataString = decryptedPayload[@"attachb64"];
NSData *attachmentData = nil;
id parsedAttachment = nil;
if ([attachmentDataString isKindOfClass:[NSString class]]) {
attachmentData = parseBase64(attachmentDataString);
if (attachmentData != nil) {
parsedAttachment = parseAttachment(attachmentData);
if (_isLockedValue) {
NSString *attachmentDataString = decryptedPayload[@"attachb64"];
if ([attachmentDataString isKindOfClass:[NSString class]]) {
attachmentData = parseBase64(attachmentDataString);
if (attachmentData != nil) {
parsedAttachment = parseAttachment(attachmentData);
}
}
}
@ -324,6 +327,7 @@ static void reportMemory() {
}
_bestAttemptContent.title = title;
if (_isLockedValue) {
_bestAttemptContent.title = @"";
_bestAttemptContent.subtitle = @"";
if (_lockedMessageTextValue != nil) {
_bestAttemptContent.body = _lockedMessageTextValue;
@ -348,37 +352,45 @@ static void reportMemory() {
}
}
NSString *threadIdString = aps[@"thread-id"];
if ([threadIdString isKindOfClass:[NSString class]]) {
_bestAttemptContent.threadIdentifier = threadIdString;
if (_isLockedValue) {
_bestAttemptContent.threadIdentifier = @"locked";
} else {
NSString *threadIdString = aps[@"thread-id"];
if ([threadIdString isKindOfClass:[NSString class]]) {
_bestAttemptContent.threadIdentifier = threadIdString;
}
}
NSString *soundString = aps[@"sound"];
if ([soundString isKindOfClass:[NSString class]]) {
_bestAttemptContent.sound = [UNNotificationSound soundNamed:soundString];
}
NSString *categoryString = aps[@"category"];
if ([categoryString isKindOfClass:[NSString class]]) {
_bestAttemptContent.categoryIdentifier = categoryString;
if (peerId != 0 && messageId != 0 && parsedAttachment != nil && attachmentData != nil) {
userInfo[@"peerId"] = @(peerId);
userInfo[@"messageId.namespace"] = @(0);
userInfo[@"messageId.id"] = @(messageId);
userInfo[@"media"] = [attachmentData base64EncodedStringWithOptions:0];
if (isExpandableMedia) {
if ([categoryString isEqualToString:@"r"]) {
_bestAttemptContent.categoryIdentifier = @"withReplyMedia";
} else if ([categoryString isEqualToString:@"m"]) {
_bestAttemptContent.categoryIdentifier = @"withMuteMedia";
if (_isLockedValue) {
_bestAttemptContent.categoryIdentifier = @"locked";
} else {
NSString *categoryString = aps[@"category"];
if ([categoryString isKindOfClass:[NSString class]]) {
_bestAttemptContent.categoryIdentifier = categoryString;
if (peerId != 0 && messageId != 0 && parsedAttachment != nil && attachmentData != nil) {
userInfo[@"peerId"] = @(peerId);
userInfo[@"messageId.namespace"] = @(0);
userInfo[@"messageId.id"] = @(messageId);
userInfo[@"media"] = [attachmentData base64EncodedStringWithOptions:0];
if (isExpandableMedia) {
if ([categoryString isEqualToString:@"r"]) {
_bestAttemptContent.categoryIdentifier = @"withReplyMedia";
} else if ([categoryString isEqualToString:@"m"]) {
_bestAttemptContent.categoryIdentifier = @"withMuteMedia";
}
}
}
}
}
if (accountInfos.accounts.count > 1) {
if (_bestAttemptContent.title.length != 0 && account.peerName.length != 0) {
_bestAttemptContent.title = [NSString stringWithFormat:@"%@ → %@", _bestAttemptContent.title, account.peerName];
if (accountInfos.accounts.count > 1) {
if (_bestAttemptContent.title.length != 0 && account.peerName.length != 0) {
_bestAttemptContent.title = [NSString stringWithFormat:@"%@ → %@", _bestAttemptContent.title, account.peerName];
}
}
}
}

View File

@ -6,6 +6,16 @@ import BuildConfig
class ShareRootController: UIViewController {
private var impl: ShareRootControllerImpl?
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.modalPresentationStyle = .fullScreen
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
super.loadView()

View File

@ -5065,3 +5065,5 @@ Any member of this group will be able to see messages in the channel.";
"WebBrowser.InAppSafari" = "In-App Safari";
"Widget.ApplicationLocked" = "Unlock the app to use the widget";
"Group.ErrorSupergroupConversionNotPossible" = "Sorry, you are a member of too many groups and channels. Please leave some before creating a new one.";

View File

@ -117,7 +117,14 @@ final class PeerView: UIView {
private let tapped: () -> Void
var primaryColor: UIColor {
didSet {
self.titleLabel.textColor = self.primaryColor
}
}
init(primaryColor: UIColor, accountPeerId: Int64, peer: WidgetDataPeer, tapped: @escaping () -> Void) {
self.primaryColor = primaryColor
self.peer = peer
self.tapped = tapped
self.avatarView = AvatarView(accountPeerId: accountPeerId, peer: peer, size: avatarSize)

View File

@ -77,6 +77,21 @@ class TodayViewController: UIViewController, NCWidgetProviding {
}
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if #available(iOSApplicationExtension 13.0, *) {
switch self.traitCollection.userInterfaceStyle {
case .dark:
self.primaryColor = .white
default:
self.primaryColor = .black
}
}
self.appLockedLabel?.textColor = self.primaryColor
for view in self.peerViews {
view.primaryColor = self.primaryColor
}
}
func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
completionHandler(.newData)
}

View File

@ -5,7 +5,7 @@ set -e
BUILD_TELEGRAM_VERSION="1"
MACOS_VERSION="10.15"
XCODE_VERSION="11.1"
XCODE_VERSION="11.2"
GUEST_SHELL="bash"
VM_BASE_NAME="macos$(echo $MACOS_VERSION | sed -e 's/\.'/_/g)_Xcode$(echo $XCODE_VERSION | sed -e 's/\.'/_/g)"
@ -150,15 +150,24 @@ if [ "$BUILD_MACHINE" == "linux" ]; then
done
elif [ "$BUILD_MACHINE" == "macOS" ]; then
if [ -z "$RUNNING_VM" ]; then
SNAPSHOT_ID=$(prlctl snapshot-list "$VM_BASE_NAME" | grep -Eo '\{(\d|[a-f]|-)*\}' | tr '\n' '\0')
if [ -z "$SNAPSHOT_ID" ]; then
echo "$VM_BASE_NAME is required to have one snapshot"
exit 1
fi
prlctl clone "$VM_BASE_NAME" --name "$VM_NAME"
prlctl snapshot-switch "$VM_NAME" -i "$SNAPSHOT_ID"
prlctl clone "$VM_BASE_NAME" --linked --name "$VM_NAME"
prlctl start "$VM_NAME"
echo "Getting VM IP"
while [ 1 ]; do
TEST_IP=$(prlctl exec "$VM_NAME" "ifconfig | grep inet | grep broadcast | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -1 | tr '\n' '\0'" || echo "")
if [ ! -z "$TEST_IP" ]; then
RESPONSE=$(ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null telegram@"$TEST_IP" -o ServerAliveInterval=60 -t "echo -n 1")
if [ "$RESPONSE" == "1" ]; then
VM_IP="$TEST_IP"
break
fi
fi
sleep 1
done
fi
VM_IP=$(prlctl exec "$VM_NAME" "ifconfig | grep inet | grep broadcast | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -1 | tr '\n' '\0'")
echo "VM_IP=$VM_IP"
fi
scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr "$BUILDBOX_DIR/$CODESIGNING_SUBPATH" telegram@"$VM_IP":codesigning_data
@ -173,24 +182,11 @@ scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/nul
ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null telegram@"$VM_IP" -o ServerAliveInterval=60 -t "export TELEGRAM_BUILD_APPSTORE_PASSWORD=\"$TELEGRAM_BUILD_APPSTORE_PASSWORD\"; export TELEGRAM_BUILD_APPSTORE_TEAM_NAME=\"$TELEGRAM_BUILD_APPSTORE_TEAM_NAME\"; export TELEGRAM_BUILD_APPSTORE_USERNAME=\"$TELEGRAM_BUILD_APPSTORE_USERNAME\"; export BUILD_NUMBER=\"$BUILD_NUMBER\"; export COMMIT_ID=\"$COMMIT_ID\"; export COMMIT_AUTHOR=\"$COMMIT_AUTHOR\"; export BUCK_HTTP_CACHE=\"$BUCK_HTTP_CACHE\"; $GUEST_SHELL -l guest-build-telegram.sh $BUILD_CONFIGURATION" || true
if [ "$BUILD_CONFIGURATION" == "appstore" ]; then
ARCHIVE_PATH="$HOME/telegram-builds-archive"
DATE_PATH=$(date +%Y-%m-%d_%H-%M-%S)
ARCHIVE_BUILD_PATH="$ARCHIVE_PATH/$DATE_PATH"
mkdir -p "$ARCHIVE_PATH"
mkdir -p "$ARCHIVE_BUILD_PATH"
APPSTORE_IPA="Telegram-iOS-AppStoreLLC.ipa"
APPSTORE_DSYM_ZIP="Telegram-iOS-AppStoreLLC.app.dSYM.zip"
APPSTORE_TARGET_IPA="$ARCHIVE_BUILD_PATH/Telegram-iOS-AppStoreLLC.ipa"
APPSTORE_TARGET_DSYM_ZIP="$ARCHIVE_BUILD_PATH/Telegram-iOS-AppStoreLLC.app.dSYM.zip"
OUTPUT_PATH="build/artifacts"
rm -rf "$OUTPUT_PATH"
mkdir -p "$OUTPUT_PATH"
scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr telegram@"$VM_IP":"telegram-ios/*.ipa" "$ARCHIVE_BUILD_PATH/"
scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr telegram@"$VM_IP":"telegram-ios/*.zip" "$ARCHIVE_BUILD_PATH/"
elif [ "$BUILD_CONFIGURATION" == "verify" ]; then
VERIFY_IPA="Telegram-Verify-Build.ipa"
rm -f "$VERIFY_IPA"
scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr telegram@"$VM_IP":telegram-ios/Telegram-iOS-AppStoreLLC.ipa "./$VERIFY_IPA"
fi
scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -pr telegram@"$VM_IP":"telegram-ios/build/artifacts/*" "$OUTPUT_PATH/"
if [ -z "$RUNNING_VM" ]; then
if [ "$BUILD_MACHINE" == "linux" ]; then
@ -200,4 +196,8 @@ if [ -z "$RUNNING_VM" ]; then
prlctl stop "$VM_NAME" --kill
prlctl delete "$VM_NAME"
fi
fi
fi
if [ ! -f "$OUTPUT_PATH/Telegram.ipa" ]; then
exit 1
fi

View File

@ -0,0 +1,68 @@
#!/bin/bash
set -e
CONFIGURATION="$1"
if [ -z "$CONFIGURATION" ]; then
echo "Usage: sh deploy-telegram.sh CONFIGURATION"
exit 1
fi
if [ ! `which setup-telegram-build.sh` ]; then
echo "setup-telegram-build.sh not found in PATH $PATH"
exit 1
fi
BASE_DIR=$(pwd)
BUILDBOX_DIR="buildbox"
mkdir -p "$BUILDBOX_DIR/transient-data"
source `which setup-telegram-build.sh`
setup_telegram_build "$CONFIGURATION" "$BASE_DIR/$BUILDBOX_DIR/transient-data"
COMMIT_ID=$(git rev-parse HEAD)
COMMIT_AUTHOR=$(git log -1 --pretty=format:'%an')
if [ -z "$2" ]; then
COMMIT_COUNT=$(git rev-list --count HEAD)
COMMIT_COUNT="$(($COMMIT_COUNT+1000))"
BUILD_NUMBER="$COMMIT_COUNT"
else
BUILD_NUMBER="$2"
fi
if [ "$CONFIGURATION" == "hockeyapp" ]; then
FASTLANE_PASSWORD=""
FASTLANE_ITC_TEAM_NAME=""
FASTLANE_BUILD_CONFIGURATION="internalhockeyapp"
elif [ "$CONFIGURATION" == "appstore" ]; then
FASTLANE_PASSWORD="$TELEGRAM_BUILD_APPSTORE_PASSWORD"
FASTLANE_ITC_TEAM_NAME="$TELEGRAM_BUILD_APPSTORE_TEAM_NAME"
FASTLANE_ITC_USERNAME="$TELEGRAM_BUILD_APPSTORE_USERNAME"
FASTLANE_BUILD_CONFIGURATION="testflight_llc"
else
echo "Unknown configuration $CONFIGURATION"
exit 1
fi
OUTPUT_PATH="build/artifacts"
IPA_PATH="$OUTPUT_PATH/Telegram.ipa"
DSYM_PATH="$OUTPUT_PATH/Telegram.DSYMs.zip"
if [ ! -f "$IPA_PATH" ]; then
echo "$IPA_PATH not found"
exit 1
fi
if [ ! -f "$DSYM_PATH" ]; then
echo "$DSYM_PATH not found"
exit 1
fi
if [ "$1" == "appstore" ]; then
export DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t DAV"
FASTLANE_PASSWORD="$FASTLANE_PASSWORD" xcrun altool --upload-app --type ios --file "$IPA_PATH" --username "$FASTLANE_ITC_USERNAME" --password "@env:FASTLANE_PASSWORD"
#FASTLANE_PASSWORD="$FASTLANE_PASSWORD" FASTLANE_ITC_TEAM_NAME="$FASTLANE_ITC_TEAM_NAME" fastlane "$FASTLANE_BUILD_CONFIGURATION" build_number:"$BUILD_NUMBER" commit_hash:"$COMMIT_ID" commit_author:"$COMMIT_AUTHOR" skip_build:1 skip_pilot:1
else
FASTLANE_PASSWORD="$FASTLANE_PASSWORD" FASTLANE_ITC_TEAM_NAME="$FASTLANE_ITC_TEAM_NAME" fastlane "$FASTLANE_BUILD_CONFIGURATION" build_number:"$BUILD_NUMBER" commit_hash:"$COMMIT_ID" commit_author:"$COMMIT_AUTHOR" skip_build:1
fi

View File

@ -108,14 +108,10 @@ else
if [ "$1" == "hockeyapp" ]; then
BUILD_ENV_SCRIPT="internal"
RESULT_IPA_NAME="Telegram-iOS-Hockeyapp-Internal.ipa"
RESULT_DSYM_NAME="Telegram-iOS-Hockeyapp-Internal.app.dSYM.zip"
FASTLANE_BUILD_CONFIGURATION="internalhockeyapp"
APP_TARGET="app_arm64"
elif [ "$1" == "appstore" ]; then
BUILD_ENV_SCRIPT="appstore"
RESULT_IPA_NAME="Telegram-iOS-AppStoreLLC.ipa"
RESULT_DSYM_NAME="Telegram-iOS-AppStoreLLC.app.dSYM.zip"
FASTLANE_BUILD_CONFIGURATION="testflight_llc"
APP_TARGET="app"
else
@ -124,16 +120,13 @@ else
fi
BUCK="$(pwd)/tools/buck" BUCK_HTTP_CACHE="$BUCK_HTTP_CACHE" LOCAL_CODESIGNING=1 sh "../telegram-ios-shared/buildbox/bin/$BUILD_ENV_SCRIPT.sh" make "$APP_TARGET"
cp "build/Telegram_signed.ipa" "./$RESULT_IPA_NAME"
cp "build/DSYMs.zip" "./$RESULT_DSYM_NAME"
export DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t DAV"
if [ "$1" == "appstore" ]; then
FASTLANE_PASSWORD="$FASTLANE_PASSWORD" xcrun altool --upload-app --type ios --file "$RESULT_IPA_NAME" --username "$FASTLANE_ITC_USERNAME" --password "@env:FASTLANE_PASSWORD"
FASTLANE_PASSWORD="$FASTLANE_PASSWORD" FASTLANE_ITC_TEAM_NAME="$FASTLANE_ITC_TEAM_NAME" fastlane "$FASTLANE_BUILD_CONFIGURATION" build_number:"$BUILD_NUMBER" commit_hash:"$COMMIT_ID" commit_author:"$COMMIT_AUTHOR" skip_build:1 skip_pilot:1
else
FASTLANE_PASSWORD="$FASTLANE_PASSWORD" FASTLANE_ITC_TEAM_NAME="$FASTLANE_ITC_TEAM_NAME" fastlane "$FASTLANE_BUILD_CONFIGURATION" build_number:"$BUILD_NUMBER" commit_hash:"$COMMIT_ID" commit_author:"$COMMIT_AUTHOR" skip_build:1
fi
OUTPUT_PATH="build/artifacts"
rm -rf "$OUTPUT_PATH"
mkdir -p "$OUTPUT_PATH"
cp "build/Telegram_signed.ipa" "./$OUTPUT_PATH/Telegram.ipa"
cp "build/DSYMs.zip" "./$OUTPUT_PATH/Telegram.DSYMs.zip"
cd "$BASE_DIR"
fi

View File

@ -73,7 +73,7 @@ with open(destination + '/BUCK', 'w+b') as file:
pass
shutil.copytree('Config', destination + '/' + 'Config')
shutil.copytree('tools/buck', destination + '/' + 'tools/buck')
shutil.copytree('tools/buck-build', destination + '/' + 'tools/buck-build')
shutil.copy('Wallet/README.md', destination + '/' + 'README.md')
os.remove(destination + '/Wallet/' + 'README.md')

View File

@ -60,6 +60,6 @@ lane :build_for_appstore do |options|
)
end
if File.exists?("../../Telegram-iOS-Shared/fastlane/Fastfile")
import "../../Telegram-iOS-Shared/fastlane/Fastfile"
if File.exists?("../buildbox/transient-data/telegram-ios-shared/fastlane/Fastfile")
import "../buildbox/transient-data/telegram-ios-shared/fastlane/Fastfile"
end

View File

@ -17,12 +17,12 @@ private func isLocked(passcodeSettings: PresentationPasscodeSettings, state: Loc
} else if let autolockTimeout = passcodeSettings.autolockTimeout {
var bootTimestamp: Int32 = 0
let uptime = getDeviceUptimeSeconds(&bootTimestamp)
let timestamp = MonotonicTimestamp(bootTimestap: bootTimestamp, uptime: uptime)
let timestamp = MonotonicTimestamp(bootTimestamp: bootTimestamp, uptime: uptime)
let applicationActivityTimestamp = state.applicationActivityTimestamp
if let applicationActivityTimestamp = applicationActivityTimestamp {
if timestamp.bootTimestap != applicationActivityTimestamp.bootTimestap {
if timestamp.bootTimestamp != applicationActivityTimestamp.bootTimestamp {
return true
}
if timestamp.uptime >= applicationActivityTimestamp.uptime + autolockTimeout {
@ -249,7 +249,7 @@ public final class AppLockContextImpl: AppLockContext {
let uptime = getDeviceUptimeSeconds(&bootTimestamp)
var state = state
state.applicationActivityTimestamp = MonotonicTimestamp(bootTimestap: bootTimestamp, uptime: uptime)
state.applicationActivityTimestamp = MonotonicTimestamp(bootTimestamp: bootTimestamp, uptime: uptime)
return state
}
}
@ -276,7 +276,7 @@ public final class AppLockContextImpl: AppLockContext {
return self.currentState.get()
|> map { state in
return state.unlockAttemts.flatMap { unlockAttemts in
return AccessChallengeAttempts(count: unlockAttemts.count, timestamp: unlockAttemts.wallClockTimestamp)
return AccessChallengeAttempts(count: unlockAttemts.count, bootTimestamp: unlockAttemts.timestamp.bootTimestamp, uptime: unlockAttemts.timestamp.uptime)
}
}
}
@ -299,7 +299,7 @@ public final class AppLockContextImpl: AppLockContext {
var bootTimestamp: Int32 = 0
let uptime = getDeviceUptimeSeconds(&bootTimestamp)
let timestamp = MonotonicTimestamp(bootTimestap: bootTimestamp, uptime: uptime)
let timestamp = MonotonicTimestamp(bootTimestamp: bootTimestamp, uptime: uptime)
state.applicationActivityTimestamp = timestamp
return state
@ -309,9 +309,15 @@ public final class AppLockContextImpl: AppLockContext {
public func failedUnlockAttempt() {
self.updateLockState { state in
var state = state
var unlockAttemts = state.unlockAttemts ?? UnlockAttempts(count: 0, wallClockTimestamp: 0)
var unlockAttemts = state.unlockAttemts ?? UnlockAttempts(count: 0, timestamp: MonotonicTimestamp(bootTimestamp: 0, uptime: 0))
unlockAttemts.count += 1
unlockAttemts.wallClockTimestamp = Int32(CFAbsoluteTimeGetCurrent())
var bootTimestamp: Int32 = 0
let uptime = getDeviceUptimeSeconds(&bootTimestamp)
let timestamp = MonotonicTimestamp(bootTimestamp: bootTimestamp, uptime: uptime)
unlockAttemts.timestamp = timestamp
state.unlockAttemts = unlockAttemts
return state
}

View File

@ -2,22 +2,22 @@ import Foundation
import MonotonicTime
public struct MonotonicTimestamp: Codable, Equatable {
public var bootTimestap: Int32
public var bootTimestamp: Int32
public var uptime: Int32
public init(bootTimestap: Int32, uptime: Int32) {
self.bootTimestap = bootTimestap
public init(bootTimestamp: Int32, uptime: Int32) {
self.bootTimestamp = bootTimestamp
self.uptime = uptime
}
}
public struct UnlockAttempts: Codable, Equatable {
public var count: Int32
public var wallClockTimestamp: Int32
public var timestamp: MonotonicTimestamp
public init(count: Int32, wallClockTimestamp: Int32) {
public init(count: Int32, timestamp: MonotonicTimestamp) {
self.count = count
self.wallClockTimestamp = wallClockTimestamp
self.timestamp = timestamp
}
}
@ -45,10 +45,10 @@ public func isAppLocked(state: LockState) -> Bool {
} else if let autolockTimeout = state.autolockTimeout {
var bootTimestamp: Int32 = 0
let uptime = getDeviceUptimeSeconds(&bootTimestamp)
let timestamp = MonotonicTimestamp(bootTimestap: bootTimestamp, uptime: uptime)
let timestamp = MonotonicTimestamp(bootTimestamp: bootTimestamp, uptime: uptime)
if let applicationActivityTimestamp = state.applicationActivityTimestamp {
if timestamp.bootTimestap != applicationActivityTimestamp.bootTimestap {
if timestamp.bootTimestamp != applicationActivityTimestamp.bootTimestamp {
return true
}
if timestamp.uptime >= applicationActivityTimestamp.uptime + autolockTimeout {

View File

@ -71,6 +71,8 @@ NS_ASSUME_NONNULL_BEGIN
//! @abstract The range of text currently selected. If length is zero, the range is the cursor location.
@property NSRange selectedRange;
@property (readonly) CGRect selectionRect;
#pragma mark - Placeholder
/**
@abstract Indicates if the receiver is displaying the placeholder text.

View File

@ -566,6 +566,15 @@
_textKitComponents.textView.selectedRange = selectedRange;
}
- (CGRect)selectionRect {
UITextRange *range = [_textKitComponents.textView selectedTextRange];
if (range != nil) {
return [_textKitComponents.textView firstRectForRange:range];
} else {
return [_textKitComponents.textView bounds];
}
}
#pragma mark - Placeholder
- (BOOL)isDisplayingPlaceholder
{

View File

@ -157,7 +157,7 @@ class BotCheckoutHeaderItemNode: ListViewItemNode {
var imageApply: (() -> Void)?
var updatedImageSignal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>?
if let photo = item.invoice.photo, let dimensions = photo.dimensions {
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: dimensions.aspectFilled(imageSize), boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.theme.list.mediaPlaceholderColor)
let arguments = TransformImageArguments(corners: ImageCorners(), imageSize: dimensions.cgSize.aspectFilled(imageSize), boundingSize: imageSize, intrinsicInsets: UIEdgeInsets(), emptyColor: item.theme.list.mediaPlaceholderColor)
imageApply = makeImageLayout(arguments)
maxTextWidth = max(1.0, maxTextWidth - imageSize.width - imageTextSpacing)
if imageUpdated {

View File

@ -109,6 +109,6 @@ public final class ChatListSearchItemHeaderNode: ListViewItemHeaderNode {
override public func animateRemoved(duration: Double) {
self.alpha = 0.0
self.layer.animateAlpha(from: 1.0, to: 0.0, duration: duration, removeOnCompletion: false)
self.layer.animateAlpha(from: 1.0, to: 0.0, duration: duration, removeOnCompletion: true)
}
}

View File

@ -75,6 +75,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
let navigationController: NavigationController?
let passthroughTouches: Bool = true
init(controller: ViewController, sourceNode: ASDisplayNode?, navigationController: NavigationController?) {
self.controller = controller
self.sourceNode = sourceNode
@ -91,6 +93,9 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
}
})
}
func animatedIn() {
}
}
public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate {

View File

@ -1206,9 +1206,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
var dimensions: CGSize?
if let contentImageMedia = contentImageMedia as? TelegramMediaImage {
dimensions = largestRepresentationForPhoto(contentImageMedia)?.dimensions
dimensions = largestRepresentationForPhoto(contentImageMedia)?.dimensions.cgSize
} else if let contentImageMedia = contentImageMedia as? TelegramMediaFile {
dimensions = contentImageMedia.dimensions
dimensions = contentImageMedia.dimensions?.cgSize
}
var contentImageNodeAppeared = false

View File

@ -33,6 +33,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
let navigationController: NavigationController? = nil
let passthroughTouches: Bool = true
init(controller: ViewController, sourceNode: ASDisplayNode?) {
self.controller = controller
self.sourceNode = sourceNode
@ -48,6 +50,9 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
}
})
}
func animatedIn() {
}
}
final class ContactsControllerNode: ASDisplayNode {

View File

@ -211,7 +211,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
if strongSelf.didCompleteAnimationIn {
if !strongSelf.didMoveFromInitialGesturePoint {
let distance = abs(localPoint.y - initialPoint.y)
if distance > 4.0 {
if distance > 12.0 {
strongSelf.didMoveFromInitialGesturePoint = true
}
}
@ -581,6 +581,13 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
self.contentContainerNode.layer.animateSpring(from: min(localSourceFrame.width / self.contentContainerNode.frame.width, localSourceFrame.height / self.contentContainerNode.frame.height) as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: springDuration, initialVelocity: 0.0, damping: springDamping)
switch self.source {
case let .controller(controller):
controller.animatedIn()
default:
break
}
let contentContainerOffset = CGPoint(x: localSourceFrame.center.x - self.contentContainerNode.frame.center.x, y: localSourceFrame.center.y - self.contentContainerNode.frame.center.y)
if let contentNode = self.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
let snapshotView: UIView? = nil// controller.sourceNode.view.snapshotContentTree()
@ -1099,7 +1106,16 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
}
case let .controller(contentParentNode):
let projectedFrame = convertFrame(contentParentNode.sourceNode.bounds, from: contentParentNode.sourceNode.view, to: self.view)
var projectedFrame: CGRect = convertFrame(contentParentNode.sourceNode.bounds, from: contentParentNode.sourceNode.view, to: self.view)
switch self.source {
case let .controller(source):
let transitionInfo = source.transitionInfo()
if let (sourceNode, sourceRect) = transitionInfo?.sourceNode() {
projectedFrame = convertFrame(sourceRect, from: sourceNode.view, to: self.view)
}
default:
break
}
self.originalProjectedContentViewFrame = (projectedFrame, projectedFrame)
if let originalProjectedContentViewFrame = self.originalProjectedContentViewFrame {
@ -1149,8 +1165,9 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
var contentHeight: CGFloat
if case .compact = layout.metrics.widthClass {
if layout.size.width < layout.size.height {
originalActionsFrame = CGRect(origin: CGPoint(x: actionsSideInset, y: min(maximumActionsFrameOrigin, floor((layout.size.height - contentActionsSpacing - contentSize.height) / 2.0) + contentSize.height + contentActionsSpacing)), size: actionsSize)
originalContentFrame = CGRect(origin: CGPoint(x: actionsSideInset, y: originalActionsFrame.minY - contentActionsSpacing - contentSize.height), size: contentSize)
let sideInset = floor((layout.size.width - max(contentSize.width, actionsSize.width)) / 2.0)
originalActionsFrame = CGRect(origin: CGPoint(x: sideInset, y: min(maximumActionsFrameOrigin, floor((layout.size.height - contentActionsSpacing - contentSize.height) / 2.0) + contentSize.height + contentActionsSpacing)), size: actionsSize)
originalContentFrame = CGRect(origin: CGPoint(x: sideInset, y: originalActionsFrame.minY - contentActionsSpacing - contentSize.height), size: contentSize)
if originalContentFrame.minY < topEdge {
let requiredOffset = topEdge - originalContentFrame.minY
let availableOffset = max(0.0, layout.size.height - layout.intrinsicInsets.bottom - actionsBottomInset - originalActionsFrame.maxY)
@ -1271,12 +1288,21 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
}
case let .controller(controller):
let controllerPoint = self.view.convert(point, to: controller.controller.view)
if let result = controller.controller.view.hitTest(controllerPoint, with: event) {
#if DEBUG
//return controller.view
#endif
return result
var passthrough = false
switch self.source {
case let .controller(controllerSource):
passthrough = controllerSource.passthroughTouches
default:
break
}
if passthrough {
let controllerPoint = self.view.convert(point, to: controller.controller.view)
if let result = controller.controller.view.hitTest(controllerPoint, with: event) {
#if DEBUG
//return controller.view
#endif
return result
}
}
}
}
@ -1325,8 +1351,11 @@ public protocol ContextExtractedContentSource: class {
public protocol ContextControllerContentSource: class {
var controller: ViewController { get }
var navigationController: NavigationController? { get }
var passthroughTouches: Bool { get }
func transitionInfo() -> ContextControllerTakeControllerInfo?
func animatedIn()
}
public enum ContextContentSource {

View File

@ -11,6 +11,8 @@ public final class ContextControllerSourceNode: ASDisplayNode {
}
}
public var activated: ((ContextGesture) -> Void)?
public var shouldBegin: ((CGPoint) -> Bool)?
public var customActivationProgress: ((CGFloat, ContextGestureTransition) -> Void)?
override public func didLoad() {
super.didLoad()
@ -19,21 +21,32 @@ public final class ContextControllerSourceNode: ASDisplayNode {
self.contextGesture = contextGesture
self.view.addGestureRecognizer(contextGesture)
contextGesture.shouldBegin = { [weak self] point in
guard let strongSelf = self, !strongSelf.bounds.width.isZero else {
return false
}
return strongSelf.shouldBegin?(point) ?? false
}
contextGesture.activationProgress = { [weak self] progress, update in
guard let strongSelf = self, !strongSelf.bounds.width.isZero else {
return
}
let minScale: CGFloat = (strongSelf.bounds.width - 10.0) / strongSelf.bounds.width
let currentScale = 1.0 * (1.0 - progress) + minScale * progress
switch update {
case .update:
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
case .begin:
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
case let .ended(previousProgress):
let previousScale = 1.0 * (1.0 - previousProgress) + minScale * previousProgress
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
strongSelf.layer.animateSpring(from: previousScale as NSNumber, to: currentScale as NSNumber, keyPath: "sublayerTransform.scale", duration: 0.5, delay: 0.0, initialVelocity: 0.0, damping: 90.0)
if let customActivationProgress = strongSelf.customActivationProgress {
customActivationProgress(progress, update)
} else {
let minScale: CGFloat = (strongSelf.bounds.width - 10.0) / strongSelf.bounds.width
let currentScale = 1.0 * (1.0 - progress) + minScale * progress
switch update {
case .update:
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
case .begin:
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
case let .ended(previousProgress):
let previousScale = 1.0 * (1.0 - previousProgress) + minScale * previousProgress
strongSelf.layer.sublayerTransform = CATransform3DMakeScale(currentScale, currentScale, 1.0)
strongSelf.layer.animateSpring(from: previousScale as NSNumber, to: currentScale as NSNumber, keyPath: "sublayerTransform.scale", duration: 0.5, delay: 0.0, initialVelocity: 0.0, damping: 90.0)
}
}
}
contextGesture.activated = { [weak self] gesture in

View File

@ -56,6 +56,7 @@ public final class ContextGesture: UIGestureRecognizer, UIGestureRecognizerDeleg
private var animator: DisplayLinkAnimator?
private var isValidated: Bool = false
public var shouldBegin: ((CGPoint) -> Bool)?
public var activationProgress: ((CGFloat, ContextGestureTransition) -> Void)?
public var activated: ((ContextGesture) -> Void)?
public var externalUpdated: ((UIView?, CGPoint) -> Void)?
@ -92,6 +93,13 @@ public final class ContextGesture: UIGestureRecognizer, UIGestureRecognizerDeleg
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesBegan(touches, with: event)
if let shouldBegin = self.shouldBegin, let touch = touches.first {
if !shouldBegin(touch.location(in: self.view)) {
self.state = .failed
return
}
}
if self.delayTimer == nil {
let delayTimer = Timer(timeInterval: beginDelay, target: TimerTargetWrapper { [weak self] in
guard let strongSelf = self, let _ = strongSelf.delayTimer else {

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Telegram Messenger LLP. All rights reserved.</string>
</dict>
</plist>

View File

@ -1,9 +0,0 @@
#import <Cocoa/Cocoa.h>
//! Project version number for crc32mac.
FOUNDATION_EXPORT double crc32macVersionNumber;
//! Project version string for crc32mac.
FOUNDATION_EXPORT const unsigned char crc32macVersionString[];
uint32_t Crc32(const void *bytes, int length);

View File

@ -6,7 +6,7 @@ public protocol KeyShortcutResponder {
public class KeyShortcutsController: UIResponder {
private var effectiveShortcuts: [KeyShortcut]?
private var viewControllerEnumerator: ((ContainableController) -> Bool) -> Void
private var viewControllerEnumerator: (@escaping (ContainableController) -> Bool) -> Void
public static var isAvailable: Bool {
if #available(iOSApplicationExtension 8.0, iOS 8.0, *), UIDevice.current.userInterfaceIdiom == .pad {
@ -16,7 +16,7 @@ public class KeyShortcutsController: UIResponder {
}
}
public init(enumerator: @escaping ((ContainableController) -> Bool) -> Void) {
public init(enumerator: @escaping (@escaping (ContainableController) -> Bool) -> Void) {
self.viewControllerEnumerator = enumerator
super.init()
}

View File

@ -249,6 +249,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
public final var generalScrollDirectionUpdated: (GeneralScrollDirection) -> Void = { _ in }
public final var reorderItem: (Int, Int, Any?) -> Signal<Bool, NoError> = { _, _, _ in return .single(false) }
public final var reorderCompleted: (Any?) -> Void = { _ in }
private final var animations: [ListViewAnimation] = []
private final var actionsForVSync: [() -> ()] = []
@ -439,6 +440,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
reorderNode.removeFromSupernode()
}
}
self.reorderCompleted(self.opaqueTransactionState)
}
private func updateReordering(offset: CGFloat) {
@ -2680,6 +2682,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
if highlightedItemNode.index != self.highlightedItemIndex {
highlightedItemNode.setHighlighted(false, at: CGPoint(), animated: false)
self.highlightedItemIndex = nil
self.selectionTouchLocation = nil
}
} else if self.highlightedItemIndex != nil {
self.highlightedItemIndex = nil

View File

@ -899,6 +899,8 @@ public class Window1 {
self.presentationContext.updateToInterfaceOrientation(orientation)
self.overlayPresentationContext.updateToInterfaceOrientation(orientation)
self.topPresentationContext.updateToInterfaceOrientation(orientation)
for controller in self.topLevelOverlayControllers {
controller.updateToInterfaceOrientation(orientation)
}
@ -972,6 +974,8 @@ public class Window1 {
}
self.presentationContext.containerLayoutUpdated(childLayout, transition: updatingLayout.transition)
self.overlayPresentationContext.containerLayoutUpdated(childLayout, transition: updatingLayout.transition)
self.topPresentationContext.containerLayoutUpdated(childLayout, transition: updatingLayout.transition)
for controller in self.topLevelOverlayControllers {
updatingLayout.transition.updateFrame(node: controller.displayNode, frame: CGRect(origin: CGPoint(), size: self.windowLayout.size))
@ -1168,11 +1172,15 @@ public class Window1 {
}
public func forEachViewController(_ f: (ContainableController) -> Bool) {
if let navigationController = self._rootController as? NavigationController, let controller = navigationController.topOverlayController {
!f(controller)
}
for (controller, _) in self.presentationContext.controllers {
if !f(controller) {
break
}
}
for controller in self.topLevelOverlayControllers {
if !f(controller) {
break

View File

@ -55,6 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
- (NSData * _Nullable)rsaEncryptPKCS1OAEPWithPublicKey:(NSString *)publicKey data:(NSData *)data;
- (id<MTRsaPublicKey>)parseRSAPublicKey:(NSString *)publicKey;
-(NSData * _Nonnull)macosRSAEncrypt:(NSString *) publicKey data: (NSData *)data;
@end
NS_ASSUME_NONNULL_END

View File

@ -204,7 +204,7 @@ public func galleryItemForEntry(context: AccountContext, presentationData: Prese
if let file = webpageContent.file, file.isVideo {
content = NativeVideoContent(id: .message(message.stableId, file.fileId), fileReference: .message(message: MessageReference(message), media: file), imageReference: mediaImage.flatMap({ ImageMediaReference.message(message: MessageReference(message), media: $0) }), streamVideo: .conservative, loopVideo: loopVideos, tempFilePath: tempFilePath)
} else if URL(string: embedUrl)?.pathExtension == "mp4" {
content = SystemVideoContent(url: embedUrl, imageReference: .webPage(webPage: WebpageReference(webpage), media: image), dimensions: webpageContent.embedSize ?? CGSize(width: 640.0, height: 640.0), duration: Int32(webpageContent.duration ?? 0))
content = SystemVideoContent(url: embedUrl, imageReference: .webPage(webPage: WebpageReference(webpage), media: image), dimensions: webpageContent.embedSize?.cgSize ?? CGSize(width: 640.0, height: 640.0), duration: Int32(webpageContent.duration ?? 0))
}
}
if content == nil, let webEmbedContent = WebEmbedVideoContent(webPage: webpage, webpageContent: webpageContent, forcedTimestamp: timecode.flatMap(Int.init)) {

View File

@ -60,13 +60,13 @@ final class ChatMediaGalleryThumbnailItem: GalleryThumbnailItem {
switch self.thumbnail {
case let .image(imageReference):
if let representation = largestImageRepresentation(imageReference.media.representations) {
return (mediaGridMessagePhoto(account: self.account, photoReference: imageReference), representation.dimensions)
return (mediaGridMessagePhoto(account: self.account, photoReference: imageReference), representation.dimensions.cgSize)
} else {
return (.single({ _ in return nil }), CGSize(width: 128.0, height: 128.0))
}
case let .video(fileReference):
if let representation = largestImageRepresentation(fileReference.media.previewRepresentations) {
return (mediaGridMessageVideo(postbox: self.account.postbox, videoReference: fileReference), representation.dimensions)
return (mediaGridMessageVideo(postbox: self.account.postbox, videoReference: fileReference), representation.dimensions.cgSize)
} else {
return (.single({ _ in return nil }), CGSize(width: 128.0, height: 128.0))
}
@ -220,10 +220,10 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
fileprivate func setImage(imageReference: ImageMediaReference) {
if self.contextAndMedia == nil || !self.contextAndMedia!.1.media.isEqual(to: imageReference.media) {
if let largestSize = largestRepresentationForPhoto(imageReference.media) {
let displaySize = largestSize.dimensions.fitted(CGSize(width: 1280.0, height: 1280.0)).dividedByScreenScale().integralFloor
let displaySize = largestSize.dimensions.cgSize.fitted(CGSize(width: 1280.0, height: 1280.0)).dividedByScreenScale().integralFloor
self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: displaySize, boundingSize: displaySize, intrinsicInsets: UIEdgeInsets()))()
self.imageNode.setSignal(chatMessagePhoto(postbox: context.account.postbox, photoReference: imageReference), dispatchOnDisplayLink: false)
self.zoomableContent = (largestSize.dimensions, self.imageNode)
self.zoomableContent = (largestSize.dimensions.cgSize, self.imageNode)
self.fetchDisposable.set(fetchedMediaResource(mediaBox: self.context.account.postbox.mediaBox, reference: imageReference.resourceReference(largestSize.resource)).start())
self.setupStatus(resource: largestSize.resource)
@ -237,18 +237,18 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode {
func setFile(context: AccountContext, fileReference: FileMediaReference) {
if self.contextAndMedia == nil || !self.contextAndMedia!.1.media.isEqual(to: fileReference.media) {
if var largestSize = fileReference.media.dimensions {
var displaySize = largestSize.dividedByScreenScale()
var displaySize = largestSize.cgSize.dividedByScreenScale()
if let previewDimensions = largestImageRepresentation(fileReference.media.previewRepresentations)?.dimensions {
let previewAspect = previewDimensions.width / previewDimensions.height
let previewAspect = CGFloat(previewDimensions.width) / CGFloat(previewDimensions.height)
let aspect = displaySize.width / displaySize.height
if abs(previewAspect - 1.0 / aspect) < 0.1 {
displaySize = CGSize(width: displaySize.height, height: displaySize.width)
largestSize = CGSize(width: largestSize.height, height: largestSize.width)
largestSize = PixelDimensions(width: largestSize.height, height: largestSize.width)
}
}
self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: displaySize, boundingSize: displaySize, intrinsicInsets: UIEdgeInsets()))()
self.imageNode.setSignal(chatMessageImageFile(account: context.account, fileReference: fileReference, thumbnail: false), dispatchOnDisplayLink: false)
self.zoomableContent = (largestSize, self.imageNode)
self.zoomableContent = (largestSize.cgSize, self.imageNode)
self.setupStatus(resource: fileReference.media.resource)
} else {
self._ready.set(.single(Void()))

View File

@ -167,6 +167,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
private var pictureInPictureNode: UniversalVideoGalleryItemPictureInPictureNode?
private let statusButtonNode: HighlightableButtonNode
private let statusNode: RadialStatusNode
private var statusNodeShouldBeHidden = true
private var isCentral = false
private var _isVisible: Bool?
@ -463,7 +464,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
}
}
self.statusDisposable.set((combineLatest(videoNode.status, mediaFileStatus)
self.statusDisposable.set((combineLatest(queue: .mainQueue(), videoNode.status, mediaFileStatus)
|> deliverOnMainQueue).start(next: { [weak self] value, fetchStatus in
if let strongSelf = self {
var initialBuffering = false
@ -496,6 +497,13 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
default:
isStreaming = true
}
} else {
switch fetchStatus {
case .Local:
break
default:
isStreaming = true
}
}
if let content = item.content as? NativeVideoContent, !isStreaming {
initialBuffering = false
@ -542,7 +550,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
strongSelf.fetchStatus = fetchStatus
if !item.hideControls {
strongSelf.statusButtonNode.isHidden = strongSelf.hideStatusNodeUntilCentrality || (!initialBuffering && (strongSelf.didPause || !isPaused) && !fetching)
strongSelf.statusNodeShouldBeHidden = (!initialBuffering && (strongSelf.didPause || !isPaused) && !fetching)
strongSelf.statusButtonNode.isHidden = strongSelf.hideStatusNodeUntilCentrality || strongSelf.statusNodeShouldBeHidden
}
if isAnimated || disablePlayerControls {
@ -648,6 +657,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
}
self.hideStatusNodeUntilCentrality = false
self.statusButtonNode.isHidden = self.hideStatusNodeUntilCentrality || self.statusNodeShouldBeHidden
if videoNode.ownsContentNode {
if isAnimated {
videoNode.seek(0.0)
@ -731,6 +741,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
videoNode.play()
} else {
self.hideStatusNodeUntilCentrality = false
self.statusButtonNode.isHidden = self.hideStatusNodeUntilCentrality || self.statusNodeShouldBeHidden
videoNode.playOnceWithSound(playAndRecord: false, seek: seek, actionAtEnd: .stop)
}
}

View File

@ -17,9 +17,9 @@ private struct InstantImageGalleryThumbnailItem: GalleryThumbnailItem {
var image: (Signal<(TransformImageArguments) -> DrawingContext?, NoError>, CGSize) {
if let imageReferene = mediaReference.concrete(TelegramMediaImage.self), let representation = largestImageRepresentation(imageReferene.media.representations) {
return (mediaGridMessagePhoto(account: self.account, photoReference: imageReferene), representation.dimensions)
return (mediaGridMessagePhoto(account: self.account, photoReference: imageReferene), representation.dimensions.cgSize)
} else if let fileReference = mediaReference.concrete(TelegramMediaFile.self), let dimensions = fileReference.media.dimensions {
return (mediaGridMessageVideo(postbox: account.postbox, videoReference: fileReference), dimensions)
return (mediaGridMessageVideo(postbox: account.postbox, videoReference: fileReference), dimensions.cgSize)
} else {
return (.single({ _ in return nil }), CGSize(width: 128.0, height: 128.0))
}
@ -133,10 +133,10 @@ final class InstantImageGalleryItemNode: ZoomableContentGalleryItemNode {
fileprivate func setImage(imageReference: ImageMediaReference) {
if self.contextAndMedia == nil || !self.contextAndMedia!.1.media.isEqual(to: imageReference.media) {
if let largestSize = largestRepresentationForPhoto(imageReference.media) {
let displaySize = largestSize.dimensions.fitted(CGSize(width: 1280.0, height: 1280.0)).dividedByScreenScale().integralFloor
let displaySize = largestSize.dimensions.cgSize.fitted(CGSize(width: 1280.0, height: 1280.0)).dividedByScreenScale().integralFloor
self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: displaySize, boundingSize: displaySize, intrinsicInsets: UIEdgeInsets(), emptyColor: .black))()
self.imageNode.setSignal(chatMessagePhoto(postbox: self.context.account.postbox, photoReference: imageReference), dispatchOnDisplayLink: false)
self.zoomableContent = (largestSize.dimensions, self.imageNode)
self.zoomableContent = (largestSize.dimensions.cgSize, self.imageNode)
self.fetchDisposable.set(fetchedMediaResource(mediaBox: self.context.account.postbox.mediaBox, reference: imageReference.resourceReference(largestSize.resource)).start())
} else {
self._ready.set(.single(Void()))
@ -149,10 +149,10 @@ final class InstantImageGalleryItemNode: ZoomableContentGalleryItemNode {
func setFile(context: AccountContext, fileReference: FileMediaReference) {
if self.contextAndMedia == nil || !self.contextAndMedia!.1.media.isEqual(to: fileReference.media) {
if let largestSize = fileReference.media.dimensions {
let displaySize = largestSize.dividedByScreenScale()
let displaySize = largestSize.cgSize.dividedByScreenScale()
self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: displaySize, boundingSize: displaySize, intrinsicInsets: UIEdgeInsets()))()
self.imageNode.setSignal(chatMessageImageFile(account: context.account, fileReference: fileReference, thumbnail: false), dispatchOnDisplayLink: false)
self.zoomableContent = (largestSize, self.imageNode)
self.zoomableContent = (largestSize.cgSize, self.imageNode)
} else {
self._ready.set(.single(Void()))
}

View File

@ -102,7 +102,7 @@ final class InstantPageArticleNode: ASDisplayNode, InstantPageNode {
self.contentTileNode.frame = self.bounds
if let imageNode = self.imageNode, let image = self.cover, let largest = largestImageRepresentation(image.representations) {
let size = largest.dimensions.aspectFilled(imageSize)
let size = largest.dimensions.cgSize.aspectFilled(imageSize)
let boundingSize = imageSize
let makeLayout = imageNode.asyncLayout()

View File

@ -199,7 +199,7 @@ final class InstantPageImageNode: ASDisplayNode, InstantPageNode {
self.statusNode.frame = CGRect(x: floorToScreenPixels((size.width - radialStatusSize) / 2.0), y: floorToScreenPixels((size.height - radialStatusSize) / 2.0), width: radialStatusSize, height: radialStatusSize)
if let image = self.media.media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
let imageSize = largest.dimensions.aspectFilled(size)
let imageSize = largest.dimensions.cgSize.aspectFilled(size)
let boundingSize = size
let radius: CGFloat = self.roundCorners ? floor(min(imageSize.width, imageSize.height) / 2.0) : 0.0
let makeLayout = self.imageNode.asyncLayout()
@ -210,7 +210,7 @@ final class InstantPageImageNode: ASDisplayNode, InstantPageNode {
} else if let file = self.media.media as? TelegramMediaFile, let dimensions = file.dimensions {
let emptyColor = file.mimeType.hasPrefix("image/") ? self.theme.imageTintColor : nil
let imageSize = dimensions.aspectFilled(size)
let imageSize = dimensions.cgSize.aspectFilled(size)
let boundingSize = size
let makeLayout = self.imageNode.asyncLayout()
let apply = makeLayout(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), emptyColor: emptyColor))
@ -234,7 +234,7 @@ final class InstantPageImageNode: ASDisplayNode, InstantPageNode {
self.pinNode.frame = CGRect(origin: CGPoint(x: floor((size.width - pinSize.width) / 2.0), y: floor(size.height * 0.5 - 10.0 - pinSize.height / 2.0)), size: pinSize)
pinApply()
} else if let webPage = media.media as? TelegramMediaWebpage, case let .Loaded(content) = webPage.content, let image = content.image, let largest = largestImageRepresentation(image.representations) {
let imageSize = largest.dimensions.aspectFilled(size)
let imageSize = largest.dimensions.cgSize.aspectFilled(size)
let boundingSize = size
let radius: CGFloat = self.roundCorners ? floor(min(imageSize.width, imageSize.height) / 2.0) : 0.0
let makeLayout = self.imageNode.asyncLayout()

View File

@ -376,12 +376,12 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
case let .image(id, caption, url, webpageId):
if let image = media[id] as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
let imageSize = largest.dimensions
var filledSize = imageSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
var filledSize = imageSize.cgSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
if let size = fillToSize {
filledSize = size
} else if isCover {
filledSize = imageSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
filledSize = imageSize.cgSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
if !filledSize.height.isZero {
filledSize = filledSize.cropped(CGSize(width: boundingWidth - safeInset * 2.0, height: floor((boundingWidth - safeInset * 2.0) * 3.0 / 5.0)))
}
@ -416,12 +416,12 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
case let .video(id, caption, autoplay, loop):
if let file = media[id] as? TelegramMediaFile, let dimensions = file.dimensions {
let imageSize = dimensions
var filledSize = imageSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
var filledSize = imageSize.cgSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
if let size = fillToSize {
filledSize = size
} else if isCover {
filledSize = imageSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
filledSize = imageSize.cgSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
if !filledSize.height.isZero {
filledSize = filledSize.cropped(CGSize(width: boundingWidth - safeInset * 2.0, height: floor((boundingWidth - safeInset * 2.0) * 3.0 / 5.0)))
}
@ -462,11 +462,11 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
switch subItem {
case let .image(id, _, _, _):
if let image = media[id] as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
size = largest.dimensions
size = largest.dimensions.cgSize
}
case let .video(id, _, _, _):
if let file = media[id] as? TelegramMediaFile, let dimensions = file.dimensions {
size = dimensions
size = dimensions.cgSize
}
default:
break
@ -577,7 +577,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
let mediaIndex = mediaIndexCounter
mediaIndexCounter += 1
let filledSize = imageSize.fitted(CGSize(width: boundingWidth, height: 1200.0))
let filledSize = imageSize.cgSize.fitted(CGSize(width: boundingWidth, height: 1200.0))
contentSize.height = max(contentSize.height, filledSize.height)
var mediaUrl: InstantPageUrlItem?
@ -610,10 +610,10 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
let size: CGSize
if let dimensions = dimensions {
if dimensions.width.isLessThanOrEqualTo(0.0) {
size = CGSize(width: embedBoundingWidth, height: dimensions.height)
if dimensions.width <= 0 {
size = CGSize(width: embedBoundingWidth, height: dimensions.cgSize.height)
} else {
size = dimensions.aspectFitted(CGSize(width: embedBoundingWidth, height: embedBoundingWidth))
size = dimensions.cgSize.aspectFitted(CGSize(width: embedBoundingWidth, height: embedBoundingWidth))
}
} else {
if let height = webEmbedHeights[embedIndex] {
@ -628,7 +628,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
let frame = CGRect(origin: CGPoint(x: floor((boundingWidth - size.width) / 2.0), y: 0.0), size: size)
let item: InstantPageItem
if let url = url, let coverId = coverId, let image = media[coverId] as? TelegramMediaImage {
let loadedContent = TelegramMediaWebpageLoadedContent(url: url, displayUrl: url, hash: 0, type: "video", websiteName: nil, title: nil, text: nil, embedUrl: url, embedType: "video", embedSize: size, duration: nil, author: nil, image: image, file: nil, files: nil, instantPage: nil)
let loadedContent = TelegramMediaWebpageLoadedContent(url: url, displayUrl: url, hash: 0, type: "video", websiteName: nil, title: nil, text: nil, embedUrl: url, embedType: "video", embedSize: PixelDimensions(size), duration: nil, author: nil, image: image, file: nil, files: nil, instantPage: nil)
let content = TelegramMediaWebpageContent.Loaded(loadedContent)
item = InstantPageImageItem(frame: frame, webPage: webpage, media: InstantPageMedia(index: embedIndex, media: TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: -1), content: content), url: nil, caption: nil, credit: nil), attributes: [], interactive: true, roundCorners: false, fit: false)
@ -805,19 +805,19 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins
return InstantPageLayout(origin: CGPoint(), contentSize: contentSize, items: items)
case let .map(latitude, longitude, zoom, dimensions, caption):
let imageSize = dimensions
var filledSize = imageSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
var filledSize = imageSize.cgSize.aspectFitted(CGSize(width: boundingWidth - safeInset * 2.0, height: 1200.0))
if let size = fillToSize {
filledSize = size
} else if isCover {
filledSize = imageSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
filledSize = imageSize.cgSize.aspectFilled(CGSize(width: boundingWidth - safeInset * 2.0, height: 1.0))
if !filledSize.height.isZero {
filledSize = filledSize.cropped(CGSize(width: boundingWidth - safeInset * 2.0, height: floor((boundingWidth - safeInset * 2.0) * 3.0 / 5.0)))
}
}
let map = TelegramMediaMap(latitude: latitude, longitude: longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)
let attributes: [InstantPageImageAttribute] = [InstantPageMapAttribute(zoom: zoom, dimensions: dimensions)]
let attributes: [InstantPageImageAttribute] = [InstantPageMapAttribute(zoom: zoom, dimensions: dimensions.cgSize)]
var contentSize = CGSize(width: boundingWidth - safeInset * 2.0, height: 0.0)
var items: [InstantPageItem] = []

View File

@ -520,10 +520,10 @@ func attributedStringForRichText(_ text: RichText, styleStack: InstantPageTextSt
}
var dimensions = dimensions
if let boundingWidth = boundingWidth {
dimensions = dimensions.fittedToWidthOrSmaller(boundingWidth)
dimensions = PixelDimensions(dimensions.cgSize.fittedToWidthOrSmaller(boundingWidth))
}
let extentBuffer = UnsafeMutablePointer<RunStruct>.allocate(capacity: 1)
extentBuffer.initialize(to: RunStruct(ascent: 0.0, descent: 0.0, width: dimensions.width))
extentBuffer.initialize(to: RunStruct(ascent: 0.0, descent: 0.0, width: dimensions.cgSize.width))
var callbacks = CTRunDelegateCallbacks(version: kCTRunDelegateVersion1, dealloc: { (pointer) in
}, getAscent: { (pointer) -> CGFloat in
let d = pointer.assumingMemoryBound(to: RunStruct.self)

View File

@ -388,7 +388,7 @@ class ItemListStickerPackItemNode: ItemListRevealOptionsItemNode {
if let thumbnailItem = thumbnailItem {
switch thumbnailItem {
case let .still(representation):
let stillImageSize = representation.dimensions.aspectFitted(imageBoundingSize)
let stillImageSize = representation.dimensions.cgSize.aspectFitted(imageBoundingSize)
imageSize = stillImageSize
if fileUpdated {

View File

@ -209,6 +209,19 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
}
}
public func setReorderCompleted<T: ItemListNodeEntry>(_ f: @escaping ([T]) -> Void) {
self.reorderCompleted = { list in
f(list.map { $0 as! T })
}
}
private var reorderCompleted: (([ItemListNodeAnyEntry]) -> Void)? {
didSet {
if self.isNodeLoaded {
(self.displayNode as! ItemListControllerNode).reorderCompleted = self.reorderCompleted
}
}
}
public var previewItemWithTag: ((ItemListItemTag) -> UIViewController?)?
public var commitPreview: ((UIViewController) -> Void)?
@ -431,6 +444,7 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
displayNode.contentScrollingEnded = self.contentScrollingEnded
displayNode.searchActivated = self.searchActivated
displayNode.reorderEntry = self.reorderEntry
displayNode.reorderCompleted = self.reorderCompleted
displayNode.listNode.experimentalSnapScrollToItem = self.experimentalSnapScrollToItem
displayNode.requestLayout = { [weak self] transition in
self?.requestLayout(transition: transition)

View File

@ -216,6 +216,7 @@ open class ItemListControllerNode: ASDisplayNode, UIScrollViewDelegate {
public var contentScrollingEnded: ((ListView) -> Bool)?
public var searchActivated: ((Bool) -> Void)?
public var reorderEntry: ((Int, Int, [ItemListNodeAnyEntry]) -> Void)?
public var reorderCompleted: (([ItemListNodeAnyEntry]) -> Void)?
public var requestLayout: ((ContainedViewLayoutTransition) -> Void)?
public var enableInteractiveDismiss = false {
@ -272,6 +273,12 @@ open class ItemListControllerNode: ASDisplayNode, UIScrollViewDelegate {
return .single(false)
}
self.listNode.reorderCompleted = { [weak self] opaqueTransactionState in
if let strongSelf = self, let reorderCompleted = strongSelf.reorderCompleted, let mergedEntries = (opaqueTransactionState as? ItemListNodeOpaqueState)?.mergedEntries {
reorderCompleted(mergedEntries)
}
}
self.listNode.visibleBottomContentOffsetChanged = { [weak self] offset in
self?.visibleBottomContentOffsetChanged?(offset)
}

View File

@ -6,6 +6,7 @@
@interface TGAttachmentAssetCell ()
{
SMetaDisposable *_itemSelectedDisposable;
bool _ignoreSetSelected;
}
@end
@ -126,14 +127,16 @@
- (void)checkButtonPressed
{
[_checkButton setSelected:!_checkButton.selected animated:true];
_ignoreSetSelected = true;
[self.selectionContext setItem:(id<TGMediaSelectableItem>)self.asset selected:_checkButton.selected animated:false sender:_checkButton];
[self.selectionContext setItem:(id<TGMediaSelectableItem>)self.asset selected:!_checkButton.selected animated:true sender:_checkButton];
bool value = [self.selectionContext isItemSelected:(id<TGMediaSelectableItem>)self.asset];
if (value != _checkButton.selected) {
[_checkButton setSelected:value animated:false];
[_checkButton setSelected:value animated:true];
}
_ignoreSetSelected = false;
}
- (void)setChecked:(bool)checked animated:(bool)animated

View File

@ -483,7 +483,7 @@ static CGAffineTransform TGCheckButtonDefaultTransform;
{
_numberLabel = [[UILabel alloc] init];
_numberLabel.backgroundColor = [UIColor clearColor];
_numberLabel.frame = CGRectMake(0.0f, -TGScreenPixel, _wrapperView.frame.size.width, _wrapperView.frame.size.height);
_numberLabel.frame = CGRectMake(0.0f, -TGScreenPixel, _wrapperView.bounds.size.width, _wrapperView.bounds.size.height);
_numberLabel.textColor = _checkColor;
_numberLabel.textAlignment = NSTextAlignmentCenter;
_numberLabel.userInteractionEnabled = false;

View File

@ -257,10 +257,7 @@
{
if (![[[LegacyComponentsGlobals provider] accessChecker] checkCameraAuthorizationStatusForIntent:TGCameraAccessIntentDefault alertDismissCompletion:nil])
return;
if ([_context currentlyInSplitView])
return;
if ([TGCameraController useLegacyCamera])
{
[self _displayLegacyCamera];

View File

@ -96,8 +96,7 @@
- (void)checkButtonPressed
{
[_checkButton setSelected:!_checkButton.selected animated:true];
[self.selectionContext setItem:(id<TGMediaSelectableItem>)self.item selected:_checkButton.selected animated:false sender:_checkButton];
[self.selectionContext setItem:(id<TGMediaSelectableItem>)self.item selected:!_checkButton.selected animated:false sender:_checkButton];
bool value = [self.selectionContext isItemSelected:(id<TGMediaSelectableItem>)self.item];
if (value != _checkButton.selected) {
[_checkButton setSelected:value animated:true];

View File

@ -264,6 +264,10 @@
- (void)_adjustContentOffsetToBottom
{
if (!self.isViewLoaded) {
return;
}
UIEdgeInsets contentInset = [self controllerInsetForInterfaceOrientation:self.interfaceOrientation];
bool hasOnScreenNavigation = false;
@ -308,6 +312,9 @@
_collectionViewWidth = frame.size.width;
_collectionView.frame = frame;
[_collectionView.collectionViewLayout invalidateLayout];
[_collectionView layoutSubviews];
if (lastInverseOffset < 45)
{
[self _adjustContentOffsetToBottom];
@ -319,9 +326,6 @@
CGPoint contentOffset = CGPointMake(0, -contentInset.top);
[_collectionView setContentOffset:contentOffset animated:false];
}
[_collectionView.collectionViewLayout invalidateLayout];
[_collectionView layoutSubviews];
}
#pragma mark - Gallery

View File

@ -64,6 +64,7 @@
TGModernButton *_muteButton;
TGCheckButtonView *_checkButton;
bool _ignoreSetSelected;
TGMediaPickerPhotoCounterButton *_photoCounterButton;
TGMediaPickerGroupButton *_groupButton;
TGMediaPickerCameraButton *_cameraButton;
@ -531,7 +532,9 @@
if ([_currentItem conformsToProtocol:@protocol(TGModernGallerySelectableItem)])
selectableItem = ((id<TGModernGallerySelectableItem>)_currentItem).selectableMediaItem;
[_checkButton setSelected:[_selectionContext isItemSelected:selectableItem] animated:false];
if (!_ignoreSetSelected) {
[_checkButton setSelected:[_selectionContext isItemSelected:selectableItem] animated:false];
}
[_checkButton setNumber:[_selectionContext indexOfItem:selectableItem]];
signal = [_selectionContext itemInformativeSelectedSignal:selectableItem];
[_itemSelectedDisposable setDisposable:[signal startWithNext:^(TGMediaSelectionChange *next)
@ -669,15 +672,17 @@
if ([_currentItem conformsToProtocol:@protocol(TGModernGallerySelectableItem)])
selectableItem = ((id<TGModernGallerySelectableItem>)_currentItem).selectableMediaItem;
[_checkButton setSelected:!_checkButton.selected animated:true];
_ignoreSetSelected = true;
if (selectableItem != nil) {
[_selectionContext setItem:selectableItem selected:_checkButton.selected animated:animated sender:_checkButton];
[_selectionContext setItem:selectableItem selected:!_checkButton.selected animated:animated sender:_checkButton];
bool value = [_selectionContext isItemSelected:selectableItem];
if (value != _checkButton.selected) {
[_checkButton setSelected:value animated:true];
}
[_checkButton setSelected:value animated:true];
} else {
[_checkButton setSelected:!_checkButton.selected animated:true];
}
_ignoreSetSelected = false;
}
- (void)photoCounterButtonPressed

View File

@ -405,7 +405,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
if let resourcePath = resourcePath, let image = UIImage(contentsOfFile: resourcePath) {
dimensions = image.size
}
representations.append(TelegramMediaImageRepresentation(dimensions: dimensions, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(dimensions), resource: resource))
}
}
@ -414,7 +414,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
if let image = UIImage(contentsOfFile: fullSizePath) {
let resource: TelegramMediaResource = LocalFileMediaResource(fileId: arc4random64())
copyLocalFiles.append((resource, fullSizePath))
representations.append(TelegramMediaImageRepresentation(dimensions: image.size, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(image.size), resource: resource))
}
}
@ -431,14 +431,14 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
} else if imageUrl.hasPrefix("file://"), let path = URL(string: imageUrl)?.path {
copyLocalFiles.append((resource, path))
}
representations.append(TelegramMediaImageRepresentation(dimensions: sizeValue.cgSizeValue, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(sizeValue.cgSizeValue), resource: resource))
}
}
var resource: TelegramMediaResource = LocalFileMediaResource(fileId: arc4random64())
var attributes: [TelegramMediaFileAttribute] = []
attributes.append(.Video(duration: Int(item.duration), size: item.dimensions, flags: item.roundMessage ? .instantRoundVideo : []))
attributes.append(.Video(duration: Int(item.duration), size: PixelDimensions(item.dimensions), flags: item.roundMessage ? .instantRoundVideo : []))
var size: Int32 = 0
if let videoUrl = item.videoInfo?.url(withQuality: 1, actualQuality: nil, actualSize: &size) {
@ -488,7 +488,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
resource = updatedResource
copyLocalFiles.append((resource, pathFromLegacyImageUrl(basePath: basePath, url: imageUrl)))
}
representations.append(TelegramMediaImageRepresentation(dimensions: sizeValue.cgSizeValue, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(sizeValue.cgSizeValue), resource: resource))
}
}
@ -512,7 +512,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
} else if let _ = attribute as? TGDocumentAttributeAnimated {
attributes.append(.Animated)
} else if let attribute = attribute as? TGDocumentAttributeVideo {
attributes.append(.Video(duration: Int(attribute.duration), size: attribute.size, flags: attribute.isRoundMessage ? .instantRoundVideo : []))
attributes.append(.Video(duration: Int(attribute.duration), size: PixelDimensions(attribute.size), flags: attribute.isRoundMessage ? .instantRoundVideo : []))
} else if let attribute = attribute as? TGDocumentAttributeSticker {
var packReference: StickerPackReference?
if let reference = attribute.packReference as? TGStickerPackIdReference {
@ -522,7 +522,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc
}
attributes.append(.Sticker(displayText: attribute.alt ?? "", packReference: packReference, maskData: nil))
} else if let attribute = attribute as? TGDocumentAttributeImageSize {
attributes.append(.ImageSize(size: attribute.size))
attributes.append(.ImageSize(size: PixelDimensions(attribute.size)))
}
}
}

View File

@ -18,10 +18,10 @@ func loadLegacyUser(database: SqliteInterface, id: Int32) -> (TelegramUser, Tele
let photoBig = cursor.getString(at: 6)
var photo: [TelegramMediaImageRepresentation] = []
if let resource = resourceFromLegacyImageUrl(photoSmall) {
photo.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 80.0, height: 80.0), resource: resource))
photo.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 80, height: 80), resource: resource))
}
if let resource = resourceFromLegacyImageUrl(photoBig) {
photo.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 600.0, height: 600.0), resource: resource))
photo.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 600, height: 600), resource: resource))
}
let user = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: cursor.getInt32(at: 0)), accessHash: accessHash == 0 ? nil : .personal(accessHash), firstName: firstName.isEmpty ? nil : firstName, lastName: lastName.isEmpty ? nil : lastName, username: username.isEmpty ? nil : username, phone: phone.isEmpty ? nil : phone, photo: photo, botInfo: nil, restrictionInfo: nil, flags: [])

View File

@ -238,7 +238,7 @@ public func legacyEnqueueGifMessage(account: Account, data: Data) -> Signal<Enqu
if let thumbnailData = thumbnailImage.jpegData(compressionQuality: 0.4) {
let resource = LocalFileMediaResource(fileId: arc4random64())
account.postbox.mediaBox.storeResourceData(resource.id, data: thumbnailData)
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: thumbnailSize, resource: resource))
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(thumbnailSize), resource: resource))
}
var randomId: Int64 = 0
@ -254,7 +254,7 @@ public func legacyEnqueueGifMessage(account: Account, data: Data) -> Signal<Enqu
let finalDimensions = TGMediaVideoConverter.dimensions(for: dimensions, adjustments: nil, preset: TGMediaVideoConversionPresetAnimation)
var fileAttributes: [TelegramMediaFileAttribute] = []
fileAttributes.append(.Video(duration: Int(0), size: finalDimensions, flags: [.supportsStreaming]))
fileAttributes.append(.Video(duration: Int(0), size: PixelDimensions(finalDimensions), flags: [.supportsStreaming]))
fileAttributes.append(.FileName(fileName: fileName))
fileAttributes.append(.Animated)
@ -285,7 +285,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
let thumbnailImage = TGScaleImageToPixelSize(thumbnail, thumbnailSize)!
if let thumbnailData = thumbnailImage.jpegData(compressionQuality: 0.4) {
account.postbox.mediaBox.storeResourceData(resource.id, data: thumbnailData)
representations.append(TelegramMediaImageRepresentation(dimensions: thumbnailSize, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(thumbnailSize), resource: resource))
}
}
switch data {
@ -316,7 +316,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
#endif
let resource = LocalFileReferenceMediaResource(localFilePath: tempFilePath, randomId: randomId)
representations.append(TelegramMediaImageRepresentation(dimensions: scaledSize, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(scaledSize), resource: resource))
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil)
var attributes: [MessageAttribute] = []
@ -334,7 +334,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
let size = CGSize(width: CGFloat(asset.pixelWidth), height: CGFloat(asset.pixelHeight))
let scaledSize = size.aspectFittedOrSmaller(CGSize(width: 1280.0, height: 1280.0))
let resource = PhotoLibraryMediaResource(localIdentifier: asset.localIdentifier, uniqueId: arc4random64())
representations.append(TelegramMediaImageRepresentation(dimensions: scaledSize, resource: resource))
representations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(scaledSize), resource: resource))
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: representations, immediateThumbnailData: nil, reference: nil, partialReference: nil)
var attributes: [MessageAttribute] = []
@ -385,7 +385,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
let thumbnailImage = TGScaleImageToPixelSize(thumbnail, thumbnailSize)!
if let thumbnailData = thumbnailImage.jpegData(compressionQuality: 0.4) {
account.postbox.mediaBox.storeResourceData(resource.id, data: thumbnailData)
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: thumbnailSize, resource: resource))
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(thumbnailSize), resource: resource))
}
}
@ -431,7 +431,7 @@ public func legacyAssetPickerEnqueueMessages(account: Account, signals: [Any]) -
fileAttributes.append(.Animated)
}
if !asFile {
fileAttributes.append(.Video(duration: Int(finalDuration), size: finalDimensions, flags: [.supportsStreaming]))
fileAttributes.append(.Video(duration: Int(finalDuration), size: PixelDimensions(finalDimensions), flags: [.supportsStreaming]))
if let adjustments = adjustments {
if adjustments.sendAsGif {
fileAttributes.append(.Animated)

View File

@ -66,7 +66,7 @@ func legacyComponentsStickers(postbox: Postbox, namespace: Int32) -> SSignal {
let encoder = PostboxEncoder()
encoder.encodeRootObject(thumbnail.resource)
let dataString = encoder.makeData().base64EncodedString(options: [])
imageInfo.addImage(with: thumbnail.dimensions, url: dataString)
imageInfo.addImage(with: thumbnail.dimensions.cgSize, url: dataString)
document.thumbnailInfo = imageInfo
}
var attributes: [Any] = []
@ -77,7 +77,7 @@ func legacyComponentsStickers(postbox: Postbox, namespace: Int32) -> SSignal {
return TGStickerMaskDescription(n: $0.n, point: CGPoint(x: CGFloat($0.x), y: CGFloat($0.y)), zoom: CGFloat($0.zoom))
}))
case let .ImageSize(size):
attributes.append(TGDocumentAttributeImageSize(size: size))
attributes.append(TGDocumentAttributeImageSize(size: size.cgSize))
default:
break
}
@ -198,7 +198,7 @@ final class LegacyStickerImageDataSource: TGImageDataSource {
var previewRepresentations: [TelegramMediaImageRepresentation] = []
if let legacyThumbnailUri = args["legacyThumbnailUri"] as? String, let data = Data(base64Encoded: legacyThumbnailUri, options: []) {
if let resource = PostboxDecoder(buffer: MemoryBuffer(data: data)).decodeRootObject() as? TelegramMediaResource {
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 140.0, height: 140.0), resource: resource))
previewRepresentations.append(TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 140, height: 140), resource: resource))
}
}

View File

@ -4,7 +4,6 @@ import SwiftSignalKit
import Postbox
import TelegramCore
import SyncCore
import SyncCore
import Display
public func mapResourceToAvatarSizes(postbox: Postbox, resource: MediaResource, representations: [TelegramMediaImageRepresentation]) -> Signal<[Int: Data], NoError> {
@ -16,7 +15,7 @@ public func mapResourceToAvatarSizes(postbox: Postbox, resource: MediaResource,
}
var result: [Int: Data] = [:]
for i in 0 ..< representations.count {
if let scaledImage = generateScaledImage(image: image, size: representations[i].dimensions, scale: 1.0), let scaledData = scaledImage.jpegData(compressionQuality: 0.8) {
if let scaledImage = generateScaledImage(image: image, size: representations[i].dimensions.cgSize, scale: 1.0), let scaledData = scaledImage.jpegData(compressionQuality: 0.8) {
result[i] = scaledData
}
}

View File

@ -335,6 +335,8 @@ private final class AudioPlayerRendererContext {
assert(audioPlayerRendererQueue.isCurrent())
if self.audioGraph == nil {
let startTime = CFAbsoluteTimeGetCurrent()
var maybeAudioGraph: AUGraph?
guard NewAUGraph(&maybeAudioGraph) == noErr, let audioGraph = maybeAudioGraph else {
return
@ -428,6 +430,8 @@ private final class AudioPlayerRendererContext {
return
}
print("MediaPlayerAudioRenderer initialize audio unit: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
self.audioGraph = audioGraph
self.timePitchAudioUnit = timePitchAudioUnit
self.outputAudioUnit = outputAudioUnit
@ -497,10 +501,14 @@ private final class AudioPlayerRendererContext {
assert(audioPlayerRendererQueue.isCurrent())
if let audioGraph = self.audioGraph {
let startTime = CFAbsoluteTimeGetCurrent()
guard AUGraphStart(audioGraph) == noErr else {
self.closeAudioUnit()
return
}
print("MediaPlayerAudioRenderer start audio unit: \((CFAbsoluteTimeGetCurrent() - startTime) * 1000.0) ms")
}
}

View File

@ -847,8 +847,8 @@ public final class MediaPlayerScrubbingNode: ASDisplayNode {
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
switch self.contentNodes {
case let .standard(node):
if let handleNodeContainer = node.handleNodeContainer, handleNodeContainer.isUserInteractionEnabled, handleNodeContainer.frame.insetBy(dx: 0.0, dy: -5.0).contains(point) {
if let handleNode = node.handleNode, handleNode.convert(handleNode.bounds, to: self).insetBy(dx: -16.0, dy: -16.0).contains(point) {
if let handleNodeContainer = node.handleNodeContainer, handleNodeContainer.isUserInteractionEnabled, handleNodeContainer.frame.insetBy(dx: 0.0, dy: -16.0).contains(point) {
if let handleNode = node.handleNode, handleNode.convert(handleNode.bounds, to: self).insetBy(dx: -32.0, dy: -16.0).contains(point) {
return handleNodeContainer.view
} else {
return nil

View File

@ -1,12 +1,7 @@
#import <Foundation/Foundation.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTEncryption.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTEncryption.h>
#else
# import <MtProtoKit/MTEncryption.h>
#endif
#import <MtProtoKit/MTEncryption.h>
void MyAesIgeEncrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv);
void MyAesIgeDecrypt(const void *inBytes, int length, void *outBytes, const void *key, int keyLength, void *iv);

View File

@ -1,48 +1,18 @@
#import "MTBackupAddressSignals.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTSignal.h>
# import <MTProtoKitDynamic/MTQueue.h>
# import <MTProtoKitDynamic/MTHttpRequestOperation.h>
# import <MTProtoKitDynamic/MTEncryption.h>
# import <MTProtoKitDynamic/MTRequestMessageService.h>
# import <MTProtoKitDynamic/MTRequest.h>
# import <MTProtoKitDynamic/MTContext.h>
# import <MTProtoKitDynamic/MTApiEnvironment.h>
# import <MTProtoKitDynamic/MTDatacenterAddress.h>
# import <MTProtoKitDynamic/MTDatacenterAddressSet.h>
# import <MTProtoKitDynamic/MTProto.h>
# import <MTProtoKitDynamic/MTSerialization.h>
# import <MTProtoKitDynamic/MTLogging.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTSignal.h>
# import <MTProtoKitMac/MTQueue.h>
# import <MTProtoKitMac/MTHttpRequestOperation.h>
# import <MTProtoKitMac/MTEncryption.h>
# import <MTProtoKitMac/MTRequestMessageService.h>
# import <MTProtoKitMac/MTRequest.h>
# import <MTProtoKitMac/MTContext.h>
# import <MTProtoKitMac/MTApiEnvironment.h>
# import <MTProtoKitMac/MTDatacenterAddress.h>
# import <MTProtoKitMac/MTDatacenterAddressSet.h>
# import <MTProtoKitMac/MTProto.h>
# import <MTProtoKitMac/MTSerialization.h>
# import <MTProtoKitMac/MTLogging.h>
#else
# import <MtProtoKit/MTSignal.h>
# import <MtProtoKit/MTQueue.h>
# import <MtProtoKit/MTHttpRequestOperation.h>
# import <MtProtoKit/MTEncryption.h>
# import <MtProtoKit/MTRequestMessageService.h>
# import <MtProtoKit/MTRequest.h>
# import <MtProtoKit/MTContext.h>
# import <MtProtoKit/MTApiEnvironment.h>
# import <MtProtoKit/MTDatacenterAddress.h>
# import <MtProtoKit/MTDatacenterAddressSet.h>
# import <MtProtoKit/MTProto.h>
# import <MtProtoKit/MTSerialization.h>
# import <MtProtoKit/MTLogging.h>
#endif
#import <MtProtoKit/MTSignal.h>
#import <MtProtoKit/MTQueue.h>
#import <MtProtoKit/MTHttpRequestOperation.h>
#import <MtProtoKit/MTEncryption.h>
#import <MtProtoKit/MTRequestMessageService.h>
#import <MtProtoKit/MTRequest.h>
#import <MtProtoKit/MTContext.h>
#import <MtProtoKit/MTApiEnvironment.h>
#import <MtProtoKit/MTDatacenterAddress.h>
#import <MtProtoKit/MTDatacenterAddressSet.h>
#import <MtProtoKit/MTProto.h>
#import <MtProtoKit/MTSerialization.h>
#import <MtProtoKit/MTLogging.h>
static NSData *base64_decode(NSString *str) {
if ([NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)]) {

View File

@ -1,54 +1,20 @@
#import "MTConnectionProbing.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTSignal.h>
# import <MTProtoKitDynamic/MTQueue.h>
# import <MTProtoKitDynamic/MTAtomic.h>
# import <MTProtoKitDynamic/MTHttpRequestOperation.h>
# import <MTProtoKitDynamic/MTEncryption.h>
# import <MTProtoKitDynamic/MTRequestMessageService.h>
# import <MTProtoKitDynamic/MTRequest.h>
# import <MTProtoKitDynamic/MTContext.h>
# import <MTProtoKitDynamic/MTApiEnvironment.h>
# import <MTProtoKitDynamic/MTDatacenterAddress.h>
# import <MTProtoKitDynamic/MTDatacenterAddressSet.h>
# import <MTProtoKitDynamic/MTProto.h>
# import <MTProtoKitDynamic/MTSerialization.h>
# import <MTProtoKitDynamic/MTLogging.h>
# import <MTProtoKitDynamic/MTProxyConnectivity.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTSignal.h>
# import <MTProtoKitMac/MTQueue.h>
# import <MTProtoKitMac/MTAtomic.h>
# import <MTProtoKitMac/MTHttpRequestOperation.h>
# import <MTProtoKitMac/MTEncryption.h>
# import <MTProtoKitMac/MTRequestMessageService.h>
# import <MTProtoKitMac/MTRequest.h>
# import <MTProtoKitMac/MTContext.h>
# import <MTProtoKitMac/MTApiEnvironment.h>
# import <MTProtoKitMac/MTDatacenterAddress.h>
# import <MTProtoKitMac/MTDatacenterAddressSet.h>
# import <MTProtoKitMac/MTProto.h>
# import <MTProtoKitMac/MTSerialization.h>
# import <MTProtoKitMac/MTLogging.h>
# import <MTProtoKitMac/MTProxyConnectivity.h>
#else
# import <MtProtoKit/MTSignal.h>
# import <MtProtoKit/MTQueue.h>
# import <MtProtoKit/MTAtomic.h>
# import <MtProtoKit/MTHttpRequestOperation.h>
# import <MtProtoKit/MTEncryption.h>
# import <MtProtoKit/MTRequestMessageService.h>
# import <MtProtoKit/MTRequest.h>
# import <MtProtoKit/MTContext.h>
# import <MtProtoKit/MTApiEnvironment.h>
# import <MtProtoKit/MTDatacenterAddress.h>
# import <MtProtoKit/MTDatacenterAddressSet.h>
# import <MtProtoKit/MTProto.h>
# import <MtProtoKit/MTSerialization.h>
# import <MtProtoKit/MTLogging.h>
# import <MtProtoKit/MTProxyConnectivity.h>
#endif
#import <MtProtoKit/MTSignal.h>
#import <MtProtoKit/MTQueue.h>
#import <MtProtoKit/MTAtomic.h>
#import <MtProtoKit/MTHttpRequestOperation.h>
#import <MtProtoKit/MTEncryption.h>
#import <MtProtoKit/MTRequestMessageService.h>
#import <MtProtoKit/MTRequest.h>
#import <MtProtoKit/MTContext.h>
#import <MtProtoKit/MTApiEnvironment.h>
#import <MtProtoKit/MTDatacenterAddress.h>
#import <MtProtoKit/MTDatacenterAddressSet.h>
#import <MtProtoKit/MTProto.h>
#import <MtProtoKit/MTSerialization.h>
#import <MtProtoKit/MTLogging.h>
#import <MtProtoKit/MTProxyConnectivity.h>
#import "PingFoundation.h"

View File

@ -8,55 +8,21 @@
#import <netinet/in.h>
#import <net/if.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTQueue.h>
# import <MTProtoKitDynamic/MTSignal.h>
# import <MTProtoKitDynamic/MTBag.h>
# import <MTProtoKitDynamic/MTAtomic.h>
# import <MTProtoKitDynamic/MTHttpRequestOperation.h>
# import <MTProtoKitDynamic/MTEncryption.h>
# import <MTProtoKitDynamic/MTRequestMessageService.h>
# import <MTProtoKitDynamic/MTRequest.h>
# import <MTProtoKitDynamic/MTContext.h>
# import <MTProtoKitDynamic/MTApiEnvironment.h>
# import <MTProtoKitDynamic/MTDatacenterAddress.h>
# import <MTProtoKitDynamic/MTDatacenterAddressSet.h>
# import <MTProtoKitDynamic/MTProto.h>
# import <MTProtoKitDynamic/MTSerialization.h>
# import <MTProtoKitDynamic/MTLogging.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTQueue.h>
# import <MTProtoKitMac/MTSignal.h>
# import <MTProtoKitMac/MTBag.h>
# import <MTProtoKitMac/MTAtomic.h>
# import <MTProtoKitMac/MTHttpRequestOperation.h>
# import <MTProtoKitMac/MTEncryption.h>
# import <MTProtoKitMac/MTRequestMessageService.h>
# import <MTProtoKitMac/MTRequest.h>
# import <MTProtoKitMac/MTContext.h>
# import <MTProtoKitMac/MTApiEnvironment.h>
# import <MTProtoKitMac/MTDatacenterAddress.h>
# import <MTProtoKitMac/MTDatacenterAddressSet.h>
# import <MTProtoKitMac/MTProto.h>
# import <MTProtoKitMac/MTSerialization.h>
# import <MTProtoKitMac/MTLogging.h>
#else
# import <MtProtoKit/MTQueue.h>
# import <MtProtoKit/MTSignal.h>
# import <MtProtoKit/MTBag.h>
# import <MtProtoKit/MTAtomic.h>
# import <MtProtoKit/MTHttpRequestOperation.h>
# import <MtProtoKit/MTEncryption.h>
# import <MtProtoKit/MTRequestMessageService.h>
# import <MtProtoKit/MTRequest.h>
# import <MtProtoKit/MTContext.h>
# import <MtProtoKit/MTApiEnvironment.h>
# import <MtProtoKit/MTDatacenterAddress.h>
# import <MtProtoKit/MTDatacenterAddressSet.h>
# import <MtProtoKit/MTProto.h>
# import <MtProtoKit/MTSerialization.h>
# import <MtProtoKit/MTLogging.h>
#endif
#import <MtProtoKit/MTQueue.h>
#import <MtProtoKit/MTSignal.h>
#import <MtProtoKit/MTBag.h>
#import <MtProtoKit/MTAtomic.h>
#import <MtProtoKit/MTHttpRequestOperation.h>
#import <MtProtoKit/MTEncryption.h>
#import <MtProtoKit/MTRequestMessageService.h>
#import <MtProtoKit/MTRequest.h>
#import <MtProtoKit/MTContext.h>
#import <MtProtoKit/MTApiEnvironment.h>
#import <MtProtoKit/MTDatacenterAddress.h>
#import <MtProtoKit/MTDatacenterAddressSet.h>
#import <MtProtoKit/MTProto.h>
#import <MtProtoKit/MTSerialization.h>
#import <MtProtoKit/MTLogging.h>
#import <netinet/in.h>
#import <arpa/inet.h>

View File

@ -3,25 +3,11 @@
#include <sys/mman.h>
#import <libkern/OSAtomic.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTNetworkUsageCalculationInfo.h>
# import <MTProtoKitDynamic/MTSignal.h>
# import <MTProtoKitDynamic/MTTimer.h>
# import <MTProtoKitDynamic/MTQueue.h>
# import <MTProtoKitDynamic/MTAtomic.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTNetworkUsageCalculationInfo.h>
# import <MTProtoKitMac/MTSignal.h>
# import <MTProtoKitMac/MTTimer.h>
# import <MTProtoKitMac/MTQueue.h>
# import <MTProtoKitMac/MTAtomic.h>
#else
# import <MtProtoKit/MTNetworkUsageCalculationInfo.h>
# import <MtProtoKit/MTSignal.h>
# import <MtProtoKit/MTTimer.h>
# import <MtProtoKit/MTQueue.h>
# import <MtProtoKit/MTAtomic.h>
#endif
#import <MtProtoKit/MTNetworkUsageCalculationInfo.h>
#import <MtProtoKit/MTSignal.h>
#import <MtProtoKit/MTTimer.h>
#import <MtProtoKit/MTQueue.h>
#import <MtProtoKit/MTAtomic.h>
static int offsetForInterface(MTNetworkUsageCalculationInfo *info, MTNetworkUsageManagerInterface interface, bool incoming) {
switch (interface) {

View File

@ -1,12 +1,6 @@
#import <Foundation/Foundation.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTDatacenterAuthInfo.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTDatacenterAuthInfo.h>
#else
# import <MtProtoKit/MTDatacenterAuthInfo.h>
#endif
#import <MtProtoKit/MTDatacenterAuthInfo.h>
#import <EncryptionProvider/EncryptionProvider.h>

View File

@ -29,16 +29,8 @@
#import "MTTransportSchemeStats.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTDisposable.h>
# import <MTProtoKitDynamic/MTSignal.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTDisposable.h>
# import <MTProtoKitMac/MTSignal.h>
#else
# import <MtProtoKit/MTDisposable.h>
# import <MtProtoKit/MTSignal.h>
#endif
#import <MtProtoKit/MTDisposable.h>
#import <MtProtoKit/MTSignal.h>
@implementation MTContextBlockChangeListener

View File

@ -1,12 +1,7 @@
#import <Foundation/Foundation.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTDatacenterAuthInfo.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTDatacenterAuthInfo.h>
#else
# import <MtProtoKit/MTDatacenterAuthInfo.h>
#endif
#import <MtProtoKit/MTDatacenterAuthInfo.h>
@class MTContext;
@class MTDatacenterAuthAction;

View File

@ -10,13 +10,8 @@
#import "MTSerialization.h"
#import "MTDatacenterAddressSet.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTSignal.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTSignal.h>
#else
# import <MtProtoKit/MTSignal.h>
#endif
#import <MtProtoKit/MTSignal.h>
#import "MTDatacenterAuthMessageService.h"
#import "MTRequestMessageService.h"

View File

@ -1,12 +1,6 @@
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTMessageService.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTMessageService.h>
#else
# import <MtProtoKit/MTMessageService.h>
#endif
#import <MtProtoKit/MTMessageService.h>
@class MTContext;
@class MTDatacenterAuthMessageService;

View File

@ -402,8 +402,7 @@ typedef enum {
arc4random_buf(&random, 1);
[dataWithHash appendBytes:&random length:1];
}
NSData *encryptedData = MTRsaEncrypt([publicKey objectForKey:@"key"], dataWithHash);
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
if (encryptedData.length < 256)
{
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];
@ -440,7 +439,7 @@ typedef enum {
[dataWithHash appendBytes:&random length:1];
}
NSData *encryptedData = MTRsaEncrypt([publicKey objectForKey:@"key"], dataWithHash);
NSData *encryptedData = MTRsaEncrypt(_encryptionProvider, [publicKey objectForKey:@"key"], dataWithHash);
if (encryptedData.length < 256)
{
NSMutableData *newEncryptedData = [[NSMutableData alloc] init];

View File

@ -28,7 +28,7 @@ void MTAesDecryptInplaceAndModifyIv(NSMutableData *data, NSData *key, NSMutableD
void MTAesDecryptBytesInplaceAndModifyIv(void *data, NSInteger length, NSData *key, void *iv);
NSData *MTAesEncrypt(NSData *data, NSData *key, NSData *iv);
NSData *MTAesDecrypt(NSData *data, NSData *key, NSData *iv);
NSData *MTRsaEncrypt(NSString *publicKey, NSData *data);
NSData *MTRsaEncrypt(id<EncryptionProvider> provider, NSString *publicKey, NSData *data);
NSData *MTExp(id<EncryptionProvider> provider, NSData *base, NSData *exp, NSData *modulus);
NSData *MTModSub(id<EncryptionProvider> provider, NSData *a, NSData *b, NSData *modulus);
NSData *MTModMul(id<EncryptionProvider> provider, NSData *a, NSData *b, NSData *modulus);

View File

@ -291,7 +291,7 @@ NSData *MTAesDecrypt(NSData *data, NSData *key, NSData *iv)
return resultData;
}
NSData *MTRsaEncrypt(NSString *publicKey, NSData *data)
NSData *MTRsaEncrypt(id<EncryptionProvider> provider, NSString *publicKey, NSData *data)
{
#if TARGET_OS_IOS
NSMutableData *updatedData = [[NSMutableData alloc] initWithData:data];
@ -301,32 +301,7 @@ NSData *MTRsaEncrypt(NSString *publicKey, NSData *data)
}
return [MTRsa encryptData:updatedData publicKey:publicKey];
#else
BIO *keyBio = BIO_new(BIO_s_mem());
const char *keyData = [publicKey UTF8String];
BIO_write(keyBio, keyData, (int)publicKey.length);
RSA *rsaKey = PEM_read_bio_RSAPublicKey(keyBio, NULL, NULL, NULL);
BIO_free(keyBio);
BN_CTX *ctx = BN_CTX_new();
BIGNUM *a = BN_bin2bn(data.bytes, (int)data.length, NULL);
BIGNUM *r = BN_new();
BN_mod_exp(r, a, RSA_get0_e(rsaKey), RSA_get0_n(rsaKey), ctx);
unsigned char *res = malloc((size_t)BN_num_bytes(r));
int resLen = BN_bn2bin(r, res);
BN_CTX_free(ctx);
BN_free(a);
BN_free(r);
RSA_free(rsaKey);
NSData *result = [[NSData alloc] initWithBytesNoCopy:res length:(NSUInteger)resLen freeWhenDone:true];
return result;
return [provider macosRSAEncrypt:publicKey data:data];
#endif
}

View File

@ -1,12 +1,7 @@
#import <Foundation/Foundation.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTKeychain.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTKeychain.h>
#else
# import <MtProtoKit/MTKeychain.h>
#endif
#import <MtProtoKit/MTKeychain.h>
NS_ASSUME_NONNULL_BEGIN

View File

@ -1,17 +1,8 @@
#import "MTHttpRequestOperation.h"
#import "../thirdparty/AFNetworking/AFHTTPRequestOperation.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTDisposable.h>
# import <MTProtoKitDynamic/MTSignal.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTDisposable.h>
# import <MTProtoKitMac/MTSignal.h>
#else
# import <MtProtoKit/MTDisposable.h>
# import <MtProtoKit/MTSignal.h>
#endif
#import <MtProtoKit/MTDisposable.h>
#import <MtProtoKit/MTSignal.h>
@implementation MTHttpRequestOperation

View File

@ -56,16 +56,8 @@
#import "MTTime.h"
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTSignal.h>
# import <MTProtoKitDynamic/MTQueue.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTSignal.h>
# import <MTProtoKitMac/MTQueue.h>
#else
# import <MtProtoKit/MTSignal.h>
# import <MtProtoKit/MTQueue.h>
#endif
#import <MtProtoKit/MTSignal.h>
#import <MtProtoKit/MTQueue.h>
typedef enum {
MTProtoStateAwaitingDatacenterScheme = 1,

View File

@ -1,12 +1,6 @@
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTMessageService.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTMessageService.h>
#else
# import <MtProtoKit/MTMessageService.h>
#endif
#import <MtProtoKit/MTMessageService.h>
@class MTContext;
@class MTRequest;

View File

@ -1,12 +1,6 @@
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTMessageService.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTMessageService.h>
#else
# import <MtProtoKit/MTMessageService.h>
#endif
#import <MtProtoKit/MTMessageService.h>
@class MTResendMessageService;

View File

@ -2,19 +2,9 @@
#import <Foundation/Foundation.h>
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTExportedAuthorizationData.h>
# import <MTProtoKitDynamic/MTDatacenterAddressListData.h>
# import <MTProtoKitDynamic/MTDatacenterVerificationData.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTExportedAuthorizationData.h>
# import <MTProtoKitMac/MTDatacenterAddressListData.h>
# import <MTProtoKitMac/MTDatacenterVerificationData.h>
#else
# import <MtProtoKit/MTExportedAuthorizationData.h>
# import <MtProtoKit/MTDatacenterAddressListData.h>
# import <MtProtoKit/MTDatacenterVerificationData.h>
#endif
#import <MtProtoKit/MTExportedAuthorizationData.h>
#import <MtProtoKit/MTDatacenterAddressListData.h>
#import <MtProtoKit/MTDatacenterVerificationData.h>
typedef MTExportedAuthorizationData *(^MTExportAuthorizationResponseParser)(NSData *);
typedef MTDatacenterAddressListData *(^MTRequestDatacenterAddressListParser)(NSData *);

View File

@ -1,12 +1,6 @@
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTTransport.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTTransport.h>
#else
# import <MtProtoKit/MTTransport.h>
#endif
#import <MtProtoKit/MTTransport.h>
@interface MTTcpTransport : MTTransport

View File

@ -1,12 +1,5 @@
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTMessageService.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTMessageService.h>
#else
# import <MtProtoKit/MTMessageService.h>
#endif
#import <MtProtoKit/MTMessageService.h>
@class MTTimeSyncMessageService;

View File

@ -12,13 +12,8 @@
@class MTNetworkUsageCalculationInfo;
@class MTSocksProxySettings;
#if defined(MtProtoKitDynamicFramework)
# import <MTProtoKitDynamic/MTMessageService.h>
#elif defined(MtProtoKitMacFramework)
# import <MTProtoKitMac/MTMessageService.h>
#else
# import <MtProtoKit/MTMessageService.h>
#endif
#import <MtProtoKit/MTMessageService.h>
@protocol MTTransportDelegate <NSObject>

View File

@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#if TARGET_OS_IOS
@interface MTRsa : NSObject
// return base64 encoded string
@ -19,3 +19,4 @@
+ (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey;
@end
#endif

View File

@ -6,7 +6,7 @@
*/
#import <Security/Security.h>
#if TARGET_OS_IOS
@implementation MTRsa
NSString *MTStringByEncodingInBase64(NSData *data) {
@ -439,3 +439,4 @@ static NSData *base64_decode(NSString *str) {
/* END: Encryption & Decryption with RSA public key */
@end
#endif

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -1,79 +0,0 @@
//
// MtProtoKitDynamic.h
// MtProtoKitDynamic
//
// Created by Peter on 08/07/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for MtProtoKitDynamic.
FOUNDATION_EXPORT double MtProtoKitDynamicVersionNumber;
//! Project version string for MtProtoKitDynamic.
FOUNDATION_EXPORT const unsigned char MtProtoKitDynamicVersionString[];
#ifndef MtProtoKitDynamicFramework
# define MtProtoKitDynamicFramework 1
#endif
#import <MTProtoKitDynamic/MTTime.h>
#import <MTProtoKitDynamic/MTTimer.h>
#import <MTProtoKitDynamic/MTLogging.h>
#import <MTProtoKitDynamic/MTEncryption.h>
#import <MTProtoKitDynamic/MTInternalId.h>
#import <MTProtoKitDynamic/MTQueue.h>
#import <MTProtoKitDynamic/MTOutputStream.h>
#import <MTProtoKitDynamic/MTInputStream.h>
#import <MTProtoKitDynamic/MTSerialization.h>
#import <MTProtoKitDynamic/MTExportedAuthorizationData.h>
#import <MTProtoKitDynamic/MTRpcError.h>
#import <MTProtoKitDynamic/MTKeychain.h>
#import <MTProtoKitDynamic/MTFileBasedKeychain.h>
#import <MTProtoKitDynamic/MTContext.h>
#import <MTProtoKitDynamic/MTTransportScheme.h>
#import <MTProtoKitDynamic/MTDatacenterTransferAuthAction.h>
#import <MTProtoKitDynamic/MTDatacenterAuthAction.h>
#import <MTProtoKitDynamic/MTDatacenterAuthMessageService.h>
#import <MTProtoKitDynamic/MTDatacenterAddress.h>
#import <MTProtoKitDynamic/MTDatacenterAddressSet.h>
#import <MTProtoKitDynamic/MTDatacenterAuthInfo.h>
#import <MTProtoKitDynamic/MTDatacenterSaltInfo.h>
#import <MTProtoKitDynamic/MTDatacenterAddressListData.h>
#import <MTProtoKitDynamic/MTProto.h>
#import <MTProtoKitDynamic/MTSessionInfo.h>
#import <MTProtoKitDynamic/MTTimeFixContext.h>
#import <MTProtoKitDynamic/MTPreparedMessage.h>
#import <MTProtoKitDynamic/MTOutgoingMessage.h>
#import <MTProtoKitDynamic/MTIncomingMessage.h>
#import <MTProtoKitDynamic/MTMessageEncryptionKey.h>
#import <MTProtoKitDynamic/MTMessageService.h>
#import <MTProtoKitDynamic/MTMessageTransaction.h>
#import <MTProtoKitDynamic/MTTimeSyncMessageService.h>
#import <MTProtoKitDynamic/MTRequestMessageService.h>
#import <MTProtoKitDynamic/MTRequest.h>
#import <MTProtoKitDynamic/MTRequestContext.h>
#import <MTProtoKitDynamic/MTRequestErrorContext.h>
#import <MTProtoKitDynamic/MTDropResponseContext.h>
#import <MTProtoKitDynamic/MTApiEnvironment.h>
#import <MTProtoKitDynamic/MTResendMessageService.h>
#import <MTProtoKitDynamic/MTNetworkAvailability.h>
#import <MTProtoKitDynamic/MTTransport.h>
#import <MTProtoKitDynamic/MTTransportTransaction.h>
#import <MTProtoKitDynamic/MTTcpTransport.h>
#import <MTProtoKitDynamic/MTHttpRequestOperation.h>
#import <MTProtoKitDynamic/MTAtomic.h>
#import <MTProtoKitDynamic/MTBag.h>
#import <MTProtoKitDynamic/MTDisposable.h>
#import <MTProtoKitDynamic/MTSubscriber.h>
#import <MTProtoKitDynamic/MTSignal.h>
#import <MTProtoKitDynamic/MTNetworkUsageCalculationInfo.h>
#import <MTProtoKitDynamic/MTNetworkUsageManager.h>
#import <MTProtoKitDynamic/MTBackupAddressSignals.h>
#import <MTProtoKitDynamic/AFURLConnectionOperation.h>
#import <MTProtoKitDynamic/AFHTTPRequestOperation.h>
#import <MTProtoKitDynamic/MTProxyConnectivity.h>
#import <MTProtoKitDynamic/MTPKCS.h>
#import <MTProtoKitDynamic/MTGzip.h>
#import <MTProtoKitDynamic/TON.h>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,40 +0,0 @@
//
// MtProtoKitDynamicTests.m
// MtProtoKitDynamicTests
//
// Created by Peter on 08/07/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
@interface MtProtoKitDynamicTests : XCTestCase
@end
@implementation MtProtoKitDynamicTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Telegram. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -1,78 +0,0 @@
//
// MtProtoKitMac.h
// MtProtoKitMac
//
// Created by Peter on 01/05/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for MtProtoKitMac.
FOUNDATION_EXPORT double MtProtoKitMacVersionNumber;
//! Project version string for MtProtoKitMac.
FOUNDATION_EXPORT const unsigned char MtProtoKitMacVersionString[];
#ifndef MtProtoKitMacFramework
# define MtProtoKitMacFramework 1
#endif
#import <MtProtoKitMac/MTTime.h>
#import <MtProtoKitMac/MTTimer.h>
#import <MtProtoKitMac/MTLogging.h>
#import <MtProtoKitMac/MTEncryption.h>
#import <MtProtoKitMac/MTInternalId.h>
#import <MtProtoKitMac/MTQueue.h>
#import <MtProtoKitMac/MTOutputStream.h>
#import <MtProtoKitMac/MTInputStream.h>
#import <MtProtoKitMac/MTSerialization.h>
#import <MtProtoKitMac/MTExportedAuthorizationData.h>
#import <MtProtoKitMac/MTRpcError.h>
#import <MtProtoKitMac/MTKeychain.h>
#import <MtProtoKitMac/MTFileBasedKeychain.h>
#import <MtProtoKitMac/MTContext.h>
#import <MtProtoKitMac/MTTransportScheme.h>
#import <MtProtoKitMac/MTDatacenterTransferAuthAction.h>
#import <MtProtoKitMac/MTDatacenterAuthAction.h>
#import <MtProtoKitMac/MTDatacenterAuthMessageService.h>
#import <MtProtoKitMac/MTDatacenterAddress.h>
#import <MtProtoKitMac/MTDatacenterAddressSet.h>
#import <MtProtoKitMac/MTDatacenterAuthInfo.h>
#import <MtProtoKitMac/MTDatacenterSaltInfo.h>
#import <MtProtoKitMac/MTDatacenterAddressListData.h>
#import <MtProtoKitMac/MTProto.h>
#import <MtProtoKitMac/MTSessionInfo.h>
#import <MtProtoKitMac/MTTimeFixContext.h>
#import <MtProtoKitMac/MTPreparedMessage.h>
#import <MtProtoKitMac/MTOutgoingMessage.h>
#import <MtProtoKitMac/MTIncomingMessage.h>
#import <MtProtoKitMac/MTMessageEncryptionKey.h>
#import <MtProtoKitMac/MTMessageService.h>
#import <MtProtoKitMac/MTMessageTransaction.h>
#import <MtProtoKitMac/MTTimeSyncMessageService.h>
#import <MtProtoKitMac/MTRequestMessageService.h>
#import <MtProtoKitMac/MTRequest.h>
#import <MtProtoKitMac/MTRequestContext.h>
#import <MtProtoKitMac/MTRequestErrorContext.h>
#import <MtProtoKitMac/MTDropResponseContext.h>
#import <MtProtoKitMac/MTApiEnvironment.h>
#import <MtProtoKitMac/MTResendMessageService.h>
#import <MtProtoKitMac/MTNetworkAvailability.h>
#import <MtProtoKitMac/MTTransport.h>
#import <MtProtoKitMac/MTTransportTransaction.h>
#import <MtProtoKitMac/MTTcpTransport.h>
#import <MTProtoKitMac/MTHttpRequestOperation.h>
#import <MtProtoKitMac/MTAtomic.h>
#import <MtProtoKitMac/MTBag.h>
#import <MtProtoKitMac/MTDisposable.h>
#import <MtProtoKitMac/MTSubscriber.h>
#import <MtProtoKitMac/MTSignal.h>
#import <MtProtoKitMac/MTNetworkUsageCalculationInfo.h>
#import <MtProtoKitMac/MTNetworkUsageManager.h>
#import <MtProtoKitMac/MTBackupAddressSignals.h>
#import <MtProtoKitMac/AFURLConnectionOperation.h>
#import <MtProtoKitMac/AFHTTPRequestOperation.h>
#import <MTProtoKitMac/MTProxyConnectivity.h>
#import <MTProtoKitMac/MTGzip.h>
#import <MTProtoKitMac/TON.h>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.telegram.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,40 +0,0 @@
//
// MtProtoKitMacTests.m
// MtProtoKitMacTests
//
// Created by Peter on 01/05/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
@interface MtProtoKitMacTests : XCTestCase
@end
@implementation MtProtoKitMacTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.telegram.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Telegram. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -1,10 +0,0 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -1,2 +0,0 @@
/* Localized versions of Info.plist keys */

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,77 +0,0 @@
#import <XCTest/XCTest.h>
#import <MtProtoKit/MTProtoKit.h>
#import <MtProtoKit/MTTcpTransport.h>
#import <MtProtoKit/MTTransportTransaction.h>
@interface TestSerialization : NSObject <MTSerialization>
@end
@implementation TestSerialization
- (NSUInteger)currentLayer {
return 42;
}
- (id)parseMessage:(NSData *)__unused data {
return nil;
}
- (MTExportAuthorizationResponseParser)exportAuthorization:(int32_t)datacenterId data:(__autoreleasing NSData **)data {
return nil;
}
- (NSData *)importAuthorization:(int32_t)authId bytes:(NSData *)bytes {
return nil;
}
- (MTRequestDatacenterAddressListParser)requestDatacenterAddressList:(int32_t)datacenterId data:(__autoreleasing NSData **)data {
return nil;
}
@end
@interface MtProtoKitStabilityTests : XCTestCase <MTTransportDelegate> {
MTTcpTransport *_transport;
}
@end
@implementation MtProtoKitStabilityTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
MTApiEnvironment *apiEnvironment = [[MTApiEnvironment alloc] init];
MTContext *context = [[MTContext alloc] initWithSerialization:[[TestSerialization alloc] init] apiEnvironment:apiEnvironment];
//for (int i = 0; i < 100; i++) {
_transport = [[MTTcpTransport alloc] initWithDelegate:self context:context datacenterId:1 address:[[MTDatacenterAddress alloc] initWithIp:@"149.154.175.50" port:443 preferForMedia:false]];
_transport.delegate = self;
[_transport setDelegateNeedsTransaction];
//}
sleep(2);
}
- (void)transportConnectionStateChanged:(MTTransport *)transport isConnected:(bool)isConnected {
if (isConnected) {
_transport = nil;
}
}
- (void)transportReadyForTransaction:(MTTransport *)transport transportSpecificTransaction:(MTMessageTransaction *)transportSpecificTransaction forceConfirmations:(bool)forceConfirmations transactionReady:(void (^)(NSArray *))transactionReady {
transactionReady(@[[[MTTransportTransaction alloc] initWithPayload:[NSData data] completion:^(bool success, id transactionId) {
}]]);
}
@end

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.telegram.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.telegram.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,40 +0,0 @@
//
// MtProtoKitTests.m
// MtProtoKitTests
//
// Created by Peter on 13/04/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
@interface MtProtoKitTests : XCTestCase
@end
@implementation MtProtoKitTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
XCTAssert(YES, @"Pass");
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

View File

@ -1,2 +0,0 @@
/* Localized versions of Info.plist keys */

View File

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D079AB961AF39B8000076F59"
BuildableName = "MtProtoKitMac.framework"
BlueprintName = "MtProtoKitMac"
ReferencedContainer = "container:MtProtoKit_Xcode.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D079AB961AF39B8000076F59"
BuildableName = "MtProtoKitMac.framework"
BlueprintName = "MtProtoKitMac"
ReferencedContainer = "container:MtProtoKit_Xcode.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D079AB961AF39B8000076F59"
BuildableName = "MtProtoKitMac.framework"
BlueprintName = "MtProtoKitMac"
ReferencedContainer = "container:MtProtoKit_Xcode.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Some files were not shown because too many files have changed in this diff Show More