diff options
Diffstat (limited to 'include/dchat/Cache.hpp')
-rw-r--r-- | include/dchat/Cache.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/dchat/Cache.hpp b/include/dchat/Cache.hpp index 8d3f28e..71bd785 100644 --- a/include/dchat/Cache.hpp +++ b/include/dchat/Cache.hpp @@ -1,7 +1,6 @@ #pragma once #include "types.hpp" -#include "WebPagePreview.hpp" #include "StringView.hpp" #include "utils.hpp" #include <boost/filesystem/path.hpp> @@ -63,6 +62,7 @@ namespace dchat // Returned gif should be allocated with @new using CreateGifFunc = std::function<Gif*(StringView fileContent)>; using CreateStaticImageFunc = std::function<StaticImage*(const boost::filesystem::path &filepath)>; + using CreateWebPagePreviewFunc = std::function<WebPagePreview*(const std::string &title, const std::string &description)>; class Cache { @@ -70,7 +70,8 @@ namespace dchat public: // @createGifFunc can't be null // @createStaticImageFunc can't be null - Cache(CreateGifFunc createGifFunc, CreateStaticImageFunc createStaticImageFunc); + // @createWebPagePreviewFunc can't be null + Cache(CreateGifFunc createGifFunc, CreateStaticImageFunc createStaticImageFunc, CreateWebPagePreviewFunc createWebPagePreviewFunc); ~Cache(); // Get cached content or download it. @@ -78,6 +79,8 @@ namespace dchat // Returns ContentByUrlResult describing texture status. const ContentByUrlResult getContentByUrl(const std::string &url, int downloadLimitBytes = 12582912); private: + ContentByUrlResult loadImageFromFile(const boost::filesystem::path &filepath, bool loadFromCache); + private: struct ImageDownloadInfo { TinyProcessLib::Process *process; @@ -93,5 +96,6 @@ namespace dchat std::unordered_map<std::string, ContentByUrlResult> contentUrlCache; CreateGifFunc createGifFunc; CreateStaticImageFunc createStaticImageFunc; + CreateWebPagePreviewFunc createWebPagePreviewFunc; }; } |