Skip to content

Commit 645c0bb

Browse files
author
overtake
committed
improve qr code and first step to give up from apihash
1 parent d927bb6 commit 645c0bb

File tree

23 files changed

+863
-159
lines changed

23 files changed

+863
-159
lines changed

‎Telegram-Mac.xcworkspace/xcuserdata/overtake.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+48-48
Original file line numberDiff line numberDiff line change
@@ -202,52 +202,36 @@
202202
landmarkType = "7">
203203
</BreakpointContent>
204204
</BreakpointProxy>
205+
<BreakpointProxy
206+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
207+
<BreakpointContent
208+
shouldBeEnabled = "No"
209+
ignoreCount = "0"
210+
continueAfterRunningActions = "No"
211+
filePath = "Telegram-Mac/ChatRowView.swift"
212+
timestampString = "596046666.853035"
213+
startingColumnNumber = "9223372036854775807"
214+
endingColumnNumber = "9223372036854775807"
215+
startingLineNumber = "1093"
216+
endingLineNumber = "1093"
217+
landmarkName = "doubleClick(in:)"
218+
landmarkType = "7">
219+
</BreakpointContent>
220+
</BreakpointProxy>
205221
<BreakpointProxy
206222
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
207223
<BreakpointContent
208224
shouldBeEnabled = "Yes"
209225
ignoreCount = "0"
210226
continueAfterRunningActions = "No"
211-
filePath = "Telegram-Mac/AppDelegate.swift"
212-
timestampString = "595943733.54133"
227+
filePath = "Spotlight/IndexRequestHandler.swift"
228+
timestampString = "595954268.103181"
213229
startingColumnNumber = "9223372036854775807"
214230
endingColumnNumber = "9223372036854775807"
215-
startingLineNumber = "364"
216-
endingLineNumber = "364"
217-
landmarkName = "launchInterface()"
231+
startingLineNumber = "47"
232+
endingLineNumber = "47"
233+
landmarkName = "data(for:itemIdentifier:typeIdentifier:)"
218234
landmarkType = "7">
219-
<Locations>
220-
<Location
221-
shouldBeEnabled = "Yes"
222-
ignoreCount = "0"
223-
continueAfterRunningActions = "No"
224-
symbolName = "closure #1 (Telegram.ThemePaletteSettings) -&gt; Telegram.ThemePaletteSettings in closure #6 (Telegram.AutoNightThemePreferences, ()) -&gt; () in closure #3 () -&gt; () in Telegram.AppDelegate.(launchInterface in _CCD28B8351993349B6200A2AC06646A5)() -&gt; ()"
225-
moduleName = "Telegram"
226-
usesParentBreakpointCondition = "Yes"
227-
urlString = "file:///Users/overtake/Dropbox/Telegram-macOS/Telegram/Telegram-Mac/AppDelegate.swift"
228-
timestampString = "595949931.315448"
229-
startingColumnNumber = "9223372036854775807"
230-
endingColumnNumber = "9223372036854775807"
231-
startingLineNumber = "364"
232-
endingLineNumber = "364"
233-
offsetFromSymbolStart = "528">
234-
</Location>
235-
<Location
236-
shouldBeEnabled = "Yes"
237-
ignoreCount = "0"
238-
continueAfterRunningActions = "No"
239-
symbolName = "closure #1 (Telegram.ThemeWallpaper) -&gt; Telegram.ThemeWallpaper in closure #1 (Telegram.ThemePaletteSettings) -&gt; Telegram.ThemePaletteSettings in closure #6 (Telegram.AutoNightThemePreferences, ()) -&gt; () in closure #3 () -&gt; () in Telegram.AppDelegate.(launchInterface in _CCD28B8351993349B6200A2AC06646A5)() -&gt; ()"
240-
moduleName = "Telegram"
241-
usesParentBreakpointCondition = "Yes"
242-
urlString = "file:///Users/overtake/Dropbox/Telegram-macOS/Telegram/Telegram-Mac/AppDelegate.swift"
243-
timestampString = "595949931.317462"
244-
startingColumnNumber = "9223372036854775807"
245-
endingColumnNumber = "9223372036854775807"
246-
startingLineNumber = "365"
247-
endingLineNumber = "365"
248-
offsetFromSymbolStart = "56">
249-
</Location>
250-
</Locations>
251235
</BreakpointContent>
252236
</BreakpointProxy>
253237
<BreakpointProxy
@@ -256,29 +240,45 @@
256240
shouldBeEnabled = "Yes"
257241
ignoreCount = "0"
258242
continueAfterRunningActions = "No"
259-
filePath = "Telegram-Mac/AppDelegate.swift"
260-
timestampString = "595943733.5413899"
243+
filePath = "Spotlight/IndexRequestHandler.swift"
244+
timestampString = "595954268.103218"
261245
startingColumnNumber = "9223372036854775807"
262246
endingColumnNumber = "9223372036854775807"
263-
startingLineNumber = "368"
264-
endingLineNumber = "368"
265-
landmarkName = "launchInterface()"
247+
startingLineNumber = "41"
248+
endingLineNumber = "41"
249+
landmarkName = "searchableIndex(_:reindexSearchableItemsWithIdentifiers:acknowledgementHandler:)"
266250
landmarkType = "7">
267251
</BreakpointContent>
268252
</BreakpointProxy>
269253
<BreakpointProxy
270254
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
271255
<BreakpointContent
272-
shouldBeEnabled = "No"
256+
shouldBeEnabled = "Yes"
273257
ignoreCount = "0"
274258
continueAfterRunningActions = "No"
275-
filePath = "Telegram-Mac/ChatRowView.swift"
276-
timestampString = "595949929.7073441"
259+
filePath = "Spotlight/IndexRequestHandler.swift"
260+
timestampString = "595954268.103251"
277261
startingColumnNumber = "9223372036854775807"
278262
endingColumnNumber = "9223372036854775807"
279-
startingLineNumber = "1093"
280-
endingLineNumber = "1093"
281-
landmarkName = "doubleClick(in:)"
263+
startingLineNumber = "35"
264+
endingLineNumber = "35"
265+
landmarkName = "searchableIndex(_:reindexAllSearchableItemsWithAcknowledgementHandler:)"
266+
landmarkType = "7">
267+
</BreakpointContent>
268+
</BreakpointProxy>
269+
<BreakpointProxy
270+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
271+
<BreakpointContent
272+
shouldBeEnabled = "Yes"
273+
ignoreCount = "0"
274+
continueAfterRunningActions = "No"
275+
filePath = "Spotlight/IndexRequestHandler.swift"
276+
timestampString = "595954268.103284"
277+
startingColumnNumber = "9223372036854775807"
278+
endingColumnNumber = "9223372036854775807"
279+
startingLineNumber = "53"
280+
endingLineNumber = "53"
281+
landmarkName = "fileURL(for:itemIdentifier:typeIdentifier:inPlace:)"
282282
landmarkType = "7">
283283
</BreakpointContent>
284284
</BreakpointProxy>

