summaryrefslogtreecommitdiff
path: root/worker.cxx
blob: df0e83249e05fa2e77df72aa109bd2b0d6a81a3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <QQmlApplicationEngine>
#include "rtclient.h"
#include "user.hxx"
#include "worker.hxx"

Worker::Worker(QObject* parent) :
	QObject{parent}
{
	rtclient_init("https://darapsa.co.id/rt");
}

void Worker::logIn(QString const& name, QString const& password)
{
	auto engine = dynamic_cast<QQmlApplicationEngine*>(this->parent());
	auto user = engine->singletonInstance<User*>(User::typeId);
	user->setName(name);
	rtclient_login(name.toLatin1().constData(), password.toLatin1().constData());
	rtclient_user(name.toLatin1().constData());
}

void Worker::getTaskList()
{
	auto engine = dynamic_cast<QQmlApplicationEngine*>(this->parent());
	auto user = engine->singletonInstance<User*>(User::typeId);
	QString query{"Owner='"};
	query.append(user->name());
	query.append("'");
	rtclient_search(query.toLatin1().constData());
}

Worker::~Worker()
{
	rtclient_cleanup();
}