mirror of https://github.com/kiwix/libkiwix.git
Deprecate methods on Book.
- `update(const Reader& reader)` is replaced by `update(const zim::Archive& archive)` - `getFavicon*()` is replaced by `getIllustration(48)->*`
This commit is contained in:
parent
7dfafe0196
commit
39732e2bcf
|
@ -24,6 +24,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
namespace pugi {
|
namespace pugi {
|
||||||
class xml_node;
|
class xml_node;
|
||||||
|
@ -68,7 +69,7 @@ class Book
|
||||||
~Book();
|
~Book();
|
||||||
|
|
||||||
bool update(const Book& other);
|
bool update(const Book& other);
|
||||||
void update(const Reader& reader);
|
DEPRECATED void update(const Reader& reader);
|
||||||
void update(const zim::Archive& archive);
|
void update(const zim::Archive& archive);
|
||||||
void updateFromXml(const pugi::xml_node& node, const std::string& baseDir);
|
void updateFromXml(const pugi::xml_node& node, const std::string& baseDir);
|
||||||
void updateFromOpds(const pugi::xml_node& node, const std::string& urlHost);
|
void updateFromOpds(const pugi::xml_node& node, const std::string& urlHost);
|
||||||
|
@ -95,9 +96,9 @@ class Book
|
||||||
const uint64_t& getArticleCount() const { return m_articleCount; }
|
const uint64_t& getArticleCount() const { return m_articleCount; }
|
||||||
const uint64_t& getMediaCount() const { return m_mediaCount; }
|
const uint64_t& getMediaCount() const { return m_mediaCount; }
|
||||||
const uint64_t& getSize() const { return m_size; }
|
const uint64_t& getSize() const { return m_size; }
|
||||||
const std::string& getFavicon() const;
|
DEPRECATED const std::string& getFavicon() const;
|
||||||
const std::string& getFaviconUrl() const;
|
DEPRECATED const std::string& getFaviconUrl() const;
|
||||||
const std::string& getFaviconMimeType() const;
|
DEPRECATED const std::string& getFaviconMimeType() const;
|
||||||
|
|
||||||
Illustrations getIllustrations() const;
|
Illustrations getIllustrations() const;
|
||||||
std::shared_ptr<const Illustration> getIllustration(unsigned int size) const;
|
std::shared_ptr<const Illustration> getIllustration(unsigned int size) const;
|
||||||
|
|
|
@ -60,10 +60,13 @@ void LibXMLDumper::handleBook(Book book, pugi::xml_node root_node) {
|
||||||
ADD_ATTR_NOT_EMPTY(entry_node, "name", book.getName());
|
ADD_ATTR_NOT_EMPTY(entry_node, "name", book.getName());
|
||||||
ADD_ATTR_NOT_EMPTY(entry_node, "flavour", book.getFlavour());
|
ADD_ATTR_NOT_EMPTY(entry_node, "flavour", book.getFlavour());
|
||||||
ADD_ATTR_NOT_EMPTY(entry_node, "tags", book.getTags());
|
ADD_ATTR_NOT_EMPTY(entry_node, "tags", book.getTags());
|
||||||
ADD_ATTR_NOT_EMPTY(entry_node, "faviconMimeType", book.getFaviconMimeType());
|
try {
|
||||||
ADD_ATTR_NOT_EMPTY(entry_node, "faviconUrl", book.getFaviconUrl());
|
auto defaultIllustration = book.getIllustration(48);
|
||||||
if (!book.getFavicon().empty())
|
ADD_ATTR_NOT_EMPTY(entry_node, "faviconMimeType", defaultIllustration->mimeType);
|
||||||
ADD_ATTRIBUTE(entry_node, "favicon", base64_encode(book.getFavicon()));
|
ADD_ATTR_NOT_EMPTY(entry_node, "faviconUrl", defaultIllustration->url);
|
||||||
|
if (!defaultIllustration->getData().empty())
|
||||||
|
ADD_ATTRIBUTE(entry_node, "favicon", base64_encode(defaultIllustration->getData()));
|
||||||
|
} catch(...) {}
|
||||||
} else {
|
} else {
|
||||||
ADD_ATTRIBUTE(entry_node, "origId", book.getOrigId());
|
ADD_ATTRIBUTE(entry_node, "origId", book.getOrigId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,10 @@ TEST(BookTest, updateFromXMLTest)
|
||||||
EXPECT_EQ(book.getArticleCount(), 123456U);
|
EXPECT_EQ(book.getArticleCount(), 123456U);
|
||||||
EXPECT_EQ(book.getMediaCount(), 234567U);
|
EXPECT_EQ(book.getMediaCount(), 234567U);
|
||||||
EXPECT_EQ(book.getSize(), 345678U*1024U);
|
EXPECT_EQ(book.getSize(), 345678U*1024U);
|
||||||
EXPECT_EQ(book.getFavicon(), "fake-book-favicon-data");
|
auto defaultIllustration = book.getIllustration(48);
|
||||||
EXPECT_EQ(book.getFaviconMimeType(), "text/plain");
|
EXPECT_EQ(defaultIllustration->getData(), "fake-book-favicon-data");
|
||||||
EXPECT_EQ(book.getFaviconUrl(), "http://who.org/zara.fav");
|
EXPECT_EQ(defaultIllustration->mimeType, "text/plain");
|
||||||
|
EXPECT_EQ(defaultIllustration->url, "http://who.org/zara.fav");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(BookTest, updateFromXMLCategoryHandlingTest)
|
TEST(BookTest, updateFromXMLCategoryHandlingTest)
|
||||||
|
@ -175,8 +176,10 @@ TEST(BookTest, updateTest)
|
||||||
EXPECT_EQ(newBook.getTags(), book.getTags());
|
EXPECT_EQ(newBook.getTags(), book.getTags());
|
||||||
EXPECT_EQ(newBook.getCategory(), book.getCategory());
|
EXPECT_EQ(newBook.getCategory(), book.getCategory());
|
||||||
EXPECT_EQ(newBook.getName(), book.getName());
|
EXPECT_EQ(newBook.getName(), book.getName());
|
||||||
EXPECT_EQ(newBook.getFavicon(), book.getFavicon());
|
auto defaultIllustration = book.getIllustration(48);
|
||||||
EXPECT_EQ(newBook.getFaviconMimeType(), book.getFaviconMimeType());
|
auto newDefaultIllustration = newBook.getIllustration(48);
|
||||||
|
EXPECT_EQ(newDefaultIllustration->getData(), defaultIllustration->getData());
|
||||||
|
EXPECT_EQ(newDefaultIllustration->mimeType, defaultIllustration->mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
Loading…
Reference in New Issue