Skip to content

Commit f79d58f

Browse files
author
overtake
committed
• I’ll have a #3 with extra bug fixes and a chocolate shake.
1 parent 10088d4 commit f79d58f

File tree

144 files changed

+15448
-10090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+15448
-10090
lines changed

‎Telegram-Mac.xcworkspace/contents.xcworkspacedata

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Telegram-Mac/AccountContext.swift

+158-153
Large diffs are not rendered by default.

‎Telegram-Mac/AccountViewController.swift

+24-24
Original file line numberDiff line numberDiff line change
@@ -442,26 +442,26 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
442442
case .wallet:
443443
return GeneralInteractedRowItem(initialSize, stableId: stableId, name: L10n.accountSettingsWallet, icon: theme.icons.settingsWallet, activeIcon: theme.icons.settingsWalletActive, type: .next, action: {
444444
let context = arguments.context
445-
if #available(OSX 10.12, *) {
446-
447-
let _ = combineLatest(queue: .mainQueue(), walletConfiguration(postbox: context.account.postbox), TONKeychain.hasKeys(for: context.account)).start(next: { configuration, hasKeys in
448-
if let config = configuration.config, let blockchainName = configuration.blockchainName {
449-
let tonContext = context.tonContext.context(config: config, blockchainName: blockchainName, enableProxy: !configuration.disableProxy)
450-
if hasKeys {
451-
let signal = tonContext.storage.getWalletRecords() |> deliverOnMainQueue
452-
_ = signal.start(next: { wallets in
453-
if wallets.isEmpty {
454-
arguments.presentController(WalletSplashController(context: context, tonContext: tonContext, mode: .intro), true)
455-
} else {
456-
arguments.presentController(WalletInfoController(context: context, tonContext: tonContext, walletInfo: wallets[0].info), true)
457-
}
458-
})
459-
} else {
460-
arguments.presentController(WalletSplashController(context: context, tonContext: tonContext, mode: .unavailable), true)
461-
}
462-
}
463-
})
464-
}
445+
// if #available(OSX 10.12, *) {
446+
//
447+
// let _ = combineLatest(queue: .mainQueue(), walletConfiguration(postbox: context.account.postbox), TONKeychain.hasKeys(for: context.account)).start(next: { configuration, hasKeys in
448+
// if let config = configuration.config, let blockchainName = configuration.blockchainName {
449+
// let tonContext = context.tonContext.context(config: config, blockchainName: blockchainName, enableProxy: !configuration.disableProxy)
450+
// if hasKeys {
451+
// let signal = tonContext.storage.getWalletRecords() |> deliverOnMainQueue
452+
// _ = signal.start(next: { wallets in
453+
// if wallets.isEmpty {
454+
// arguments.presentController(WalletSplashController(context: context, tonContext: tonContext, mode: .intro), true)
455+
// } else {
456+
// arguments.presentController(WalletInfoController(context: context, tonContext: tonContext, walletInfo: wallets[0].info), true)
457+
// }
458+
// })
459+
// } else {
460+
// arguments.presentController(WalletSplashController(context: context, tonContext: tonContext, mode: .unavailable), true)
461+
// }
462+
// }
463+
// })
464+
// }
465465

466466
}, border:[BorderType.Right], inset:NSEdgeInsets(left:16))
467467
case .faq:
@@ -592,10 +592,10 @@ private func accountInfoEntries(peerView:PeerView, accounts: [AccountWithInfo],
592592
entries.append(.passport(index: index, peer: peer))
593593
index += 1
594594
}
595-
if hasWallet {
596-
entries.append(.wallet(index: index))
597-
index += 1
598-
}
595+
// if hasWallet {
596+
// entries.append(.wallet(index: index))
597+
// index += 1
598+
// }
599599

600600

601601

‎Telegram-Mac/AppDelegate.swift

+37-30
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ import Quartz
99
import MtProtoKit
1010
import CoreServices
1111
import LocalAuthentication
12-
import WalletCore
12+
//import WalletCore
1313
import OpenSSLEncryption
1414
import CoreSpotlight
1515
#if !APP_STORE
1616
import AppCenter
1717
import AppCenterCrashes
1818
#endif
1919

