Build Postbox, SyncCore, TelegramCore

This commit is contained in:
Ali 2020-02-20 04:15:02 +04:00
parent a7ff727533
commit a75bd17b6c
83 changed files with 474 additions and 397 deletions

View File

@ -120,6 +120,9 @@ swift_library(
"//submodules/WalletUI:WalletUI", "//submodules/WalletUI:WalletUI",
"//submodules/WebsiteType:WebsiteType", "//submodules/WebsiteType:WebsiteType",
"//submodules/MtProtoKit:MtProtoKit", "//submodules/MtProtoKit:MtProtoKit",
"//submodules/Postbox:Postbox",
"//submodules/SyncCore:SyncCore",
"//submodules/TelegramCore:TelegramCore",
], ],
) )

View File

@ -9,6 +9,7 @@ static_library(
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared",
"//submodules/Postbox:Postbox#shared", "//submodules/Postbox:Postbox#shared",
"//submodules/MtProtoKit:MtProtoKit#shared", "//submodules/MtProtoKit:MtProtoKit#shared",
"//submodules/EncryptionProvider:EncryptionProvider",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -0,0 +1,18 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "CloudData",
module_name = "CloudData",
srcs = glob([
"Sources/**/*.swift",
]),
deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox",
"//submodules/MtProtoKit:MtProtoKit",
"//submodules/EncryptionProvider:EncryptionProvider",
],
visibility = [
"//visibility:public",
],
)

View File

@ -9,7 +9,7 @@ static_library(
"Sources/*.h", "Sources/*.h",
]), ]),
exported_headers = glob([ exported_headers = glob([
"Sources/*.h", "PublicHeaders/**/*.h",
]), ]),
deps = [ deps = [
], ],

21
submodules/Crc32/BUILD Normal file
View File

@ -0,0 +1,21 @@
objc_library(
name = "Crc32",
enable_modules = True,
module_name = "Crc32",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)

View File

@ -1,4 +1,4 @@
#import "Crc32.h" #import <Crc32/Crc32.h>
#import <zlib.h> #import <zlib.h>

View File

@ -0,0 +1,19 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "CryptoUtils",
srcs = glob([
"Sources/*.m",
]),
headers = glob([
"Sources/*.h",
]),
exported_headers = glob([
"PublicHeaders/**/*.h",
]),
deps = [
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
],
)

View File

@ -0,0 +1,21 @@
objc_library(
name = "CryptoUtils",
enable_modules = True,
module_name = "CryptoUtils",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)

View File

@ -1,4 +1,4 @@
#include "Crypto.h" #include <CryptoUtils/Crypto.h>
#import <CommonCrypto/CommonCrypto.h> #import <CommonCrypto/CommonCrypto.h>

View File

@ -6,10 +6,10 @@ static_library(
"Sources/**/*.m", "Sources/**/*.m",
]), ]),
headers = glob([ headers = glob([
"Sources/**/*.h", "PublicHeaders/**/*.h",
]), ]),
exported_headers = glob([ exported_headers = glob([
"Sources/**/*.h", "PublicHeaders/**/*.h",
]), ]),
deps = [ deps = [
], ],

View File

