Inject version info into embedded xml and ignore local xml file by default.
Added check for 3.60 update pup.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "cmautils.h"
|
#include "cmautils.h"
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -31,6 +32,8 @@
|
|||||||
|
|
||||||
QFile *CmaEvent::m_file = NULL;
|
QFile *CmaEvent::m_file = NULL;
|
||||||
|
|
||||||
|
const QString hash360 = "8cc2e2666626c4ff8f582bf209473526e825e2a5e38e39b259a8a46e25ef371c";
|
||||||
|
|
||||||
static metadata_t g_thumbmeta = {0, 0, 0, NULL, NULL, 0, 0, 0, Thumbnail, {{17, 240, 136, 0, 1, 1.0f, 2}}, NULL};
|
static metadata_t g_thumbmeta = {0, 0, 0, NULL, NULL, 0, 0, 0, Thumbnail, {{17, 240, 136, 0, 1, 1.0f, 2}}, NULL};
|
||||||
|
|
||||||
CmaEvent::CmaEvent(Database *db, vita_device_t *s_device) :
|
CmaEvent::CmaEvent(Database *db, vita_device_t *s_device) :
|
||||||
@@ -533,11 +536,17 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *cma_event, int event
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
bool offlineMode = settings.value("offlineMode", true).toBool();
|
bool offlineMode = settings.value("offlineMode", true).toBool();
|
||||||
|
bool ignorexml = settings.value("ignorexml", true).toBool();
|
||||||
|
bool ignorefile = false;
|
||||||
|
|
||||||
if(!file.open(QIODevice::ReadOnly)) {
|
// do not try to open the xml file if the flag is set
|
||||||
|
if(basename == "psp2-updatelist.xml" && ignorexml) {
|
||||||
|
ignorefile = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ignorefile || !file.open(QIODevice::ReadOnly)) {
|
||||||
if(offlineMode && basename == "psp2-updatelist.xml") {
|
if(offlineMode && basename == "psp2-updatelist.xml") {
|
||||||
qDebug("Found request for update list. Sending cached data");
|
qDebug("Found request for update list. Sending embedded xml file");
|
||||||
messageSent(tr("The PSVita has requested an update check, sending embedded xml file (version 0.00)"));
|
|
||||||
QFile res(":/main/resources/xml/psp2-updatelist.xml");
|
QFile res(":/main/resources/xml/psp2-updatelist.xml");
|
||||||
res.open(QIODevice::ReadOnly);
|
res.open(QIODevice::ReadOnly);
|
||||||
data = res.readAll();
|
data = res.readAll();
|
||||||
@@ -555,6 +564,22 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *cma_event, int event
|
|||||||
data.replace("<region id=\"us\">", qPrintable(regionTag));
|
data.replace("<region id=\"us\">", qPrintable(regionTag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString versiontype = settings.value("versiontype", "zero").toString();
|
||||||
|
|
||||||
|
if(versiontype == "henkaku") {
|
||||||
|
qDebug("Setting XML version to 03.600.000");
|
||||||
|
data.replace("00.000.000", "03.600.000");
|
||||||
|
data.replace("label=\"0.00\"", "label=\"3.60\"");
|
||||||
|
} else if(versiontype == "custom") {
|
||||||
|
QString customVersion = settings.value("customversion", "00.000.000").toString();
|
||||||
|
QString customLabel = QString("label=\"%1\"").arg(customVersion.mid(1, 4));
|
||||||
|
qDebug("Setting XML version to %s", qPrintable(customVersion));
|
||||||
|
data.replace("00.000.000", qPrintable(customVersion));
|
||||||
|
data.replace("label=\"0.00\"", qPrintable(customLabel));
|
||||||
|
} else {
|
||||||
|
qDebug("Using default XML version: 00.000.000");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "No country code found in URL, defaulting to \"us\"";
|
qWarning() << "No country code found in URL, defaulting to \"us\"";
|
||||||
}
|
}
|
||||||
@@ -595,8 +620,32 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *cma_event, int event
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug("Reading from local file");
|
qDebug("Reading from local file");
|
||||||
messageSent(tr("The PSVita has requested an update check, sending local xml file"));
|
|
||||||
data = file.readAll();
|
data = file.readAll();
|
||||||
|
|
||||||
|
if(basename == "psp2-updatelist.xml" && !ignorefile) {
|
||||||
|
messageSent(tr("The PSVita has requested an update check, sending local xml file and ignoring version settings"));
|
||||||
|
} else {
|
||||||
|
QString versiontype = settings.value("versiontype", "zero").toString();
|
||||||
|
QString customVersion = settings.value("customversion", "00.000.000").toString();
|
||||||
|
|
||||||
|
// verify that the update file is really the 3.60 pup
|
||||||
|
if(ignorexml && basename == "PSP2UPDAT.PUP" &&
|
||||||
|
(versiontype == "henkaku" ||
|
||||||
|
(versiontype == "custom" &&
|
||||||
|
customVersion == "03.600.000"))) {
|
||||||
|
QCryptographicHash crypto(QCryptographicHash::Sha256);
|
||||||
|
crypto.addData(data);
|
||||||
|
QString result = crypto.result().toHex();
|
||||||
|
|
||||||
|
if(result != hash360) {
|
||||||
|
qWarning("3.60 PUP SHA256 mismatch");
|
||||||
|
qWarning("> Actual: %s", qPrintable(result));
|
||||||
|
qWarning("> Expected: %s", qPrintable(hash360));
|
||||||
|
// notify the user
|
||||||
|
messageSent(tr("The XML version is set to 3.60 but the PUP file hash doesn't match, cancel the update if you don't want this"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Sending %i bytes of data for HTTP request %s", data.size(), url);
|
qDebug("Sending %i bytes of data for HTTP request %s", data.size(), url);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -64,6 +64,7 @@ void ConfigWidget::connectSignals()
|
|||||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
connect(ui->protocolModeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolModeChanged(int)));
|
connect(ui->protocolModeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolModeChanged(int)));
|
||||||
|
connect(ui->psversionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(versionModeChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWidget::protocolModeChanged(int index)
|
void ConfigWidget::protocolModeChanged(int index)
|
||||||
@@ -87,7 +88,25 @@ void ConfigWidget::protocolModeChanged(int index)
|
|||||||
ui->protocolEdit->setEnabled(false);
|
ui->protocolEdit->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigWidget::versionModeChanged(int index)
|
||||||
|
{
|
||||||
|
switch(index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
ui->psversionEdit->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ui->psversionEdit->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ui->psversionEdit->setEnabled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ui->psversionEdit->setEnabled(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWidget::setDefaultData()
|
void ConfigWidget::setDefaultData()
|
||||||
@@ -151,6 +170,23 @@ void ConfigWidget::setDefaultData()
|
|||||||
ui->protocolEdit->setText(QString::number(protocol_version));
|
ui->protocolEdit->setText(QString::number(protocol_version));
|
||||||
else
|
else
|
||||||
ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
|
ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
|
||||||
|
|
||||||
|
bool ignorexml = settings.value("ignorexml", true).toBool();
|
||||||
|
ui->ignorexmlCheck->setChecked(ignorexml);
|
||||||
|
|
||||||
|
QString versiontype = settings.value("versiontype", "zero").toString();
|
||||||
|
QString customVersion = settings.value("customversion", "00.000.000").toString();
|
||||||
|
|
||||||
|
if(versiontype == "custom")
|
||||||
|
ui->psversionBox->setCurrentIndex(2);
|
||||||
|
else if(versiontype == "henkaku")
|
||||||
|
ui->psversionBox->setCurrentIndex(1);
|
||||||
|
else
|
||||||
|
ui->psversionBox->setCurrentIndex(0);
|
||||||
|
|
||||||
|
versionModeChanged(ui->psversionBox->currentIndex());
|
||||||
|
|
||||||
|
ui->psversionEdit->setText(customVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigWidget::~ConfigWidget()
|
ConfigWidget::~ConfigWidget()
|
||||||
@@ -241,6 +277,17 @@ void ConfigWidget::accept()
|
|||||||
else if(ui->protocolModeBox->currentIndex() == 2)
|
else if(ui->protocolModeBox->currentIndex() == 2)
|
||||||
settings.setValue("protocolMode", "custom");
|
settings.setValue("protocolMode", "custom");
|
||||||
|
|
||||||
|
if(ui->psversionBox->currentIndex() == 0)
|
||||||
|
settings.setValue("versiontype", "zero");
|
||||||
|
else if(ui->psversionBox->currentIndex() == 1)
|
||||||
|
settings.setValue("versiontype", "henkaku");
|
||||||
|
else if(ui->psversionBox->currentIndex() == 2)
|
||||||
|
settings.setValue("versiontype", "custom");
|
||||||
|
|
||||||
|
settings.setValue("ignorexml", ui->ignorexmlCheck->isChecked());
|
||||||
|
|
||||||
|
settings.setValue("customversion", ui->psversionEdit->text());
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int protocol = ui->protocolEdit->text().toInt(&ok);
|
int protocol = ui->protocolEdit->text().toInt(&ok);
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void protocolModeChanged(int index);
|
void protocolModeChanged(int index);
|
||||||
|
void versionModeChanged(int index);
|
||||||
void browseBtnPressed(int from);
|
void browseBtnPressed(int from);
|
||||||
void accept();
|
void accept();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>519</width>
|
<width>519</width>
|
||||||
<height>525</height>
|
<height>559</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -305,16 +305,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="checkBox_3">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Update database automatically when files on the PC are changed</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
@@ -367,6 +357,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="ignorexmlCheck">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore local file psp2-updatelist.xml on update folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
||||||
</item>
|
</item>
|
||||||
@@ -375,6 +375,32 @@
|
|||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>CMA protocol selection</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="protocolModeBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Latest</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Manual</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_10">
|
<widget class="QLabel" name="label_10">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -445,6 +471,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="text">
|
||||||
|
<string>CMA custom version</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="protocolEdit">
|
<widget class="QLineEdit" name="protocolEdit">
|
||||||
<property name="inputMask">
|
<property name="inputMask">
|
||||||
@@ -455,23 +488,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QLabel" name="label_13">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>CMA protocol selection</string>
|
<string>Custom PS Vita version</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="protocolModeBox">
|
<widget class="QLineEdit" name="psversionEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">03.600.000</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_14">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use this version for updates</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="psversionBox">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Latest</string>
|
<string>FW 0.00 (Always up-to-date)</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Manual</string>
|
<string>FW 3.60 (HENkaku)</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -481,13 +528,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_12">
|
|
||||||
<property name="text">
|
|
||||||
<string>CMA custom version</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user