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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
*
* (C) 2003-2014 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
*/
#include "module.h"
#include "accounttype.h"
#include "modules/nickserv/access.h"
AccountImpl::~AccountImpl()
{
NickServ::nickcore_map& map = NickServ::service->GetAccountMap();
map.erase(this->GetDisplay());
}
void AccountImpl::Delete()
{
Event::OnDelCore(&Event::DelCore::OnDelCore, this);
for (unsigned i = users.size(); i > 0; --i)
users[i - 1]->Logout();
return Serialize::Object::Delete();
}
Anope::string AccountImpl::GetDisplay()
{
return Get<Anope::string>(&AccountType::display);
}
void AccountImpl::SetDisplay(const Anope::string &disp)
{
Set(&AccountType::display, disp);
}
Anope::string AccountImpl::GetPassword()
{
return Get(&AccountType::pass);
}
void AccountImpl::SetPassword(const Anope::string &pass)
{
Set(&AccountType::pass, pass);
}
Anope::string AccountImpl::GetEmail()
{
return Get(&AccountType::email);
}
void AccountImpl::SetEmail(const Anope::string &email)
{
Set(&AccountType::email, email);
}
Anope::string AccountImpl::GetLanguage()
{
return Get(&AccountType::language);
}
void AccountImpl::SetLanguage(const Anope::string &lang)
{
Set(&AccountType::language, lang);
}
MemoServ::MemoInfo *AccountImpl::GetMemos()
{
return GetRef<MemoServ::MemoInfo *>(MemoServ::memoinfo);
}
void AccountImpl::SetDisplay(NickServ::Nick *na)
{
if (na->GetAccount() != this || na->GetNick() == this->GetDisplay())
return;
Event::OnChangeCoreDisplay(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, this, na->GetNick());
NickServ::nickcore_map& map = NickServ::service->GetAccountMap();
/* Remove the core from the list */
map.erase(this->GetDisplay());
this->SetDisplay(na->GetNick());
NickServ::Account* &nc = map[this->GetDisplay()];
if (nc)
Log(LOG_DEBUG) << "Duplicate account " << this->GetDisplay() << " in nickcore table?";
nc = this;
}
bool AccountImpl::IsServicesOper() const
{
return this->o != NULL;
}
bool AccountImpl::IsOnAccess(User *u)
{
Anope::string buf = u->GetIdent() + "@" + u->host, buf2, buf3;
if (!u->vhost.empty())
buf2 = u->GetIdent() + "@" + u->vhost;
if (!u->GetCloakedHost().empty())
buf3 = u->GetIdent() + "@" + u->GetCloakedHost();
for (NickAccess *access : GetRefs<NickAccess *>(nsaccess))
{
Anope::string a = access->GetMask();
if (Anope::Match(buf, a) || (!buf2.empty() && Anope::Match(buf2, a)) || (!buf3.empty() && Anope::Match(buf3, a)))
return true;
}
return false;
}
unsigned int AccountImpl::GetChannelCount()
{
unsigned int i = 0;
for (ChanServ::Channel *c : GetRefs<ChanServ::Channel *>(ChanServ::channel))
if (c->GetFounder() == this)
++i;
return i;
}
|