3#include "PluginWakeOnLan.h"
4#include "ConnecterWakeOnLan.h"
5#include <QLoggingCategory>
7#ifdef HAVE_PCAPPLUSPLUS
8 #include "PcapPlusPlusVersion.h"
9 #include "PcapDevice.h"
11 static Q_LOGGING_CATEGORY(logPcpp,
"WOL.PCPP")
12 void Pcpp_Logger(pcpp::Logger::LogLevel logLevel,
13 const std::
string& logMessage,
14 const std::
string& file,
15 const std::
string& method,
20 case pcpp::Logger::LogLevel::Debug:
21 qDebug(logPcpp) << logMessage.c_str();
23 case pcpp::Logger::LogLevel::Info:
24 qInfo(logPcpp) << logMessage.c_str();
26 case pcpp::Logger::LogLevel::Error:
27 qCritical(logPcpp) << logMessage.c_str();
33static Q_LOGGING_CATEGORY(log,
"WakeOnLan.Plugin")
36 , m_pConnecter(
nullptr)
38#ifdef HAVE_PCAPPLUSPLUS
39 pcpp::Logger::getInstance().setLogPrinter(Pcpp_Logger);
40 pcpp::Logger::getInstance().setAllModulesToLogLevel(
41 pcpp::Logger::LogLevel::Debug);
43 pcpp::Logger::getInstance().enableLogs();
44 pcpp::Logger::getInstance().setLogLevel(
45 pcpp::LogModule::PcapLogModuleLiveDevice, pcpp::Logger::Info);
49CPluginWakeOnLan::~CPluginWakeOnLan()
51 qDebug(log) <<
"CPluginWakeOnLan::~CPluginWakeOnLan()";
66 return tr(
"Wake on lan");
71 return tr(
"Wake on lan");
74const QIcon CPluginWakeOnLan::Icon()
const
76 return QIcon::fromTheme(
"lan");
81 return PluginWakeOnLan_VERSION;
87#ifdef HAVE_PCAPPLUSPLUS
88 szDetails =
"- PcapPlusPlus";
90 szDetails +=
" - " + tr(
"version: ")
91 + pcpp::getPcapPlusPlusVersionFull().c_str();
93 szDetails +=
" - " + tr(
"Pcap lib version info: ")
94 + pcpp::IPcapDevice::getPcapLibVersionInfo().c_str();
103 if(!m_pConnecter)
return m_pConnecter;
105 QString szFile = m_pConnecter->GetSettingsFile();
107 if(!d.exists(szFile))
return m_pConnecter;
110 bool bRet = QMetaObject::invokeMethod(
113 Qt::DirectConnection,
114 Q_RETURN_ARG(
int, nRet),
115 Q_ARG(QString, szFile));
117 qCritical(log) <<
"Call m_pConnecter->Load(szFile) fail.";
121 qCritical(log) <<
"Load parameter fail" << nRet;
129CConnecter* CPluginWakeOnLan::OnCreateConnecter(
const QString &szId)
131 qDebug(log) << Q_FUNC_INFO;
141 qDebug(log) << Q_FUNC_INFO;
142 Q_ASSERT(m_pConnecter == p);
143 m_pConnecter =
nullptr;
The parameters of client.
virtual const QString Id() const
ID. Default: Protocol() + ":" + Name()
virtual Q_INVOKABLE CConnecter * CreateConnecter(const QString &szId, CParameterClient *para)
New CConnecter instance.
virtual Q_INVOKABLE int DeleteConnecter(CConnecter *p)
Delete CConnecter.
virtual const QString Details() const override
Display more information in About dialog or log.
virtual CConnecter * CreateConnecter(const QString &szId, CParameterClient *para) override
New CConnecter instance.
virtual const QString Protocol() const override
Plugin Protocol.
virtual const QString DisplayName() const override
The plugin display name.
virtual const QString Name() const override
This name must be the same as the project name (${PROJECT_NAME}). The translation file (${PROJECT_NAM...
virtual const QString Version() const override
Version.
virtual const QString Description() const override
Plugin description.
virtual int DeleteConnecter(CConnecter *p) override
Delete CConnecter.