summarylogtreecommitdiffstats
path: root/PR154-fix-build-with-tdlib-1.8.0.patch
blob: 8aafb25c285475abaed1023ff65f5692cc9f7472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
From 8c87b899ddbec32ec6ab4a34ddf0dc770f97d396 Mon Sep 17 00:00:00 2001
From: ludo <kontsek@tovek.cz>
Date: Fri, 11 Mar 2022 13:52:46 +0100
Subject: [PATCH] Update to tdlib 1.8.0

---
 CMakeLists.txt   | 12 +++++++-----
 client-utils.cpp |  2 +-
 identifiers.cpp  | 24 ++++++++++++------------
 identifiers.h    | 10 ++++++----
 td-client.cpp    | 15 +++++++--------
 td-client.h      |  2 +-
 6 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5006f78..2b05311 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,11 +6,11 @@ project(tdlib-purple VERSION ${VERSION} LANGUAGES CXX)
 
 find_package(Td REQUIRED)
 math(EXPR TDLIB_VERSION_NUMBER "10000*${Td_VERSION_MAJOR} + 100*${Td_VERSION_MINOR} + ${Td_VERSION_PATCH}")
-if (NOT(${TDLIB_VERSION_NUMBER} EQUAL 10709))
+if (${TDLIB_VERSION_NUMBER} LESS 10800)
     # Error message must begin with "tdlib version" for a grep command from readme
-    message(FATAL_ERROR "tdlib version 1.7.9 is required
+    message(FATAL_ERROR "at least tdlib version 1.8.0 is required
 (version found: ${Td_VERSION_MAJOR}.${Td_VERSION_MINOR}.${Td_VERSION_PATCH})")
-endif (NOT(${TDLIB_VERSION_NUMBER} EQUAL 10709))
+endif (${TDLIB_VERSION_NUMBER} LESS 10800)
 
 set(NoPkgConfig FALSE CACHE BOOL "Do not use pkg-config")
 set(NoWebp FALSE CACHE BOOL "Do not decode webp stickers")
@@ -18,8 +18,6 @@ set(NoBundledLottie FALSE CACHE BOOL "Do not use bundled rlottie library")
 set(NoLottie FALSE CACHE BOOL "Disable animated sticker conversion")
 set(NoTranslations FALSE CACHE BOOL "Disable translation support")
 set(NoVoip FALSE CACHE BOOL "Disable voice call support")
-set(tgvoip_INCLUDE_DIRS "" CACHE STRING "Path to libtgvoip headers")
-set(tgvoip_LIBRARIES "tgvoip" CACHE STRING "tgvoip library to link against")
 set(API_ID 94575 CACHE STRING "API id")
 set(API_HASH a3406de8d171bb422bb6ddf3bbd800e2 CACHE STRING "API hash")
 set(STUFF "" CACHE STRING "")
@@ -31,6 +29,10 @@ if (NOT NoPkgConfig)
         pkg_check_modules(libwebp libwebp)
         pkg_check_modules(libpng libpng)
     endif (NOT NoWebp)
+    if (NOT NoVoip)
+        pkg_check_modules(tgvoip tgvoip)
+    endif(NOT NoVoip)
+
     pkg_get_variable(PURPLE_PLUGIN_DIR purple plugindir)
     pkg_get_variable(PURPLE_DATA_DIR purple datarootdir)
 endif (NOT NoPkgConfig)
diff --git a/client-utils.cpp b/client-utils.cpp
index 16a3d78..8614694 100644
--- a/client-utils.cpp
+++ b/client-utils.cpp
@@ -434,7 +434,7 @@ bool isInviteLinkActive(const td::td_api::chatInviteLink &linkInfo)
 {
     return !linkInfo.is_revoked_ &&
         ((linkInfo.member_limit_ == 0) || (linkInfo.member_count_ < linkInfo.member_limit_)) &&
-        ((linkInfo.expire_date_ == 0) || (std::time(NULL) < static_cast<time_t>(linkInfo.expire_date_)));
+        ((linkInfo.expiration_date_ == 0) || (std::time(NULL) < static_cast<time_t>(linkInfo.expiration_date_)));
 }
 
 static std::string lastMessageSetting(ChatId chatId)
diff --git a/identifiers.cpp b/identifiers.cpp
index 43172d2..51a3a8d 100644
--- a/identifiers.cpp
+++ b/identifiers.cpp
@@ -45,11 +45,7 @@ UserId getUserId(const td::td_api::chatTypePrivate &privType)
 
 UserId getUserId(const td::td_api::chatMember &member)
 {
-    if (member.member_id_ && (member.member_id_->get_id() == td::td_api::messageSenderUser::ID)) {
-        const td::td_api::messageSenderUser &userInfo = static_cast<const td::td_api::messageSenderUser &>(*member.member_id_);
-        return UserId(userInfo.user_id_);
-    }
-    return UserId::invalid;
+    return getUserId(member.member_id_);
 }
 
 UserId getUserId(const td::td_api::call &call)
@@ -59,10 +55,7 @@ UserId getUserId(const td::td_api::call &call)
 
 UserId getSenderUserId(const td::td_api::message &message)
 {
-    if (message.sender_ && (message.sender_->get_id() == td::td_api::messageSenderUser::ID))
-        return UserId(static_cast<const td::td_api::messageSenderUser &>(*message.sender_).user_id_);
-    else
-        return UserId::invalid;
+    return getUserId(message.sender_id_);
 }
 
 UserId getSenderUserId(const td::td_api::messageForwardOriginUser &forwardOrigin)
@@ -80,9 +73,9 @@ UserId getUserId(const td::td_api::updateUserStatus &update)
     return UserId(update.user_id_);
 }
 
-UserId getUserId(const td::td_api::updateUserChatAction &update)
+UserId getUserId(const td::td_api::updateChatAction &update)
 {
-    return UserId(update.user_id_);
+    return getUserId(update.sender_id_);
 }
 
 UserId getUserId(const td::td_api::importedContacts &contacts, unsigned index)
@@ -95,6 +88,13 @@ UserId getUserId(const td::td_api::users &users, unsigned index)
     return UserId(users.user_ids_[index]);
 }
 
