Allow deleting secure values.

This commit is contained in:
Steven Smith 2016-04-13 15:44:10 -07:00
parent e1cab80c4a
commit a832bed1d2
8 changed files with 59 additions and 11 deletions

View File

@ -26,4 +26,5 @@ void action_delete_title(title_info* info, bool* populated);
void action_launch_title(title_info* info, bool* populated);
void action_browse_title_save_data(title_info* info, bool* populated);
void action_import_secure_value(title_info* info, bool* populated);
void action_export_secure_value(title_info* info, bool* populated);
void action_export_secure_value(title_info* info, bool* populated);
void action_delete_secure_value(title_info* info, bool* populated);

View File

@ -62,6 +62,10 @@ static void action_delete_dir_contents_update(ui_view* view, void* data, float*
res = FSUSER_DeleteFile(*archive, fsPath);
}
if(R_SUCCEEDED(res) && archive->id == ARCHIVE_USER_SAVEDATA) {
res = FSUSER_ControlArchive(*archive, ARCHIVE_ACTION_COMMIT_SAVE_DATA, NULL, 0, NULL, 0);
}
if(R_FAILED(res)) {
if(deleteData->processed >= deleteData->total - 1) {
ui_pop();

View File

@ -0,0 +1,41 @@
#include <stdio.h>
#include <3ds.h>
#include "action.h"
#include "../../error.h"
#include "../../progressbar.h"
#include "../../prompt.h"
#include "../../../util.h"
#include "../../../screen.h"
static void action_delete_secure_value_end_onresponse(ui_view* view, void* data, bool response) {
prompt_destroy(view);
}
static void action_delete_secure_value_update(ui_view* view, void* data, float* progress, char* progressText) {
title_info* info = (title_info*) data;
Result res = FSUSER_ControlSecureSave(SECURESAVE_ACTION_DELETE, (SECUREVALUE_SLOT_SD << 32) | (info->titleId & 0xFFFFFFF));
progressbar_destroy(view);
ui_pop();
if(R_FAILED(res)) {
error_display_res(info, ui_draw_title_info, res, "Failed to delete secure value.");
} else {
ui_push(prompt_create("Success", "Secure value deleted.", COLOR_TEXT, false, info, NULL, ui_draw_title_info, action_delete_secure_value_end_onresponse));
}
}
static void action_delete_secure_value_onresponse(ui_view* view, void* data, bool response) {
prompt_destroy(view);
if(response) {
ui_push(progressbar_create("Deleting Secure Value", "", data, action_delete_secure_value_update, ui_draw_title_info));
}
}
void action_delete_secure_value(title_info* info, bool* populated) {
ui_push(prompt_create("Confirmation", "Delete the secure value of the selected title?", COLOR_TEXT, true, info, NULL, ui_draw_title_info, action_delete_secure_value_onresponse));
}

View File

@ -72,5 +72,5 @@ static void action_export_secure_value_onresponse(ui_view* view, void* data, boo
}
void action_export_secure_value(title_info* info, bool* populated) {
ui_push(prompt_create("Confirmation", "Export secure value for the selected title?", COLOR_TEXT, true, info, NULL, ui_draw_title_info, action_export_secure_value_onresponse));
ui_push(prompt_create("Confirmation", "Export the secure value of the selected title?", COLOR_TEXT, true, info, NULL, ui_draw_title_info, action_export_secure_value_onresponse));
}

View File

@ -56,5 +56,5 @@ static void action_import_secure_value_onresponse(ui_view* view, void* data, boo
}
void action_import_secure_value(title_info* info, bool* populated) {
ui_push(prompt_create("Confirmation", "Import secure value for the selected title?", COLOR_TEXT, true, info, NULL, ui_draw_title_info, action_import_secure_value_onresponse));
ui_push(prompt_create("Confirmation", "Import the secure value of the selected title?", COLOR_TEXT, true, info, NULL, ui_draw_title_info, action_import_secure_value_onresponse));
}

View File

@ -114,7 +114,9 @@ static void action_install_cias_update(ui_view* view, void* data, float* progres
}
if(installData->delete) {
FSUSER_DeleteFile(*installData->base->archive, fsMakePath(PATH_ASCII, path));
if(R_SUCCEEDED(FSUSER_DeleteFile(*installData->base->archive, fsMakePath(PATH_ASCII, path))) && installData->base->archive->id == ARCHIVE_USER_SAVEDATA) {
FSUSER_ControlArchive(*installData->base->archive, ARCHIVE_ACTION_COMMIT_SAVE_DATA, NULL, 0, NULL, 0);
}
*installData->populated = false;
}

View File

@ -1,7 +1,4 @@
#include <sys/syslimits.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <3ds.h>
@ -9,7 +6,6 @@
#include "../../list.h"
#include "../../error.h"
#include "../../../util.h"
#include "task.h"
typedef struct {
@ -95,7 +91,10 @@ static void task_install_cia_thread(void* arg) {
AM_DeleteTitle(dest, titleId);
AM_DeleteTicket(titleId);
AM_QueryAvailableExternalTitleDatabase(NULL);
if(dest == 1) {
AM_QueryAvailableExternalTitleDatabase(NULL);
}
if(R_FAILED(data->result->result = AM_StartCiaInstall(dest, &ciaHandle))) {
break;
@ -115,7 +114,7 @@ static void task_install_cia_thread(void* arg) {
if(R_FAILED(data->result->result)) {
AM_CancelCIAInstall(ciaHandle);
} else if(R_SUCCEEDED(data->result->result = AM_FinishCiaInstall(ciaHandle))) {
if(titleId == 0x0004013800000002LL || titleId == 0x0004013820000002LL) {
if(titleId == 0x0004013800000002 || titleId == 0x0004013820000002) {
data->result->result = AM_InstallFirm(titleId);
}
}

View File

@ -17,7 +17,7 @@ typedef struct {
bool populated;
} titles_data;
#define TITLES_ACTION_COUNT 5
#define TITLES_ACTION_COUNT 6
static u32 titles_action_count = TITLES_ACTION_COUNT;
static list_item titles_action_items[TITLES_ACTION_COUNT] = {
@ -26,6 +26,7 @@ static list_item titles_action_items[TITLES_ACTION_COUNT] = {
{"Browse Save Data", COLOR_TEXT, action_browse_title_save_data},
{"Import Secure Value", COLOR_TEXT, action_import_secure_value},
{"Export Secure Value", COLOR_TEXT, action_export_secure_value},
{"Delete Secure Value", COLOR_TEXT, action_delete_secure_value},
};
#define CARD_TITLES_ACTION_COUNT 2