From 86d5d243468a89c6a1ba9af04f19e12b7215a42c Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Thu, 16 Jul 2026 14:53:21 +0800
Subject: [PATCH] Fix build with Qt4

---
 I2PChat.pro                           |  10 +
 src/backend/ConnectionManager.cpp     |   6 +-
 src/backend/Core.cpp                  |  46 ++--
 src/backend/Core.h                    |   8 +
 src/backend/FileTransferManager.cpp   |  10 +-
 src/backend/FileTransferSend.cpp      |  20 +-
 src/backend/HttpOverStreamObject.cpp  |  26 +--
 src/backend/I2PSamMessageAnalyser.cpp |   2 +-
 src/backend/Main.cpp                  |  52 +++--
 src/backend/PacketManager.cpp         |  12 +-
 src/backend/Protocol.cpp              | 320 +++++++++++++-------------
 src/backend/SessionController.cpp     |  10 +-
 src/backend/TextEmotionChanger.cpp    |   2 +-
 src/backend/User.cpp                  |  64 +++---
 src/backend/UserBlockManager.cpp      |  30 +--
 src/backend/UserManager.cpp           |  36 +--
 src/backend/UserManager.h             |   1 +
 src/gui/form_Main.cpp                 |  14 ++
 src/gui/form_Main.ui                  |   3 -
 src/gui/form_chatwidget.cpp           |   7 +-
 src/gui/form_settingsgui.cpp          |  20 +-
 src/gui/form_settingsgui.ui           |  12 -
 22 files changed, 385 insertions(+), 326 deletions(-)

diff --git a/I2PChat.pro b/I2PChat.pro
index 832e98f..7720673 100644
--- a/I2PChat.pro
+++ b/I2PChat.pro
@@ -6,6 +6,16 @@ QT += network xml
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia core svg
 
+# Qt4 has no QCryptographicHash::Sha256, so use OpenSSL for SHA-256 there.
+# We use the EVP one-shot API, which is present and non-deprecated in both
+# OpenSSL 1.1 and 3.0, so either can be linked without source changes.
+# MacPorts (and system) install headers/libs on the default search paths,
+# so no explicit -I/-L is needed; just link libcrypto.
+!greaterThan(QT_MAJOR_VERSION, 4) {
+	DEFINES += USE_OPENSSL_SHA256
+	LIBS += -lcrypto
+}
+
 TEMPLATE = app
 
 QMAKE_CXXFLAGS += -std=c++11
diff --git a/src/backend/ConnectionManager.cpp b/src/backend/ConnectionManager.cpp
index ee7eb9c..7d3c7fa 100644
--- a/src/backend/ConnectionManager.cpp
+++ b/src/backend/ConnectionManager.cpp
@@ -2,8 +2,6 @@
 
 #include "ConnectionManager.h"
 
-#include <QRandomGenerator>
-
 #include <utility>
 
 CConnectionManager::CConnectionManager(QString SamHost, QString SamPort, QString ConfigPath)