+UserId getUserId(const td::td_api::object_ptr<td::td_api::MessageSender>& sender) {
+    if(sender && (sender->get_id() == td::td_api::messageSenderUser::ID)) {
+        return UserId(static_cast<const td::td_api::messageSenderUser &>(*sender.get()).user_id_);
+    }
+    return UserId::invalid;
+}
+
 ChatId getChatId(const td::td_api::updateChatPosition &update)
 {
     return ChatId(update.chat_id_);
@@ -115,7 +115,7 @@ ChatId getChatId(const td::td_api::message &message)
     return ChatId(message.chat_id_);
 }
 
-ChatId getChatId(const td::td_api::updateUserChatAction &update)
+ChatId getChatId(const td::td_api::updateChatAction &update)
 {
     return ChatId(update.chat_id_);
 }
diff --git a/identifiers.h b/identifiers.h
index 21a60eb..747edad 100644
--- a/identifiers.h
+++ b/identifiers.h
@@ -63,9 +63,10 @@ DEFINE_ID_CLASS(UserId, int64_t)
     friend UserId getSenderUserId(const td::td_api::messageForwardOriginUser &forwardOrigin);
     friend UserId getUserId(const td::td_api::secretChat &secretChat);
     friend UserId getUserId(const td::td_api::updateUserStatus &update);
-    friend UserId getUserId(const td::td_api::updateUserChatAction &update);
+    friend UserId getUserId(const td::td_api::updateChatAction &update);
     friend UserId getUserId(const td::td_api::importedContacts &contacts, unsigned index);
     friend UserId getUserId(const td::td_api::users &users, unsigned index);
+    friend UserId getUserId(const td::td_api::object_ptr<td::td_api::MessageSender>& sender);
 };
 
 DEFINE_ID_CLASS(ChatId, int64_t)
@@ -74,7 +75,7 @@ DEFINE_ID_CLASS(ChatId, int64_t)
     friend ChatId getChatId(const td::td_api::updateChatTitle &update);
     friend ChatId getChatId(const td::td_api::messageForwardOriginChannel &forwardOrigin);
     friend ChatId getChatId(const td::td_api::message &message);
-    friend ChatId getChatId(const td::td_api::updateUserChatAction &update);
+    friend ChatId getChatId(const td::td_api::updateChatAction &update);
     friend ChatId getChatId(const td::td_api::updateChatLastMessage &update);
 };
 
@@ -116,15 +117,16 @@ UserId       getSenderUserId(const td::td_api::message &message);
 UserId       getSenderUserId(const td::td_api::messageForwardOriginUser &forwardOrigin);
 UserId       getUserId(const td::td_api::secretChat &secretChat);
 UserId       getUserId(const td::td_api::updateUserStatus &update);
-UserId       getUserId(const td::td_api::updateUserChatAction &update);
+UserId       getUserId(const td::td_api::updateChatAction &update);
 UserId       getUserId(const td::td_api::importedContacts &contacts, unsigned index);
 UserId       getUserId(const td::td_api::users &users, unsigned index);
