* @brief Get available scriptlets for an event * * @return Returns an array of valid LPDISPATCH */
| 900 | * @return Returns an array of valid LPDISPATCH |
| 901 | */ |
| 902 | static std::map<String, PluginArrayPtr> GetAvailableScripts() |
| 903 | { |
| 904 | vector<String>& scriptlets = LoadTheScriptletList(); |
| 905 | std::map<std::wstring, PluginArrayPtr> plugins; |
| 906 | |
| 907 | std::list<String> badScriptlets; |
| 908 | for (size_t i = 0; i < scriptlets.size(); i++) |
| 909 | { |
| 910 | // Note all the info about the plugin |
| 911 | PluginInfoPtr plugin(new PluginInfo); |
| 912 | |
| 913 | String scriptletFilepath = scriptlets.at(i); |
| 914 | int rtn = LoadPluginWrapper(*plugin.get(), scriptletFilepath); |
| 915 | if (rtn == 1) |
| 916 | { |
| 917 | // Plugin has this event |
| 918 | if (plugins.find(plugin->m_event) == plugins.end()) |
| 919 | plugins[plugin->m_event].reset(new PluginArray); |
| 920 | plugins[plugin->m_event]->push_back(plugin); |
| 921 | } |
| 922 | else if (rtn < 0) |
| 923 | { |
| 924 | // Plugin is bad |
| 925 | badScriptlets.push_back(scriptletFilepath); |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | if (CAllThreadsScripts::GetInternalPluginsLoader()) |
| 930 | { |
| 931 | String errmsg; |
| 932 | if (!CAllThreadsScripts::GetInternalPluginsLoader()(plugins, errmsg)) |
| 933 | AppErrorMessageBox(errmsg); |
| 934 | } |
| 935 | |
| 936 | // Remove any bad plugins from the cache |
| 937 | // This might be a good time to see if the user wants to abort or continue |
| 938 | while (!badScriptlets.empty()) |
| 939 | { |
| 940 | RemoveScriptletCandidate(badScriptlets.front()); |
| 941 | badScriptlets.pop_front(); |
| 942 | } |
| 943 | |
| 944 | ResolveNameConflict(plugins); |
| 945 | LoadCustomSettings(plugins); |
| 946 | |
| 947 | return plugins; |
| 948 | } |
| 949 | |
| 950 | static void FreeAllScripts(PluginArrayPtr& pArray) |
| 951 | { |
no test coverage detected