@@ -252,11 +250,11 @@ QString CConnectionManager::generateBridgeName() const {
   int length = 0;
 
   while (length < 3) {
-    length = QRandomGenerator::global()->bounded(9);
+    length = (qrand() % 9);
   }
 
   for (int i = 0; i < length; i++) {
-    Name.append(QLatin1Char('A' + QRandomGenerator::global()->bounded(26)));
+    Name.append(QLatin1Char('A' + (qrand() % 26)));
   }
 
   return Name;
diff --git a/src/backend/Core.cpp b/src/backend/Core.cpp
index 46af79b..44ab83e 100644
--- a/src/backend/Core.cpp
+++ b/src/backend/Core.cpp
@@ -11,10 +11,10 @@
 #include "UserManager.h"
 
 #include <QApplication>
+#include <QDesktopServices>
 #include <QDir>
 #include <QFileInfoList>
 #include <QMessageBox>
-#include <QStandardPaths>
 #include <QtGlobal>
 
 #include <cmath>
@@ -220,13 +220,29 @@ QString CCore::calcSessionOptionString() const {
   return SessionOptionString;
 }
 
+static bool removeDirRecursively(const QString &path) {
+    QDir dir(path);
+    if (!dir.exists())
+        return true;
+    foreach (const QFileInfo &info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries)) {
+        if (info.isDir()) {
+            if (!removeDirRecursively(info.absoluteFilePath()))
+                return false;
+        } else {
+            if (!QFile::remove(info.absoluteFilePath()))
+                return false;
+        }
+    }
+    return dir.rmdir(path);
+}
+
 void CCore::init() {
   using namespace SESSION_ENUMS;
 
   // Clean up transient chat previews from previous session
   QDir tmpDir("/tmp/i2pchat");
   if (tmpDir.exists())
-    tmpDir.removeRecursively();
+    removeDirRecursively("/tmp/i2pchat");
 
   qDebug() << "CCore::init() called";
   this->mMyDestination = "";
@@ -381,15 +397,15 @@ void CCore::slotNamingReplyReceived(const SAM_Message_Types::RESULT result,
       theUser->setReplaceB32WithB64(Value);
     }
   } else if (result == SAM_Message_Types::FAILED) {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "CCore::slotNamingReplyReceived" << Qt::endl
+               << "CCore::slotNamingReplyReceived" << endl
                << "Message:\t"
-               << "slotNamingReplyReceived\nSAM_Message_Types::FAILED" << Qt::endl
-               << "Name:\t" << Name << Qt::endl
-               << "Value:\t" << Value << Qt::endl
-               << "Message:\t" << Message << Qt::endl;
+               << "slotNamingReplyReceived\nSAM_Message_Types::FAILED" << endl
+               << "Name:\t" << Name << endl
+               << "Value:\t" << Value << endl
+               << "Message:\t" << Message << endl;
   }
 }
 const QString CCore::getMyDestination() const {
@@ -896,15 +912,15 @@ void CCore::setMyDestinationB32(const QString &B32Dest) {
     return;
 
   if (!B32Dest.right(8).contains(".b32.i2p", Qt::CaseInsensitive)) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CCore::setMyDestinationB32" << Qt::endl
+                << "CCore::setMyDestinationB32" << endl
                 << "Message:\t"
-                << "the last 8 char must be .b32.i2p" << Qt::endl
+                << "the last 8 char must be .b32.i2p" << endl
                 << "\tDestination:\n"
-                << B32Dest << Qt::endl
-                << "\tAction apported" << Qt::endl;
+                << B32Dest << endl
+                << "\tAction apported" << endl;
   }
 
   QSettings settings(mConfigPath + "/application.ini", QSettings::IniFormat);
diff --git a/src/backend/Core.h b/src/backend/Core.h
index 2a93dd6..5afcc10 100644
--- a/src/backend/Core.h
+++ b/src/backend/Core.h
@@ -84,6 +84,14 @@ public:
 
   QString canonicalizeTopicId(QString topicIdNonCanonicalized);
 
+  void emitIncomingUserAuthorizationRequest(const QString &destination, qint32 streamID, const QByteArray &data) {
+    emit signIncomingUserAuthorizationRequest(destination, streamID, data);
+  }
+
+  void emitNicknameChanged() {
+    emit signNicknameChanged();
+  }
+
 private slots:
   // <SIGNALS FROM CONNECTIONMANAGER>
   void slotStreamStatusReceived(const SAM_Message_Types::RESULT result, const qint32 ID, const QString &Message);
diff --git a/src/backend/FileTransferManager.cpp b/src/backend/FileTransferManager.cpp
index db973e3..2d8ce53 100644
--- a/src/backend/FileTransferManager.cpp
+++ b/src/backend/FileTransferManager.cpp
@@ -111,13 +111,13 @@ void CFileTransferManager::addNewFileReceive(qint32 ID,
   }
   ProtocolVersionD = ProtocolVersion.toDouble(&OK);
   if (OK == false) {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << " CFileTransferManager::addNewFileReceive" << Qt::endl
+               << " CFileTransferManager::addNewFileReceive" << endl
                << "Message:\t"
-               << "Can't convert QString to double" << Qt::endl
-               << "QString:\t" << ProtocolVersion << Qt::endl;
+               << "Can't convert QString to double" << endl
+               << "QString:\t" << ProtocolVersion << endl;
 
     // abort the Filereceive
     if (ProtocolVersion == "0.1" || ProtocolVersion == "0.2") {
diff --git a/src/backend/FileTransferSend.cpp b/src/backend/FileTransferSend.cpp
index 11f161d..ae1e9c1 100644
--- a/src/backend/FileTransferSend.cpp
+++ b/src/backend/FileTransferSend.cpp
@@ -64,14 +64,14 @@ void CFileTransferSend::slotStreamStatus(const SAM_Message_Types::RESULT result,
   using namespace FileTransferProtocol;
 
   if (mStreamID != ID) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CFileTransferSend::slotStreamStatus" << Qt::endl
+                << "CFileTransferSend::slotStreamStatus" << endl
                 << "Message:\t"
-                << "mStreamID!=ID WTF" << Qt::endl
-                << "mStreamID:\t" << mStreamID << Qt::endl
-                << "ID:\t" << ID << Qt::endl;
+                << "mStreamID!=ID WTF" << endl
+                << "mStreamID:\t" << mStreamID << endl
+                << "ID:\t" << ID << endl;
   }
 
   switch (result) {
@@ -234,12 +234,12 @@ void CFileTransferSend::StartFileTransfer(qint64 mFromPos) {
     mCurrentPacketSize = MAXPACKETSIZE;
     SendFile_v0dot3();
   } else {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "CFileTransferSend::StartFileTransfer" << Qt::endl
+               << "CFileTransferSend::StartFileTransfer" << endl
                << "Message:\t"
-               << "Unsupported Protocolversion:" << mUsingProtocolVersion << Qt::endl;
+               << "Unsupported Protocolversion:" << mUsingProtocolVersion << endl;
 
     mCore.getFileTransferManager()->removeFileTransfer(mStreamID);
   }
diff --git a/src/backend/HttpOverStreamObject.cpp b/src/backend/HttpOverStreamObject.cpp
index 9dde222..34db23d 100644
--- a/src/backend/HttpOverStreamObject.cpp
+++ b/src/backend/HttpOverStreamObject.cpp
@@ -22,15 +22,15 @@ void CHttpOverStreamObject::slotStreamStatus(const SAM_Message_Types::RESULT res
                                              const qint32 ID,
                                              const QString &Message) {
   if (mStreamID != ID) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CHttpOverStreamObject::slotStreamStatus" << Qt::endl
-                << "Stream-Message:\t" << Message << Qt::endl
+                << "CHttpOverStreamObject::slotStreamStatus" << endl
+                << "Stream-Message:\t" << Message << endl
                 << "Message:\t"
-                << "mStreamID!=ID WTF" << Qt::endl
-                << "mStreamID:\t" << mStreamID << Qt::endl
-                << "ID:\t" << ID << Qt::endl;
+                << "mStreamID!=ID WTF" << endl
+                << "mStreamID:\t" << mStreamID << endl
+                << "ID:\t" << ID << endl;
   }
 
   switch (result) {
@@ -74,14 +74,14 @@ void CHttpOverStreamObject::slotStreamStatus(const SAM_Message_Types::RESULT res
 
 void CHttpOverStreamObject::slotDataReceived(const qint32 ID, const QByteArray &t) {
   if (mStreamID != ID) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CHttpOverStreamObject::slotDataReceived" << Qt::endl
+                << "CHttpOverStreamObject::slotDataReceived" << endl
                 << "Message:\t"
-                << "mStreamID!=ID WTF" << Qt::endl
-                << "mStreamID:\t" << mStreamID << Qt::endl
-                << "ID:\t" << ID << Qt::endl;
+                << "mStreamID!=ID WTF" << endl
+                << "mStreamID:\t" << mStreamID << endl
+                << "ID:\t" << ID << endl;
   }
 
   mDataReceived.append(t);
diff --git a/src/backend/I2PSamMessageAnalyser.cpp b/src/backend/I2PSamMessageAnalyser.cpp
index 31d8595..13dfeb2 100644
--- a/src/backend/I2PSamMessageAnalyser.cpp
+++ b/src/backend/I2PSamMessageAnalyser.cpp
@@ -11,7 +11,7 @@ const SAM_MESSAGE CI2PSamMessageAnalyser::Analyse(const QString &Message) const
   using namespace SAM_Message_Types;
 
   SAM_MESSAGE t;
-  QStringList list = Message.split(" ", Qt::SkipEmptyParts);
+  QStringList list = Message.split(" ", QString::SkipEmptyParts);
 
   if ((list[0] == "HELLO") && (list[1] == "REPLY")) {
     t.type = HELLO_REPLAY;
diff --git a/src/backend/Main.cpp b/src/backend/Main.cpp
index 6313a5d..9512b76 100644
--- a/src/backend/Main.cpp
+++ b/src/backend/Main.cpp
@@ -5,11 +5,11 @@
 
 #include <QApplication>
 #include <QDateTime>
+#include <QDesktopServices>
 #include <QDir>
 #include <QElapsedTimer>
 #include <QFile>
 #include <QSettings>
-#include <QStandardPaths>
 #include <QTextStream>
 #include <QtDebug>
 #include <QtGui>
@@ -20,8 +20,11 @@
 QString debugLogDir;
 
 void enableDebugLogging(const QString &configPath);
-// void myMessageHandler(QtMsgType type, const char *msg);
+#if QT_VERSION >= 0x050000
 void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
+#else
+void myMessageHandler(QtMsgType type, const char *msg);
+#endif
 
 void help() {
   printf("\r\n%s\r\n\r\n"
@@ -46,11 +49,19 @@ int main(int argc, char *argv[]) {
 #endif
 
   QApplication app(argc, argv);
+
+#if QT_VERSION < 0x050000
+  // Qt4's qrand() shares one default seed on every run; QRandomGenerator (Qt5+)
+  // self-seeds from system entropy. Seed once so generateBridgeName() and other
+  // qrand() users vary across runs, matching the original behavior.
+  qsrand(QDateTime::currentMSecsSinceEpoch());
+#endif
+
   QString configPath;
   QFile styleSheetFile(":qss/Default.qss");
 
 #ifdef ANDROID
-  QStringList loc = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
+  QStringList loc = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
   if (loc.size() <= 0) {
     QMessageBox::critical(NULL, "I2PChat", "Error: no USER folder found");
     app.exec();
@@ -90,7 +101,7 @@ int main(int argc, char *argv[]) {
 #ifdef _WIN32
   configPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
 #else
-  configPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + NameOfConfigDirectoryOnLinux;
+  configPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + NameOfConfigDirectoryOnLinux;
 #endif
 
   { // getopt_long + getopt (short)
@@ -136,9 +147,9 @@ int main(int argc, char *argv[]) {
 
   // configPath=QApplication::applicationDirPath();
   if (QFile::exists(configPath + "/UseHomeForConfigStore") == true) {
-    QStringList tmp = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
-    if (!tmp.empty()) {
-      configPath = tmp.at(0);
+    QString tmp = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+    if (!tmp.isEmpty()) {
+      configPath = tmp;
       configPath += "/.I2PChat";
     }
   }
@@ -178,44 +189,53 @@ void enableDebugLogging(const QString &configPath) {
   QSettings settings(configPath + "/application.ini", QSettings::IniFormat);
   settings.beginGroup("General");
   if (settings.value("DebugLogging", "true").toBool() == true) {
+#if QT_VERSION >= 0x050000
     qInstallMessageHandler(myMessageHandler);
+#else
+    qInstallMsgHandler(myMessageHandler);
+#endif
   }
   settings.endGroup();
   settings.sync();
 }
 
+#if QT_VERSION >= 0x050000
 void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
+  const QString message = msg;
+  const QString where = QString(" (%1:%2, %3)").arg(context.file).arg(context.line).arg(context.function);
+#else
+void myMessageHandler(QtMsgType type, const char *msg) {
+  const QString message = QString::fromLocal8Bit(msg);
+  const QString where; // Qt4 provides no file/line/function context
+#endif
   QString txt;
 
   txt.append(QDateTime::currentDateTime().toString("hh:mm:ss"));
 
   switch (type) {
   case QtDebugMsg: {
-    txt.append(QString(" Debug: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function));
+    txt.append(QString(" Debug: %1%2\n").arg(message).arg(where));
     break;
   }
   case QtWarningMsg: {
-    txt.append(
-      QString(" Warning: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function));
+    txt.append(QString(" Warning: %1%2\n").arg(message).arg(where));
     break;
   }
   case QtCriticalMsg: {
-    txt.append(
-      QString(" Critical: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function));
+    txt.append(QString(" Critical: %1%2\n").arg(message).arg(where));
     break;
   }
   case QtFatalMsg: {
-    txt.append(QString(" Fatal: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function));
+    txt.append(QString(" Fatal: %1%2\n").arg(message).arg(where));
     break;
   }
   default: {
-    txt.append(
-      QString(" Message: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function));
+    txt.append(QString(" Message: %1%2\n").arg(message).arg(where));
     break;
   }
   }
   QFile outFile(debugLogDir + "/DebugLog.txt");
   outFile.open(QIODevice::WriteOnly | QIODevice::Append);
   QTextStream ts(&outFile);
-  ts << txt << Qt::endl;
+  ts << txt << endl;
 }
diff --git a/src/backend/PacketManager.cpp b/src/backend/PacketManager.cpp
index 851822f..47c5f46 100644
--- a/src/backend/PacketManager.cpp
+++ b/src/backend/PacketManager.cpp
@@ -36,14 +36,14 @@ void CPacketManager::checkifOnePacketIsCompleate() {
     bool OK = false;
     int iPacketLength = sPacketLength.toInt(&OK, 16);
     if (OK == false) {
-      qCritical() << "File\t" << __FILE__ << Qt::endl
-                  << "Line:\t" << __LINE__ << Qt::endl
+      qCritical() << "File\t" << __FILE__ << endl
+                  << "Line:\t" << __LINE__ << endl
                   << "Function:\t"
-                  << "CPacketManager::checkifOnePacketIsCompleate" << Qt::endl
+                  << "CPacketManager::checkifOnePacketIsCompleate" << endl
                   << "Message:\t"
-                  << "cant parse PacketLength" << Qt::endl
-                  << "StreamID: " << mID << Qt::endl
-                  << "sPacketLength: " << sPacketLength << Qt::endl;
+                  << "cant parse PacketLength" << endl
+                  << "StreamID: " << mID << endl
+                  << "sPacketLength: " << sPacketLength << endl;
 
       CI2PStream *stream = mConnectionManager.getStreamObjectByID(mID);
       if (stream != NULL) {
diff --git a/src/backend/Protocol.cpp b/src/backend/Protocol.cpp
index e0ff43e..90bd4e4 100644
--- a/src/backend/Protocol.cpp
+++ b/src/backend/Protocol.cpp
@@ -53,13 +53,13 @@ void CProtocol::slotInputKnown(const qint32 ID, const QByteArray &Data) {
              ProtocolInfoTag == "0022") {
     dispatchKnownMessage(ID, Data, ProtocolInfoTag);
   } else {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "CProtocol::slotInputKnown" << Qt::endl
+               << "CProtocol::slotInputKnown" << endl
                << "Message:\t"
-               << "Unknown ProtocolInfoTag: " << ProtocolInfoTag << Qt::endl
-               << "Packet ignored" << Qt::endl;
+               << "Unknown ProtocolInfoTag: " << ProtocolInfoTag << endl
+               << "Packet ignored" << endl;
   }
 }
 
@@ -131,13 +131,13 @@ void CProtocol::send(const COMMANDS_TAGS TAG, const qint32 ID) const {
     break;
   }
   default: {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CProtocol::send" << Qt::endl
+                << "CProtocol::send" << endl
                 << "Message:\t"
                 << "unhandeld Command-TAG"
-                << "exit" << Qt::endl;
+                << "exit" << endl;
     exit(-1);
   }
   }
@@ -251,13 +251,13 @@ void CProtocol::send(const MESSAGES_TAGS TAG, const qint32 ID, QByteArray Data)
     break;
   }
   default: {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CProtocol::send" << Qt::endl
+                << "CProtocol::send" << endl
                 << "Message:\t"
                 << "unhandeld Message-TAG"
-                << "exit" << Qt::endl;
+                << "exit" << endl;
 
     exit(-1);
   }
@@ -278,73 +278,69 @@ void CProtocol::dispatchKnownCommand(const qint32 ID, const QByteArray &Data, co
   Q_UNUSED(Data);
   using namespace Protocol_Info;
 
-  using CmdFn = void (*)(CProtocol &, qint32);
-  static const QHash<QString, CmdFn> handlers = {
-    {"1000", [](CProtocol &p, qint32 id) { p.send(ECHO_OF_PING, id, QString("")); }},
-    {"1001", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_CLIENTVERSION, id, p.mCore.getClientVersion()); }},
-    {"1002", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_CLIENTNAME, id, p.mCore.getClientName()); }},
-    {"1003",
-     [](CProtocol &p, qint32 id) {
-       if (p.mCore.getUserManager()->getUserByI2P_ID(id)->getIsInvisible() == true) {
-         p.send(USER_ONLINESTATUS_OFFLINE, id, QString(""));
-       } else {
-         switch (p.mCore.getOnlineStatus()) {
-         case USERONLINE:
-           p.send(USER_ONLINESTATUS_ONLINE, id, QString(""));
-           break;
-         case USEROFFLINE:
-         case USERINVISIBLE:
-           p.send(USER_ONLINESTATUS_OFFLINE, id, QString(""));
-           break;
-         case USERAWAY:
-           p.send(USER_ONLINESTATUS_AWAY, id, QString(""));
-           break;
-         case USERWANTTOCHAT:
-           p.send(USER_ONLINESTATUS_WANTTOCHAT, id, QString(""));
-           break;
-         case USERDONT_DISTURB:
-           p.send(USER_ONLINESTATUS_DONT_DISTURB, id, QString(""));
-           break;
-         default: {
-           QMessageBox *msgBox = new QMessageBox(NULL);
-           msgBox->setIcon(QMessageBox::Warning);
-           msgBox->setText(p.tr("cProtocol(inputKnown)"));
-           msgBox->setInformativeText(p.tr("Unknown USERSTATE"));
-           msgBox->setStandardButtons(QMessageBox::Ok);
-           msgBox->setDefaultButton(QMessageBox::Ok);
-           msgBox->setWindowModality(Qt::NonModal);
-           msgBox->setAttribute(Qt::WA_DeleteOnClose);
-           msgBox->show();
-         }
-         }
-       }
-     }},
-    {"1004", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_PROTOCOLVERSION, id, p.mCore.getProtocolVersion()); }},
-    {"1005",
-     [](CProtocol &p, qint32 id) {
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u != NULL)
-         p.send(ANSWER_OF_GET_MAX_PROTOCOLVERSION_FILETRANSFER, id, FileTransferProtocol::MAXPROTOCOLVERSION);
-     }},
-    {"1006",
-     [](CProtocol &p, qint32 id) {
-       CReceivedInfos Infos = p.mCore.getUserInfos();
-       p.send(USER_INFO_NICKNAME, id, Infos.Nickname);
-       p.send(USER_INFO_GENDER, id, Infos.Gender);
-       p.send(USER_INFO_INTERESTS, id, Infos.Interests);
-       QString sAge;
-       sAge.setNum(Infos.Age, 10);
-       p.send(USER_INFO_AGE, id, sAge);
-     }},
-    {"1007",
-     [](CProtocol &p, qint32 id) {
-       p.send(ANSWER_OF_GET_MIN_PROTOCOLVERSION_FILETRANSFER, id, FileTransferProtocol::MINPROTOCOLVERSION);
-     }},
-    {"1008",
-     [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_AVATARIMAGE_IMAGE, id, p.mCore.getUserInfos().AvatarImage); }},
-  };
-
-  auto it = handlers.constFind(tag);
+  typedef void (*CmdFn)(CProtocol &, qint32);
+  static QHash<QString, CmdFn> handlers;
+  if (handlers.isEmpty()) {
+    handlers.insert("1000", [](CProtocol &p, qint32 id) { p.send(ECHO_OF_PING, id, QString("")); });
+    handlers.insert("1001", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_CLIENTVERSION, id, p.mCore.getClientVersion()); });
+    handlers.insert("1002", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_CLIENTNAME, id, p.mCore.getClientName()); });
+    handlers.insert("1003", [](CProtocol &p, qint32 id) {
+      if (p.mCore.getUserManager()->getUserByI2P_ID(id)->getIsInvisible() == true) {
+        p.send(USER_ONLINESTATUS_OFFLINE, id, QString(""));
+      } else {
+        switch (p.mCore.getOnlineStatus()) {
+        case USERONLINE:
+          p.send(USER_ONLINESTATUS_ONLINE, id, QString(""));
+          break;
+        case USEROFFLINE:
+        case USERINVISIBLE:
+          p.send(USER_ONLINESTATUS_OFFLINE, id, QString(""));
+          break;
+        case USERAWAY:
+          p.send(USER_ONLINESTATUS_AWAY, id, QString(""));
+          break;
+        case USERWANTTOCHAT:
+          p.send(USER_ONLINESTATUS_WANTTOCHAT, id, QString(""));
+          break;
+        case USERDONT_DISTURB:
+          p.send(USER_ONLINESTATUS_DONT_DISTURB, id, QString(""));
+          break;
+        default: {
+          QMessageBox *msgBox = new QMessageBox(NULL);
+          msgBox->setIcon(QMessageBox::Warning);
+          msgBox->setText(p.tr("cProtocol(inputKnown)"));
+          msgBox->setInformativeText(p.tr("Unknown USERSTATE"));
+          msgBox->setStandardButtons(QMessageBox::Ok);
+          msgBox->setDefaultButton(QMessageBox::Ok);
+          msgBox->setWindowModality(Qt::NonModal);
+          msgBox->setAttribute(Qt::WA_DeleteOnClose);
+          msgBox->show();
+        }
+        }
+      }
+    });
+    handlers.insert("1004", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_PROTOCOLVERSION, id, p.mCore.getProtocolVersion()); });
+    handlers.insert("1005", [](CProtocol &p, qint32 id) {
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u != NULL)
+        p.send(ANSWER_OF_GET_MAX_PROTOCOLVERSION_FILETRANSFER, id, FileTransferProtocol::MAXPROTOCOLVERSION);
+    });
+    handlers.insert("1006", [](CProtocol &p, qint32 id) {
+      CReceivedInfos Infos = p.mCore.getUserInfos();
+      p.send(USER_INFO_NICKNAME, id, Infos.Nickname);
+      p.send(USER_INFO_GENDER, id, Infos.Gender);
+      p.send(USER_INFO_INTERESTS, id, Infos.Interests);
+      QString sAge;
+      sAge.setNum(Infos.Age, 10);
+      p.send(USER_INFO_AGE, id, sAge);
+    });
+    handlers.insert("1007", [](CProtocol &p, qint32 id) {
+      p.send(ANSWER_OF_GET_MIN_PROTOCOLVERSION_FILETRANSFER, id, FileTransferProtocol::MINPROTOCOLVERSION);
+    });
+    handlers.insert("1008", [](CProtocol &p, qint32 id) { p.send(ANSWER_OF_GET_AVATARIMAGE_IMAGE, id, p.mCore.getUserInfos().AvatarImage); });
+  }
+
+  QHash<QString, CmdFn>::const_iterator it = handlers.constFind(tag);
   if (it != handlers.constEnd())
     it.value()(*this, ID);
 }
@@ -352,31 +348,31 @@ void CProtocol::dispatchKnownCommand(const qint32 ID, const QByteArray &Data, co
 void CProtocol::dispatchKnownMessage(const qint32 ID, const QByteArray &Data, const QString &tag) {
   using namespace Protocol_Info;
 
-  using UserFn = void (*)(CUser *, const QByteArray &);
-  static const QHash<QString, UserFn> userHandlers = {
-    {"0001", [](CUser *u, const QByteArray &d) { u->setClientVersion(d.mid(4)); }},
-    {"0002", [](CUser *u, const QByteArray &d) { u->setClientName(d.mid(4)); }},
-    {"0003", [](CUser *u, const QByteArray &d) { u->slotIncomingNewChatMessage(d.mid(4)); }},
-    {"0004", [](CUser *u, const QByteArray &) { u->setOnlineState(USERONLINE); }},
-    {"0005", [](CUser *u, const QByteArray &) { u->setOnlineState(USEROFFLINE); }},
-    {"0006", [](CUser *u, const QByteArray &) { u->setOnlineState(USERWANTTOCHAT); }},
-    {"0007", [](CUser *u, const QByteArray &) { u->setOnlineState(USERAWAY); }},
-    {"0008", [](CUser *u, const QByteArray &) { u->setOnlineState(USERDONT_DISTURB); }},
-    {"0009", [](CUser *u, const QByteArray &d) { u->setProtocolVersion(d.mid(4)); }},
-    {"0010", [](CUser *u, const QByteArray &d) { u->setMaxProtocolVersionFiletransfer(d.mid(4)); }},
-    {"0011", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::NICKNAME, d.mid(4)); }},
-    {"0012", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::GENDER, d.mid(4)); }},
-    {"0013", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::AGE, d.mid(4)); }},
-    {"0014", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::INTERESTS, d.mid(4)); }},
-    {"0017", [](CUser *u, const QByteArray &d) { u->setMinProtocolVersionFiletransfer(d.mid(4)); }},
-    {"0018",
-     [](CUser *u, const QByteArray &d) {
-       QByteArray temp = d.mid(4);
-       u->setAvatarImage(temp);
-     }},
-  };
-
-  auto it = userHandlers.constFind(tag);
+  typedef void (*UserFn)(CUser *, const QByteArray &);
+  static QHash<QString, UserFn> userHandlers;
+  if (userHandlers.isEmpty()) {
+    userHandlers.insert("0001", [](CUser *u, const QByteArray &d) { u->setClientVersion(d.mid(4)); });
+    userHandlers.insert("0002", [](CUser *u, const QByteArray &d) { u->setClientName(d.mid(4)); });
+    userHandlers.insert("0003", [](CUser *u, const QByteArray &d) { u->slotIncomingNewChatMessage(d.mid(4)); });
+    userHandlers.insert("0004", [](CUser *u, const QByteArray &) { u->setOnlineState(USERONLINE); });
+    userHandlers.insert("0005", [](CUser *u, const QByteArray &) { u->setOnlineState(USEROFFLINE); });
+    userHandlers.insert("0006", [](CUser *u, const QByteArray &) { u->setOnlineState(USERWANTTOCHAT); });
+    userHandlers.insert("0007", [](CUser *u, const QByteArray &) { u->setOnlineState(USERAWAY); });
+    userHandlers.insert("0008", [](CUser *u, const QByteArray &) { u->setOnlineState(USERDONT_DISTURB); });
+    userHandlers.insert("0009", [](CUser *u, const QByteArray &d) { u->setProtocolVersion(d.mid(4)); });
+    userHandlers.insert("0010", [](CUser *u, const QByteArray &d) { u->setMaxProtocolVersionFiletransfer(d.mid(4)); });
+    userHandlers.insert("0011", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::NICKNAME, d.mid(4)); });
+    userHandlers.insert("0012", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::GENDER, d.mid(4)); });
+    userHandlers.insert("0013", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::AGE, d.mid(4)); });
+    userHandlers.insert("0014", [](CUser *u, const QByteArray &d) { u->setReceivedUserInfos(User::INTERESTS, d.mid(4)); });
+    userHandlers.insert("0017", [](CUser *u, const QByteArray &d) { u->setMinProtocolVersionFiletransfer(d.mid(4)); });
+    userHandlers.insert("0018", [](CUser *u, const QByteArray &d) {
+      QByteArray temp = d.mid(4);
+      u->setAvatarImage(temp);
+    });
+  }
+
+  QHash<QString, UserFn>::const_iterator it = userHandlers.constFind(tag);
   if (it != userHandlers.constEnd()) {
     CUser *user = mCore.getUserManager()->getUserByI2P_ID(ID);
     if (user != NULL)
@@ -385,63 +381,59 @@ void CProtocol::dispatchKnownMessage(const qint32 ID, const QByteArray &Data, co
   }
 
   // Protocol-level handlers (need mCore access)
-  using ProtoFn = void (*)(CProtocol &, qint32, const QByteArray &);
-  static const QHash<QString, ProtoFn> protoHandlers = {
-    {"0015",
-     [](CProtocol &p, qint32 id, const QByteArray &) {
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u != NULL) {
-         p.mCore.deletePacketManagerByID(id);
-         if (p.mCore.getConnectionManager()->isComponentStopped() == false)
-           p.mCore.getConnectionManager()->doDestroyStreamObjectByID(id);
-         u->setConnectionStatus(OFFLINE);
-       }
-     }},
-    {"0016",
-     [](CProtocol &p, qint32 id, const QByteArray &) {
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u != NULL) {
-         u->setOnlineState(USERBLOCKEDYOU);
-         u->setConnectionStatus(OFFLINE);
-         p.mCore.deletePacketManagerByID(id);
-         if (p.mCore.getConnectionManager()->isComponentStopped() == false)
-           p.mCore.getConnectionManager()->doDestroyStreamObjectByID(id);
-       }
-     }},
-    {"0020",
-     [](CProtocol &p, qint32 id, const QByteArray &d) {
-       // FILE_OFFER — forward to user handler for display
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u != NULL) {
-         u->slotIncomingFileOffer(QString::fromUtf8(d.mid(4)));
-       }
-     }},
-    {"0019", [](CProtocol &p, qint32 id, const QByteArray &) { p.send(GET_AVATARIMAGE, id); }},
-    {"0021",
-     [](CProtocol &p, qint32 id, const QByteArray &d) {
-       // FILE_OFFER_ACCEPTED — recipient accepted; start the file transfer
-       QString fileName = QString::fromUtf8(d.mid(4));
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u == NULL)
-         return;
-       QString filePath = u->takeAcceptedFileOffer(fileName);
-       if (!filePath.isEmpty()) {
-         p.mCore.getFileTransferManager()->addNewFileTransfer(filePath, u->getI2PDestination());
-       }
-     }},
-    {"0022",
-     [](CProtocol &p, qint32 id, const QByteArray &d) {
-       // FILE_OFFER_REJECTED — recipient rejected
-       QString fileName = QString::fromUtf8(d.mid(4));
-       CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
-       if (u != NULL) {
-         u->slotIncomingMessageFromSystem(u->tr("File offer for \"%1\" was rejected by the recipient.").arg(fileName));
-         u->removeFileOffer(fileName);
-       }
-     }},
-  };
-
-  auto it2 = protoHandlers.constFind(tag);
+  typedef void (*ProtoFn)(CProtocol &, qint32, const QByteArray &);
+  static QHash<QString, ProtoFn> protoHandlers;
+  if (protoHandlers.isEmpty()) {
+    protoHandlers.insert("0015", [](CProtocol &p, qint32 id, const QByteArray &) {
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u != NULL) {
+        p.mCore.deletePacketManagerByID(id);
+        if (p.mCore.getConnectionManager()->isComponentStopped() == false)
+          p.mCore.getConnectionManager()->doDestroyStreamObjectByID(id);
+        u->setConnectionStatus(OFFLINE);
+      }
+    });
+    protoHandlers.insert("0016", [](CProtocol &p, qint32 id, const QByteArray &) {
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u != NULL) {
+        u->setOnlineState(USERBLOCKEDYOU);
+        u->setConnectionStatus(OFFLINE);
+        p.mCore.deletePacketManagerByID(id);
+        if (p.mCore.getConnectionManager()->isComponentStopped() == false)
+          p.mCore.getConnectionManager()->doDestroyStreamObjectByID(id);
+      }
+    });
+    protoHandlers.insert("0019", [](CProtocol &p, qint32 id, const QByteArray &) {
+      p.send(GET_AVATARIMAGE, id);
+    });
+    protoHandlers.insert("0020", [](CProtocol &p, qint32 id, const QByteArray &d) {
+      // FILE_OFFER — forward to user handler for display
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u != NULL)
+        u->slotIncomingFileOffer(QString::fromUtf8(d.mid(4)));
+    });
+    protoHandlers.insert("0021", [](CProtocol &p, qint32 id, const QByteArray &d) {
+      // FILE_OFFER_ACCEPTED — recipient accepted; start the file transfer
+      QString fileName = QString::fromUtf8(d.mid(4));
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u == NULL)
+        return;
+      QString filePath = u->takeAcceptedFileOffer(fileName);
+      if (!filePath.isEmpty())
+        p.mCore.getFileTransferManager()->addNewFileTransfer(filePath, u->getI2PDestination());
+    });
+    protoHandlers.insert("0022", [](CProtocol &p, qint32 id, const QByteArray &d) {
+      // FILE_OFFER_REJECTED — recipient rejected
+      QString fileName = QString::fromUtf8(d.mid(4));
+      CUser *u = p.mCore.getUserManager()->getUserByI2P_ID(id);
+      if (u != NULL) {
+        u->slotIncomingMessageFromSystem(u->tr("File offer for \"%1\" was rejected by the recipient.").arg(fileName));
+        u->removeFileOffer(fileName);
+      }
+    });
+  }
+
+  QHash<QString, ProtoFn>::const_iterator it2 = protoHandlers.constFind(tag);
   if (it2 != protoHandlers.constEnd())
     it2.value()(*this, ID, Data);
 }
