X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmonoapplication.cpp;fp=src%2Fqtui%2Fmonoapplication.cpp;h=0000000000000000000000000000000000000000;hp=068ec711e1bd6c388c23140cac712c5f76ddf024;hb=4ce53949ab7d52a49ae79b8817bd3aa50fada0d1;hpb=48d41896ba35eafc64b4cb00e446d6123b3502cb diff --git a/src/qtui/monoapplication.cpp b/src/qtui/monoapplication.cpp deleted file mode 100644 index 068ec711..00000000 --- a/src/qtui/monoapplication.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * - * devel@quassel-irc.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "monoapplication.h" -#include "coreapplication.h" -#include "client.h" -#include "core.h" -#include "internalpeer.h" -#include "logmessage.h" -#include "qtui.h" - -class InternalPeer; - -MonolithicApplication::MonolithicApplication(int &argc, char **argv) - : QtUiApplication(argc, argv) -{ -} - - -void MonolithicApplication::init() -{ - QtUiApplication::init(); - - connect(Client::coreConnection(), SIGNAL(connectToInternalCore(QPointer)), this, SLOT(onConnectionRequest(QPointer))); - - // If port is set, start internal core directly so external clients can connect - // This is useful in case the mono client re-gains remote connection capability, - // in which case the internal core would not have to be started by default. - if (Quassel::isOptionSet("port")) { - startInternalCore(); - } -} - - -Quassel::QuitHandler MonolithicApplication::quitHandler() -{ - return [this]() { - quInfo() << "Client shutting down..."; - connect(_client.get(), SIGNAL(destroyed()), this, SLOT(onClientDestroyed())); - _client.release()->deleteLater(); - }; -} - - -void MonolithicApplication::onClientDestroyed() -{ - if (_core) { - connect(_core, SIGNAL(shutdownComplete()), this, SLOT(onCoreShutdown())); - _core->shutdown(); - } - else { - QCoreApplication::quit(); - } -} - - -void MonolithicApplication::onCoreShutdown() -{ - if (_core) { - connect(_core, SIGNAL(destroyed()), QCoreApplication::instance(), SLOT(quit())); - _coreThread.quit(); - _coreThread.wait(); - } - else { - QCoreApplication::quit(); - } -} - - -void MonolithicApplication::startInternalCore() -{ - if (_core) { - // Already started - return; - } - - // Start internal core in a separate thread, so it doesn't block the UI - _core = new Core{}; - _core->moveToThread(&_coreThread); - connect(&_coreThread, SIGNAL(started()), _core, SLOT(initAsync())); - connect(&_coreThread, SIGNAL(finished()), _core, SLOT(deleteLater())); - - connect(this, SIGNAL(connectInternalPeer(QPointer)), _core, SLOT(connectInternalPeer(QPointer))); - connect(_core, SIGNAL(sessionState(Protocol::SessionState)), Client::coreConnection(), SLOT(internalSessionStateReceived(Protocol::SessionState))); - - connect(_core, SIGNAL(dbUpgradeInProgress(bool)), Client::instance(), SLOT(onDbUpgradeInProgress(bool))); - connect(_core, SIGNAL(exitRequested(int,QString)), Client::instance(), SLOT(onExitRequested(int,QString))); - - _coreThread.start(); -} - - -void MonolithicApplication::onConnectionRequest(QPointer peer) -{ - if (!_core) { - startInternalCore(); - } - - // While starting the core may take a while, the object itself is instantiated synchronously and the connections - // established, so it's safe to emit this immediately. The core will take care of queueing the request until - // initialization is complete. - emit connectInternalPeer(peer); -}