00001 /* 00002 00003 $Log$ 00003 Revision 1.1 2003/01/23 19:45:58 brain 00003 Initial revision 00003 00003 Revision 1.9 2003/01/22 20:59:12 brain 00003 Added FileReader class documentation 00003 00004 Revision 1.11 2003/01/22 20:49:16 brain 00005 Added FileReader file-caching class 00006 Changed m_randquote to use FileReader class 00007 00008 Revision 1.10 2003/01/22 00:57:27 brain 00009 Changes to documentation 00010 00011 Revision 1.9 2003/01/22 00:44:26 brain 00012 Added documentation comments 00013 00014 Revision 1.8 2003/01/21 20:31:24 brain 00015 Modified to add documentation 00016 Added ConfigReader class for modules 00017 00018 Revision 1.7 2003/01/15 22:47:44 brain 00019 Changed user and channel structs to classes (finally) 00020 00021 Revision 1.6 2003/01/13 22:30:50 brain 00022 Added Admin class (holds /admin info for modules) 00023 Added methods to Server class 00024 00025 00026 */ 00027 00028 00029 #ifndef __PLUGIN_H 00030 #define __PLUGIN_H 00031 00032 #include "dynamic.h" 00033 #include <string> 00034 #include <deque> 00035 00038 typedef deque<string> file_cache; 00039 00040 00041 // This #define allows us to call a method in all 00042 // loaded modules in a readable simple way, e.g.: 00043 // 'FOREACH_MOD OnConnect(user);' 00044 00045 #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]-> 00046 00047 // class Version holds the version information of a Module, returned 00048 // by Module::GetVersion (thanks RD) 00049 00054 class Version 00055 { 00056 public: 00057 const int Major, Minor, Revision, Build; 00058 Version(int major, int minor, int revision, int build); 00059 }; 00060 00061 00067 class Admin 00068 { 00069 public: 00070 const string Name, Email, Nick; 00071 Admin(string name,string email,string nick); 00072 }; 00073 00079 class Module 00080 { 00081 public: 00085 Module(); 00089 virtual ~Module(); 00094 virtual Version GetVersion(); 00098 virtual void OnUserConnect(userrec* user); 00102 virtual void OnUserQuit(userrec* user); 00107 virtual void OnUserJoin(userrec* user, chanrec* channel); 00112 virtual void OnUserPart(userrec* user, chanrec* channel); 00113 }; 00114 00115 00121 class Server 00122 { 00123 public: 00127 Server(); 00131 virtual ~Server(); 00132 00136 virtual void SendOpers(string s); 00141 virtual void Debug(string s); 00146 virtual void Send(int Socket, string s); 00151 virtual void SendServ(int Socket, string s); 00156 virtual void SendFrom(int Socket, userrec* User, string s); 00161 virtual void SendTo(userrec* Source, userrec* Dest, string s); 00168 virtual void SendChannel(userrec* User, chanrec* Channel, string s,bool IncludeSender); 00173 virtual bool CommonChannels(userrec* u1, userrec* u2); 00181 virtual void SendCommon(userrec* User, string text,bool IncludeSender); 00186 virtual void SendWallops(userrec* User, string text); 00187 00191 virtual bool IsNick(string nick); 00195 virtual userrec* FindNick(string nick); 00199 virtual chanrec* FindChannel(string channel); 00204 virtual string ChanMode(userrec* User, chanrec* Chan); 00207 virtual string GetServerName(); 00210 virtual string GetNetworkName(); 00216 virtual Admin GetAdmin(); 00217 00218 }; 00219 00226 class ConfigReader 00227 { 00228 protected: 00231 string fname; 00232 public: 00237 ConfigReader(); // default constructor reads ircd.conf 00241 ConfigReader(string filename); // read a module-specific config 00245 ~ConfigReader(); 00250 string ReadValue(string tag, string name, int index); 00257 int Enumerate(string tag); 00261 bool Verify(); 00262 }; 00263 00264 00265 00271 class FileReader 00272 { 00273 file_cache fc; 00274 public: 00279 FileReader(); 00285 FileReader(string filename); 00289 ~FileReader(); 00295 void LoadFile(string filename); 00300 string GetLine(int x); 00306 int FileSize(); 00307 }; 00308 00309 00316 class ModuleFactory 00317 { 00318 public: 00319 ModuleFactory() { } 00320 virtual ~ModuleFactory() { } 00325 virtual Module * CreateModule() = 0; 00326 }; 00327 00328 #endif