Don't activate main window with passport request.
This commit is contained in:
parent
44b551898d
commit
275ec3e679
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/qthelp_regex.h"
|
#include "base/qthelp_regex.h"
|
||||||
#include "core/update_checker.h"
|
#include "core/update_checker.h"
|
||||||
#include "core/crash_report_window.h"
|
#include "core/crash_report_window.h"
|
||||||
|
#include "base/qthelp_regex.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -140,11 +141,11 @@ void Application::socketConnected() {
|
||||||
const QStringList &lst(cSendPaths());
|
const QStringList &lst(cSendPaths());
|
||||||
for (QStringList::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
|
for (QStringList::const_iterator i = lst.cbegin(), e = lst.cend(); i != e; ++i) {
|
||||||
commands += qsl("SEND:") + _escapeTo7bit(*i) + ';';
|
commands += qsl("SEND:") + _escapeTo7bit(*i) + ';';
|
||||||
|
commands += qsl("CMD:show;");
|
||||||
}
|
}
|
||||||
if (!cStartUrl().isEmpty()) {
|
if (!cStartUrl().isEmpty()) {
|
||||||
commands += qsl("OPEN:") + _escapeTo7bit(cStartUrl()) + ';';
|
commands += qsl("OPEN:") + _escapeTo7bit(cStartUrl()) + ';';
|
||||||
}
|
}
|
||||||
commands += qsl("CMD:show;");
|
|
||||||
|
|
||||||
DEBUG_LOG(("Application Info: writing commands %1").arg(commands));
|
DEBUG_LOG(("Application Info: writing commands %1").arg(commands));
|
||||||
_localSocket.write(commands.toLatin1());
|
_localSocket.write(commands.toLatin1());
|
||||||
|
@ -169,7 +170,9 @@ void Application::socketReading() {
|
||||||
_localSocketReadData.append(_localSocket.readAll());
|
_localSocketReadData.append(_localSocket.readAll());
|
||||||
if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) {
|
if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) {
|
||||||
uint64 pid = _localSocketReadData.mid(4, _localSocketReadData.length() - 5).toULongLong();
|
uint64 pid = _localSocketReadData.mid(4, _localSocketReadData.length() - 5).toULongLong();
|
||||||
psActivateProcess(pid);
|
if (pid != kEmptyPidForCommandResponse) {
|
||||||
|
psActivateProcess(pid);
|
||||||
|
}
|
||||||
LOG(("Show command response received, pid = %1, activating and quitting...").arg(pid));
|
LOG(("Show command response received, pid = %1, activating and quitting...").arg(pid));
|
||||||
return App::quit();
|
return App::quit();
|
||||||
}
|
}
|
||||||
|
@ -270,16 +273,26 @@ void Application::readClients() {
|
||||||
QStringRef cmd(&cmds, from, to - from);
|
QStringRef cmd(&cmds, from, to - from);
|
||||||
if (cmd.startsWith(qsl("CMD:"))) {
|
if (cmd.startsWith(qsl("CMD:"))) {
|
||||||
Sandbox::execExternal(cmds.mid(from + 4, to - from - 4));
|
Sandbox::execExternal(cmds.mid(from + 4, to - from - 4));
|
||||||
QByteArray response(qsl("RES:%1;").arg(QCoreApplication::applicationPid()).toLatin1());
|
const auto response = qsl("RES:%1;").arg(QCoreApplication::applicationPid()).toLatin1();
|
||||||
i->first->write(response.data(), response.size());
|
i->first->write(response.data(), response.size());
|
||||||
} else if (cmd.startsWith(qsl("SEND:"))) {
|
} else if (cmd.startsWith(qsl("SEND:"))) {
|
||||||
if (cSendPaths().isEmpty()) {
|
if (cSendPaths().isEmpty()) {
|
||||||
toSend.append(_escapeFrom7bit(cmds.mid(from + 5, to - from - 5)));
|
toSend.append(_escapeFrom7bit(cmds.mid(from + 5, to - from - 5)));
|
||||||
}
|
}
|
||||||
} else if (cmd.startsWith(qsl("OPEN:"))) {
|
} else if (cmd.startsWith(qsl("OPEN:"))) {
|
||||||
|
auto activateRequired = true;
|
||||||
if (cStartUrl().isEmpty()) {
|
if (cStartUrl().isEmpty()) {
|
||||||
startUrl = _escapeFrom7bit(cmds.mid(from + 5, to - from - 5)).mid(0, 8192);
|
startUrl = _escapeFrom7bit(cmds.mid(from + 5, to - from - 5)).mid(0, 8192);
|
||||||
|
activateRequired = StartUrlRequiresActivate(startUrl);
|
||||||
}
|
}
|
||||||
|
if (activateRequired) {
|
||||||
|
Sandbox::execExternal("show");
|
||||||
|
}
|
||||||
|
const auto responsePid = activateRequired
|
||||||
|
? QCoreApplication::applicationPid()
|
||||||
|
: kEmptyPidForCommandResponse;
|
||||||
|
const auto response = qsl("RES:%1;").arg(responsePid).toLatin1();
|
||||||
|
i->first->write(response.data(), response.size());
|
||||||
} else {
|
} else {
|
||||||
LOG(("Application Error: unknown command %1 passed in local socket").arg(QString(cmd.constData(), cmd.length())));
|
LOG(("Application Error: unknown command %1 passed in local socket").arg(QString(cmd.constData(), cmd.length())));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue