mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-03 22:56:49 +00:00
fix(cli): do not execute command if calls window is not created
This commit is contained in:
parent
55c1776667
commit
09f59f40c3
3 changed files with 27 additions and 6 deletions
|
|
@ -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.");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue