mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
Ref T218, renamed some functions of CIdentifier
This commit is contained in:
@@ -92,7 +92,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [this](const QStringList & actions, const CIdentifier & origin)
|
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [this](const QStringList & actions, const CIdentifier & origin)
|
||||||
{
|
{
|
||||||
if (origin.isFromSameProcess()) { return; }
|
if (origin.hasApplicationProcessId()) { return; }
|
||||||
CInputManager::instance()->registerRemoteActions(actions);
|
CInputManager::instance()->registerRemoteActions(actions);
|
||||||
});
|
});
|
||||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey actions failed");
|
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey actions failed");
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextApplication::logMessage(const CStatusMessage &message, const CIdentifier &origin)
|
void CContextApplication::logMessage(const CStatusMessage &message, const CIdentifier &origin)
|
||||||
{
|
{
|
||||||
if (!origin.isFromSameProcess())
|
if (!origin.hasApplicationProcessId())
|
||||||
{
|
{
|
||||||
CLogHandler::instance()->logRemoteMessage(message);
|
CLogHandler::instance()->logRemoteMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage & message, const CIdentifier & origin)
|
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage & message, const CIdentifier & origin)
|
||||||
{
|
{
|
||||||
if (!origin.isFromSameProcess())
|
if (!origin.hasApplicationProcessId())
|
||||||
{
|
{
|
||||||
CLogHandler::instance()->logRemoteMessage(message);
|
CLogHandler::instance()->logRemoteMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace BlackGui
|
|||||||
for (const auto &app : machineIdentifiersUnique)
|
for (const auto &app : machineIdentifiersUnique)
|
||||||
{
|
{
|
||||||
ui->cb_Identifier->addItem(app.getMachineName(), QVariant::fromValue(app));
|
ui->cb_Identifier->addItem(app.getMachineName(), QVariant::fromValue(app));
|
||||||
if (m_actionHotkey.getApplicableMachine().isFromSameMachine(app)) { index = ui->cb_Identifier->count() - 1; }
|
if (m_actionHotkey.getApplicableMachine().hasSameMachineName(app)) { index = ui->cb_Identifier->count() - 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 0 && ui->cb_Identifier->count() > 0)
|
if (index < 0 && ui->cb_Identifier->count() > 0)
|
||||||
|
|||||||
@@ -100,22 +100,27 @@ namespace BlackMisc
|
|||||||
return QByteArray::fromBase64(m_machineIdBase64.toLocal8Bit());
|
return QByteArray::fromBase64(m_machineIdBase64.toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CIdentifier::hasSameMachineName(const CIdentifier &other) const
|
||||||
|
{
|
||||||
|
return !other.getMachineName().isEmpty() && other.getMachineName() == this->getMachineName();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CIdentifier::hasSameMachineId(const CIdentifier &other) const
|
||||||
|
{
|
||||||
|
return !m_machineIdBase64.isEmpty() && m_machineIdBase64 == other.m_machineIdBase64;
|
||||||
|
}
|
||||||
|
|
||||||
bool CIdentifier::isFromLocalMachine() const
|
bool CIdentifier::isFromLocalMachine() const
|
||||||
{
|
{
|
||||||
return QDBusConnection::localMachineId() == getMachineId();
|
return QDBusConnection::localMachineId() == getMachineId();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIdentifier::isFromSameMachine(const CIdentifier &other) const
|
bool CIdentifier::hasApplicationProcessId() const
|
||||||
{
|
|
||||||
return getMachineIdBase64() == other.getMachineIdBase64();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CIdentifier::isFromSameProcess() const
|
|
||||||
{
|
{
|
||||||
return QCoreApplication::applicationPid() == getProcessId() && isFromLocalMachine();
|
return QCoreApplication::applicationPid() == getProcessId() && isFromLocalMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CIdentifier::isFromSameProcessName() const
|
bool CIdentifier::hasApplicationProcessName() const
|
||||||
{
|
{
|
||||||
return QCoreApplication::applicationName() == getProcessName();
|
return QCoreApplication::applicationName() == getProcessName();
|
||||||
}
|
}
|
||||||
@@ -157,8 +162,8 @@ namespace BlackMisc
|
|||||||
case IndexProcessId: return CVariant::fromValue(m_processId);
|
case IndexProcessId: return CVariant::fromValue(m_processId);
|
||||||
case IndexProcessName: return CVariant::fromValue(m_processName);
|
case IndexProcessName: return CVariant::fromValue(m_processName);
|
||||||
case IndexIsFromLocalMachine: return CVariant::fromValue(isFromLocalMachine());
|
case IndexIsFromLocalMachine: return CVariant::fromValue(isFromLocalMachine());
|
||||||
case IndexIsFromSameProcess: return CVariant::fromValue(isFromSameProcess());
|
case IndexIsFromSameProcess: return CVariant::fromValue(hasApplicationProcessId());
|
||||||
case IndexIsFromSameProcessName: return CVariant::fromValue(isFromSameProcessName());
|
case IndexIsFromSameProcessName: return CVariant::fromValue(hasApplicationProcessName());
|
||||||
default: return CValueObject::propertyByIndex(index);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace BlackMisc
|
|||||||
QString toUuidString() const;
|
QString toUuidString() const;
|
||||||
|
|
||||||
//! Name
|
//! Name
|
||||||
QString getName() const { return m_name; }
|
const QString &getName() const { return m_name; }
|
||||||
|
|
||||||
//! Has name
|
//! Has name
|
||||||
bool hasName() const { return !m_name.isEmpty(); }
|
bool hasName() const { return !m_name.isEmpty(); }
|
||||||
@@ -95,29 +95,32 @@ namespace BlackMisc
|
|||||||
//! Get machine id
|
//! Get machine id
|
||||||
QByteArray getMachineId() const;
|
QByteArray getMachineId() const;
|
||||||
|
|
||||||
//! Machine 64 base64 encoded
|
//! Machine base64 encoded
|
||||||
QString getMachineIdBase64() const { return m_machineIdBase64; }
|
const QString &getMachineIdBase64() const { return m_machineIdBase64; }
|
||||||
|
|
||||||
//! Machine name
|
//! Machine name
|
||||||
QString getMachineName() const { return m_machineName; }
|
const QString &getMachineName() const { return m_machineName; }
|
||||||
|
|
||||||
|
//! Check if the other identifier has the same machine name
|
||||||
|
bool hasSameMachineName(const CIdentifier &other) const;
|
||||||
|
|
||||||
|
//! Check if other identifier is from the same machine id
|
||||||
|
bool hasSameMachineId(const CIdentifier &other) const;
|
||||||
|
|
||||||
//! Get process id
|
//! Get process id
|
||||||
qint64 getProcessId() const {return m_processId;}
|
qint64 getProcessId() const {return m_processId;}
|
||||||
|
|
||||||
//! Get process name
|
//! Get process name
|
||||||
QString getProcessName() const {return m_processName;}
|
const QString &getProcessName() const {return m_processName;}
|
||||||
|
|
||||||
//! Check if originating from the same local machine
|
//! Check if originating from the same local machine
|
||||||
bool isFromLocalMachine() const;
|
bool isFromLocalMachine() const;
|
||||||
|
|
||||||
//! Check if other identifier is from the same machine
|
|
||||||
bool isFromSameMachine(const CIdentifier &other) const;
|
|
||||||
|
|
||||||
//! Check if originating from the same process id
|
//! Check if originating from the same process id
|
||||||
bool isFromSameProcess() const;
|
bool hasApplicationProcessId() const;
|
||||||
|
|
||||||
//! Check if originating from the same process name
|
//! Check if originating from the same process name
|
||||||
bool isFromSameProcessName() const;
|
bool hasApplicationProcessName() const;
|
||||||
|
|
||||||
//! Check if it is anonymous identifier
|
//! Check if it is anonymous identifier
|
||||||
bool isAnonymous() const;
|
bool isAnonymous() const;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
bool contained = il.containsBy([ = ] (const CIdentifier &ident)
|
bool contained = il.containsBy([ = ] (const CIdentifier &ident)
|
||||||
{
|
{
|
||||||
return identifier.isFromSameMachine(ident);
|
return identifier.hasSameMachineName(ident);
|
||||||
});
|
});
|
||||||
if (!contained) { il.push_back(identifier); }
|
if (!contained) { il.push_back(identifier); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ namespace BlackMisc
|
|||||||
while (out != end && out.key() < in.key()) { ++out; }
|
while (out != end && out.key() < in.key()) { ++out; }
|
||||||
auto &element = getElement(in.key(), out);
|
auto &element = getElement(in.key(), out);
|
||||||
|
|
||||||
if (originator.isFromSameProcess()) // round trip
|
if (originator.hasApplicationProcessId()) // round trip
|
||||||
{
|
{
|
||||||
element.m_pendingChanges--;
|
element.m_pendingChanges--;
|
||||||
Q_ASSERT(element.m_pendingChanges >= 0);
|
Q_ASSERT(element.m_pendingChanges >= 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user