2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-24 03:07:20 +00:00

114 lines
2.5 KiB
C
Raw Normal View History

/*
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
2024-03-23 12:42:22 +04:00
#include "iv/iv_delegate.h"
namespace Main {
class Session;
class SessionShow;
} // namespace Main
2024-03-23 12:42:22 +04:00
namespace Window {
class SessionController;
} // namespace Window
namespace Iv {
class Data;
class Shown;
2024-07-26 19:25:47 +02:00
class TonSite;
class Instance final {
public:
2024-03-23 12:42:22 +04:00
explicit Instance(not_null<Delegate*> delegate);
~Instance();
2024-03-23 12:42:22 +04:00
void show(
not_null<Window::SessionController*> controller,
not_null<Data*> data,
QString hash);
void show(
std::shared_ptr<Main::SessionShow> show,
not_null<Data*> data,
2023-12-05 11:54:46 +04:00
QString hash);
2024-04-04 18:20:33 +04:00
void show(
not_null<Main::Session*> session,
not_null<Data*> data,
QString hash);
void openWithIvPreferred(
not_null<Window::SessionController*> controller,
QString uri,
QVariant context = {});
void openWithIvPreferred(
not_null<Main::Session*> session,
QString uri,
QVariant context = {});
2024-07-26 19:25:47 +02:00
void showTonSite(
const QString &uri,
QVariant context = {});
[[nodiscard]] bool hasActiveWindow(
not_null<Main::Session*> session) const;
2023-12-01 18:47:24 +04:00
bool closeActive();
bool minimizeActive();
void closeAll();
[[nodiscard]] rpl::lifetime &lifetime();
private:
struct FullResult {
crl::time lastRequestedAt = 0;
WebPageData *page = nullptr;
int32 hash = 0;
};
2023-12-04 23:06:44 +04:00
void processOpenChannel(const QString &context);
void processJoinChannel(const QString &context);
2024-03-11 16:59:11 +04:00
void requestFull(not_null<Main::Session*> session, const QString &id);
2023-12-04 23:06:44 +04:00
void trackSession(not_null<Main::Session*> session);
WebPageData *processReceivedPage(
not_null<Main::Session*> session,
const QString &url,
const MTPmessages_WebPage &result);
2024-03-23 12:42:22 +04:00
const not_null<Delegate*> _delegate;
std::unique_ptr<Shown> _shown;
2023-12-04 23:06:44 +04:00
Main::Session *_shownSession = nullptr;
base::flat_set<not_null<Main::Session*>> _tracking;
2024-03-11 16:59:11 +04:00
base::flat_map<
not_null<Main::Session*>,
base::flat_set<not_null<ChannelData*>>> _joining;
base::flat_map<
not_null<Main::Session*>,
base::flat_map<QString, FullResult>> _fullRequested;
base::flat_map<
not_null<Main::Session*>,
base::flat_map<QString, WebPageData*>> _ivCache;
Main::Session *_ivRequestSession = nullptr;
QString _ivRequestUri;
mtpRequestId _ivRequestId = 0;
2024-07-26 19:25:47 +02:00
std::unique_ptr<TonSite> _tonSite;
rpl::lifetime _lifetime;
};
[[nodiscard]] bool PreferForUri(const QString &uri);
} // namespace Iv