summaryrefslogtreecommitdiff
path: root/client.cxx
blob: f4624751a95d25ecd36b54eb478d38b30f087f69 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <rtclient/client.h>
#include "qrtclient/client.hxx"

namespace RTClient {

	Client::Client(QString const& url)
	{
		rtclient_init(url.toLatin1().constData());
	}

	void Client::logIn(QString const& name, QString const& password)
	{
		rtclient_login(name.toLatin1().constData(), password.toLatin1().constData());
		struct rt_user* user = NULL;
		rtclient_user_show(&user, name.toLatin1().constData());
		if (user) emit logged(user);
	}

	void Client::userNew(QString const& name
			, QString const& password
			, QString const& emailAddress
			, QString const& realName
			, QString const& nickName
			, QString const& organization
			, QString const& address1
			, QString const& address2
			, QString const& city
			, QString const& state
			, QString const& zip
			, QString const& country
			, QString const& homePhone
			, QString const& workPhone
			, QString const& mobilePhone
			, QString const& pagerPhone
			, QString const& contactInfo
			, QString const& comments
			, QString const& signature
			, QString const& gecos
			, int lang
			, int timeZone
			, bool disabled
			, bool privileged)
	{
		rtclient_user_new(name.toLatin1().constData()
				, emailAddress.toLatin1().constData()
				, realName.toLatin1().constData()
				, nickName.toLatin1().constData()
				, gecos.toLatin1().constData()
				, static_cast<enum rt_lang>(lang)
				, static_cast<enum rt_timezone>(timeZone)
				, contactInfo.toLatin1().constData()
				, disabled
				, privileged
				, password.toLatin1().constData()
				, comments.toLatin1().constData()
				, signature.toLatin1().constData()
				, organization.toLatin1().constData()
				, address1.toLatin1().constData()
				, address2.toLatin1().constData()
				, city.toLatin1().constData()
				, state.toLatin1().constData()
				, zip.toLatin1().constData()
				, country.toLatin1().constData()
				, homePhone.toLatin1().constData()
				, workPhone.toLatin1().constData()
				, mobilePhone.toLatin1().constData()
				, pagerPhone.toLatin1().constData());
	}

	void Client::search(QString const& owner)
	{
		QString query{"Owner='"};
		query.append(owner);
		query.append("'");
		rt_ticketlist* taskList = NULL;
		rtclient_ticket_search(&taskList, query.toLatin1().constData());
		if (taskList) emit foundTasks(taskList);
	}

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

}