void RuntimeJsImpl::onReload(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse) { if (dArgParse.HasMember("modulefiles")){ auto& allocator = dReplyParse.GetAllocator(); rapidjson::Value bodyvalue(rapidjson::kObjectType); const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++){ if (!reloadScript(objectfiles[i].GetString())) { bodyvalue.AddMember(rapidjson::Value(objectfiles[i].GetString(), allocator) , rapidjson::Value(1) , allocator); } } if (0 == objectfiles.Size()) { reloadScript(""); } dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); }else { reloadScript(""); } dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); }
void PacManager::replyFinished() { if (m_reply->error() != QNetworkReply::NoError) { qWarning() << "PacManager: Cannot download PAC file from" << m_url; m_reply->deleteLater(); m_reply = 0; return; } QByteArray data = m_reply->readAll(); m_reply->deleteLater(); m_reply = 0; QFile file(mApp->currentProfilePath() + "proxy.pac"); if (!file.open(QFile::WriteOnly)) { qWarning() << "PacManager: Cannot open PAC file for writing" << file.fileName(); return; } file.write(data); file.close(); reloadScript(); }
QList<QNetworkProxy> PacManager::queryProxy(const QUrl &url) { if (!m_pacrunner) { reloadScript(); } QString proxyString = m_pacrunner->findProxyForUrl(url.toEncoded(), url.host()); return parseProxies(proxyString.trimmed()); }
KateAutoIndent::KateAutoIndent (KateDocument *_doc) : QObject(_doc), doc(_doc), m_script (0) { // don't call updateConfig() here, document might is not ready for that.... // on script reload, the script pointer is invalid -> force reload connect(KateGlobal::self()->scriptManager(), SIGNAL(reloaded()), this, SLOT(reloadScript())); }
// NOTE: The load() command is similar to the include() command except that it loads the script // as a stand-alone script. To accomplish this, the ScriptEngine class just emits a signal which // the Application or other context will connect to in order to know to actually load the script void ScriptEngine::load(const QString& loadFile) { if (_stoppingAllScripts) { qCDebug(scriptengine) << "Script.load() while shutting down is ignored... " << "loadFile:" << loadFile << "parent script:" << getFilename(); return; // bail early } QUrl url = resolvePath(loadFile); if (_isReloading) { auto scriptCache = DependencyManager::get<ScriptCache>(); scriptCache->deleteScript(url.toString()); emit reloadScript(url.toString(), false); } else { emit loadScript(url.toString(), false); } }
void PacManager::downloadPacFile() { if (m_reply) { qWarning() << "PacManager: PAC file is already being downloaded!"; return; } if (m_url.isLocalFile()) { if (!QFile(m_url.path()).exists()) { qWarning() << "PacManager: PAC file " << m_url.path() << "doesn't exists!"; } else { reloadScript(); } return; } m_reply = new FollowRedirectReply(m_url, mApp->networkManager()); connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); }