diff options
| author | Adam <Adam@anope.org> | 2014-05-28 12:07:29 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-05-28 12:07:54 -0400 |
| commit | f29e1cf383529a1a29f02b0669d973f5ee0b7a66 (patch) | |
| tree | 3c33db276dc9328235bbd572641521ed44458176 /include/modules/memoserv.h | |
| parent | 1253c70e0682fa1490c99c3d2869049a0e3fa2e0 (diff) | |
Move most of the core pseudoclient logic to modules
Diffstat (limited to 'include/modules/memoserv.h')
| -rw-r--r-- | include/modules/memoserv.h | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h index 4e5d67de6..99f34b6e9 100644 --- a/include/modules/memoserv.h +++ b/include/modules/memoserv.h @@ -6,6 +6,10 @@ * */ +#pragma once + +#include "module.h" + namespace MemoServ { class MemoServService : public Service @@ -18,26 +22,29 @@ namespace MemoServ MEMO_TOO_FAST, MEMO_TARGET_FULL }; - + MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") { } - + /** Sends a memo. * @param source The source of the memo, can be anythin. * @param target The target of the memo, nick or channel. * @param message Memo text * @param force true to force the memo, restrictions/delays etc are not checked */ - virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; - + virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) anope_abstract; + /** Check for new memos and notify the user if there are any * @param u The user */ - virtual void Check(User *u) = 0; + virtual void Check(User *u) anope_abstract; + + virtual Memo *CreateMemo() anope_abstract; + virtual MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_registered, bool &is_chan, bool create) anope_abstract; }; static ServiceReference<MemoServService> service("MemoServService", "MemoServ"); - + namespace Event { struct CoreExport MemoSend : Events @@ -51,7 +58,7 @@ namespace MemoServ virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) anope_abstract; }; static EventHandlersReference<MemoSend> OnMemoSend("OnMemoSend"); - + struct CoreExport MemoDel : Events { /** Called when a memo is deleted @@ -63,4 +70,41 @@ namespace MemoServ }; static EventHandlersReference<MemoDel> OnMemoDel("OnMemoDel"); } + + class Memo : public Serializable + { + public: + bool unread; + bool receipt; + protected: + Memo() : Serializable("Memo") { } + public: + + Anope::string owner; + /* When it was sent */ + time_t time; + Anope::string sender; + Anope::string text; + }; + + /* Memo info structures. Since both nicknames and channels can have memos, + * we encapsulate memo data in a MemoInfo to make it easier to handle. + */ + struct CoreExport MemoInfo + { + int16_t memomax = 0; + Serialize::Checker<std::vector<Memo *> > memos; + std::vector<Anope::string> ignores; + + MemoInfo() : memos("Memo") { } + virtual ~MemoInfo() { } + + virtual Memo *GetMemo(unsigned index) const anope_abstract; + + virtual unsigned GetIndex(Memo *m) const anope_abstract; + + virtual void Del(unsigned index) anope_abstract; + + virtual bool HasIgnore(User *u) anope_abstract; + }; } |
