Skip to content

Commit 06d4a43

Browse files
committed
Changes to plugin callbacks to support miniwindows
1 parent a03c93b commit 06d4a43

File tree

8 files changed

+196
-354
lines changed

8 files changed

+196
-354
lines changed

OtherTypes.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,17 @@ class CScriptDispatchID
938938
typedef map<const string, CScriptDispatchID> CScriptDispatchIDsMap;
939939
typedef map<const string, CScriptDispatchID>::const_iterator CScriptDispatchIDIterator;
940940

941+
class CScriptCallInfo
942+
{
943+
public:
944+
945+
CScriptCallInfo (const string name, CScriptDispatchID & dispid_info)
946+
: _dispid_info (dispid_info), _name (name) {};
947+
948+
CScriptDispatchID & _dispid_info;
949+
const string _name;
950+
951+
}; // end of class CScriptCallInfo
941952

942953
class CScriptEngine;
943954

@@ -996,22 +1007,22 @@ class CPlugin :public CObject
9961007
~CPlugin (); // destructor
9971008
bool SaveState (const bool bScripted = false);
9981009
DISPID GetPluginDispid (const char * sName);
999-
void ExecutePluginScript (const char * sName); // no arguments
1000-
bool ExecutePluginScript (const char * sName,
1010+
void ExecutePluginScript (CScriptCallInfo & callinfo); // no arguments
1011+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
10011012
const char * sText); // 1 argument
1002-
bool ExecutePluginScript (const char * sName,
1013+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
10031014
const long arg1, // 2 arguments
10041015
const string sText);
1005-
bool ExecutePluginScript (const char * sName,
1016+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
10061017
const long arg1, // 3 arguments
10071018
const long arg2,
10081019
const string sText);
1009-
bool ExecutePluginScript (const char * sName,
1020+
bool ExecutePluginScript (CScriptCallInfo & callinfo,
10101021
const long arg1, // 1 number, 3 strings
10111022
const char * arg2,
10121023
const char * arg3,
10131024
const char * arg4);
1014-
void ExecutePluginScriptRtn (const char * sName,
1025+
void ExecutePluginScriptRtn (CScriptCallInfo & callinfo,
10151026
CString & strResult); // taking and returning a string
10161027

10171028
};

doc.cpp

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8050,30 +8050,32 @@ static bool bInPluginListChanged = false;
80508050
} // end CMUSHclientDoc::PluginListChanged
80518051

80528052

8053-
void CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName) // no arguments
8053+
void CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName) // no arguments
80548054
{
80558055
CPlugin * pSavedPlugin = m_CurrentPlugin;
8056-
m_CurrentPlugin = NULL; // not sure about this
80578056

80588057
// tell a plugin the message
80598058
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
80608059
{
80618060
CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
80628061

8063-
if (pPlugin->m_bEnabled) // ignore disabled plugins
8064-
pPlugin->ExecutePluginScript (sName);
8062+
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
8063+
continue;
80658064

8066-
} // end of doing each plugin
8065+
// change to this plugin, call function, put current plugin back
8066+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8067+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8068+
pPlugin->ExecutePluginScript (callinfo);
8069+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
80678070

8068-
m_CurrentPlugin = pSavedPlugin;
8071+
} // end of doing each plugin
80698072

80708073
} // end of CMUSHclientDoc::SendToAllPluginCallbacks
80718074

80728075
// this is for when we want the first available plugin to handle something (eg. Trace, Sound)
80738076
bool CMUSHclientDoc::SendToFirstPluginCallbacks (const char * sName, const char * sText) // one argument
80748077
{
80758078
CPlugin * pSavedPlugin = m_CurrentPlugin;
8076-
m_CurrentPlugin = NULL; // not sure about this
80778079

80788080
// tell a plugin the message
80798081
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
@@ -8083,19 +8085,20 @@ bool CMUSHclientDoc::SendToFirstPluginCallbacks (const char * sName, const char
80838085
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
80848086
continue;
80858087

8086-
// see what the plugin makes of this,
8087-
pPlugin->ExecutePluginScript (sName, sText);
8088+
// change to this plugin, call function, put current plugin back
8089+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8090+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8091+
pPlugin->ExecutePluginScript (callinfo, sText);
8092+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
80888093

8089-
if (pPlugin->m_PluginCallbacks [sName].isvalid ())
8094+
if (callinfo._dispid_info.isvalid ())
80908095
{
80918096
m_CurrentPlugin = pSavedPlugin;
80928097
return true; // indicate we found it
80938098
}
80948099

80958100
} // end of doing each plugin
80968101

8097-
m_CurrentPlugin = pSavedPlugin;
8098-
80998102
return false; // didn't find one
81008103
} // end of CMUSHclientDoc::SendToFirstPluginCallbacks
81018104

