Commit 09f59f40 authored by Ronan's avatar Ronan

fix(cli): do not execute command if calls window is not created

parent 55c17766
......@@ -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);
}
// -----------------------------------------------------------------------------
......
......@@ -84,6 +84,10 @@ public:
bool hasFocus () const;
bool isOpened () const {
return mIsOpened;
}
static App *getInstance () {
return static_cast<App *>(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_
......@@ -275,13 +275,14 @@ void Cli::Command::execute (QHash<QString, QString> &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<QString, QString> 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<QString, QString> 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.");
......
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