summaryrefslogtreecommitdiff
path: root/modules/memoserv
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-11-25 16:35:10 -0500
committerAdam <Adam@anope.org>2016-11-25 16:35:56 -0500
commita635344582a13d935631fbe930d79d3788359c8a (patch)
treecd7b372d02f94c7f6c18542e06d29deff0f19842 /modules/memoserv
parentf30d99f81f6fb8abd7ca555068173bad6c99e07a (diff)
Rename most ext fields names to be consistent with everything else, add accessors for many
Diffstat (limited to 'modules/memoserv')
-rw-r--r--modules/memoserv/info.cpp20
-rw-r--r--modules/memoserv/main/memoinfo.cpp11
-rw-r--r--modules/memoserv/main/memoinfo.h4
-rw-r--r--modules/memoserv/main/memoinfotype.cpp1
-rw-r--r--modules/memoserv/main/memoinfotype.h1
-rw-r--r--modules/memoserv/main/memoserv.cpp6
-rw-r--r--modules/memoserv/send.cpp2
-rw-r--r--modules/memoserv/set.cpp41
8 files changed, 48 insertions, 38 deletions
diff --git a/modules/memoserv/info.cpp b/modules/memoserv/info.cpp
index 05ca0c213..045e4cb6d 100644
--- a/modules/memoserv/info.cpp
+++ b/modules/memoserv/info.cpp
@@ -47,7 +47,7 @@ class CommandMSInfo : public Command
}
mi = na->GetAccount()->GetMemos();
- hardmax = na->GetAccount()->HasFieldS("MEMO_HARDMAX");
+ hardmax = mi->IsHardMax();
}
else if (!nname.empty() && nname[0] == '#')
{
@@ -65,7 +65,7 @@ class CommandMSInfo : public Command
}
mi = ci->GetMemos();
- hardmax = ci->HasFieldS("MEMO_HARDMAX");
+ hardmax = mi->IsHardMax();
}
else if (!nname.empty()) /* It's not a chan and we aren't an oper */
{
@@ -75,7 +75,7 @@ class CommandMSInfo : public Command
else
{
mi = nc->GetMemos();
- hardmax = nc->HasFieldS("MEMO_HARDMAX");
+ hardmax = mi->IsHardMax();
}
if (!mi)
@@ -123,11 +123,11 @@ class CommandMSInfo : public Command
if (na)
{
- if (na->GetAccount()->HasFieldS("MEMO_RECEIVE") && na->GetAccount()->HasFieldS("MEMO_SIGNON"))
+ if (na->GetAccount()->IsMemoReceive() && na->GetAccount()->IsMemoSignon())
source.Reply(_("\002{0}\002 is notified of new memos at logon and when they arrive."), nname);
- else if (na->GetAccount()->HasFieldS("MEMO_RECEIVE"))
+ else if (na->GetAccount()->IsMemoReceive())
source.Reply(_("\002{0}\002 is notified when new memos arrive."), nname);
- else if (na->GetAccount()->HasFieldS("MEMO_SIGNON"))
+ else if (na->GetAccount()->IsMemoSignon())
source.Reply(_("\002{0}\002 is notified of news memos at logon."), nname);
else
source.Reply(_("\002{0}\002 is not notified of new memos."), nname);
@@ -179,22 +179,22 @@ class CommandMSInfo : public Command
else
source.Reply(_("You have no limit on the number of memos you may keep."));
- bool memo_mail = nc->HasFieldS("MEMO_MAIL");
- if (nc->HasFieldS("MEMO_RECEIVE") && nc->HasFieldS("MEMO_SIGNON"))
+ bool memo_mail = nc->IsMemoMail();
+ if (nc->IsMemoReceive() && nc->IsMemoSignon())
{
if (memo_mail)
source.Reply(_("You will be notified of new memos at logon and when they arrive, and by mail when they arrive."));
else
source.Reply(_("You will be notified of new memos at logon and when they arrive."));
}
- else if (nc->HasFieldS("MEMO_RECEIVE"))
+ else if (nc->IsMemoReceive())
{
if (memo_mail)
source.Reply(_("You will be notified by message and by mail when new memos arrive."));
else
source.Reply(_("You will be notified when new memos arrive."));
}
- else if (nc->HasFieldS("MEMO_SIGNON"))
+ else if (nc->IsMemoSignon())
{
if (memo_mail)
source.Reply(_("You will be notified of new memos at logon, and by mail when they arrive."));
diff --git a/modules/memoserv/main/memoinfo.cpp b/modules/memoserv/main/memoinfo.cpp
index 6fa8df8b1..aa5ca71e4 100644
--- a/modules/memoserv/main/memoinfo.cpp
+++ b/modules/memoserv/main/memoinfo.cpp
@@ -31,6 +31,7 @@ unsigned MemoInfoImpl::GetIndex(MemoServ::Memo *m)
for (unsigned i = 0; i < memos.size(); ++i)
if (this->GetMemo(i) == m)
return i;
+#warning "-1 unsigned?"
return -1; // XXX wtf?
}
@@ -70,6 +71,16 @@ void MemoInfoImpl::SetMemoMax(const int16_t &i)
Set(&MemoInfoType::memomax, i);
}
+bool MemoInfoImpl::IsHardMax()
+{
+ return Get(&MemoInfoType::hardmax);
+}
+
+void MemoInfoImpl::SetHardMax(bool hardmax)
+{
+ Set(&MemoInfoType::hardmax, hardmax);
+}
+
std::vector<MemoServ::Memo *> MemoInfoImpl::GetMemos()
{
return GetRefs<MemoServ::Memo *>();
diff --git a/modules/memoserv/main/memoinfo.h b/modules/memoserv/main/memoinfo.h
index 79deb496b..3232262a3 100644
--- a/modules/memoserv/main/memoinfo.h
+++ b/modules/memoserv/main/memoinfo.h
@@ -25,6 +25,7 @@ class MemoInfoImpl : public MemoServ::MemoInfo
Serialize::Object *owner = nullptr;
int16_t memomax = 0;
+ bool hardmax = false;
public:
MemoInfoImpl(Serialize::TypeBase *type) : MemoServ::MemoInfo(type) { }
@@ -41,6 +42,9 @@ class MemoInfoImpl : public MemoServ::MemoInfo
int16_t GetMemoMax() override;
void SetMemoMax(const int16_t &) override;
+ bool IsHardMax() override;
+ void SetHardMax(bool) override;
+
std::vector<MemoServ::Memo *> GetMemos() override;
std::vector<MemoServ::Ignore *> GetIgnores() override;
};
diff --git a/modules/memoserv/main/memoinfotype.cpp b/modules/memoserv/main/memoinfotype.cpp
index 3447de5c8..27e3bba75 100644
--- a/modules/memoserv/main/memoinfotype.cpp
+++ b/modules/memoserv/main/memoinfotype.cpp
@@ -23,6 +23,7 @@
MemoInfoType::MemoInfoType(Module *me) : Serialize::Type<MemoInfoImpl>(me)
, owner(this, "owner", &MemoInfoImpl::owner, true)
, memomax(this, "memomax", &MemoInfoImpl::memomax)
+ , hardmax(this, "hardmax", &MemoInfoImpl::hardmax)
{
}
diff --git a/modules/memoserv/main/memoinfotype.h b/modules/memoserv/main/memoinfotype.h
index 97af31917..1a45b361a 100644
--- a/modules/memoserv/main/memoinfotype.h
+++ b/modules/memoserv/main/memoinfotype.h
@@ -24,6 +24,7 @@ class MemoInfoType : public Serialize::Type<MemoInfoImpl>
public:
Serialize::ObjectField<MemoInfoImpl, Serialize::Object *> owner;
Serialize::Field<MemoInfoImpl, int16_t> memomax;
+ Serialize::Field<MemoInfoImpl, bool> hardmax;
MemoInfoType(Module *);
};
diff --git a/modules/memoserv/main/memoserv.cpp b/modules/memoserv/main/memoserv.cpp
index 4fe747472..3b2b7cd17 100644
--- a/modules/memoserv/main/memoserv.cpp
+++ b/modules/memoserv/main/memoserv.cpp
@@ -133,7 +133,7 @@ class MemoServCore : public Module, public MemoServ::MemoServService
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
{
- if (cu->user->Account() && cu->user->Account()->HasFieldS("MEMO_RECEIVE"))
+ if (cu->user->Account() && cu->user->Account()->IsMemoReceive())
cu->user->SendMessage(*MemoServ, _("There is a new memo on channel \002{0}\002. Type \002{1}{2} READ {3} {4}\002 to read it."), ci->GetName(), Config->StrictPrivmsg, MemoServ->nick, ci->GetName(), mi->GetMemos().size()); // XXX
}
}
@@ -143,12 +143,12 @@ class MemoServCore : public Module, public MemoServ::MemoServService
{
NickServ::Account *nc = NickServ::FindNick(target)->GetAccount();
- if (nc->HasFieldS("MEMO_RECEIVE"))
+ if (nc->IsMemoReceive())
for (User *u : nc->users)
u->SendMessage(*MemoServ, _("You have a new memo from \002{0}\002. Type \002{1}{2} READ {3}\002 to read it."), source, Config->StrictPrivmsg, MemoServ->nick, mi->GetMemos().size());//XXX
/* let's get out the mail if set in the nickcore - certus */
- if (nc->HasFieldS("MEMO_MAIL"))
+ if (nc->IsMemoMail())
SendMemoMail(nc, mi, m);
}
diff --git a/modules/memoserv/send.cpp b/modules/memoserv/send.cpp
index 418a82c21..4cdbc0eb3 100644
--- a/modules/memoserv/send.cpp
+++ b/modules/memoserv/send.cpp
@@ -43,7 +43,7 @@ class CommandMSSend : public Command
return;
}
- if (source.GetAccount()->HasFieldS("UNCONFIRMED"))
+ if (source.GetAccount()->IsUnconfirmed())
{
source.Reply(_("You must confirm your account before you may send a memo."));
return;
diff --git a/modules/memoserv/set.cpp b/modules/memoserv/set.cpp
index 13d24bd98..12f5e5b8d 100644
--- a/modules/memoserv/set.cpp
+++ b/modules/memoserv/set.cpp
@@ -33,27 +33,27 @@ class CommandMSSet : public Command
if (param.equals_ci("ON"))
{
- nc->SetS<bool>("MEMO_SIGNON", true);
- nc->SetS<bool>("MEMO_RECEIVE", true);
+ nc->SetMemoSignon(true);
+ nc->SetMemoReceive(true);
source.Reply(_("\002{0}\002 will now notify you of memos when you log on and when they are sent to you."), MemoServ->nick);
}
else if (param.equals_ci("LOGON"))
{
- nc->SetS<bool>("MEMO_SIGNON", true);
- nc->UnsetS<bool>("MEMO_RECEIVE");
+ nc->SetMemoSignon(true);
+ nc->SetMemoReceive(false);
source.Reply(_("\002{0}\002 will now notify you of memos when you log on or unset /AWAY."), MemoServ->nick);
}
else if (param.equals_ci("NEW"))
{
- nc->UnsetS<bool>("MEMO_SIGNON");
- nc->SetS<bool>("MEMO_RECEIVE", true);
+ nc->SetMemoSignon(false);
+ nc->SetMemoReceive(true);
source.Reply(_("\002{0}\002 will now notify you of memos when they are sent to you."), MemoServ->nick);
}
else if (param.equals_ci("MAIL"))
{
if (!nc->GetEmail().empty())
{
- nc->SetS<bool>("MEMO_MAIL", true);
+ nc->SetMemoMail(true);
source.Reply(_("You will now be informed about new memos via email."));
}
else
@@ -63,14 +63,14 @@ class CommandMSSet : public Command
}
else if (param.equals_ci("NOMAIL"))
{
- nc->UnsetS<bool>("MEMO_MAIL");
+ nc->SetMemoMail(false);
source.Reply(_("You will no longer be informed via email."));
}
else if (param.equals_ci("OFF"))
{
- nc->UnsetS<bool>("MEMO_SIGNON");
- nc->UnsetS<bool>("MEMO_RECEIVE");
- nc->UnsetS<bool>("MEMO_MAIL");
+ nc->SetMemoSignon(false);
+ nc->SetMemoReceive(false);
+ nc->SetMemoMail(false);
source.Reply(_("\002{0}\002 will not send you any notification of memos."), MemoServ->nick);
}
else
@@ -138,16 +138,16 @@ class CommandMSSet : public Command
if (!chan.empty())
{
if (!p2.empty())
- ci->SetS<bool>("MEMO_HARDMAX", true);
+ mi->SetHardMax(true);
else
- ci->UnsetS<bool>("MEMO_HARDMAX");
+ mi->SetHardMax(false);
}
else
{
if (!p2.empty())
- nc->SetS<bool>("MEMO_HARDMAX", true);
+ mi->SetHardMax(true);
else
- nc->UnsetS<bool>("MEMO_HARDMAX");
+ mi->SetHardMax(false);
}
limit = -1;
try
@@ -163,12 +163,12 @@ class CommandMSSet : public Command
this->OnSyntaxError(source, "");
return;
}
- if (!chan.empty() && ci->HasFieldS("MEMO_HARDMAX"))
+ if (!chan.empty() && mi->IsHardMax())
{
source.Reply(_("The memo limit for \002{0}\002 may not be changed."), chan);
return;
}
- if (chan.empty() && nc->HasFieldS("MEMO_HARDMAX"))
+ if (chan.empty() && mi->IsHardMax())
{
source.Reply(_("You are not permitted to change your memo limit."));
return;
@@ -315,17 +315,10 @@ class CommandMSSet : public Command
class MSSet : public Module
{
CommandMSSet commandmsset;
- Serialize::Field<NickServ::Account, bool> memo_signon, memo_receive, memo_mail, memo_hardmax_nick;
- Serialize::Field<ChanServ::Channel, bool> memo_hardmax_channel;
public:
MSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
, commandmsset(this)
- , memo_signon(this, "MEMO_SIGNON")
- , memo_receive(this, "MEMO_RECEIVE")
- , memo_mail(this, "MEMO_MAIL")
- , memo_hardmax_nick(this, "MEMO_HARDMAX")
- , memo_hardmax_channel(this, "MEMO_HARDMAX")
{
}