@@ -8107,25 +8110,28 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
81078110
const bool bStopOnFalse)
81088111
{
81098112
CPlugin * pSavedPlugin = m_CurrentPlugin;
8110-
m_CurrentPlugin = NULL; // not sure about this
81118113
bool bResult = true; // assume they OK'd something
81128114

81138115
// tell a plugin the message
81148116
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
81158117
{
81168118
CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
81178119

8118-
if (pPlugin->m_bEnabled) // ignore disabled plugins
8119-
if (!pPlugin->ExecutePluginScript (sName, sText))
8120+
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
8121+
continue;
8122+
8123+
// change to this plugin, call function, put current plugin back
8124+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8125+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8126+
if (!pPlugin->ExecutePluginScript (callinfo, sText))
81208127
bResult = false;
8128+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
81218129

8122-
if (bStopOnFalse && !bResult && pPlugin->m_PluginCallbacks [sName].isvalid ())
8130+
if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
81238131
return false;
81248132

81258133
} // end of doing each plugin
81268134

8127-
m_CurrentPlugin = pSavedPlugin;
8128-
81298135
return bResult;
81308136
} // end of CMUSHclientDoc::SendToAllPluginCallbacks
81318137

@@ -8134,19 +8140,22 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
81348140
void CMUSHclientDoc::SendToAllPluginCallbacksRtn (const char * sName, CString & strResult) // taking and returning a string
81358141
{
81368142
CPlugin * pSavedPlugin = m_CurrentPlugin;
8137-
m_CurrentPlugin = NULL; // not sure about this
81388143

81398144
// tell a plugin the message
81408145
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
81418146
{
81428147
CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
81438148

8144-
if (pPlugin->m_bEnabled) // ignore disabled plugins
8145-
pPlugin->ExecutePluginScriptRtn (sName, strResult);
8149+
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
8150+
continue;
81468151

8147-
} // end of doing each plugin
8152+
// change to this plugin, call function, put current plugin back
8153+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8154+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8155+
pPlugin->ExecutePluginScriptRtn (callinfo, strResult);
8156+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
81488157

8149-
m_CurrentPlugin = pSavedPlugin;
8158+
} // end of doing each plugin
81508159

81518160
} // end of CMUSHclientDoc::SendToAllPluginCallbacks
81528161

@@ -8159,7 +8168,6 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
81598168
const bool bStopOnFalse)
81608169
{
81618170
CPlugin * pSavedPlugin = m_CurrentPlugin;
8162-
m_CurrentPlugin = NULL; // not sure about this
81638171

81648172
// tell a plugin the message
81658173
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
@@ -8169,17 +8177,20 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
81698177
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
81708178
continue;
81718179

8172-
bool bResult = pPlugin->ExecutePluginScript (sName, arg1, sText);
8180+
// change to this plugin, call function, put current plugin back
8181+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8182+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8183+
bool bResult = pPlugin->ExecutePluginScript (callinfo, arg1, sText);
8184+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
81738185

8174-
if (bStopOnTrue && bResult && pPlugin->m_PluginCallbacks [sName].isvalid ())
8186+
if (bStopOnTrue && bResult && callinfo._dispid_info.isvalid ())
81758187
return true;
81768188

8177-
if (bStopOnFalse && !bResult && pPlugin->m_PluginCallbacks [sName].isvalid ())
8189+
if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
81788190
return false;
81798191

81808192
} // end of doing each plugin
81818193

8182-
m_CurrentPlugin = pSavedPlugin;
81838194

81848195
if (bStopOnTrue)
81858196
return false;
@@ -8197,7 +8208,6 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
81978208
const bool bStopOnFalse)
81988209
{
81998210
CPlugin * pSavedPlugin = m_CurrentPlugin;
8200-
m_CurrentPlugin = NULL; // not sure about this
82018211

82028212
// tell a plugin the message
82038213
for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
@@ -8207,18 +8217,20 @@ bool CMUSHclientDoc::SendToAllPluginCallbacks (const char * sName,
82078217
if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
82088218
continue;
82098219

8210-
bool bResult = pPlugin->ExecutePluginScript (sName, arg1, arg2, sText);
8220+
// change to this plugin, call function, put current plugin back
8221+
m_CurrentPlugin = pPlugin; // so plugin knows who it is
8222+
CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
8223+
bool bResult = pPlugin->ExecutePluginScript (callinfo, arg1, arg2, sText);
8224+
m_CurrentPlugin = pSavedPlugin; // back to current plugin
82118225

8212-
if (bStopOnTrue && bResult && pPlugin->m_PluginCallbacks [sName].isvalid ())
8226+
if (bStopOnTrue && bResult && callinfo._dispid_info.isvalid ())
82138227
return true;
82148228

8215-
if (bStopOnFalse && !bResult && pPlugin->m_PluginCallbacks [sName].isvalid ())
8229+
if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
82168230
return false;
82178231

82188232
} // end of doing each plugin
82198233

8220-
m_CurrentPlugin = pSavedPlugin;
8221-
82228234
if (bStopOnTrue)
82238235
return false;
82248236
else

mushclient.clw

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)