mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
093ec63cc5
commit
d1b6b182fe
@ -46,20 +46,18 @@ extern "C" {
|
||||
LOT_EXPORT unsigned char *lottie_image_load(char const *filename, int *x,
|
||||
int *y, int *comp, int req_comp)
|
||||
{
|
||||
return stbi_load(filename, x, y, comp, req_comp);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LOT_EXPORT unsigned char *lottie_image_load_from_data(const char *imageData,
|
||||
int len, int *x, int *y,
|
||||
int *comp, int req_comp)
|
||||
{
|
||||
unsigned char *data = (unsigned char *)imageData;
|
||||
return stbi_load_from_memory(data, len, x, y, comp, req_comp);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LOT_EXPORT void lottie_image_free(unsigned char *data)
|
||||
{
|
||||
stbi_image_free(data);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -8,207 +8,9 @@
|
||||
#endif
|
||||
#include <cstring>
|
||||
|
||||
using lottie_image_load_f = unsigned char *(*)(const char *filename, int *x,
|
||||
int *y, int *comp, int req_comp);
|
||||
using lottie_image_load_data_f = unsigned char *(*)(const char *data, int len,
|
||||
int *x, int *y, int *comp,
|
||||
int req_comp);
|
||||
using lottie_image_free_f = void (*)(unsigned char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern unsigned char *lottie_image_load(char const *filename, int *x, int *y,
|
||||
int *comp, int req_comp);
|
||||
extern unsigned char *lottie_image_load_from_data(const char *imageData,
|
||||
int len, int *x, int *y,
|
||||
int *comp, int req_comp);
|
||||
extern void lottie_image_free(unsigned char *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "vimageloader.h"
|
||||
|
||||
struct VImageLoader::Impl {
|
||||
lottie_image_load_f imageLoad{nullptr};
|
||||
lottie_image_free_f imageFree{nullptr};
|
||||
lottie_image_load_data_f imageFromData{nullptr};
|
||||
|
||||
#ifndef LOTTIE_STATIC_IMAGE_LOADER
|
||||
#ifdef WIN32
|
||||
HMODULE dl_handle{nullptr};
|
||||
bool moduleLoad()
|
||||
{
|
||||
dl_handle = LoadLibraryA("librlottie-image-loader.dll");
|
||||
return (dl_handle == nullptr);
|
||||
}
|
||||
void moduleFree()
|
||||
{
|
||||
if (dl_handle) FreeLibrary(dl_handle);
|
||||
}
|
||||
void init()
|
||||
{
|
||||
imageLoad =
|
||||
(lottie_image_load_f)GetProcAddress(dl_handle, "lottie_image_load");
|
||||
imageFree =
|
||||
(lottie_image_free_f)GetProcAddress(dl_handle, "lottie_image_free");
|
||||
imageFromData = (lottie_image_load_data_f)GetProcAddress(
|
||||
dl_handle, "lottie_image_load_from_data");
|
||||
}
|
||||
#else
|
||||
void *dl_handle{nullptr};
|
||||
void init()
|
||||
{
|
||||
imageLoad = (lottie_image_load_f)dlsym(dl_handle, "lottie_image_load");
|
||||
imageFree = (lottie_image_free_f)dlsym(dl_handle, "lottie_image_free");
|
||||
imageFromData = (lottie_image_load_data_f)dlsym(
|
||||
dl_handle, "lottie_image_load_from_data");
|
||||
}
|
||||
|
||||
void moduleFree()
|
||||
{
|
||||
if (dl_handle) dlclose(dl_handle);
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
bool moduleLoad()
|
||||
{
|
||||
dl_handle = dlopen("librlottie-image-loader.dylib", RTLD_LAZY);
|
||||
return (dl_handle == nullptr);
|
||||
}
|
||||
#else
|
||||
bool moduleLoad()
|
||||
{
|
||||
dl_handle = dlopen("librlottie-image-loader.so", RTLD_LAZY);
|
||||
return (dl_handle == nullptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
void *dl_handle{nullptr};
|
||||
void init()
|
||||
{
|
||||
imageLoad = lottie_image_load;
|
||||
imageFree = lottie_image_free;
|
||||
imageFromData = lottie_image_load_from_data;
|
||||
}
|
||||
void moduleFree() {}
|
||||
bool moduleLoad() { return false; }
|
||||
#endif
|
||||
|
||||
Impl()
|
||||
{
|
||||
if (moduleLoad()) {
|
||||
vWarning << "Failed to dlopen librlottie-image-loader library";
|
||||
return;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
if (!imageLoad)
|
||||
vWarning << "Failed to find symbol lottie_image_load in "
|
||||
"librlottie-image-loader library";
|
||||
|
||||
if (!imageFree)
|
||||
vWarning << "Failed to find symbol lottie_image_free in "
|
||||
"librlottie-image-loader library";
|
||||
|
||||
if (!imageFromData)
|
||||
vWarning << "Failed to find symbol lottie_image_load_data in "
|
||||
"librlottie-image-loader library";
|
||||
}
|
||||
|
||||
~Impl() { moduleFree(); }
|
||||
|
||||
VBitmap createBitmap(unsigned char *data, int width, int height,
|
||||
int channel)
|
||||
{
|
||||
// premultiply alpha
|
||||
if (channel == 4)
|
||||
convertToBGRAPremul(data, width, height);
|
||||
else
|
||||
convertToBGRA(data, width, height);
|
||||
|
||||
// create a bitmap of same size.
|
||||
VBitmap result =
|
||||
VBitmap(width, height, VBitmap::Format::ARGB32_Premultiplied);
|
||||
|
||||
// copy the data to bitmap buffer
|
||||
memcpy(result.data(), data, width * height * 4);
|
||||
|
||||
// free the image data
|
||||
imageFree(data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VBitmap load(const char *fileName)
|
||||
{
|
||||
if (!imageLoad) return VBitmap();
|
||||
|
||||
int width, height, n;
|
||||
unsigned char *data = imageLoad(fileName, &width, &height, &n, 4);
|
||||
|
||||
if (!data) {
|
||||
return VBitmap();
|
||||
}
|
||||
|
||||
return createBitmap(data, width, height, n);
|
||||
}
|
||||
|
||||
VBitmap load(const char *imageData, int len)
|
||||
{
|
||||
if (!imageFromData) return VBitmap();
|
||||
|
||||
int width, height, n;
|
||||
unsigned char *data =
|
||||
imageFromData(imageData, len, &width, &height, &n, 4);
|
||||
|
||||
if (!data) {
|
||||
return VBitmap();
|
||||
}
|
||||
|
||||
return createBitmap(data, width, height, n);
|
||||
}
|
||||
/*
|
||||
* convert from RGBA to BGRA and premultiply
|
||||
*/
|
||||
void convertToBGRAPremul(unsigned char *bits, int width, int height)
|
||||
{
|
||||
int pixelCount = width * height;
|
||||
unsigned char *pix = bits;
|
||||
for (int i = 0; i < pixelCount; i++) {
|
||||
unsigned char r = pix[0];
|
||||
unsigned char g = pix[1];
|
||||
unsigned char b = pix[2];
|
||||
unsigned char a = pix[3];
|
||||
|
||||
r = (r * a) / 255;
|
||||
g = (g * a) / 255;
|
||||
b = (b * a) / 255;
|
||||
|
||||
pix[0] = b;
|
||||
pix[1] = g;
|
||||
pix[2] = r;
|
||||
|
||||
pix += 4;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* convert from RGBA to BGRA
|
||||
*/
|
||||
void convertToBGRA(unsigned char *bits, int width, int height)
|
||||
{
|
||||
int pixelCount = width * height;
|
||||
unsigned char *pix = bits;
|
||||
for (int i = 0; i < pixelCount; i++) {
|
||||
unsigned char r = pix[0];
|
||||
unsigned char b = pix[2];
|
||||
pix[0] = b;
|
||||
pix[2] = r;
|
||||
pix += 4;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VImageLoader::VImageLoader() : mImpl(std::make_unique<VImageLoader::Impl>()) {}
|
||||
@ -217,10 +19,10 @@ VImageLoader::~VImageLoader() {}
|
||||
|
||||
VBitmap VImageLoader::load(const char *fileName)
|
||||
{
|
||||
return mImpl->load(fileName);
|
||||
return VBitmap();
|
||||
}
|
||||
|
||||
VBitmap VImageLoader::load(const char *data, int len)
|
||||
{
|
||||
return mImpl->load(data, len);
|
||||
return VBitmap();
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1802240206] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedFile($0) }
|
||||
dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) }
|
||||
dict[-855308010] = { return Api.auth.Authorization.parse_authorization($0) }
|
||||
dict[1148485274] = { return Api.auth.Authorization.parse_authorizationSignUpRequired($0) }
|
||||
dict[-181407105] = { return Api.InputFile.parse_inputFile($0) }
|
||||
dict[-95482955] = { return Api.InputFile.parse_inputFileBig($0) }
|
||||
dict[-1649296275] = { return Api.Peer.parse_peerUser($0) }
|
||||
@ -238,9 +239,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
|
||||
dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) }
|
||||
dict[-1557620115] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) }
|
||||
dict[-471670279] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) }
|
||||
dict[470789295] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) }
|
||||
dict[1571450403] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) }
|
||||
dict[-859915345] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) }
|
||||
dict[-2138237532] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) }
|
||||
dict[471043349] = { return Api.contacts.Blocked.parse_blocked($0) }
|
||||
dict[-1878523231] = { return Api.contacts.Blocked.parse_blockedSlice($0) }
|
||||
dict[-55902537] = { return Api.InputDialogPeer.parse_inputDialogPeer($0) }
|
||||
@ -349,7 +350,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[295067450] = { return Api.BotInlineResult.parse_botInlineResult($0) }
|
||||
dict[911761060] = { return Api.messages.BotCallbackAnswer.parse_botCallbackAnswer($0) }
|
||||
dict[1314881805] = { return Api.payments.PaymentResult.parse_paymentResult($0) }
|
||||
dict[1800845601] = { return Api.payments.PaymentResult.parse_paymentVerficationNeeded($0) }
|
||||
dict[-666824391] = { return Api.payments.PaymentResult.parse_paymentVerificationNeeded($0) }
|
||||
dict[1694474197] = { return Api.messages.Chats.parse_chats($0) }
|
||||
dict[-1663561404] = { return Api.messages.Chats.parse_chatsSlice($0) }
|
||||
dict[482797855] = { return Api.InputSingleMedia.parse_inputSingleMedia($0) }
|
||||
@ -488,7 +489,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-923939298] = { return Api.messages.Messages.parse_messagesSlice($0) }
|
||||
dict[-1022713000] = { return Api.Invoice.parse_invoice($0) }
|
||||
dict[-2122045747] = { return Api.PeerSettings.parse_peerSettings($0) }
|
||||
dict[955951967] = { return Api.auth.SentCode.parse_sentCode($0) }
|
||||
dict[1577067778] = { return Api.auth.SentCode.parse_sentCode($0) }
|
||||
dict[480546647] = { return Api.InputChatPhoto.parse_inputChatPhotoEmpty($0) }
|
||||
dict[-1837345356] = { return Api.InputChatPhoto.parse_inputChatUploadedPhoto($0) }
|
||||
dict[-1991004873] = { return Api.InputChatPhoto.parse_inputChatPhoto($0) }
|
||||
|
@ -6064,9 +6064,9 @@ public extension Api {
|
||||
public enum ChannelParticipant: TypeConstructorDescription {
|
||||
case channelParticipant(userId: Int32, date: Int32)
|
||||
case channelParticipantSelf(userId: Int32, inviterId: Int32, date: Int32)
|
||||
case channelParticipantCreator(userId: Int32)
|
||||
case channelParticipantBanned(flags: Int32, userId: Int32, kickedBy: Int32, date: Int32, bannedRights: Api.ChatBannedRights)
|
||||
case channelParticipantAdmin(flags: Int32, userId: Int32, inviterId: Int32?, promotedBy: Int32, date: Int32, adminRights: Api.ChatAdminRights)
|
||||
case channelParticipantAdmin(flags: Int32, userId: Int32, inviterId: Int32?, promotedBy: Int32, date: Int32, adminRights: Api.ChatAdminRights, rank: String?)
|
||||
case channelParticipantCreator(flags: Int32, userId: Int32, rank: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -6085,12 +6085,6 @@ public extension Api {
|
||||
serializeInt32(inviterId, buffer: buffer, boxed: false)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .channelParticipantCreator(let userId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-471670279)
|
||||
}
|
||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .channelParticipantBanned(let flags, let userId, let kickedBy, let date, let bannedRights):
|
||||
if boxed {
|
||||
buffer.appendInt32(470789295)
|
||||
@ -6101,9 +6095,9 @@ public extension Api {
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
bannedRights.serialize(buffer, true)
|
||||
break
|
||||
case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights):
|
||||
case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights, let rank):
|
||||
if boxed {
|
||||
buffer.appendInt32(1571450403)
|
||||
buffer.appendInt32(-859915345)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
||||
@ -6111,6 +6105,15 @@ public extension Api {
|
||||
serializeInt32(promotedBy, buffer: buffer, boxed: false)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
adminRights.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeString(rank!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .channelParticipantCreator(let flags, let userId, let rank):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2138237532)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(userId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(rank!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -6121,12 +6124,12 @@ public extension Api {
|
||||
return ("channelParticipant", [("userId", userId), ("date", date)])
|
||||
case .channelParticipantSelf(let userId, let inviterId, let date):
|
||||
return ("channelParticipantSelf", [("userId", userId), ("inviterId", inviterId), ("date", date)])
|
||||
case .channelParticipantCreator(let userId):
|
||||
return ("channelParticipantCreator", [("userId", userId)])
|
||||
case .channelParticipantBanned(let flags, let userId, let kickedBy, let date, let bannedRights):
|
||||
return ("channelParticipantBanned", [("flags", flags), ("userId", userId), ("kickedBy", kickedBy), ("date", date), ("bannedRights", bannedRights)])
|
||||
case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights):
|
||||
return ("channelParticipantAdmin", [("flags", flags), ("userId", userId), ("inviterId", inviterId), ("promotedBy", promotedBy), ("date", date), ("adminRights", adminRights)])
|
||||
case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights, let rank):
|
||||
return ("channelParticipantAdmin", [("flags", flags), ("userId", userId), ("inviterId", inviterId), ("promotedBy", promotedBy), ("date", date), ("adminRights", adminRights), ("rank", rank)])
|
||||
case .channelParticipantCreator(let flags, let userId, let rank):
|
||||
return ("channelParticipantCreator", [("flags", flags), ("userId", userId), ("rank", rank)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -6161,17 +6164,6 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_channelParticipantCreator(_ reader: BufferReader) -> ChannelParticipant? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.ChannelParticipant.channelParticipantCreator(userId: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_channelParticipantBanned(_ reader: BufferReader) -> ChannelParticipant? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
@ -6212,14 +6204,34 @@ public extension Api {
|
||||
if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights
|
||||
}
|
||||
var _7: String?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_7 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.ChannelParticipant.channelParticipantAdmin(flags: _1!, userId: _2!, inviterId: _3, promotedBy: _4!, date: _5!, adminRights: _6!)
|
||||
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.ChannelParticipant.channelParticipantAdmin(flags: _1!, userId: _2!, inviterId: _3, promotedBy: _4!, date: _5!, adminRights: _6!, rank: _7)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_channelParticipantCreator(_ reader: BufferReader) -> ChannelParticipant? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.ChannelParticipant.channelParticipantCreator(flags: _1!, userId: _2!, rank: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -226,7 +226,7 @@ public struct payments {
|
||||
}
|
||||
public enum PaymentResult: TypeConstructorDescription {
|
||||
case paymentResult(updates: Api.Updates)
|
||||
case paymentVerficationNeeded(url: String)
|
||||
case paymentVerificationNeeded(url: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -236,9 +236,9 @@ public struct payments {
|
||||
}
|
||||
updates.serialize(buffer, true)
|
||||
break
|
||||
case .paymentVerficationNeeded(let url):
|
||||
case .paymentVerificationNeeded(let url):
|
||||
if boxed {
|
||||
buffer.appendInt32(1800845601)
|
||||
buffer.appendInt32(-666824391)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
break
|
||||
@ -249,8 +249,8 @@ public struct payments {
|
||||
switch self {
|
||||
case .paymentResult(let updates):
|
||||
return ("paymentResult", [("updates", updates)])
|
||||
case .paymentVerficationNeeded(let url):
|
||||
return ("paymentVerficationNeeded", [("url", url)])
|
||||
case .paymentVerificationNeeded(let url):
|
||||
return ("paymentVerificationNeeded", [("url", url)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,12 +267,12 @@ public struct payments {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_paymentVerficationNeeded(_ reader: BufferReader) -> PaymentResult? {
|
||||
public static func parse_paymentVerificationNeeded(_ reader: BufferReader) -> PaymentResult? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.payments.PaymentResult.paymentVerficationNeeded(url: _1!)
|
||||
return Api.payments.PaymentResult.paymentVerificationNeeded(url: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -496,6 +496,7 @@ public extension Api {
|
||||
public struct auth {
|
||||
public enum Authorization: TypeConstructorDescription {
|
||||
case authorization(flags: Int32, tmpSessions: Int32?, user: Api.User)
|
||||
case authorizationSignUpRequired(flags: Int32, termsOfService: Api.help.TermsOfService?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -507,6 +508,13 @@ public struct auth {
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(tmpSessions!, buffer: buffer, boxed: false)}
|
||||
user.serialize(buffer, true)
|
||||
break
|
||||
case .authorizationSignUpRequired(let flags, let termsOfService):
|
||||
if boxed {
|
||||
buffer.appendInt32(1148485274)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {termsOfService!.serialize(buffer, true)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,6 +522,8 @@ public struct auth {
|
||||
switch self {
|
||||
case .authorization(let flags, let tmpSessions, let user):
|
||||
return ("authorization", [("flags", flags), ("tmpSessions", tmpSessions), ("user", user)])
|
||||
case .authorizationSignUpRequired(let flags, let termsOfService):
|
||||
return ("authorizationSignUpRequired", [("flags", flags), ("termsOfService", termsOfService)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,6 +546,22 @@ public struct auth {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_authorizationSignUpRequired(_ reader: BufferReader) -> Authorization? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.help.TermsOfService?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.help.TermsOfService
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.auth.Authorization.authorizationSignUpRequired(flags: _1!, termsOfService: _2)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum PasswordRecovery: TypeConstructorDescription {
|
||||
@ -647,28 +673,27 @@ public struct auth {
|
||||
|
||||
}
|
||||
public enum SentCode: TypeConstructorDescription {
|
||||
case sentCode(flags: Int32, type: Api.auth.SentCodeType, phoneCodeHash: String, nextType: Api.auth.CodeType?, timeout: Int32?, termsOfService: Api.help.TermsOfService?)
|
||||
case sentCode(flags: Int32, type: Api.auth.SentCodeType, phoneCodeHash: String, nextType: Api.auth.CodeType?, timeout: Int32?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .sentCode(let flags, let type, let phoneCodeHash, let nextType, let timeout, let termsOfService):
|
||||
case .sentCode(let flags, let type, let phoneCodeHash, let nextType, let timeout):
|
||||
if boxed {
|
||||
buffer.appendInt32(955951967)
|
||||
buffer.appendInt32(1577067778)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
type.serialize(buffer, true)
|
||||
serializeString(phoneCodeHash, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {nextType!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {termsOfService!.serialize(buffer, true)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .sentCode(let flags, let type, let phoneCodeHash, let nextType, let timeout, let termsOfService):
|
||||
return ("sentCode", [("flags", flags), ("type", type), ("phoneCodeHash", phoneCodeHash), ("nextType", nextType), ("timeout", timeout), ("termsOfService", termsOfService)])
|
||||
case .sentCode(let flags, let type, let phoneCodeHash, let nextType, let timeout):
|
||||
return ("sentCode", [("flags", flags), ("type", type), ("phoneCodeHash", phoneCodeHash), ("nextType", nextType), ("timeout", timeout)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -687,18 +712,13 @@ public struct auth {
|
||||
} }
|
||||
var _5: Int32?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_5 = reader.readInt32() }
|
||||
var _6: Api.help.TermsOfService?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.help.TermsOfService
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.auth.SentCode.sentCode(flags: _1!, type: _2!, phoneCodeHash: _3!, nextType: _4, timeout: _5, termsOfService: _6)
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.auth.SentCode.sentCode(flags: _1!, type: _2!, phoneCodeHash: _3!, nextType: _4, timeout: _5)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -3367,22 +3367,6 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func editAdmin(channel: Api.InputChannel, userId: Api.InputUser, adminRights: Api.ChatAdminRights) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1895338938)
|
||||
channel.serialize(buffer, true)
|
||||
userId.serialize(buffer, true)
|
||||
adminRights.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "channels.editAdmin", parameters: [("channel", channel), ("userId", userId), ("adminRights", adminRights)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func editBanned(channel: Api.InputChannel, userId: Api.InputUser, bannedRights: Api.ChatBannedRights) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1920559378)
|
||||
@ -3520,6 +3504,23 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func editAdmin(channel: Api.InputChannel, userId: Api.InputUser, adminRights: Api.ChatAdminRights, rank: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-751007486)
|
||||
channel.serialize(buffer, true)
|
||||
userId.serialize(buffer, true)
|
||||
adminRights.serialize(buffer, true)
|
||||
serializeString(rank, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "channels.editAdmin", parameters: [("channel", channel), ("userId", userId), ("adminRights", adminRights), ("rank", rank)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct payments {
|
||||
public static func getPaymentForm(msgId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.PaymentForm>) {
|
||||
@ -3645,24 +3646,6 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func signUp(phoneNumber: String, phoneCodeHash: String, phoneCode: String, firstName: String, lastName: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.auth.Authorization>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(453408308)
|
||||
serializeString(phoneNumber, buffer: buffer, boxed: false)
|
||||
serializeString(phoneCodeHash, buffer: buffer, boxed: false)
|
||||
serializeString(phoneCode, buffer: buffer, boxed: false)
|
||||
serializeString(firstName, buffer: buffer, boxed: false)
|
||||
serializeString(lastName, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "auth.signUp", parameters: [("phoneNumber", phoneNumber), ("phoneCodeHash", phoneCodeHash), ("phoneCode", phoneCode), ("firstName", firstName), ("lastName", lastName)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.Authorization? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.auth.Authorization?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.auth.Authorization
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func signIn(phoneNumber: String, phoneCodeHash: String, phoneCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.auth.Authorization>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1126886015)
|
||||
@ -3878,6 +3861,23 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func signUp(phoneNumber: String, phoneCodeHash: String, firstName: String, lastName: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.auth.Authorization>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-2131827673)
|
||||
serializeString(phoneNumber, buffer: buffer, boxed: false)
|
||||
serializeString(phoneCodeHash, buffer: buffer, boxed: false)
|
||||
serializeString(firstName, buffer: buffer, boxed: false)
|
||||
serializeString(lastName, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "auth.signUp", parameters: [("phoneNumber", phoneNumber), ("phoneCodeHash", phoneCodeHash), ("firstName", firstName), ("lastName", lastName)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.Authorization? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.auth.Authorization?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.auth.Authorization
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct bots {
|
||||
public static func sendCustomRequest(customMethod: String, params: Api.DataJSON) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.DataJSON>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user