@ -1,13 +1,16 @@
objc_library( objc_library(
name = "EncryptionProvider", name = "EncryptionProvider",
enable_modules = True,
module_name = "EncryptionProvider",
srcs = glob([ srcs = glob([
"Sources/**/*.m", "Sources/**/*.m",
]), ]),
hdrs = glob([ hdrs = glob([
"Sources/**/*.h", "PublicHeaders/**/*.h",
]), ]),
includes = [ includes = [
"Sources/Public", "PublicHeaders",
], ],
deps = [ deps = [
], ],

View File

@ -0,0 +1,19 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "MurMurHash32",
srcs = glob([
"Sources/*.m",
]),
headers = glob([
"Sources/*.h",
]),
exported_headers = glob([
"PublicHeaders/**/*.h",
]),
deps = [
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
],
)

View File

@ -0,0 +1,21 @@
objc_library(
name = "MurMurHash32",
enable_modules = True,
module_name = "MurMurHash32",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)

View File

@ -7,6 +7,7 @@
int32_t murMurHash32(void *bytes, int length); int32_t murMurHash32(void *bytes, int length);
int32_t murMurHash32Data(NSData *data); int32_t murMurHash32Data(NSData *data);
int32_t murMurHashString32(const char *s); int32_t murMurHashString32(const char *s);
NSString *postboxTransformedString(CFStringRef string, bool replaceWithTransliteratedVersion, bool appendTransliteratedVersion); NSString *postboxTransformedString(CFStringRef string, bool replaceWithTransliteratedVersion, bool appendTransliteratedVersion);
#endif #endif

View File

@ -1,4 +1,4 @@
#import "MurMurHash32.h" #import <MurMurHash32/MurMurHash32.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -0,0 +1,20 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "NetworkLogging",
srcs = glob([
"Sources/*.m",
]),
headers = glob([
"Sources/*.h",
]),
exported_headers = glob([
"PublicHeaders/**/*.h",
]),
deps = [
"//submodules/MtProtoKit:MtProtoKit#shared",
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
],
)

View File

