1.1 --- a/core/PluginSys.cpp Wed Mar 18 19:15:40 2009 -0700
1.2 +++ b/core/PluginSys.cpp Wed Mar 18 19:20:40 2009 -0700
1.3 @@ -57,6 +57,7 @@
1.4
1.5 m_type = PluginType_Private;
1.6 m_status = Plugin_Uncompiled;
1.7 + m_bSilentlyFailed = false;
1.8 m_serial = ++MySerial;
1.9 m_pRuntime = NULL;
1.10 m_errormsg[256] = '\0';
1.11 @@ -386,22 +387,27 @@
1.12 }
1.13 }
1.14
1.15 -bool CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
1.16 +APLRes CPlugin::Call_AskPluginLoad(char *error, size_t maxlength)
1.17 {
1.18 if (m_status != Plugin_Created)
1.19 {
1.20 - return false;
1.21 + return APLRes_Failure;
1.22 }
1.23
1.24 m_status = Plugin_Loaded;
1.25
1.26 int err;
1.27 cell_t result;
1.28 - IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad");
1.29 + bool haveNewAPL = false;
1.30 + IPluginFunction *pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad2");
1.31
1.32 - if (!pFunction)
1.33 + if (pFunction)
1.34 {
1.35 - return true;
1.36 + haveNewAPL = true;
1.37 + }
1.38 + else if (!(pFunction = m_pRuntime->GetFunctionByName("AskPluginLoad")))
1.39 + {
1.40 + return APLRes_Success;
1.41 }
1.42
1.43 pFunction->PushCell(m_handle);
1.44 @@ -410,15 +416,21 @@
1.45 pFunction->PushCell(maxlength);
1.46 if ((err=pFunction->Execute(&result)) != SP_ERROR_NONE)
1.47 {
1.48 - return false;
1.49 + return APLRes_Failure;
1.50 }
1.51
1.52 - if (!result || m_status != Plugin_Loaded)
1.53 + if (haveNewAPL)
1.54 + {
1.55 + return (APLRes)result;
1.56 + }
1.57 + else if (result)
1.58 {
1.59 - return false;
1.60 + return APLRes_Success;
1.61 }
1.62 -
1.63 - return true;
1.64 + else
1.65 + {
1.66 + return APLRes_Failure;
1.67 + }
1.68 }
1.69
1.70 void *CPlugin::GetPluginStructure()
1.71 @@ -470,6 +482,11 @@
1.72 return m_status;
1.73 }
1.74
1.75 +bool CPlugin::IsSilentlyFailed()
1.76 +{
1.77 + return m_bSilentlyFailed;
1.78 +}
1.79 +
1.80 bool CPlugin::IsDebugging()
1.81 {
1.82 if (m_pRuntime == NULL)
1.83 @@ -480,6 +497,11 @@
1.84 return true;
1.85 }
1.86
1.87 +void CPlugin::SetSilentlyFailed(bool sf)
1.88 +{
1.89 + m_bSilentlyFailed = sf;
1.90 +}
1.91 +
1.92 void CPlugin::LibraryActions(bool dropping)
1.93 {
1.94 List<String>::iterator iter;
1.95 @@ -1004,20 +1026,31 @@
1.96 }
1.97 }
1.98
1.99 + LoadRes loadFailure = LoadRes_Failure;
1.100 /* Get the status */
1.101 if (pPlugin->GetStatus() == Plugin_Created)
1.102 {
1.103 /* First native pass - add anything from Core */
1.104 g_ShareSys.BindNativesToPlugin(pPlugin, true);
1.105 pPlugin->InitIdentity();
1.106 - if (pPlugin->Call_AskPluginLoad(error, maxlength))
1.107 + APLRes result = pPlugin->Call_AskPluginLoad(error, maxlength);
1.108 + switch (result)
1.109 {
1.110 + case APLRes_Success:
1.111 /* Autoload any modules */
1.112 LoadOrRequireExtensions(pPlugin, 1, error, maxlength);
1.113 - }
1.114 - else
1.115 - {
1.116 + break;
1.117 + case APLRes_Failure:
1.118 pPlugin->SetErrorState(Plugin_Failed, "%s", error);
1.119 + loadFailure = LoadRes_Failure;
1.120 + break;
1.121 + case APLRes_SilentFailure:
1.122 + pPlugin->SetErrorState(Plugin_Failed, "%s", error);
1.123 + loadFailure = LoadRes_SilentFailure;
1.124 + pPlugin->SetSilentlyFailed(true);
1.125 + break;
1.126 + default:
1.127 + assert(false);
1.128 }
1.129 }
1.130
1.131 @@ -1030,7 +1063,7 @@
1.132 *_plugin = pPlugin;
1.133 }
1.134
1.135 - return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : LoadRes_Failure;
1.136 + return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : loadFailure;
1.137 }
1.138
1.139 IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t maxlength, bool *wasloaded)
1.140 @@ -1095,7 +1128,7 @@
1.141 error);
1.142 }
1.143
1.144 - if (res == LoadRes_Successful || res == LoadRes_Failure)
1.145 + if (res == LoadRes_Successful || res == LoadRes_Failure || res == LoadRes_SilentFailure)
1.146 {
1.147 AddPlugin(pl);
1.148 }
1.149 @@ -1951,7 +1984,7 @@
1.150 assert(pl->GetStatus() != Plugin_Created);
1.151 int len = 0;
1.152 const sm_plugininfo_t *info = pl->GetPublicInfo();
1.153 - if (pl->GetStatus() != Plugin_Running)
1.154 + if (pl->GetStatus() != Plugin_Running && !pl->IsSilentlyFailed())
1.155 {
1.156 len += UTIL_Format(buffer, sizeof(buffer), " %02d <%s>", id, GetStatusText(pl->GetStatus()));
1.157
1.158 @@ -1967,6 +2000,8 @@
1.159 }
1.160 if (pl->GetStatus() < Plugin_Created)
1.161 {
1.162 + if (pl->IsSilentlyFailed())
1.163 + len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " Disabled:");
1.164 len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
1.165 if (IS_STR_FILLED(info->version))
1.166 {