diff --git a/src/app/App.cpp b/src/app/App.cpp index 37dce01c5..bc89cb013 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -141,6 +141,7 @@ inline void activeSplashScreen (QQmlApplicationEngine *engine) { void App::initContentApp () { shared_ptr config = ::getConfigIfExists(*mParser); + bool mustBeIconified = false; // Destroy qml components and linphone core if necessary. if (mEngine) { @@ -168,6 +169,8 @@ void App::initContentApp () { // Add plugins directory. addLibraryPath(::Utils::coreStringToAppString(Paths::getPluginsDirPath())); qInfo() << QStringLiteral("Library paths:") << libraryPaths(); + + mustBeIconified = mParser->isSet("iconified"); } // Init core. @@ -176,8 +179,12 @@ void App::initContentApp () { // Execute command argument if needed. if (!mEngine) { const QString commandArgument = getCommandArgument(); - if (!commandArgument.isEmpty()) - mCli->executeCommand(commandArgument); + if (!commandArgument.isEmpty()) { + Cli::CommandFormat format; + mCli->executeCommand(commandArgument, &format); + if (format==Cli::UriFormat) + mustBeIconified = true; + } } // Init engine content. @@ -212,7 +219,7 @@ void App::initContentApp () { #ifdef Q_OS_MACOS ::activeSplashScreen(mEngine); #else - if (!mParser->isSet("iconified")) + if (!mustBeIconified) ::activeSplashScreen(mEngine); #endif // ifdef Q_OS_MACOS @@ -224,8 +231,9 @@ void App::initContentApp () { QObject::connect( CoreManager::getInstance()->getHandlers().get(), - &CoreHandlers::coreStarted, - this, &App::openAppAfterInit + &CoreHandlers::coreStarted, [this, mustBeIconified] () { + openAppAfterInit(mustBeIconified); + } ); } @@ -526,7 +534,7 @@ QString App::getLocale () const { // ----------------------------------------------------------------------------- -void App::openAppAfterInit () { +void App::openAppAfterInit (bool mustBeIconified) { qInfo() << QStringLiteral("Open linphone app."); QQuickWindow *mainWindow = getMainWindow(); @@ -538,7 +546,7 @@ void App::openAppAfterInit () { else setTrayIcon(); - if (!mParser->isSet("iconified")) + if (!mustBeIconified) smartShowWindow(mainWindow); #else smartShowWindow(mainWindow); diff --git a/src/app/App.hpp b/src/app/App.hpp index dfe0b732c..400748360 100644 --- a/src/app/App.hpp +++ b/src/app/App.hpp @@ -119,7 +119,7 @@ private: return mAvailableLocales; } - void openAppAfterInit (); + void openAppAfterInit (bool mustBeIconified = false); static void checkForUpdate (); diff --git a/src/app/cli/Cli.cpp b/src/app/cli/Cli.cpp index 9e74e7861..8b03aa0db 100644 --- a/src/app/cli/Cli.cpp +++ b/src/app/cli/Cli.cpp @@ -189,7 +189,7 @@ void Cli::addCommand ( // ----------------------------------------------------------------------------- -void Cli::executeCommand (const QString &command) const { +void Cli::executeCommand (const QString &command, CommandFormat *format) const { shared_ptr address = linphone::Factory::get()->createAddress( ::Utils::appStringToCoreString(command) ); @@ -202,10 +202,18 @@ void Cli::executeCommand (const QString &command) const { mCommands[functionName].execute(args); } + if (format) + *format = CliFormat; + return; } + if (format) + *format = UriFormat; + // Execute uri command. + qInfo() << QStringLiteral("Execute uri command: `%1`.").arg(command); + string scheme = address->getScheme(); if (address->getUsername().empty() || (scheme != "sip" && scheme != "sip-linphone")) { qWarning() << QStringLiteral("Not a valid uri: `%1`.").arg(command); diff --git a/src/app/cli/Cli.hpp b/src/app/cli/Cli.hpp index 299b8fcb6..82c25ad8a 100644 --- a/src/app/cli/Cli.hpp +++ b/src/app/cli/Cli.hpp @@ -77,7 +77,13 @@ public: Cli (QObject *parent = Q_NULLPTR); ~Cli () = default; - void executeCommand (const QString &command) const; + enum CommandFormat { + UnknownFormat, + CliFormat, + UriFormat + }; + + void executeCommand (const QString &command, CommandFormat *format = nullptr) const; private: void addCommand (