Permalink
Browse files

Moved 'do to all' plugins functions to plugins.cpp

  • Loading branch information...
nickgammon committed Sep 18, 2010
1 parent 0f1e591 commit 5de14b97abd0c4ba55967bbb032d38ba7fd044d9
Showing with 209 additions and 207 deletions.
  1. +0 −206 doc.cpp
  2. +208 −0 plugins.cpp
  3. +1 −1 stdafx.h
View
206 doc.cpp
@@ -8031,209 +8031,3 @@ void CMUSHclientDoc::EditFileWithEditor (CString strName)
}
}
-
-// tell plugins the list of plugins may have changed
-void CMUSHclientDoc::PluginListChanged (void)
-
- {
-
-static bool bInPluginListChanged = false;
-
- // don't recurse into infinite loops
- if (bInPluginListChanged)
- return;
-
- bInPluginListChanged = true;
- SendToAllPluginCallbacks (ON_PLUGIN_LIST_CHANGED);
- bInPluginListChanged = false;
-
- } // end CMUSHclientDoc::PluginListChanged
-
-
-void CMUSHclientDoc::SendToAllPluginCallbacks (const string & sName) // no arguments
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- pPlugin->ExecutePluginScript (callinfo);
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- } // end of doing each plugin
-
- } // end of CMUSHclientDoc::SendToAllPluginCallbacks
-
-// this is for when we want the first available plugin to handle something (eg. Trace, Sound)
-bool CMUSHclientDoc::SendToFirstPluginCallbacks (const string & sName, const char * sText) // one argument
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- pPlugin->ExecutePluginScript (callinfo, sText);
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- if (callinfo._dispid_info.isvalid ())
- {
- m_CurrentPlugin = pSavedPlugin;
- return true; // indicate we found it
- }
-
- } // end of doing each plugin
-
- return false; // didn't find one
- } // end of CMUSHclientDoc::SendToFirstPluginCallbacks
-
-
-// this is for when each plugin gets a chance to "black ball" an action (like sending a line)
-// we only return true if each plugin returned true
-bool CMUSHclientDoc::SendToAllPluginCallbacks (const string & sName,
- const char * sText, // one argument
- const bool bStopOnFalse)
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
- bool bResult = true; // assume they OK'd something
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- if (!pPlugin->ExecutePluginScript (callinfo, sText))
- bResult = false;
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
- return false;
-
- } // end of doing each plugin
-
- return bResult;
- } // end of CMUSHclientDoc::SendToAllPluginCallbacks
-
-
-// this sends a string to all plugins and allows them to modify it
-void CMUSHclientDoc::SendToAllPluginCallbacksRtn (const string & sName, CString & strResult) // taking and returning a string
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- pPlugin->ExecutePluginScriptRtn (callinfo, strResult);
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- } // end of doing each plugin
-
- } // end of CMUSHclientDoc::SendToAllPluginCallbacks
-
-
-// this sends a number and a string to all plugins, and optionally stops on a true or false response
-bool CMUSHclientDoc::SendToAllPluginCallbacks (const string & sName,
- const long arg1, // 2 arguments
- const string sText,
- const bool bStopOnTrue,
- const bool bStopOnFalse)
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- bool bResult = pPlugin->ExecutePluginScript (callinfo, arg1, sText);
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- if (bStopOnTrue && bResult && callinfo._dispid_info.isvalid ())
- return true;
-
- if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
- return false;
-
- } // end of doing each plugin
-
-
- if (bStopOnTrue)
- return false;
- else
- return !bStopOnFalse; // if they wanted to stop on true, assume false and vice-versa
-
- } // end of CMUSHclientDoc::SendToAllPluginCallbacks
-
-// this sends two numbers and a string to all plugins, and optionally stops on a true or false response
-bool CMUSHclientDoc::SendToAllPluginCallbacks (const string & sName,
- const long arg1, // 3 arguments
- const long arg2,
- const string sText,
- const bool bStopOnTrue,
- const bool bStopOnFalse)
- {
- CPlugin * pSavedPlugin = m_CurrentPlugin;
-
- // tell a plugin the message
- for (POSITION pluginpos = m_PluginList.GetHeadPosition(); pluginpos; )
- {
- CPlugin * pPlugin = m_PluginList.GetNext (pluginpos);
-
- if (!(pPlugin->m_bEnabled)) // ignore disabled plugins
- continue;
-
- // change to this plugin, call function, put current plugin back
- m_CurrentPlugin = pPlugin; // so plugin knows who it is
- CScriptCallInfo callinfo (sName, pPlugin->m_PluginCallbacks [sName]);
- bool bResult = pPlugin->ExecutePluginScript (callinfo, arg1, arg2, sText);
- m_CurrentPlugin = pSavedPlugin; // back to current plugin
-
- if (bStopOnTrue && bResult && callinfo._dispid_info.isvalid ())
- return true;
-
- if (bStopOnFalse && !bResult && callinfo._dispid_info.isvalid ())
- return false;
-
- } // end of doing each plugin
-
- if (bStopOnTrue)
- return false;
- else
- return !bStopOnFalse; // if they wanted to stop on true, assume false and vice-versa
-
- } // end of CMUSHclientDoc::SendToAllPluginCallbacks
Oops, something went wrong.

0 comments on commit 5de14b9

Please sign in to comment.