-void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
- if(!msg.contains("MsgType")) {
- // Client is way too old, does not even use the current init format
- qWarning() << qPrintable(tr("Antique client trying to connect... refusing."));
- socket->close();
- return;
- }
- // OK, so we have at least an init message format we can understand
- if(msg["MsgType"] == "ClientInit") {
- QVariantMap reply;
-
- // Just version information -- check it!
- uint ver = msg["ProtocolVersion"].toUInt();
- if(ver < Quassel::buildInfo().coreNeedsProtocol) {
- reply["MsgType"] = "ClientInitReject";
- reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
- "This core needs at least client/core protocol version %1.<br>"
- "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
- SignalProxy::writeDataToDevice(socket, reply);
- qWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
- socket->close(); return;
- }
-
- reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
- reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
- reply["CoreDate"] = Quassel::buildInfo().buildDate;
- reply["CoreStartTime"] = startTime(); // v10 clients don't necessarily parse this, see below
-
- // FIXME: newer clients no longer use the hardcoded CoreInfo (for now), since it gets the
- // time zone wrong. With the next protocol bump (10 -> 11), we should remove this
- // or make it properly configurable.
-
- int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
- int updays = uptime / 86400; uptime %= 86400;
- int uphours = uptime / 3600; uptime %= 3600;
- int upmins = uptime / 60;
- reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
- "Built: %2<br>"
- "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
- .arg(Quassel::buildInfo().buildDate)
- .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
-
- reply["CoreFeatures"] = (int)Quassel::features();
+// FIXME: Apparently, this is the legacy way of initting storage backends?
+// If there's a not-legacy way, it should be used here
+bool Core::initAuthenticator(
+ const QString& backend, const QVariantMap& settings, const QProcessEnvironment& environment, bool loadFromEnvironment, bool setup)
+{
+ if (backend.isEmpty()) {
+ qWarning() << "No authenticator selected!";
+ return false;
+ }
+
+ auto auth = authenticator(backend);
+ if (!auth) {
+ qCritical() << "Selected auth backend is not available:" << backend;
+ return false;
+ }
+
+ Authenticator::State authState = auth->init(settings, environment, loadFromEnvironment);
+ switch (authState) {
+ case Authenticator::NeedsSetup:
+ if (!setup)
+ return false; // trigger setup process
+ if (auth->setup(settings, environment, loadFromEnvironment))
+ return initAuthenticator(backend, settings, environment, loadFromEnvironment, false);
+ return false;
+
+ case Authenticator::NotAvailable:
+ if (!setup) {
+ // If initialization wasn't successful, we quit to keep from coming up unconfigured
+ throw ExitException{EXIT_FAILURE, tr("Selected auth backend %1 is not available.").arg(backend)};
+ }
+ qCritical() << "Selected auth backend is not available:" << backend;
+ return false;