ssl: Use QSslSocket directly to avoid redundant qobject_casts
[quassel.git] / src / core / coresession.cpp
index f4196b0..6c85605 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2019 by the Quassel Project                        *
+ *   Copyright (C) 2005-2020 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -22,8 +22,6 @@
 
 #include <utility>
 
-#include <QtScript>
-
 #include "core.h"
 #include "corebacklogmanager.h"
 #include "corebuffersyncer.h"
@@ -78,7 +76,6 @@ CoreSession::CoreSession(UserId uid, bool restoreState, bool strictIdentEnabled,
     , _sessionEventProcessor(new CoreSessionEventProcessor(this))
     , _ctcpParser(new CtcpParser(this))
     , _ircParser(new IrcParser(this))
-    , scriptEngine(new QScriptEngine(this))
     , _processMessages(false)
     , _ignoreListManager(this)
     , _highlightRuleManager(this)
@@ -121,7 +118,6 @@ CoreSession::CoreSession(UserId uid, bool restoreState, bool strictIdentEnabled,
     _coreInfo->setCoreData(data);
 
     loadSettings();
-    initScriptEngine();
 
     eventManager()->registerObject(ircParser(), EventManager::NormalPriority);
     eventManager()->registerObject(sessionEventProcessor(), EventManager::HighPriority);  // needs to process events *before* the stringifier!
@@ -211,11 +207,11 @@ void CoreSession::loadSettings()
 
     // migrate to db
     QList<IdentityId> ids = s.identityIds();
-    QList<NetworkInfo> networkInfos = Core::networks(user());
+    std::vector<NetworkInfo> networkInfos = Core::networks(user());
     for (IdentityId id : ids) {
         CoreIdentity identity(s.identity(id));
         IdentityId newId = Core::createIdentity(user(), identity);
-        QList<NetworkInfo>::iterator networkIter = networkInfos.begin();
+        auto networkIter = networkInfos.begin();
         while (networkIter != networkInfos.end()) {
             if (networkIter->identity == id) {
                 networkIter->identity = newId;
@@ -248,10 +244,8 @@ void CoreSession::saveSessionState() const
 
 void CoreSession::restoreSessionState()
 {
-    QList<NetworkId> nets = Core::connectedNetworks(user());
-    CoreNetwork* net = nullptr;
-    for (NetworkId id :  nets) {
-        net = network(id);
+    for (NetworkId id : Core::connectedNetworks(user())) {
+        auto net = network(id);
         Q_ASSERT(net);
         net->connectToIrc();
     }
@@ -363,7 +357,7 @@ void CoreSession::processMessageEvent(MessageEvent* event)
     });
 }
 
-QList<BufferInfo> CoreSession::buffers() const
+std::vector<BufferInfo> CoreSession::buffers() const
 {
     return Core::requestBuffers(user());
 }
@@ -532,35 +526,14 @@ Protocol::SessionState CoreSession::sessionState() const
     return Protocol::SessionState(identities, bufferInfos, networkIds);
 }
 
-void CoreSession::initScriptEngine()
-{
-    signalProxy()->attachSlot(SIGNAL(scriptRequest(QString)), this, &CoreSession::scriptRequest);
-    signalProxy()->attachSignal(this, &CoreSession::scriptResult);
-
-    // FIXME
-    // QScriptValue storage_ = scriptEngine->newQObject(storage);
-    // scriptEngine->globalObject().setProperty("storage", storage_);
-}
-
-void CoreSession::scriptRequest(QString script)
-{
-    emit scriptResult(scriptEngine->evaluate(script).toString());
-}
-
 /*** Identity Handling ***/
 void CoreSession::createIdentity(const Identity& identity, const QVariantMap& additional)
 {
-#ifndef HAVE_SSL
-    Q_UNUSED(additional)
-#endif
-
     CoreIdentity coreIdentity(identity);
-#ifdef HAVE_SSL
     if (additional.contains("KeyPem"))
         coreIdentity.setSslKey(additional["KeyPem"].toByteArray());
     if (additional.contains("CertPem"))
         coreIdentity.setSslCert(additional["CertPem"].toByteArray());
-#endif
     qDebug() << Q_FUNC_INFO;
     IdentityId id = Core::createIdentity(user(), coreIdentity);
     if (!id.isValid())
@@ -678,7 +651,6 @@ void CoreSession::removeNetwork(NetworkId id)
 
 void CoreSession::destroyNetwork(NetworkId id)
 {
-    QList<BufferId> removedBuffers = Core::requestBufferIdsForNetwork(user(), id);
     Network* net = _networks.take(id);
     if (net && Core::removeNetwork(user(), id)) {
         // make sure that all unprocessed RawMessages from this network are removed
@@ -692,7 +664,7 @@ void CoreSession::destroyNetwork(NetworkId id)
             }
         }
         // remove buffers from syncer
-        for (BufferId bufferId : removedBuffers) {
+        for (BufferId bufferId : Core::requestBufferIdsForNetwork(user(), id)) {
             _bufferSyncer->removeBuffer(bufferId);
         }
         emit networkRemoved(id);