diff --git a/src/app/App.cpp b/src/app/App.cpp index 727394650..577f16822 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -248,6 +248,7 @@ void App::initContentApp () { // Destroy qml components and linphone core if necessary. if (mEngine) { + setOpened(false); qInfo() << QStringLiteral("Restarting app..."); delete mEngine; @@ -799,6 +800,8 @@ void App::openAppAfterInit (bool mustBeIconified) { checkForUpdate(); #endif // ifdef ENABLE_UPDATE_CHECK + + setOpened(true); } // ----------------------------------------------------------------------------- diff --git a/src/app/App.hpp b/src/app/App.hpp index 432b60d1c..f57c8db75 100644 --- a/src/app/App.hpp +++ b/src/app/App.hpp @@ -84,6 +84,10 @@ public: bool hasFocus () const; + bool isOpened () const { + return mIsOpened; + } + static App *getInstance () { return static_cast(QApplication::instance()); } @@ -104,6 +108,8 @@ signals: void autoStartChanged (bool enabled); + void opened (bool status); + private: void createParser (); @@ -134,6 +140,13 @@ private: void openAppAfterInit (bool mustBeIconified = false); + void setOpened (bool status) { + if (mIsOpened != status) { + mIsOpened = status; + emit opened(mIsOpened); + } + } + static void checkForUpdate (); static QString getQtVersion () { @@ -158,6 +171,8 @@ private: Colors *mColors = nullptr; QSystemTrayIcon *mSystemTrayIcon = nullptr; + + bool mIsOpened = false; }; #endif // APP_H_ diff --git a/src/app/cli/Cli.cpp b/src/app/cli/Cli.cpp index 1e0f15dcf..9d1a9506a 100644 --- a/src/app/cli/Cli.cpp +++ b/src/app/cli/Cli.cpp @@ -275,13 +275,14 @@ void Cli::Command::execute (QHash &args) const { } // Execute! - CoreManager *coreManager = CoreManager::getInstance(); - - if (coreManager->started()) + App *app = App::getInstance(); + if (app->isOpened()) { + qInfo() << QStringLiteral("Execute command:") << args; (*mFunction)(args); - else { + } else { Function f = mFunction; - Utils::connectOnce(coreManager->getHandlers().get(), &CoreHandlers::coreStarted, coreManager, [f, args] { + Utils::connectOnce(app, &App::opened, app, [f, args] { + qInfo() << QStringLiteral("Execute deferred command:") << args; QHash fuckConst = args; (*f)(fuckConst); }); @@ -356,6 +357,8 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) { // Execute cli command. if (!address) { + qInfo() << QStringLiteral("Detecting cli command: `%1`...").arg(command); + const QString &functionName = parseFunctionName(command); if (!functionName.isEmpty()) { QHash args = parseArgs(command); @@ -372,7 +375,7 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) { *format = UriFormat; // Execute uri command. - qInfo() << QStringLiteral("Execute uri command: `%1`...").arg(command); + qInfo() << QStringLiteral("Detecting uri command: `%1`...").arg(command); if (address->getUsername().empty()) { qWarning() << QStringLiteral("Failed to execute command. No username given.");