@@ -459,7 +451,7 @@ void CProtocol::handleChatProtocolPacket(const qint32 ID, const QByteArray &Data
                 << "CProtocol::handleChatProtocolPacket"
                 << "\nMessage:\t"
                 << "Can't convert QString to double"
-                << "\nQString:\t" << version << Qt::endl;
+                << "\nQString:\t" << version << endl;
   }
 
   if (ID < 0) {
@@ -499,7 +491,7 @@ void CProtocol::handleChatProtocolPacket(const qint32 ID, const QByteArray &Data
       return;
     }
     if (requestAuth) {
-      emit mCore.signIncomingUserAuthorizationRequest(stream->getDestination(), ID, Data);
+      mCore.emitIncomingUserAuthorizationRequest(stream->getDestination(), ID, Data);
       return;
     }
 
diff --git a/src/backend/SessionController.cpp b/src/backend/SessionController.cpp
index a973929..55eb18c 100644
--- a/src/backend/SessionController.cpp
+++ b/src/backend/SessionController.cpp
@@ -133,15 +133,15 @@ void CSessionController::slotReadFromSocket() {
           msgBox.setWindowModality(Qt::NonModal);
           msgBox.exec();
 
-          qCritical() << "File\t" << __FILE__ << Qt::endl
-                      << "Line:\t" << __LINE__ << Qt::endl
+          qCritical() << "File\t" << __FILE__ << endl
+                      << "Line:\t" << __LINE__ << endl
                       << "Function:\t"
-                      << "CStreamController::slotReadFromSocket()" << Qt::endl
+                      << "CStreamController::slotReadFromSocket()" << endl
                       << "Message:\t"
-                      << "Session: DUPLICATED_DEST" << Qt::endl
+                      << "Session: DUPLICATED_DEST" << endl
                       << "Only one Messenger per Destination,\nor SAMv3 "
                          "crashed (Tunnel will persist if I2PChat was closed)"
-                      << Qt::endl;
+                      << endl;
         }
 
         emit signSessionStreamStatusOK(false);
diff --git a/src/backend/TextEmotionChanger.cpp b/src/backend/TextEmotionChanger.cpp
index d343648..9f0f960 100644
--- a/src/backend/TextEmotionChanger.cpp
+++ b/src/backend/TextEmotionChanger.cpp
@@ -153,7 +153,7 @@ void CTextEmotionChanger::setEmoticonPath(const QString &path) {
                 int width = 16;
                 int height = width;
                 image = image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
-                QString text = emoticonString.text().toHtmlEscaped();
+                QString text = Qt::escape(emoticonString.text());
                 m_urls.insert(text,
                               QString("<img src=\"%1\" width=\"%2\" "
                                       "height=\"%2\" alt=\"%1\" title=\"%1\"/>")
diff --git a/src/backend/User.cpp b/src/backend/User.cpp
index b70dc86..8479da3 100644
--- a/src/backend/User.cpp
+++ b/src/backend/User.cpp
@@ -211,7 +211,7 @@ void CUser::slotIncomingFileOffer(const QString &data) {
                 tr("Offers file: %1 (%2 %3) "
                    "<a href=\"fileoffer:accept:%4\">[Accept]</a> "
                    "<a href=\"fileoffer:reject:%4\">[Reject]</a><br>")
-                  .arg(fileName, sizeStr, sizeType, fileName.toHtmlEscaped());
+                  .arg(fileName, sizeStr, sizeType, Qt::escape(fileName));
 
   mAllMessages.push_back(msg);
   mNewMessages.push_back(msg);
@@ -510,13 +510,13 @@ double CUser::getProtocolVersion_D() const {
   double tmp = mProtocolVersion.toDouble(&OK);
 
   if (OK == false) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CUser::getProtocolVersion_D" << Qt::endl
+                << "CUser::getProtocolVersion_D" << endl
                 << "Message:\t"
-                << "Can't convert QString to double" << Qt::endl
-                << "QString:\t" << mProtocolVersion << Qt::endl;
+                << "Can't convert QString to double" << endl
+                << "QString:\t" << mProtocolVersion << endl;
   }
   return tmp;
 }
@@ -526,13 +526,13 @@ double CUser::getMaxProtocolVersionFiletransfer_D() const {
   double tmp = mMaxProtocolVersionFiletransfer.toDouble(&OK);
 
   if (OK == false) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CUser::getMaxProtocolVersionFiletransfer_D" << Qt::endl
+                << "CUser::getMaxProtocolVersionFiletransfer_D" << endl
                 << "Message\t"
-                << "Can't convert QString to double" << Qt::endl
-                << "QString:\t" << mMaxProtocolVersionFiletransfer << Qt::endl;
+                << "Can't convert QString to double" << endl
+                << "QString:\t" << mMaxProtocolVersionFiletransfer << endl;
   }
   return tmp;
 }
@@ -542,13 +542,13 @@ double CUser::getMinProtocolVersionFiletransfer_D() const {
   double tmp = mMinProtocolVersionFiletransfer.toDouble(&OK);
 
   if (OK == false) {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CUser::getMinProtocolVersionFiletransfer_D" << Qt::endl
+                << "CUser::getMinProtocolVersionFiletransfer_D" << endl
                 << "Message:\t"
-                << "Can't convert QString to double" << Qt::endl
-                << "QString:\t" << mMinProtocolVersionFiletransfer << Qt::endl;
+                << "Can't convert QString to double" << endl
+                << "QString:\t" << mMinProtocolVersionFiletransfer << endl;
   }
   return tmp;
 }
@@ -576,11 +576,11 @@ void CUser::setReceivedUserInfos(RECEIVEDINFOS Tag, const QString &value) {
     bool OK = false;
     mReceivedUserInfos.Age = value.toInt(&OK);
     if (OK == false) {
-      qCritical() << "File\t" << __FILE__ << Qt::endl
-                  << "Line:\t" << __LINE__ << Qt::endl
+      qCritical() << "File\t" << __FILE__ << endl
+                  << "Line:\t" << __LINE__ << endl
                   << "Function:\t"
-                  << "Can't convert QString to qint32" << Qt::endl
-                  << "QString:\t" << value << Qt::endl;
+                  << "Can't convert QString to qint32" << endl
+                  << "QString:\t" << value << endl;
     }
     break;
   }
@@ -589,12 +589,12 @@ void CUser::setReceivedUserInfos(RECEIVEDINFOS Tag, const QString &value) {
     break;
   }
   default: {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "CUser::setReceivedUserInfos" << Qt::endl
+               << "CUser::setReceivedUserInfos" << endl
                << "Message:\t"
-               << "unknown Tag" << Qt::endl;
+               << "unknown Tag" << endl;
     break;
   }
   }
@@ -604,12 +604,12 @@ void CUser::setReceivedNicknameToUserNickname() {
   if (getProtocolVersion_D() >= 0.3) {
     mReceivedNicknameToUserNickname = true;
   } else {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "setReceivedNicknameToUserNickname" << Qt::endl
+               << "setReceivedNicknameToUserNickname" << endl
                << "Message:\t"
-               << "Protocolversion <0.3, action ignored" << Qt::endl;
+               << "Protocolversion <0.3, action ignored" << endl;
   }
 }
 
@@ -630,12 +630,12 @@ void CUser::setReplaceB32WithB64(QString b64Dest) {
     QString &dest = const_cast<QString &>(mI2PDestination);
     dest = std::move(b64Dest);
   } else {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CUser::setReplaceB32WithB64" << Qt::endl
+                << "CUser::setReplaceB32WithB64" << endl
                 << "Message:\t"
-                << "Current Destination is not a b32 dest" << Qt::endl;
+                << "Current Destination is not a b32 dest" << endl;
   }
 }
 
