TDLib 1.8.0: Headers and sender -> sender_id changes

This commit is contained in:
Sebastian Wolf 2022-01-07 19:18:04 +01:00
parent 3a8615dbe3
commit fcbf9d65f1
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A
16 changed files with 930 additions and 732 deletions

View file

@ -37,7 +37,7 @@ Row {
onInReplyToMessageChanged: {
if (inReplyToMessage) {
inReplyToUserText.text = (inReplyToMessage.sender["@type"] === "messageSenderChat" ? page.chatInformation.title : (inReplyToRow.inReplyToMessage.sender.user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender.user_id)), inReplyToUserText.font.pixelSize) : qsTr("You"));
inReplyToUserText.text = (inReplyToMessage.sender_id["@type"] === "messageSenderChat" ? page.chatInformation.title : (inReplyToRow.inReplyToMessage.sender_id.user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_id.user_id)), inReplyToUserText.font.pixelSize) : qsTr("You"));
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true, inReplyToRow.myUserId, false), inReplyToMessageText.font.pixelSize);
}
}

View file

@ -32,8 +32,8 @@ ListItem {
property int messageViewCount
property var myMessage
property bool canReplyToMessage
readonly property bool isAnonymous: myMessage.sender["@type"] === "messageSenderChat"
readonly property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender.user_id)
readonly property bool isAnonymous: myMessage.sender_id["@type"] === "messageSenderChat"
readonly property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_id.user_id)
property QtObject precalculatedValues: ListView.view.precalculatedValues
readonly property color textColor: isOwnMessage ? Theme.highlightColor : Theme.primaryColor
readonly property int textAlign: isOwnMessage ? Text.AlignRight : Text.AlignLeft
@ -41,7 +41,7 @@ ListItem {
readonly property bool isSelected: messageListItem.precalculatedValues.pageIsSelecting && page.selectedMessages.some(function(existingMessage) {
return existingMessage.id === messageId
});
readonly property bool isOwnMessage: page.myUserId === myMessage.sender.user_id
readonly property bool isOwnMessage: page.myUserId === myMessage.sender_id.user_id
readonly property bool canDeleteMessage: myMessage.can_be_deleted_for_all_users || (myMessage.can_be_deleted_only_for_self && myMessage.chat_id === page.myUserId)
property bool hasContentComponent
property bool additionalOptionsOpened

View file

@ -25,9 +25,9 @@ import "../js/debug.js" as Debug
Item {
id: messageListItem
property var myMessage: display
property bool senderIsUser: myMessage.sender["@type"] === "messageSenderUser"
property var userInformation: senderIsUser ? tdLibWrapper.getUserInformation(myMessage.sender.user_id) : null
property bool isOwnMessage: senderIsUser && chatPage.myUserId === myMessage.sender.user_id
property bool senderIsUser: myMessage.sender_id["@type"] === "messageSenderUser"
property var userInformation: senderIsUser ? tdLibWrapper.getUserInformation(myMessage.sender_id.user_id) : null
property bool isOwnMessage: senderIsUser && chatPage.myUserId === myMessage.sender_id.user_id
property var linkedMessage
height: backgroundRectangle.height + Theme.paddingMedium

View file

@ -32,9 +32,9 @@ Flickable {
property var overlayMessage;
property bool showHeader: true
readonly property var userInformation: tdLibWrapper.getUserInformation(overlayMessage.sender.user_id);
readonly property bool isOwnMessage: tdLibWrapper.getUserInformation().id === overlayMessage.sender.user_id;
readonly property bool isAnonymous: overlayMessage.sender["@type"] === "messageSenderChat"
readonly property var userInformation: tdLibWrapper.getUserInformation(overlayMessage.sender_id.user_id);
readonly property bool isOwnMessage: tdLibWrapper.getUserInformation().id === overlayMessage.sender_id.user_id;
readonly property bool isAnonymous: overlayMessage.sender_id["@type"] === "messageSenderChat"
property bool hasContentComponent: overlayMessage.content && chatView.delegateMessagesContent.indexOf(overlayMessage.content['@type']) > -1
signal requestClose;
@ -44,7 +44,7 @@ Flickable {
var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id);
return Emoji.emojify(otherChatInformation.title, fontSize);
case "messageForwardOriginUser":
var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender.user_id);
var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_id.user_id);
return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize);
default:
return Emoji.emojify(forwardInformation.origin.sender_name, fontSize);

View file

