tdesktop/Telegram/SourceFiles/data/data_group_call.h

92 lines
2.4 KiB
C
Raw Normal View History

2020-11-20 19:25:35 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
class UserData;
class ChannelData;
namespace Data {
class GroupCall final {
public:
GroupCall(not_null<ChannelData*> channel, uint64 id, uint64 accessHash);
2020-11-24 11:56:46 +00:00
~GroupCall();
2020-11-20 19:25:35 +00:00
[[nodiscard]] uint64 id() const;
2020-11-24 11:56:46 +00:00
[[nodiscard]] not_null<ChannelData*> channel() const;
2020-11-20 19:25:35 +00:00
[[nodiscard]] MTPInputGroupCall input() const;
struct Participant {
not_null<UserData*> user;
TimeId date = 0;
TimeId lastActive = 0;
2020-11-28 07:21:11 +00:00
TimeId lastSpoke = 0;
2020-11-24 11:56:46 +00:00
uint32 source = 0;
2020-11-20 19:25:35 +00:00
bool muted = false;
bool canSelfUnmute = false;
};
struct ParticipantUpdate {
Participant participant;
bool removed = false;
};
2020-11-20 19:25:35 +00:00
[[nodiscard]] auto participants() const
-> const std::vector<Participant> &;
void requestParticipants();
[[nodiscard]] bool participantsLoaded() const;
[[nodiscard]] UserData *userBySource(uint32 source) const;
2020-11-20 19:25:35 +00:00
[[nodiscard]] rpl::producer<> participantsSliceAdded();
[[nodiscard]] rpl::producer<ParticipantUpdate> participantUpdated() const;
2020-11-24 11:56:46 +00:00
void applyUpdate(const MTPGroupCall &update);
void applyUpdate(const MTPDupdateGroupCallParticipants &update);
void applyUpdateChecked(
const MTPDupdateGroupCallParticipants &update);
2020-11-24 11:56:46 +00:00
2020-11-20 19:25:35 +00:00
[[nodiscard]] int fullCount() const;
[[nodiscard]] rpl::producer<int> fullCountValue() const;
2020-11-20 19:25:35 +00:00
2020-11-24 11:56:46 +00:00
void reload();
2020-11-28 16:18:51 +00:00
void setJoinMutedLocally(bool muted);
[[nodiscard]] bool joinMuted() const;
[[nodiscard]] bool canChangeJoinMuted() const;
2020-11-20 19:25:35 +00:00
private:
2020-11-24 11:56:46 +00:00
void applyCall(const MTPGroupCall &call, bool force);
void applyParticipantsSlice(
const QVector<MTPGroupCallParticipant> &list,
bool sendIndividualUpdates = false);
void applyParticipantsMutes(
const MTPDupdateGroupCallParticipants &update);
2020-11-24 11:56:46 +00:00
2020-11-20 19:25:35 +00:00
const not_null<ChannelData*> _channel;
const uint64 _id = 0;
const uint64 _accessHash = 0;
int _version = 0;
mtpRequestId _participantsRequestId = 0;
2020-11-24 11:56:46 +00:00
mtpRequestId _reloadRequestId = 0;
2020-11-20 19:25:35 +00:00
std::vector<Participant> _participants;
base::flat_map<uint32, not_null<UserData*>> _userBySource;
2020-11-26 11:04:00 +00:00
QString _nextOffset;
rpl::variable<int> _fullCount = 0;
rpl::event_stream<ParticipantUpdate> _participantUpdates;
rpl::event_stream<> _participantsSliceAdded;
2020-11-28 16:18:51 +00:00
bool _joinMuted = false;
bool _canChangeJoinMuted = true;
2020-11-20 19:25:35 +00:00
bool _allReceived = false;
};
} // namespace Data