Support separate webview storages.
This commit is contained in:
parent
471831bcd6
commit
c6d034174b
|
@ -1491,7 +1491,7 @@ void AttachWebView::show(
|
||||||
_catchingCancelInShowCall = true;
|
_catchingCancelInShowCall = true;
|
||||||
_panel = Ui::BotWebView::Show({
|
_panel = Ui::BotWebView::Show({
|
||||||
.url = url,
|
.url = url,
|
||||||
.userDataPath = _session->domain().local().webviewDataPath(),
|
.storageId = _session->local().resolveStorageIdBots(),
|
||||||
.title = std::move(title),
|
.title = std::move(title),
|
||||||
.bottom = rpl::single('@' + _bot->username()),
|
.bottom = rpl::single('@' + _bot->username()),
|
||||||
.delegate = static_cast<Ui::BotWebView::Delegate*>(this),
|
.delegate = static_cast<Ui::BotWebView::Delegate*>(this),
|
||||||
|
|
|
@ -224,6 +224,7 @@ void Step::createSession(
|
||||||
account->createSession(user, std::move(settings));
|
account->createSession(user, std::move(settings));
|
||||||
|
|
||||||
// "this" is already deleted here by creating the main widget.
|
// "this" is already deleted here by creating the main widget.
|
||||||
|
account->local().enforceModernStorageIdBots();
|
||||||
account->local().writeMtpData();
|
account->local().writeMtpData();
|
||||||
auto &session = account->session();
|
auto &session = account->session();
|
||||||
session.data().chatsFilters().setPreloaded(filters);
|
session.data().chatsFilters().setPreloaded(filters);
|
||||||
|
|
|
@ -292,12 +292,12 @@ void Controller::initControls() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::show(
|
void Controller::show(
|
||||||
const QString &dataPath,
|
const Webview::StorageId &storageId,
|
||||||
Prepared page,
|
Prepared page,
|
||||||
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues) {
|
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues) {
|
||||||
page.script = fillInChannelValuesScript(std::move(inChannelValues));
|
page.script = fillInChannelValuesScript(std::move(inChannelValues));
|
||||||
InvokeQueued(_container, [=, page = std::move(page)]() mutable {
|
InvokeQueued(_container, [=, page = std::move(page)]() mutable {
|
||||||
showInWindow(dataPath, std::move(page));
|
showInWindow(storageId, std::move(page));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ void Controller::createWindow() {
|
||||||
window->show();
|
window->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::createWebview(const QString &dataPath) {
|
void Controller::createWebview(const Webview::StorageId &storageId) {
|
||||||
Expects(!_webview);
|
Expects(!_webview);
|
||||||
|
|
||||||
const auto window = _window.get();
|
const auto window = _window.get();
|
||||||
|
@ -397,7 +397,7 @@ void Controller::createWebview(const QString &dataPath) {
|
||||||
_container,
|
_container,
|
||||||
Webview::WindowConfig{
|
Webview::WindowConfig{
|
||||||
.opaqueBg = st::windowBg->c,
|
.opaqueBg = st::windowBg->c,
|
||||||
.userDataPath = dataPath,
|
.storageId = storageId,
|
||||||
});
|
});
|
||||||
const auto raw = _webview.get();
|
const auto raw = _webview.get();
|
||||||
|
|
||||||
|
@ -558,7 +558,9 @@ void Controller::createWebview(const QString &dataPath) {
|
||||||
raw->init(R"()");
|
raw->init(R"()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::showInWindow(const QString &dataPath, Prepared page) {
|
void Controller::showInWindow(
|
||||||
|
const Webview::StorageId &storageId,
|
||||||
|
Prepared page) {
|
||||||
Expects(_container != nullptr);
|
Expects(_container != nullptr);
|
||||||
|
|
||||||
const auto url = page.url;
|
const auto url = page.url;
|
||||||
|
@ -571,7 +573,7 @@ void Controller::showInWindow(const QString &dataPath, Prepared page) {
|
||||||
const auto index = i->second;
|
const auto index = i->second;
|
||||||
_index = index;
|
_index = index;
|
||||||
if (!_webview) {
|
if (!_webview) {
|
||||||
createWebview(dataPath);
|
createWebview(storageId);
|
||||||
if (_webview && _webview->widget()) {
|
if (_webview && _webview->widget()) {
|
||||||
auto id = u"iv/page%1.html"_q.arg(index);
|
auto id = u"iv/page%1.html"_q.arg(index);
|
||||||
if (!_hash.isEmpty()) {
|
if (!_hash.isEmpty()) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "iv/iv_delegate.h"
|
#include "iv/iv_delegate.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/text/text.h"
|
#include "ui/text/text.h"
|
||||||
|
#include "webview/webview_common.h"
|
||||||
|
|
||||||
class Painter;
|
class Painter;
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void show(
|
void show(
|
||||||
const QString &dataPath,
|
const Webview::StorageId &storageId,
|
||||||
Prepared page,
|
Prepared page,
|
||||||
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues);
|
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues);
|
||||||
void update(Prepared page);
|
void update(Prepared page);
|
||||||
|
@ -90,11 +91,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void createWebview(const QString &dataPath);
|
void createWebview(const Webview::StorageId &storageId);
|
||||||
[[nodiscard]] QByteArray navigateScript(int index, const QString &hash);
|
[[nodiscard]] QByteArray navigateScript(int index, const QString &hash);
|
||||||
[[nodiscard]] QByteArray reloadScript(int index);
|
[[nodiscard]] QByteArray reloadScript(int index);
|
||||||
|
|
||||||
void showInWindow(const QString &dataPath, Prepared page);
|
void showInWindow(const Webview::StorageId &storageId, Prepared page);
|
||||||
[[nodiscard]] QByteArray fillInChannelValuesScript(
|
[[nodiscard]] QByteArray fillInChannelValuesScript(
|
||||||
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues);
|
base::flat_map<QByteArray, rpl::producer<bool>> inChannelValues);
|
||||||
[[nodiscard]] QByteArray toggleInChannelScript(
|
[[nodiscard]] QByteArray toggleInChannelScript(
|
||||||
|
|
|
@ -31,13 +31,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "lottie/lottie_common.h" // Lottie::ReadContent.
|
#include "lottie/lottie_common.h" // Lottie::ReadContent.
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_domain.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/session/session_show.h"
|
#include "main/session/session_show.h"
|
||||||
#include "media/streaming/media_streaming_loader.h"
|
#include "media/streaming/media_streaming_loader.h"
|
||||||
#include "media/view/media_view_open_common.h"
|
#include "media/view/media_view_open_common.h"
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
#include "storage/storage_domain.h"
|
#include "storage/storage_account.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/layers/layer_widget.h"
|
#include "ui/layers/layer_widget.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -348,9 +347,8 @@ void Shown::showWindowed(Prepared result) {
|
||||||
createController();
|
createController();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto domain = &_session->domain();
|
|
||||||
_controller->show(
|
_controller->show(
|
||||||
domain->local().webviewDataPath(),
|
_session->local().resolveStorageIdOther(),
|
||||||
std::move(result),
|
std::move(result),
|
||||||
base::duplicate(_inChannelValues));
|
base::duplicate(_inChannelValues));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "payments/ui/payments_panel.h"
|
#include "payments/ui/payments_panel.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_domain.h"
|
#include "storage/storage_account.h"
|
||||||
#include "storage/storage_domain.h"
|
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "data/data_user.h" // UserData::isBot.
|
#include "data/data_user.h" // UserData::isBot.
|
||||||
|
@ -25,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_cloud_password.h"
|
#include "api/api_cloud_password.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "webview/webview_interface.h"
|
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
@ -877,8 +875,8 @@ void CheckoutProcess::performInitialSilentValidation() {
|
||||||
_form->validateInformation(saved);
|
_form->validateInformation(saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CheckoutProcess::panelWebviewDataPath() {
|
Webview::StorageId CheckoutProcess::panelWebviewStorageId() {
|
||||||
return _session->domain().local().webviewDataPath();
|
return _session->local().resolveStorageIdOther();
|
||||||
}
|
}
|
||||||
|
|
||||||
Webview::ThemeParams CheckoutProcess::panelWebviewThemeParams() {
|
Webview::ThemeParams CheckoutProcess::panelWebviewThemeParams() {
|
||||||
|
|
|
@ -7,8 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "payments/ui/payments_panel_delegate.h"
|
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
|
#include "payments/ui/payments_panel_delegate.h"
|
||||||
|
#include "webview/webview_common.h"
|
||||||
|
|
||||||
class HistoryItem;
|
class HistoryItem;
|
||||||
class PasscodeBox;
|
class PasscodeBox;
|
||||||
|
@ -153,7 +154,7 @@ private:
|
||||||
void panelShowBox(object_ptr<Ui::BoxContent> box) override;
|
void panelShowBox(object_ptr<Ui::BoxContent> box) override;
|
||||||
QVariant panelClickHandlerContext() override;
|
QVariant panelClickHandlerContext() override;
|
||||||
|
|
||||||
QString panelWebviewDataPath() override;
|
Webview::StorageId panelWebviewStorageId() override;
|
||||||
Webview::ThemeParams panelWebviewThemeParams() override;
|
Webview::ThemeParams panelWebviewThemeParams() override;
|
||||||
|
|
||||||
std::optional<QDate> panelOverrideExpireDateThreshold() override;
|
std::optional<QDate> panelOverrideExpireDateThreshold() override;
|
||||||
|
|
|
@ -547,7 +547,7 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||||
container,
|
container,
|
||||||
Webview::WindowConfig{
|
Webview::WindowConfig{
|
||||||
.opaqueBg = params.opaqueBg,
|
.opaqueBg = params.opaqueBg,
|
||||||
.userDataPath = _delegate->panelWebviewDataPath(),
|
.storageId = _delegate->panelWebviewStorageId(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto raw = &_webview->window;
|
const auto raw = &_webview->window;
|
||||||
|
|
|
@ -18,6 +18,7 @@ class BoxContent;
|
||||||
|
|
||||||
namespace Webview {
|
namespace Webview {
|
||||||
struct ThemeParams;
|
struct ThemeParams;
|
||||||
|
struct StorageId;
|
||||||
} // namespace Webview
|
} // namespace Webview
|
||||||
|
|
||||||
namespace Payments::Ui {
|
namespace Payments::Ui {
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
virtual void panelShowBox(object_ptr<BoxContent> box) = 0;
|
virtual void panelShowBox(object_ptr<BoxContent> box) = 0;
|
||||||
virtual QVariant panelClickHandlerContext() = 0;
|
virtual QVariant panelClickHandlerContext() = 0;
|
||||||
|
|
||||||
virtual QString panelWebviewDataPath() = 0;
|
virtual Webview::StorageId panelWebviewStorageId() = 0;
|
||||||
virtual Webview::ThemeParams panelWebviewThemeParams() = 0;
|
virtual Webview::ThemeParams panelWebviewThemeParams() = 0;
|
||||||
|
|
||||||
virtual std::optional<QDate> panelOverrideExpireDateThreshold() = 0;
|
virtual std::optional<QDate> panelOverrideExpireDateThreshold() = 0;
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/serialize_peer.h"
|
#include "storage/serialize_peer.h"
|
||||||
#include "storage/serialize_document.h"
|
#include "storage/serialize_document.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_domain.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "mtproto/mtproto_dc_options.h"
|
#include "mtproto/mtproto_dc_options.h"
|
||||||
|
@ -35,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "export/export_settings.h"
|
#include "export/export_settings.h"
|
||||||
|
#include "webview/webview_interface.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
@ -91,6 +93,7 @@ enum { // Local Storage Keys
|
||||||
lskMasksKeys = 0x16, // no data
|
lskMasksKeys = 0x16, // no data
|
||||||
lskCustomEmojiKeys = 0x17, // no data
|
lskCustomEmojiKeys = 0x17, // no data
|
||||||
lskSearchSuggestions = 0x18, // no data
|
lskSearchSuggestions = 0x18, // no data
|
||||||
|
lskWebviewTokens = 0x19, // data: QByteArray bots, QByteArray other
|
||||||
};
|
};
|
||||||
|
|
||||||
auto EmptyMessageDraftSources()
|
auto EmptyMessageDraftSources()
|
||||||
|
@ -303,6 +306,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
||||||
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
||||||
quint64 searchSuggestionsKey = 0;
|
quint64 searchSuggestionsKey = 0;
|
||||||
|
QByteArray webviewStorageTokenBots, webviewStorageTokenOther;
|
||||||
while (!map.stream.atEnd()) {
|
while (!map.stream.atEnd()) {
|
||||||
quint32 keyType;
|
quint32 keyType;
|
||||||
map.stream >> keyType;
|
map.stream >> keyType;
|
||||||
|
@ -411,6 +415,11 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
case lskSearchSuggestions: {
|
case lskSearchSuggestions: {
|
||||||
map.stream >> searchSuggestionsKey;
|
map.stream >> searchSuggestionsKey;
|
||||||
} break;
|
} break;
|
||||||
|
case lskWebviewTokens: {
|
||||||
|
map.stream
|
||||||
|
>> webviewStorageTokenBots
|
||||||
|
>> webviewStorageTokenOther;
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
||||||
return ReadMapResult::Failed;
|
return ReadMapResult::Failed;
|
||||||
|
@ -448,6 +457,8 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
_exportSettingsKey = exportSettingsKey;
|
_exportSettingsKey = exportSettingsKey;
|
||||||
_searchSuggestionsKey = searchSuggestionsKey;
|
_searchSuggestionsKey = searchSuggestionsKey;
|
||||||
_oldMapVersion = mapData.version;
|
_oldMapVersion = mapData.version;
|
||||||
|
_webviewStorageIdBots.token = webviewStorageTokenBots;
|
||||||
|
_webviewStorageIdOther.token = webviewStorageTokenOther;
|
||||||
|
|
||||||
if (_oldMapVersion < AppVersion) {
|
if (_oldMapVersion < AppVersion) {
|
||||||
writeMapDelayed();
|
writeMapDelayed();
|
||||||
|
@ -553,6 +564,12 @@ void Account::writeMap() {
|
||||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
}
|
}
|
||||||
if (_searchSuggestionsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_searchSuggestionsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
|
if (!_webviewStorageIdBots.token.isEmpty()
|
||||||
|
|| !_webviewStorageIdOther.token.isEmpty()) {
|
||||||
|
mapSize += sizeof(quint32)
|
||||||
|
+ Serialize::bytearraySize(_webviewStorageIdBots.token)
|
||||||
|
+ Serialize::bytearraySize(_webviewStorageIdOther.token);
|
||||||
|
}
|
||||||
|
|
||||||
EncryptedDescriptor mapData(mapSize);
|
EncryptedDescriptor mapData(mapSize);
|
||||||
if (!self.isEmpty()) {
|
if (!self.isEmpty()) {
|
||||||
|
@ -616,6 +633,13 @@ void Account::writeMap() {
|
||||||
mapData.stream << quint32(lskSearchSuggestions);
|
mapData.stream << quint32(lskSearchSuggestions);
|
||||||
mapData.stream << quint64(_searchSuggestionsKey);
|
mapData.stream << quint64(_searchSuggestionsKey);
|
||||||
}
|
}
|
||||||
|
if (!_webviewStorageIdBots.token.isEmpty()
|
||||||
|
|| !_webviewStorageIdOther.token.isEmpty()) {
|
||||||
|
mapData.stream << quint32(lskWebviewTokens);
|
||||||
|
mapData.stream
|
||||||
|
<< _webviewStorageIdBots.token
|
||||||
|
<< _webviewStorageIdOther.token;
|
||||||
|
}
|
||||||
map.writeEncrypted(mapData, _localKey);
|
map.writeEncrypted(mapData, _localKey);
|
||||||
|
|
||||||
_mapChanged = false;
|
_mapChanged = false;
|
||||||
|
@ -655,11 +679,27 @@ void Account::reset() {
|
||||||
_cacheTotalTimeLimit = Database::Settings().totalTimeLimit;
|
_cacheTotalTimeLimit = Database::Settings().totalTimeLimit;
|
||||||
_cacheBigFileTotalSizeLimit = Database::Settings().totalSizeLimit;
|
_cacheBigFileTotalSizeLimit = Database::Settings().totalSizeLimit;
|
||||||
_cacheBigFileTotalTimeLimit = Database::Settings().totalTimeLimit;
|
_cacheBigFileTotalTimeLimit = Database::Settings().totalTimeLimit;
|
||||||
|
|
||||||
|
const auto wvbots = _webviewStorageIdBots.path;
|
||||||
|
const auto wvother = _webviewStorageIdOther.path;
|
||||||
|
const auto wvclear = [](Webview::StorageId &storageId) {
|
||||||
|
Webview::ClearStorageDataByToken(
|
||||||
|
base::take(storageId).token.toStdString());
|
||||||
|
};
|
||||||
|
wvclear(_webviewStorageIdBots);
|
||||||
|
wvclear(_webviewStorageIdOther);
|
||||||
|
|
||||||
_mapChanged = true;
|
_mapChanged = true;
|
||||||
writeMap();
|
writeMap();
|
||||||
writeMtpData();
|
writeMtpData();
|
||||||
|
|
||||||
crl::async([base = _basePath, temp = _tempPath, names = std::move(names)] {
|
crl::async([
|
||||||
|
base = _basePath,
|
||||||
|
temp = _tempPath,
|
||||||
|
names = std::move(names),
|
||||||
|
wvbots,
|
||||||
|
wvother
|
||||||
|
] {
|
||||||
for (const auto &name : names) {
|
for (const auto &name : names) {
|
||||||
if (!name.endsWith(u"map0"_q)
|
if (!name.endsWith(u"map0"_q)
|
||||||
&& !name.endsWith(u"map1"_q)
|
&& !name.endsWith(u"map1"_q)
|
||||||
|
@ -669,6 +709,12 @@ void Account::reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QDir(LegacyTempDirectory()).removeRecursively();
|
QDir(LegacyTempDirectory()).removeRecursively();
|
||||||
|
if (!wvbots.isEmpty()) {
|
||||||
|
QDir(wvbots).removeRecursively();
|
||||||
|
}
|
||||||
|
if (!wvother.isEmpty()) {
|
||||||
|
QDir(wvother).removeRecursively();
|
||||||
|
}
|
||||||
QDir(temp).removeRecursively();
|
QDir(temp).removeRecursively();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -3080,6 +3126,54 @@ bool Account::isBotTrustedOpenWebView(PeerId botId) {
|
||||||
&& ((i->second & BotTrustFlag::OpenWebView) != 0);
|
&& ((i->second & BotTrustFlag::OpenWebView) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::enforceModernStorageIdBots() {
|
||||||
|
if (_webviewStorageIdBots.token.isEmpty()) {
|
||||||
|
_webviewStorageIdBots.token = QByteArray::fromStdString(
|
||||||
|
Webview::GenerateStorageToken());
|
||||||
|
writeMapDelayed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Webview::StorageId Account::resolveStorageIdBots() {
|
||||||
|
if (!_webviewStorageIdBots) {
|
||||||
|
auto &token = _webviewStorageIdBots.token;
|
||||||
|
const auto legacy = Webview::LegacyStorageIdToken();
|
||||||
|
if (token.isEmpty()) {
|
||||||
|
auto legacyTaken = false;
|
||||||
|
const auto &list = _owner->domain().accounts();
|
||||||
|
for (const auto &[index, account] : list) {
|
||||||
|
if (account.get() != _owner.get()) {
|
||||||
|
const auto &id = account->local()._webviewStorageIdBots;
|
||||||
|
if (id.token == legacy) {
|
||||||
|
legacyTaken = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
token = legacyTaken
|
||||||
|
? QByteArray::fromStdString(Webview::GenerateStorageToken())
|
||||||
|
: legacy;
|
||||||
|
writeMapDelayed();
|
||||||
|
}
|
||||||
|
_webviewStorageIdBots.path = (token == legacy)
|
||||||
|
? (BaseGlobalPath() + u"webview"_q)
|
||||||
|
: (_databasePath + u"wvbots"_q);
|
||||||
|
}
|
||||||
|
return _webviewStorageIdBots;
|
||||||
|
}
|
||||||
|
|
||||||
|
Webview::StorageId Account::resolveStorageIdOther() {
|
||||||
|
if (!_webviewStorageIdOther) {
|
||||||
|
if (_webviewStorageIdOther.token.isEmpty()) {
|
||||||
|
_webviewStorageIdOther.token = QByteArray::fromStdString(
|
||||||
|
Webview::GenerateStorageToken());
|
||||||
|
writeMapDelayed();
|
||||||
|
}
|
||||||
|
_webviewStorageIdOther.path = _databasePath + u"wvother"_q;
|
||||||
|
}
|
||||||
|
return _webviewStorageIdOther;
|
||||||
|
}
|
||||||
|
|
||||||
bool Account::encrypt(
|
bool Account::encrypt(
|
||||||
const void *src,
|
const void *src,
|
||||||
void *dst,
|
void *dst,
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/cache/storage_cache_database.h"
|
#include "storage/cache/storage_cache_database.h"
|
||||||
#include "data/stickers/data_stickers_set.h"
|
#include "data/stickers/data_stickers_set.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
|
#include "webview/webview_common.h"
|
||||||
|
|
||||||
class History;
|
class History;
|
||||||
|
|
||||||
|
@ -169,6 +170,10 @@ public:
|
||||||
void markBotTrustedOpenWebView(PeerId botId);
|
void markBotTrustedOpenWebView(PeerId botId);
|
||||||
[[nodiscard]] bool isBotTrustedOpenWebView(PeerId botId);
|
[[nodiscard]] bool isBotTrustedOpenWebView(PeerId botId);
|
||||||
|
|
||||||
|
void enforceModernStorageIdBots();
|
||||||
|
[[nodiscard]] Webview::StorageId resolveStorageIdBots();
|
||||||
|
[[nodiscard]] Webview::StorageId resolveStorageIdOther();
|
||||||
|
|
||||||
[[nodiscard]] bool encrypt(
|
[[nodiscard]] bool encrypt(
|
||||||
const void *src,
|
const void *src,
|
||||||
void *dst,
|
void *dst,
|
||||||
|
@ -309,6 +314,9 @@ private:
|
||||||
bool _recentHashtagsAndBotsWereRead = false;
|
bool _recentHashtagsAndBotsWereRead = false;
|
||||||
bool _searchSuggestionsRead = false;
|
bool _searchSuggestionsRead = false;
|
||||||
|
|
||||||
|
Webview::StorageId _webviewStorageIdBots;
|
||||||
|
Webview::StorageId _webviewStorageIdOther;
|
||||||
|
|
||||||
int _oldMapVersion = 0;
|
int _oldMapVersion = 0;
|
||||||
|
|
||||||
base::Timer _writeMapTimer;
|
base::Timer _writeMapTimer;
|
||||||
|
|
|
@ -268,10 +268,6 @@ void Domain::clearOldVersion() {
|
||||||
_oldVersion = 0;
|
_oldVersion = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Domain::webviewDataPath() const {
|
|
||||||
return BaseGlobalPath() + "webview";
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<> Domain::localPasscodeChanged() const {
|
rpl::producer<> Domain::localPasscodeChanged() const {
|
||||||
return _passcodeKeyChanged.events();
|
return _passcodeKeyChanged.events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,6 @@ public:
|
||||||
[[nodiscard]] int oldVersion() const;
|
[[nodiscard]] int oldVersion() const;
|
||||||
void clearOldVersion();
|
void clearOldVersion();
|
||||||
|
|
||||||
[[nodiscard]] QString webviewDataPath() const;
|
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> localPasscodeChanged() const;
|
[[nodiscard]] rpl::producer<> localPasscodeChanged() const;
|
||||||
[[nodiscard]] bool hasLocalPasscode() const;
|
[[nodiscard]] bool hasLocalPasscode() const;
|
||||||
|
|
||||||
|
|
|
@ -313,12 +313,12 @@ Panel::Progress::Progress(QWidget *parent, Fn<QRect()> rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
Panel::Panel(
|
Panel::Panel(
|
||||||
const QString &userDataPath,
|
const Webview::StorageId &storageId,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
MenuButtons menuButtons,
|
MenuButtons menuButtons,
|
||||||
bool allowClipboardRead)
|
bool allowClipboardRead)
|
||||||
: _userDataPath(userDataPath)
|
: _storageId(storageId)
|
||||||
, _delegate(delegate)
|
, _delegate(delegate)
|
||||||
, _menuButtons(menuButtons)
|
, _menuButtons(menuButtons)
|
||||||
, _widget(std::make_unique<SeparatePanel>())
|
, _widget(std::make_unique<SeparatePanel>())
|
||||||
|
@ -597,7 +597,7 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||||
container,
|
container,
|
||||||
Webview::WindowConfig{
|
Webview::WindowConfig{
|
||||||
.opaqueBg = params.opaqueBg,
|
.opaqueBg = params.opaqueBg,
|
||||||
.userDataPath = _userDataPath,
|
.storageId = _storageId,
|
||||||
});
|
});
|
||||||
const auto raw = &_webview->window;
|
const auto raw = &_webview->window;
|
||||||
|
|
||||||
|
@ -1339,7 +1339,7 @@ rpl::lifetime &Panel::lifetime() {
|
||||||
|
|
||||||
std::unique_ptr<Panel> Show(Args &&args) {
|
std::unique_ptr<Panel> Show(Args &&args) {
|
||||||
auto result = std::make_unique<Panel>(
|
auto result = std::make_unique<Panel>(
|
||||||
args.userDataPath,
|
args.storageId,
|
||||||
std::move(args.title),
|
std::move(args.title),
|
||||||
args.delegate,
|
args.delegate,
|
||||||
args.menuButtons,
|
args.menuButtons,
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "base/flags.h"
|
#include "base/flags.h"
|
||||||
|
#include "webview/webview_common.h"
|
||||||
|
|
||||||
class QJsonObject;
|
class QJsonObject;
|
||||||
class QJsonValue;
|
class QJsonValue;
|
||||||
|
@ -23,7 +24,6 @@ class SeparatePanel;
|
||||||
|
|
||||||
namespace Webview {
|
namespace Webview {
|
||||||
struct Available;
|
struct Available;
|
||||||
struct ThemeParams;
|
|
||||||
} // namespace Webview
|
} // namespace Webview
|
||||||
|
|
||||||
namespace Ui::BotWebView {
|
namespace Ui::BotWebView {
|
||||||
|
@ -72,7 +72,7 @@ public:
|
||||||
class Panel final : public base::has_weak_ptr {
|
class Panel final : public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
Panel(
|
Panel(
|
||||||
const QString &userDataPath,
|
const Webview::StorageId &storageId,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
MenuButtons menuButtons,
|
MenuButtons menuButtons,
|
||||||
|
@ -144,7 +144,7 @@ private:
|
||||||
[[nodiscard]] QRect progressRect() const;
|
[[nodiscard]] QRect progressRect() const;
|
||||||
void setupProgressGeometry();
|
void setupProgressGeometry();
|
||||||
|
|
||||||
QString _userDataPath;
|
Webview::StorageId _storageId;
|
||||||
const not_null<Delegate*> _delegate;
|
const not_null<Delegate*> _delegate;
|
||||||
bool _closeNeedConfirmation = false;
|
bool _closeNeedConfirmation = false;
|
||||||
bool _hasSettingsButton = false;
|
bool _hasSettingsButton = false;
|
||||||
|
@ -172,7 +172,7 @@ private:
|
||||||
|
|
||||||
struct Args {
|
struct Args {
|
||||||
QString url;
|
QString url;
|
||||||
QString userDataPath;
|
Webview::StorageId storageId;
|
||||||
rpl::producer<QString> title;
|
rpl::producer<QString> title;
|
||||||
rpl::producer<QString> bottom;
|
rpl::producer<QString> bottom;
|
||||||
not_null<Delegate*> delegate;
|
not_null<Delegate*> delegate;
|
||||||
|
|
|
@ -35,9 +35,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/style/style_palette_colorizer.h"
|
#include "ui/style/style_palette_colorizer.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "webview/webview_interface.h"
|
|
||||||
#include "boxes/background_box.h"
|
#include "boxes/background_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "webview/webview_common.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7c346c6b042266b5adb116a2114df1d46b37c03f
|
Subproject commit 9f9bcaaec922644406faadda4d37014c9dec2dd9
|
Loading…
Reference in New Issue