Fix for i2p starts
This commit is contained in:
parent
fb3dfdbd1c
commit
a3cbc27388
@ -4,6 +4,39 @@
|
|||||||
I2PController::I2PController(QObject *parent)
|
I2PController::I2PController(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
this->isFatalErrored = false;
|
||||||
|
|
||||||
|
connect(&i2p, &QProcess::errorOccurred,
|
||||||
|
this, &I2PController::onProcessError);
|
||||||
|
|
||||||
|
connect(&i2p, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
|
this, &I2PController::onProcessFinished);
|
||||||
|
|
||||||
|
connect(&i2p, &QProcess::readyReadStandardOutput, this, [this]() {
|
||||||
|
qDebug() << "[i2pd]" << i2p.readAllStandardOutput();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(&i2p, &QProcess::readyReadStandardError, this, [this]() {
|
||||||
|
QString msg = i2p.readAllStandardError();
|
||||||
|
qDebug() << "[i2pd ERROR]" << msg;
|
||||||
|
if (msg.contains("missing/unreadable config file:")) {
|
||||||
|
emit fatalError(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the launcher
|
||||||
|
connect(this, &I2PController::fatalError, [this](QString msg) {
|
||||||
|
this->isFatalErrored = true;
|
||||||
|
qCritical() << msg;
|
||||||
|
QMessageBox::critical(
|
||||||
|
nullptr,
|
||||||
|
"I2P Error",
|
||||||
|
"A fatal error occurred while running i2pd:\n\n" + msg +
|
||||||
|
"\n\nThe launcher will now close.",
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
|
qApp->exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PController::start() {
|
void I2PController::start() {
|
||||||
@ -72,6 +105,8 @@ void I2PController::onProcessFinished(int exitCode, QProcess::ExitStatus status)
|
|||||||
|
|
||||||
void I2PController::restartI2P()
|
void I2PController::restartI2P()
|
||||||
{
|
{
|
||||||
|
if (isFatalErrored) return;
|
||||||
|
|
||||||
static int restartCount = 0;
|
static int restartCount = 0;
|
||||||
|
|
||||||
if (restartCount > 5)
|
if (restartCount > 5)
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
class I2PController : public QObject
|
class I2PController : public QObject
|
||||||
{
|
{
|
||||||
@ -14,6 +16,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QProcess i2p;
|
QProcess i2p;
|
||||||
void restartI2P();
|
void restartI2P();
|
||||||
|
bool isFatalErrored;
|
||||||
public slots:
|
public slots:
|
||||||
void onProcessError(QProcess::ProcessError error);
|
void onProcessError(QProcess::ProcessError error);
|
||||||
void onProcessFinished(int exitCode, QProcess::ExitStatus status);
|
void onProcessFinished(int exitCode, QProcess::ExitStatus status);
|
||||||
|
|||||||
17
locales.cpp
17
locales.cpp
@ -25,6 +25,10 @@ LocaleMap ru_RU = {
|
|||||||
{"welcome.showPassword", "Показать пароль"},
|
{"welcome.showPassword", "Показать пароль"},
|
||||||
{"welcome.logIn", "Войти"},
|
{"welcome.logIn", "Войти"},
|
||||||
{"welcome.register", "Зарегистрироваться"},
|
{"welcome.register", "Зарегистрироваться"},
|
||||||
|
// I2PD
|
||||||
|
{"i2pd.errorTitle", "Ошибка I2P"},
|
||||||
|
{"i2pd.errorDescription.p1", "I2P Завершилась с фатальной ошибкой:\n\n"},
|
||||||
|
{"i2pd.errorDescription.p2", "\n\nЛаунчер будет закрыт."},
|
||||||
};
|
};
|
||||||
|
|
||||||
// English
|
// English
|
||||||
@ -50,6 +54,10 @@ LocaleMap en_US = {
|
|||||||
{"welcome.showPassword", "Show the password"},
|
{"welcome.showPassword", "Show the password"},
|
||||||
{"welcome.logIn", "LogIn"},
|
{"welcome.logIn", "LogIn"},
|
||||||
{"welcome.register", "Registration"},
|
{"welcome.register", "Registration"},
|
||||||
|
// I2PD
|
||||||
|
{"i2pd.errorTitle", "I2P Error"},
|
||||||
|
{"i2pd.errorDescription.p1", "A fatal error occurred while running i2pd:\n\n"},
|
||||||
|
{"i2pd.errorDescription.p2", "\n\nThe launcher will now close."},
|
||||||
};
|
};
|
||||||
|
|
||||||
void initLocales () {
|
void initLocales () {
|
||||||
@ -58,3 +66,12 @@ void initLocales () {
|
|||||||
locales["en_US"] = &en_US;
|
locales["en_US"] = &en_US;
|
||||||
//locales["en_UK"] = &en_US;
|
//locales["en_UK"] = &en_US;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocaleMap* getLocale () {
|
||||||
|
std::string locale = (QLocale::system()).name().toStdString();
|
||||||
|
if (locales.find(locale) == locales.end()) {
|
||||||
|
locale = "en_US";
|
||||||
|
}
|
||||||
|
LocaleMap* localeMap = locales[locale];
|
||||||
|
return localeMap;
|
||||||
|
}
|
||||||
|
|||||||
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
using LocaleMap = std::map<const std::string, const std::string>;
|
using LocaleMap = std::map<const std::string, const std::string>;
|
||||||
extern std::map<const std::string, LocaleMap*> locales;
|
extern std::map<const std::string, LocaleMap*> locales;
|
||||||
extern void initLocales ();
|
extern void initLocales ();
|
||||||
|
LocaleMap* getLocale ();
|
||||||
|
|
||||||
#endif // LOCALES_H
|
#endif // LOCALES_H
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user