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

This commit is contained in:
nicolas 2017-08-09 15:35:04 +02:00
parent f315211985
commit 55153d720d
4 changed files with 32 additions and 10 deletions

View file

@ -141,6 +141,7 @@ inline void activeSplashScreen (QQmlApplicationEngine *engine) {
void App::initContentApp () {
shared_ptr<linphone::Config> 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);

View file

@ -119,7 +119,7 @@ private:
return mAvailableLocales;
}
void openAppAfterInit ();
void openAppAfterInit (bool mustBeIconified = false);
static void checkForUpdate ();

View file

@ -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(
::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);

View file

@ -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 (