-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated functions #831
Conversation
Removing the |
(There's a crash I just found, fixing that..) Edit: Done ✔️ |
d0d2e38
to
590a649
Compare
As say the small comment in https://github.com/kiwix/libkiwix/blob/master/src/server/internalServer.cpp#L408-L440, searching in the title list using "normalized" case should be done in libzim. I'm partisan to only use |
590a649
to
fc3f093
Compare
For a zim like https://sourceforge.net/projects/telugu-dictionary-zim-file/files/ (from 2016), this will lead to no suggestions, won't that be a major regression for old files? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
fc3f093
to
a3b19e2
Compare
From a user perspective it looks good. I don't see DEPRECATED warnings during the compilation too. @mgautierfr Please have a look to the code. |
src/readinglistbar.cpp
Outdated
std::string mimeType; | ||
reader->getFavicon(content, mimeType); | ||
} | ||
auto illustration = archive->getIllustrationItem(48); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to handle the case the archive as no 48x48 illustration (pretty rare but anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you handle it?
Currently, I have just left the catch block empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends of the use case.
We probably want to display nothing (in the library or in the tab icon) if the zim has no illustration. It seems that lefting the catch block empty is enough.
(In the library we display a "broken" image. It would be better to not display an image at all. But it is not the purpose of this PR)
src/urlschemehandler.cpp
Outdated
zim::Entry getFinalEntry(zim::Entry entry) | ||
{ | ||
int loopCounter = 42; | ||
auto final_entry = entry; | ||
while (final_entry.isRedirect() && loopCounter--) { | ||
final_entry = final_entry.getRedirectEntry(); | ||
} | ||
// Prevent infinite loops. | ||
if (final_entry.isRedirect()) { | ||
throw zim::EntryNotFound("bad entry"); | ||
} | ||
return final_entry; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zim::Entry::getItem(true)
follows the redirection (until we have a item) and then return the associated item. We could use it directly instead this intermediate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is getFinalEntry
still needed as you now use getItem(true)
?
src/webview.cpp
Outdated
return; | ||
} | ||
std::string favicon, _mimetype; | ||
reader->getFavicon(favicon, _mimetype); | ||
auto item = archive->getIllustrationItem(48); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must handle case where archive has not 48x48 illustration
68e38af
to
afd23e1
Compare
src/library.cpp
Outdated
std::shared_ptr<zim::Searcher> searcher; | ||
auto archive = getArchive(zimId); | ||
if (!searcher) { | ||
searcher = std::make_shared<zim::Searcher>(*archive); | ||
} else { | ||
searcher->addArchive(*archive); | ||
} | ||
return searcher; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure (if searcher, add archive else create reader) is usefull only when we loop on a set of archives.
But here we have only one archive
std::shared_ptr<zim::Searcher> searcher; | |
auto archive = getArchive(zimId); | |
if (!searcher) { | |
searcher = std::make_shared<zim::Searcher>(*archive); | |
} else { | |
searcher->addArchive(*archive); | |
} | |
return searcher; | |
auto archive = getArchive(zimId); | |
return std::make_shared<zim::Searcher>(*archive); |
src/urlschemehandler.cpp
Outdated
BlobBuffer* buffer = new BlobBuffer(entry.getItem().getData(0)); | ||
auto mimeType = QByteArray::fromStdString(entry.getItem(true).getMimetype()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, it would be better to have either getItem()
or getItem(true)
. But not both.
src/urlschemehandler.cpp
Outdated
zim::Entry getFinalEntry(zim::Entry entry) | ||
{ | ||
int loopCounter = 42; | ||
auto final_entry = entry; | ||
while (final_entry.isRedirect() && loopCounter--) { | ||
final_entry = final_entry.getRedirectEntry(); | ||
} | ||
// Prevent infinite loops. | ||
if (final_entry.isRedirect()) { | ||
throw zim::EntryNotFound("bad entry"); | ||
} | ||
return final_entry; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is getFinalEntry
still needed as you now use getItem(true)
?
src/readinglistbar.cpp
Outdated
std::string mimeType; | ||
reader->getFavicon(content, mimeType); | ||
} | ||
auto illustration = archive->getIllustrationItem(48); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends of the use case.
We probably want to display nothing (in the library or in the tab icon) if the zim has no illustration. It seems that lefting the catch block empty is enough.
(In the library we display a "broken" image. It would be better to not display an image at all. But it is not the purpose of this PR)
src/contentmanager.cpp
Outdated
if (key == "favicon") { | ||
auto s = b->getFavicon(); | ||
auto s = b->getIllustration(48)->getData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not try around this getIllustration
src/suggestionlistworker.cpp
Outdated
int suggestionsCount = 15; | ||
auto prefix = m_text.toStdString(); | ||
auto suggestionSearcher = zim::SuggestionSearcher(*archive); | ||
if (archive->hasTitleIndex()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why limiting suggestion to when archive has a title index ?
If archive has no title index, suggestion may indeed not be the best (as we search in the title listing) but it is better than nothing.
src/suggestionlistworker.cpp
Outdated
auto suggestionSearch = suggestionSearcher.suggest(prefix); | ||
const auto suggestions = suggestionSearch.getResults(0, suggestionsCount); | ||
for (auto current : suggestions) { | ||
kiwix::SuggestionItem suggestion(current.getTitle(), lcAll(current.getTitle()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to use a kiwix::SuggestionItem
?
Could we feed suggestionList, url and urlList directly from current
?
@juuz0 Any update? |
This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions. |
afd23e1
to
6cf07d4
Compare
@juuz0 I've added few fixup commit which should fix my remarks. |
@mgautierfr LGTM and works too. Only thing remaining is my comment above |
This replaces the deprecated Reader and Favicon functions from libkiwix kiwix::Reader functions are converted to use zim::Archive Favicon functions are converted to use Illustration Fix #805
Commented out unused variable names in function parameters Casted unused variable (void) in for-loop Fixed a signed-unsigned comparison warning
6cf07d4
to
b49ea7c
Compare
Last comment fixed. Rebase-fixup done. |
This replaces the deprecated Reader and Favicon functions from libkiwix
kiwix::Reader functions are converted to use zim::Archive
Favicon functions are converted to use Illustration
Fixes #805