2018-07-22 13:04:13 +00:00
|
|
|
|
|
|
|
#include "R2Task.h"
|
|
|
|
|
|
|
|
R2Task::R2Task(const QString &cmd)
|
|
|
|
{
|
|
|
|
task = r_core_task_new(Core()->core(),
|
|
|
|
true,
|
|
|
|
cmd.toLocal8Bit().constData(),
|
|
|
|
static_cast<RCoreTaskCallback>(&R2Task::taskFinishedCallback),
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
|
|
|
R2Task::~R2Task()
|
|
|
|
{
|
2018-09-26 13:48:57 +00:00
|
|
|
// Don't delete current task as it might be still running
|
2018-09-27 08:24:47 +00:00
|
|
|
// TODO
|
|
|
|
// For now tasks are not freed, so find we need to something
|
2018-07-22 13:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void R2Task::taskFinishedCallback(void *user, char *)
|
|
|
|
{
|
|
|
|
reinterpret_cast<R2Task *>(user)->taskFinished();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2Task::taskFinished()
|
|
|
|
{
|
|
|
|
emit finished();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2Task::startTask()
|
|
|
|
{
|
|
|
|
r_core_task_enqueue(Core()->core(), task);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2Task::breakTask()
|
|
|
|
{
|
|
|
|
r_core_task_break(Core()->core(), task->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2Task::joinTask()
|
|
|
|
{
|
2018-08-23 16:44:26 +00:00
|
|
|
r_core_task_join(Core()->core(), nullptr, task->id);
|
2018-07-22 13:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString R2Task::getResult()
|
|
|
|
{
|
|
|
|
return QString::fromUtf8(task->res);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *R2Task::getResultRaw()
|
|
|
|
{
|
|
|
|
return task->res;
|
|
|
|
}
|