@ -0,0 +1,24 @@
objc_library(
name = "NetworkLogging",
enable_modules = True,
module_name = "NetworkLogging",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
deps = [
"//submodules/MtProtoKit:MtProtoKit",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)

View File

@ -1,8 +1,7 @@
#import "NetworkLogging.h" #import <NetworkLogging/NetworkLogging.h>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <MtProtoKit/MtLogging.h>
#import <MtProtoKit/MtProtoKit.h>
static void (*bridgingTrace)(NSString *, NSString *); static void (*bridgingTrace)(NSString *, NSString *);
void setBridgingTraceFunction(void (*f)(NSString *, NSString *)) { void setBridgingTraceFunction(void (*f)(NSString *, NSString *)) {

View File

@ -4,18 +4,13 @@ framework(
name = "Postbox", name = "Postbox",
srcs = glob([ srcs = glob([
"Sources/*.swift", "Sources/*.swift",
"Sources/*.m",
]), ]),
headers = [
"Sources/MurMurHash32.h",
],
exported_headers = [
"Sources/MurMurHash32.h",
],
deps = [ deps = [
"//submodules/Crc32:Crc32", "//submodules/Crc32:Crc32",
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared",
"//submodules/sqlcipher:sqlcipher", "//submodules/sqlcipher:sqlcipher",
"//submodules/MurMurHash32:MurMurHash32",
"//submodules/StringTransliteration:StringTransliteration",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

19
submodules/Postbox/BUILD Normal file
View File

@ -0,0 +1,19 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "Postbox",
module_name = "Postbox",
srcs = glob([
"Sources/**/*.swift",
]),
deps = [
"//submodules/Crc32:Crc32",
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/sqlcipher:sqlcipher",
"//submodules/MurMurHash32:MurMurHash32",
"//submodules/StringTransliteration:StringTransliteration",
],
visibility = [
"//visibility:public",
],
)

View File

@ -1,5 +1,5 @@
import Foundation import Foundation
import sqlcipher import MurMurHash32
public protocol PostboxCoding { public protocol PostboxCoding {
init(decoder: PostboxDecoder) init(decoder: PostboxDecoder)

View File

@ -1,2 +0,0 @@
SWIFT_INCLUDE_PATHS = $(SRCROOT)/Postbox
MODULEMAP_PRIVATE_FILE = $(SRCROOT)/Postbox/module.private.modulemap

View File

@ -22,6 +22,7 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
import Foundation
import sqlcipher import sqlcipher
public final class Database { public final class Database {

View File

@ -1,5 +1,5 @@
import Foundation import Foundation
import sqlcipher import MurMurHash32
public enum HashFunctions { public enum HashFunctions {
public static func murMurHash32(_ s: String) -> Int32 { public static func murMurHash32(_ s: String) -> Int32 {

View File

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

View File

@ -1,14 +0,0 @@
#ifndef IpcNotifier_h
#define IpcNotifier_h
#import <Foundation/Foundation.h>
@interface RLMNotifier : NSObject
- (instancetype _Nonnull)initWithBasePath:(NSString * _Nonnull)basePath notify:(void (^ _Nonnull)())notify;
- (void)listen;
- (void)notifyOtherRealms;
@end
#endif

View File

@ -1,195 +0,0 @@
#import <sys/event.h>
#import <sys/stat.h>
#import <sys/time.h>
#import <sys/errno.h>
#import <unistd.h>
#import "IpcNotifier.h"
// Write a byte to a pipe to notify anyone waiting for data on the pipe
static void notifyFd(int fd) {
while (true) {
char c = 0;
ssize_t ret = write(fd, &c, 1);
if (ret == 1) {
break;
}
// If the pipe's buffer is full, we need to read some of the old data in
// it to make space. We don't just read in the code waiting for
// notifications so that we can notify multiple waiters with a single
// write.
assert(ret == -1 && errno == EAGAIN);
char buff[1024];
read(fd, buff, sizeof buff);
}
}
namespace {
// A RAII holder for a file descriptor which automatically closes the wrapped fd
// when it's deallocated
class FdHolder {
int fd = -1;
void close() {
if (fd != -1) {
::close(fd);
}
fd = -1;
}
FdHolder& operator=(FdHolder const&) = delete;
FdHolder(FdHolder const&) = delete;
public:
FdHolder() { }
~FdHolder() { close(); }
operator int() const { return fd; }
FdHolder& operator=(int newFd) {
close();
fd = newFd;
return *this;
}
};
}
// Inter-thread and inter-process notifications of changes are done using a
// named pipe in the filesystem next to the Realm file. Everyone who wants to be
// notified of commits waits for data to become available on the pipe, and anyone
// who commits a write transaction writes data to the pipe after releasing the
// write lock. Note that no one ever actually *reads* from the pipe: the data
// actually written is meaningless, and trying to read from a pipe from multiple
// processes at once is fraught with race conditions.
// When a RLMRealm instance is created, we add a CFRunLoopSource to the current
// thread's runloop. On each cycle of the run loop, the run loop checks each of
// its sources for work to do, which in the case of CFRunLoopSource is just
// checking if CFRunLoopSourceSignal has been called since the last time it ran,
// and if so invokes the function pointer supplied when the source is created,
// which in our case just invokes `[realm handleExternalChange]`.
// Listening for external changes is done using kqueue() on a background thread.
// kqueue() lets us efficiently wait until the amount of data which can be read
// from one or more file descriptors has changed, and tells us which of the file
// descriptors it was that changed. We use this to wait on both the shared named
// pipe, and a local anonymous pipe. When data is written to the named pipe, we
// signal the runloop source and wake up the target runloop, and when data is
// written to the anonymous pipe the background thread removes the runloop
// source from the runloop and and shuts down.
@implementation RLMNotifier {
// Realm to notify of changes
void (^_notify)();
// Runloop which notifications are delivered on
CFRunLoopRef _runLoop;
// Read-write file descriptor for the named pipe which is waited on for
// changes and written to when a commit is made
FdHolder _notifyFd;
// File descriptor for the kqueue
FdHolder _kq;
// The two ends of an anonymous pipe used to notify the kqueue() thread that
// it should be shut down.
FdHolder _shutdownReadFd;
FdHolder _shutdownWriteFd;
}
- (instancetype)initWithBasePath:(NSString *)basePath notify:( void (^ _Nonnull)())notify {
self = [super init];
if (self) {
_notify = [notify copy];
_kq = kqueue();
if (_kq == -1) {
return nil;
}
const char *path = [basePath stringByAppendingString:@"postbox.note"].UTF8String;
// Create and open the named pipe
int ret = mkfifo(path, 0600);
if (ret == -1) {
int err = errno;
if (err == ENOTSUP) {
// Filesystem doesn't support named pipes, so try putting it in tmp instead
// Hash collisions are okay here because they just result in doing
// extra work, as opposed to correctness problems
static NSString *tmpDir = NSTemporaryDirectory();
path = [tmpDir stringByAppendingFormat:@"poxtbox_%llu.note", (unsigned long long)[basePath hash]].UTF8String;
ret = mkfifo(path, 0600);
err = errno;
}
// the fifo already existing isn't an error
if (ret == -1 && err != EEXIST) {
return nil;
}
}
_notifyFd = open(path, O_RDWR);
if (_notifyFd == -1) {
return nil;
}
// Make writing to the pipe return -1 when the pipe's buffer is full
// rather than blocking until there's space available
ret = fcntl(_notifyFd, F_SETFL, O_NONBLOCK);
if (ret == -1) {
return nil;
}
// Create the anonymous pipe
int pipeFd[2];
ret = pipe(pipeFd);
if (ret == -1) {
return nil;
}
_shutdownReadFd = pipeFd[0];
_shutdownWriteFd = pipeFd[1];
}
return self;
}
- (void)listen {
// Set up the kqueue
// EVFILT_READ indicates that we care about data being available to read
// on the given file descriptor.
// EV_CLEAR makes it wait for the amount of data available to be read to
// change rather than just returning when there is any data to read.
struct kevent ke[2];
EV_SET(&ke[0], _notifyFd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);
EV_SET(&ke[1], _shutdownReadFd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);
int ret = kevent(_kq, ke, 2, nullptr, 0, nullptr);
assert(ret == 0);
while (true) {
struct kevent event;
// Wait for data to become on either fd
// Return code is number of bytes available or -1 on error
ret = kevent(_kq, nullptr, 0, &event, 1, nullptr);
assert(ret >= 0);
if (ret == 0) {
// Spurious wakeup; just wait again
continue;
}
// Check which file descriptor had activity: if it's the shutdown
// pipe, then someone called -stop; otherwise it's the named pipe
// and someone committed a write transaction
if (event.ident == (uint32_t)_shutdownReadFd) {
return;
}
assert(event.ident == (uint32_t)_notifyFd);
_notify();
}
}
- (void)stop {
notifyFd(_shutdownWriteFd);
}
- (void)notifyOtherRealms {
notifyFd(_notifyFd);
}
@end

View File

@ -1,20 +0,0 @@
//
// Postbox.h
// Postbox
//
// Created by Peter on 10/06/15.
// Copyright (c) 2015 Telegram. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Postbox.
FOUNDATION_EXPORT double PostboxVersionNumber;
//! Project version string for Postbox.
FOUNDATION_EXPORT const unsigned char PostboxVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Postbox/PublicHeader.h>
#import <Postbox/MurMurHash32.h>
//#import <Postbox/IpcNotifier.h>

View File

@ -1,5 +1,5 @@
import Foundation import Foundation
import sqlcipher import StringTransliteration
public enum StringIndexTokenTransliteration { public enum StringIndexTokenTransliteration {
case none case none

View File

@ -1,3 +0,0 @@
module Postbox.PostboxPrivate {
export *
}

View File

@ -0,0 +1,18 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "Reachability",
srcs = glob([
"Sources/*.m",
]),
headers = glob([
"Sources/*.h",
]),
exported_headers = glob([
"PublicHeaders/**/*.h",
]),
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/SystemConfiguration.framework",
],
)

View File

@ -0,0 +1,22 @@
objc_library(
name = "Reachability",
enable_modules = True,
module_name = "Reachability",
srcs = glob([
"Sources/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
"SystemConfiguration",
],
visibility = [
"//visibility:public",
],
)

View File

@ -14,7 +14,7 @@
#import <CoreFoundation/CoreFoundation.h> #import <CoreFoundation/CoreFoundation.h>
#import "Reachability.h" #import <Reachability/Reachability.h>
#import <pthread.h> #import <pthread.h>
#import <libkern/OSAtomic.h> #import <libkern/OSAtomic.h>

View File

@ -0,0 +1,19 @@
load("//Config:buck_rule_macros.bzl", "static_library")
static_library(
name = "StringTransliteration",
srcs = glob([
"Sources/*.m",
]),
headers = glob([
"Sources/*.h",
]),
exported_headers = glob([
"PublicHeaders/**/*.h",
]),
deps = [
],
frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
],
)

View File

@ -0,0 +1,21 @@
objc_library(
name = "StringTransliteration",
enable_modules = True,
module_name = "StringTransliteration",
srcs = glob([
"Source/*.m",
]),
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
sdk_frameworks = [
"Foundation",
],
visibility = [
"//visibility:public",
],
)

View File

@ -0,0 +1,8 @@
#ifndef StringTransliteration_h
#define StringTransliteration_h
#import <Foundation/Foundation.h>
NSString *postboxTransformedString(CFStringRef string, bool replaceWithTransliteratedVersion, bool appendTransliteratedVersion);
#endif

View File

@ -0,0 +1,19 @@
#import <StringTransliteration/StringTransliteration.h>
NSString *postboxTransformedString(CFStringRef string, bool replaceWithTransliteratedVersion, bool appendTransliteratedVersion) {
NSMutableString *mutableString = [[NSMutableString alloc] initWithString:(__bridge NSString * _Nonnull)(string)];
CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformStripCombiningMarks, false);
if (replaceWithTransliteratedVersion || appendTransliteratedVersion) {
NSMutableString *transliteratedString = [[NSMutableString alloc] initWithString:mutableString];
CFStringTransform((CFMutableStringRef)transliteratedString, NULL, kCFStringTransformToLatin, false);
if (replaceWithTransliteratedVersion) {
return transliteratedString;
} else {
[mutableString appendString:@" "];
[mutableString appendString:transliteratedString];
}
}
return mutableString;
}

16
submodules/SyncCore/BUILD Normal file
View File

@ -0,0 +1,16 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "SyncCore",
module_name = "SyncCore",
srcs = glob([
"Sources/**/*.swift",
]),
deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox",
],
visibility = [
"//visibility:public",
],
)

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct AccountBackupData: Codable, Equatable { public struct AccountBackupData: Codable, Equatable {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public final class CachedResolvedByNamePeer: PostboxCoding { public final class CachedResolvedByNamePeer: PostboxCoding {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct SecureIdConfiguration: PostboxCoding { public struct SecureIdConfiguration: PostboxCoding {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct CloudFileMediaResourceId: MediaResourceId { public struct CloudFileMediaResourceId: MediaResourceId {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public enum ProxyServerConnection: Equatable, Hashable, PostboxCoding { public enum ProxyServerConnection: Equatable, Hashable, PostboxCoding {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
private enum SecretChatOutgoingFileValue: Int32 { private enum SecretChatOutgoingFileValue: Int32 {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public final class SecretFileEncryptionKey: PostboxCoding, Equatable { public final class SecretFileEncryptionKey: PostboxCoding, Equatable {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct SecureFileMediaResourceId: MediaResourceId { public struct SecureFileMediaResourceId: MediaResourceId {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct SecureIdFileReference: Equatable { public struct SecureIdFileReference: Equatable {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
private let typeFileName: Int32 = 0 private let typeFileName: Int32 = 0

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public enum TelegramMediaImageReference: PostboxCoding, Equatable { public enum TelegramMediaImageReference: PostboxCoding, Equatable {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct TelegramMediaPollOption: Equatable, PostboxCoding { public struct TelegramMediaPollOption: Equatable, PostboxCoding {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct TemporaryTwoStepPasswordToken: PostboxCoding, Equatable { public struct TemporaryTwoStepPasswordToken: PostboxCoding, Equatable {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
public struct WalletCollectionItem: Equatable, PostboxCoding { public struct WalletCollectionItem: Equatable, PostboxCoding {

View File

@ -0,0 +1,12 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "TelegramApi",
module_name = "TelegramApi",
srcs = glob([
"Sources/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)

View File

@ -4,18 +4,7 @@ framework(
name = "TelegramCore", name = "TelegramCore",
srcs = glob([ srcs = glob([
"Sources/*.swift", "Sources/*.swift",
"Sources/*.m",
]), ]),
headers = [
"Sources/Crypto.h",
"Sources/NetworkLogging.h",
"Sources/Reachability.h",
],
exported_headers = [
"Sources/Crypto.h",
"Sources/NetworkLogging.h",
"Sources/Reachability.h",
],
deps = [ deps = [
"//submodules/TelegramApi:TelegramApi#shared", "//submodules/TelegramApi:TelegramApi#shared",
"//submodules/MtProtoKit:MtProtoKit#shared", "//submodules/MtProtoKit:MtProtoKit#shared",
@ -24,9 +13,11 @@ framework(
"//submodules/SyncCore:SyncCore#shared", "//submodules/SyncCore:SyncCore#shared",
"//submodules/CloudData:CloudData", "//submodules/CloudData:CloudData",
"//submodules/EncryptionProvider:EncryptionProvider", "//submodules/EncryptionProvider:EncryptionProvider",
"//submodules/CryptoUtils:CryptoUtils",
"//submodules/NetworkLogging:NetworkLogging",
"//submodules/Reachability:Reachability",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",
], ],
) )

View File

@ -0,0 +1,24 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "TelegramCore",
module_name = "TelegramCore",
srcs = glob([
"Sources/**/*.swift",
]),
deps = [
"//submodules/TelegramApi:TelegramApi",
"//submodules/MtProtoKit:MtProtoKit",
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/Postbox:Postbox",
"//submodules/SyncCore:SyncCore",
"//submodules/CloudData:CloudData",
"//submodules/EncryptionProvider:EncryptionProvider",
"//submodules/CryptoUtils:CryptoUtils",
"//submodules/NetworkLogging:NetworkLogging",
"//submodules/Reachability:Reachability",
],
visibility = [
"//visibility:public",
],
)

View File

@ -2,6 +2,7 @@ import Foundation
import Postbox import Postbox
import MtProtoKit import MtProtoKit
import SwiftSignalKit import SwiftSignalKit
import CryptoUtils
private enum GenerateSecureSecretError { private enum GenerateSecureSecretError {
case generic case generic

View File

@ -3,7 +3,7 @@ import Postbox
import SwiftSignalKit import SwiftSignalKit
import MtProtoKit import MtProtoKit
import TelegramApi import TelegramApi
import CryptoUtils
import SyncCore import SyncCore
import EncryptionProvider import EncryptionProvider

View File

@ -1,7 +1,6 @@
import Foundation import Foundation
import Postbox import Postbox
import SyncCore import SyncCore
import TelegramCore
public final class ChatUpdatingMessageMedia: Equatable { public final class ChatUpdatingMessageMedia: Equatable {
public let text: String public let text: String

View File

@ -2,7 +2,7 @@ import Foundation
import TelegramApi import TelegramApi
import Postbox import Postbox
import SwiftSignalKit import SwiftSignalKit
import CryptoUtils
import SyncCore import SyncCore
private func md5(_ data: Data) -> Data { private func md5(_ data: Data) -> Data {

View File

@ -2,6 +2,7 @@ import Foundation
import SwiftSignalKit import SwiftSignalKit
import Postbox import Postbox
import TelegramApi import TelegramApi
import NetworkLogging
private let queue = DispatchQueue(label: "org.telegram.Telegram.trace", qos: .utility) private let queue = DispatchQueue(label: "org.telegram.Telegram.trace", qos: .utility)

View File

@ -1,5 +1,6 @@
import Foundation import Foundation
import Postbox import Postbox
import CryptoUtils
public extension MemoryBuffer { public extension MemoryBuffer {
func md5Digest() -> Data { func md5Digest() -> Data {

View File

@ -3,7 +3,7 @@ import Postbox
import TelegramApi import TelegramApi
import SwiftSignalKit import SwiftSignalKit
import MtProtoKit import MtProtoKit
import CryptoUtils
import SyncCore import SyncCore
private typealias SignalKitTimer = SwiftSignalKit.Timer private typealias SignalKitTimer = SwiftSignalKit.Timer

View File

@ -1,9 +1,9 @@
import Foundation import Foundation
import Postbox import Postbox
import TelegramApi import TelegramApi
import SwiftSignalKit import SwiftSignalKit
import MtProtoKit import MtProtoKit
import NetworkLogging
#if os(iOS) #if os(iOS)
import CloudData import CloudData

View File

@ -1,6 +1,7 @@
import Foundation import Foundation
import SwiftSignalKit import SwiftSignalKit
import MtProtoKit import MtProtoKit
import Reachability
#if os(iOS) #if os(iOS)
import CoreTelephony import CoreTelephony
#endif #endif

View File

@ -2,7 +2,7 @@ import Foundation
import Postbox import Postbox
import TelegramApi import TelegramApi
import SwiftSignalKit import SwiftSignalKit
import CryptoUtils
import SyncCore import SyncCore
enum PendingMessageUploadedContent { enum PendingMessageUploadedContent {

View File

@ -1,3 +1,4 @@
import Foundation
import Postbox import Postbox
import MtProtoKit import MtProtoKit
import SwiftSignalKit import SwiftSignalKit

View File

@ -0,0 +1,19 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "TextFormat",
module_name = "TextFormat",
srcs = glob([
"Sources/**/*.swift",
]),
deps = [
"//submodules/TelegramCore:TelegramCore",
"//submodules/SyncCore:SyncCore",
"//submodules/Display:Display",
"//submodules/TelegramPresentationData:TelegramPresentationData",
"//submodules/Markdown:Markdown",
],
visibility = [
"//visibility:public",
],
)

View File

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

View File

@ -0,0 +1,12 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "TinyThumbnail",
module_name = "TinyThumbnail",
srcs = glob([
"Sources/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)

View File

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

View File

@ -1,19 +0,0 @@
//
// TinyThumbnail.h
// TinyThumbnail
//
// Created by Peter on 8/10/19.
// Copyright © 2019 Telegram Messenger LLP. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for TinyThumbnail.
FOUNDATION_EXPORT double TinyThumbnailVersionNumber;
//! Project version string for TinyThumbnail.
FOUNDATION_EXPORT const unsigned char TinyThumbnailVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <TinyThumbnail/PublicHeader.h>

12
submodules/Tuples/BUILD Normal file
View File

@ -0,0 +1,12 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "Tuples",
module_name = "Tuples",
srcs = glob([
"Sources/**/*.swift",
]),
visibility = [
"//visibility:public",
],
)

View File

@ -12,18 +12,12 @@ static_library(
srcs = glob([ srcs = glob([
"Sources/*.c", "Sources/*.c",
]), ]),
headers = [ headers = glob([
"Sources/sqlcipher_config.h", "Sources/*.h",
"Sources/sqlite3.h", ]),
"Sources/sqlite3ext.h", exported_headers = glob([
], "PublicHeaders/**/*.h",
exported_headers = [ ]),
"Sources/sqlcipher_config.h",
"Sources/sqlite3.h",
"Sources/sqlite3ext.h",
],
deps = [
],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",
], ],

32
submodules/sqlcipher/BUILD vendored Normal file
View File

@ -0,0 +1,32 @@
public_headers = glob([
"PublicHeaders/**/*.h",
])
objc_library(
name = "sqlcipher",
enable_modules = True,
module_name = "sqlcipher",
srcs = glob([
"Sources/*.c",
"Sources/*.h",
], exclude = public_headers),
hdrs = public_headers,
includes = [
"PublicHeaders",
],
copts = [
"-DDSQLITE_HAS_CODEC=1",
"-DSQLCIPHER_CRYPTO_CC=1",
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_DEFAULT_MEMSTATUS=0",
"-DNDEBUG",
],
sdk_frameworks = [
"Foundation",
"Security",
],
visibility = [
"//visibility:public",
],
)

View File

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