void ScriptServer::LoadScripts() { try { script_language_ = Configuration::Instance()->GetScriptLanguage(); if (script_language_ == _T("VBScript")) script_extension_ = "vbs"; else if (script_language_ == _T("JScript")) script_extension_ = "js"; else script_extension_ = ""; String sCurrentScriptFile = GetCurrentScriptFile(); // Load the script file from disk script_contents_ = FileUtilities::ReadCompleteTextFile(sCurrentScriptFile); // Do a syntax check before loading it. String sMessage = ScriptServer::CheckSyntax(); if (!sMessage.IsEmpty()) { ErrorManager::Instance()->ReportError(ErrorManager::High, 5016, "ScriptServer::LoadScripts", sMessage); return; } // Determine which functions are available. has_on_client_connect_ = DoesFunctionExist_("OnClientConnect"); has_on_accept_message_ = DoesFunctionExist_("OnAcceptMessage"); has_on_deliver_message_ = DoesFunctionExist_("OnDeliverMessage"); has_on_backup_completed_ = DoesFunctionExist_("OnBackupCompleted"); has_on_backup_failed_ = DoesFunctionExist_("OnBackupFailed"); has_on_delivery_start_ = DoesFunctionExist_("OnDeliveryStart"); has_on_error_ = DoesFunctionExist_("OnError"); has_on_delivery_failed_ = DoesFunctionExist_("OnDeliveryFailed"); has_on_external_account_download_ = DoesFunctionExist_("OnExternalAccountDownload"); has_on_smtpdata_ = DoesFunctionExist_("OnSMTPData"); } catch (...) { ErrorManager::Instance()->ReportError(ErrorManager::High, 5017, "ScriptServer::LoadScripts", "An exception was thrown when loading scripts."); } }
void ScriptServer::LoadScripts() { try { m_sScriptLanguage = Configuration::Instance()->GetScriptLanguage(); if (m_sScriptLanguage == _T("VBScript")) m_sScriptExtension = "vbs"; else if (m_sScriptLanguage == _T("JScript")) m_sScriptExtension = "js"; else m_sScriptExtension = ""; String sCurrentScriptFile = GetCurrentScriptFile(); // Load the script file from disk m_sScriptContents = FileUtilities::ReadCompleteTextFile(sCurrentScriptFile); // Do a syntax check before loading it. String sMessage = ScriptServer::CheckSyntax(); if (!sMessage.IsEmpty()) { ErrorManager::Instance()->ReportError(ErrorManager::High, 5016, "ScriptServer::LoadScripts", sMessage); return; } // Determine which functions are available. m_bHasOnClientConnect = _DoesFunctionExist("OnClientConnect"); m_bHasOnAcceptMessage = _DoesFunctionExist("OnAcceptMessage"); m_bHasOnDeliverMessage = _DoesFunctionExist("OnDeliverMessage"); m_bHasOnBackupCompleted = _DoesFunctionExist("OnBackupCompleted"); m_bHasOnBackupFailed = _DoesFunctionExist("OnBackupFailed"); m_bHasOnDeliveryStart = _DoesFunctionExist("OnDeliveryStart"); m_bHasOnError = _DoesFunctionExist("OnError"); m_bHasOnDeliveryFailed = _DoesFunctionExist("OnDeliveryFailed"); m_bHasOnExternalAccountDownload = _DoesFunctionExist("OnExternalAccountDownload"); m_bHasOnSMTPData = _DoesFunctionExist("OnSMTPData"); } catch (...) { ErrorManager::Instance()->ReportError(ErrorManager::High, 5017, "ScriptServer::LoadScripts", "An exception was thrown when loading scripts."); } }