- // 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, std::string extname, std::string extdata)
- {
- // check if its our metadata key, and its associated with a user
- if ((target_type == TYPE_USER) && (extname == "swhois"))
- {
- userrec* dest = (userrec*)target;
- // if they dont already have an swhois field, accept the remote server's
- if (!dest->GetExt("swhois"))
- {
- std::string* text = new std::string(extdata);
- dest->Extend("swhois",(char*)text);
- }
- }
- }
-
- virtual void OnOper(userrec* user, std::string opertype)
- {
- for(int i =0; i < Conf->Enumerate("type"); i++)
- {
- std::string type = Conf->ReadValue("type", "name", i);
-
- if(strcmp(type.c_str(), user->oper) == 0)
- {
- std::string swhois = Conf->ReadValue("type", "swhois", i);
-
- if(swhois.length())
- {
- if(std::string* old = (std::string*)user->GetExt("swhois"))
- {
- user->Shrink("swhois");
- delete old;
- }
-
- std::string* text = new std::string(swhois);
- user->Extend("swhois", (char*)text);
-
- break;
- }
- }
- }
- }
-
- virtual ~ModuleSWhois()
- {
- delete Conf;
- }
-
- virtual Version GetVersion()
- {
- return Version(1,0,0,0,VF_VENDOR);
- }
-};