2017-09-04 11:40:02 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#include "storage/storage_facade.h"
|
|
|
|
|
|
|
|
#include "storage/storage_shared_media.h"
|
2017-08-29 19:52:52 +00:00
|
|
|
#include "storage/storage_user_photos.h"
|
2017-09-04 11:40:02 +00:00
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
|
|
|
|
class Facade::Impl {
|
|
|
|
public:
|
|
|
|
void add(SharedMediaAddNew &&query);
|
|
|
|
void add(SharedMediaAddExisting &&query);
|
|
|
|
void add(SharedMediaAddSlice &&query);
|
|
|
|
void remove(SharedMediaRemoveOne &&query);
|
|
|
|
void remove(SharedMediaRemoveAll &&query);
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaResult> query(SharedMediaQuery &&query) const;
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaSliceUpdate> sharedMediaSliceUpdated() const;
|
|
|
|
rpl::producer<SharedMediaRemoveOne> sharedMediaOneRemoved() const;
|
|
|
|
rpl::producer<SharedMediaRemoveAll> sharedMediaAllRemoved() const;
|
2017-08-18 19:14:31 +00:00
|
|
|
|
2017-08-29 19:52:52 +00:00
|
|
|
void add(UserPhotosAddNew &&query);
|
|
|
|
void add(UserPhotosAddSlice &&query);
|
|
|
|
void remove(UserPhotosRemoveOne &&query);
|
|
|
|
void remove(UserPhotosRemoveAfter &&query);
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosResult> query(UserPhotosQuery &&query) const;
|
2017-08-29 19:52:52 +00:00
|
|
|
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosSliceUpdate> userPhotosSliceUpdated() const;
|
2017-08-29 19:52:52 +00:00
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
private:
|
|
|
|
SharedMedia _sharedMedia;
|
2017-08-29 19:52:52 +00:00
|
|
|
UserPhotos _userPhotos;
|
2017-09-04 11:40:02 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void Facade::Impl::add(SharedMediaAddNew &&query) {
|
|
|
|
_sharedMedia.add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::add(SharedMediaAddExisting &&query) {
|
|
|
|
_sharedMedia.add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::add(SharedMediaAddSlice &&query) {
|
|
|
|
_sharedMedia.add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::remove(SharedMediaRemoveOne &&query) {
|
|
|
|
_sharedMedia.remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::remove(SharedMediaRemoveAll &&query) {
|
|
|
|
_sharedMedia.remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaResult> Facade::Impl::query(SharedMediaQuery &&query) const {
|
|
|
|
return _sharedMedia.query(std::move(query));
|
2017-09-04 11:40:02 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaSliceUpdate> Facade::Impl::sharedMediaSliceUpdated() const {
|
|
|
|
return _sharedMedia.sliceUpdated();
|
2017-08-18 19:14:31 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaRemoveOne> Facade::Impl::sharedMediaOneRemoved() const {
|
|
|
|
return _sharedMedia.oneRemoved();
|
2017-08-18 19:14:31 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaRemoveAll> Facade::Impl::sharedMediaAllRemoved() const {
|
|
|
|
return _sharedMedia.allRemoved();
|
2017-08-18 19:14:31 +00:00
|
|
|
}
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2017-08-29 19:52:52 +00:00
|
|
|
void Facade::Impl::add(UserPhotosAddNew &&query) {
|
|
|
|
return _userPhotos.add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::add(UserPhotosAddSlice &&query) {
|
|
|
|
return _userPhotos.add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::remove(UserPhotosRemoveOne &&query) {
|
|
|
|
return _userPhotos.remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::Impl::remove(UserPhotosRemoveAfter &&query) {
|
|
|
|
return _userPhotos.remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosResult> Facade::Impl::query(UserPhotosQuery &&query) const {
|
|
|
|
return _userPhotos.query(std::move(query));
|
2017-08-29 19:52:52 +00:00
|
|
|
}
|
|
|
|
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosSliceUpdate> Facade::Impl::userPhotosSliceUpdated() const {
|
|
|
|
return _userPhotos.sliceUpdated();
|
2017-08-29 19:52:52 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Facade::Facade() : _impl(std::make_unique<Impl>()) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::add(SharedMediaAddNew &&query) {
|
|
|
|
_impl->add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::add(SharedMediaAddExisting &&query) {
|
|
|
|
_impl->add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::add(SharedMediaAddSlice &&query) {
|
|
|
|
_impl->add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::remove(SharedMediaRemoveOne &&query) {
|
|
|
|
_impl->remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::remove(SharedMediaRemoveAll &&query) {
|
|
|
|
_impl->remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaResult> Facade::query(SharedMediaQuery &&query) const {
|
|
|
|
return _impl->query(std::move(query));
|
2017-09-04 11:40:02 +00:00
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaSliceUpdate> Facade::sharedMediaSliceUpdated() const {
|
2017-08-18 19:14:31 +00:00
|
|
|
return _impl->sharedMediaSliceUpdated();
|
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaRemoveOne> Facade::sharedMediaOneRemoved() const {
|
2017-08-18 19:14:31 +00:00
|
|
|
return _impl->sharedMediaOneRemoved();
|
|
|
|
}
|
|
|
|
|
2017-09-04 19:14:44 +00:00
|
|
|
rpl::producer<SharedMediaRemoveAll> Facade::sharedMediaAllRemoved() const {
|
2017-08-18 19:14:31 +00:00
|
|
|
return _impl->sharedMediaAllRemoved();
|
|
|
|
}
|
|
|
|
|
2017-08-29 19:52:52 +00:00
|
|
|
void Facade::add(UserPhotosAddNew &&query) {
|
|
|
|
return _impl->add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::add(UserPhotosAddSlice &&query) {
|
|
|
|
return _impl->add(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::remove(UserPhotosRemoveOne &&query) {
|
|
|
|
return _impl->remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Facade::remove(UserPhotosRemoveAfter &&query) {
|
|
|
|
return _impl->remove(std::move(query));
|
|
|
|
}
|
|
|
|
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosResult> Facade::query(UserPhotosQuery &&query) const {
|
|
|
|
return _impl->query(std::move(query));
|
2017-08-29 19:52:52 +00:00
|
|
|
}
|
|
|
|
|
2017-09-06 14:50:11 +00:00
|
|
|
rpl::producer<UserPhotosSliceUpdate> Facade::userPhotosSliceUpdated() const {
|
2017-08-29 19:52:52 +00:00
|
|
|
return _impl->userPhotosSliceUpdated();
|
|
|
|
}
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Facade::~Facade() = default;
|
|
|
|
|
|
|
|
} // namespace Storage
|