2020-02-05 00:03:54 +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
|
|
|
|
|
|
|
|
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
|
|
|
|
2020-02-05 10:59:07 +00:00
|
|
|
#include "storage/storage_cloud_blob.h"
|
2020-02-21 18:55:11 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2020-02-05 10:59:07 +00:00
|
|
|
|
2020-02-07 22:42:01 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2020-02-05 00:03:54 +00:00
|
|
|
namespace Spellchecker {
|
|
|
|
|
2020-02-05 13:06:38 +00:00
|
|
|
struct Dict : public Storage::CloudBlob::Blob {
|
2020-02-05 00:03:54 +00:00
|
|
|
};
|
|
|
|
|
2022-05-10 14:22:28 +00:00
|
|
|
int64 GetDownloadSize(int id);
|
2020-02-06 15:27:35 +00:00
|
|
|
MTP::DedicatedLoader::Location GetDownloadLocation(int id);
|
|
|
|
|
2020-02-05 00:03:54 +00:00
|
|
|
[[nodiscard]] QString DictionariesPath();
|
|
|
|
[[nodiscard]] QString DictPathByLangId(int langId);
|
|
|
|
bool UnpackDictionary(const QString &path, int langId);
|
|
|
|
[[nodiscard]] bool DictionaryExists(int langId);
|
2020-02-08 13:57:43 +00:00
|
|
|
bool RemoveDictionary(int langId);
|
|
|
|
[[nodiscard]] bool IsEn(int langId);
|
2020-02-05 00:03:54 +00:00
|
|
|
|
|
|
|
bool WriteDefaultDictionary();
|
2020-02-06 15:27:35 +00:00
|
|
|
std::vector<Dict> Dictionaries();
|
2020-02-05 00:03:54 +00:00
|
|
|
|
2020-02-07 22:42:01 +00:00
|
|
|
void Start(not_null<Main::Session*> session);
|
2020-02-11 09:11:09 +00:00
|
|
|
[[nodiscard]] rpl::producer<QString> ButtonManageDictsState(
|
|
|
|
not_null<Main::Session*> session);
|
2020-02-07 22:42:01 +00:00
|
|
|
|
2020-02-21 18:55:11 +00:00
|
|
|
std::vector<int> DefaultLanguages();
|
|
|
|
|
|
|
|
class DictLoader : public Storage::CloudBlob::BlobLoader {
|
|
|
|
public:
|
|
|
|
DictLoader(
|
|
|
|
QObject *parent,
|
2020-06-10 10:49:10 +00:00
|
|
|
not_null<Main::Session*> session,
|
2020-02-21 18:55:11 +00:00
|
|
|
int id,
|
|
|
|
MTP::DedicatedLoader::Location location,
|
|
|
|
const QString &folder,
|
2022-05-10 14:22:28 +00:00
|
|
|
int64 size,
|
2020-02-21 18:55:11 +00:00
|
|
|
Fn<void()> destroyCallback);
|
|
|
|
|
|
|
|
void destroy() override;
|
|
|
|
|
|
|
|
rpl::lifetime &lifetime() {
|
|
|
|
return _lifetime;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void unpack(const QString &path) override;
|
|
|
|
void fail() override;
|
|
|
|
|
2020-02-26 09:38:24 +00:00
|
|
|
// Be sure to always call it in the main thread.
|
2020-02-21 18:55:11 +00:00
|
|
|
Fn<void()> _destroyCallback;
|
|
|
|
|
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
std::shared_ptr<base::unique_qptr<DictLoader>> GlobalLoader();
|
|
|
|
rpl::producer<int> GlobalLoaderChanged();
|
|
|
|
|
2020-02-05 00:03:54 +00:00
|
|
|
} // namespace Spellchecker
|
|
|
|
|
|
|
|
#endif // !TDESKTOP_DISABLE_SPELLCHECK
|