Modify embedded xml on the fly with the country code from the url.

This commit is contained in:
codestation
2015-12-27 22:33:52 -04:30
parent 6eeba0b71a
commit d014e9c823
2 changed files with 17 additions and 81 deletions

View File

@@ -540,6 +540,23 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *cma_event, int event
res.open(QIODevice::ReadOnly);
data = res.readAll();
// fetch country code from url
QString countryCode;
QStringList parts = QUrl(url).path().split('/');
if(parts.size() >= 2) {
parts.removeLast();
countryCode = parts.last();
qDebug() << "Detected country code from URL: " << countryCode;
if(countryCode != "us") {
QString regionTag = QString("<region id=\"%1\">").arg(countryCode);
data.replace("<region id=\"us\">", qPrintable(regionTag));
}
} else {
qWarning() << "No country code found in URL, defaulting to \"us\"";
}
} else if(!offlineMode) {
qDebug("URL: %s", url);
HTTPDownloader downloader(url);