From 901d6038085ea075d627febaf0e6283a74c4a01e Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 8 Dec 2020 17:29:25 +0300 Subject: [PATCH] Add GroupCallParticipant class. --- CMakeLists.txt | 2 ++ td/generate/scheme/td_api.tl | 5 +++ td/generate/scheme/td_api.tlo | Bin 189728 -> 190052 bytes td/telegram/GroupCallParticipant.cpp | 45 +++++++++++++++++++++++++++ td/telegram/GroupCallParticipant.h | 44 ++++++++++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 td/telegram/GroupCallParticipant.cpp create mode 100644 td/telegram/GroupCallParticipant.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b6972eb2..5b03c28a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,6 +320,7 @@ set(TDLIB_SOURCE td/telegram/Game.cpp td/telegram/Global.cpp td/telegram/GroupCallManager.cpp + td/telegram/GroupCallParticipant.cpp td/telegram/HashtagHints.cpp td/telegram/InlineQueriesManager.cpp td/telegram/InputDialogId.cpp @@ -494,6 +495,7 @@ set(TDLIB_SOURCE td/telegram/Game.h td/telegram/Global.h td/telegram/GroupCallManager.h + td/telegram/GroupCallParticipant.h td/telegram/HashtagHints.h td/telegram/InlineQueriesManager.h td/telegram/InputDialogId.h diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 271186011..4c6f2ee31 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2087,6 +2087,11 @@ groupCallJoinResponseCandidate port:string protocol:string network:string genera //@description Describes a join response for interaction with tgcalls @payload Join response payload to pass to tgcalls @candidates Join response candidates to pass to tgcalls groupCallJoinResponse payload:groupCallPayload candidates:vector = GroupCallJoinResponse; +//@description Represents a group call participant @user_id Identifier of the user @source User's synchronization source +//@is_speaking True, if the user is speaking as set by setGroupCallMemberIsSpeaking @is_muted True, if the user is muted @can_self_unmute True, if the user can unmute themself +//@order User's order in the group call participant list. The bigger is order, the higher is user in the list +groupCallParticipant user_id:int32 source:int32 is_speaking:Bool is_muted:Bool can_self_unmute:Bool order:int64 = GroupCallParticipant; + //@class CallProblem @description Describes the exact type of a problem with a call diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 5e96404980640b174ba562d2c85cbd3e15ef46ad..a0c6f49d11e4f29d18a5549b59780a763cfd3f1b 100644 GIT binary patch delta 172 zcmZ2*iu=hKZr(?;^{p77Ky4%MX(0)Tds|kCxEJM@7C0y7~442&A8oVH &&participant) { + CHECK(participant != nullptr); + user_id = UserId(participant->user_id_); + source = participant->source_; + is_muted = participant->muted_; + can_self_unmute = participant->can_self_unmute_; + if (!participant->left_) { + joined_date = participant->date_; + if ((participant->flags_ & telegram_api::groupCallParticipant::ACTIVE_DATE_MASK) != 0) { + active_date = participant->active_date_; + } + } +} + +td_api::object_ptr GroupCallParticipant::get_group_call_participant_object(Td *td) const { + if (!is_valid()) { + return nullptr; + } + + return td_api::make_object( + td->contacts_manager_->get_user_id_object(user_id, "get_group_call_participant_object"), source, is_speaking, + is_muted, can_self_unmute, order); +} + +StringBuilder &operator<<(StringBuilder &string_builder, const GroupCallParticipant &group_call_participant) { + return string_builder << '[' << group_call_participant.user_id << " with source " << group_call_participant.source + << " and order " << group_call_participant.order << ']'; +} + +} // namespace td diff --git a/td/telegram/GroupCallParticipant.h b/td/telegram/GroupCallParticipant.h new file mode 100644 index 000000000..b79c8521a --- /dev/null +++ b/td/telegram/GroupCallParticipant.h @@ -0,0 +1,44 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/td_api.h" +#include "td/telegram/telegram_api.h" +#include "td/telegram/UserId.h" + +#include "td/utils/common.h" +#include "td/utils/StringBuilder.h" + +namespace td { + +class Td; + +struct GroupCallParticipant { + UserId user_id; + int32 source = 0; + bool is_muted = false; + bool can_self_unmute = false; + int32 joined_date = 0; + int32 active_date = 0; + + bool is_speaking = false; + int64 order = 0; + + bool is_valid() const { + return user_id.is_valid(); + } + + GroupCallParticipant() = default; + + GroupCallParticipant(tl_object_ptr &&participant); + + td_api::object_ptr get_group_call_participant_object(Td *td) const; +}; + +StringBuilder &operator<<(StringBuilder &string_builder, const GroupCallParticipant &group_call_participant); + +} // namespace td