summaryrefslogtreecommitdiff
path: root/src/nickcore.cpp
blob: f195c233a2a445dd625e97e8461259ca58244f14 (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
#include "services.h"
#include "pseudo.h"

NickCore::NickCore()
{
	next = prev = NULL;
	display = email = greet = url = NULL;
	ot = NULL;
	pass[0] = '\0';
	icq = flags = 0;
	language = channelcount = 0;
	lastmail = 0;
}

bool NickCore::HasCommand(const std::string &cmdstr) const
{
	if (!this->ot)
	{
		// No opertype.
		return false;
	}

	return this->ot->HasCommand(cmdstr);
}

bool NickCore::IsServicesOper() const
{
	if (this->ot)
		return true;

	return false;
}

bool NickCore::HasPriv(const std::string &privstr) const
{
	if (!this->ot)
	{
		// No opertype.
		return false;
	}

	return this->ot->HasPriv(privstr);
}

void NickCore::AddAccess(const std::string &entry)
{
	access.push_back(entry);
}

std::string NickCore::GetAccess(unsigned entry)
{
	if (access.empty() || entry >= access.size())
		return "";
	return access[entry];
}

bool NickCore::FindAccess(const std::string &entry)
{
	for (unsigned i = 0; i < access.size(); ++i)
		if (access[i] == entry)
			return true;

	return false;
}

void NickCore::EraseAccess(const std::string &entry)
{
	for (unsigned i = 0; i < access.size(); ++i)
		if (access[i] == entry)
		{
			FOREACH_MOD(I_OnNickEraseAccess, OnNickEraseAccess(this, entry));
			access.erase(access.begin() + i);
			break;
		}
}

void NickCore::ClearAccess()
{
	FOREACH_MOD(I_OnNickClearAccess, OnNickClearAccess(this));
	access.clear();
}