aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/TitleManagerDialog.cpp
diff options
context:
space:
mode:
authorJesse Talavera-Greenberg <jesse@jesse.tg>2023-07-08 16:17:30 -0400
committerGitHub <noreply@github.com>2023-07-08 22:17:30 +0200
commit0947e941b83b23b701edb31345c119f14e5ad56f (patch)
tree8162328db5d7b881fe8ed1cd9a0ea4a72e5aaf28 /src/frontend/qt_sdl/TitleManagerDialog.cpp
parentd1ff103259bf44047b0da458cbd22d5e66a70773 (diff)
Modest cleanups for DSi_NAND (#1714)
* Add a definition for TMD files * Wrap TitleMetadata in a namespace * Add a comment * Remove TitleMetadataCertificate - melonDS ignores it anyway * Refactor the use of title metadata - Move bitwise operations on the title ID into helper methods - Use TitleMetadata objects instead of pointers to raw data * Slight cleanup in DSi_NAND - Replace some constants with sizeof - Use an NDSHeader object instead of a raw array of bytes * Add a DSi_NAND::ImportFile overload that loads a file from memory * Split most of ImportTitle into InitTitleFileStructure - It will be reused in the next commit * Add ability to import title from memory * Fix another potential issue * Fix broken DSiWare installation - The bytes of the title ID/category were being swapped in most places, but not all * Add some logging calls * Declare array sizes in DSi_TMD in decimal, not hex * Add a space after the #endif - To adhere to the style guide * Assert the size of TitleMetadataContent * Change the type of SignatureName * Don't mark the TMD structs as packed * Remove extraneous comments * Cut down some newlines
Diffstat (limited to 'src/frontend/qt_sdl/TitleManagerDialog.cpp')
-rw-r--r--src/frontend/qt_sdl/TitleManagerDialog.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/frontend/qt_sdl/TitleManagerDialog.cpp b/src/frontend/qt_sdl/TitleManagerDialog.cpp
index 72d19ec..3d52bdd 100644
--- a/src/frontend/qt_sdl/TitleManagerDialog.cpp
+++ b/src/frontend/qt_sdl/TitleManagerDialog.cpp
@@ -176,7 +176,7 @@ void TitleManagerDialog::done(int r)
void TitleManagerDialog::on_btnImportTitle_clicked()
{
- TitleImportDialog* importdlg = new TitleImportDialog(this, importAppPath, importTmdData, importReadOnly);
+ TitleImportDialog* importdlg = new TitleImportDialog(this, importAppPath, &importTmdData, importReadOnly);
importdlg->open();
connect(importdlg, &TitleImportDialog::finished, this, &TitleManagerDialog::onImportTitleFinished);
@@ -188,8 +188,8 @@ void TitleManagerDialog::onImportTitleFinished(int res)
if (res != QDialog::Accepted) return;
u32 titleid[2];
- titleid[0] = (importTmdData[0x18C] << 24) | (importTmdData[0x18D] << 16) | (importTmdData[0x18E] << 8) | importTmdData[0x18F];
- titleid[1] = (importTmdData[0x190] << 24) | (importTmdData[0x191] << 16) | (importTmdData[0x192] << 8) | importTmdData[0x193];
+ titleid[0] = importTmdData.GetCategory();
+ titleid[1] = importTmdData.GetID();
// remove anything that might hinder the install
DSi_NAND::DeleteTitle(titleid[0], titleid[1]);
@@ -381,7 +381,7 @@ void TitleManagerDialog::onExportTitleData()
}
-TitleImportDialog::TitleImportDialog(QWidget* parent, QString& apppath, u8* tmd, bool& readonly)
+TitleImportDialog::TitleImportDialog(QWidget* parent, QString& apppath, const DSi_TMD::TitleMetadata* tmd, bool& readonly)
: QDialog(parent), ui(new Ui::TitleImportDialog), appPath(apppath), tmdData(tmd), readOnly(readonly)
{
ui->setupUi(this);
@@ -440,12 +440,12 @@ void TitleImportDialog::accept()
return;
}
- fread(tmdData, 0x208, 1, f);
+ fread((void *) tmdData, sizeof(DSi_TMD::TitleMetadata), 1, f);
fclose(f);
u32 tmdtitleid[2];
- tmdtitleid[0] = (tmdData[0x18C] << 24) | (tmdData[0x18D] << 16) | (tmdData[0x18E] << 8) | tmdData[0x18F];
- tmdtitleid[1] = (tmdData[0x190] << 24) | (tmdData[0x191] << 16) | (tmdData[0x192] << 8) | tmdData[0x193];
+ tmdtitleid[0] = tmdData->GetCategory();
+ tmdtitleid[1] = tmdData->GetID();
if (tmdtitleid[1] != titleid[0] || tmdtitleid[0] != titleid[1])
{
@@ -507,11 +507,11 @@ void TitleImportDialog::tmdDownloaded()
}
else
{
- netreply->read((char*)tmdData, 520);
+ netreply->read((char*)tmdData, sizeof(*tmdData));
u32 tmdtitleid[2];
- tmdtitleid[0] = (tmdData[0x18C] << 24) | (tmdData[0x18D] << 16) | (tmdData[0x18E] << 8) | tmdData[0x18F];
- tmdtitleid[1] = (tmdData[0x190] << 24) | (tmdData[0x191] << 16) | (tmdData[0x192] << 8) | tmdData[0x193];
+ tmdtitleid[0] = tmdData->GetCategory();
+ tmdtitleid[1] = tmdData->GetID();
if (tmdtitleid[1] != titleid[0] || tmdtitleid[0] != titleid[1])
{