20+
#if !SHARE
21+
extension Account {
22+
var diceCache: DiceCache? {
23+
return (NSApp.delegate as? AppDelegate)?.contextValue?.context.diceCache
24+
}
25+
}
26+
#endif
2027

2128

2229
private final class SharedApplicationContext {
@@ -63,7 +70,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
6370
}
6471

6572

66-
private var contextValue: AuthorizedApplicationContext?
73+
fileprivate var contextValue: AuthorizedApplicationContext?
6774
private let context = Promise<AuthorizedApplicationContext?>()
6875

6976
private var authContextValue: UnauthorizedApplicationContext?
@@ -377,7 +384,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
377384
}
378385
})
379386

380-
let networkArguments = NetworkInitializationArguments(apiId: ApiEnvironment.apiId, apiHash: ApiEnvironment.apiHash, languagesCategory: ApiEnvironment.language, appVersion: ApiEnvironment.version, voipMaxLayer: CallBridge.voipMaxLayer(), appData: .single(ApiEnvironment.appData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider())
387+
let networkArguments = NetworkInitializationArguments(apiId: ApiEnvironment.apiId, apiHash: ApiEnvironment.apiHash, languagesCategory: ApiEnvironment.language, appVersion: ApiEnvironment.version, voipMaxLayer: CallBridge.voipMaxLayer(), voipVersions: [CallBridge.voipVersion()], appData: .single(ApiEnvironment.appData), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider())
381388

382389
let sharedContext = SharedAccountContext(accountManager: accountManager, networkArguments: networkArguments, rootPath: rootPath, encryptionParameters: encryptionParameters, displayUpgradeProgress: displayUpgrade)
383390

@@ -439,31 +446,31 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
439446
})
440447

441448

442-
let tonKeychain: TonKeychain
443-
444-
tonKeychain = TonKeychain(encryptionPublicKey: {
445-
return Signal { subscriber in
446-
return EmptyDisposable
447-
}
448-
}, encrypt: { data in
449-
return Signal { subscriber in
450-
if #available(OSX 10.12, *) {
451-
if let context = self.contextValue?.context, let publicKey = TKPublicKey.get(for: context.account) {
452-
if let result = publicKey.encrypt(data: data) {
453-
subscriber.putNext(TonKeychainEncryptedData(publicKey: publicKey.key, data: result))
454-
subscriber.putCompletion()
455-
return EmptyDisposable
456-
}
457-
}
458-
}
459-
subscriber.putError(.generic)
460-
return EmptyDisposable
461-
}
462-
}, decrypt: { encryptedData in
463-
return Signal { subscriber in
464-
return EmptyDisposable
465-
}
466-
})
449+
// let tonKeychain: TonKeychain
450+
//
451+
// tonKeychain = TonKeychain(encryptionPublicKey: {
452+
// return Signal { subscriber in
453+
// return EmptyDisposable
454+
// }
455+
// }, encrypt: { data in
456+
// return Signal { subscriber in
457+
// if #available(OSX 10.12, *) {
458+
// if let context = self.contextValue?.context, let publicKey = TKPublicKey.get(for: context.account) {
459+
// if let result = publicKey.encrypt(data: data) {
460+
// subscriber.putNext(TonKeychainEncryptedData(publicKey: publicKey.key, data: result))
461+
// subscriber.putCompletion()
462+
// return EmptyDisposable
463+
// }
464+
// }
465+
// }
466+
// subscriber.putError(.generic)
467+
// return EmptyDisposable
468+
// }
469+
// }, decrypt: { encryptedData in
470+
// return Signal { subscriber in
471+
// return EmptyDisposable
472+
// }
473+
// })
467474

468475

469476

@@ -493,9 +500,9 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
493500
}.start()
494501
semaphore.wait()
495502
}
496-
let tonContext = StoredTonContext(basePath: account.basePath, postbox: account.postbox, network: account.network, keychain: tonKeychain)
503+
// let tonContext = StoredTonContext(basePath: account.basePath, postbox: account.postbox, network: account.network, keychain: tonKeychain)
497504

