- // when a user quits, tidy up their metadata
- virtual void OnUserQuit(User* user, const std::string &message, const std::string &oper_message)
- {
- std::string* swhois;
- user->GetExt("swhois", swhois);
- if (swhois)
- {
- user->Shrink("swhois");
- delete swhois;
- }
- }
-
- // if the module is unloaded, tidy up all our dangling metadata
- virtual void OnCleanup(int target_type, void* item)
- {
- if (target_type == TYPE_USER)
- {
- User* user = (User*)item;
- std::string* swhois;
- user->GetExt("swhois", swhois);
- if (swhois)
- {
- user->Shrink("swhois");
- delete swhois;
- }
- }
- }
-
- // Whenever the linking module receives metadata from another server and doesnt know what
- // to do with it (of course, hence the 'meta') it calls this method, and it is up to each
- // module in turn to figure out if this metadata key belongs to them, and what they want
- // to do with it.
- // In our case we're only sending a single string around, so we just construct a std::string.
- // Some modules will probably get much more complex and format more detailed structs and classes
- // in a textual way for sending over the link.
- virtual void OnDecodeMetaData(int target_type, void* target, const std::string &extname, const std::string &extdata)
- {
- // check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "swhois"))
- {
- User* dest = (User*)target;
-
- // if they already have an swhois field, trash it and replace it with the remote one.
- std::string* text;
- if (dest->GetExt("swhois", text))
- {
- dest->Shrink("swhois");
- delete text;
- }
-
- if (extdata.empty())
- return; // XXX does the command parser even allow sending blank mdata? it needs to here! -- w00t
-
- text = new std::string(extdata);
- dest->Extend("swhois", text);
- }
- }
-
- virtual void OnPostCommand(const std::string &command, const std::vector<std::string> ¶ms, User *user, CmdResult result, const std::string &original_line)