mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
User-controllable catalog host & port
So far the details of the host serving the OPDS catalog were hardcoded. In order to debug issues related to large downloads it helps if one can use one's own server. Hence this enhancement.
This commit is contained in:
parent
9924570670
commit
c10026a3a2
@ -681,13 +681,13 @@ void ContentManager::updateLibrary() {
|
||||
} catch (std::runtime_error&) {}
|
||||
}
|
||||
|
||||
#define CATALOG_URL "library.kiwix.org"
|
||||
void ContentManager::updateRemoteLibrary(const QString& content) {
|
||||
QtConcurrent::run([=]() {
|
||||
QMutexLocker locker(&remoteLibraryLocker);
|
||||
mp_remoteLibrary = kiwix::Library::create();
|
||||
kiwix::Manager manager(mp_remoteLibrary);
|
||||
manager.readOpds(content.toStdString(), CATALOG_URL);
|
||||
const auto catalogUrl = m_remoteLibraryManager.getCatalogHost();
|
||||
manager.readOpds(content.toStdString(), catalogUrl.toStdString());
|
||||
emit(this->booksChanged());
|
||||
emit(this->pendingRequest(false));
|
||||
});
|
||||
|
@ -5,8 +5,22 @@ OpdsRequestManager::OpdsRequestManager()
|
||||
{
|
||||
}
|
||||
|
||||
#define CATALOG_HOST "library.kiwix.org"
|
||||
#define CATALOG_PORT 443
|
||||
QString OpdsRequestManager::getCatalogHost()
|
||||
{
|
||||
const char* const envVarVal = getenv("KIWIX_CATALOG_HOST");
|
||||
return envVarVal
|
||||
? envVarVal
|
||||
: "library.kiwix.org";
|
||||
}
|
||||
|
||||
int OpdsRequestManager::getCatalogPort()
|
||||
{
|
||||
const char* const envVarVal = getenv("KIWIX_CATALOG_PORT");
|
||||
return envVarVal
|
||||
? atoi(envVarVal)
|
||||
: 443;
|
||||
}
|
||||
|
||||
void OpdsRequestManager::doUpdate(const QString& currentLanguage, const QString& categoryFilter)
|
||||
{
|
||||
QUrlQuery query;
|
||||
@ -36,9 +50,10 @@ void OpdsRequestManager::doUpdate(const QString& currentLanguage, const QString&
|
||||
QNetworkReply* OpdsRequestManager::opdsResponseFromPath(const QString &path, const QUrlQuery &query)
|
||||
{
|
||||
QUrl url;
|
||||
url.setScheme("https");
|
||||
url.setHost(CATALOG_HOST);
|
||||
url.setPort(CATALOG_PORT);
|
||||
const int port = getCatalogPort();
|
||||
url.setScheme(port == 443 ? "https" : "http");
|
||||
url.setHost(getCatalogHost());
|
||||
url.setPort(port);
|
||||
url.setPath(path);
|
||||
url.setQuery(query);
|
||||
qInfo() << "Downloading" << url.toString(QUrl::FullyEncoded);
|
||||
|
@ -32,6 +32,10 @@ public slots:
|
||||
void receiveContent(QNetworkReply*);
|
||||
void receiveLanguages(QNetworkReply*);
|
||||
void receiveCategories(QNetworkReply*);
|
||||
|
||||
public:
|
||||
static QString getCatalogHost();
|
||||
static int getCatalogPort();
|
||||
};
|
||||
|
||||
#endif // OPDSREQUESTMANAGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user