diff options
author | George Hazan <ghazan@miranda.im> | 2022-12-13 21:13:42 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-12-13 21:13:42 +0300 |
commit | 367fc21050725d43fe38eaed2b2474a6f0a42a51 (patch) | |
tree | b704c3c118f12490bea999eca827a13cb917e0cd /protocols/Telegram/src/mt_proto.cpp | |
parent | 1113b5c3a26280a3c2a330361579c84f533be468 (diff) |
Telegram: - the first version of contact list reading
- the phone number is not a primary key anymore
Diffstat (limited to 'protocols/Telegram/src/mt_proto.cpp')
-rw-r--r-- | protocols/Telegram/src/mt_proto.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/protocols/Telegram/src/mt_proto.cpp b/protocols/Telegram/src/mt_proto.cpp index 8f8476636b..eb5c7be0ee 100644 --- a/protocols/Telegram/src/mt_proto.cpp +++ b/protocols/Telegram/src/mt_proto.cpp @@ -1,8 +1,17 @@ #include "stdafx.h" +static int CompareUsers(const TG_USER *p1, const TG_USER *p2) +{ + if (p1->id == p2->id) + return 0; + + return (p1->id < p2->id) ? -1 : 1; +} + CMTProto::CMTProto(const char* protoName, const wchar_t* userName) : PROTO<CMTProto>(protoName, userName), m_pClientMmanager(std::make_unique<td::ClientManager>()), + m_arUsers(10, CompareUsers), m_arRequests(10, NumericKeySortT), m_szOwnPhone(this, "Phone"), m_wszDefaultGroup(this, "DefaultGroup", L"Telegram"), @@ -20,6 +29,20 @@ CMTProto::~CMTProto() { } +void CMTProto::OnModulesLoaded() +{ + CMStringA szId(getMStringA(DBKEY_ID)); + if (!szId.IsEmpty()) + m_arUsers.insert(new TG_USER(_atoi64(szId.c_str()), 0)); + + for (auto &cc : AccContacts()) { + bool isGroupChat = isChatRoom(cc); + szId = getMStringA(cc, isGroupChat ? "ChatRoomID" : DBKEY_ID); + if (!szId.IsEmpty()) + m_arUsers.insert(new TG_USER(_atoi64(szId.c_str()), cc, isGroupChat)); + } +} + void CMTProto::OnErase() { DeleteDirectoryTreeW(GetProtoFolder(), false); |