tdesktop/Telegram/SourceFiles/dialogs/dialogs_key.cpp

77 lines
1.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
*/
#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"
#include "history/history.h"
namespace Dialogs {
2020-06-12 14:09:04 +00:00
Key::Key(History *history) : _value(history) {
}
Key::Key(Data::Folder *folder) : _value(folder) {
}
Key::Key(Data::Thread *thread) : _value(thread) {
}
Key::Key(Data::ForumTopic *topic) : _value(topic) {
2022-09-20 18:12:30 +00:00
}
2020-06-12 14:09:04 +00:00
Key::Key(not_null<History*> history) : _value(history) {
}
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) {
}
Key::Key(not_null<Data::ForumTopic*> topic) : _value(topic) {
2022-09-20 18:12:30 +00:00
}
not_null<Entry*> Key::entry() const {
2020-06-12 14:09:04 +00:00
Expects(_value != nullptr);
return _value;
}
History *Key::history() const {
2020-06-12 14:09:04 +00:00
return _value ? _value->asHistory() : nullptr;
}
Data::Folder *Key::folder() const {
2020-06-12 14:09:04 +00:00
return _value ? _value->asFolder() : nullptr;
}
Data::ForumTopic *Key::topic() const {
return _value ? _value->asTopic() : nullptr;
2022-09-20 18:12:30 +00:00
}
Data::Thread *Key::thread() const {
return _value ? _value->asThread() : nullptr;
}
History *Key::owningHistory() const {
if (const auto thread = this->thread()) {
return thread->owningHistory();
2022-09-27 12:05:47 +00:00
}
return nullptr;
}
PeerData *Key::peer() const {
if (const auto history = owningHistory()) {
2020-06-12 14:09:04 +00:00
return history->peer;
}
return nullptr;
}
} // namespace Dialogs