@ -33,7 +33,7 @@ Item {
onPinnedMessageChanged: {
if (pinnedMessage) {
Debug.log("[ChatPage] Activating pinned message");
var messageUserText = (pinnedMessage.sender.user_id !== chatPage.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(pinnedMessage.sender.user_id)), pinnedMessageUserText.font.pixelSize) : qsTr("You");
var messageUserText = (pinnedMessage.sender_id.user_id !== chatPage.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(pinnedMessage.sender_id.user_id)), pinnedMessageUserText.font.pixelSize) : qsTr("You");
pinnedMessageUserText.text = (messageUserText === "" ? qsTr("Pinned Message") : messageUserText );
pinnedMessageText.text = Emoji.emojify(Functions.getMessageText(pinnedMessage, true, chatPage.myUserId, false), pinnedMessageText.font.pixelSize);
pinnedMessageItem.visible = true;

View file

@ -36,7 +36,7 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) {
var myself = false;
if ( message['@type'] !== "sponsoredMessage" ) {
myself = ( message.sender['@type'] === "messageSenderUser" && message.sender.user_id.toString() === currentUserId.toString() );
myself = ( message.sender_id['@type'] === "messageSenderUser" && message.sender_id.user_id.toString() === currentUserId.toString() );
}
switch(message.content['@type']) {
@ -97,7 +97,7 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) {
case 'messageChatJoinByLink':
return myself ? qsTr("joined this chat", "myself") : qsTr("joined this chat");
case 'messageChatAddMembers':
if (message.sender['@type'] === "messageSenderUser" && message.sender.user_id === message.content.member_user_ids[0]) {
if (message.sender_id['@type'] === "messageSenderUser" && message.sender_id.user_id === message.content.member_user_ids[0]) {
return myself ? qsTr("were added to this chat", "myself") : qsTr("was added to this chat");
} else {
var addedUserNames = "";
@ -110,7 +110,7 @@ function getMessageText(message, simple, currentUserId, ignoreEntities) {
return myself ? qsTr("have added %1 to the chat", "myself").arg(addedUserNames) : qsTr("has added %1 to the chat").arg(addedUserNames);
}
case 'messageChatDeleteMember':
if (message.sender['@type'] === "messageSenderUser" && message.sender.user_id === message.content.user_id) {
if (message.sender_id['@type'] === "messageSenderUser" && message.sender_id.user_id === message.content.user_id) {
return myself ? qsTr("left this chat", "myself") : qsTr("left this chat");
} else {
return myself ? qsTr("have removed %1 from the chat", "myself").arg(getUserName(tdLibWrapper.getUserInformation(message.content.user_id))) : qsTr("has removed %1 from the chat").arg(getUserName(tdLibWrapper.getUserInformation(message.content.user_id)));
@ -469,7 +469,7 @@ function getMessagesArrayText(messages) {
var lastSenderName = "";
var lines = [];
for(var i = 0; i < messages.length; i += 1) {
var senderName = getUserName(tdLibWrapper.getUserInformation(messages[i].sender.user_id));
var senderName = getUserName(tdLibWrapper.getUserInformation(messages[i].sender_id.user_id));
if(senderName !== lastSenderName) {
lines.push(senderName);
}

View file

@ -203,7 +203,7 @@ Page {
messageStatusSuffix += " - " + qsTr("edited");
}
if (chatPage.myUserId === message.sender.user_id) {
if (chatPage.myUserId === message.sender_id.user_id) {
messageStatusSuffix += "&nbsp;&nbsp;"
if (listItemIndex <= lastReadSentIndex) {
// Read by other party
@ -610,7 +610,7 @@ Page {
chatViewStartupReadTimer.restart();
}
onNewMessageReceived: {
if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender.user_id === chatPage.myUserId) {
if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender_id.user_id === chatPage.myUserId) {
Debug.log("[ChatPage] Own message received or was scrolled to bottom, scrolling down to see it...");
chatView.scrollToIndex(chatView.count - 1);
viewMessageTimer.queueViewMessage(chatView.count - 1);

View file

@ -33,7 +33,7 @@ Page {
property var pollData: message.content.poll
property var userInformation: tdLibWrapper.getUserInformation(message.sender.user_id)
property var userInformation: tdLibWrapper.getUserInformation(message.sender_id.user_id)
property bool isQuiz: pollData.type['@type'] === "pollTypeQuiz"

View file

@ -37,7 +37,7 @@ namespace {
const QString CONTENT("content");
const QString LAST_MESSAGE("last_message");
const QString DRAFT_MESSAGE("draft_message");
const QString SENDER("sender");
const QString SENDER_ID("sender_id");
const QString USER_ID("user_id");
const QString BASIC_GROUP_ID("basic_group_id");
const QString SUPERGROUP_ID("supergroup_id");
@ -171,17 +171,17 @@ qlonglong ChatListModel::ChatData::lastReadInboxMessageId() const
qlonglong ChatListModel::ChatData::senderUserId() const
{
return lastMessage(SENDER).toMap().value(USER_ID).toLongLong();
return lastMessage(SENDER_ID).toMap().value(USER_ID).toLongLong();
}
qlonglong ChatListModel::ChatData::senderChatId() const
{
return lastMessage(SENDER).toMap().value(CHAT_ID).toLongLong();
return lastMessage(SENDER_ID).toMap().value(CHAT_ID).toLongLong();
}
bool ChatListModel::ChatData::senderIsChat() const
{
return lastMessage(SENDER).toMap().value(_TYPE).toString() == "messageSenderChat";
return lastMessage(SENDER_ID).toMap().value(_TYPE).toString() == "messageSenderChat";
}
qlonglong ChatListModel::ChatData::senderMessageDate() const
@ -192,7 +192,7 @@ qlonglong ChatListModel::ChatData::senderMessageDate() const
QString ChatListModel::ChatData::senderMessageText() const
{
qlonglong myUserId = tdLibWrapper->getUserInformation().value(ID).toLongLong();
return FernschreiberUtils::getMessageShortText(tdLibWrapper, lastMessage(CONTENT).toMap(), isChannel(), myUserId, lastMessage(SENDER).toMap() );
return FernschreiberUtils::getMessageShortText(tdLibWrapper, lastMessage(CONTENT).toMap(), isChannel(), myUserId, lastMessage(SENDER_ID).toMap() );
}

View file

@ -35,7 +35,7 @@ namespace {
const QString UNREAD_COUNT("unread_count");
const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id");
const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id");
const QString SENDER("sender");
const QString SENDER_ID("sender_id");
const QString USER_ID("user_id");
const QString PINNED_MESSAGE_ID("pinned_message_id");
const QString REPLY_MARKUP("reply_markup");
@ -129,17 +129,17 @@ QVector<int> ChatModel::MessageData::flagsToRoles(uint flags)
int ChatModel::MessageData::senderUserId() const
{
return messageData.value(SENDER).toMap().value(USER_ID).toInt();
return messageData.value(SENDER_ID).toMap().value(USER_ID).toInt();
}
qlonglong ChatModel::MessageData::senderChatId() const
{
return messageData.value(SENDER).toMap().value(CHAT_ID).toLongLong();
return messageData.value(SENDER_ID).toMap().value(CHAT_ID).toLongLong();
}
bool ChatModel::MessageData::senderIsChat() const
{
return messageData.value(SENDER).toMap().value(_TYPE).toString() == "messageSenderChat";
return messageData.value(SENDER_ID).toMap().value(_TYPE).toString() == "messageSenderChat";
}
QVector<int> ChatModel::MessageData::diff(const MessageData *message) const

View file

@ -43,7 +43,7 @@ namespace {
const QString MESSAGE("message");
const QString FIRST_NAME("first_name");
const QString LAST_NAME("last_name");
const QString SENDER("sender");
const QString SENDER_ID("sender_id");
const QString USER_ID("user_id");
const QString NOTIFICATIONS("notifications");
const QString NOTIFICATION_GROUP_ID("notification_group_id");
@ -336,7 +336,7 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat
}
QString notificationBody;
const QVariantMap senderInformation = messageMap.value(SENDER).toMap();
const QVariantMap senderInformation = messageMap.value(SENDER_ID).toMap();
if (notificationGroup->totalCount == 1 && !messageMap.isEmpty()) {
LOG("Group" << notificationGroup->notificationGroupId << "has 1 notification");
if (chatInformation && (chatInformation->type == TDLibWrapper::ChatTypeBasicGroup ||

View file

@ -17,122 +17,7 @@
namespace td {
/**
* Native C++ interface for interaction with TDLib.
*
* The TDLib instance is created for the lifetime of the Client object.
* Requests to TDLib can be sent using the Client::send method from any thread.
* New updates and responses to requests can be received using the Client::receive method from any thread,
* this function must not be called simultaneously from two different threads. Also note that all updates and
* responses to requests should be applied in the same order as they were received, to ensure consistency.
* Given this information, it's advisable to call this function from a dedicated thread.
* Some service TDLib requests can be executed synchronously from any thread using the Client::execute method.
*
* General pattern of usage:
* \code
* std::shared_ptr<td::Client> client = std::make_shared<td::Client>();
* // somehow share the client with other threads, which will be able to send requests via client->send
*
* const double WAIT_TIMEOUT = 10.0; // seconds
* bool is_closed = false; // should be set to true, when updateAuthorizationState with
* // authorizationStateClosed is received
* while (!is_closed) {
* auto response = client->receive(WAIT_TIMEOUT);
* if (response.object == nullptr) {
* continue;
* }
*
* if (response.id == 0) {
* // process response.object as an incoming update of type td_api::Update
* } else {
* // process response.object as an answer to a sent request with id response.id
* }
* }
* \endcode
*/
class Client final {
public:
/**
* Creates a new TDLib client.
*/
Client();
/**
* A request to the TDLib.
*/
struct Request {
/**
* Request identifier.
* Responses to TDLib requests will have the same id as the corresponding request.
* Updates from TDLib will have id == 0, incoming requests are thus disallowed to have id == 0.
*/
std::uint64_t id;
/**
* TDLib API function representing a request to TDLib.
*/
td_api::object_ptr<td_api::Function> function;
};
/**
* Sends request to TDLib. May be called from any thread.
* \param[in] request Request to TDLib.
*/
void send(Request &&request);
/**
* A response to a request, or an incoming update from TDLib.
*/
struct Response {
/**
* TDLib request identifier, which corresponds to the response, or 0 for incoming updates from TDLib.
*/
std::uint64_t id;
/**
* TDLib API object representing a response to a TDLib request or an incoming update.
*/
td_api::object_ptr<td_api::Object> object;
};
/**
* Receives incoming updates and request responses from TDLib. May be called from any thread, but shouldn't be
* called simultaneously from two different threads.
* \param[in] timeout The maximum number of seconds allowed for this function to wait for new data.
* \return An incoming update or request response. The object returned in the response may be a nullptr
* if the timeout expires.
*/
Response receive(double timeout);
/**
* Synchronously executes TDLib requests. Only a few requests can be executed synchronously.
* May be called from any thread.
* \param[in] request Request to the TDLib.
* \return The request response.
*/
static Response execute(Request &&request);
/**
* Destroys the client and TDLib instance.
*/
~Client();
/**
* Move constructor.
*/
Client(Client &&other) noexcept;
/**
* Move assignment operator.
*/
Client &operator=(Client &&other) noexcept;
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
/**
* The future native C++ interface for interaction with TDLib.
* The native C++ interface for interaction with TDLib.
*
* A TDLib client instance can be created through the method ClientManager::create_client_id.
* Requests can be sent using the method ClientManager::send from any thread.
@ -286,4 +171,119 @@ class ClientManager final {
std::unique_ptr<Impl> impl_;
};
/**
* Old native C++ interface for interaction with TDLib to be removed in TDLib 2.0.0.
*
* The TDLib instance is created for the lifetime of the Client object.
* Requests to TDLib can be sent using the Client::send method from any thread.
* New updates and responses to requests can be received using the Client::receive method from any thread,
* this function must not be called simultaneously from two different threads. Also note that all updates and
* responses to requests should be applied in the same order as they were received, to ensure consistency.
* Given this information, it's advisable to call this function from a dedicated thread.
* Some service TDLib requests can be executed synchronously from any thread using the Client::execute method.
*
* General pattern of usage:
* \code
* std::shared_ptr<td::Client> client = std::make_shared<td::Client>();
* // somehow share the client with other threads, which will be able to send requests via client->send
*
* const double WAIT_TIMEOUT = 10.0; // seconds
* bool is_closed = false; // should be set to true, when updateAuthorizationState with
* // authorizationStateClosed is received
* while (!is_closed) {
* auto response = client->receive(WAIT_TIMEOUT);
* if (response.object == nullptr) {
* continue;
* }
*
* if (response.id == 0) {
* // process response.object as an incoming update of type td_api::Update
* } else {
* // process response.object as an answer to a sent request with id response.id
* }
* }
* \endcode
*/
class Client final {
public:
/**
* Creates a new TDLib client.
*/
Client();
/**
* A request to the TDLib.
*/
struct Request {
/**
* Request identifier.
* Responses to TDLib requests will have the same id as the corresponding request.
* Updates from TDLib will have id == 0, incoming requests are thus disallowed to have id == 0.
*/
std::uint64_t id;
/**
* TDLib API function representing a request to TDLib.
*/
td_api::object_ptr<td_api::Function> function;
};
/**
* Sends request to TDLib. May be called from any thread.
* \param[in] request Request to TDLib.
*/
void send(Request &&request);
/**
* A response to a request, or an incoming update from TDLib.
*/
struct Response {
/**
* TDLib request identifier, which corresponds to the response, or 0 for incoming updates from TDLib.
*/
std::uint64_t id;
/**
* TDLib API object representing a response to a TDLib request or an incoming update.
*/
td_api::object_ptr<td_api::Object> object;
};
/**
* Receives incoming updates and request responses from TDLib. May be called from any thread, but shouldn't be
* called simultaneously from two different threads.
* \param[in] timeout The maximum number of seconds allowed for this function to wait for new data.
* \return An incoming update or request response. The object returned in the response may be a nullptr
* if the timeout expires.
*/
Response receive(double timeout);
/**
* Synchronously executes TDLib requests. Only a few requests can be executed synchronously.
* May be called from any thread.
* \param[in] request Request to the TDLib.
* \return The request response.
*/
static Response execute(Request &&request);
/**
* Destroys the client and TDLib instance.
*/
~Client();
/**
* Move constructor.
*/
Client(Client &&other) noexcept;
/**
* Move assignment operator.
*/
Client &operator=(Client &&other) noexcept;
private:
class Impl;
std::unique_ptr<Impl> impl_;
};
} // namespace td

File diff suppressed because it is too large Load diff

View file

@ -55,6 +55,9 @@ bool downcast_call(Object &obj, const T &func) {
case authenticationCodeTypeFlashCall::ID:
func(static_cast<authenticationCodeTypeFlashCall &>(obj));
return true;
case authenticationCodeTypeMissedCall::ID:
func(static_cast<authenticationCodeTypeMissedCall &>(obj));
return true;
case authorizationStateWaitTdlibParameters::ID:
func(static_cast<authorizationStateWaitTdlibParameters &>(obj));
return true;
@ -325,6 +328,9 @@ bool downcast_call(Object &obj, const T &func) {
case chatActionBarSharePhoneNumber::ID:
func(static_cast<chatActionBarSharePhoneNumber &>(obj));
return true;
case chatActionBarJoinRequest::ID:
func(static_cast<chatActionBarJoinRequest &>(obj));
return true;
case chatAdministrator::ID:
func(static_cast<chatAdministrator &>(obj));
return true;
@ -394,12 +400,15 @@ bool downcast_call(Object &obj, const T &func) {
case chatEventSlowModeDelayChanged::ID:
func(static_cast<chatEventSlowModeDelayChanged &>(obj));
return true;
case chatEventMessageTtlSettingChanged::ID:
func(static_cast<chatEventMessageTtlSettingChanged &>(obj));
case chatEventMessageTtlChanged::ID:
func(static_cast<chatEventMessageTtlChanged &>(obj));
return true;
case chatEventSignMessagesToggled::ID:
func(static_cast<chatEventSignMessagesToggled &>(obj));
return true;
case chatEventHasProtectedContentToggled::ID:
func(static_cast<chatEventHasProtectedContentToggled &>(obj));
return true;
case chatEventStickerSetChanged::ID:
func(static_cast<chatEventStickerSetChanged &>(obj));
return true;
@ -421,8 +430,8 @@ bool downcast_call(Object &obj, const T &func) {
case chatEventVideoChatCreated::ID:
func(static_cast<chatEventVideoChatCreated &>(obj));
return true;
case chatEventVideoChatDiscarded::ID:
func(static_cast<chatEventVideoChatDiscarded &>(obj));
case chatEventVideoChatEnded::ID:
func(static_cast<chatEventVideoChatEnded &>(obj));
return true;
case chatEventVideoChatParticipantIsMutedToggled::ID:
func(static_cast<chatEventVideoChatParticipantIsMutedToggled &>(obj));
@ -652,9 +661,6 @@ bool downcast_call(Object &obj, const T &func) {
case closedVectorPath::ID:
func(static_cast<closedVectorPath &>(obj));
return true;
case colorReplacement::ID:
func(static_cast<colorReplacement &>(obj));
return true;
case connectedWebsite::ID:
func(static_cast<connectedWebsite &>(obj));
return true;
@ -898,6 +904,9 @@ bool downcast_call(Object &obj, const T &func) {
case inlineKeyboardButtonTypeBuy::ID:
func(static_cast<inlineKeyboardButtonTypeBuy &>(obj));
return true;
case inlineKeyboardButtonTypeUser::ID:
func(static_cast<inlineKeyboardButtonTypeUser &>(obj));
return true;
case inlineQueryResultArticle::ID:
func(static_cast<inlineQueryResultArticle &>(obj));
return true;
@ -2167,12 +2176,6 @@ bool downcast_call(Object &obj, const T &func) {
case searchMessagesFilterChatPhoto::ID:
func(static_cast<searchMessagesFilterChatPhoto &>(obj));
return true;
case searchMessagesFilterCall::ID:
func(static_cast<searchMessagesFilterCall &>(obj));
return true;
case searchMessagesFilterMissedCall::ID:
func(static_cast<searchMessagesFilterMissedCall &>(obj));
return true;
case searchMessagesFilterVideoNote::ID:
func(static_cast<searchMessagesFilterVideoNote &>(obj));
return true;
@ -2218,9 +2221,6 @@ bool downcast_call(Object &obj, const T &func) {
case sponsoredMessage::ID:
func(static_cast<sponsoredMessage &>(obj));
return true;
case sponsoredMessages::ID:
func(static_cast<sponsoredMessages &>(obj));
return true;
case statisticalGraphData::ID:
func(static_cast<statisticalGraphData &>(obj));
return true;
@ -2269,12 +2269,15 @@ bool downcast_call(Object &obj, const T &func) {
case suggestedActionCheckPhoneNumber::ID:
func(static_cast<suggestedActionCheckPhoneNumber &>(obj));
return true;
case suggestedActionSeeTicksHint::ID:
func(static_cast<suggestedActionSeeTicksHint &>(obj));
case suggestedActionViewChecksHint::ID:
func(static_cast<suggestedActionViewChecksHint &>(obj));
return true;
case suggestedActionConvertToBroadcastGroup::ID:
func(static_cast<suggestedActionConvertToBroadcastGroup &>(obj));
return true;
case suggestedActionSetPassword::ID:
func(static_cast<suggestedActionSetPassword &>(obj));
return true;
case supergroup::ID:
func(static_cast<supergroup &>(obj));
return true;
@ -2521,44 +2524,26 @@ bool downcast_call(Object &obj, const T &func) {
case updateChatPosition::ID:
func(static_cast<updateChatPosition &>(obj));
return true;
case updateChatIsMarkedAsUnread::ID:
func(static_cast<updateChatIsMarkedAsUnread &>(obj));
return true;
case updateChatIsBlocked::ID:
func(static_cast<updateChatIsBlocked &>(obj));
return true;
case updateChatHasScheduledMessages::ID:
func(static_cast<updateChatHasScheduledMessages &>(obj));
return true;
case updateChatVideoChat::ID:
func(static_cast<updateChatVideoChat &>(obj));
return true;
case updateChatDefaultDisableNotification::ID:
func(static_cast<updateChatDefaultDisableNotification &>(obj));
return true;
case updateChatReadInbox::ID:
func(static_cast<updateChatReadInbox &>(obj));
return true;
case updateChatReadOutbox::ID:
func(static_cast<updateChatReadOutbox &>(obj));
return true;
case updateChatUnreadMentionCount::ID:
func(static_cast<updateChatUnreadMentionCount &>(obj));
return true;
case updateChatNotificationSettings::ID:
func(static_cast<updateChatNotificationSettings &>(obj));
return true;
case updateScopeNotificationSettings::ID:
func(static_cast<updateScopeNotificationSettings &>(obj));
return true;
case updateChatMessageTtlSetting::ID:
func(static_cast<updateChatMessageTtlSetting &>(obj));
return true;
case updateChatActionBar::ID:
func(static_cast<updateChatActionBar &>(obj));
return true;
case updateChatTheme::ID:
func(static_cast<updateChatTheme &>(obj));
case updateChatDraftMessage::ID:
func(static_cast<updateChatDraftMessage &>(obj));
return true;
case updateChatMessageSender::ID:
func(static_cast<updateChatMessageSender &>(obj));
return true;
case updateChatMessageTtl::ID:
func(static_cast<updateChatMessageTtl &>(obj));
return true;
case updateChatNotificationSettings::ID:
func(static_cast<updateChatNotificationSettings &>(obj));
return true;
case updateChatPendingJoinRequests::ID:
func(static_cast<updateChatPendingJoinRequests &>(obj));
@ -2566,8 +2551,29 @@ bool downcast_call(Object &obj, const T &func) {
case updateChatReplyMarkup::ID:
func(static_cast<updateChatReplyMarkup &>(obj));
return true;
case updateChatDraftMessage::ID:
func(static_cast<updateChatDraftMessage &>(obj));
case updateChatTheme::ID:
func(static_cast<updateChatTheme &>(obj));
return true;
case updateChatUnreadMentionCount::ID:
func(static_cast<updateChatUnreadMentionCount &>(obj));
return true;
case updateChatVideoChat::ID:
func(static_cast<updateChatVideoChat &>(obj));
return true;
case updateChatDefaultDisableNotification::ID:
func(static_cast<updateChatDefaultDisableNotification &>(obj));
return true;
case updateChatHasProtectedContent::ID:
func(static_cast<updateChatHasProtectedContent &>(obj));
return true;
case updateChatHasScheduledMessages::ID:
func(static_cast<updateChatHasScheduledMessages &>(obj));
return true;
case updateChatIsBlocked::ID:
func(static_cast<updateChatIsBlocked &>(obj));
return true;
case updateChatIsMarkedAsUnread::ID:
func(static_cast<updateChatIsMarkedAsUnread &>(obj));
return true;
case updateChatFilters::ID:
func(static_cast<updateChatFilters &>(obj));
@ -2575,6 +2581,9 @@ bool downcast_call(Object &obj, const T &func) {
case updateChatOnlineMemberCount::ID:
func(static_cast<updateChatOnlineMemberCount &>(obj));
return true;
case updateScopeNotificationSettings::ID:
func(static_cast<updateScopeNotificationSettings &>(obj));
return true;
case updateNotification::ID:
func(static_cast<updateNotification &>(obj));
return true;
@ -2590,8 +2599,8 @@ bool downcast_call(Object &obj, const T &func) {
case updateDeleteMessages::ID:
func(static_cast<updateDeleteMessages &>(obj));
return true;
case updateUserChatAction::ID:
func(static_cast<updateUserChatAction &>(obj));
case updateChatAction::ID:
func(static_cast<updateChatAction &>(obj));
return true;
case updateUserStatus::ID:
func(static_cast<updateUserStatus &>(obj));
@ -2937,9 +2946,6 @@ bool downcast_call(Function &obj, const T &func) {
case answerShippingQuery::ID:
func(static_cast<answerShippingQuery &>(obj));
return true;
case approveChatJoinRequest::ID:
func(static_cast<approveChatJoinRequest &>(obj));
return true;
case banChatMember::ID:
func(static_cast<banChatMember &>(obj));
return true;
@ -3081,9 +3087,6 @@ bool downcast_call(Function &obj, const T &func) {
case createVideoChat::ID:
func(static_cast<createVideoChat &>(obj));
return true;
case declineChatJoinRequest::ID:
func(static_cast<declineChatJoinRequest &>(obj));
return true;
case deleteAccount::ID:
func(static_cast<deleteAccount &>(obj));
return true;
@ -3105,8 +3108,8 @@ bool downcast_call(Function &obj, const T &func) {
case deleteChatMessagesByDate::ID:
func(static_cast<deleteChatMessagesByDate &>(obj));
return true;
case deleteChatMessagesFromUser::ID:
func(static_cast<deleteChatMessagesFromUser &>(obj));
case deleteChatMessagesBySender::ID:
func(static_cast<deleteChatMessagesBySender &>(obj));
return true;
case deleteChatReplyMarkup::ID:
func(static_cast<deleteChatReplyMarkup &>(obj));
@ -3147,9 +3150,6 @@ bool downcast_call(Function &obj, const T &func) {
case discardCall::ID:
func(static_cast<discardCall &>(obj));
return true;
case discardGroupCall::ID:
func(static_cast<discardGroupCall &>(obj));
return true;
case disconnectAllWebsites::ID:
func(static_cast<disconnectAllWebsites &>(obj));
return true;
@ -3207,6 +3207,9 @@ bool downcast_call(Function &obj, const T &func) {
case enableProxy::ID:
func(static_cast<enableProxy &>(obj));
return true;
case endGroupCall::ID:
func(static_cast<endGroupCall &>(obj));
return true;
case endGroupCallRecording::ID:
func(static_cast<endGroupCallRecording &>(obj));
return true;
@ -3282,6 +3285,9 @@ bool downcast_call(Function &obj, const T &func) {
case getChatAdministrators::ID:
func(static_cast<getChatAdministrators &>(obj));
return true;
case getChatAvailableMessageSenders::ID:
func(static_cast<getChatAvailableMessageSenders &>(obj));
return true;
case getChatEventLog::ID:
func(static_cast<getChatEventLog &>(obj));
return true;
@ -3336,8 +3342,8 @@ bool downcast_call(Function &obj, const T &func) {
case getChatSparseMessagePositions::ID:
func(static_cast<getChatSparseMessagePositions &>(obj));
return true;
case getChatSponsoredMessages::ID:
func(static_cast<getChatSponsoredMessages &>(obj));
case getChatSponsoredMessage::ID:
func(static_cast<getChatSponsoredMessage &>(obj));
return true;
case getChatStatistics::ID:
func(static_cast<getChatStatistics &>(obj));
@ -3723,6 +3729,12 @@ bool downcast_call(Function &obj, const T &func) {
case pingProxy::ID:
func(static_cast<pingProxy &>(obj));
return true;
case processChatJoinRequest::ID:
func(static_cast<processChatJoinRequest &>(obj));
return true;
case processChatJoinRequests::ID:
func(static_cast<processChatJoinRequests &>(obj));
return true;
case processPushNotification::ID:
func(static_cast<processPushNotification &>(obj));
return true;
@ -3993,8 +4005,11 @@ bool downcast_call(Function &obj, const T &func) {
case setChatMemberStatus::ID:
func(static_cast<setChatMemberStatus &>(obj));
return true;
case setChatMessageTtlSetting::ID:
func(static_cast<setChatMessageTtlSetting &>(obj));
case setChatMessageSender::ID:
func(static_cast<setChatMessageSender &>(obj));
return true;
case setChatMessageTtl::ID:
func(static_cast<setChatMessageTtl &>(obj));
return true;
case setChatNotificationSettings::ID:
func(static_cast<setChatNotificationSettings &>(obj));
@ -4041,6 +4056,9 @@ bool downcast_call(Function &obj, const T &func) {
case setGroupCallTitle::ID:
func(static_cast<setGroupCallTitle &>(obj));
return true;
case setInactiveSessionTtl::ID:
func(static_cast<setInactiveSessionTtl &>(obj));
return true;
case setInlineGameScore::ID:
func(static_cast<setInlineGameScore &>(obj));
return true;
@ -4179,6 +4197,9 @@ bool downcast_call(Function &obj, const T &func) {
case toggleChatDefaultDisableNotification::ID:
func(static_cast<toggleChatDefaultDisableNotification &>(obj));
return true;
case toggleChatHasProtectedContent::ID:
func(static_cast<toggleChatHasProtectedContent &>(obj));
return true;
case toggleChatIsMarkedAsUnread::ID:
func(static_cast<toggleChatIsMarkedAsUnread &>(obj));
return true;
@ -4209,6 +4230,12 @@ bool downcast_call(Function &obj, const T &func) {
case toggleMessageSenderIsBlocked::ID:
func(static_cast<toggleMessageSenderIsBlocked &>(obj));
return true;
case toggleSessionCanAcceptCalls::ID:
func(static_cast<toggleSessionCanAcceptCalls &>(obj));
return true;
case toggleSessionCanAcceptSecretChats::ID:
func(static_cast<toggleSessionCanAcceptSecretChats &>(obj));
return true;
case toggleSupergroupIsAllHistoryAvailable::ID:
func(static_cast<toggleSupergroupIsAllHistoryAvailable &>(obj));
return true;
@ -4242,9 +4269,6 @@ bool downcast_call(Function &obj, const T &func) {
case viewMessages::ID:
func(static_cast<viewMessages &>(obj));
return true;
case viewSponsoredMessage::ID:
func(static_cast<viewSponsoredMessage &>(obj));
return true;
case viewTrendingStickerSets::ID:
func(static_cast<viewTrendingStickerSets &>(obj));
return true;
@ -4277,6 +4301,9 @@ bool downcast_call(AuthenticationCodeType &obj, const T &func) {
case authenticationCodeTypeFlashCall::ID:
func(static_cast<authenticationCodeTypeFlashCall &>(obj));
return true;
case authenticationCodeTypeMissedCall::ID:
func(static_cast<authenticationCodeTypeMissedCall &>(obj));
return true;
default:
return false;
}
@ -4667,6 +4694,9 @@ bool downcast_call(ChatActionBar &obj, const T &func) {
case chatActionBarSharePhoneNumber::ID:
func(static_cast<chatActionBarSharePhoneNumber &>(obj));
return true;
case chatActionBarJoinRequest::ID:
func(static_cast<chatActionBarJoinRequest &>(obj));
return true;
default:
return false;
}
@ -4741,12 +4771,15 @@ bool downcast_call(ChatEventAction &obj, const T &func) {
case chatEventSlowModeDelayChanged::ID:
func(static_cast<chatEventSlowModeDelayChanged &>(obj));
return true;
case chatEventMessageTtlSettingChanged::ID:
func(static_cast<chatEventMessageTtlSettingChanged &>(obj));
case chatEventMessageTtlChanged::ID:
func(static_cast<chatEventMessageTtlChanged &>(obj));
return true;
case chatEventSignMessagesToggled::ID:
func(static_cast<chatEventSignMessagesToggled &>(obj));
return true;
case chatEventHasProtectedContentToggled::ID:
func(static_cast<chatEventHasProtectedContentToggled &>(obj));
return true;
case chatEventStickerSetChanged::ID:
func(static_cast<chatEventStickerSetChanged &>(obj));
return true;
@ -4768,8 +4801,8 @@ bool downcast_call(ChatEventAction &obj, const T &func) {
case chatEventVideoChatCreated::ID:
func(static_cast<chatEventVideoChatCreated &>(obj));
return true;
case chatEventVideoChatDiscarded::ID:
func(static_cast<chatEventVideoChatDiscarded &>(obj));
case chatEventVideoChatEnded::ID:
func(static_cast<chatEventVideoChatEnded &>(obj));
return true;
case chatEventVideoChatParticipantIsMutedToggled::ID:
func(static_cast<chatEventVideoChatParticipantIsMutedToggled &>(obj));
@ -5242,6 +5275,9 @@ bool downcast_call(InlineKeyboardButtonType &obj, const T &func) {
case inlineKeyboardButtonTypeBuy::ID:
func(static_cast<inlineKeyboardButtonTypeBuy &>(obj));
return true;
case inlineKeyboardButtonTypeUser::ID:
func(static_cast<inlineKeyboardButtonTypeUser &>(obj));
return true;
default:
return false;
}
@ -6888,12 +6924,6 @@ bool downcast_call(SearchMessagesFilter &obj, const T &func) {
case searchMessagesFilterChatPhoto::ID:
func(static_cast<searchMessagesFilterChatPhoto &>(obj));
return true;
case searchMessagesFilterCall::ID:
func(static_cast<searchMessagesFilterCall &>(obj));
return true;
case searchMessagesFilterMissedCall::ID:
func(static_cast<searchMessagesFilterMissedCall &>(obj));
return true;
case searchMessagesFilterVideoNote::ID:
func(static_cast<searchMessagesFilterVideoNote &>(obj));
return true;
@ -6981,12 +7011,15 @@ bool downcast_call(SuggestedAction &obj, const T &func) {
case suggestedActionCheckPhoneNumber::ID:
func(static_cast<suggestedActionCheckPhoneNumber &>(obj));
return true;
case suggestedActionSeeTicksHint::ID:
func(static_cast<suggestedActionSeeTicksHint &>(obj));
case suggestedActionViewChecksHint::ID:
func(static_cast<suggestedActionViewChecksHint &>(obj));
return true;
case suggestedActionConvertToBroadcastGroup::ID:
func(static_cast<suggestedActionConvertToBroadcastGroup &>(obj));
return true;
case suggestedActionSetPassword::ID:
func(static_cast<suggestedActionSetPassword &>(obj));
return true;
default:
return false;
}
@ -7274,44 +7307,26 @@ bool downcast_call(Update &obj, const T &func) {
case updateChatPosition::ID:
func(static_cast<updateChatPosition &>(obj));
return true;
case updateChatIsMarkedAsUnread::ID:
func(static_cast<updateChatIsMarkedAsUnread &>(obj));
return true;
case updateChatIsBlocked::ID:
func(static_cast<updateChatIsBlocked &>(obj));
return true;
case updateChatHasScheduledMessages::ID:
func(static_cast<updateChatHasScheduledMessages &>(obj));
return true;
case updateChatVideoChat::ID:
func(static_cast<updateChatVideoChat &>(obj));
return true;
case updateChatDefaultDisableNotification::ID:
func(static_cast<updateChatDefaultDisableNotification &>(obj));
return true;
case updateChatReadInbox::ID:
func(static_cast<updateChatReadInbox &>(obj));
return true;
case updateChatReadOutbox::ID:
func(static_cast<updateChatReadOutbox &>(obj));
return true;
case updateChatUnreadMentionCount::ID:
func(static_cast<updateChatUnreadMentionCount &>(obj));
return true;
case updateChatNotificationSettings::ID:
func(static_cast<updateChatNotificationSettings &>(obj));
return true;
case updateScopeNotificationSettings::ID:
func(static_cast<updateScopeNotificationSettings &>(obj));
return true;
case updateChatMessageTtlSetting::ID:
func(static_cast<updateChatMessageTtlSetting &>(obj));
return true;
case updateChatActionBar::ID:
func(static_cast<updateChatActionBar &>(obj));
return true;
case updateChatTheme::ID:
func(static_cast<updateChatTheme &>(obj));
case updateChatDraftMessage::ID:
func(static_cast<updateChatDraftMessage &>(obj));
return true;
case updateChatMessageSender::ID:
func(static_cast<updateChatMessageSender &>(obj));
return true;
case updateChatMessageTtl::ID:
func(static_cast<updateChatMessageTtl &>(obj));
return true;
case updateChatNotificationSettings::ID:
func(static_cast<updateChatNotificationSettings &>(obj));
return true;
case updateChatPendingJoinRequests::ID:
func(static_cast<updateChatPendingJoinRequests &>(obj));
@ -7319,8 +7334,29 @@ bool downcast_call(Update &obj, const T &func) {
case updateChatReplyMarkup::ID:
func(static_cast<updateChatReplyMarkup &>(obj));
return true;
case updateChatDraftMessage::ID:
func(static_cast<updateChatDraftMessage &>(obj));
case updateChatTheme::ID:
func(static_cast<updateChatTheme &>(obj));
return true;
case updateChatUnreadMentionCount::ID:
func(static_cast<updateChatUnreadMentionCount &>(obj));
return true;
case updateChatVideoChat::ID:
func(static_cast<updateChatVideoChat &>(obj));
return true;
case updateChatDefaultDisableNotification::ID:
func(static_cast<updateChatDefaultDisableNotification &>(obj));
return true;
case updateChatHasProtectedContent::ID:
func(static_cast<updateChatHasProtectedContent &>(obj));
return true;
case updateChatHasScheduledMessages::ID:
func(static_cast<updateChatHasScheduledMessages &>(obj));
return true;
case updateChatIsBlocked::ID:
func(static_cast<updateChatIsBlocked &>(obj));
return true;
case updateChatIsMarkedAsUnread::ID:
func(static_cast<updateChatIsMarkedAsUnread &>(obj));
return true;
case updateChatFilters::ID:
func(static_cast<updateChatFilters &>(obj));
@ -7328,6 +7364,9 @@ bool downcast_call(Update &obj, const T &func) {
case updateChatOnlineMemberCount::ID:
func(static_cast<updateChatOnlineMemberCount &>(obj));
return true;
case updateScopeNotificationSettings::ID:
func(static_cast<updateScopeNotificationSettings &>(obj));
return true;
case updateNotification::ID:
func(static_cast<updateNotification &>(obj));
return true;
@ -7343,8 +7382,8 @@ bool downcast_call(Update &obj, const T &func) {
case updateDeleteMessages::ID:
func(static_cast<updateDeleteMessages &>(obj));
return true;
case updateUserChatAction::ID:
func(static_cast<updateUserChatAction &>(obj));
case updateChatAction::ID:
func(static_cast<updateChatAction &>(obj));
return true;
case updateUserStatus::ID:
func(static_cast<updateUserStatus &>(obj));

View file

@ -18,87 +18,6 @@
* Fields of Bool type are stored as Boolean, fields of int32, int53, and double types are stored as Number, fields of
* int64 and string types are stored as String, fields of bytes type are base64 encoded and then stored as String,
* fields of array type are stored as Array.
* The main TDLib interface is asynchronous. To match requests with a corresponding response a field "@extra" can
* be added to the request object. The corresponding response will have an "@extra" field with exactly the same value.
*
* A TDLib client instance can be created through td_json_client_create.
* Requests then can be sent using td_json_client_send from any thread.
* New updates and request responses can be received through td_json_client_receive from any thread. This function
* must not be called simultaneously from two different threads. Also note that all updates and request responses
* must be applied in the order they were received to ensure consistency.
* Given this information, it's advisable to call this function from a dedicated thread.
* Some service TDLib requests can be executed synchronously from any thread by using td_json_client_execute.
* The TDLib client instance can be destroyed via td_json_client_destroy.
*
* General pattern of usage:
* \code
* void *client = td_json_client_create();
* // somehow share the client with other threads, which will be able to send requests via td_json_client_send
*
* const double WAIT_TIMEOUT = 10.0; // seconds
* int is_closed = 0; // should be set to 1, when updateAuthorizationState with authorizationStateClosed is received
* while (!is_closed) {
* const char *result = td_json_client_receive(client, WAIT_TIMEOUT);
* if (result) {
* // parse the result as JSON object and process it as an incoming update or an answer to a previously sent request
* }
* }
* td_json_client_destroy(client);
* \endcode
*/
#include "td/telegram/tdjson_export.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new instance of TDLib.
* \return Pointer to the created instance of TDLib.
*/
TDJSON_EXPORT void *td_json_client_create();
/**
* Sends request to the TDLib client. May be called from any thread.
* \param[in] client The client.
* \param[in] request JSON-serialized null-terminated request to TDLib.
*/
TDJSON_EXPORT void td_json_client_send(void *client, const char *request);
/**
* Receives incoming updates and request responses from the TDLib client. May be called from any thread, but
* must not be called simultaneously from two different threads.
* Returned pointer will be deallocated by TDLib during next call to td_json_client_receive or td_json_client_execute
* in the same thread, so it can't be used after that.
* \param[in] client The client.
* \param[in] timeout The maximum number of seconds allowed for this function to wait for new data.
* \return JSON-serialized null-terminated incoming update or request response. May be NULL if the timeout expires.
*/
TDJSON_EXPORT const char *td_json_client_receive(void *client, double timeout);
/**
* Synchronously executes TDLib request. May be called from any thread.
* Only a few requests can be executed synchronously.
* Returned pointer will be deallocated by TDLib during next call to td_json_client_receive or td_json_client_execute
* in the same thread, so it can't be used after that.
* \param[in] client The client. Currently ignored for all requests, so NULL can be passed.
* \param[in] request JSON-serialized null-terminated request to TDLib.
* \return JSON-serialized null-terminated request response.
*/
TDJSON_EXPORT const char *td_json_client_execute(void *client, const char *request);
/**
* Destroys the TDLib client instance. After this is called the client instance must not be used anymore.
* \param[in] client The client.
*/
TDJSON_EXPORT void td_json_client_destroy(void *client);
/**
* \file
* Alternatively, you can use new TDLib JSON interface, which will replace the current JSON interface in TDLib 2.0.0.
*
* Objects and functions serialization to JSON is the same for both JSON interfaces.
*
* The main TDLib interface is asynchronous. To match requests with a corresponding response, the field "@extra" can
* be added to the request object. The corresponding response will have an "@extra" field with exactly the same value.
@ -129,6 +48,12 @@ TDJSON_EXPORT void td_json_client_destroy(void *client);
* \endcode
*/
#include "td/telegram/tdjson_export.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Returns an opaque identifier of a new TDLib instance.
* The TDLib instance will not send updates until the first request is sent to it.
@ -181,6 +106,82 @@ typedef void (*td_log_message_callback_ptr)(int verbosity_level, const char *mes
*/
TDJSON_EXPORT void td_set_log_message_callback(int max_verbosity_level, td_log_message_callback_ptr callback);
/**
* \file
* Alternatively, you can use old TDLib JSON interface, which will be removed in TDLib 2.0.0.
*
* Objects and functions serialization to JSON is the same for both JSON interfaces.
*
* The main TDLib interface is asynchronous. To match requests with a corresponding response a field "@extra" can
* be added to the request object. The corresponding response will have an "@extra" field with exactly the same value.
*
* A TDLib client instance can be created through td_json_client_create.
* Requests then can be sent using td_json_client_send from any thread.
* New updates and request responses can be received through td_json_client_receive from any thread. This function
* must not be called simultaneously from two different threads. Also note that all updates and request responses
* must be applied in the order they were received to ensure consistency.
* Given this information, it's advisable to call this function from a dedicated thread.
* Some service TDLib requests can be executed synchronously from any thread by using td_json_client_execute.
* The TDLib client instance can be destroyed via td_json_client_destroy.
*
* General pattern of usage:
* \code
* void *client = td_json_client_create();
* // somehow share the client with other threads, which will be able to send requests via td_json_client_send
*
* const double WAIT_TIMEOUT = 10.0; // seconds
* int is_closed = 0; // should be set to 1, when updateAuthorizationState with authorizationStateClosed is received
* while (!is_closed) {
* const char *result = td_json_client_receive(client, WAIT_TIMEOUT);
* if (result) {
* // parse the result as JSON object and process it as an incoming update or an answer to a previously sent request
* }
* }
* td_json_client_destroy(client);
* \endcode
*/
/**
* Creates a new instance of TDLib.
* \return Pointer to the created instance of TDLib.
*/
TDJSON_EXPORT void *td_json_client_create();
/**
* Sends request to the TDLib client. May be called from any thread.
* \param[in] client The client.
* \param[in] request JSON-serialized null-terminated request to TDLib.
*/
TDJSON_EXPORT void td_json_client_send(void *client, const char *request);
/**
* Receives incoming updates and request responses from the TDLib client. May be called from any thread, but
* must not be called simultaneously from two different threads.
* Returned pointer will be deallocated by TDLib during next call to td_json_client_receive or td_json_client_execute
* in the same thread, so it can't be used after that.
* \param[in] client The client.
* \param[in] timeout The maximum number of seconds allowed for this function to wait for new data.
* \return JSON-serialized null-terminated incoming update or request response. May be NULL if the timeout expires.
*/
TDJSON_EXPORT const char *td_json_client_receive(void *client, double timeout);
/**
* Synchronously executes TDLib request. May be called from any thread.
* Only a few requests can be executed synchronously.
* Returned pointer will be deallocated by TDLib during next call to td_json_client_receive or td_json_client_execute
* in the same thread, so it can't be used after that.
* \param[in] client The client. Currently ignored for all requests, so NULL can be passed.
* \param[in] request JSON-serialized null-terminated request to TDLib.
* \return JSON-serialized null-terminated request response.
*/
TDJSON_EXPORT const char *td_json_client_execute(void *client, const char *request);
/**
* Destroys the TDLib client instance. After this is called the client instance must not be used anymore.
* \param[in] client The client.
*/
TDJSON_EXPORT void td_json_client_destroy(void *client);
#ifdef __cplusplus
} // extern "C"
#endif