mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +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)
|
||||
{
|
||||
if (origin.isFromSameProcess()) { return; }
|
||||
if (origin.hasApplicationProcessId()) { return; }
|
||||
CInputManager::instance()->registerRemoteActions(actions);
|
||||
});
|
||||
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)
|
||||
{
|
||||
if (!origin.isFromSameProcess())
|
||||
if (!origin.hasApplicationProcessId())
|
||||
{
|
||||
CLogHandler::instance()->logRemoteMessage(message);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace BlackCore
|
||||
|
||||
connect(this, &IContextApplication::messageLogged, this, [](const CStatusMessage & message, const CIdentifier & origin)
|
||||
{
|
||||
if (!origin.isFromSameProcess())
|
||||
if (!origin.hasApplicationProcessId())
|
||||
{
|
||||
CLogHandler::instance()->logRemoteMessage(message);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace BlackGui
|
||||
for (const auto &app : machineIdentifiersUnique)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -100,22 +100,27 @@ namespace BlackMisc
|
||||
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
|
||||
{
|
||||
return QDBusConnection::localMachineId() == getMachineId();
|
||||
}
|
||||
|
||||
bool CIdentifier::isFromSameMachine(const CIdentifier &other) const
|
||||
{
|
||||
return getMachineIdBase64() == other.getMachineIdBase64();
|
||||
}
|
||||
|
||||
bool CIdentifier::isFromSameProcess() const
|
||||
bool CIdentifier::hasApplicationProcessId() const
|
||||
{
|
||||
return QCoreApplication::applicationPid() == getProcessId() && isFromLocalMachine();
|
||||
}
|
||||
|
||||
bool CIdentifier::isFromSameProcessName() const
|
||||
bool CIdentifier::hasApplicationProcessName() const
|
||||
{
|
||||
return QCoreApplication::applicationName() == getProcessName();
|
||||
}
|
||||
@@ -157,8 +162,8 @@ namespace BlackMisc
|
||||
case IndexProcessId: return CVariant::fromValue(m_processId);
|
||||
case IndexProcessName: return CVariant::fromValue(m_processName);
|
||||
case IndexIsFromLocalMachine: return CVariant::fromValue(isFromLocalMachine());
|
||||
case IndexIsFromSameProcess: return CVariant::fromValue(isFromSameProcess());
|
||||
case IndexIsFromSameProcessName: return CVariant::fromValue(isFromSameProcessName());
|
||||
case IndexIsFromSameProcess: return CVariant::fromValue(hasApplicationProcessId());
|
||||
case IndexIsFromSameProcessName: return CVariant::fromValue(hasApplicationProcessName());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace BlackMisc
|
||||
QString toUuidString() const;
|
||||
|
||||
//! Name
|
||||
QString getName() const { return m_name; }
|
||||
const QString &getName() const { return m_name; }
|
||||
|
||||
//! Has name
|
||||
bool hasName() const { return !m_name.isEmpty(); }
|
||||
@@ -95,29 +95,32 @@ namespace BlackMisc
|
||||
//! Get machine id
|
||||
QByteArray getMachineId() const;
|
||||
|
||||
//! Machine 64 base64 encoded
|
||||
QString getMachineIdBase64() const { return m_machineIdBase64; }
|
||||
//! Machine base64 encoded
|
||||
const QString &getMachineIdBase64() const { return m_machineIdBase64; }
|
||||
|
||||
//! 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
|
||||
qint64 getProcessId() const {return m_processId;}
|
||||
|
||||
//! Get process name
|
||||
QString getProcessName() const {return m_processName;}
|
||||
const QString &getProcessName() const {return m_processName;}
|
||||
|
||||
//! Check if originating from the same local machine
|
||||
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
|
||||
bool isFromSameProcess() const;
|
||||
bool hasApplicationProcessId() const;
|
||||
|
||||
//! Check if originating from the same process name
|
||||
bool isFromSameProcessName() const;
|
||||
bool hasApplicationProcessName() const;
|
||||
|
||||
//! Check if it is anonymous identifier
|
||||
bool isAnonymous() const;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackMisc
|
||||
{
|
||||
bool contained = il.containsBy([ = ] (const CIdentifier &ident)
|
||||
{
|
||||
return identifier.isFromSameMachine(ident);
|
||||
return identifier.hasSameMachineName(ident);
|
||||
});
|
||||
if (!contained) { il.push_back(identifier); }
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace BlackMisc
|
||||
while (out != end && out.key() < in.key()) { ++out; }
|
||||
auto &element = getElement(in.key(), out);
|
||||
|
||||
if (originator.isFromSameProcess()) // round trip
|
||||
if (originator.hasApplicationProcessId()) // round trip
|
||||
{
|
||||
element.m_pendingChanges--;
|
||||
Q_ASSERT(element.m_pendingChanges >= 0);
|
||||
|
||||
Reference in New Issue
Block a user