mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
YACReaderLibraryServer: Print QR code and basic server info on start
This commit is contained in:
parent
c100edfcd0
commit
f8f25c396f
@ -63,6 +63,7 @@ HEADERS += ../YACReaderLibrary/library_creator.h \
|
|||||||
../YACReaderLibrary/comic_files_manager.h \
|
../YACReaderLibrary/comic_files_manager.h \
|
||||||
console_ui_library_creator.h \
|
console_ui_library_creator.h \
|
||||||
libraries_updater.h \
|
libraries_updater.h \
|
||||||
|
../YACReaderLibrary/ip_config_helper.h
|
||||||
../YACReaderLibrary/db/query_lexer.h \
|
../YACReaderLibrary/db/query_lexer.h \
|
||||||
../YACReaderLibrary/db/query_parser.h \
|
../YACReaderLibrary/db/query_parser.h \
|
||||||
../YACReaderLibrary/db/search_query.h
|
../YACReaderLibrary/db/search_query.h
|
||||||
@ -91,6 +92,7 @@ SOURCES += ../YACReaderLibrary/library_creator.cpp \
|
|||||||
console_ui_library_creator.cpp \
|
console_ui_library_creator.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
libraries_updater.cpp \
|
libraries_updater.cpp \
|
||||||
|
../YACReaderLibrary/ip_config_helper.cpp
|
||||||
../YACReaderLibrary/db/query_lexer.cpp \
|
../YACReaderLibrary/db/query_lexer.cpp \
|
||||||
../YACReaderLibrary/db/query_parser.cpp \
|
../YACReaderLibrary/db/query_parser.cpp \
|
||||||
../YACReaderLibrary/db/search_query.cpp \
|
../YACReaderLibrary/db/search_query.cpp \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// #include <QtCore>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -20,6 +19,8 @@
|
|||||||
|
|
||||||
#include "QsLog.h"
|
#include "QsLog.h"
|
||||||
#include "QsLogDest.h"
|
#include "QsLogDest.h"
|
||||||
|
#include "qrcodegen.hpp"
|
||||||
|
#include "ip_config_helper.h"
|
||||||
|
|
||||||
using namespace QsLogging;
|
using namespace QsLogging;
|
||||||
// Returns false in case of a parse error (unknown option or missing value); returns true otherwise.
|
// Returns false in case of a parse error (unknown option or missing value); returns true otherwise.
|
||||||
@ -29,17 +30,6 @@ void logSystemAndConfig()
|
|||||||
QLOG_INFO() << "---------- System & configuration ----------";
|
QLOG_INFO() << "---------- System & configuration ----------";
|
||||||
QLOG_INFO() << "OS:" << QSysInfo::prettyProductName() << "Version: " << QSysInfo::productVersion();
|
QLOG_INFO() << "OS:" << QSysInfo::prettyProductName() << "Version: " << QSysInfo::productVersion();
|
||||||
QLOG_INFO() << "Kernel:" << QSysInfo::kernelType() << QSysInfo::kernelVersion() << "Architecture:" << QSysInfo::currentCpuArchitecture();
|
QLOG_INFO() << "Kernel:" << QSysInfo::kernelType() << QSysInfo::kernelVersion() << "Architecture:" << QSysInfo::currentCpuArchitecture();
|
||||||
/* TODO: qrencode could be helpfull for showing a qr code in the web client for client devices
|
|
||||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
|
||||||
if(QFileInfo(QString(BINDIR)+"/qrencode").exists())
|
|
||||||
#else
|
|
||||||
if(QFileInfo(QCoreApplication::applicationDirPath()+"/utils/qrencode.exe").exists() || QFileInfo("./util/qrencode").exists())
|
|
||||||
#endif
|
|
||||||
QLOG_INFO() << "qrencode : found";
|
|
||||||
else
|
|
||||||
QLOG_INFO() << "qrencode : not found";
|
|
||||||
*/
|
|
||||||
|
|
||||||
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
|
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
|
||||||
QLOG_INFO() << "--------------------------------------------";
|
QLOG_INFO() << "--------------------------------------------";
|
||||||
}
|
}
|
||||||
@ -76,6 +66,31 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printServerInfo(YACReaderHttpServer *httpServer)
|
||||||
|
{
|
||||||
|
auto addresses = getIpAddresses();
|
||||||
|
QLOG_INFO() << "Running on" << addresses.first() + ":" + httpServer->getPort().toLocal8Bit() << "\n";
|
||||||
|
|
||||||
|
qrcodegen::QrCode code = qrcodegen::QrCode::encodeText(
|
||||||
|
(addresses.first() + ":" + httpServer->getPort()).toLocal8Bit(),
|
||||||
|
qrcodegen::QrCode::Ecc::LOW);
|
||||||
|
int border = 4;
|
||||||
|
for (int y = -border; y < code.getSize() + border; y += 2) {
|
||||||
|
QString QRCodeString;
|
||||||
|
for (int x = -border - 1; x < code.getSize() + border + 1; x++) {
|
||||||
|
QRCodeString.append((code.getModule(x, y) && code.getModule(x, y + 1))
|
||||||
|
? " "
|
||||||
|
: code.getModule(x, y + 1) ? "\u2580"
|
||||||
|
: code.getModule(x, y) ? "\u2584"
|
||||||
|
: "\u2588");
|
||||||
|
}
|
||||||
|
QLOG_INFO() << QRCodeString;
|
||||||
|
}
|
||||||
|
if (addresses.length() > 1) {
|
||||||
|
QLOG_INFO() << addresses.length() - 1 << "more network interfaces detected";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
@ -215,7 +230,7 @@ int main(int argc, char **argv)
|
|||||||
httpServer->start();
|
httpServer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
QLOG_INFO() << "Running on port" << httpServer->getPort();
|
printServerInfo(httpServer);
|
||||||
|
|
||||||
// Update libraries to new versions
|
// Update libraries to new versions
|
||||||
LibrariesUpdater updater;
|
LibrariesUpdater updater;
|
||||||
|
Loading…
Reference in New Issue
Block a user