2018-01-04 19:54: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
|
|
|
|
*/
|
|
|
|
#include "dialogs/dialogs_key.h"
|
|
|
|
|
2019-04-15 11:54:03 +00:00
|
|
|
#include "data/data_folder.h"
|
2022-09-20 18:12:30 +00:00
|
|
|
#include "data/data_forum_topic.h"
|
2023-12-27 01:09:20 +00:00
|
|
|
#include "data/data_saved_sublist.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2018-01-04 19:54:35 +00:00
|
|
|
|
|
|
|
namespace Dialogs {
|
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
Key::Key(History *history) : _value(history) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Key::Key(Data::Folder *folder) : _value(folder) {
|
|
|
|
}
|
|
|
|
|
2022-10-17 16:29:48 +00:00
|
|
|
Key::Key(Data::Thread *thread) : _value(thread) {
|
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
Key::Key(Data::ForumTopic *topic) : _value(topic) {
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
Key::Key(Data::SavedSublist *sublist) : _value(sublist) {
|
|
|
|
}
|
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
Key::Key(not_null<History*> history) : _value(history) {
|
|
|
|
}
|
|
|
|
|
2022-10-17 16:29:48 +00:00
|
|
|
Key::Key(not_null<Data::Thread*> thread) : _value(thread) {
|
|
|
|
}
|
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
Key::Key(not_null<Data::Folder*> folder) : _value(folder) {
|
|
|
|
}
|
|
|
|
|
2022-09-23 19:21:31 +00:00
|
|
|
Key::Key(not_null<Data::ForumTopic*> topic) : _value(topic) {
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
Key::Key(not_null<Data::SavedSublist*> sublist) : _value(sublist) {
|
|
|
|
}
|
|
|
|
|
2018-01-05 15:57:18 +00:00
|
|
|
not_null<Entry*> Key::entry() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
Expects(_value != nullptr);
|
|
|
|
|
|
|
|
return _value;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
History *Key::history() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
return _value ? _value->asHistory() : nullptr;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
Data::Folder *Key::folder() const {
|
2020-06-12 14:09:04 +00:00
|
|
|
return _value ? _value->asFolder() : nullptr;
|
2018-01-04 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
Data::ForumTopic *Key::topic() const {
|
2022-09-23 19:21:31 +00:00
|
|
|
return _value ? _value->asTopic() : nullptr;
|
2022-09-20 18:12:30 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 10:32:03 +00:00
|
|
|
Data::Thread *Key::thread() const {
|
|
|
|
return _value ? _value->asThread() : nullptr;
|
|
|
|
}
|
|
|
|
|
2023-12-27 01:09:20 +00:00
|
|
|
Data::SavedSublist *Key::sublist() const {
|
|
|
|
return _value ? _value->asSublist() : nullptr;
|
|
|
|
}
|
|
|
|
|
2022-10-13 17:34:04 +00:00
|
|
|
History *Key::owningHistory() const {
|
|
|
|
if (const auto thread = this->thread()) {
|
|
|
|
return thread->owningHistory();
|
2022-09-27 12:05:47 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
PeerData *Key::peer() const {
|
2022-10-13 17:34:04 +00:00
|
|
|
if (const auto history = owningHistory()) {
|
2020-06-12 14:09:04 +00:00
|
|
|
return history->peer;
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-04 19:54:35 +00:00
|
|
|
} // namespace Dialogs
|