Showing the changes to libraries/script-engine/src/ScriptsModel.cpp (1 of 6 files). Show all
Unified · Split
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <QXmlStreamReader> |
| 16 | 16 | |
| 17 | 17 | #include <NetworkAccessManager.h> |
| 18 | +#include <PathUtils.h> | |
| 18 | 19 | |
| 19 | 20 | #include "ScriptEngine.h" |
| 20 | 21 | #include "ScriptEngines.h" |
| @@ -23,11 +24,7 @@ · 2 unmodified lines | ||
| 23 | 24 | #define __STR1__(x) __STR2__(x) |
| 24 | 25 | #define __LOC__ __FILE__ "(" __STR1__(__LINE__) ") : Warning Msg: " |
| 25 | 26 | |
| 26 | − | |
| 27 | −static const QString S3_URL = "http://s3.amazonaws.com/hifi-public"; | |
| 28 | −static const QString PUBLIC_URL = "http://public.highfidelity.io"; | |
| 29 | 27 | static const QString MODELS_LOCATION = "scripts/"; |
| 30 | − | |
| 31 | 28 | static const QString PREFIX_PARAMETER_NAME = "prefix"; |
| 32 | 29 | static const QString MARKER_PARAMETER_NAME = "marker"; |
| 33 | 30 | static const QString IS_TRUNCATED_NAME = "IsTruncated"; |
| @@ -63,7 +60,7 @@ ScriptsModel::ScriptsModel(QObject* parent) : · 29 unmodified lines | ||
| 63 | 60 | |
| 64 | 61 | connect(&_fsWatcher, &QFileSystemWatcher::directoryChanged, this, &ScriptsModel::reloadLocalFiles); |
| 65 | 62 | reloadLocalFiles(); |
| 66 | − reloadRemoteFiles(); | |
| 63 | + reloadDefaultFiles(); | |
| 67 | 64 | } |
| 68 | 65 | |
| 69 | 66 | ScriptsModel::~ScriptsModel() { |
| @@ -140,24 +137,24 @@ void ScriptsModel::updateScriptsLocation(const QString& newPath) { · 70 unmodified lines | ||
| 140 | 137 | reloadLocalFiles(); |
| 141 | 138 | } |
| 142 | 139 | |
| 143 | −void ScriptsModel::reloadRemoteFiles() { | |
| 140 | +void ScriptsModel::reloadDefaultFiles() { | |
| 144 | 141 | if (!_loadingScripts) { |
| 145 | 142 | _loadingScripts = true; |
| 146 | 143 | for (int i = _treeNodes.size() - 1; i >= 0; i--) { |
| 147 | 144 | TreeNodeBase* node = _treeNodes.at(i); |
| 148 | 145 | if (node->getType() == TREE_NODE_TYPE_SCRIPT && |
| 149 | − static_cast<TreeNodeScript*>(node)->getOrigin() == SCRIPT_ORIGIN_REMOTE) | |
| 146 | + static_cast<TreeNodeScript*>(node)->getOrigin() == SCRIPT_ORIGIN_DEFAULT) | |
| 150 | 147 | { |
| 151 | 148 | delete node; |
| 152 | 149 | _treeNodes.removeAt(i); |
| 153 | 150 | } |
| 154 | 151 | } |
| 155 | − requestRemoteFiles(); | |
| 152 | + requestDefaultFiles(); | |
| 156 | 153 | } |
| 157 | 154 | } |
| 158 | 155 | |
| 159 | −void ScriptsModel::requestRemoteFiles(QString marker) { | |
| 160 | − QUrl url(S3_URL); | |
| 156 | +void ScriptsModel::requestDefaultFiles(QString marker) { | |
| 157 | + QUrl url(defaultScriptsLocation()); | |
| 161 | 158 | QUrlQuery query; |
| 162 | 159 | query.addQueryItem(PREFIX_PARAMETER_NAME, MODELS_LOCATION); |
| 163 | 160 | if (!marker.isEmpty()) { |
| @@ -218,7 +215,9 @@ bool ScriptsModel::parseXML(QByteArray xmlFile) { · 54 unmodified lines | ||
| 218 | 215 | xml.readNext(); |
| 219 | 216 | lastKey = xml.text().toString(); |
| 220 | 217 | if (jsRegex.exactMatch(xml.text().toString())) { |
| 221 | − _treeNodes.append(new TreeNodeScript(lastKey.mid(MODELS_LOCATION.length()), S3_URL + "/" + lastKey, SCRIPT_ORIGIN_REMOTE)); | |
| 218 | + _treeNodes.append(new TreeNodeScript(lastKey.mid(MODELS_LOCATION.length()), | |
| 219 | + defaultScriptsLocation() + "/" + lastKey, | |
| 220 | + SCRIPT_ORIGIN_DEFAULT)); | |
| 222 | 221 | } |
| 223 | 222 | } |
| 224 | 223 | xml.readNext(); |
| @@ -236,7 +235,7 @@ bool ScriptsModel::parseXML(QByteArray xmlFile) { · 11 unmodified lines | ||
| 236 | 235 | } |
| 237 | 236 | |
| 238 | 237 | if (truncated) { |
| 239 | − requestRemoteFiles(lastKey); | |
| 238 | + requestDefaultFiles(lastKey); | |
| 240 | 239 | } |
| 241 | 240 | |
| 242 | 241 | // If this request was not truncated, we are done. |