From b256886a5cb9f2ae3ebda70a2045b19ed9f4233e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Dec 2017 22:23:08 +0100 Subject: api: add status check for modules --- proto-flightgear/ftnoir_protocol_fg.cpp | 9 +++++++-- proto-flightgear/ftnoir_protocol_fg.h | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'proto-flightgear') diff --git a/proto-flightgear/ftnoir_protocol_fg.cpp b/proto-flightgear/ftnoir_protocol_fg.cpp index 3e0f955c..e1101c0f 100644 --- a/proto-flightgear/ftnoir_protocol_fg.cpp +++ b/proto-flightgear/ftnoir_protocol_fg.cpp @@ -25,9 +25,14 @@ void flightgear::pose(const double* headpose) { (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(s.port)); } -bool flightgear::correct() +module_status flightgear::check_status() { - return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); + if (outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) + return status_ok(); + else + return error(QCoreApplication::translate("flightgear", "Can't bind to [%1.%2.%3.%4]:%5") + .arg(s.ip1).arg(s.ip2).arg(s.ip3).arg(s.ip4) + .arg(s.port)); } OPENTRACK_DECLARE_PROTOCOL(flightgear, FGControls, flightgearDll) diff --git a/proto-flightgear/ftnoir_protocol_fg.h b/proto-flightgear/ftnoir_protocol_fg.h index 48e5f1c1..31a7660c 100644 --- a/proto-flightgear/ftnoir_protocol_fg.h +++ b/proto-flightgear/ftnoir_protocol_fg.h @@ -41,11 +41,9 @@ struct settings : opts { class flightgear : public IProtocol { public: - bool correct(); void pose(const double *headpose); - QString game_name() { - return QCoreApplication::translate("flightgear", "FlightGear"); - } + QString game_name() { return QCoreApplication::translate("flightgear", "FlightGear"); } + module_status check_status() override; private: settings s; flightgear_datagram FlightData; -- cgit v1.2.3