mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 19:25:49 +08:00
refs #428 Move COriginator from Event into BlackMisc namespace
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "statusmessagelist.h"
|
||||
#include "pixmap.h"
|
||||
#include "iconlist.h"
|
||||
#include "originator.h"
|
||||
#include "eventallclasses.h"
|
||||
#include <QtNetwork/QHostInfo>
|
||||
#include <QProcessEnvironment>
|
||||
@@ -80,7 +81,6 @@ void BlackMisc::Hardware::registerMetadata()
|
||||
*/
|
||||
void BlackMisc::Event::registerMetadata()
|
||||
{
|
||||
COriginator::registerMetadata();
|
||||
CEventHotkeyFunction::registerMetadata();
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ void BlackMisc::registerMetadata()
|
||||
CLogCategory::registerMetadata();
|
||||
CLogCategoryList::registerMetadata();
|
||||
CPixmap::registerMetadata();
|
||||
COriginator::registerMetadata();
|
||||
|
||||
// sub namespaces
|
||||
PhysicalQuantities::registerMetadata();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef BLACKMISC_EVENT_ALLCLASSES_H
|
||||
#define BLACKMISC_EVENT_ALLCLASSES_H
|
||||
|
||||
#include "blackmisc/evoriginator.h"
|
||||
#include "blackmisc/eveventhotkeyfunction.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackmiscexport.h"
|
||||
#include "valueobject.h"
|
||||
#include "evoriginator.h"
|
||||
#include "originator.h"
|
||||
#include "hotkeyfunction.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/* 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 "evoriginator.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Event
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to string
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISC_EVENT_ORIGINATOR_H
|
||||
#define BLACKMISC_EVENT_ORIGINATOR_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackmiscexport.h"
|
||||
#include "valueobject.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Event
|
||||
{
|
||||
|
||||
//! Value object encapsulating information about the originiator
|
||||
class BLACKMISC_EXPORT COriginator :
|
||||
public Mixin::MetaType<COriginator>,
|
||||
public Mixin::HashByTuple<COriginator>,
|
||||
public Mixin::DBusByTuple<COriginator>,
|
||||
public Mixin::EqualsByTuple<COriginator>,
|
||||
public Mixin::LessThanByTuple<COriginator>,
|
||||
public Mixin::CompareByTuple<COriginator>,
|
||||
public Mixin::Index<COriginator>,
|
||||
public Mixin::String<COriginator>,
|
||||
public Mixin::Icon<COriginator>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
COriginator();
|
||||
|
||||
//! Get machine id
|
||||
QByteArray getMachineId() const {return m_machineId;}
|
||||
|
||||
//! Get process id
|
||||
qint32 getProcessId() const {return m_processId;}
|
||||
|
||||
//! Get process name
|
||||
QString getProcessName() const {return m_processName;}
|
||||
|
||||
//! Check if originating from the same local machine
|
||||
bool isFromLocalMachine() const;
|
||||
|
||||
//! Check if originating from the same process id
|
||||
bool isFromSameProcess() const;
|
||||
|
||||
//! Check if originating from the same process name
|
||||
bool isFromSameProcessName() const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(COriginator)
|
||||
QString m_originatorName;
|
||||
QByteArray m_machineId;
|
||||
QByteArray m_primaryIpAddress;
|
||||
QByteArray m_objectId;
|
||||
qint32 m_processId;
|
||||
QString m_processName;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Event::COriginator, (o.m_originatorName, o.m_machineId, o.m_primaryIpAddress, o.m_objectId, o.m_processId, o.m_processName))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Event::COriginator)
|
||||
|
||||
#endif // BLACKMISC_EVENT_ORIGINATOR_H
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
82
src/blackmisc/originator.h
Normal file
82
src/blackmisc/originator.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISC_EVENT_ORIGINATOR_H
|
||||
#define BLACKMISC_EVENT_ORIGINATOR_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackmiscexport.h"
|
||||
#include "valueobject.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
//! Value object encapsulating information about the originiator
|
||||
class BLACKMISC_EXPORT COriginator :
|
||||
public Mixin::MetaType<COriginator>,
|
||||
public Mixin::HashByTuple<COriginator>,
|
||||
public Mixin::DBusByTuple<COriginator>,
|
||||
public Mixin::EqualsByTuple<COriginator>,
|
||||
public Mixin::LessThanByTuple<COriginator>,
|
||||
public Mixin::CompareByTuple<COriginator>,
|
||||
public Mixin::Index<COriginator>,
|
||||
public Mixin::String<COriginator>,
|
||||
public Mixin::Icon<COriginator>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
COriginator();
|
||||
|
||||
//! Get machine id
|
||||
QByteArray getMachineId() const {return m_machineId;}
|
||||
|
||||
//! Get process id
|
||||
qint32 getProcessId() const {return m_processId;}
|
||||
|
||||
//! Get process name
|
||||
QString getProcessName() const {return m_processName;}
|
||||
|
||||
//! Check if originating from the same local machine
|
||||
bool isFromLocalMachine() const;
|
||||
|
||||
//! Check if originating from the same process id
|
||||
bool isFromSameProcess() const;
|
||||
|
||||
//! Check if originating from the same process name
|
||||
bool isFromSameProcessName() const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(COriginator)
|
||||
QString m_originatorName;
|
||||
QByteArray m_machineId;
|
||||
QByteArray m_primaryIpAddress;
|
||||
QByteArray m_objectId;
|
||||
qint32 m_processId;
|
||||
QString m_processName;
|
||||
};
|
||||
}
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::COriginator, (
|
||||
o.m_originatorName,
|
||||
o.m_machineId,
|
||||
o.m_primaryIpAddress,
|
||||
o.m_objectId,
|
||||
o.m_processId,
|
||||
o.m_processName
|
||||
))
|
||||
Q_DECLARE_METATYPE(BlackMisc::COriginator)
|
||||
|
||||
#endif // BLACKMISC_EVENT_ORIGINATOR_H
|
||||
Reference in New Issue
Block a user