|
|
@ -126,63 +126,60 @@ string ContentManager::GetCurrentBookId() {
|
|
|
|
return none;
|
|
|
|
return none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*bool ContentManager::GetBookById(const char* &id,
|
|
|
|
bool ContentManager::GetBookById(string &id,
|
|
|
|
char* &path,
|
|
|
|
string &path,
|
|
|
|
char* &title,
|
|
|
|
string &title,
|
|
|
|
char* &indexPath,
|
|
|
|
string &indexPath,
|
|
|
|
char* &indexType,
|
|
|
|
string &indexType,
|
|
|
|
char* &description,
|
|
|
|
string &description,
|
|
|
|
char* &articleCount,
|
|
|
|
string &articleCount,
|
|
|
|
char* &mediaCount,
|
|
|
|
string &mediaCount,
|
|
|
|
char* &size,
|
|
|
|
string &size,
|
|
|
|
char* &creator,
|
|
|
|
string &creator,
|
|
|
|
char* &date,
|
|
|
|
string &date,
|
|
|
|
char* &language,
|
|
|
|
string &language,
|
|
|
|
char* &favicon,
|
|
|
|
string &favicon,
|
|
|
|
char* &url, bool *retVal) {
|
|
|
|
string &url) {
|
|
|
|
*retVal = PR_FALSE;
|
|
|
|
|
|
|
|
const char *cid;
|
|
|
|
try {
|
|
|
|
NS_CStringGetData(id, &cid);
|
|
|
|
kiwix::Book book;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (this->manager.getBookById(id.c_str(), book)) {
|
|
|
|
kiwix::Book book;
|
|
|
|
path = book.pathAbsolute.data();
|
|
|
|
|
|
|
|
title = book.title.data();
|
|
|
|
if (this->manager.getBookById(cid, book)) {
|
|
|
|
indexPath = book.indexPathAbsolute.data();
|
|
|
|
path = nsDependentCString(book.pathAbsolute.data(), book.pathAbsolute.size());
|
|
|
|
articleCount = book.articleCount.data();
|
|
|
|
title = nsDependentCString(book.title.data(), book.title.size());
|
|
|
|
mediaCount = book.mediaCount.data();
|
|
|
|
indexPath = nsDependentCString(book.indexPathAbsolute.data(), book.indexPathAbsolute.size());
|
|
|
|
size = book.size.data();
|
|
|
|
articleCount = nsDependentCString(book.articleCount.data(), book.articleCount.size());
|
|
|
|
creator = book.creator.data();
|
|
|
|
mediaCount = nsDependentCString(book.mediaCount.data(), book.mediaCount.size());
|
|
|
|
date = book.date.data();
|
|
|
|
size = nsDependentCString(book.size.data(), book.size.size());
|
|
|
|
language = book.language.data();
|
|
|
|
creator = nsDependentCString(book.creator.data(), book.creator.size());
|
|
|
|
url = book.url.data();
|
|
|
|
date = nsDependentCString(book.date.data(), book.date.size());
|
|
|
|
|
|
|
|
language = nsDependentCString(book.language.data(), book.language.size());
|
|
|
|
string faviconUrl = "";
|
|
|
|
url = nsDependentCString(book.url.data(), book.url.size());
|
|
|
|
if (!book.faviconMimeType.empty()) {
|
|
|
|
|
|
|
|
faviconUrl = "url(data:" + book.faviconMimeType + ";base64," + book.favicon + ")";
|
|
|
|
string faviconUrl = "";
|
|
|
|
}
|
|
|
|
if (!book.faviconMimeType.empty()) {
|
|
|
|
favicon = faviconUrl.data();
|
|
|
|
faviconUrl = "url(data:" + book.faviconMimeType + ";base64," + book.favicon + ")";
|
|
|
|
|
|
|
|
}
|
|
|
|
string indexTypeString = "";
|
|
|
|
favicon = nsDependentCString(faviconUrl.data(), faviconUrl.size());
|
|
|
|
if (book.indexType == kiwix::XAPIAN) {
|
|
|
|
|
|
|
|
indexTypeString = "xapian";
|
|
|
|
string indexTypeString = "";
|
|
|
|
} else if (book.indexType == kiwix::CLUCENE) {
|
|
|
|
if (book.indexType == kiwix::XAPIAN) {
|
|
|
|
indexTypeString = "clucene";
|
|
|
|
indexTypeString = "xapian";
|
|
|
|
}
|
|
|
|
} else if (book.indexType == kiwix::CLUCENE) {
|
|
|
|
indexType = indexTypeString.data();
|
|
|
|
indexTypeString = "clucene";
|
|
|
|
|
|
|
|
}
|
|
|
|
description = book.description.data();
|
|
|
|
indexType = nsDependentCString(indexTypeString.data(), indexTypeString.size());
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
description = nsDependentCString(book.description.data(), book.description.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (exception &e) {
|
|
|
|
*retVal = PR_TRUE;
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (exception &e) {
|
|
|
|
return false;
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ContentManager::UpdateBookLastOpenDateById(string &id) {
|
|
|
|
bool ContentManager::UpdateBookLastOpenDateById(string &id) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -208,49 +205,39 @@ unsigned int ContentManager::GetBookCount(const bool localBooks, const bool remo
|
|
|
|
return count;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*bool ContentManager::ListBooks(const char* &mode, const char* &sortBy, PRUint32 maxSize,
|
|
|
|
bool ContentManager::ListBooks(string &mode, string &sortBy, unsigned int maxSize,
|
|
|
|
const char* &language, const char* &publisher, const char* &search, bool *retVal) {
|
|
|
|
string &language, string &publisher, string &search) {
|
|
|
|
*retVal = PR_FALSE;
|
|
|
|
try {
|
|
|
|
const char *cmode; NS_CStringGetData(mode, &cmode);
|
|
|
|
|
|
|
|
const char *csortBy; NS_CStringGetData(sortBy, &csortBy);
|
|
|
|
|
|
|
|
const char *clanguage; NS_CStringGetData(language, &clanguage);
|
|
|
|
|
|
|
|
const char *cpublisher; NS_CStringGetData(publisher, &cpublisher);
|
|
|
|
|
|
|
|
const char *csearch; NS_CStringGetData(search, &csearch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set the mode enum
|
|
|
|
|
|
|
|
kiwix::supportedListMode listMode;
|
|
|
|
|
|
|
|
if (std::string(cmode) == "lastOpen") {
|
|
|
|
|
|
|
|
listMode = kiwix::LASTOPEN;
|
|
|
|
|
|
|
|
} else if ( std::string(cmode) == "remote") {
|
|
|
|
|
|
|
|
listMode = kiwix::REMOTE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
listMode = kiwix::LOCAL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set the sortBy enum
|
|
|
|
// Set the mode enum
|
|
|
|
kiwix::supportedListSortBy listSortBy;
|
|
|
|
kiwix::supportedListMode listMode;
|
|
|
|
if (std::string(csortBy) == "publisher") {
|
|
|
|
if (mode == "lastOpen") {
|
|
|
|
listSortBy = kiwix::PUBLISHER;
|
|
|
|
listMode = kiwix::LASTOPEN;
|
|
|
|
} else if ( std::string(csortBy) == "date") {
|
|
|
|
} else if ( mode == "remote") {
|
|
|
|
listSortBy = kiwix::DATE;
|
|
|
|
listMode = kiwix::REMOTE;
|
|
|
|
} else if ( std::string(csortBy) == "size") {
|
|
|
|
} else {
|
|
|
|
listSortBy = kiwix::SIZE;
|
|
|
|
listMode = kiwix::LOCAL;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
listSortBy = kiwix::TITLE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this->manager.listBooks(listMode, listSortBy, maxSize, clanguage, cpublisher, csearch)) {
|
|
|
|
// Set the sortBy enum
|
|
|
|
*retVal = PR_TRUE;
|
|
|
|
kiwix::supportedListSortBy listSortBy;
|
|
|
|
}
|
|
|
|
if (sortBy == "publisher") {
|
|
|
|
} catch (exception &e) {
|
|
|
|
listSortBy = kiwix::PUBLISHER;
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
} else if ( sortBy == "date") {
|
|
|
|
}
|
|
|
|
listSortBy = kiwix::DATE;
|
|
|
|
|
|
|
|
} else if ( sortBy == "size") {
|
|
|
|
|
|
|
|
listSortBy = kiwix::SIZE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
listSortBy = kiwix::TITLE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
return this->manager.listBooks(listMode, listSortBy, maxSize, language.c_str(), publisher.c_str(), search.c_str());
|
|
|
|
}*/
|
|
|
|
} catch (exception &e) {
|
|
|
|
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char* ContentManager::GetListNextBookId() {
|
|
|
|
const char* ContentManager::GetListNextBookId() {
|
|
|
|
|
|
|
|
|
|
|
|