diff --git a/src/backend/UserBlockManager.cpp b/src/backend/UserBlockManager.cpp
index a63c426..eff775f 100644
--- a/src/backend/UserBlockManager.cpp
+++ b/src/backend/UserBlockManager.cpp
@@ -62,9 +62,9 @@ void CUserBlockManager::saveBlockListe() {
     i.next();
     CUserBlockEntity *currentEntity = i.value();
 
-    out << "NickName:\t" << currentEntity->mNickName << Qt::endl
-        << "Destination:\t" << currentEntity->mDestination << Qt::endl
-        << "BlockDate:\t" << currentEntity->mBlockDate << Qt::endl;
+    out << "NickName:\t" << currentEntity->mNickName << endl
+        << "Destination:\t" << currentEntity->mDestination << endl
+        << "BlockDate:\t" << currentEntity->mBlockDate << endl;
   }
   out.flush();
   file.close();
@@ -79,14 +79,14 @@ void CUserBlockManager::addNewBlockEntity(const QString &NickName,
 
   if (mUserBlockMap.contains(Destination) == true) {
     // do nothing allready blocked ?
-    qDebug() << "File\t" << __FILE__ << Qt::endl
-             << "Line:\t" << __LINE__ << Qt::endl
+    qDebug() << "File\t" << __FILE__ << endl
+             << "Line:\t" << __LINE__ << endl
              << "Function:\t"
-             << "cUserBlockManager::addNewBlockEntity" << Qt::endl
+             << "cUserBlockManager::addNewBlockEntity" << endl
              << "Message:\t"
-             << "Destination: " << Destination << Qt::endl
-             << "is allready in the Blocklist" << Qt::endl
-             << "Action Aborted" << Qt::endl;
+             << "Destination: " << Destination << endl
+             << "is allready in the Blocklist" << endl
+             << "Action Aborted" << endl;
   } else {
     if (BlockDate.isEmpty()) {
       CUserBlockEntity *tmp = new CUserBlockEntity(NickName, Destination);
@@ -133,14 +133,14 @@ void CUserBlockManager::removeBlockEntity(const QString &Destination, bool Creat
     }
 
   } else {
-    qDebug() << "File\t" << __FILE__ << Qt::endl
-             << "Line:\t" << __LINE__ << Qt::endl
+    qDebug() << "File\t" << __FILE__ << endl
+             << "Line:\t" << __LINE__ << endl
              << "Function:\t"
-             << "CUserBlockManager::removeBlockEntity" << Qt::endl
+             << "CUserBlockManager::removeBlockEntity" << endl
              << "Message:\t"
-             << "Destination: " << Destination << Qt::endl
-             << "isn't in the Blocklist" << Qt::endl
-             << "Action Aborted" << Qt::endl;
+             << "Destination: " << Destination << endl
+             << "isn't in the Blocklist" << endl
+             << "Action Aborted" << endl;
   }
   saveBlockListe();
 }
diff --git a/src/backend/UserManager.cpp b/src/backend/UserManager.cpp
index 3b3e3dd..6b247de 100644
--- a/src/backend/UserManager.cpp
+++ b/src/backend/UserManager.cpp
@@ -115,12 +115,12 @@ void CUserManager::saveUserList() {
       InvisibleText = "false";
     }
 
-    out << "Nick:\t" << (mUsers.at(i)->getName()) << Qt::endl
-        << "I2PDest:\t" << (mUsers.at(i)->getI2PDestination()) << Qt::endl
-        << "Invisible:\t" << InvisibleText << Qt::endl
-        << "DateAdded:\t" << mUsers.at(i)->getDateAdded().toString(Qt::ISODate) << Qt::endl
-        << "LastCommunication:\t" << mUsers.at(i)->getLastCommunication().toString(Qt::ISODate) << Qt::endl
-        << "LastOnline:\t" << mUsers.at(i)->getLastOnline().toString(Qt::ISODate) << Qt::endl;
+    out << "Nick:\t" << (mUsers.at(i)->getName()) << endl
+        << "I2PDest:\t" << (mUsers.at(i)->getI2PDestination()) << endl
+        << "Invisible:\t" << InvisibleText << endl
+        << "DateAdded:\t" << mUsers.at(i)->getDateAdded().toString(Qt::ISODate) << endl
+        << "LastCommunication:\t" << mUsers.at(i)->getLastCommunication().toString(Qt::ISODate) << endl
+        << "LastOnline:\t" << mUsers.at(i)->getLastOnline().toString(Qt::ISODate) << endl;
 
     // save unsent items for this users
     const QString Dest = mUsers.at(i)->getI2PDestination();
@@ -286,14 +286,14 @@ bool CUserManager::addNewUser(QString Name, QString I2PDestination, qint32 I2PSt
   bool isValid = validateI2PDestination(I2PDestination);
 
   auto critical = [&I2PDestination](const QString &why = "undefined") {
-    qCritical() << "File\t" << __FILE__ << Qt::endl
-                << "Line:\t" << __LINE__ << Qt::endl
+    qCritical() << "File\t" << __FILE__ << endl
+                << "Line:\t" << __LINE__ << endl
                 << "Function:\t"
-                << "CUserManager::addNewUser" << Qt::endl
+                << "CUserManager::addNewUser" << endl
                 << "Message:\t"
-                << "Destination is not valid" << Qt::endl
-                << "Destination:\t" << I2PDestination << Qt::endl
-                << why << Qt::endl;
+                << "Destination is not valid" << endl
+                << "Destination:\t" << I2PDestination << endl
+                << why << endl;
     return false;
   };
   if (isValid == false) {
@@ -350,7 +350,7 @@ bool CUserManager::checkIfUserExistsByI2PDestination(const QString &I2PDestinati
   return false;
 }
 void CUserManager::changeUserPositionInUserList(int oldPos, int newPos) {
-  mUsers.swapItemsAt(oldPos, newPos);
+  qSwap(mUsers[oldPos], mUsers[newPos]);
   saveUserList();
   emit signUserStatusChanged();
 }
@@ -459,12 +459,12 @@ void CUserManager::slotSaveUnsentMessageForDest(const QString &I2PDest) {
     const QStringList Offers = theUser->getUnsentedFileOffers();
     mUnsentMessageStorage.saveFileOffersForDest(I2PDest, Offers);
   } else {
-    qWarning() << "File\t" << __FILE__ << Qt::endl
-               << "Line:\t" << __LINE__ << Qt::endl
+    qWarning() << "File\t" << __FILE__ << endl
+               << "Line:\t" << __LINE__ << endl
                << "Function:\t"
-               << "CUserManager::slotSaveUnsentMessageForDest" << Qt::endl
+               << "CUserManager::slotSaveUnsentMessageForDest" << endl
                << "Message:\t"
-               << "No User found with this destination" << Qt::endl
-               << "I2PDest.:\t" << I2PDest << Qt::endl;
+               << "No User found with this destination" << endl
+               << "I2PDest.:\t" << I2PDest << endl;
   }
 }
diff --git a/src/backend/UserManager.h b/src/backend/UserManager.h
index 1c34cdd..4628787 100644
--- a/src/backend/UserManager.h
+++ b/src/backend/UserManager.h
@@ -9,6 +9,7 @@
 
 #include <QObject>
 #include <QRegExp>
+
 static const QRegExp nicknameRegExp("^[a-zA-Z0-9_ ]{1,12}$");
 
 class CUserManager : public QObject {
diff --git a/src/gui/form_Main.cpp b/src/gui/form_Main.cpp
index ba9fd20..03a029a 100644
--- a/src/gui/form_Main.cpp
+++ b/src/gui/form_Main.cpp
@@ -9,6 +9,12 @@
 #include <QMessageBox>
 #include <QSystemTrayIcon>
 
+#ifdef USE_OPENSSL_SHA256
+#include <openssl/evp.h>
+#else
+#include <QCryptographicHash>
+#endif
+
 form_MainWindow::form_MainWindow(const QString &configDir, QWidget *parent)
   : QMainWindow(parent) {
   setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint |
@@ -784,7 +790,15 @@ void form_MainWindow::copyB32() {
   while (outputcount > qarraysha256hash.size()) {
     qarraysha256hash.append((char)0);
   }
+#ifdef USE_OPENSSL_SHA256
+  QByteArray sha256hash(EVP_MAX_MD_SIZE, 0);
+  unsigned int digestLen = 0;
+  EVP_Digest(qarraysha256hash.constData(), qarraysha256hash.size(),
+             (unsigned char *)sha256hash.data(), &digestLen, EVP_sha256(), NULL);
+  sha256hash.resize(digestLen);
+#else
   QByteArray sha256hash = QCryptographicHash::hash(qarraysha256hash, QCryptographicHash::Sha256);
+#endif
   i2p::data::ByteStreamToBase32((uint8_t *)sha256hash.data(), sha256hash.size(), b32buffer, 52);
   b32buffer[52] = '\0';
   QString Address = "http://" + QString(b32buffer) + ".b32.i2p";
diff --git a/src/gui/form_Main.ui b/src/gui/form_Main.ui
index 06cb1d0..5122f22 100644
--- a/src/gui/form_Main.ui
+++ b/src/gui/form_Main.ui
@@ -93,9 +93,6 @@ QListView{padding:1px;}</string>
       <property name="frameShadow">
        <enum>QFrame::Plain</enum>
       </property>
-      <property name="sizeAdjustPolicy">
-       <enum>QAbstractScrollArea::AdjustToContents</enum>
-      </property>
       <property name="autoScrollMargin">
        <number>0</number>
       </property>
diff --git a/src/gui/form_chatwidget.cpp b/src/gui/form_chatwidget.cpp
index ddf0cb7..7944f6d 100644
--- a/src/gui/form_chatwidget.cpp
+++ b/src/gui/form_chatwidget.cpp
@@ -4,7 +4,7 @@
 
 #include <QErrorMessage>
 #include <QFile>
-#include <QRegularExpression>
+#include <QRegExp>
 #include <QXmlStreamReader>
 
 bool ChatEventEater::eventFilter(QObject *obj, QEvent *event) {
@@ -369,7 +369,7 @@ void form_ChatWidget::anchorClicked(const QUrl &link) {
       return;
 
     QString action = parts.at(1);
-    QString fileName = parts.mid(2).join(":"); // Restore filename if it contained colons
+    QString fileName = QStringList(parts.mid(2)).join(":"); // Restore filename if it contained colons
 
     if (action == "accept") {
       // Send acceptance over chat protocol
@@ -536,8 +536,9 @@ void form_ChatWidget::messageTextChanged() {
   }
   message->setTextCursor(tmpCursor);
 }
+
 void form_ChatWidget::centerDialog() {
-  QRect scr = QGuiApplication::primaryScreen()->geometry();
+  QRect scr = QApplication::desktop()->screenGeometry();
   move(scr.center() - rect().center());
 }
 
diff --git a/src/gui/form_settingsgui.cpp b/src/gui/form_settingsgui.cpp
index 0d3aba8..5024498 100644
--- a/src/gui/form_settingsgui.cpp
+++ b/src/gui/form_settingsgui.cpp
@@ -9,6 +9,12 @@
 #include <QDebug>
 #include <QFileDialog>
 
+#ifdef USE_OPENSSL_SHA256
+#include <openssl/evp.h>
+#else
+#include <QCryptographicHash>
+#endif
+
 form_settingsgui::form_settingsgui(CCore &Core, QWidget *parent, Qt::WindowFlags flags)
   : QDialog(parent, flags)
   , mCore(Core)
@@ -392,17 +398,25 @@ void form_settingsgui::loadSettings() {
     while (outputcount > qarraysha256hash.size()) {
       qarraysha256hash.append((char)0);
     }
+#ifdef USE_OPENSSL_SHA256
+    sha256hash.resize(EVP_MAX_MD_SIZE);
+    unsigned int digestLen = 0;
+    EVP_Digest(qarraysha256hash.constData(), qarraysha256hash.size(),
+               (unsigned char *)sha256hash.data(), &digestLen, EVP_sha256(), NULL);
+    sha256hash.resize(digestLen);
+#else
     sha256hash = QCryptographicHash::hash(qarraysha256hash, QCryptographicHash::Sha256);
+#endif
     i2p::data::ByteStreamToBase32((uint8_t *)sha256hash.data(), sha256hash.size(), b32buffer, 52);
     b32buffer[52] = '\0';
     QString strb32address = "http://" + QString(b32buffer) + ".b32.i2p";
     b32address->setPlainText(
-      QApplication::translate("form_settingsgui", strb32address.toUtf8().constData(), Q_NULLPTR));
+      QApplication::translate("form_settingsgui", strb32address.toUtf8().constData(), 0));
     free(outputbuffer);
     free(b32buffer);
   } else {
     b32address->setPlainText(
-      QApplication::translate("form_settingsgui", "b32 address will be displayed when online", Q_NULLPTR));
+      QApplication::translate("form_settingsgui", "b32 address will be displayed when online", 0));
   }
 
   settings->beginGroup("Usersearch");
@@ -549,7 +563,7 @@ void form_settingsgui::saveSettings() {
   mCore.getUserManager()->avatarImageChanged();
 
   // Force update nickname display in main window
-  emit mCore.signNicknameChanged();
+  mCore.emitNicknameChanged();
 
   // Refresh avatar display in config panel AFTER avatar update signals have been sent
   QPixmap tmpPixmap;
diff --git a/src/gui/form_settingsgui.ui b/src/gui/form_settingsgui.ui
index 518fadd..6738629 100644
--- a/src/gui/form_settingsgui.ui
+++ b/src/gui/form_settingsgui.ui
@@ -476,9 +476,6 @@ p, li { white-space: pre-wrap; }
           <property name="autoFillBackground">
            <bool>true</bool>
           </property>
-          <property name="clearButtonEnabled">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item row="0" column="1" alignment="Qt::AlignRight">
@@ -996,9 +993,6 @@ p, li { white-space: pre-wrap; }
         </item>
         <item row="0" column="1" alignment="Qt::AlignVCenter">
          <widget class="QLineEdit" name="lineEdit">
-          <property name="clearButtonEnabled">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
        </layout>
@@ -1071,9 +1065,6 @@ p, li { white-space: pre-wrap; }
         </item>
         <item row="0" column="1" alignment="Qt::AlignVCenter">
          <widget class="QLineEdit" name="lineEdit_3">
-          <property name="clearButtonEnabled">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item row="0" column="2">
@@ -1617,9 +1608,6 @@ border-radius: 2px;
             <height>16777215</height>
            </size>
           </property>
-          <property name="clearButtonEnabled">
-           <bool>true</bool>
-          </property>
          </widget>
         </item>
         <item row="1" column="1" colspan="2" alignment="Qt::AlignRight|Qt::AlignVCenter">
