Merge pull request #175 from kiwix/fix

Fix
This commit is contained in:
Matthieu Gautier 2018-11-02 17:32:22 +01:00 committed by GitHub
commit 802df71410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 6 deletions

View File

@ -1,3 +1,8 @@
kiwix-lib 3.0.1
===============
* Small fix about parsing the opdsStream.
kiwix-lib 3.0.0 kiwix-lib 3.0.0
=============== ===============

View File

@ -71,5 +71,13 @@ std::string to_string(T value)
oss << value; oss << value;
return oss.str(); return oss.str();
} }
template<typename T>
T extractFromString(const std::string& str) {
std::istringstream iss(str);
T ret;
iss >> ret;
return ret;
}
} //namespace kiwix } //namespace kiwix
#endif #endif

View File

@ -196,7 +196,10 @@ class Manager
std::string writableLibraryPath; std::string writableLibraryPath;
std::vector<std::string> bookIdList; bool m_hasSearchResult = false;
uint64_t m_totalBooks = 0;
uint64_t m_startIndex = 0;
uint64_t m_itemsPerPage = 0;
protected: protected:
kiwix::LibraryManipulator* manipulator; kiwix::LibraryManipulator* manipulator;

View File

@ -1,5 +1,5 @@
project('kiwix-lib', 'cpp', project('kiwix-lib', 'cpp',
version : '3.0.0', version : '3.0.1',
license : 'GPL', license : 'GPL',
default_options : ['c_std=c11', 'cpp_std=c++11', 'werror=true']) default_options : ['c_std=c11', 'cpp_std=c++11', 'werror=true'])

View File

@ -72,12 +72,12 @@ void Download::updateStatus(bool follow)
} catch (InvalidRPCNode& e) { } } catch (InvalidRPCNode& e) { }
} }
m_status = status; m_status = status;
m_totalLength = structNode.getMember("totalLength").getValue().getAsI(); m_totalLength = extractFromString<uint64_t>(structNode.getMember("totalLength").getValue().getAsS());
m_completedLength = structNode.getMember("completedLength").getValue().getAsI(); m_completedLength = extractFromString<uint64_t>(structNode.getMember("completedLength").getValue().getAsS());
m_downloadSpeed = structNode.getMember("downloadSpeed").getValue().getAsI(); m_downloadSpeed = extractFromString<uint64_t>(structNode.getMember("downloadSpeed").getValue().getAsS());
try { try {
auto verifiedLengthValue = structNode.getMember("verifiedLength").getValue(); auto verifiedLengthValue = structNode.getMember("verifiedLength").getValue();
m_verifiedLength = verifiedLengthValue.getAsI(); m_verifiedLength = extractFromString<uint64_t>(verifiedLengthValue.getAsS());
} catch (InvalidRPCNode& e) { m_verifiedLength = 0; } } catch (InvalidRPCNode& e) { m_verifiedLength = 0; }
auto filesMember = structNode.getMember("files"); auto filesMember = structNode.getMember("files");
auto fileStruct = filesMember.getValue().getArray().getValue(0).getStruct(); auto fileStruct = filesMember.getValue().getArray().getValue(0).getStruct();

View File

@ -95,6 +95,15 @@ bool Manager::parseOpdsDom(const pugi::xml_document& doc, const std::string& url
{ {
pugi::xml_node libraryNode = doc.child("feed"); pugi::xml_node libraryNode = doc.child("feed");
try {
m_totalBooks = strtoull(libraryNode.child("totalResults").child_value(), 0, 0);
m_startIndex = strtoull(libraryNode.child("startIndex").child_value(), 0, 0);
m_itemsPerPage = strtoull(libraryNode.child("itemsPerPage").child_value(), 0, 0);
m_hasSearchResult = true;
} catch(...) {
m_hasSearchResult = false;
}
for (pugi::xml_node entryNode = libraryNode.child("entry"); entryNode; for (pugi::xml_node entryNode = libraryNode.child("entry"); entryNode;
entryNode = entryNode.next_sibling("entry")) { entryNode = entryNode.next_sibling("entry")) {
kiwix::Book book; kiwix::Book book;