/* 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 #include "base/timer.h" #include "support/support_templates.h" #include "mtproto/sender.h" class History; namespace Main { class Session; } // namespace Main namespace Window { class SessionController; } // namespace Window namespace Support { struct UserInfo { QString author; TimeId date = 0; TextWithEntities text; }; inline bool operator==(const UserInfo &a, const UserInfo &b) { return (a.author == b.author) && (a.date == b.date) && (a.text == b.text); } inline bool operator!=(const UserInfo &a, const UserInfo &b) { return !(a == b); } class Helper final { public: explicit Helper(not_null session); static std::unique_ptr Create(not_null session); void registerWindow(not_null controller); void cloudDraftChanged(not_null history); void chatOccupiedUpdated(not_null history); bool isOccupiedByMe(History *history) const; bool isOccupiedBySomeone(History *history) const; void refreshInfo(not_null user); rpl::producer infoValue(not_null user) const; rpl::producer infoLabelValue(not_null user) const; rpl::producer infoTextValue( not_null user) const; UserInfo infoCurrent(not_null user) const; void editInfo(not_null user); Templates &templates(); private: struct SavingInfo { TextWithEntities data; mtpRequestId requestId = 0; }; void checkOccupiedChats(); void updateOccupiedHistory( not_null controller, History *history); void setSupportName(const QString &name); void occupyIfNotYet(); void occupyInDraft(); void reoccupy(); void applyInfo( not_null user, const MTPhelp_UserInfo &result); void showEditInfoBox(not_null user); void saveInfo( not_null user, TextWithEntities text, Fn done); not_null _session; MTP::Sender _api; Templates _templates; QString _supportName; QString _supportNameNormalized; History *_occupiedHistory = nullptr; base::Timer _reoccupyTimer; base::Timer _checkOccupiedTimer; base::flat_map, TimeId> _occupiedChats; base::flat_map, UserInfo> _userInformation; base::flat_set> _userInfoEditPending; base::flat_map, SavingInfo> _userInfoSaving; rpl::lifetime _lifetime; }; QString ChatOccupiedString(not_null history); QString InterpretSendPath(const QString &path); } // namespace Support