botkernel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029 #ifndef BOTKERNEL_H
00030 #define BOTKERNEL_H
00031
00032
00033
00034
00035
00036
00037 #include "message.h"
00038 #include "ircprotocol.h"
00039 #include "configurationfile.h"
00040 #include "logfile.h"
00041 #include "tools.h"
00042 #include "socket.h"
00043 #include "plugin.h"
00044 #include "cppthread.h"
00045 #include <sys/time.h>
00046 #include <sys/types.h>
00047 #include <semaphore.h>
00048 #include <errno.h>
00049 #include <dlfcn.h>
00050 #include <dirent.h>
00051 #include <time.h>
00052 #include <list>
00053 using namespace std;
00054
00056 typedef struct
00057 {
00058 time_t last_decrease;
00059 int penality ;
00060 }AntiExcessFlood;
00061
00063 typedef struct {
00064 StructFunctionStorage function;
00065 Message msg;
00066 time_t timestamp;
00067 unsigned int count;
00068 }CountDownFunction;
00069
00071 typedef struct {
00072 StructFunctionStorage* function;
00073 Message* msg;
00074 BotKernel* b;
00075 sem_t* sem;
00076 }ThreadParams;
00077
00083 class BotKernel
00084 {
00085 public:
00087 BotKernel(string);
00089 ~BotKernel();
00091 plugin_function registerFunction(string,Plugin*,func_type,string,plugin_function,time_t,unsigned int);
00093 void unregisterFunction(plugin_function);
00095 plugin_function addCountDown(Plugin*,plugin_function,Message*,unsigned int,unsigned int);
00097 void run();
00099 void stop();
00101 void send(string);
00103 void send(vector<string>);
00105 string getVersion();
00107 string getDescription();
00109 string getAuthor();
00111 void setConnected(bool);
00113 bool getConnected();
00115 LogFile* getSysLog();
00117 string getNick();
00119 void setNick(string);
00121 bool loadPlugin(string,bool);
00123 bool unloadPlugin(string,bool);
00125 pPlugin* getPlugin(string);
00127 vector<string> getPluginsList();
00129 time_t getStartTime();
00131 time_t getStartOnline();
00133 vector<CountDownFunction>* getCountDowns();
00135 ConfigurationFile* getCONFF();
00137 string getDatasDir();
00138
00139 private:
00141 bool connected;
00143 string version;
00145 string description;
00147 string author;
00149 list<string> sendQueue;
00151 bool turn;
00153 string datasDir;
00155 bool verbose;
00157 time_t startTime;
00159 time_t startOnline;
00161 LogFile* myLog;
00163 ConfigurationFile * conff;
00165 Socket* sock;
00167 vector<StructFunctionStorage> in_loop_plugins;
00169 vector<StructFunctionStorage> in_free_command_handler_plugins;
00171 vector<StructFunctionStorage> in_command_handler_plugins;
00173 vector<StructFunctionStorage> in_type_handler_plugins;
00175 vector<StructFunctionStorage> in_before_treatment_plugins;
00177 vector<StructFunctionStorage> in_all_msgs_plugins;
00179 vector<StructFunctionStorage> in_first_word_plugins;
00181 vector<StructFunctionStorage> out_all_msgs_plugins;
00183 vector<pPlugin> myPlugins;
00185 vector<CountDownFunction> countDowns;
00187 string nick ;
00189 void displayLicenceHeader();
00191 void initDirs() ;
00193 bool executeFunction(Message*,StructFunctionStorage);
00195 plugin_function storeFunction(StructFunctionStorage*);
00197 AntiExcessFlood AEX;
00199 void msgTreatment(Message*);
00201 void connect();
00203 void reconnect();
00205 void loadPlugins(bool);
00207 void unloadMyPlugins(bool);
00209 bool pluginLoaded(string);
00211 bool pluginLoaded(void*);
00212 };
00213 #endif