Added an Out for Lunch status
[centerim.git] / src / imexternal.h
blob8533564e2b6f7e678e4e71b01b6ea16d4b45cb7d
1 #ifndef __IMEXTERNAL_H__
2 #define __IMEXTERNAL_H__
4 #include "imevents.h"
6 class imexternal {
7 public:
8 enum aoption {
9 aostdin = 2,
10 aostdout = 4,
11 aoprereceive = 8,
12 aopresend = 16,
13 aomanual = 32,
14 aonowait = 64
17 struct actioninfo {
18 string name;
19 bool enabled;
22 private:
23 class action {
24 private:
25 set<imevent::imeventtype> event;
26 set<protocolname> proto;
27 set<imstatus> status;
29 int options;
30 bool enabled;
31 string name, code, sname, output;
33 imevent *currentev;
35 void writescript();
36 int execscript();
38 void respond();
39 void substitute();
41 static string geteventname(imevent::imeventtype et);
43 public:
44 action();
45 ~action();
47 bool exec(imevent *ev, int &result, int option);
48 bool exec(const imcontact &ic, string &outbuf);
50 bool load(ifstream &f);
52 bool matches(int aoptions, protocolname apname) const;
53 string getname() const { return name; }
56 vector<action> actions;
58 public:
59 imexternal();
60 ~imexternal();
62 void load();
64 int exec(const imevent &ev);
65 int exec(imevent *ev, bool &result, int option = 0);
66 // returns the amount of external actions ran
67 // option can be aopresend or aoprereceive if needed
68 // and "result" is filled in with a bool that indicates
69 // if the event is accepted or not
71 bool execmanual(const imcontact &ic, int id, string &outbuf);
73 vector<pair<int, string> > getlist(int options, protocolname pname) const;
76 extern imexternal external;
78 #endif