RequestHandler.cpp   RequestHandler.cpp 
skipping to change at line 59 skipping to change at line 59
{ {
rcTranslator = localInstance; rcTranslator = localInstance;
} }
QString getTranslation(const QString &key) Q_DECL_OVERRIDE QString getTranslation(const QString &key) Q_DECL_OVERRIDE
{ {
//try to get a RemoteControl specific translation first //try to get a RemoteControl specific translation first
QString trans = rcTranslator->tryQtranslate(key); QString trans = rcTranslator->tryQtranslate(key);
if(trans.isNull()) if(trans.isNull())
trans = StelTranslator::globalTranslator->qtranslate (key); trans = StelTranslator::globalTranslator->qtranslate (key);
//HTML escape + single quote escape //HTML escape + single quote escape
return trans.toHtmlEscaped().replace('\'',"&#39"); return trans.toHtmlEscaped().replace('\'',"'");
} }
private: private:
StelTranslator* rcTranslator; StelTranslator* rcTranslator;
}; };
class JsTranslationProvider : public ITemplateTranslationProvider class JsTranslationProvider : public ITemplateTranslationProvider
{ {
public: public:
JsTranslationProvider(StelTranslator* localInstance) JsTranslationProvider(StelTranslator* localInstance)
{ {
skipping to change at line 86 skipping to change at line 86
QString trans = rcTranslator->tryQtranslate(key); QString trans = rcTranslator->tryQtranslate(key);
if(trans.isNull()) if(trans.isNull())
trans = StelTranslator::globalTranslator->qtranslate (key); trans = StelTranslator::globalTranslator->qtranslate (key);
//JS escape single/double quotes //JS escape single/double quotes
return trans.replace('\'',"\\'").replace('"',"\\\""); return trans.replace('\'',"\\'").replace('"',"\\\"");
} }
private: private:
StelTranslator* rcTranslator; StelTranslator* rcTranslator;
}; };
RequestHandler::RequestHandler(const StaticFileControllerSettings& settings , QObject* parent) : HttpRequestHandler(parent), usePassword(false) RequestHandler::RequestHandler(const StaticFileControllerSettings& settings , QObject* parent) : HttpRequestHandler(parent), usePassword(false), templa teMutex(QMutex::Recursive)
{ {
apiController = new APIController(QByteArray("/api/").size(),this); apiController = new APIController(QByteArray("/api/").size(),this);
//register the services //register the services
//they "live" in the main thread in the QObject sense, but their ser vice methods are actually //they "live" in the main thread in the QObject sense, but their ser vice methods are actually
//executed in the HTTP handler threads //executed in the HTTP handler threads
apiController->registerService(new MainService("main",apiController) ); apiController->registerService(new MainService("main",apiController) );
apiController->registerService(new ObjectService("objects",apiContro ller)); apiController->registerService(new ObjectService("objects",apiContro ller));
apiController->registerService(new ScriptService("scripts",apiContro ller)); apiController->registerService(new ScriptService("scripts",apiContro ller));
apiController->registerService(new SimbadService("simbad",apiControl ler)); apiController->registerService(new SimbadService("simbad",apiControl ler));
skipping to change at line 158 skipping to change at line 158
apiController->service(request,response); apiController->service(request,response);
} }
else else
{ {
if(path.isEmpty() || path == "/" || path == "/index.html") if(path.isEmpty() || path == "/" || path == "/index.html")
{ {
//transparently redirect to index.html //transparently redirect to index.html
path = "/index.html"; path = "/index.html";
} }
//make sure we can access the template map
templateMutex.lock();
if(templateMap.contains(path)) if(templateMap.contains(path))
{ {
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
//force fresh loading for each request in debug mode //force fresh loading for each request in debug mode
//to allow for immediate display of changes //to allow for immediate display of changes
refreshTemplates(); refreshTemplates();
#endif #endif
QByteArray content = templateMap[path].toUtf8();
templateMutex.unlock();
//get a mime type //get a mime type
QByteArray mime = StaticFileController::getContentTy pe(path,"utf-8"); QByteArray mime = StaticFileController::getContentTy pe(path,"utf-8");
if(!mime.isEmpty()) if(!mime.isEmpty())
response.setHeader("Content-Type",mime); response.setHeader("Content-Type",mime);
//serve the stored template //serve the stored template
response.write(templateMap[path].toUtf8(),true); response.write(content,true);
} }
else else
{ {
templateMutex.unlock();
//let the static file controller handle the request //let the static file controller handle the request
staticFiles->service(request,response); staticFiles->service(request,response);
} }
} }
} }
void RequestHandler::setUsePassword(bool v) void RequestHandler::setUsePassword(bool v)
{ {
usePassword = v; usePassword = v;
} }
 End of changes. 6 change blocks. 
3 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/