498-
let context = AccountContext(sharedContext: sharedApplicationContext.sharedContext, window: window, tonContext: tonContext, account: account)
505+
let context = AccountContext(sharedContext: sharedApplicationContext.sharedContext, window: window, account: account)
499506
return AuthorizedApplicationContext(window: window, context: context, launchSettings: settings ?? LaunchSettings.defaultSettings)
500507

501508
} else {

‎Telegram-Mac/ApplicationContext.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ final class AuthorizedApplicationContext: NSObject, SplitViewDelegate {
124124
private let chatUndoManagerDisposable = MetaDisposable()
125125
private let appUpdateDisposable = MetaDisposable()
126126
private let updatesDisposable = MetaDisposable()
127-
128127
private let _ready:Promise<Bool> = Promise()
129128
var ready: Signal<Bool, NoError> {
130129
return _ready.get() |> filter { $0 } |> take (1)
@@ -531,9 +530,7 @@ final class AuthorizedApplicationContext: NSObject, SplitViewDelegate {
531530
}
532531
})
533532
}
534-
535-
536-
533+
537534
// _ready.set(.single(true))
538535
}
539536

‎Telegram-Mac/CachedResourceRepresentations.swift

+23
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,29 @@ final class CachedPatternWallpaperMaskRepresentation: CachedMediaResourceReprese
177177
}
178178

179179

180+
final class CachedDiceRepresentation: CachedMediaResourceRepresentation {
181+
let keepDuration: CachedMediaRepresentationKeepDuration = .general
182+
183+
let value: String
184+
let size: NSSize
185+
var uniqueId: String {
186+
return value
187+
}
188+
189+
init(value: String, size: NSSize) {
190+
self.value = value
191+
self.size = size
192+
}
193+
194+
func isEqual(to: CachedMediaResourceRepresentation) -> Bool {
195+
if let to = to as? CachedDiceRepresentation {
196+
return self.value == to.value && self.size == to.size
197+
} else {
198+
return false
199+
}
200+
}
201+
}
202+
180203

181204

182205
public enum EmojiFitzModifier: Int32, Equatable {

‎Telegram-Mac/CalendarController.swift

+8
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ class CalendarController: GenericViewController<CalendarControllerView> {
8383
if let strongSelf = self {
8484
strongSelf.navigation.push(strongSelf.stepMonth(date: CalendarUtils.stepMonth(1, date: date)), style: .push)
8585
}
86+
}, changeYear: { [weak self] year, date in
87+
if let strongSelf = self {
88+
strongSelf.navigation.push(strongSelf.stepMonth(date: CalendarUtils.year(Int(year), date: date)), style: .push)
89+
}
8690
})
8791

8892
self.navigation = CalendarNavigation(stepMonth(date: current), window)
@@ -93,6 +97,10 @@ class CalendarController: GenericViewController<CalendarControllerView> {
9397
func stepMonth(date:Date) -> CalendarMonthController {
9498
return CalendarMonthController(date, onlyFuture: self.onlyFuture, selectDayAnyway: CalendarUtils.isSameDate(current, date: date, checkDay: false), interactions: interactions)
9599
}
100+
101+
override var isAutoclosePopover: Bool {
102+
return false
103+
}
96104
}
97105

98106

‎Telegram-Mac/CalendarMonthController.swift

