Commit 55153d72 authored by nicolas's avatar nicolas

fix(Cli): no longer displays the main view when calling cli

parent f3152119
...@@ -141,6 +141,7 @@ inline void activeSplashScreen (QQmlApplicationEngine *engine) { ...@@ -141,6 +141,7 @@ inline void activeSplashScreen (QQmlApplicationEngine *engine) {
void App::initContentApp () { void App::initContentApp () {
shared_ptr<linphone::Config> config = ::getConfigIfExists(*mParser); shared_ptr<linphone::Config> config = ::getConfigIfExists(*mParser);
bool mustBeIconified = false;
// Destroy qml components and linphone core if necessary. // Destroy qml components and linphone core if necessary.
if (mEngine) { if (mEngine) {
...@@ -168,6 +169,8 @@ void App::initContentApp () { ...@@ -168,6 +169,8 @@ void App::initContentApp () {
// Add plugins directory. // Add plugins directory.
addLibraryPath(::Utils::coreStringToAppString(Paths::getPluginsDirPath())); addLibraryPath(::Utils::coreStringToAppString(Paths::getPluginsDirPath()));
qInfo() << QStringLiteral("Library paths:") << libraryPaths(); qInfo() << QStringLiteral("Library paths:") << libraryPaths();
mustBeIconified = mParser->isSet("iconified");
} }
// Init core. // Init core.
...@@ -176,8 +179,12 @@ void App::initContentApp () { ...@@ -176,8 +179,12 @@ void App::initContentApp () {
// Execute command argument if needed. // Execute command argument if needed.
if (!mEngine) { if (!mEngine) {
const QString commandArgument = getCommandArgument(); const QString commandArgument = getCommandArgument();
if (!commandArgument.isEmpty()) if (!commandArgument.isEmpty()) {
mCli->executeCommand(commandArgument); Cli::CommandFormat format;
mCli->executeCommand(commandArgument, &format);
if (format==Cli::UriFormat)
mustBeIconified = true;
}
} }
// Init engine content. // Init engine content.
...@@ -212,7 +219,7 @@ void App::initContentApp () { ...@@ -212,7 +219,7 @@ void App::initContentApp () {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
::activeSplashScreen(mEngine); ::activeSplashScreen(mEngine);
#else #else
if (!mParser->isSet("iconified")) if (!mustBeIconified)
::activeSplashScreen(mEngine); ::activeSplashScreen(mEngine);
#endif // ifdef Q_OS_MACOS #endif // ifdef Q_OS_MACOS
...@@ -224,8 +231,9 @@ void App::initContentApp () { ...@@ -224,8 +231,9 @@ void App::initContentApp () {
QObject::connect( QObject::connect(
CoreManager::getInstance()->getHandlers().get(), CoreManager::getInstance()->getHandlers().get(),
&CoreHandlers::coreStarted, &CoreHandlers::coreStarted, [this, mustBeIconified] () {
this, &App::openAppAfterInit openAppAfterInit(mustBeIconified);
}
); );
} }
...@@ -526,7 +534,7 @@ QString App::getLocale () const { ...@@ -526,7 +534,7 @@ QString App::getLocale () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void App::openAppAfterInit () { void App::openAppAfterInit (bool mustBeIconified) {
qInfo() << QStringLiteral("Open linphone app."); qInfo() << QStringLiteral("Open linphone app.");
QQuickWindow *mainWindow = getMainWindow(); QQuickWindow *mainWindow = getMainWindow();
...@@ -538,7 +546,7 @@ void App::openAppAfterInit () { ...@@ -538,7 +546,7 @@ void App::openAppAfterInit () {
else else
setTrayIcon(); setTrayIcon();
if (!mParser->isSet("iconified")) if (!mustBeIconified)
smartShowWindow(mainWindow); smartShowWindow(mainWindow);
#else #else
smartShowWindow(mainWindow); smartShowWindow(mainWindow);
......
...@@ -119,7 +119,7 @@ private: ...@@ -119,7 +119,7 @@ private:
return mAvailableLocales; return mAvailableLocales;
} }
void openAppAfterInit (); void openAppAfterInit (bool mustBeIconified = false);
static void checkForUpdate (); static void checkForUpdate ();
......
...@@ -189,7 +189,7 @@ void Cli::addCommand ( ...@@ -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<linphone::Address> address = linphone::Factory::get()->createAddress( shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
::Utils::appStringToCoreString(command) ::Utils::appStringToCoreString(command)
); );
...@@ -202,10 +202,18 @@ void Cli::executeCommand (const QString &command) const { ...@@ -202,10 +202,18 @@ void Cli::executeCommand (const QString &command) const {
mCommands[functionName].execute(args); mCommands[functionName].execute(args);
} }
if (format)
*format = CliFormat;
return; return;
} }
if (format)
*format = UriFormat;
// Execute uri command. // Execute uri command.
qInfo() << QStringLiteral("Execute uri command: `%1`.").arg(command);
string scheme = address->getScheme(); string scheme = address->getScheme();
if (address->getUsername().empty() || (scheme != "sip" && scheme != "sip-linphone")) { if (address->getUsername().empty() || (scheme != "sip" && scheme != "sip-linphone")) {
qWarning() << QStringLiteral("Not a valid uri: `%1`.").arg(command); qWarning() << QStringLiteral("Not a valid uri: `%1`.").arg(command);
......
...@@ -77,7 +77,13 @@ public: ...@@ -77,7 +77,13 @@ public:
Cli (QObject *parent = Q_NULLPTR); Cli (QObject *parent = Q_NULLPTR);
~Cli () = default; ~Cli () = default;
void executeCommand (const QString &command) const; enum CommandFormat {
UnknownFormat,
CliFormat,
UriFormat
};
void executeCommand (const QString &command, CommandFormat *format = nullptr) const;
private: private:
void addCommand ( void addCommand (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment