summaryrefslogtreecommitdiff
path: root/backgroundtask.cpp
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2016-09-16 00:58:12 -0400
committerJordan Wiens <jordan@psifertex.com>2016-09-16 00:58:12 -0400
commitc334d84ff86c2bc3ce0298bdec79d5c6f5aa8b63 (patch)
tree533b57384862655b8a0cbbfcbd8d0678147aa97f /backgroundtask.cpp
parent978acef68bd6b023041f669e23e9faf8802760a7 (diff)
parent124cf1bc4f465a915621b7ac81af94b9a69a937a (diff)
Merge branch 'dev' of github.com:Vector35/binaryninja-api into dev
Diffstat (limited to 'backgroundtask.cpp')
-rw-r--r--backgroundtask.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/backgroundtask.cpp b/backgroundtask.cpp
new file mode 100644
index 00000000..aebf980c
--- /dev/null
+++ b/backgroundtask.cpp
@@ -0,0 +1,75 @@
+#include "binaryninjaapi.h"
+
+using namespace std;
+using namespace BinaryNinja;
+
+
+BackgroundTask::BackgroundTask(BNBackgroundTask* task)
+{
+ m_object = task;
+}
+
+
+BackgroundTask::BackgroundTask(const string& initialText, bool canCancel)
+{
+ m_object = BNBeginBackgroundTask(initialText.c_str(), canCancel);
+}
+
+
+bool BackgroundTask::CanCancel() const
+{
+ return BNCanCancelBackgroundTask(m_object);
+}
+
+
+bool BackgroundTask::IsCancelled() const
+{
+ return BNIsBackgroundTaskCancelled(m_object);
+}
+
+
+bool BackgroundTask::IsFinished() const
+{
+ return BNIsBackgroundTaskFinished(m_object);
+}
+
+
+string BackgroundTask::GetProgressText() const
+{
+ char* text = BNGetBackgroundTaskProgressText(m_object);
+ string result = text;
+ BNFreeString(text);
+ return result;
+}
+
+
+void BackgroundTask::Cancel()
+{
+ BNCancelBackgroundTask(m_object);
+}
+
+
+void BackgroundTask::Finish()
+{
+ BNFinishBackgroundTask(m_object);
+}
+
+
+void BackgroundTask::SetProgressText(const string& text)
+{
+ BNSetBackgroundTaskProgressText(m_object, text.c_str());
+}
+
+
+vector<Ref<BackgroundTask>> BackgroundTask::GetRunningTasks()
+{
+ size_t count;
+ BNBackgroundTask** tasks = BNGetRunningBackgroundTasks(&count);
+
+ vector<Ref<BackgroundTask>> result;
+ for (size_t i = 0; i < count; i++)
+ result.push_back(new BackgroundTask(BNNewBackgroundTaskReference(tasks[i])));
+
+ BNFreeBackgroundTaskList(tasks, count);
+ return result;
+}