00001 /* 00002 00003 $Log$ 00003 Revision 1.2 2003/01/23 20:38:00 brain 00003 Updated documentation scripts 00003 00004 Revision 1.1.1.1 2003/01/23 19:45:58 brain 00005 InspIRCd second source tree 00006 00007 Revision 1.12 2003/01/22 20:59:10 brain 00008 Added FileReader class documentation 00009 00010 Revision 1.11 2003/01/22 20:49:16 brain 00011 Added FileReader file-caching class 00012 Changed m_randquote to use FileReader class 00013 00014 Revision 1.10 2003/01/22 00:57:27 brain 00015 Changes to documentation 00016 00017 Revision 1.9 2003/01/22 00:44:26 brain 00018 Added documentation comments 00019 00020 Revision 1.8 2003/01/21 20:31:24 brain 00021 Modified to add documentation 00022 Added ConfigReader class for modules 00023 00024 Revision 1.7 2003/01/15 22:47:44 brain 00025 Changed user and channel structs to classes (finally) 00026 00027 Revision 1.6 2003/01/13 22:30:50 brain 00028 Added Admin class (holds /admin info for modules) 00029 Added methods to Server class 00030 00031 00032 */ 00033 00034 00035 #ifndef __PLUGIN_H 00036 #define __PLUGIN_H 00037 00038 #include "dynamic.h" 00039 #include <string> 00040 #include <deque> 00041 00044 typedef deque<string> file_cache; 00045 00046 00047 // This #define allows us to call a method in all 00048 // loaded modules in a readable simple way, e.g.: 00049 // 'FOREACH_MOD OnConnect(user);' 00050 00051 #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]-> 00052 00053 // class Version holds the version information of a Module, returned 00054 // by Module::GetVersion (thanks RD) 00055 00060 class Version 00061 { 00062 public: 00063 const int Major, Minor, Revision, Build; 00064 Version(int major, int minor, int revision, int build); 00065 }; 00066 00067 00073 class Admin 00074 { 00075 public: 00076 const string Name, Email, Nick; 00077 Admin(string name,string email,string nick); 00078 }; 00079 00085 class Module 00086 { 00087 public: 00091 Module(); 00095 virtual ~Module(); 00100 virtual Version GetVersion(); 00104 virtual void OnUserConnect(userrec* user); 00108 virtual void OnUserQuit(userrec* user); 00113 virtual void OnUserJoin(userrec* user, chanrec* channel); 00118 virtual void OnUserPart(userrec* user, chanrec* channel); 00119 }; 00120 00121 00127 class Server 00128 { 00129 public: 00133 Server(); 00137 virtual ~Server(); 00138 00142 virtual void SendOpers(string s); 00147 virtual void Debug(string s); 00152 virtual void Send(int Socket, string s); 00157 virtual void SendServ(int Socket, string s); 00162 virtual void SendFrom(int Socket, userrec* User, string s); 00167 virtual void SendTo(userrec* Source, userrec* Dest, string s); 00174 virtual void SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender); 00179 virtual bool CommonChannels(userrec* u1, userrec* u2); 00187 virtual void SendCommon(userrec* User, string text,bool IncludeSender); 00192 virtual void SendWallops(userrec* User, string text); 00193 00197 virtual bool IsNick(string nick); 00201 virtual userrec* FindNick(string nick); 00205 virtual chanrec* FindChannel(string channel); 00210 virtual string ChanMode(userrec* User, chanrec* Chan); 00213 virtual string GetServerName(); 00216 virtual string GetNetworkName(); 00222 virtual Admin GetAdmin(); 00223 00224 }; 00225 00232 class ConfigReader 00233 { 00234 protected: 00237 string fname; 00238 public: 00243 ConfigReader(); // default constructor reads ircd.conf 00247 ConfigReader(string filename); // read a module-specific config 00251 ~ConfigReader(); 00256 string ReadValue(string tag, string name, int index); 00263 int Enumerate(string tag); 00267 bool Verify(); 00268 }; 00269 00270 00271 00277 class FileReader 00278 { 00279 file_cache fc; 00280 public: 00285 FileReader(); 00291 FileReader(string filename); 00295 ~FileReader(); 00301 void LoadFile(string filename); 00306 string GetLine(int x); 00312 int FileSize(); 00313 }; 00314 00315 00322 class ModuleFactory 00323 { 00324 public: 00325 ModuleFactory() { } 00326 virtual ~ModuleFactory() { } 00331 virtual Module * CreateModule() = 0; 00332 }; 00333 00334 #endif