+34-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ struct CalendarMonthInteractions {
1313
let selectAction:(Date)->Void
1414
let backAction:((Date)->Void)?
1515
let nextAction:((Date)->Void)?
16-
init(selectAction:@escaping (Date)->Void, backAction:((Date)->Void)? = nil, nextAction:((Date)->Void)? = nil) {
16+
let changeYear: (Int32, Date)->Void
17+
init(selectAction:@escaping (Date)->Void, backAction:((Date)->Void)? = nil, nextAction:((Date)->Void)? = nil, changeYear: @escaping(Int32, Date)->Void) {
1718
self.selectAction = selectAction
1819
self.backAction = backAction
1920
self.nextAction = nextAction
21+
self.changeYear = changeYear
2022
}
2123
}
2224

@@ -188,7 +190,37 @@ class CalendarMonthController: GenericViewController<CalendarMonthView> {
188190
formatter.dateFormat = "yyyy"
189191
let yearString:String = formatter.string(from: month.month)
190192

191-
return TitledBarView(controller: self, .initialize(string: monthString, color: theme.colors.text, font:.medium(.text)), .initialize(string:yearString, color: theme.colors.grayText, font:.normal(.small)))
193+
let barView = TitledBarView(controller: self, .initialize(string: monthString, color: theme.colors.text, font:.medium(.text)), .initialize(string:yearString, color: theme.colors.grayText, font:.normal(.small)))
194+
195+
barView.set(handler: { [weak self] control in
196+
197+
guard let `self` = self else {
198+
return
199+
}
200+
201+
let nowTimestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
202+
203+
var now: time_t = time_t(nowTimestamp)
204+
var timeinfoNow: tm = tm()
205+
localtime_r(&now, &timeinfoNow)
206+
207+
var items:[SPopoverItem] = []
208+
209+
for i in stride(from: 1900 + timeinfoNow.tm_year - 1, to: 2012, by: -1) {
210+
items.append(.init("\(i)", { [weak self] in
211+
guard let `self` = self else {
212+
return
213+
}
214+
self.interactions.changeYear(i, self.month.month)
215+
}))
216+
}
217+
if !items.isEmpty {
218+
showPopover(for: control, with: SPopoverViewController(items: items), edge: .maxY, inset: NSMakePoint(30, -50))
219+
}
220+
221+
}, for: .Click)
222+
223+
return barView
192224
}
193225

194226
var isNextEnabled:Bool {

‎Telegram-Mac/CalendarUtils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
+ (NSDate*) monthDay:(NSInteger)day date:(NSDate *)date;
1313
+ (NSInteger)weekDay:(NSDate *)date;
1414
+ (NSDate *) stepMonth:(NSInteger)dm date:(NSDate *)date;
15-
15+
+ (NSDate *) year:(NSInteger)dm date:(NSDate *)date;
1616
@end

‎Telegram-Mac/CalendarUtils.m

+10
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,14 @@ + (NSDate *) stepMonth:(NSInteger)dm date:(NSDate *)date {
9595
return [cal dateFromComponents:components];
9696
}
9797

98+
+ (NSDate *) year:(NSInteger)dm date:(NSDate *)date {
99+
NSCalendar *cal = [NSCalendar currentCalendar];
100+
unsigned unitFlags = NSCalendarUnitDay| NSCalendarUnitYear | NSCalendarUnitMonth;
101+
NSDateComponents *components = [cal components:unitFlags fromDate:date];
102+
components.day = 1;
103+
components.year = dm;
104+
components.month = components.month;
105+
return [cal dateFromComponents:components];
106+
}
107+
98108
@end

‎Telegram-Mac/CallBridge.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
@interface CallBridge : NSObject
2828
-(void)startTransmissionIfNeeded:(bool)outgoing allowP2p:(bool)allowP2p serializedData:(NSString *)serializedData connection:(TGCallConnection *)connection;
2929

30+
-(id)initWithProxy:(CProxy *)proxy;
31+
3032
-(void)mute;
3133
-(void)unmute;
3234
-(BOOL)isMuted;
@@ -41,6 +43,7 @@
4143
@property (nonatomic, copy) void (^stateChangeHandler)(int);
4244

4345
+(int32_t)voipMaxLayer;
46+
+(NSString *)voipVersion;
4447

4548
+(NSArray<AudioDevice *> *)outputDevices;
4649
+(NSArray<AudioDevice *> *)inputDevices;

‎Telegram-Mac/CallBridge.mm

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ - (void)controllerStateChanged:(int)state
136136
+(int32_t)voipMaxLayer {
137137
return tgvoip::VoIPController::GetConnectionMaxLayer();
138138
}
139+
+(NSString *)voipVersion {
140+
return [NSString stringWithUTF8String:tgvoip::VoIPController::GetVersion()];
141+
}
139142

140143
+(NSArray<AudioDevice *> *)inputDevices {
141144

0 commit comments

Comments
 (0)