‎Telegram-Mac/AccountContext.swift

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ final class AccountContext {
212212
let chatUndoManager = ChatUndoManager()
213213
let blockedPeersContext: BlockedPeersContext
214214
let walletPasscodeTimeoutContext: WalletPasscodeTimeoutContext
215+
215216
#endif
216217

217218
let cancelGlobalSearch:ValuePromise<Bool> = ValuePromise(ignoreRepeated: false)
@@ -270,6 +271,7 @@ final class AccountContext {
270271

271272
public var closeFolderFirst: Bool = false
272273

274+
273275
init(sharedContext: SharedAccountContext, window: Window, tonContext: StoredTonContext?, account: Account) {
274276
self.sharedContext = sharedContext
275277
self.account = account
@@ -282,6 +284,8 @@ final class AccountContext {
282284
#endif
283285

284286

287+
288+
285289
let limitConfiguration = _limitConfiguration
286290

287291
limitsDisposable.set(account.postbox.preferencesView(keys: [PreferencesKeys.limitsConfiguration]).start(next: { view in

‎Telegram-Mac/AppDelegate.swift

+42-17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CoreServices
1111
import LocalAuthentication
1212
import WalletCore
1313
import OpenSSLEncryption
14+
import CoreSpotlight
1415
#if !APP_STORE
1516
import AppCenter
1617
import AppCenterCrashes
@@ -87,8 +88,9 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
8788

8889
func applicationDidFinishLaunching(_ aNotification: Notification) {
8990

90-
9191

92+
evaluateApiHash()
93+
9294
initializeSelectManager()
9395
startLottieCacheCleaner()
9496

@@ -181,7 +183,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
181183
MTLogSetEnabled(UserDefaults.standard.bool(forKey: "enablelogs"))
182184

183185
let logger = Logger(basePath: containerUrl.path + "/logs")
184-
logger.logToConsole = TEST_SERVER
186+
logger.logToConsole = false
185187
logger.logToFile = UserDefaults.standard.bool(forKey: "enablelogs")
186188

187189
#if DEBUG
@@ -278,8 +280,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
278280
updateTheme(with: themeSettings, for: window)
279281

280282

281-
282-
283283
let basicTheme = Atomic<ThemePaletteSettings?>(value: themeSettings)
284284
let viewDidChangedAppearance: ValuePromise<Bool> = ValuePromise(true)
285285
let backingProperties:ValuePromise<CGFloat> = ValuePromise(System.backingScale, ignoreRepeated: true)
@@ -299,13 +299,10 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
299299
backingProperties.set(System.backingScale)
300300
})
301301

302-
303-
304302
let autoNightSignal = viewDidChangedAppearance.get() |> mapToSignal { _ in
305303
return combineLatest(autoNightSettings(accountManager: accountManager), Signal<Void, NoError>.single(Void()) |> then( Signal<Void, NoError>.single(Void()) |> delay(60, queue: Queue.mainQueue()) |> restart))
306304
} |> deliverOnMainQueue
307305

308-
var previousIsEnabled: Bool? = nil
309306

310307
_ = autoNightSignal.start(next: { preference, _ in
311308

@@ -338,9 +335,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
338335
}
339336

340337
} else if preference.systemBased {
341-
342-
343-
344338
if #available(OSX 10.14, *) {
345339
switch systemAppearance.name {
346340
case NSAppearance.Name.aqua:
@@ -384,9 +378,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
384378
}
385379
})
386380

387-
388-
389-
let networkArguments = NetworkInitializationArguments(apiId: API_ID, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: CallBridge.voipMaxLayer(), appData: .single(nil), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider())
381+
let networkArguments = NetworkInitializationArguments(apiId: ApiEnvironment.apiId, languagesCategory: ApiEnvironment.language, appVersion: ApiEnvironment.version, voipMaxLayer: CallBridge.voipMaxLayer(), appData: .single(nil), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider())
390382

391383
let sharedContext = SharedAccountContext(accountManager: accountManager, networkArguments: networkArguments, rootPath: rootPath, encryptionParameters: encryptionParameters, displayUpgradeProgress: displayUpgrade)
392384

@@ -585,9 +577,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
585577

586578
self.contextValue = context
587579

588-
589-
590-
591580
if let context = context {
592581
context.context.isCurrent = true
593582
context.applyNewTheme()
@@ -620,6 +609,9 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
620609
if let url = AppDelegate.eventProcessed {
621610
self.processURL(url)
622611
}
612+
if let action = AppDelegate.spotlightAction {
613+
self.processSpotlightAction(action)
614+
}
623615

624616
if !self.window.isKeyWindow {
625617
self.window.makeKeyAndOrderFront(self)
@@ -792,7 +784,8 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
792784
}
793785

794786
private static var eventProcessed: String? = nil
795-
787+
private static var spotlightAction: SpotlightIdentifier? = nil
788+
796789
@objc func handleURLEvent(_ event:NSAppleEventDescriptor, with replyEvent:NSAppleEventDescriptor) {
797790
let url = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue
798791
processURL(url)
@@ -987,6 +980,38 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
987980
NSApp.keyWindow?.close()
988981
}
989982

983+
func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool {
984+
if userActivity.activityType == CSSearchableItemActionType {
985+
if let uniqueIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
986+
if let identifier = parseSpotlightIdentifier(uniqueIdentifier) {
987+
self.processSpotlightAction(identifier)
988+
}
989+
}
990+
}
991+
992+
return true
993+
}
994+
995+
private func processSpotlightAction(_ identifier: SpotlightIdentifier) {
996+
if let context = contextValue?.context {
997+
AppDelegate.spotlightAction = nil
998+
if context.account.id == identifier.recordId {
999+
switch identifier.source {
1000+
case let .peerId(peerId):
1001+
context.sharedContext.bindings.rootNavigation().push(ChatController(context: context, chatLocation: .peer(peerId)))
1002+
}
1003+
} else {
1004+
switch identifier.source {
1005+
case let .peerId(peerId):
1006+
context.sharedContext.switchToAccount(id: identifier.recordId, action: .chat(peerId, necessary: true))
1007+
}
1008+
}
1009+
} else {
1010+
AppDelegate.spotlightAction = identifier
1011+
}
1012+
1013+
}
1014+
9901015
func getLogFilesContentWithMaxSize() -> String {
9911016

9921017
let semaphore = DispatchSemaphore(value: 0)

‎Telegram-Mac/ApplicationContext.swift

+4-13
Original file line numberDiff line numberDiff line change
@@ -344,19 +344,10 @@ final class AuthorizedApplicationContext: NSObject, SplitViewDelegate {
344344
}, with: self, for: .F, priority: .supreme, modifierFlags: [.command, .option])
345345

346346
#if DEBUG
347-
// window.set(handler: { [weak self] () -> KeyHandlerResult in
348-
// var items: [ValuesSelectorValue<String>] = []
349-
// for i in 0 ..< 100 {
350-
// items.append(ValuesSelectorValue(localized: "value: \(i)", value: "\(i)"))
351-
// }
352-
//
353-
// let controller = ValuesSelectorModalController(values: items, selected: items[0], title: "test", onComplete: { value in
354-
//
355-
// })
356-
//
357-
// showModal(with: controller, for: window)
358-
// return .invoked
359-
// }, with: self, for: .T, priority: .supreme, modifierFlags: .command)
347+
window.set(handler: { () -> KeyHandlerResult in
348+
alert(for: window, info: evaluateApiHash())
349+
return .invoked
350+
}, with: self, for: .T, priority: .supreme, modifierFlags: .command)
360351
#endif
361352

362353

‎Telegram-Mac/AuthController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ class AuthController : GenericViewController<AuthHeaderView> {
491491
}
492492

493493

494-
self?.actionDisposable.set((showModalProgress(signal: sendAuthorizationCode(accountManager: sharedContext.accountManager, account: strongSelf.account, phoneNumber: phoneNumber, apiId: API_ID, apiHash: API_HASH, syncContacts: false)
494+
self?.actionDisposable.set((showModalProgress(signal: sendAuthorizationCode(accountManager: sharedContext.accountManager, account: strongSelf.account, phoneNumber: phoneNumber, apiId: ApiEnvironment.apiId, apiHash: ApiEnvironment.apiHash, syncContacts: false)
495495
|> map {Optional($0)}
496496
|> mapError {Optional($0)}
497497
|> timeout(20, queue: Queue.mainQueue(), alternate: .fail(nil))

‎Telegram-Mac/Extensions.swift

+11
Original file line numberDiff line numberDiff line change
@@ -2320,3 +2320,14 @@ public extension String {
23202320
}
23212321
}
23222322

2323+
2324+
2325+
extension CGImage {
2326+
var data: Data? {
2327+
guard let mutableData = CFDataCreateMutable(nil, 0),
2328+
let destination = CGImageDestinationCreateWithData(mutableData, "public.png" as CFString, 1, nil) else { return nil }
2329+
CGImageDestinationAddImage(destination, self, nil)
2330+
guard CGImageDestinationFinalize(destination) else { return nil }
2331+
return mutableData as Data
2332+
}
2333+
}

‎Telegram-Mac/InAppLinks.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ func escape(with link:String, addPercent: Bool = true) -> String {
524524
}
525525

526526

527-
private func urlVars(with url:String) -> [String:String] {
527+
func urlVars(with url:String) -> [String:String] {
528528
var vars:[String:String] = [:]
529529
let range = url.nsstring.range(of: "?")
530530
let ns:NSString = range.location != NSNotFound ? url.nsstring.substring(from: range.location + 1).nsstring : url.nsstring

‎Telegram-Mac/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</dict>
3737
</array>
3838
<key>CFBundleVersion</key>
39-
<string>186100</string>
39+
<string>186212</string>
4040
<key>LSApplicationCategoryType</key>
4141
<string>public.app-category.social-networking</string>
4242
<key>LSFileQuarantineEnabled</key>

‎Telegram-Mac/ProxyQRCodeRowItem.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ private final class ProxyQRCodeRowView : TableRowView {
7171

7272
textView.update(item.textLayout)
7373

74-
disposable.set((qrCode(string: item.link, color: theme.colors.text, backgroundColor: theme.colors.grayBackground, scale: 2.0)
74+
disposable.set((qrCode(string: item.link, color: theme.colors.text, backgroundColor: theme.colors.grayBackground, icon: .proxy)
7575
|> map { generator -> CGImage? in
7676
let imageSize = CGSize(width: 256, height: 256)
77-
let context = generator.execute(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: NSEdgeInsets()), generator.data)
77+
let context = generator.1(TransformImageArguments(corners: ImageCorners(), imageSize: imageSize, boundingSize: imageSize, intrinsicInsets: NSEdgeInsets()))
7878

7979
return context?.generateImage()
8080
}

0 commit comments

Comments
 (0)