diff --git a/Telegram/BUILD b/Telegram/BUILD
index 9f0f593247..9ed27ba1cb 100644
--- a/Telegram/BUILD
+++ b/Telegram/BUILD
@@ -997,6 +997,74 @@ ios_extension(
],
)
+plist_fragment(
+ name = "NotificationContentInfoPlist",
+ extension = "plist",
+ template =
+ """
+ CFBundleDevelopmentRegion
+ en
+ CFBundleIdentifier
+ {telegram_bundle_id}.NotificationContent
+ CFBundleName
+ Telegram
+ CFBundlePackageType
+ XPC!
+ NSExtension
+
+ NSExtensionAttributes
+
+ UNNotificationExtensionCategory
+
+ withReplyMedia
+ withMuteMedia
+
+ UNNotificationExtensionInitialContentSizeRatio
+ 0.0001
+
+ NSExtensionPointIdentifier
+ com.apple.usernotifications.content-extension
+ NSExtensionPrincipalClass
+ NotificationViewController
+
+ """.format(
+ telegram_bundle_id = telegram_bundle_id,
+ )
+)
+
+swift_library(
+ name = "NotificationContentExtensionLib",
+ module_name = "NotificationContentExtensionLib",
+ srcs = glob([
+ "NotificationContent/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/TelegramUI:TelegramUI"
+ ],
+)
+
+ios_extension(
+ name = "NotificationContentExtension",
+ bundle_id = "{telegram_bundle_id}.NotificationContent".format(
+ telegram_bundle_id = telegram_bundle_id,
+ ),
+ families = [
+ "iphone",
+ "ipad",
+ ],
+ infoplists = [
+ ":NotificationContentInfoPlist",
+ ":VersionInfoPlist",
+ ":AppNameInfoPlist",
+ ],
+ minimum_os_version = "9.0",
+ provisioning_profile = "//build-input/data/provisioning-profiles:NotificationContent.mobileprovision",
+ deps = [":NotificationContentExtensionLib"],
+ frameworks = [
+ ":TelegramUIFramework"
+ ],
+)
+
plist_fragment(
name = "WidgetInfoPlist",
extension = "plist",
@@ -1054,13 +1122,86 @@ ios_extension(
frameworks = [],
)
+plist_fragment(
+ name = "IntentsInfoPlist",
+ extension = "plist",
+ template =
+ """
+ CFBundleDevelopmentRegion
+ en
+ CFBundleIdentifier
+ {telegram_bundle_id}.SiriIntents
+ CFBundleName
+ Telegram
+ CFBundlePackageType
+ XPC!
+ NSExtension
+
+ NSExtensionAttributes
+
+ IntentsRestrictedWhileLocked
+
+ IntentsRestrictedWhileProtectedDataUnavailable
+
+ IntentsSupported
+
+ INSendMessageIntent
+ INStartAudioCallIntent
+ INSearchForMessagesIntent
+ INSetMessageAttributeIntent
+ INSearchCallHistoryIntent
+
+
+ NSExtensionPointIdentifier
+ com.apple.intents-service
+ NSExtensionPrincipalClass
+ IntentHandler
+
+ """.format(
+ telegram_bundle_id = telegram_bundle_id,
+ )
+)
+
swift_library(
- name = "NotificationServiceExtensionLib",
- module_name = "NotificationServiceExtensionLib",
+ name = "IntentsExtensionLib",
+ module_name = "IntentsExtensionLib",
srcs = glob([
- "NotificationServiceNext/**/*.swift",
+ "SiriIntents/**/*.swift",
]),
deps = [
+ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
+ "//submodules/Postbox:Postbox",
+ "//submodules/TelegramApi:TelegramApi",
+ "//submodules/SyncCore:SyncCore",
+ "//submodules/TelegramCore:TelegramCore",
+ "//submodules/BuildConfig:BuildConfig",
+ "//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider",
+ "//submodules/AppLockState:AppLockState",
+ ],
+)
+
+ios_extension(
+ name = "IntentsExtension",
+ bundle_id = "{telegram_bundle_id}.SiriIntents".format(
+ telegram_bundle_id = telegram_bundle_id,
+ ),
+ families = [
+ "iphone",
+ "ipad",
+ ],
+ infoplists = [
+ ":IntentsInfoPlist",
+ ":VersionInfoPlist",
+ ":AppNameInfoPlist",
+ ],
+ minimum_os_version = "9.0",
+ provisioning_profile = "//build-input/data/provisioning-profiles:Intents.mobileprovision",
+ deps = [":IntentsExtensionLib"],
+ frameworks = [
+ ":SwiftSignalKitFramework",
+ ":PostboxFramework",
+ ":TelegramApiFramework",
+ ":SyncCoreFramework",
],
)
@@ -1105,8 +1246,13 @@ ios_extension(
],
minimum_os_version = "10.0",
provisioning_profile = "//build-input/data/provisioning-profiles:NotificationService.mobileprovision",
- deps = [":NotificationServiceExtensionLib"],
+ deps = ["//Telegram/NotificationService:NotificationServiceExtensionLib"],
frameworks = [
+ ":MtProtoKitFramework",
+ ":SwiftSignalKitFramework",
+ ":PostboxFramework",
+ ":TelegramApiFramework",
+ ":SyncCoreFramework",
],
)
@@ -1309,9 +1455,9 @@ ios_application(
extensions = [
":ShareExtension",
":WidgetExtension",
- #":NotificationContentExtension",
- #":NotificationServiceExtension",
- #":IntentsExtension",
+ ":NotificationContentExtension",
+ ":NotificationServiceExtension",
+ ":IntentsExtension",
],
watch_application = ":TelegramWatchApp",
deps = [
diff --git a/Telegram/NotificationContent/NotificationViewController.swift b/Telegram/NotificationContent/NotificationViewController.swift
index 8a6372ecdd..d61ef5ffa2 100644
--- a/Telegram/NotificationContent/NotificationViewController.swift
+++ b/Telegram/NotificationContent/NotificationViewController.swift
@@ -5,7 +5,7 @@ import TelegramUI
import BuildConfig
@objc(NotificationViewController)
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
class NotificationViewController: UIViewController, UNNotificationContentExtension {
private var impl: NotificationViewControllerImpl?
diff --git a/Telegram/NotificationService/BUCK b/Telegram/NotificationService/BUCK
new file mode 100644
index 0000000000..e918952b8c
--- /dev/null
+++ b/Telegram/NotificationService/BUCK
@@ -0,0 +1,2 @@
+load("//Config:buck_rule_macros.bzl", "static_library")
+
diff --git a/Telegram/NotificationService/BUILD b/Telegram/NotificationService/BUILD
new file mode 100644
index 0000000000..45229e4515
--- /dev/null
+++ b/Telegram/NotificationService/BUILD
@@ -0,0 +1,28 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "NotificationServiceExtensionLib",
+ module_name = "NotificationServiceExtensionLib",
+ srcs = glob([
+ "Sources/*.swift",
+ ]),
+ deps = [
+ "//submodules/BuildConfig:BuildConfig",
+ "//submodules/MtProtoKit:MtProtoKit",
+ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
+ "//submodules/EncryptionProvider:EncryptionProvider",
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/PostboxDataTypes:PostboxDataTypes",
+ "//submodules/Database/MessageHistoryReadStateTable:MessageHistoryReadStateTable",
+ "//submodules/Database/MessageHistoryMetadataTable:MessageHistoryMetadataTable",
+ "//submodules/Database/PreferencesTable:PreferencesTable",
+ "//submodules/Database/PeerTable:PeerTable",
+ "//submodules/sqlcipher:sqlcipher",
+ "//submodules/AppLockState:AppLockState",
+ "//submodules/NotificationsPresentationData:NotificationsPresentationData",
+ "//Telegram/NotificationService/NotificationServiceObjC:NotificationServiceObjC",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/Telegram/NotificationService/NotificationService-Bridging-Header.h b/Telegram/NotificationService/NotificationService-Bridging-Header.h
deleted file mode 100644
index d6f4fefa20..0000000000
--- a/Telegram/NotificationService/NotificationService-Bridging-Header.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef NotificationService_BridgingHeader_h
-#define NotificationService_BridgingHeader_h
-
-#import "NotificationService.h"
-
-#endif
diff --git a/Telegram/NotificationService/NotificationServiceObjC/BUCK b/Telegram/NotificationService/NotificationServiceObjC/BUCK
new file mode 100644
index 0000000000..56d88969a4
--- /dev/null
+++ b/Telegram/NotificationService/NotificationServiceObjC/BUCK
@@ -0,0 +1,18 @@
+load("//Config:buck_rule_macros.bzl", "static_library")
+
+static_library(
+ name = "NotificationServiceObjC",
+ srcs = glob([
+ "Sources/*.m",
+ ]),
+ headers = glob([
+ "Sources/*.h",
+ ]),
+ exported_headers = glob([
+ "PublicHeaders/**/*.h",
+ ]),
+ frameworks = [
+ "$SDKROOT/System/Library/Frameworks/Foundation.framework",
+ "$SDKROOT/System/Library/Frameworks/UIKit.framework",
+ ],
+)
diff --git a/Telegram/NotificationService/NotificationServiceObjC/BUILD b/Telegram/NotificationService/NotificationServiceObjC/BUILD
new file mode 100644
index 0000000000..4a3ea0828a
--- /dev/null
+++ b/Telegram/NotificationService/NotificationServiceObjC/BUILD
@@ -0,0 +1,30 @@
+
+objc_library(
+ name = "NotificationServiceObjC",
+ enable_modules = True,
+ module_name = "NotificationServiceObjC",
+ srcs = glob([
+ "Sources/**/*.m",
+ "Sources/**/*.h",
+ ]),
+ hdrs = glob([
+ "PublicHeaders/**/*.h",
+ ]),
+ includes = [
+ "PublicHeaders",
+ ],
+ deps = [
+ "//submodules/BuildConfig:BuildConfig",
+ "//submodules/MtProtoKit:MtProtoKit",
+ "//submodules/NotificationsPresentationData:NotificationsPresentationData",
+ ],
+ sdk_frameworks = [
+ "Foundation",
+ ],
+ weak_sdk_frameworks = [
+ "BackgroundTasks",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/Telegram/NotificationService/NotificationService.h b/Telegram/NotificationService/NotificationServiceObjC/PublicHeaders/NotificationServiceObjC/NotificationServiceObjC.h
similarity index 100%
rename from Telegram/NotificationService/NotificationService.h
rename to Telegram/NotificationService/NotificationServiceObjC/PublicHeaders/NotificationServiceObjC/NotificationServiceObjC.h
diff --git a/Telegram/NotificationService/Api.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h
similarity index 100%
rename from Telegram/NotificationService/Api.h
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h
diff --git a/Telegram/NotificationService/Api.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m
similarity index 100%
rename from Telegram/NotificationService/Api.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m
diff --git a/Telegram/NotificationService/Attachments.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/Attachments.h
similarity index 100%
rename from Telegram/NotificationService/Attachments.h
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Attachments.h
diff --git a/Telegram/NotificationService/Attachments.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/Attachments.m
similarity index 100%
rename from Telegram/NotificationService/Attachments.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Attachments.m
diff --git a/Telegram/NotificationService/FetchImage.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.h
similarity index 100%
rename from Telegram/NotificationService/FetchImage.h
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.h
diff --git a/Telegram/NotificationService/FetchImage.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m
similarity index 100%
rename from Telegram/NotificationService/FetchImage.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m
diff --git a/Telegram/NotificationService/NotificationService.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/NotificationService.m
similarity index 99%
rename from Telegram/NotificationService/NotificationService.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/NotificationService.m
index 83f17b94fe..c86437eccc 100644
--- a/Telegram/NotificationService/NotificationService.m
+++ b/Telegram/NotificationService/NotificationServiceObjC/Sources/NotificationService.m
@@ -1,4 +1,4 @@
-#import "NotificationService.h"
+#import
#import
@@ -14,8 +14,6 @@
#import "Api.h"
#import "FetchImage.h"
-#import "NotificationService-Bridging-Header.h"
-
static NSData * _Nullable parseBase64(NSString *string) {
string = [string stringByReplacingOccurrencesOfString:@"-" withString:@"+"];
string = [string stringByReplacingOccurrencesOfString:@"_" withString:@"/"];
diff --git a/Telegram/NotificationService/Serialization.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.h
similarity index 100%
rename from Telegram/NotificationService/Serialization.h
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.h
diff --git a/Telegram/NotificationService/Serialization.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m
similarity index 100%
rename from Telegram/NotificationService/Serialization.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m
diff --git a/Telegram/NotificationService/StoredAccountInfos.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/StoredAccountInfos.h
similarity index 100%
rename from Telegram/NotificationService/StoredAccountInfos.h
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/StoredAccountInfos.h
diff --git a/Telegram/NotificationService/StoredAccountInfos.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/StoredAccountInfos.m
similarity index 100%
rename from Telegram/NotificationService/StoredAccountInfos.m
rename to Telegram/NotificationService/NotificationServiceObjC/Sources/StoredAccountInfos.m
diff --git a/Telegram/NotificationService/ApplicationSpecificSharedDataKeys.swift b/Telegram/NotificationService/Sources/ApplicationSpecificSharedDataKeys.swift
similarity index 100%
rename from Telegram/NotificationService/ApplicationSpecificSharedDataKeys.swift
rename to Telegram/NotificationService/Sources/ApplicationSpecificSharedDataKeys.swift
diff --git a/Telegram/NotificationService/InAppNotificationSettings.swift b/Telegram/NotificationService/Sources/InAppNotificationSettings.swift
similarity index 100%
rename from Telegram/NotificationService/InAppNotificationSettings.swift
rename to Telegram/NotificationService/Sources/InAppNotificationSettings.swift
diff --git a/Telegram/NotificationService/Namespaces.swift b/Telegram/NotificationService/Sources/Namespaces.swift
similarity index 100%
rename from Telegram/NotificationService/Namespaces.swift
rename to Telegram/NotificationService/Sources/Namespaces.swift
diff --git a/Telegram/NotificationService/NotificationService.swift b/Telegram/NotificationService/Sources/NotificationService.swift
similarity index 98%
rename from Telegram/NotificationService/NotificationService.swift
rename to Telegram/NotificationService/Sources/NotificationService.swift
index b40349579e..606c0a7482 100644
--- a/Telegram/NotificationService/NotificationService.swift
+++ b/Telegram/NotificationService/Sources/NotificationService.swift
@@ -1,6 +1,7 @@
import Foundation
import UserNotifications
import SwiftSignalKit
+import NotificationServiceObjC
private let queue = Queue()
diff --git a/Telegram/NotificationService/Sync.swift b/Telegram/NotificationService/Sources/Sync.swift
similarity index 99%
rename from Telegram/NotificationService/Sync.swift
rename to Telegram/NotificationService/Sources/Sync.swift
index 26fdd95d42..1b66718df3 100644
--- a/Telegram/NotificationService/Sync.swift
+++ b/Telegram/NotificationService/Sources/Sync.swift
@@ -9,6 +9,7 @@ import PeerTable
import PostboxCoding
import AppLockState
import NotificationsPresentationData
+import BuildConfig
private let registeredTypes: Void = {
declareEncodable(InAppNotificationSettings.self, f: InAppNotificationSettings.init(decoder:))
diff --git a/Telegram/NotificationService/TelegramChannel.swift b/Telegram/NotificationService/Sources/TelegramChannel.swift
similarity index 100%
rename from Telegram/NotificationService/TelegramChannel.swift
rename to Telegram/NotificationService/Sources/TelegramChannel.swift
diff --git a/Telegram/SiriIntents/IntentContacts.swift b/Telegram/SiriIntents/IntentContacts.swift
index 39423c63ea..836fc29984 100644
--- a/Telegram/SiriIntents/IntentContacts.swift
+++ b/Telegram/SiriIntents/IntentContacts.swift
@@ -54,7 +54,7 @@ private func cleanPhoneNumber(_ text: String) -> String {
return result
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
func matchingDeviceContacts(stableIds: [String]) -> Signal<[MatchingDeviceContact], IntentContactsError> {
guard CNContactStore.authorizationStatus(for: .contacts) == .authorized else {
return .fail(.generic)
@@ -128,7 +128,7 @@ func matchingCloudContact(postbox: Postbox, peerId: PeerId) -> Signal INPerson {
var nameComponents = PersonNameComponents()
nameComponents.givenName = user.firstName
diff --git a/Telegram/SiriIntents/IntentHandler.swift b/Telegram/SiriIntents/IntentHandler.swift
index 46253f0897..651b484340 100644
--- a/Telegram/SiriIntents/IntentHandler.swift
+++ b/Telegram/SiriIntents/IntentHandler.swift
@@ -50,7 +50,7 @@ enum IntentHandlingError {
case generic
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
@objc(IntentHandler)
public class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessagesIntentHandling, INSetMessageAttributeIntentHandling, INStartAudioCallIntentHandling, INSearchCallHistoryIntentHandling {
private let accountPromise = Promise()
@@ -68,7 +68,6 @@ public class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
}
let baseAppBundleId = String(appBundleIdentifier[.. Void) {
if let appGroupUrl = self.appGroupUrl {
let rootPath = rootPathForBasePath(appGroupUrl.path)
@@ -598,7 +597,7 @@ public class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
})
}
- @available(iOSApplicationExtension 11.0, *)
+ @available(iOSApplicationExtension 11.0, iOS 11.0, *)
public func resolveDestinationType(for intent: INStartAudioCallIntent, with completion: @escaping (INCallDestinationTypeResolutionResult) -> Void) {
completion(.success(with: .normal))
}
@@ -647,7 +646,7 @@ public class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
// MARK: - INSearchCallHistoryIntentHandling
- @available(iOSApplicationExtension 11.0, *)
+ @available(iOSApplicationExtension 11.0, iOS 11.0, *)
public func resolveCallTypes(for intent: INSearchCallHistoryIntent, with completion: @escaping (INCallRecordTypeOptionsResolutionResult) -> Void) {
completion(.success(with: .missed))
}
@@ -685,7 +684,7 @@ public class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
|> deliverOnMainQueue).start(next: { calls in
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchCallHistoryIntent.self))
let response: INSearchCallHistoryIntentResponse
- if #available(iOSApplicationExtension 11.0, *) {
+ if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
response = INSearchCallHistoryIntentResponse(code: .success, userActivity: userActivity)
response.callRecords = calls.map { $0.intentCall }
} else {
diff --git a/Telegram/SiriIntents/IntentMessages.swift b/Telegram/SiriIntents/IntentMessages.swift
index 0f1e90de05..6f7afa6568 100644
--- a/Telegram/SiriIntents/IntentMessages.swift
+++ b/Telegram/SiriIntents/IntentMessages.swift
@@ -17,7 +17,7 @@ extension MessageId {
}
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
func getMessages(account: Account, ids: [MessageId]) -> Signal<[INMessage], NoError> {
return account.postbox.transaction { transaction -> [INMessage] in
var messages: [INMessage] = []
@@ -30,7 +30,7 @@ func getMessages(account: Account, ids: [MessageId]) -> Signal<[INMessage], NoEr
}
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
func unreadMessages(account: Account) -> Signal<[INMessage], NoError> {
return account.postbox.tailChatListView(groupId: .root, count: 20, summaryComponents: ChatListEntrySummaryComponents())
|> take(1)
@@ -89,7 +89,7 @@ func unreadMessages(account: Account) -> Signal<[INMessage], NoError> {
}
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
struct CallRecord {
let identifier: String
let date: Date
@@ -97,13 +97,13 @@ struct CallRecord {
let duration: Int32?
let unseen: Bool
- @available(iOSApplicationExtension 11.0, *)
+ @available(iOSApplicationExtension 11.0, iOS 11.0, *)
var intentCall: INCallRecord {
return INCallRecord(identifier: self.identifier, dateCreated: self.date, caller: self.caller, callRecordType: .missed, callCapability: .audioCall, callDuration: self.duration.flatMap(Double.init), unseen: self.unseen)
}
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
func missedCalls(account: Account) -> Signal<[CallRecord], NoError> {
return account.viewTracker.callListView(type: .missed, index: MessageIndex.absoluteUpperBound(), count: 30)
|> take(1)
@@ -125,7 +125,7 @@ func missedCalls(account: Account) -> Signal<[CallRecord], NoError> {
}
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
private func callWithTelegramMessage(_ telegramMessage: Message, account: Account) -> CallRecord? {
guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser else {
return nil
@@ -133,7 +133,7 @@ private func callWithTelegramMessage(_ telegramMessage: Message, account: Accoun
let identifier = "\(telegramMessage.id.peerId.toInt64())_\(telegramMessage.id.namespace)_\(telegramMessage.id.id)"
let personHandle: INPersonHandle
- if #available(iOSApplicationExtension 10.2, *) {
+ if #available(iOSApplicationExtension 10.2, iOS 10.2, *) {
var type: INPersonHandleType
var label: INPersonHandleLabel?
if let username = user.username {
@@ -164,7 +164,7 @@ private func callWithTelegramMessage(_ telegramMessage: Message, account: Accoun
return CallRecord(identifier: identifier, date: date, caller: caller, duration: duration, unseen: true)
}
-@available(iOSApplicationExtension 10.0, *)
+@available(iOSApplicationExtension 10.0, iOS 10.0, *)
private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage? {
guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser, user.id.id != 777000 else {
return nil
@@ -172,7 +172,7 @@ private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage
let identifier = "\(telegramMessage.id.peerId.toInt64())_\(telegramMessage.id.namespace)_\(telegramMessage.id.id)"
let personHandle: INPersonHandle
- if #available(iOSApplicationExtension 10.2, *) {
+ if #available(iOSApplicationExtension 10.2, iOS 10.2, *) {
var type: INPersonHandleType
var label: INPersonHandleLabel?
if let username = user.username {
@@ -195,7 +195,7 @@ private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage
let date = Date(timeIntervalSince1970: TimeInterval(telegramMessage.timestamp))
let message: INMessage
- if #available(iOSApplicationExtension 11.0, *) {
+ if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
var messageType: INMessageType = .text
loop: for media in telegramMessage.media {
if media is TelegramMediaImage {
@@ -218,7 +218,7 @@ private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage
} else if file.isAnimated {
messageType = .mediaVideo
break loop
- } else if #available(iOSApplicationExtension 12.0, *) {
+ } else if #available(iOSApplicationExtension 12.0, iOS 12.0, *) {
messageType = .file
break loop
}
diff --git a/submodules/BuildConfig/BUILD b/submodules/BuildConfig/BUILD
index 347afe08eb..43c0ca2b29 100644
--- a/submodules/BuildConfig/BUILD
+++ b/submodules/BuildConfig/BUILD
@@ -26,8 +26,11 @@ objc_library(
"-DAPP_SPECIFIC_URL_SCHEME=\\\"{}\\\"".format(telegram_app_specific_url_scheme),
],
hdrs = glob([
- "Sources/*.h",
+ "PublicHeaders/**/*.h",
]),
+ includes = [
+ "PublicHeaders",
+ ],
deps = [
],
visibility = ["//visibility:public"],
diff --git a/submodules/BuildConfig/Sources/BuildConfig.h b/submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h
similarity index 100%
rename from submodules/BuildConfig/Sources/BuildConfig.h
rename to submodules/BuildConfig/PublicHeaders/BuildConfig/BuildConfig.h
diff --git a/submodules/BuildConfig/Sources/BuildConfig.m b/submodules/BuildConfig/Sources/BuildConfig.m
index afd727fcc8..37a9398b37 100644
--- a/submodules/BuildConfig/Sources/BuildConfig.m
+++ b/submodules/BuildConfig/Sources/BuildConfig.m
@@ -1,4 +1,4 @@
-#import "BuildConfig.h"
+#import
static NSString *telegramApplicationSecretKey = @"telegramApplicationSecretKey_v3";
API_AVAILABLE(ios(10))
diff --git a/submodules/Database/Buffers/BUILD b/submodules/Database/Buffers/BUILD
new file mode 100644
index 0000000000..1dfc9d649e
--- /dev/null
+++ b/submodules/Database/Buffers/BUILD
@@ -0,0 +1,14 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "Buffers",
+ module_name = "Buffers",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/MessageHistoryMetadataTable/BUILD b/submodules/Database/MessageHistoryMetadataTable/BUILD
new file mode 100644
index 0000000000..63e55881b1
--- /dev/null
+++ b/submodules/Database/MessageHistoryMetadataTable/BUILD
@@ -0,0 +1,18 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "MessageHistoryMetadataTable",
+ module_name = "MessageHistoryMetadataTable",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/Table:Table",
+ "//submodules/Database/PostboxDataTypes:PostboxDataTypes",
+ "//submodules/Database/PostboxCoding:PostboxCoding",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/MessageHistoryReadStateTable/BUILD b/submodules/Database/MessageHistoryReadStateTable/BUILD
new file mode 100644
index 0000000000..57bc50c44f
--- /dev/null
+++ b/submodules/Database/MessageHistoryReadStateTable/BUILD
@@ -0,0 +1,17 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "MessageHistoryReadStateTable",
+ module_name = "MessageHistoryReadStateTable",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/Table:Table",
+ "//submodules/Database/PostboxDataTypes:PostboxDataTypes",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/MurmurHash/BUCK b/submodules/Database/MurmurHash/BUCK
index 645fb93634..a9021604da 100644
--- a/submodules/Database/MurmurHash/BUCK
+++ b/submodules/Database/MurmurHash/BUCK
@@ -13,6 +13,7 @@ static_library(
"Sources/**/*.h",
]),
deps = [
+ "submodules/Database/MurmurHash/Impl:MurMurHashObjC",
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
diff --git a/submodules/Database/MurmurHash/BUILD b/submodules/Database/MurmurHash/BUILD
new file mode 100644
index 0000000000..9c13a397df
--- /dev/null
+++ b/submodules/Database/MurmurHash/BUILD
@@ -0,0 +1,15 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "MurmurHash",
+ module_name = "MurmurHash",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/MurmurHash/Impl:MurMurHashObjC",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/MurmurHash/Impl/BUCK b/submodules/Database/MurmurHash/Impl/BUCK
new file mode 100644
index 0000000000..d6c57bb02b
--- /dev/null
+++ b/submodules/Database/MurmurHash/Impl/BUCK
@@ -0,0 +1,18 @@
+load("//Config:buck_rule_macros.bzl", "static_library")
+
+static_library(
+ name = "MurMurHashObjC",
+ srcs = glob([
+ "Sources/*.m",
+ ]),
+ headers = glob([
+ "Sources/*.h",
+ ]),
+ exported_headers = glob([
+ "PublicHeaders/**/*.h",
+ ]),
+ frameworks = [
+ "$SDKROOT/System/Library/Frameworks/Foundation.framework",
+ "$SDKROOT/System/Library/Frameworks/UIKit.framework",
+ ],
+)
diff --git a/submodules/Database/MurmurHash/Impl/BUILD b/submodules/Database/MurmurHash/Impl/BUILD
new file mode 100644
index 0000000000..ca77824b12
--- /dev/null
+++ b/submodules/Database/MurmurHash/Impl/BUILD
@@ -0,0 +1,22 @@
+
+objc_library(
+ name = "MurMurHashObjC",
+ enable_modules = True,
+ module_name = "MurMurHashObjC",
+ srcs = glob([
+ "Sources/**/*.m",
+ "Sources/**/*.h",
+ ]),
+ hdrs = glob([
+ "PublicHeaders/**/*.h",
+ ]),
+ includes = [
+ "PublicHeaders",
+ ],
+ sdk_frameworks = [
+ "Foundation",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/MurmurHash/Sources/MurMurHash32.h b/submodules/Database/MurmurHash/Impl/PublicHeaders/MurMurHashObjC/MurMurHashObjC.h
similarity index 100%
rename from submodules/Database/MurmurHash/Sources/MurMurHash32.h
rename to submodules/Database/MurmurHash/Impl/PublicHeaders/MurMurHashObjC/MurMurHashObjC.h
diff --git a/submodules/Database/MurmurHash/Sources/MurMurHash32.m b/submodules/Database/MurmurHash/Impl/Sources/MurMurHashObjC.m
similarity index 98%
rename from submodules/Database/MurmurHash/Sources/MurMurHash32.m
rename to submodules/Database/MurmurHash/Impl/Sources/MurMurHashObjC.m
index 87f695f017..23c166dab8 100644
--- a/submodules/Database/MurmurHash/Sources/MurMurHash32.m
+++ b/submodules/Database/MurmurHash/Impl/Sources/MurMurHashObjC.m
@@ -1,4 +1,4 @@
-#import "MurMurHash32.h"
+#import
#include
#include
diff --git a/submodules/Database/MurmurHash/Sources/MurmurHash.swift b/submodules/Database/MurmurHash/Sources/MurmurHash.swift
index a0f326a4eb..3316df4419 100644
--- a/submodules/Database/MurmurHash/Sources/MurmurHash.swift
+++ b/submodules/Database/MurmurHash/Sources/MurmurHash.swift
@@ -1,4 +1,5 @@
import Foundation
+import MurMurHashObjC
public enum HashFunctions {
public static func murMurHash32(_ s: String) -> Int32 {
diff --git a/submodules/Database/PeerTable/BUILD b/submodules/Database/PeerTable/BUILD
new file mode 100644
index 0000000000..029695c652
--- /dev/null
+++ b/submodules/Database/PeerTable/BUILD
@@ -0,0 +1,18 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "PeerTable",
+ module_name = "PeerTable",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/Table:Table",
+ "//submodules/Database/PostboxCoding:PostboxCoding",
+ "//submodules/Database/PostboxDataTypes:PostboxDataTypes",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/PostboxCoding/BUILD b/submodules/Database/PostboxCoding/BUILD
new file mode 100644
index 0000000000..cb072c69c0
--- /dev/null
+++ b/submodules/Database/PostboxCoding/BUILD
@@ -0,0 +1,16 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "PostboxCoding",
+ module_name = "PostboxCoding",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/Buffers:Buffers",
+ "//submodules/Database/MurmurHash:MurmurHash",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/PostboxCoding/Sources/PostboxCoding.swift b/submodules/Database/PostboxCoding/Sources/PostboxCoding.swift
index 3566cfbf59..8435834a72 100644
--- a/submodules/Database/PostboxCoding/Sources/PostboxCoding.swift
+++ b/submodules/Database/PostboxCoding/Sources/PostboxCoding.swift
@@ -26,11 +26,11 @@ private let typeStore = { () -> EncodableTypeStore in
public func declareEncodable(_ type: Any.Type, f: @escaping(PostboxDecoder) -> PostboxCoding) {
let string = "\(type)"
- let hash = murMurHashString32(string)
+ let hash = HashFunctions.murMurHash32(string)
if typeStore.dict[hash] != nil {
assertionFailure("Encodable type hash collision for \(type)")
}
- typeStore.dict[murMurHashString32("\(type)")] = f
+ typeStore.dict[HashFunctions.murMurHash32("\(type)")] = f
}
public func declareEncodable(typeHash: Int32, _ f: @escaping(PostboxDecoder) -> PostboxCoding) {
@@ -41,7 +41,7 @@ public func declareEncodable(typeHash: Int32, _ f: @escaping(PostboxDecoder) ->
}
public func persistentHash32(_ string: String) -> Int32 {
- return murMurHashString32(string)
+ return HashFunctions.murMurHash32(string)
}
private enum ValueType: Int8 {
@@ -172,7 +172,7 @@ public final class PostboxEncoder {
self.buffer.write(&t, offset: 0, length: 1)
let string = "\(type(of: value))"
- var typeHash: Int32 = murMurHashString32(string)
+ var typeHash: Int32 = HashFunctions.murMurHash32(string)
self.buffer.write(&typeHash, offset: 0, length: 4)
let innerEncoder = PostboxEncoder()
@@ -189,7 +189,7 @@ public final class PostboxEncoder {
self.buffer.write(&t, offset: 0, length: 1)
let string = "\(type(of: value))"
- var typeHash: Int32 = murMurHashString32(string)
+ var typeHash: Int32 = HashFunctions.murMurHash32(string)
self.buffer.write(&typeHash, offset: 0, length: 4)
let innerEncoder = PostboxEncoder()
@@ -232,7 +232,7 @@ public final class PostboxEncoder {
self.buffer.write(&length, offset: 0, length: 4)
let innerEncoder = PostboxEncoder()
for object in value {
- var typeHash: Int32 = murMurHashString32("\(type(of: object))")
+ var typeHash: Int32 = HashFunctions.murMurHash32("\(type(of: object))")
self.buffer.write(&typeHash, offset: 0, length: 4)
innerEncoder.reset()
@@ -252,7 +252,7 @@ public final class PostboxEncoder {
self.buffer.write(&length, offset: 0, length: 4)
let innerEncoder = PostboxEncoder()
for object in value {
- var typeHash: Int32 = murMurHashString32("\(type(of: object))")
+ var typeHash: Int32 = HashFunctions.murMurHash32("\(type(of: object))")
self.buffer.write(&typeHash, offset: 0, length: 4)
innerEncoder.reset()
@@ -272,7 +272,7 @@ public final class PostboxEncoder {
self.buffer.write(&length, offset: 0, length: 4)
let innerEncoder = PostboxEncoder()
for object in value {
- var typeHash: Int32 = murMurHashString32("\(type(of: object))")
+ var typeHash: Int32 = HashFunctions.murMurHash32("\(type(of: object))")
self.buffer.write(&typeHash, offset: 0, length: 4)
innerEncoder.reset()
@@ -322,7 +322,7 @@ public final class PostboxEncoder {
let innerEncoder = PostboxEncoder()
for record in value {
- var keyTypeHash: Int32 = murMurHashString32("\(type(of: record.0))")
+ var keyTypeHash: Int32 = HashFunctions.murMurHash32("\(type(of: record.0))")
self.buffer.write(&keyTypeHash, offset: 0, length: 4)
innerEncoder.reset()
record.0.encode(innerEncoder)
@@ -330,7 +330,7 @@ public final class PostboxEncoder {
self.buffer.write(&keyLength, offset: 0, length: 4)
self.buffer.write(innerEncoder.buffer.memory, offset: 0, length: Int(keyLength))
- var valueTypeHash: Int32 = murMurHashString32("\(type(of: record.1))")
+ var valueTypeHash: Int32 = HashFunctions.murMurHash32("\(type(of: record.1))")
self.buffer.write(&valueTypeHash, offset: 0, length: 4)
innerEncoder.reset()
record.1.encode(innerEncoder)
@@ -349,7 +349,7 @@ public final class PostboxEncoder {
let innerEncoder = PostboxEncoder()
for record in value {
- var keyTypeHash: Int32 = murMurHashString32("\(type(of: record.0))")
+ var keyTypeHash: Int32 = HashFunctions.murMurHash32("\(type(of: record.0))")
self.buffer.write(&keyTypeHash, offset: 0, length: 4)
innerEncoder.reset()
keyEncoder(record.0, innerEncoder)
@@ -357,7 +357,7 @@ public final class PostboxEncoder {
self.buffer.write(&keyLength, offset: 0, length: 4)
self.buffer.write(innerEncoder.buffer.memory, offset: 0, length: Int(keyLength))
- var valueTypeHash: Int32 = murMurHashString32("\(type(of: record.1))")
+ var valueTypeHash: Int32 = HashFunctions.murMurHash32("\(type(of: record.1))")
self.buffer.write(&valueTypeHash, offset: 0, length: 4)
innerEncoder.reset()
record.1.encode(innerEncoder)
diff --git a/submodules/Database/PostboxDataTypes/BUILD b/submodules/Database/PostboxDataTypes/BUILD
new file mode 100644
index 0000000000..e2f103ef60
--- /dev/null
+++ b/submodules/Database/PostboxDataTypes/BUILD
@@ -0,0 +1,16 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "PostboxDataTypes",
+ module_name = "PostboxDataTypes",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/PostboxCoding:PostboxCoding",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/PreferencesTable/BUILD b/submodules/Database/PreferencesTable/BUILD
new file mode 100644
index 0000000000..4859d92d74
--- /dev/null
+++ b/submodules/Database/PreferencesTable/BUILD
@@ -0,0 +1,18 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "PreferencesTable",
+ module_name = "PreferencesTable",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ "//submodules/Database/Table:Table",
+ "//submodules/Database/PostboxCoding:PostboxCoding",
+ "//submodules/Database/PostboxDataTypes:PostboxDataTypes",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/Table/BUILD b/submodules/Database/Table/BUILD
new file mode 100644
index 0000000000..864f57d137
--- /dev/null
+++ b/submodules/Database/Table/BUILD
@@ -0,0 +1,15 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "Table",
+ module_name = "Table",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/Database/ValueBox:ValueBox",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)
diff --git a/submodules/Database/ValueBox/BUILD b/submodules/Database/ValueBox/BUILD
new file mode 100644
index 0000000000..cbf2af7dc6
--- /dev/null
+++ b/submodules/Database/ValueBox/BUILD
@@ -0,0 +1,17 @@
+load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
+
+swift_library(
+ name = "ValueBox",
+ module_name = "ValueBox",
+ srcs = glob([
+ "Sources/**/*.swift",
+ ]),
+ deps = [
+ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
+ "//submodules/sqlcipher:sqlcipher",
+ "//submodules/Database/Buffers:Buffers",
+ ],
+ visibility = [
+ "//visibility:public",
+ ],
+)