Bump min iOS version to 11.0

This commit is contained in:
Ali 2022-09-17 01:08:04 +04:00
parent 11e11668e6
commit a14cd136c3
49 changed files with 378 additions and 329 deletions

View File

@ -115,6 +115,8 @@ genrule(
], ],
) )
minimum_os_version = "11.0"
empty_languages = [ empty_languages = [
"ar", "ar",
"be", "be",
@ -768,7 +770,7 @@ ios_framework(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":VersionInfoPlist", ":VersionInfoPlist",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -808,7 +810,7 @@ ios_framework(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":VersionInfoPlist", ":VersionInfoPlist",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -851,7 +853,7 @@ ios_framework(
frameworks = [ frameworks = [
":SwiftSignalKitFramework", ":SwiftSignalKitFramework",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -891,7 +893,7 @@ ios_framework(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":VersionInfoPlist", ":VersionInfoPlist",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -936,7 +938,7 @@ ios_framework(
":SwiftSignalKitFramework", ":SwiftSignalKitFramework",
":PostboxFramework", ":PostboxFramework",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -976,7 +978,7 @@ ios_framework(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":VersionInfoPlist", ":VersionInfoPlist",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -1063,7 +1065,7 @@ ios_framework(
":SwiftSignalKitFramework", ":SwiftSignalKitFramework",
":AsyncDisplayKitFramework", ":AsyncDisplayKitFramework",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -1111,7 +1113,7 @@ ios_framework(
":AsyncDisplayKitFramework", ":AsyncDisplayKitFramework",
":DisplayFramework", ":DisplayFramework",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
extension_safe = True, extension_safe = True,
ipa_post_processor = strip_framework, ipa_post_processor = strip_framework,
deps = [ deps = [
@ -1198,7 +1200,7 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Share.mobileprovision", "//conditions:default": "@build_configuration//provisioning:Share.mobileprovision",
@ -1269,7 +1271,7 @@ swift_library(
], ],
) )
genrule( '''genrule(
name = "SetMinOsVersionNotificationContentExtension", name = "SetMinOsVersionNotificationContentExtension",
cmd_bash = cmd_bash =
""" """
@ -1286,7 +1288,7 @@ genrule(
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
] ]
) )'''
ios_extension( ios_extension(
name = "NotificationContentExtension", name = "NotificationContentExtension",
@ -1303,8 +1305,8 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions minimum_os_version = minimum_os_version, # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionNotificationContentExtension", #ipa_post_processor = ":SetMinOsVersionNotificationContentExtension",
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:NotificationContent.mobileprovision", "//conditions:default": "@build_configuration//provisioning:NotificationContent.mobileprovision",
@ -1407,7 +1409,7 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions minimum_os_version = minimum_os_version, # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionWidgetExtension", ipa_post_processor = ":SetMinOsVersionWidgetExtension",
#provides_main = True, #provides_main = True,
provisioning_profile = select({ provisioning_profile = select({
@ -1506,7 +1508,7 @@ swift_library(
], ],
) )
genrule( '''genrule(
name = "SetMinOsVersionIntentsExtension", name = "SetMinOsVersionIntentsExtension",
cmd_bash = cmd_bash =
""" """
@ -1523,7 +1525,7 @@ genrule(
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
] ]
) )'''
ios_extension( ios_extension(
name = "IntentsExtension", name = "IntentsExtension",
@ -1540,8 +1542,8 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions minimum_os_version = minimum_os_version, # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionIntentsExtension", #ipa_post_processor = ":SetMinOsVersionIntentsExtension",
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Intents.mobileprovision", "//conditions:default": "@build_configuration//provisioning:Intents.mobileprovision",
@ -1600,7 +1602,7 @@ swift_library(
], ],
) )
genrule( '''genrule(
name = "SetMinOsVersionBroadcastUploadExtension", name = "SetMinOsVersionBroadcastUploadExtension",
cmd_bash = cmd_bash =
""" """
@ -1617,7 +1619,7 @@ genrule(
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
] ]
) )'''
ios_extension( ios_extension(
name = "BroadcastUploadExtension", name = "BroadcastUploadExtension",
@ -1634,8 +1636,8 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions minimum_os_version = minimum_os_version, # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionBroadcastUploadExtension", #ipa_post_processor = ":SetMinOsVersionBroadcastUploadExtension",
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:BroadcastUpload.mobileprovision", "//conditions:default": "@build_configuration//provisioning:BroadcastUpload.mobileprovision",
@ -1679,7 +1681,7 @@ plist_fragment(
) )
) )
genrule( '''genrule(
name = "SetMinOsVersionNotificationServiceExtension", name = "SetMinOsVersionNotificationServiceExtension",
cmd_bash = cmd_bash =
""" """
@ -1696,7 +1698,7 @@ genrule(
visibility = [ visibility = [
"//visibility:public", "//visibility:public",
] ]
) )'''
ios_extension( ios_extension(
name = "NotificationServiceExtension", name = "NotificationServiceExtension",
@ -1713,8 +1715,8 @@ ios_extension(
":BuildNumberInfoPlist", ":BuildNumberInfoPlist",
":AppNameInfoPlist", ":AppNameInfoPlist",
], ],
minimum_os_version = "9.0", # maintain the same minimum OS version across extensions minimum_os_version = minimum_os_version, # maintain the same minimum OS version across extensions
ipa_post_processor = ":SetMinOsVersionNotificationServiceExtension", #ipa_post_processor = ":SetMinOsVersionNotificationServiceExtension",
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:NotificationService.mobileprovision", "//conditions:default": "@build_configuration//provisioning:NotificationService.mobileprovision",
@ -1912,7 +1914,7 @@ ios_application(
telegram_bundle_id = telegram_bundle_id, telegram_bundle_id = telegram_bundle_id,
), ),
families = ["iphone", "ipad"], families = ["iphone", "ipad"],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision", "//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision",
@ -1974,7 +1976,7 @@ ios_application(
telegram_bundle_id = telegram_bundle_id, telegram_bundle_id = telegram_bundle_id,
), ),
families = ["iphone", "ipad"], families = ["iphone", "ipad"],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision", "//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision",
@ -1997,7 +1999,7 @@ ios_application(
telegram_bundle_id = telegram_bundle_id, telegram_bundle_id = telegram_bundle_id,
), ),
families = ["iphone", "ipad"], families = ["iphone", "ipad"],
minimum_os_version = "9.0", minimum_os_version = minimum_os_version,
provisioning_profile = select({ provisioning_profile = select({
":disableProvisioningProfilesSetting": None, ":disableProvisioningProfilesSetting": None,
"//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision", "//conditions:default": "@build_configuration//provisioning:Telegram.mobileprovision",

View File

@ -478,8 +478,28 @@ public extension DeviceContactExtendedData {
} }
} }
extension DeviceContactAddressData { public extension DeviceContactAddressData {
public var dictionary: [String: String] { var asPostalAddress: CNPostalAddress {
let address = CNMutablePostalAddress()
if !self.street1.isEmpty {
address.street = self.street1
}
if !self.city.isEmpty {
address.city = self.city
}
if !self.state.isEmpty {
address.state = self.state
}
if !self.country.isEmpty {
address.country = self.country
}
if !self.postcode.isEmpty {
address.postalCode = self.postcode
}
return address
}
var dictionary: [String: String] {
var dictionary: [String: String] = [:] var dictionary: [String: String] = [:]
if !self.street1.isEmpty { if !self.street1.isEmpty {
dictionary["Street"] = self.street1 dictionary["Street"] = self.street1
@ -499,7 +519,7 @@ extension DeviceContactAddressData {
return dictionary return dictionary
} }
public var string: String { var string: String {
var array: [String] = [] var array: [String] = []
if !self.street1.isEmpty { if !self.street1.isEmpty {
array.append(self.street1) array.append(self.street1)
@ -519,7 +539,7 @@ extension DeviceContactAddressData {
return array.joined(separator: " ") return array.joined(separator: " ")
} }
public var displayString: String { var displayString: String {
var array: [String] = [] var array: [String] = []
if !self.street1.isEmpty { if !self.street1.isEmpty {
array.append(self.street1) array.append(self.street1)

View File

@ -17,7 +17,7 @@ final class CameraDevice {
func configure(for session: AVCaptureSession, position: Camera.Position) { func configure(for session: AVCaptureSession, position: Camera.Position) {
self.position = position self.position = position
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
self.videoDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDuoCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: position).devices.first self.videoDevice = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInDualCamera, .builtInWideAngleCamera, .builtInTelephotoCamera], mediaType: .video, position: position).devices.first
} else { } else {
self.videoDevice = AVCaptureDevice.devices(for: .video).filter { $0.position == position }.first self.videoDevice = AVCaptureDevice.devices(for: .video).filter { $0.position == position }.first
} }
@ -61,7 +61,7 @@ final class CameraDevice {
} }
} }
var isFlashActive: Signal<Bool, NoError> { /*var isFlashActive: Signal<Bool, NoError> {
return self.videoDevicePromise.get() return self.videoDevicePromise.get()
|> mapToSignal { device -> Signal<Bool, NoError> in |> mapToSignal { device -> Signal<Bool, NoError> in
return Signal { subscriber in return Signal { subscriber in
@ -75,7 +75,7 @@ final class CameraDevice {
} }
|> distinctUntilChanged |> distinctUntilChanged
} }
} }*/
var isFlashAvailable: Signal<Bool, NoError> { var isFlashAvailable: Signal<Bool, NoError> {
return self.videoDevicePromise.get() return self.videoDevicePromise.get()

View File

@ -375,7 +375,7 @@ public protocol CustomViewControllerNavigationDataSummary: AnyObject {
} }
} }
self.navigationBar?.item = self.navigationItem self.navigationBar?.item = self.navigationItem
self.automaticallyAdjustsScrollViewInsets = false //self.automaticallyAdjustsScrollViewInsets = false
self.scrollToTopWithTabBar = { [weak self] in self.scrollToTopWithTabBar = { [weak self] in
self?.scrollToTop?() self?.scrollToTop?()

View File

@ -65,8 +65,6 @@ final class GameControllerNode: ViewControllerTracingNode {
configuration.allowsInlineMediaPlayback = true configuration.allowsInlineMediaPlayback = true
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = [] configuration.mediaTypesRequiringUserActionForPlayback = []
} else if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
configuration.requiresUserActionForMediaPlayback = false
} else { } else {
configuration.mediaPlaybackRequiresUserAction = false configuration.mediaPlaybackRequiresUserAction = false
} }

View File

@ -1,4 +1,5 @@
import Foundation import Foundation
import Contacts
import CoreLocation import CoreLocation
import SwiftSignalKit import SwiftSignalKit
@ -15,10 +16,10 @@ public func geocodeLocation(address: String) -> Signal<[CLPlacemark]?, NoError>
} }
} }
public func geocodeLocation(dictionary: [String: String]) -> Signal<(Double, Double)?, NoError> { public func geocodeLocation(address: CNPostalAddress) -> Signal<(Double, Double)?, NoError> {
return Signal { subscriber in return Signal { subscriber in
let geocoder = CLGeocoder() let geocoder = CLGeocoder()
geocoder.geocodeAddressDictionary(dictionary, completionHandler: { placemarks, _ in geocoder.geocodePostalAddress(address, completionHandler: { placemarks, _ in
if let location = placemarks?.first?.location { if let location = placemarks?.first?.location {
subscriber.putNext((location.coordinate.latitude, location.coordinate.longitude)) subscriber.putNext((location.coordinate.latitude, location.coordinate.longitude))
} else { } else {

View File

@ -8,7 +8,10 @@
@interface PGCameraCaptureSession : AVCaptureSession @interface PGCameraCaptureSession : AVCaptureSession
@property (nonatomic, readonly) AVCaptureDevice *videoDevice; @property (nonatomic, readonly) AVCaptureDevice *videoDevice;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@property (nonatomic, readonly) AVCaptureStillImageOutput *imageOutput; @property (nonatomic, readonly) AVCaptureStillImageOutput *imageOutput;
#pragma clang diagnostic pop
@property (nonatomic, readonly) AVCaptureVideoDataOutput *videoOutput; @property (nonatomic, readonly) AVCaptureVideoDataOutput *videoOutput;
@property (nonatomic, readonly) AVCaptureAudioDataOutput *audioOutput; @property (nonatomic, readonly) AVCaptureAudioDataOutput *audioOutput;
@property (nonatomic, readonly) AVCaptureMetadataOutput *metadataOutput; @property (nonatomic, readonly) AVCaptureMetadataOutput *metadataOutput;

View File

@ -6,7 +6,7 @@
#import "ASActor.h" #import "ASActor.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
@ -17,8 +17,8 @@ static dispatch_queue_t mainGraphQueue = nil;
static dispatch_queue_t globalGraphQueue = nil; static dispatch_queue_t globalGraphQueue = nil;
static dispatch_queue_t highPriorityGraphQueue = nil; static dispatch_queue_t highPriorityGraphQueue = nil;
static volatile OSSpinLock removeWatcherRequestsLock = OS_SPINLOCK_INIT; static os_unfair_lock removeWatcherRequestsLock = OS_UNFAIR_LOCK_INIT;
static volatile OSSpinLock removeWatcherFromPathRequestsLock = OS_SPINLOCK_INIT; static os_unfair_lock removeWatcherFromPathRequestsLock = OS_UNFAIR_LOCK_INIT;
@interface ActionStage () @interface ActionStage ()
{ {
@ -790,11 +790,11 @@ ActionStage *ActionStageInstance()
} }
bool alreadyExecuting = false; bool alreadyExecuting = false;
OSSpinLockLock(&removeWatcherRequestsLock); os_unfair_lock_lock(&removeWatcherRequestsLock);
if (!_removeWatcherRequests.empty()) if (!_removeWatcherRequests.empty())
alreadyExecuting = true; alreadyExecuting = true;
_removeWatcherRequests.push_back(watcherGraphHandle); _removeWatcherRequests.push_back(watcherGraphHandle);
OSSpinLockUnlock(&removeWatcherRequestsLock); os_unfair_lock_unlock(&removeWatcherRequestsLock);
if (alreadyExecuting && ![self isCurrentQueueStageQueue]) if (alreadyExecuting && ![self isCurrentQueueStageQueue])
return; return;
@ -803,10 +803,10 @@ ActionStage *ActionStageInstance()
{ {
std::vector<ASHandle *> removeWatchers; std::vector<ASHandle *> removeWatchers;
OSSpinLockLock(&removeWatcherRequestsLock); os_unfair_lock_lock(&removeWatcherRequestsLock);
removeWatchers.insert(removeWatchers.begin(), _removeWatcherRequests.begin(), _removeWatcherRequests.end()); removeWatchers.insert(removeWatchers.begin(), _removeWatcherRequests.begin(), _removeWatcherRequests.end());
_removeWatcherRequests.clear(); _removeWatcherRequests.clear();
OSSpinLockUnlock(&removeWatcherRequestsLock); os_unfair_lock_unlock(&removeWatcherRequestsLock);
for (std::vector<ASHandle *>::iterator it = removeWatchers.begin(); it != removeWatchers.end(); it++) for (std::vector<ASHandle *>::iterator it = removeWatchers.begin(); it != removeWatchers.end(); it++)
{ {
@ -894,11 +894,11 @@ ActionStage *ActionStageInstance()
} }
bool alreadyExecuting = false; bool alreadyExecuting = false;
OSSpinLockLock(&removeWatcherFromPathRequestsLock); os_unfair_lock_lock(&removeWatcherFromPathRequestsLock);
if (!_removeWatcherFromPathRequests.empty()) if (!_removeWatcherFromPathRequests.empty())
alreadyExecuting = true; alreadyExecuting = true;
_removeWatcherFromPathRequests.push_back(std::pair<ASHandle *, NSString *>(watcherGraphHandle, watcherPath)); _removeWatcherFromPathRequests.push_back(std::pair<ASHandle *, NSString *>(watcherGraphHandle, watcherPath));
OSSpinLockUnlock(&removeWatcherFromPathRequestsLock); os_unfair_lock_unlock(&removeWatcherFromPathRequestsLock);
if (alreadyExecuting && ![self isCurrentQueueStageQueue]) if (alreadyExecuting && ![self isCurrentQueueStageQueue])
return; return;
@ -907,10 +907,10 @@ ActionStage *ActionStageInstance()
{ {
std::vector<std::pair<ASHandle *, NSString *> > removeWatchersFromPath; std::vector<std::pair<ASHandle *, NSString *> > removeWatchersFromPath;
OSSpinLockLock(&removeWatcherFromPathRequestsLock); os_unfair_lock_lock(&removeWatcherFromPathRequestsLock);
removeWatchersFromPath.insert(removeWatchersFromPath.begin(), _removeWatcherFromPathRequests.begin(), _removeWatcherFromPathRequests.end()); removeWatchersFromPath.insert(removeWatchersFromPath.begin(), _removeWatcherFromPathRequests.begin(), _removeWatcherFromPathRequests.end());
_removeWatcherFromPathRequests.clear(); _removeWatcherFromPathRequests.clear();
OSSpinLockUnlock(&removeWatcherFromPathRequestsLock); os_unfair_lock_unlock(&removeWatcherFromPathRequestsLock);
if (removeWatchersFromPath.size() > 1) if (removeWatchersFromPath.size() > 1)
{ {

View File

@ -21,9 +21,7 @@
#import "POPBasicAnimationInternal.h" #import "POPBasicAnimationInternal.h"
#import "POPDecayAnimation.h" #import "POPDecayAnimation.h"
#if !TARGET_OS_IPHONE #import <os/lock.h>
#import <libkern/OSAtomic.h>
#endif
using namespace std; using namespace std;
using namespace POP; using namespace POP;
@ -97,7 +95,7 @@ static BOOL _disableBackgroundThread = YES;
CFTimeInterval _slowMotionLastTime; CFTimeInterval _slowMotionLastTime;
CFTimeInterval _slowMotionAccumulator; CFTimeInterval _slowMotionAccumulator;
CFTimeInterval _beginTime; CFTimeInterval _beginTime;
OSSpinLock _lock; os_unfair_lock _lock;
BOOL _disableDisplayLink; BOOL _disableDisplayLink;
} }
@end @end
@ -263,7 +261,7 @@ static POPAnimation *deleteDictEntry(POPAnimator *self, id __unsafe_unretained o
POPAnimation *anim = nil; POPAnimation *anim = nil;
// lock // lock
OSSpinLockLock(&self->_lock); os_unfair_lock_lock(&self->_lock);
NSMutableDictionary *keyAnimationsDict = (__bridge id)CFDictionaryGetValue(self->_dict, (__bridge void *)obj); NSMutableDictionary *keyAnimationsDict = (__bridge id)CFDictionaryGetValue(self->_dict, (__bridge void *)obj);
if (keyAnimationsDict) { if (keyAnimationsDict) {
@ -282,7 +280,7 @@ static POPAnimation *deleteDictEntry(POPAnimator *self, id __unsafe_unretained o
} }
// unlock // unlock
OSSpinLockUnlock(&self->_lock); os_unfair_lock_unlock(&self->_lock);
return anim; return anim;
} }
@ -299,7 +297,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
if (shouldRemove) { if (shouldRemove) {
// lock // lock
OSSpinLockLock(&self->_lock); os_unfair_lock_lock(&self->_lock);
// find item in list // find item in list
// may have already been removed on animationDidStop: // may have already been removed on animationDidStop:
@ -311,7 +309,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// unlock // unlock
OSSpinLockUnlock(&self->_lock); os_unfair_lock_unlock(&self->_lock);
} }
} }
@ -352,7 +350,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
#endif #endif
_dict = POPDictionaryCreateMutableWeakPointerToStrongObject(5); _dict = POPDictionaryCreateMutableWeakPointerToStrongObject(5);
_lock = OS_SPINLOCK_INIT; _lock = OS_UNFAIR_LOCK_INIT;
return self; return self;
} }
@ -377,14 +375,14 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
[self _renderTime:(0 != _beginTime) ? _beginTime : time items:_pendingList]; [self _renderTime:(0 != _beginTime) ? _beginTime : time items:_pendingList];
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// clear list and observer // clear list and observer
_pendingList.clear(); _pendingList.clear();
[self _clearPendingListObserver]; [self _clearPendingListObserver];
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)_clearPendingListObserver - (void)_clearPendingListObserver
@ -403,7 +401,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
static const CFIndex POPAnimationApplyRunLoopOrder = CATransactionCommitRunLoopOrder - 1; static const CFIndex POPAnimationApplyRunLoopOrder = CATransactionCommitRunLoopOrder - 1;
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_pendingListObserver) { if (!_pendingListObserver) {
__weak POPAnimator *weakSelf = self; __weak POPAnimator *weakSelf = self;
@ -418,7 +416,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)_renderTime:(CFTimeInterval)time items:(std::list<POPAnimatorItemRef>)items - (void)_renderTime:(CFTimeInterval)time items:(std::list<POPAnimatorItemRef>)items
@ -432,19 +430,19 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
[delegate animatorWillAnimate:self]; [delegate animatorWillAnimate:self];
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// count active animations // count active animations
const NSUInteger count = items.size(); const NSUInteger count = items.size();
if (0 == count) { if (0 == count) {
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} else { } else {
// copy list into vector // copy list into vector
std::vector<POPAnimatorItemRef> vector{ std::begin(items), std::end(items) }; std::vector<POPAnimatorItemRef> vector{ std::begin(items), std::end(items) };
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (auto item : vector) { for (auto item : vector) {
[self _renderTime:time item:item]; [self _renderTime:time item:item];
@ -457,13 +455,13 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// update display link // update display link
updateDisplayLink(self); updateDisplayLink(self);
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
// notify delegate and commit // notify delegate and commit
[delegate animatorDidAnimate:self]; [delegate animatorDidAnimate:self];
@ -541,13 +539,13 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
- (NSArray *)observers - (NSArray *)observers
{ {
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// get observers // get observers
NSArray *observers = 0 != _observers.count ? [_observers copy] : nil; NSArray *observers = 0 != _observers.count ? [_observers copy] : nil;
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return observers; return observers;
} }
@ -563,7 +561,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// get key, animation dict associated with object // get key, animation dict associated with object
NSMutableDictionary *keyAnimationDict = (__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj); NSMutableDictionary *keyAnimationDict = (__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj);
@ -577,7 +575,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
POPAnimation *existingAnim = keyAnimationDict[key]; POPAnimation *existingAnim = keyAnimationDict[key];
if (existingAnim) { if (existingAnim) {
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (existingAnim == anim) { if (existingAnim == anim) {
return; return;
@ -585,7 +583,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
[self removeAnimationForObject:obj key:key cleanupDict:NO]; [self removeAnimationForObject:obj key:key cleanupDict:NO];
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
} }
} }
keyAnimationDict[key] = anim; keyAnimationDict[key] = anim;
@ -604,7 +602,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
updateDisplayLink(self); updateDisplayLink(self);
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
// schedule runloop processing of pending animations // schedule runloop processing of pending animations
[self _scheduleProcessPendingList]; [self _scheduleProcessPendingList];
@ -613,13 +611,13 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
- (void)removeAllAnimationsForObject:(id)obj - (void)removeAllAnimationsForObject:(id)obj
{ {
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
NSArray *animations = [(__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj) allValues]; NSArray *animations = [(__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj) allValues];
CFDictionaryRemoveValue(_dict, (__bridge void *)obj); CFDictionaryRemoveValue(_dict, (__bridge void *)obj);
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (0 == animations.count) { if (0 == animations.count) {
return; return;
@ -631,7 +629,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
POPAnimatorItemRef item; POPAnimatorItemRef item;
for (auto iter = _list.begin(); iter != _list.end();) { for (auto iter = _list.begin(); iter != _list.end();) {
@ -644,7 +642,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (POPAnimation *anim in animations) { for (POPAnimation *anim in animations) {
POPAnimationState *state = POPAnimationGetState(anim); POPAnimationState *state = POPAnimationGetState(anim);
@ -660,7 +658,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// remove from list // remove from list
POPAnimatorItemRef item; POPAnimatorItemRef item;
@ -686,7 +684,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
// stop animation and callout // stop animation and callout
POPAnimationState *state = POPAnimationGetState(anim); POPAnimationState *state = POPAnimationGetState(anim);
@ -701,27 +699,27 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
- (NSArray *)animationKeysForObject:(id)obj - (NSArray *)animationKeysForObject:(id)obj
{ {
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// get keys // get keys
NSArray *keys = [(__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj) allKeys]; NSArray *keys = [(__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj) allKeys];
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return keys; return keys;
} }
- (id)animationForObject:(id)obj key:(NSString *)key - (id)animationForObject:(id)obj key:(NSString *)key
{ {
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
// lookup animation // lookup animation
NSDictionary *keyAnimationsDict = (__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj); NSDictionary *keyAnimationsDict = (__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj);
POPAnimation *animation = keyAnimationsDict[key]; POPAnimation *animation = keyAnimationsDict[key];
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return animation; return animation;
} }
@ -771,7 +769,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_observers) { if (!_observers) {
// use ordered collection for deterministic callout // use ordered collection for deterministic callout
@ -782,7 +780,7 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
updateDisplayLink(self); updateDisplayLink(self);
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)removeObserver:(id<POPAnimatorObserving>)observer - (void)removeObserver:(id<POPAnimatorObserving>)observer
@ -793,13 +791,13 @@ static void stopAndCleanup(POPAnimator *self, POPAnimatorItemRef item, bool shou
} }
// lock // lock
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
[_observers removeObject:observer]; [_observers removeObject:observer];
updateDisplayLink(self); updateDisplayLink(self);
// unlock // unlock
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
@end @end

View File

@ -5,7 +5,7 @@
#import <Accelerate/Accelerate.h> #import <Accelerate/Accelerate.h>
#import <CommonCrypto/CommonCrypto.h> #import <CommonCrypto/CommonCrypto.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <map> #import <map>
#import <objc/runtime.h> #import <objc/runtime.h>

View File

@ -2,7 +2,7 @@
#import "LegacyComponentsInternal.h" #import "LegacyComponentsInternal.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <CoreMedia/CoreMedia.h> #import <CoreMedia/CoreMedia.h>
#import <ImageIO/ImageIO.h> #import <ImageIO/ImageIO.h>
#import <Accelerate/Accelerate.h> #import <Accelerate/Accelerate.h>
@ -69,7 +69,7 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16;
id<TGLiveUploadInterface> _watcher; id<TGLiveUploadInterface> _watcher;
id _liveUploadData; id _liveUploadData;
OSSpinLock _recordLock; os_unfair_lock _recordLock;
bool _startRecordAfterAudioBuffer; bool _startRecordAfterAudioBuffer;
CVPixelBufferRef _currentPreviewPixelBuffer; CVPixelBufferRef _currentPreviewPixelBuffer;
@ -404,7 +404,7 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16;
CFRelease(blockBuffer); CFRelease(blockBuffer);
OSSpinLockLock(&_recordLock); os_unfair_lock_lock(&_recordLock);
if (_startRecordAfterAudioBuffer) if (_startRecordAfterAudioBuffer)
{ {
_startRecordAfterAudioBuffer = false; _startRecordAfterAudioBuffer = false;
@ -413,7 +413,7 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16;
[self startRecording:_recordingURL preset:_preset liveUpload:_liveUpload]; [self startRecording:_recordingURL preset:_preset liveUpload:_liveUpload];
}); });
} }
OSSpinLockUnlock(&_recordLock); os_unfair_lock_unlock(&_recordLock);
} }
} }
@ -669,14 +669,14 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16;
_preset = preset; _preset = preset;
_liveUpload = liveUpload; _liveUpload = liveUpload;
OSSpinLockLock(&_recordLock); os_unfair_lock_lock(&_recordLock);
if (self.outputAudioFormatDescription == NULL) if (self.outputAudioFormatDescription == NULL)
{ {
_startRecordAfterAudioBuffer = true; _startRecordAfterAudioBuffer = true;
OSSpinLockUnlock(&_recordLock); os_unfair_lock_unlock(&_recordLock);
return; return;
} }
OSSpinLockUnlock(&_recordLock); os_unfair_lock_unlock(&_recordLock);
@synchronized (self) @synchronized (self)
{ {

View File

@ -57,7 +57,7 @@ public func geocodeAddress(engine: TelegramEngine, address: DeviceContactAddress
if let cached = cached { if let cached = cached {
return .single((cached.latitude, cached.longitude)) return .single((cached.latitude, cached.longitude))
} else { } else {
return geocodeLocation(dictionary: address.dictionary) return geocodeLocation(address: address.asPostalAddress)
|> mapToSignal { coordinate in |> mapToSignal { coordinate in
if let (latitude, longitude) = coordinate { if let (latitude, longitude) = coordinate {
return updateCachedGeocode(engine: engine, address: address, latitude: latitude, longitude: longitude) return updateCachedGeocode(engine: engine, address: address, latitude: latitude, longitude: longitude)

View File

@ -3,7 +3,7 @@
#ifndef MtProtoKit_MTInternalId_h #ifndef MtProtoKit_MTInternalId_h
#define MtProtoKit_MTInternalId_h #define MtProtoKit_MTInternalId_h
#import <libkern/OSAtomic.h> #import <os/lock.h>
#define MTInternalId(name) MT##name##InternalId #define MTInternalId(name) MT##name##InternalId

View File

@ -1,10 +1,10 @@
#import <MtProtoKit/MTAtomic.h> #import <MtProtoKit/MTAtomic.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface MTAtomic () @interface MTAtomic ()
{ {
volatile OSSpinLock _lock; os_unfair_lock _lock;
id _value; id _value;
} }
@ -25,19 +25,19 @@
- (id)swap:(id)newValue - (id)swap:(id)newValue
{ {
id previousValue = nil; id previousValue = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
previousValue = _value; previousValue = _value;
_value = newValue; _value = newValue;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return previousValue; return previousValue;
} }
- (id)value - (id)value
{ {
id previousValue = nil; id previousValue = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
previousValue = _value; previousValue = _value;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return previousValue; return previousValue;
} }
@ -45,19 +45,19 @@
- (id)modify:(id (^)(id))f - (id)modify:(id (^)(id))f
{ {
id newValue = nil; id newValue = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
newValue = f(_value); newValue = f(_value);
_value = newValue; _value = newValue;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return newValue; return newValue;
} }
- (id)with:(id (^)(id))f - (id)with:(id (^)(id))f
{ {
id result = nil; id result = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
result = f(_value); result = f(_value);
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return result; return result;
} }

View File

@ -22,7 +22,7 @@
#import <MtProtoKit/MTApiEnvironment.h> #import <MtProtoKit/MTApiEnvironment.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import "MTDiscoverConnectionSignals.h" #import "MTDiscoverConnectionSignals.h"
@ -176,7 +176,7 @@ static MTDatacenterAuthInfoMapKeyStruct parseAuthInfoMapKeyInteger(NSNumber *key
NSMutableDictionary *_periodicTasksTimerByDatacenterId; NSMutableDictionary *_periodicTasksTimerByDatacenterId;
volatile OSSpinLock _passwordEntryRequiredLock; os_unfair_lock _passwordEntryRequiredLock;
NSMutableDictionary *_passwordRequiredByDatacenterId; NSMutableDictionary *_passwordRequiredByDatacenterId;
NSMutableDictionary *_transportSchemeDisposableByDatacenterId; NSMutableDictionary *_transportSchemeDisposableByDatacenterId;
@ -680,20 +680,20 @@ static void copyKeychainKey(NSString * _Nonnull group, NSString * _Nonnull key,
- (bool)isPasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId - (bool)isPasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId
{ {
OSSpinLockLock(&_passwordEntryRequiredLock); os_unfair_lock_lock(&_passwordEntryRequiredLock);
bool currentValue = [_passwordRequiredByDatacenterId[@(datacenterId)] boolValue]; bool currentValue = [_passwordRequiredByDatacenterId[@(datacenterId)] boolValue];
OSSpinLockUnlock(&_passwordEntryRequiredLock); os_unfair_lock_unlock(&_passwordEntryRequiredLock);
return currentValue; return currentValue;
} }
- (bool)updatePasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId required:(bool)required - (bool)updatePasswordInputRequiredForDatacenterWithId:(NSInteger)datacenterId required:(bool)required
{ {
OSSpinLockLock(&_passwordEntryRequiredLock); os_unfair_lock_lock(&_passwordEntryRequiredLock);
bool currentValue = [_passwordRequiredByDatacenterId[@(datacenterId)] boolValue]; bool currentValue = [_passwordRequiredByDatacenterId[@(datacenterId)] boolValue];
bool updated = currentValue != required; bool updated = currentValue != required;
_passwordRequiredByDatacenterId[@(datacenterId)] = @(required); _passwordRequiredByDatacenterId[@(datacenterId)] = @(required);
OSSpinLockUnlock(&_passwordEntryRequiredLock); os_unfair_lock_unlock(&_passwordEntryRequiredLock);
if (updated) if (updated)
{ {

View File

@ -1,6 +1,8 @@
#import <MtProtoKit/MTDisposable.h> #import <MtProtoKit/MTDisposable.h>
#import <os/lock.h>
#import <libkern/OSAtomic.h> #import <libkern/OSAtomic.h>
#import <stdatomic.h>
#import <objc/runtime.h> #import <objc/runtime.h>
@interface MTBlockDisposable () @interface MTBlockDisposable ()
@ -27,6 +29,8 @@
void *block = _block; void *block = _block;
if (block != NULL) if (block != NULL)
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) if (OSAtomicCompareAndSwapPtr(block, 0, &_block))
{ {
if (block != nil) if (block != nil)
@ -35,6 +39,7 @@
strongBlock = nil; strongBlock = nil;
} }
} }
#pragma clang diagnostic pop
} }
} }
@ -43,6 +48,8 @@
void *block = _block; void *block = _block;
if (block != NULL) if (block != NULL)
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) if (OSAtomicCompareAndSwapPtr(block, 0, &_block))
{ {
if (block != nil) if (block != nil)
@ -52,6 +59,7 @@
strongBlock = nil; strongBlock = nil;
} }
} }
#pragma clang diagnostic pop
} }
} }
@ -59,7 +67,7 @@
@interface MTMetaDisposable () @interface MTMetaDisposable ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _disposed; bool _disposed;
id<MTDisposable> _disposable; id<MTDisposable> _disposable;
} }
@ -73,14 +81,14 @@
id<MTDisposable> previousDisposable = nil; id<MTDisposable> previousDisposable = nil;
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
dispose = _disposed; dispose = _disposed;
if (!dispose) if (!dispose)
{ {
previousDisposable = _disposable; previousDisposable = _disposable;
_disposable = disposable; _disposable = disposable;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (previousDisposable != nil) if (previousDisposable != nil)
[previousDisposable dispose]; [previousDisposable dispose];
@ -93,13 +101,13 @@
{ {
id<MTDisposable> disposable = nil; id<MTDisposable> disposable = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_disposed) if (!_disposed)
{ {
disposable = _disposable; disposable = _disposable;
_disposed = true; _disposed = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (disposable != nil) if (disposable != nil)
[disposable dispose]; [disposable dispose];
@ -109,7 +117,7 @@
@interface MTDisposableSet () @interface MTDisposableSet ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _disposed; bool _disposed;
id<MTDisposable> _singleDisposable; id<MTDisposable> _singleDisposable;
NSArray *_multipleDisposables; NSArray *_multipleDisposables;
@ -126,7 +134,7 @@
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
dispose = _disposed; dispose = _disposed;
if (!dispose) if (!dispose)
{ {
@ -147,14 +155,14 @@
_singleDisposable = disposable; _singleDisposable = disposable;
} }
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (dispose) if (dispose)
[disposable dispose]; [disposable dispose];
} }
- (void)remove:(id<MTDisposable>)disposable { - (void)remove:(id<MTDisposable>)disposable {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_multipleDisposables != nil) if (_multipleDisposables != nil)
{ {
NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables];
@ -165,7 +173,7 @@
{ {
_singleDisposable = nil; _singleDisposable = nil;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)dispose - (void)dispose
@ -173,7 +181,7 @@
id<MTDisposable> singleDisposable = nil; id<MTDisposable> singleDisposable = nil;
NSArray *multipleDisposables = nil; NSArray *multipleDisposables = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_disposed) if (!_disposed)
{ {
_disposed = true; _disposed = true;
@ -182,7 +190,7 @@
_singleDisposable = nil; _singleDisposable = nil;
_multipleDisposables = nil; _multipleDisposables = nil;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (singleDisposable != nil) if (singleDisposable != nil)
[singleDisposable dispose]; [singleDisposable dispose];

View File

@ -2,7 +2,12 @@
#import <MtProtoKit/MTInternalId.h> #import <MtProtoKit/MTInternalId.h>
#import <libkern/OSAtomic.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
MTInternalIdClass(MTMessageTransaction) MTInternalIdClass(MTMessageTransaction)
#pragma clang diagnostic pop
@implementation MTMessageTransaction @implementation MTMessageTransaction

View File

@ -1,7 +1,7 @@
#import <MtProtoKit/MTNetworkUsageManager.h> #import <MtProtoKit/MTNetworkUsageManager.h>
#include <sys/mman.h> #include <sys/mman.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <MtProtoKit/MTNetworkUsageCalculationInfo.h> #import <MtProtoKit/MTNetworkUsageCalculationInfo.h>
#import <MtProtoKit/MTSignal.h> #import <MtProtoKit/MTSignal.h>

View File

@ -1,5 +1,6 @@
#import <MtProtoKit/MTOutgoingMessage.h> #import <MtProtoKit/MTOutgoingMessage.h>
#import <os/lock.h>
#import <libkern/OSAtomic.h> #import <libkern/OSAtomic.h>
@interface MTOutgoingMessageInternalId : NSObject <NSCopying> @interface MTOutgoingMessageInternalId : NSObject <NSCopying>
@ -17,7 +18,10 @@
if (self != nil) if (self != nil)
{ {
static int32_t nextValue = 1; static int32_t nextValue = 1;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_value = OSAtomicIncrement32(&nextValue); _value = OSAtomicIncrement32(&nextValue);
#pragma clang diagnostic pop
} }
return self; return self;
} }

View File

@ -2,7 +2,12 @@
#import <MtProtoKit/MTInternalId.h> #import <MtProtoKit/MTInternalId.h>
#import <libkern/OSAtomic.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
MTInternalIdClass(MTPreparedMessage) MTInternalIdClass(MTPreparedMessage)
#pragma clang diagnostic pop
@implementation MTPreparedMessage @implementation MTPreparedMessage

View File

@ -2,6 +2,7 @@
#import <MtProtoKit/MTRpcError.h> #import <MtProtoKit/MTRpcError.h>
#import <os/lock.h>
#import <libkern/OSAtomic.h> #import <libkern/OSAtomic.h>
@interface MTRequestInternalId : NSObject <NSCopying> @interface MTRequestInternalId : NSObject <NSCopying>
@ -19,7 +20,10 @@
if (self != nil) if (self != nil)
{ {
static int32_t nextValue = 1; static int32_t nextValue = 1;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
_value = OSAtomicIncrement32(&nextValue); _value = OSAtomicIncrement32(&nextValue);
#pragma clang diagnostic pop
} }
return self; return self;
} }

View File

@ -1,6 +1,6 @@
#import <MtProtoKit/MTSignal.h> #import <MtProtoKit/MTSignal.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <MtProtoKit/MTTimer.h> #import <MtProtoKit/MTTimer.h>
#import <MtProtoKit/MTQueue.h> #import <MtProtoKit/MTQueue.h>
#import <MtProtoKit/MTAtomic.h> #import <MtProtoKit/MTAtomic.h>
@ -55,7 +55,7 @@
@interface MTSignalQueueState : NSObject <MTDisposable> @interface MTSignalQueueState : NSObject <MTDisposable>
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _executingSignal; bool _executingSignal;
bool _terminated; bool _terminated;
@ -92,7 +92,7 @@
- (void)enqueueSignal:(MTSignal *)signal - (void)enqueueSignal:(MTSignal *)signal
{ {
bool startSignal = false; bool startSignal = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_queueMode && _executingSignal) if (_queueMode && _executingSignal)
{ {
[_queuedSignals addObject:signal]; [_queuedSignals addObject:signal];
@ -102,7 +102,7 @@
_executingSignal = true; _executingSignal = true;
startSignal = true; startSignal = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (startSignal) if (startSignal)
{ {
@ -130,7 +130,7 @@
MTSignal *nextSignal = nil; MTSignal *nextSignal = nil;
bool terminated = false; bool terminated = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
_executingSignal = false; _executingSignal = false;
if (_queueMode) if (_queueMode)
@ -146,7 +146,7 @@
} }
else else
terminated = _terminated; terminated = _terminated;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (terminated) if (terminated)
[_subscriber putCompletion]; [_subscriber putCompletion];
@ -174,10 +174,10 @@
- (void)beginCompletion - (void)beginCompletion
{ {
bool executingSignal = false; bool executingSignal = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
executingSignal = _executingSignal; executingSignal = _executingSignal;
_terminated = true; _terminated = true;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (!executingSignal) if (!executingSignal)
[_subscriber putCompletion]; [_subscriber putCompletion];

View File

@ -1,6 +1,6 @@
#import <MtProtoKit/MTSubscriber.h> #import <MtProtoKit/MTSubscriber.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface MTSubscriberBlocks : NSObject { @interface MTSubscriberBlocks : NSObject {
@public @public
@ -28,7 +28,7 @@
@interface MTSubscriber () @interface MTSubscriber ()
{ {
@protected @protected
OSSpinLock _lock; os_unfair_lock _lock;
bool _terminated; bool _terminated;
id<MTDisposable> _disposable; id<MTDisposable> _disposable;
MTSubscriberBlocks *_blocks; MTSubscriberBlocks *_blocks;
@ -51,13 +51,13 @@
- (void)_assignDisposable:(id<MTDisposable>)disposable - (void)_assignDisposable:(id<MTDisposable>)disposable
{ {
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_terminated) { if (_terminated) {
dispose = true; dispose = true;
} else { } else {
_disposable = disposable; _disposable = disposable;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (dispose) { if (dispose) {
[disposable dispose]; [disposable dispose];
@ -66,7 +66,7 @@
- (void)_markTerminatedWithoutDisposal - (void)_markTerminatedWithoutDisposal
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
MTSubscriberBlocks *blocks = nil; MTSubscriberBlocks *blocks = nil;
if (!_terminated) if (!_terminated)
{ {
@ -75,7 +75,7 @@
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks) { if (blocks) {
blocks = nil; blocks = nil;
@ -86,11 +86,11 @@
{ {
MTSubscriberBlocks *blocks = nil; MTSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) { if (!_terminated) {
blocks = _blocks; blocks = _blocks;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_next) { if (blocks && blocks->_next) {
blocks->_next(next); blocks->_next(next);
@ -102,7 +102,7 @@
bool shouldDispose = false; bool shouldDispose = false;
MTSubscriberBlocks *blocks = nil; MTSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
blocks = _blocks; blocks = _blocks;
@ -111,7 +111,7 @@
shouldDispose = true; shouldDispose = true;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_error) { if (blocks && blocks->_error) {
blocks->_error(error); blocks->_error(error);
@ -126,7 +126,7 @@
bool shouldDispose = false; bool shouldDispose = false;
MTSubscriberBlocks *blocks = nil; MTSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
blocks = _blocks; blocks = _blocks;
@ -135,7 +135,7 @@
shouldDispose = true; shouldDispose = true;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_completed) if (blocks && blocks->_completed)
blocks->_completed(); blocks->_completed();

View File

@ -25,6 +25,8 @@
#import <EncryptionProvider/EncryptionProvider.h> #import <EncryptionProvider/EncryptionProvider.h>
#import <libkern/OSAtomic.h>
static id<MTBignum> get_y2(id<MTBignum> x, id<MTBignum> mod, id<MTBignumContext> context) { static id<MTBignum> get_y2(id<MTBignum> x, id<MTBignum> mod, id<MTBignumContext> context) {
// returns y^2 = x^3 + 486662 * x^2 + x // returns y^2 = x^3 + 486662 * x^2 + x
id<MTBignum> y = [context clone:x]; id<MTBignum> y = [context clone:x];
@ -495,7 +497,10 @@ static NSData *executeGenerationCode(id<EncryptionProvider> provider, NSData *do
@end @end
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
MTInternalIdClass(MTTcpConnection) MTInternalIdClass(MTTcpConnection)
#pragma clang diagnostic pop
struct socks5_ident_req struct socks5_ident_req
{ {

View File

@ -727,7 +727,7 @@ private func deviceContactInfoEntries(account: Account, engine: TelegramEngine,
var addressIndex = 0 var addressIndex = 0
for address in contactData.addresses { for address in contactData.addresses {
let signal = geocodeLocation(dictionary: address.dictionary) let signal = geocodeLocation(address: address.asPostalAddress)
|> mapToSignal { coordinates -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in |> mapToSignal { coordinates -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in
if let (latitude, longitude) = coordinates { if let (latitude, longitude) = coordinates {
let resource = MapSnapshotMediaResource(latitude: latitude, longitude: longitude, width: 90, height: 90) let resource = MapSnapshotMediaResource(latitude: latitude, longitude: longitude, width: 90, height: 90)

View File

@ -17,6 +17,7 @@
#import <LegacyReachability/LegacyReachability.h> #import <LegacyReachability/LegacyReachability.h>
#import <pthread.h> #import <pthread.h>
#import <os/lock.h>
#import <libkern/OSAtomic.h> #import <libkern/OSAtomic.h>
#pragma mark IPv6 Support #pragma mark IPv6 Support

View File

@ -1,7 +1,8 @@
#import "SBlockDisposable.h" #import "SBlockDisposable.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#import <libkern/OSAtomic.h>
@interface SBlockDisposable () @interface SBlockDisposable ()
{ {
@ -27,6 +28,8 @@
void *block = _block; void *block = _block;
if (block != NULL) if (block != NULL)
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) if (OSAtomicCompareAndSwapPtr(block, 0, &_block))
{ {
if (block != nil) if (block != nil)
@ -35,6 +38,7 @@
strongBlock = nil; strongBlock = nil;
} }
} }
#pragma clang diagnostic pop
} }
} }
@ -43,6 +47,8 @@
void *block = _block; void *block = _block;
if (block != NULL) if (block != NULL)
{ {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) if (OSAtomicCompareAndSwapPtr(block, 0, &_block))
{ {
if (block != nil) if (block != nil)
@ -52,6 +58,7 @@
strongBlock = nil; strongBlock = nil;
} }
} }
#pragma clang diagnostic pop
} }
} }

View File

@ -2,11 +2,11 @@
#import "SSignal.h" #import "SSignal.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface SDisposableSet () @interface SDisposableSet ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _disposed; bool _disposed;
id<SDisposable> _singleDisposable; id<SDisposable> _singleDisposable;
NSArray *_multipleDisposables; NSArray *_multipleDisposables;
@ -23,7 +23,7 @@
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
dispose = _disposed; dispose = _disposed;
if (!dispose) if (!dispose)
{ {
@ -44,14 +44,14 @@
_singleDisposable = disposable; _singleDisposable = disposable;
} }
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (dispose) if (dispose)
[disposable dispose]; [disposable dispose];
} }
- (void)remove:(id<SDisposable>)disposable { - (void)remove:(id<SDisposable>)disposable {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_multipleDisposables != nil) if (_multipleDisposables != nil)
{ {
NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables];
@ -62,7 +62,7 @@
{ {
_singleDisposable = nil; _singleDisposable = nil;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)dispose - (void)dispose
@ -70,7 +70,7 @@
id<SDisposable> singleDisposable = nil; id<SDisposable> singleDisposable = nil;
NSArray *multipleDisposables = nil; NSArray *multipleDisposables = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_disposed) if (!_disposed)
{ {
_disposed = true; _disposed = true;
@ -79,7 +79,7 @@
_singleDisposable = nil; _singleDisposable = nil;
_multipleDisposables = nil; _multipleDisposables = nil;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (singleDisposable != nil) if (singleDisposable != nil)
[singleDisposable dispose]; [singleDisposable dispose];

View File

@ -1,10 +1,10 @@
#import "SMetaDisposable.h" #import "SMetaDisposable.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface SMetaDisposable () @interface SMetaDisposable ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _disposed; bool _disposed;
id<SDisposable> _disposable; id<SDisposable> _disposable;
} }
@ -18,14 +18,14 @@
id<SDisposable> previousDisposable = nil; id<SDisposable> previousDisposable = nil;
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
dispose = _disposed; dispose = _disposed;
if (!dispose) if (!dispose)
{ {
previousDisposable = _disposable; previousDisposable = _disposable;
_disposable = disposable; _disposable = disposable;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (previousDisposable != nil) if (previousDisposable != nil)
[previousDisposable dispose]; [previousDisposable dispose];
@ -38,13 +38,13 @@
{ {
id<SDisposable> disposable = nil; id<SDisposable> disposable = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_disposed) if (!_disposed)
{ {
disposable = _disposable; disposable = _disposable;
_disposed = true; _disposed = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (disposable != nil) if (disposable != nil)
[disposable dispose]; [disposable dispose];

View File

@ -6,11 +6,11 @@
#import "SMetaDisposable.h" #import "SMetaDisposable.h"
#import "SBlockDisposable.h" #import "SBlockDisposable.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface SMulticastSignalManager () @interface SMulticastSignalManager ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
NSMutableDictionary *_multicastSignals; NSMutableDictionary *_multicastSignals;
NSMutableDictionary *_standaloneSignalDisposables; NSMutableDictionary *_standaloneSignalDisposables;
NSMutableDictionary *_pipeListeners; NSMutableDictionary *_pipeListeners;
@ -35,9 +35,9 @@
- (void)dealloc - (void)dealloc
{ {
NSArray *disposables = nil; NSArray *disposables = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
disposables = [_standaloneSignalDisposables allValues]; disposables = [_standaloneSignalDisposables allValues];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (id<SDisposable> disposable in disposables) for (id<SDisposable> disposable in disposables)
{ {
@ -56,7 +56,7 @@
} }
SSignal *signal = nil; SSignal *signal = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
signal = _multicastSignals[key]; signal = _multicastSignals[key];
if (signal == nil) if (signal == nil)
{ {
@ -70,15 +70,15 @@
__strong SMulticastSignalManager *strongSelf = weakSelf; __strong SMulticastSignalManager *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
{ {
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf->_multicastSignals removeObjectForKey:key]; [strongSelf->_multicastSignals removeObjectForKey:key];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
} }
}] multicast]; }] multicast];
_multicastSignals[key] = signal; _multicastSignals[key] = signal;
} }
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return signal; return signal;
} }
@ -89,13 +89,13 @@
return; return;
bool produce = false; bool produce = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_standaloneSignalDisposables[key] == nil) if (_standaloneSignalDisposables[key] == nil)
{ {
_standaloneSignalDisposables[key] = [[SMetaDisposable alloc] init]; _standaloneSignalDisposables[key] = [[SMetaDisposable alloc] init];
produce = true; produce = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (produce) if (produce)
{ {
@ -105,24 +105,24 @@
__strong SMulticastSignalManager *strongSelf = weakSelf; __strong SMulticastSignalManager *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
{ {
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf->_standaloneSignalDisposables removeObjectForKey:key]; [strongSelf->_standaloneSignalDisposables removeObjectForKey:key];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
} }
} completed:^ } completed:^
{ {
__strong SMulticastSignalManager *strongSelf = weakSelf; __strong SMulticastSignalManager *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
{ {
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf->_standaloneSignalDisposables removeObjectForKey:key]; [strongSelf->_standaloneSignalDisposables removeObjectForKey:key];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
} }
}]; }];
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
[(SMetaDisposable *)_standaloneSignalDisposables[key] setDisposable:disposable]; [(SMetaDisposable *)_standaloneSignalDisposables[key] setDisposable:disposable];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
} }
@ -130,7 +130,7 @@
{ {
return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber) return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber)
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
SBag *bag = _pipeListeners[key]; SBag *bag = _pipeListeners[key];
if (bag == nil) if (bag == nil)
{ {
@ -141,26 +141,26 @@
{ {
[subscriber putNext:next]; [subscriber putNext:next];
} copy]]; } copy]];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return [[SBlockDisposable alloc] initWithBlock:^ return [[SBlockDisposable alloc] initWithBlock:^
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
SBag *bag = _pipeListeners[key]; SBag *bag = _pipeListeners[key];
[bag removeItem:index]; [bag removeItem:index];
if ([bag isEmpty]) { if ([bag isEmpty]) {
[_pipeListeners removeObjectForKey:key]; [_pipeListeners removeObjectForKey:key];
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
}]; }];
}]; }];
} }
- (void)putNext:(id)next toMulticastedPipeForKey:(NSString *)key - (void)putNext:(id)next toMulticastedPipeForKey:(NSString *)key
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
NSArray *pipeListeners = [(SBag *)_pipeListeners[key] copyItems]; NSArray *pipeListeners = [(SBag *)_pipeListeners[key] copyItems];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (void (^listener)(id) in pipeListeners) for (void (^listener)(id) in pipeListeners)
{ {

View File

@ -6,11 +6,11 @@
#import "SAtomic.h" #import "SAtomic.h"
#import "SSignal+Pipe.h" #import "SSignal+Pipe.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface SSignalQueueState : NSObject <SDisposable> @interface SSignalQueueState : NSObject <SDisposable>
{ {
OSSpinLock _lock; os_unfair_lock _lock;
bool _executingSignal; bool _executingSignal;
bool _terminated; bool _terminated;
@ -49,7 +49,7 @@
- (void)enqueueSignal:(SSignal *)signal - (void)enqueueSignal:(SSignal *)signal
{ {
bool startSignal = false; bool startSignal = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_queueMode && _executingSignal) { if (_queueMode && _executingSignal) {
if (_throttleMode) { if (_throttleMode) {
[_queuedSignals removeAllObjects]; [_queuedSignals removeAllObjects];
@ -61,7 +61,7 @@
_executingSignal = true; _executingSignal = true;
startSignal = true; startSignal = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (startSignal) if (startSignal)
{ {
@ -89,7 +89,7 @@
SSignal *nextSignal = nil; SSignal *nextSignal = nil;
bool terminated = false; bool terminated = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
_executingSignal = false; _executingSignal = false;
if (_queueMode) if (_queueMode)
@ -105,7 +105,7 @@
} }
else else
terminated = _terminated; terminated = _terminated;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (terminated) if (terminated)
[_subscriber putCompletion]; [_subscriber putCompletion];
@ -133,10 +133,10 @@
- (void)beginCompletion - (void)beginCompletion
{ {
bool executingSignal = false; bool executingSignal = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
executingSignal = _executingSignal; executingSignal = _executingSignal;
_terminated = true; _terminated = true;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (!executingSignal) if (!executingSignal)
[_subscriber putCompletion]; [_subscriber putCompletion];

View File

@ -1,6 +1,6 @@
#import "SSignal+Multicast.h" #import "SSignal+Multicast.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import "SBag.h" #import "SBag.h"
#import "SBlockDisposable.h" #import "SBlockDisposable.h"
@ -12,7 +12,7 @@ typedef enum {
@interface SSignalMulticastSubscribers : NSObject @interface SSignalMulticastSubscribers : NSObject
{ {
volatile OSSpinLock _lock; os_unfair_lock _lock;
SBag *_subscribers; SBag *_subscribers;
SSignalMulticastState _state; SSignalMulticastState _state;
id<SDisposable> _disposable; id<SDisposable> _disposable;
@ -40,7 +40,7 @@ typedef enum {
- (id<SDisposable>)addSubscriber:(SSubscriber *)subscriber start:(bool *)start - (id<SDisposable>)addSubscriber:(SSubscriber *)subscriber start:(bool *)start
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
NSInteger index = [_subscribers addItem:subscriber]; NSInteger index = [_subscribers addItem:subscriber];
switch (_state) { switch (_state) {
case SSignalMulticastStateReady: case SSignalMulticastStateReady:
@ -50,7 +50,7 @@ typedef enum {
default: default:
break; break;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
return [[SBlockDisposable alloc] initWithBlock:^ return [[SBlockDisposable alloc] initWithBlock:^
{ {
@ -62,7 +62,7 @@ typedef enum {
{ {
id<SDisposable> currentDisposable = nil; id<SDisposable> currentDisposable = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
[_subscribers removeItem:index]; [_subscribers removeItem:index];
switch (_state) { switch (_state) {
case SSignalMulticastStateStarted: case SSignalMulticastStateStarted:
@ -75,7 +75,7 @@ typedef enum {
default: default:
break; break;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
[currentDisposable dispose]; [currentDisposable dispose];
} }
@ -83,9 +83,9 @@ typedef enum {
- (void)notifyNext:(id)next - (void)notifyNext:(id)next
{ {
NSArray *currentSubscribers = nil; NSArray *currentSubscribers = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
currentSubscribers = [_subscribers copyItems]; currentSubscribers = [_subscribers copyItems];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (SSubscriber *subscriber in currentSubscribers) for (SSubscriber *subscriber in currentSubscribers)
{ {
@ -96,10 +96,10 @@ typedef enum {
- (void)notifyError:(id)error - (void)notifyError:(id)error
{ {
NSArray *currentSubscribers = nil; NSArray *currentSubscribers = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
currentSubscribers = [_subscribers copyItems]; currentSubscribers = [_subscribers copyItems];
_state = SSignalMulticastStateCompleted; _state = SSignalMulticastStateCompleted;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (SSubscriber *subscriber in currentSubscribers) for (SSubscriber *subscriber in currentSubscribers)
{ {
@ -110,10 +110,10 @@ typedef enum {
- (void)notifyCompleted - (void)notifyCompleted
{ {
NSArray *currentSubscribers = nil; NSArray *currentSubscribers = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
currentSubscribers = [_subscribers copyItems]; currentSubscribers = [_subscribers copyItems];
_state = SSignalMulticastStateCompleted; _state = SSignalMulticastStateCompleted;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (SSubscriber *subscriber in currentSubscribers) for (SSubscriber *subscriber in currentSubscribers)
{ {

View File

@ -1,6 +1,6 @@
#import "SSubscriber.h" #import "SSubscriber.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
@interface SSubscriberBlocks : NSObject { @interface SSubscriberBlocks : NSObject {
@public @public
@ -28,7 +28,7 @@
@interface SSubscriber () @interface SSubscriber ()
{ {
@protected @protected
OSSpinLock _lock; os_unfair_lock _lock;
bool _terminated; bool _terminated;
id<SDisposable> _disposable; id<SDisposable> _disposable;
SSubscriberBlocks *_blocks; SSubscriberBlocks *_blocks;
@ -51,13 +51,13 @@
- (void)_assignDisposable:(id<SDisposable>)disposable - (void)_assignDisposable:(id<SDisposable>)disposable
{ {
bool dispose = false; bool dispose = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_terminated) { if (_terminated) {
dispose = true; dispose = true;
} else { } else {
_disposable = disposable; _disposable = disposable;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (dispose) { if (dispose) {
[disposable dispose]; [disposable dispose];
} }
@ -65,7 +65,7 @@
- (void)_markTerminatedWithoutDisposal - (void)_markTerminatedWithoutDisposal
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
SSubscriberBlocks *blocks = nil; SSubscriberBlocks *blocks = nil;
if (!_terminated) if (!_terminated)
{ {
@ -74,7 +74,7 @@
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks) { if (blocks) {
blocks = nil; blocks = nil;
@ -85,11 +85,11 @@
{ {
SSubscriberBlocks *blocks = nil; SSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) { if (!_terminated) {
blocks = _blocks; blocks = _blocks;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_next) { if (blocks && blocks->_next) {
blocks->_next(next); blocks->_next(next);
@ -101,7 +101,7 @@
bool shouldDispose = false; bool shouldDispose = false;
SSubscriberBlocks *blocks = nil; SSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
blocks = _blocks; blocks = _blocks;
@ -110,7 +110,7 @@
shouldDispose = true; shouldDispose = true;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_error) { if (blocks && blocks->_error) {
blocks->_error(error); blocks->_error(error);
@ -125,7 +125,7 @@
bool shouldDispose = false; bool shouldDispose = false;
SSubscriberBlocks *blocks = nil; SSubscriberBlocks *blocks = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
blocks = _blocks; blocks = _blocks;
@ -134,7 +134,7 @@
shouldDispose = true; shouldDispose = true;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (blocks && blocks->_completed) if (blocks && blocks->_completed)
blocks->_completed(); blocks->_completed();
@ -179,7 +179,7 @@
- (void)_markTerminatedWithoutDisposal - (void)_markTerminatedWithoutDisposal
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
NSLog(@"trace(%@ terminated)", _name); NSLog(@"trace(%@ terminated)", _name);
@ -188,17 +188,17 @@
_error = nil; _error = nil;
_completed = nil; _completed = nil;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)putNext:(id)next - (void)putNext:(id)next
{ {
void (^fnext)(id) = nil; void (^fnext)(id) = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
fnext = self->_next; fnext = self->_next;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (fnext) if (fnext)
{ {
@ -214,7 +214,7 @@
bool shouldDispose = false; bool shouldDispose = false;
void (^ferror)(id) = nil; void (^ferror)(id) = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
ferror = self->_error; ferror = self->_error;
@ -224,7 +224,7 @@
self->_completed = nil; self->_completed = nil;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (ferror) if (ferror)
{ {
@ -243,7 +243,7 @@
bool shouldDispose = false; bool shouldDispose = false;
void (^completed)() = nil; void (^completed)() = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (!_terminated) if (!_terminated)
{ {
completed = self->_completed; completed = self->_completed;
@ -253,7 +253,7 @@
self->_completed = nil; self->_completed = nil;
_terminated = true; _terminated = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (completed) if (completed)
{ {

View File

@ -1,6 +1,6 @@
#import "SThreadPool.h" #import "SThreadPool.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <pthread.h> #import <pthread.h>
#import "SQueue.h" #import "SQueue.h"

View File

@ -1,6 +1,6 @@
#import "SVariable.h" #import "SVariable.h"
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import "SSignal.h" #import "SSignal.h"
#import "SBag.h" #import "SBag.h"
@ -9,7 +9,7 @@
@interface SVariable () @interface SVariable ()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
id _value; id _value;
bool _hasValue; bool _hasValue;
SBag *_subscribers; SBag *_subscribers;
@ -40,14 +40,14 @@
{ {
return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber) return [[SSignal alloc] initWithGenerator:^id<SDisposable>(SSubscriber *subscriber)
{ {
OSSpinLockLock(&self->_lock); os_unfair_lock_lock(&self->_lock);
id currentValue = _value; id currentValue = _value;
bool hasValue = _hasValue; bool hasValue = _hasValue;
NSInteger index = [self->_subscribers addItem:[^(id value) NSInteger index = [self->_subscribers addItem:[^(id value)
{ {
[subscriber putNext:value]; [subscriber putNext:value];
} copy]]; } copy]];
OSSpinLockUnlock(&self->_lock); os_unfair_lock_unlock(&self->_lock);
if (hasValue) if (hasValue)
{ {
@ -56,18 +56,18 @@
return [[SBlockDisposable alloc] initWithBlock:^ return [[SBlockDisposable alloc] initWithBlock:^
{ {
OSSpinLockLock(&self->_lock); os_unfair_lock_lock(&self->_lock);
[self->_subscribers removeItem:index]; [self->_subscribers removeItem:index];
OSSpinLockUnlock(&self->_lock); os_unfair_lock_unlock(&self->_lock);
}]; }];
}]; }];
} }
- (void)set:(SSignal *)signal - (void)set:(SSignal *)signal
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
_hasValue = false; _hasValue = false;
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
__weak SVariable *weakSelf = self; __weak SVariable *weakSelf = self;
[_disposable setDisposable:[signal startWithNext:^(id next) [_disposable setDisposable:[signal startWithNext:^(id next)
@ -76,11 +76,11 @@
if (strongSelf != nil) if (strongSelf != nil)
{ {
NSArray *subscribers = nil; NSArray *subscribers = nil;
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
strongSelf->_value = next; strongSelf->_value = next;
strongSelf->_hasValue = true; strongSelf->_hasValue = true;
subscribers = [strongSelf->_subscribers copyItems]; subscribers = [strongSelf->_subscribers copyItems];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
for (void (^subscriber)(id) in subscribers) for (void (^subscriber)(id) in subscribers)
{ {

View File

@ -43,7 +43,7 @@ public enum Passthrough<T> {
} }
private final class ReduceQueueState<T, E> : Disposable { private final class ReduceQueueState<T, E> : Disposable {
var lock: OSSpinLock = 0 var lock = os_unfair_lock()
var executingSignal = false var executingSignal = false
var terminated = false var terminated = false
@ -68,7 +68,7 @@ private final class ReduceQueueState<T, E> : Disposable {
func enqueueNext(_ next: T) { func enqueueNext(_ next: T) {
var startSignal = false var startSignal = false
var currentValue: T var currentValue: T
OSSpinLockLock(&self.lock) os_unfair_lock_lock(&self.lock)
currentValue = self.value currentValue = self.value
if self.executingSignal { if self.executingSignal {
self.queuedValues.append(next) self.queuedValues.append(next)
@ -76,7 +76,7 @@ private final class ReduceQueueState<T, E> : Disposable {
self.executingSignal = true self.executingSignal = true
startSignal = true startSignal = true
} }
OSSpinLockUnlock(&self.lock) os_unfair_lock_unlock(&self.lock)
if startSignal { if startSignal {
let disposable = generator(currentValue, next).start(next: { next in let disposable = generator(currentValue, next).start(next: { next in
@ -97,9 +97,9 @@ private final class ReduceQueueState<T, E> : Disposable {
} }
func updateValue(_ value: T) { func updateValue(_ value: T) {
OSSpinLockLock(&self.lock) os_unfair_lock_lock(&self.lock)
self.value = value self.value = value
OSSpinLockUnlock(&self.lock) os_unfair_lock_unlock(&self.lock)
} }
func headCompleted() { func headCompleted() {
@ -110,7 +110,7 @@ private final class ReduceQueueState<T, E> : Disposable {
var terminated = false var terminated = false
var currentValue: T! var currentValue: T!
OSSpinLockLock(&self.lock) os_unfair_lock_lock(&self.lock)
self.executingSignal = false self.executingSignal = false
if self.queuedValues.count != 0 { if self.queuedValues.count != 0 {
nextSignal = self.generator(self.value, self.queuedValues[0]) nextSignal = self.generator(self.value, self.queuedValues[0])
@ -120,7 +120,7 @@ private final class ReduceQueueState<T, E> : Disposable {
currentValue = self.value currentValue = self.value
terminated = self.terminated terminated = self.terminated
} }
OSSpinLockUnlock(&self.lock) os_unfair_lock_unlock(&self.lock)
if terminated { if terminated {
self.subscriber.putNext(currentValue) self.subscriber.putNext(currentValue)
@ -154,11 +154,11 @@ private final class ReduceQueueState<T, E> : Disposable {
func beginCompletion() { func beginCompletion() {
var executingSignal = false var executingSignal = false
let currentValue: T let currentValue: T
OSSpinLockLock(&self.lock) os_unfair_lock_lock(&self.lock)
executingSignal = self.executingSignal executingSignal = self.executingSignal
self.terminated = true self.terminated = true
currentValue = self.value currentValue = self.value
OSSpinLockUnlock(&self.lock) os_unfair_lock_unlock(&self.lock)
if !executingSignal { if !executingSignal {
self.subscriber.putNext(currentValue) self.subscriber.putNext(currentValue)

View File

@ -140,7 +140,6 @@ public func copyToPasteboard(context: AccountContext, postbox: Postbox, mediaRef
if case let .data(data) = state, data.complete { if case let .data(data) = state, data.complete {
return Signal<Void, NoError> { subscriber in return Signal<Void, NoError> { subscriber in
let pasteboard = UIPasteboard.general let pasteboard = UIPasteboard.general
pasteboard.setPersistent(true)
if mediaReference.media is TelegramMediaImage { if mediaReference.media is TelegramMediaImage {
if let fileData = try? Data(contentsOf: URL(fileURLWithPath: data.path), options: .mappedIfSafe) { if let fileData = try? Data(contentsOf: URL(fileURLWithPath: data.path), options: .mappedIfSafe) {

View File

@ -94,6 +94,6 @@ typedef NS_ENUM(NSUInteger, STPBillingAddressFields) {
- (BOOL)containsRequiredFields:(STPBillingAddressFields)requiredFields; - (BOOL)containsRequiredFields:(STPBillingAddressFields)requiredFields;
+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields:(STPBillingAddressFields)billingAddressFields; FAUXPAS_IGNORED_ON_LINE(APIAvailability); //+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields:(STPBillingAddressFields)billingAddressFields; FAUXPAS_IGNORED_ON_LINE(APIAvailability);
@end @end

View File

@ -91,7 +91,7 @@
countryCode:self.country]); countryCode:self.country]);
} }
+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields:(STPBillingAddressFields)billingAddressFields { /*+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields:(STPBillingAddressFields)billingAddressFields {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability); FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
switch (billingAddressFields) { switch (billingAddressFields) {
case STPBillingAddressFieldsNone: case STPBillingAddressFieldsNone:
@ -100,7 +100,7 @@
case STPBillingAddressFieldsFull: case STPBillingAddressFieldsFull:
return PKAddressFieldPostalAddress; return PKAddressFieldPostalAddress;
} }
} }*/
@end @end

View File

@ -99,7 +99,7 @@ public final class CallKitIntegration {
let handle = INPersonHandle(value: "tg\(peerId.id._internalGetInt64Value())", type: .unknown) let handle = INPersonHandle(value: "tg\(peerId.id._internalGetInt64Value())", type: .unknown)
let contact = INPerson(personHandle: handle, nameComponents: nil, displayName: displayTitle, image: nil, contactIdentifier: localContactId, customIdentifier: "tg\(peerId.id._internalGetInt64Value())") let contact = INPerson(personHandle: handle, nameComponents: nil, displayName: displayTitle, image: nil, contactIdentifier: localContactId, customIdentifier: "tg\(peerId.id._internalGetInt64Value())")
let intent = INStartAudioCallIntent(contacts: [contact]) let intent = INStartAudioCallIntent(destinationType: .normal, contacts: [contact])
let interaction = INInteraction(intent: intent, response: nil) let interaction = INInteraction(intent: intent, response: nil)
interaction.direction = .outgoing interaction.direction = .outgoing

View File

@ -193,12 +193,14 @@ public func donateSendMessageIntent(account: Account, sharedContext: SharedAccou
nameComponents.givenName = displayTitle nameComponents.givenName = displayTitle
} }
let recipient = INPerson(personHandle: recipientHandle, nameComponents: nameComponents, displayName: displayTitle, image: nil, contactIdentifier: nil, customIdentifier: "tg\(peer.id.toInt64())") var personImage: INImage?
if let avatarImage = avatarImage, let avatarImageData = avatarImage.jpegData(compressionQuality: 0.8) {
personImage = INImage(imageData: avatarImageData)
}
let recipient = INPerson(personHandle: recipientHandle, nameComponents: nameComponents, displayName: displayTitle, image: personImage, contactIdentifier: nil, customIdentifier: "tg\(peer.id.toInt64())")
let intent = INSendMessageIntent(recipients: [recipient], content: nil, speakableGroupName: INSpeakableString(spokenPhrase: displayTitle), conversationIdentifier: "tg\(peer.id.toInt64())", serviceName: nil, sender: nil) let intent = INSendMessageIntent(recipients: [recipient], content: nil, speakableGroupName: INSpeakableString(spokenPhrase: displayTitle), conversationIdentifier: "tg\(peer.id.toInt64())", serviceName: nil, sender: nil)
if let avatarImage = avatarImage, let avatarImageData = avatarImage.jpegData(compressionQuality: 0.8) {
intent.setImage(INImage(imageData: avatarImageData), forParameterNamed: \.groupName)
}
let interaction = INInteraction(intent: intent, response: nil) let interaction = INInteraction(intent: intent, response: nil)
interaction.direction = .outgoing interaction.direction = .outgoing
interaction.groupIdentifier = "sendMessage_\(peer.id.toInt64())" interaction.groupIdentifier = "sendMessage_\(peer.id.toInt64())"

View File

@ -529,7 +529,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
}, canOpenUrl: { url in }, canOpenUrl: { url in
return UIApplication.shared.canOpenURL(url) return UIApplication.shared.canOpenURL(url)
}, openUrl: { url in }, openUrl: { url in
UIApplication.shared.openURL(url) UIApplication.shared.open(url, options: [:], completionHandler: nil)
}) })
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
@ -555,9 +555,9 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
} }
if let parsedUrl = parsedUrl { if let parsedUrl = parsedUrl {
UIApplication.shared.openURL(parsedUrl) UIApplication.shared.open(parsedUrl, options: [:], completionHandler: nil)
} else if let escapedUrl = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let parsedUrl = URL(string: escapedUrl) { } else if let escapedUrl = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let parsedUrl = URL(string: escapedUrl) {
UIApplication.shared.openURL(parsedUrl) UIApplication.shared.open(parsedUrl, options: [:], completionHandler: nil)
} }
}, openUniversalUrl: { url, completion in }, openUniversalUrl: { url, completion in
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
@ -633,12 +633,12 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
return disposable return disposable
}, openSettings: { }, openSettings: {
if let url = URL(string: UIApplication.openSettingsURLString) { if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.openURL(url) UIApplication.shared.open(url, options: [:], completionHandler: nil)
} }
}, openAppStorePage: { }, openAppStorePage: {
let appStoreId = buildConfig.appStoreId let appStoreId = buildConfig.appStoreId
if let url = URL(string: "itms-apps://itunes.apple.com/app/id\(appStoreId)") { if let url = URL(string: "itms-apps://itunes.apple.com/app/id\(appStoreId)") {
UIApplication.shared.openURL(url) UIApplication.shared.open(url, options: [:], completionHandler: nil)
} }
}, openSubscriptions: { }, openSubscriptions: {
if #available(iOS 15, *), let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene { if #available(iOS 15, *), let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
@ -646,7 +646,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
try await AppStore.showManageSubscriptions(in: scene) try await AppStore.showManageSubscriptions(in: scene)
} }
} else if let url = URL(string: "https://apps.apple.com/account/subscriptions") { } else if let url = URL(string: "https://apps.apple.com/account/subscriptions") {
UIApplication.shared.openURL(url) UIApplication.shared.open(url, options: [:], completionHandler: nil)
} }
}, registerForNotifications: { completion in }, registerForNotifications: { completion in
let _ = (self.context.get() let _ = (self.context.get()
@ -1434,11 +1434,11 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
}) })
} }
func application(_ application: UIApplication, didReceive notification: UILocalNotification) { /*func application(_ application: UIApplication, didReceive notification: UILocalNotification) {
if (application.applicationState == .inactive) { if (application.applicationState == .inactive) {
Logger.shared.log("App \(self.episodeId)", "tap local notification \(String(describing: notification.userInfo)), applicationState \(application.applicationState)") Logger.shared.log("App \(self.episodeId)", "tap local notification \(String(describing: notification.userInfo)), applicationState \(application.applicationState)")
} }
} }*/
public func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) { public func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
if #available(iOS 9.0, *) { if #available(iOS 9.0, *) {
@ -1697,7 +1697,7 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
let presentationData = authContext.sharedContext.currentPresentationData.with { $0 } let presentationData = authContext.sharedContext.currentPresentationData.with { $0 }
authContext.rootController.currentWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: presentationData.strings.Passport_NotLoggedInMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Calls_NotNow, action: { authContext.rootController.currentWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: presentationData.strings.Passport_NotLoggedInMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Calls_NotNow, action: {
if let callbackUrl = URL(string: secureIdCallbackUrl(with: secureIdData.callbackUrl, peerId: secureIdData.peerId, result: .cancel, parameters: [:])) { if let callbackUrl = URL(string: secureIdCallbackUrl(with: secureIdData.callbackUrl, peerId: secureIdData.peerId, result: .cancel, parameters: [:])) {
UIApplication.shared.openURL(callbackUrl) UIApplication.shared.open(callbackUrl, options: [:], completionHandler: nil)
} }
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {}) }), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {})
} else if let confirmationCode = parseConfirmationCodeUrl(url) { } else if let confirmationCode = parseConfirmationCodeUrl(url) {
@ -2153,14 +2153,9 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
reply.identifier = "reply" reply.identifier = "reply"
reply.title = replyString reply.title = replyString
reply.isDestructive = false reply.isDestructive = false
if #available(iOS 9.0, *) {
reply.isAuthenticationRequired = false reply.isAuthenticationRequired = false
reply.behavior = .textInput reply.behavior = .textInput
reply.activationMode = .background reply.activationMode = .background
} else {
reply.isAuthenticationRequired = true
reply.activationMode = .foreground
}
let unknownMessageCategory = UIMutableUserNotificationCategory() let unknownMessageCategory = UIMutableUserNotificationCategory()
unknownMessageCategory.identifier = "unknown" unknownMessageCategory.identifier = "unknown"

View File

@ -465,7 +465,7 @@ final class AuthorizedApplicationContext {
declineImpl?() declineImpl?()
}, openUrl: { url in }, openUrl: { url in
if let parsedUrl = URL(string: url) { if let parsedUrl = URL(string: url) {
UIApplication.shared.openURL(parsedUrl) UIApplication.shared.open(parsedUrl, options: [:], completionHandler: nil)
} }
}) })

View File

@ -464,16 +464,10 @@ public final class SharedNotificationManager {
} else { } else {
let notification = UILocalNotification() let notification = UILocalNotification()
if #available(iOS 8.2, *) {
notification.alertTitle = title notification.alertTitle = title
notification.alertBody = body notification.alertBody = body
} else {
if let title = title {
notification.alertBody = "\(title): \(body)"
} else {
notification.alertBody = body
}
}
notification.category = "incomingCall" notification.category = "incomingCall"
notification.userInfo = ["callId": String(describing: notificationCall.internalId)] notification.userInfo = ["callId": String(describing: notificationCall.internalId)]
notification.soundName = "0.m4a" notification.soundName = "0.m4a"

View File

@ -259,7 +259,7 @@ private final class SystemVideoContentNode: ASDisplayNode, UniversalVideoContent
func seek(_ timestamp: Double) { func seek(_ timestamp: Double) {
assert(Queue.mainQueue().isCurrent()) assert(Queue.mainQueue().isCurrent())
self.seekId += 1 self.seekId += 1
self.playerItem.seek(to: CMTimeMake(value: Int64(timestamp) * 1000, timescale: 1000)) self.playerItem.seek(to: CMTimeMake(value: Int64(timestamp) * 1000, timescale: 1000), completionHandler: nil)
} }
func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek, actionAtEnd: MediaPlayerPlayOnceWithSoundActionAtEnd) { func playOnceWithSound(playAndRecord: Bool, seek: MediaPlayerSeek, actionAtEnd: MediaPlayerPlayOnceWithSoundActionAtEnd) {

View File

@ -102,8 +102,6 @@ final class WebEmbedPlayerNode: ASDisplayNode, WKNavigationDelegate {
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = [] configuration.mediaTypesRequiringUserActionForPlayback = []
} else if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
configuration.requiresUserActionForMediaPlayback = false
} else { } else {
configuration.mediaPlaybackRequiresUserAction = false configuration.mediaPlaybackRequiresUserAction = false
} }

View File

@ -5,6 +5,8 @@
#import <MtProtoKit/MtProtoKit.h> #import <MtProtoKit/MtProtoKit.h>
#include <memory> #include <memory>
#import <libkern/OSAtomic.h>
static void TGCallAesIgeEncrypt(uint8_t *inBytes, uint8_t *outBytes, size_t length, uint8_t *key, uint8_t *iv) { static void TGCallAesIgeEncrypt(uint8_t *inBytes, uint8_t *outBytes, size_t length, uint8_t *key, uint8_t *iv) {
MTAesEncryptRaw(inBytes, outBytes, length, key, iv); MTAesEncryptRaw(inBytes, outBytes, length, key, iv);
} }

View File

@ -2,7 +2,7 @@
#import <LegacyComponents/LegacyComponents.h> #import <LegacyComponents/LegacyComponents.h>
#import <WatchConnectivity/WatchConnectivity.h> #import <WatchConnectivity/WatchConnectivity.h>
#import <libkern/OSAtomic.h> #import <os/lock.h>
#import <WatchCommon/WatchCommon.h> #import <WatchCommon/WatchCommon.h>
@interface TGBridgeSignalManager : NSObject @interface TGBridgeSignalManager : NSObject
@ -31,16 +31,16 @@
TGBridgeSignalManager *_signalManager; TGBridgeSignalManager *_signalManager;
OSSpinLock _incomingQueueLock; os_unfair_lock _incomingQueueLock;
NSMutableArray *_incomingMessageQueue; NSMutableArray *_incomingMessageQueue;
bool _requestSubscriptionList; bool _requestSubscriptionList;
NSArray *_initialSubscriptionList; NSArray *_initialSubscriptionList;
OSSpinLock _outgoingQueueLock; os_unfair_lock _outgoingQueueLock;
NSMutableArray *_outgoingMessageQueue; NSMutableArray *_outgoingMessageQueue;
OSSpinLock _replyHandlerMapLock; os_unfair_lock _replyHandlerMapLock;
NSMutableDictionary *_replyHandlerMap; NSMutableDictionary *_replyHandlerMap;
SPipe *_appInstalled; SPipe *_appInstalled;
@ -102,14 +102,14 @@
if (self.isRunning) if (self.isRunning)
return; return;
OSSpinLockLock(&_incomingQueueLock); os_unfair_lock_lock(&_incomingQueueLock);
_isRunning = true; _isRunning = true;
for (id message in _incomingMessageQueue) for (id message in _incomingMessageQueue)
[self handleMessage:message replyHandler:nil finishTask:nil completion:nil]; [self handleMessage:message replyHandler:nil finishTask:nil completion:nil];
[_incomingMessageQueue removeAllObjects]; [_incomingMessageQueue removeAllObjects];
OSSpinLockUnlock(&_incomingQueueLock); os_unfair_lock_unlock(&_incomingQueueLock);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self dispatch:^{ [self dispatch:^{
@ -189,7 +189,7 @@
}; };
id message = [NSKeyedUnarchiver unarchiveObjectWithData:messageData]; id message = [NSKeyedUnarchiver unarchiveObjectWithData:messageData];
OSSpinLockLock(&_incomingQueueLock); os_unfair_lock_lock(&_incomingQueueLock);
if (!self.isRunning) if (!self.isRunning)
{ {
[_incomingMessageQueue addObject:message]; [_incomingMessageQueue addObject:message];
@ -199,10 +199,10 @@
finishTask(4.0); finishTask(4.0);
OSSpinLockUnlock(&_incomingQueueLock); os_unfair_lock_unlock(&_incomingQueueLock);
return; return;
} }
OSSpinLockUnlock(&_incomingQueueLock); os_unfair_lock_unlock(&_incomingQueueLock);
[self handleMessage:message replyHandler:replyHandler finishTask:finishTask completion:completion]; [self handleMessage:message replyHandler:replyHandler finishTask:finishTask completion:completion];
} }
@ -261,9 +261,9 @@
//TGLog(@"[BridgeServer] Halt all active subscriptions"); //TGLog(@"[BridgeServer] Halt all active subscriptions");
[_signalManager haltAllSignals]; [_signalManager haltAllSignals];
OSSpinLockLock(&_outgoingQueueLock); os_unfair_lock_lock(&_outgoingQueueLock);
[_outgoingMessageQueue removeAllObjects]; [_outgoingMessageQueue removeAllObjects];
OSSpinLockUnlock(&_outgoingQueueLock); os_unfair_lock_unlock(&_outgoingQueueLock);
} }
_sessionId = ping.sessionId; _sessionId = ping.sessionId;
@ -307,9 +307,9 @@
SSignal *subscriptionHandler = _handler(subscription); SSignal *subscriptionHandler = _handler(subscription);
if (replyHandler != nil) if (replyHandler != nil)
{ {
OSSpinLockLock(&_replyHandlerMapLock); os_unfair_lock_lock(&_replyHandlerMapLock);
_replyHandlerMap[@(subscription.identifier)] = replyHandler; _replyHandlerMap[@(subscription.identifier)] = replyHandler;
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
} }
if (subscriptionHandler != nil) if (subscriptionHandler != nil)
@ -318,11 +318,11 @@
{ {
STimer *timer = [[STimer alloc] initWithTimeout:2.0 repeat:false completion:^ STimer *timer = [[STimer alloc] initWithTimeout:2.0 repeat:false completion:^
{ {
OSSpinLockLock(&_replyHandlerMapLock); os_unfair_lock_lock(&_replyHandlerMapLock);
void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)]; void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)];
if (reply == nil) if (reply == nil)
{ {
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
if (finishTask != nil) if (finishTask != nil)
finishTask(2.0); finishTask(2.0);
@ -331,7 +331,7 @@
reply([NSData data]); reply([NSData data]);
[_replyHandlerMap removeObjectForKey:@(subscription.identifier)]; [_replyHandlerMap removeObjectForKey:@(subscription.identifier)];
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
if (finishTask != nil) if (finishTask != nil)
finishTask(4.0); finishTask(4.0);
@ -369,11 +369,11 @@
} }
else else
{ {
OSSpinLockLock(&_replyHandlerMapLock); os_unfair_lock_lock(&_replyHandlerMapLock);
void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)]; void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)];
if (reply == nil) if (reply == nil)
{ {
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
if (finishTask != nil) if (finishTask != nil)
finishTask(2.0); finishTask(2.0);
@ -382,7 +382,7 @@
reply([NSData data]); reply([NSData data]);
[_replyHandlerMap removeObjectForKey:@(subscription.identifier)]; [_replyHandlerMap removeObjectForKey:@(subscription.identifier)];
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
if (finishTask != nil) if (finishTask != nil)
finishTask(2.0); finishTask(2.0);
@ -410,11 +410,11 @@
break; break;
} }
OSSpinLockLock(&_replyHandlerMapLock); os_unfair_lock_lock(&_replyHandlerMapLock);
void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)]; void (^reply)(NSData *) = _replyHandlerMap[@(subscription.identifier)];
if (reply != nil) if (reply != nil)
[_replyHandlerMap removeObjectForKey:@(subscription.identifier)]; [_replyHandlerMap removeObjectForKey:@(subscription.identifier)];
OSSpinLockUnlock(&_replyHandlerMapLock); os_unfair_lock_unlock(&_replyHandlerMapLock);
if (_processingNotification) if (_processingNotification)
{ {
@ -460,7 +460,7 @@
- (void)_enqueueResponse:(TGBridgeResponse *)response forSubscription:(TGBridgeSubscription *)subscription - (void)_enqueueResponse:(TGBridgeResponse *)response forSubscription:(TGBridgeSubscription *)subscription
{ {
OSSpinLockLock(&_outgoingQueueLock); os_unfair_lock_lock(&_outgoingQueueLock);
NSMutableArray *updatedResponses = (_outgoingMessageQueue != nil) ? [_outgoingMessageQueue mutableCopy] : [[NSMutableArray alloc] init]; NSMutableArray *updatedResponses = (_outgoingMessageQueue != nil) ? [_outgoingMessageQueue mutableCopy] : [[NSMutableArray alloc] init];
if (subscription.dropPreviouslyQueued) if (subscription.dropPreviouslyQueued)
@ -479,7 +479,7 @@
[updatedResponses addObject:response]; [updatedResponses addObject:response];
_outgoingMessageQueue = updatedResponses; _outgoingMessageQueue = updatedResponses;
OSSpinLockUnlock(&_outgoingQueueLock); os_unfair_lock_unlock(&_outgoingQueueLock);
} }
- (void)_sendQueuedResponses - (void)_sendQueuedResponses
@ -487,7 +487,7 @@
if (_processingNotification) if (_processingNotification)
return; return;
OSSpinLockLock(&_outgoingQueueLock); os_unfair_lock_lock(&_outgoingQueueLock);
if (_outgoingMessageQueue.count > 0) if (_outgoingMessageQueue.count > 0)
{ {
@ -501,7 +501,7 @@
[_outgoingMessageQueue removeAllObjects]; [_outgoingMessageQueue removeAllObjects];
} }
OSSpinLockUnlock(&_outgoingQueueLock); os_unfair_lock_unlock(&_outgoingQueueLock);
} }
- (void)_requestSubscriptionList - (void)_requestSubscriptionList
@ -669,7 +669,7 @@
@interface TGBridgeSignalManager() @interface TGBridgeSignalManager()
{ {
OSSpinLock _lock; os_unfair_lock _lock;
NSMutableDictionary *_disposables; NSMutableDictionary *_disposables;
} }
@end @end
@ -689,9 +689,9 @@
- (void)dealloc - (void)dealloc
{ {
NSArray *disposables = nil; NSArray *disposables = nil;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
disposables = [_disposables allValues]; disposables = [_disposables allValues];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
for (id<SDisposable> disposable in disposables) for (id<SDisposable> disposable in disposables)
{ {
@ -705,13 +705,13 @@
return false; return false;
bool produce = false; bool produce = false;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_disposables[key] == nil) if (_disposables[key] == nil)
{ {
_disposables[key] = [[SMetaDisposable alloc] init]; _disposables[key] = [[SMetaDisposable alloc] init];
produce = true; produce = true;
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
if (produce) if (produce)
{ {
@ -721,24 +721,24 @@
__strong TGBridgeSignalManager *strongSelf = weakSelf; __strong TGBridgeSignalManager *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
{ {
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf->_disposables removeObjectForKey:key]; [strongSelf->_disposables removeObjectForKey:key];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
} }
} completed:^ } completed:^
{ {
__strong TGBridgeSignalManager *strongSelf = weakSelf; __strong TGBridgeSignalManager *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
{ {
OSSpinLockLock(&strongSelf->_lock); os_unfair_lock_lock(&strongSelf->_lock);
[strongSelf->_disposables removeObjectForKey:key]; [strongSelf->_disposables removeObjectForKey:key];
OSSpinLockUnlock(&strongSelf->_lock); os_unfair_lock_unlock(&strongSelf->_lock);
} }
}]; }];
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
[(SMetaDisposable *)_disposables[key] setDisposable:disposable]; [(SMetaDisposable *)_disposables[key] setDisposable:disposable];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
return produce; return produce;
@ -749,22 +749,22 @@
if (key == nil) if (key == nil)
return; return;
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
if (_disposables[key] != nil) if (_disposables[key] != nil)
{ {
[_disposables[key] dispose]; [_disposables[key] dispose];
[_disposables removeObjectForKey:key]; [_disposables removeObjectForKey:key];
} }
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
- (void)haltAllSignals - (void)haltAllSignals
{ {
OSSpinLockLock(&_lock); os_unfair_lock_lock(&_lock);
for (NSObject <SDisposable> *disposable in _disposables.allValues) for (NSObject <SDisposable> *disposable in _disposables.allValues)
[disposable dispose]; [disposable dispose];
[_disposables removeAllObjects]; [_disposables removeAllObjects];
OSSpinLockUnlock(&_lock); os_unfair_lock_unlock(&_lock);
} }
@end @end

View File

@ -68,8 +68,6 @@ final class WebAppWebView: WKWebView {
configuration.allowsPictureInPictureMediaPlayback = false configuration.allowsPictureInPictureMediaPlayback = false
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = .all configuration.mediaTypesRequiringUserActionForPlayback = .all
} else if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
configuration.requiresUserActionForMediaPlayback = true
} else { } else {
configuration.mediaPlaybackRequiresUserAction = true configuration.mediaPlaybackRequiresUserAction = true
} }