summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-12-03 22:23:08 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-12-04 12:19:26 +0100
commitb256886a5cb9f2ae3ebda70a2045b19ed9f4233e (patch)
tree4fa1e46de224cf834a05824dc1eb86001bdb3300 /logic
parente89709a801e7874bc02c66848c638c6a0ccc85c1 (diff)
api: add status check for modules
Diffstat (limited to 'logic')
-rw-r--r--logic/runtime-libraries.cpp43
-rw-r--r--logic/runtime-libraries.hpp2
2 files changed, 31 insertions, 14 deletions
diff --git a/logic/runtime-libraries.cpp b/logic/runtime-libraries.cpp
index a04da6a2..8feeaaba 100644
--- a/logic/runtime-libraries.cpp
+++ b/logic/runtime-libraries.cpp
@@ -1,13 +1,13 @@
#include "runtime-libraries.hpp"
#include "options/scoped.hpp"
+#include <QMessageBox>
#include <QDebug>
-runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) :
- pTracker(nullptr),
- pFilter(nullptr),
- pProtocol(nullptr),
- correct(false)
+runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f)
{
+ module_status status =
+ module_status_mixin::error(QCoreApplication::translate("module", "Library load failure"));
+
using namespace options;
with_tracker_teardown sentinel;
@@ -15,15 +15,12 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli
pProtocol = make_dylib_instance<IProtocol>(p);
if (!pProtocol)
- {
- qDebug() << "protocol dylib load failure";
goto end;
- }
- if(!pProtocol->correct())
+ if(status = pProtocol->check_status(), !status.is_ok())
{
- qDebug() << "protocol load failure";
- pProtocol = nullptr;
+ status = QCoreApplication::translate("module", "Error occured while loading protocol %1\n\n%2\n")
+ .arg(p->name).arg(status.error);
goto end;
}
@@ -36,10 +33,30 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli
goto end;
}
- pTracker->start_tracker(frame);
+ if (pFilter)
+ if(status = pFilter->check_status(), !status.is_ok())
+ {
+ status = QCoreApplication::translate("module", "Error occured while loading filter %1\n\n%2\n")
+ .arg(f->name).arg(status.error);
+ goto end;
+ }
+
+ if (status = pTracker->start_tracker(frame), !status.is_ok())
+ {
+ status = QCoreApplication::translate("module", "Error occured while loading tracker %1\n\n%2\n")
+ .arg(t->name).arg(status.error);
+ goto end;
+ }
correct = true;
+ return;
+
end:
- (void)0;
+ pTracker = nullptr;
+ pFilter = nullptr;
+ pProtocol = nullptr;
+
+ if (!status.is_ok())
+ QMessageBox::critical(nullptr, "Startup failure", status.error, QMessageBox::Cancel, QMessageBox::NoButton);
}
diff --git a/logic/runtime-libraries.hpp b/logic/runtime-libraries.hpp
index cc96f0e7..1105c179 100644
--- a/logic/runtime-libraries.hpp
+++ b/logic/runtime-libraries.hpp
@@ -24,5 +24,5 @@ struct OTR_LOGIC_EXPORT runtime_libraries final
runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f);
runtime_libraries() : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) {}
- bool correct;
+ bool correct = false;
};