Merge pull request #178 from jpirnay/feat-koreader-metadata
feat: Send optional document metadata with KOSync progress uploads (upstream pr 1820 by nperez0111)
This commit is contained in:
@@ -405,6 +405,7 @@ void KOReaderSyncActivity::performUpload() {
|
||||
progress.document = documentHash;
|
||||
progress.progress = localProgress.xpath;
|
||||
progress.percentage = localProgress.percentage;
|
||||
progress.metadata = localDocumentMetadata;
|
||||
|
||||
const auto result = KOReaderSyncClient::updateProgress(progress);
|
||||
KOReaderSyncClient::endPersistentSession();
|
||||
@@ -717,6 +718,18 @@ bool KOReaderSyncActivity::computeLocalProgressAndChapter() {
|
||||
localChapterLabel = (localTocIndex >= 0)
|
||||
? epub->getTocItem(localTocIndex).title
|
||||
: (std::string(tr(STR_SECTION_PREFIX)) + std::to_string(currentSpineIndex + 1));
|
||||
|
||||
if (KOREADER_STORE.getSendMetadata()) {
|
||||
const size_t slash = epubPath.rfind('/');
|
||||
KOReaderMetadata meta;
|
||||
meta.filename = (slash != std::string::npos) ? epubPath.substr(slash + 1) : epubPath;
|
||||
meta.title = epub->getTitle();
|
||||
meta.authors = epub->getAuthor();
|
||||
localDocumentMetadata = std::move(meta);
|
||||
} else {
|
||||
localDocumentMetadata.reset();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ class KOReaderSyncActivity final : public Activity {
|
||||
KOReaderPosition localProgress;
|
||||
std::string remoteChapterLabel;
|
||||
std::string localChapterLabel;
|
||||
std::optional<KOReaderMetadata> localDocumentMetadata;
|
||||
|
||||
// Selection in result screen (0=Apply, 1=Upload)
|
||||
int selectedOption = 0;
|
||||
|
||||
@@ -17,7 +17,7 @@ KOReaderSettingsActivity::KOReaderSettingsActivity(GfxRenderer& renderer, Mapped
|
||||
}
|
||||
|
||||
void KOReaderSettingsActivity::buildMenuItems() {
|
||||
menuItems.reserve(7);
|
||||
menuItems.reserve(8);
|
||||
// Username, Password, Server URL: ACTION items with custom value display
|
||||
menuItems.push_back(SettingInfo::Action(StrId::STR_SYNC_SERVER_URL, SettingAction::None)
|
||||
.withSubcategory(StrId::STR_MENU_KOSYNC_SERVER));
|
||||
@@ -35,6 +35,17 @@ void KOReaderSettingsActivity::buildMenuItems() {
|
||||
.withSubcategory(StrId::STR_MENU_KOSYNC_BEHAVIOR));
|
||||
menuItems.push_back(SettingInfo::Toggle(StrId::STR_KO_SYNC_ON_BOOK_CLOSE, &CrossPointSettings::koSyncOnBookClose,
|
||||
"koSyncOnBookClose"));
|
||||
{
|
||||
SettingInfo s;
|
||||
s.nameId = StrId::STR_SEND_METADATA;
|
||||
s.type = SettingType::TOGGLE;
|
||||
s.valueGetter = [](const void*) -> uint8_t { return KOREADER_STORE.getSendMetadata() ? 1u : 0u; };
|
||||
s.valueSetter = [](void*, uint8_t v) {
|
||||
KOREADER_STORE.setSendMetadata(v != 0);
|
||||
KOREADER_STORE.saveToFile();
|
||||
};
|
||||
menuItems.push_back(std::move(s));
|
||||
}
|
||||
|
||||
// Authenticate and Register: ACTION items
|
||||
menuItems.push_back(
|
||||
|
||||
Reference in New Issue
Block a user