+UserId 	     getUserId(const td::td_api::object_ptr<td::td_api::MessageSender>& sender);
 
 ChatId       getChatId(const td::td_api::updateChatPosition &update);
 ChatId       getChatId(const td::td_api::updateChatTitle &update);
 ChatId       getChatId(const td::td_api::messageForwardOriginChannel &forwardOrigin);
 ChatId       getChatId(const td::td_api::message &message);
-ChatId       getChatId(const td::td_api::updateUserChatAction &update);
+ChatId       getChatId(const td::td_api::updateChatAction &update);
 ChatId       getChatId(const td::td_api::updateChatLastMessage &update);
 
 BasicGroupId getBasicGroupId(const td::td_api::updateBasicGroupFullInfo &update);
diff --git a/td-client.cpp b/td-client.cpp
index 34d8b9b..5aaa48f 100644
--- a/td-client.cpp
+++ b/td-client.cpp
@@ -111,8 +111,8 @@ void PurpleTdClient::processUpdate(td::td_api::Object &update)
         break;
     }
 
-    case td::td_api::updateUserChatAction::ID: {
-        auto &updateChatAction = static_cast<td::td_api::updateUserChatAction &>(update);
+    case td::td_api::updateChatAction::ID: {
+        auto &updateChatAction = static_cast<td::td_api::updateChatAction &>(update);
         purple_debug_misc(config::pluginId, "Incoming update: chat action %d\n",
             updateChatAction.action_ ? updateChatAction.action_->get_id() : 0);
         handleUserChatAction(updateChatAction);
@@ -1276,7 +1276,7 @@ void PurpleTdClient::addChat(td::td_api::object_ptr<td::td_api::chat> chat)
     updateChat(m_data.getChat(chatId));
 }
 
-void PurpleTdClient::handleUserChatAction(const td::td_api::updateUserChatAction &updateChatAction)
+void PurpleTdClient::handleUserChatAction(const td::td_api::updateChatAction &updateChatAction)
 {
     const td::td_api::chat *chat = m_data.getChat(getChatId(updateChatAction));
     if (!chat) {
@@ -1295,19 +1295,18 @@ void PurpleTdClient::handleUserChatAction(const td::td_api::updateUserChatAction
     if (chatUserId != getUserId(updateChatAction)) {
         purpleDebug("Got user action for private chat {} (with user {}) for another user {}", {
             std::to_string(updateChatAction.chat_id_), std::to_string(chatUserId.value()),
-            std::to_string(updateChatAction.user_id_)
+            std::to_string(getUserId(updateChatAction))
         });
     } else if (updateChatAction.action_) {
         if (updateChatAction.action_->get_id() == td::td_api::chatActionCancel::ID) {
-            purpleDebug("User (id {}) stopped chat action", updateChatAction.user_id_);
+            purpleDebug("User (id {}) stopped chat action", getUserId(updateChatAction));
             showUserChatAction(getUserId(updateChatAction), false);
         } else if (updateChatAction.action_->get_id() == td::td_api::chatActionStartPlayingGame::ID) {
-            purpleDebug("User (id %d): treating chatActionStartPlayingGame as cancel",
-                        updateChatAction.user_id_);
+            purpleDebug("User (id %d): treating chatActionStartPlayingGame as cancel", getUserId(updateChatAction));
             showUserChatAction(getUserId(updateChatAction), false);
         } else {
             purpleDebug("User (id {}) started chat action (id {})", {
-                std::to_string(updateChatAction.user_id_), std::to_string(updateChatAction.action_->get_id())
+		std::to_string(getUserId(updateChatAction)), std::to_string(updateChatAction.action_->get_id())
             });
             showUserChatAction(getUserId(updateChatAction), true);
         }
diff --git a/td-client.h b/td-client.h
index 33503f0..741e915 100644
--- a/td-client.h
+++ b/td-client.h
@@ -113,7 +113,7 @@ private:
     void       addContactById(UserId userId, const std::string &phoneNumber, const std::string &alias,
                               const std::string &groupName);
     void       addChat(td::td_api::object_ptr<td::td_api::chat> chat);
-    void       handleUserChatAction(const td::td_api::updateUserChatAction &updateChatAction);
+    void       handleUserChatAction(const td::td_api::updateChatAction &updateChatAction);
     void       showUserChatAction(UserId userId, bool isTyping);
     void       addBuddySearchChatResponse(uint64_t requestId, td::td_api::object_ptr<td::td_api::Object> object);
     void       importContactResponse(uint64_t requestId, td::td_api::object_ptr<td::td_api::Object> object);
-- 
2.35.1