mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #428 Move COriginator from Event into BlackMisc namespace
This commit is contained in:
52
src/blackmisc/originator.cpp
Normal file
52
src/blackmisc/originator.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* Copyright (C) 2014
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "originator.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
// Default constructor
|
||||
COriginator::COriginator()
|
||||
: m_machineId(QDBusConnection::localMachineId()),
|
||||
m_processId(QCoreApplication::applicationPid()),
|
||||
m_processName(QCoreApplication::applicationName())
|
||||
{
|
||||
}
|
||||
|
||||
bool COriginator::isFromLocalMachine() const
|
||||
{
|
||||
return QDBusConnection::localMachineId() == getMachineId();
|
||||
}
|
||||
|
||||
bool COriginator::isFromSameProcess() const
|
||||
{
|
||||
return QCoreApplication::applicationPid() == getProcessId() && isFromLocalMachine();
|
||||
}
|
||||
|
||||
bool COriginator::isFromSameProcessName() const
|
||||
{
|
||||
return QCoreApplication::applicationName() == getProcessName();
|
||||
}
|
||||
|
||||
QString COriginator::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
QString s;
|
||||
s.append(m_originatorName);
|
||||
s.append(" ").append(m_machineId);
|
||||
s.append(" ").append(m_primaryIpAddress);
|
||||
s.append(" ").append(m_objectId);
|
||||
s.append(" ").append(m_processId);
|
||||
s.append(" ").append(m_processName);
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user