Skip to content

Commit e38cf98

Browse files
committed
Moved plugin definitions to plugins.h
1 parent d1b453f commit e38cf98

File tree

1 file changed

+204
-0
lines changed

1 file changed

+204
-0
lines changed

plugins.h

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/////////////////////////////////////////////////////////////////////////////
2+
// CPlugin - these are world plugins
3+
4+
// for storing dispatch IDs, and how many times each one is called
5+
class CScriptDispatchID
6+
{
7+
public:
8+
// default constructor
9+
CScriptDispatchID () :
10+
_dispid (DISPID_UNKNOWN),
11+
_count (0) {};
12+
13+
// copy constructor
14+
CScriptDispatchID (const CScriptDispatchID & d)
15+
: _dispid (d._dispid),
16+
_count (d._count)
17+
{};
18+
19+
// operator =
20+
const CScriptDispatchID & operator= (const CScriptDispatchID & rhs)
21+
{
22+
_dispid = rhs._dispid;
23+
_count = rhs._count;
24+
return *this;
25+
};
26+
27+
// returns true if DISPID is valid
28+
inline bool isvalid () const { return _dispid != DISPID_UNKNOWN; };
29+
30+
DISPID _dispid; // the dispatch ID from the COM engine, or DISPID_UNKNOWN
31+
__int64 _count; // count of attempts to call it (if not DISPID_UNKNOWN)
32+
}; // end of class CScriptDispatchID
33+
34+
typedef map<const string, CScriptDispatchID> CScriptDispatchIDsMap;
35+
typedef map<const string, CScriptDispatchID>::const_iterator CScriptDispatchIDIterator;
36+
37+
class CScriptCallInfo
38+
{
39+
public:
40+
41+
CScriptCallInfo (const string name, CScriptDispatchID & dispid_info)
42+
: _dispid_info (dispid_info), _name (name) {};
43+
44+
CScriptDispatchID & _dispid_info;
45+
const string _name;
46+
47+
}; // end of class CScriptCallInfo
48+
49+
class CScriptEngine;
50+
51+
class CPlugin :public CObject
52+
{
53+
54+
public:
55+
56+
CString m_strName; // name of plugin
57+
CString m_strAuthor; // who wrote it
58+
CString m_strPurpose; // what it does (short description)
59+
CString m_strDescription; // what it does (long description)
60+
CString m_strScript; // script source (ie. from <script> tags)
61+
CString m_strLanguage; // script language (eg. vbscript)
62+
CString m_strSource; // include file that contains this plugin
63+
CString m_strDirectory; // directory source is in (m_strSource minus the actual filename)
64+
CString m_strID; // unique ID
65+
CTime m_tDateWritten; // date written
66+
CTime m_tDateModified; // date last modified
67+
double m_dVersion; // plugin version
68+
double m_dRequiredVersion; // minimum MUSHclient version required
69+
CTime m_tDateInstalled; // date installed
70+
CString m_strCallingPluginID; // during a CallPlugin - the ID of the calling plugin
71+
72+
CScriptEngine * m_ScriptEngine; // script engine for script, if any
73+
74+
CAliasMap m_AliasMap; // aliases
75+
CAliasArray m_AliasArray; // array of aliases for sequencing
76+
CAliasRevMap m_AliasRevMap; // for getting name back from pointer
77+
CTriggerMap m_TriggerMap; // triggers
78+
CTriggerArray m_TriggerArray; // array of triggers for sequencing
79+
CTriggerRevMap m_TriggerRevMap; // for getting name back from pointer
80+
CTimerMap m_TimerMap; // timers
81+
CTimerRevMap m_TimerRevMap; // for getting name back from pointer
82+
CVariableMap m_VariableMap; // variables
83+
tStringMapOfMaps m_Arrays; // map of arrays (for scripting)
84+
85+
bool m_bEnabled; // true if active (enabled)
86+
CMUSHclientDoc * m_pDoc; // related MUSHclient document
87+
bool m_bSaveState; // true to save plugin state
88+
bool m_bSendToScriptUsed; // plugin sends to script
89+
bool m_bGlobal; // true if plugin was loaded from global prefs
90+
long m_iLoadOrder; // sequence in which plugins are processed
91+
92+
// Lua note - for Lua the DISPID is a flag indicating whether or not
93+
// the routine exists. It is set to DISPID_UNKNOWN if the last call caused an error
94+
// It will be 1 if the routine exists, and DISPID_UNKNOWN if it doesn't.
95+
96+
// WARNING! PHP currently uses a DISPID of zero, so that can't be used as a "not found" flag.
97+
98+
CScriptDispatchIDsMap m_PluginCallbacks; // maps plugin callback names to their DISPIDs
99+
100+
// methods
101+
102+
CPlugin (CMUSHclientDoc * pDoc); // constructor
103+
~CPlugin (); // destructor
104+
bool SaveState (const bool bScripted = false);
105+
DISPID GetPluginDispid (const char * sName);
106+
void ExecutePluginScript (CScriptCallInfo & callinfo); // no arguments
107+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
108+
const char * sText); // 1 argument
109+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
110+
const long arg1, // 2 arguments
111+
const string sText);
112+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
113+
const long arg1, // 3 arguments
114+
const long arg2,
115+
const string sText);
116+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
117+
const long arg1, // 1 number, 3 strings
118+
const char * arg2,
119+
const char * arg3,
120+
const char * arg4);
121+
void ExecutePluginScriptRtn (CScriptCallInfo & callinfo,
122+
CString & strResult); // taking and returning a string
123+
124+
};
125+
126+
typedef CTypedPtrList <CPtrList, CPlugin*> CPluginList;
127+
128+
129+
130+
// plugin callback routines - start with OnPlugin so that we can advise
131+
// users not to use that string for their own routines
132+
133+
// install / remove
134+
const string ON_PLUGIN_INSTALL ("OnPluginInstall");
135+
const string ON_PLUGIN_CLOSE ("OnPluginClose");
136+
const string ON_PLUGIN_LIST_CHANGED ("OnPluginListChanged");
137+
138+
// connect / disconnect
139+
const string ON_PLUGIN_CONNECT ("OnPluginConnect");
140+
const string ON_PLUGIN_DISCONNECT ("OnPluginDisconnect");
141+
142+
// saving
143+
const string ON_PLUGIN_SAVE_STATE ("OnPluginSaveState");
144+
const string ON_PLUGIN_WORLD_SAVE ("OnPluginWorldSave");
145+
146+
// enable / disable
147+
const string ON_PLUGIN_ENABLE ("OnPluginEnable");
148+
const string ON_PLUGIN_DISABLE ("OnPluginDisable");
149+
150+
// the focus
151+
const string ON_PLUGIN_GETFOCUS ("OnPluginGetFocus");
152+
const string ON_PLUGIN_LOSEFOCUS ("OnPluginLoseFocus");
153+
154+
// capture stuff
155+
const string ON_PLUGIN_TRACE ("OnPluginTrace");
156+
const string ON_PLUGIN_BROADCAST ("OnPluginBroadcast");
157+
const string ON_PLUGIN_SCREENDRAW ("OnPluginScreendraw");
158+
159+
// sounds
160+
const string ON_PLUGIN_PLAYSOUND ("OnPluginPlaySound");
161+
162+
// stuff received/sent
163+
const string ON_PLUGIN_SEND ("OnPluginSend");
164+
const string ON_PLUGIN_SENT ("OnPluginSent");
165+
const string ON_PLUGIN_PARTIAL_LINE ("OnPluginPartialLine");
166+
const string ON_PLUGIN_LINE_RECEIVED ("OnPluginLineReceived");
167+
const string ON_PLUGIN_PACKET_RECEIVED ("OnPluginPacketReceived");
168+
169+
// telnet negotiation
170+
const string ON_PLUGIN_TELNET_OPTION ("OnPluginTelnetOption");
171+
const string ON_PLUGIN_TELNET_REQUEST ("OnPluginTelnetRequest");
172+
const string ON_PLUGIN_TELNET_SUBNEGOTIATION ("OnPluginTelnetSubnegotiation");
173+
const string ON_PLUGIN_IAC_GA ("OnPlugin_IAC_GA");
174+
175+
// commands
176+
const string ON_PLUGIN_COMMAND ("OnPluginCommand");
177+
const string ON_PLUGIN_COMMAND_ENTERED ("OnPluginCommandEntered");
178+
const string ON_PLUGIN_COMMAND_CHANGED ("OnPluginCommandChanged");
179+
const string ON_PLUGIN_TABCOMPLETE ("OnPluginTabComplete");
180+
181+
// resizing, ticking, moving, rhythm
182+
const string ON_PLUGIN_WORLD_OUTPUT_RESIZED ("OnPluginWorldOutputResized");
183+
const string ON_PLUGIN_TICK ("OnPluginTick");
184+
const string ON_PLUGIN_MOUSE_MOVED ("OnPluginMouseMoved");
185+
186+
// MXP stuff
187+
const string ON_PLUGIN_MXP_START ("OnPluginMXPstart");
188+
const string ON_PLUGIN_MXP_STOP ("OnPluginMXPstop");
189+
const string ON_PLUGIN_MXP_OPENTAG ("OnPluginMXPopenTag");
190+
const string ON_PLUGIN_MXP_CLOSETAG ("OnPluginMXPcloseTag");
191+
const string ON_PLUGIN_MXP_SETVARIABLE ("OnPluginMXPsetVariable");
192+
const string ON_PLUGIN_MXP_SETENTITY ("OnPluginMXPsetEntity");
193+
const string ON_PLUGIN_MXP_ERROR ("OnPluginMXPerror");
194+
195+
// chat stuff
196+
const string ON_PLUGIN_CHAT_ACCEPT ("OnPluginChatAccept");
197+
const string ON_PLUGIN_CHAT_MESSAGE ("OnPluginChatMessage");
198+
const string ON_PLUGIN_CHAT_MESSAGE_OUT ("OnPluginChatMessageOut");
199+
const string ON_PLUGIN_CHAT_DISPLAY ("OnPluginChatDisplay");
200+
const string ON_PLUGIN_CHAT_NEWUSER ("OnPluginChatNewUser");
201+
const string ON_PLUGIN_CHAT_USERDISCONNECT ("OnPluginChatUserDisconnect");
202+
203+
// table of callbacks
204+
extern string PluginCallbacksNames [];

0 commit comments

Comments
 (0)