Exemplo n.º 1
0
static void action_delete_title_update(ui_view* view, void* data, float* progress, char* text) {
    delete_title_data* deleteData = (delete_title_data*) data;

    title_info* info = (title_info*) deleteData->selected->data;

    Result res = 0;

    if(R_SUCCEEDED(res = AM_DeleteTitle(info->mediaType, info->titleId)) && deleteData->ticket) {
        res = AM_DeleteTicket(info->titleId);
    }

    ui_pop();
    info_destroy(view);

    if(R_FAILED(res)) {
        error_display_res(info, ui_draw_title_info, res, "Failed to delete title.");
    } else {
        linked_list_remove(deleteData->items, deleteData->selected);
        task_free_title(deleteData->selected);

        prompt_display("Success", "Title deleted.", COLOR_TEXT, false, NULL, NULL, NULL);
    }

    free(data);
}
Exemplo n.º 2
0
static void action_paste_files_update(ui_view* view, void* data, float* progress, char* text) {
    paste_files_data* pasteData = (paste_files_data*) data;

    if(pasteData->pasteInfo.finished) {
        FSUSER_ControlArchive(pasteData->target->archive, ARCHIVE_ACTION_COMMIT_SAVE_DATA, NULL, 0, NULL, 0);

        linked_list_sort(pasteData->items, util_compare_file_infos);

        ui_pop();
        info_destroy(view);

        if(R_SUCCEEDED(pasteData->pasteInfo.result)) {
            prompt_display("Success", "Contents pasted.", COLOR_TEXT, false, NULL, NULL, NULL);
        }

        action_paste_files_free_data(pasteData);

        return;
    }

    if((hidKeysDown() & KEY_B) && !pasteData->pasteInfo.finished) {
        svcSignalEvent(pasteData->pasteInfo.cancelEvent);
    }

    *progress = pasteData->pasteInfo.currTotal != 0 ? (float) ((double) pasteData->pasteInfo.currProcessed / (double) pasteData->pasteInfo.currTotal) : 0;
    snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", pasteData->pasteInfo.processed, pasteData->pasteInfo.total, util_get_display_size(pasteData->pasteInfo.currProcessed), util_get_display_size_units(pasteData->pasteInfo.currProcessed), util_get_display_size(pasteData->pasteInfo.currTotal), util_get_display_size_units(pasteData->pasteInfo.currTotal));
}
Exemplo n.º 3
0
static void action_import_seed_update(ui_view* view, void* data, float* progress, char* text) {
    title_info* info = (title_info*) data;

    Result res = util_import_seed(info->titleId);

    ui_pop();
    info_destroy(view);

    if(R_SUCCEEDED(res)) {
        prompt_display("Success", "Seed imported.", COLOR_TEXT, false, info, NULL, ui_draw_title_info, NULL);
    } else {
        error_display_res(NULL, info, ui_draw_title_info, res, "Failed to import seed.");
    }
}
Exemplo n.º 4
0
void tag_cloud_fin(void)
{
  if (tag_cloud_refcount == 0)
    return;

  if (--tag_cloud_refcount == 0)
  {
    /* finalise */

    info_destroy(LOCALS.taginfo_d);
    name_destroy(LOCALS.renametag_d);
    name_destroy(LOCALS.newtag_d);
    wimp_delete_window(LOCALS.toolbar_w);
    wimp_delete_window(LOCALS.main_w);
  }
}
Exemplo n.º 5
0
static void action_delete_secure_value_update(ui_view* view, void* data, float* progress, char* text) {
    title_info* info = (title_info*) data;

    u64 param = ((u64) SECUREVALUE_SLOT_SD << 32) | (info->titleId & 0xFFFFFFF);
    u8 out = 0;
    Result res = FSUSER_ControlSecureSave(SECURESAVE_ACTION_DELETE, &param, sizeof(param), &out, sizeof(out));

    ui_pop();
    info_destroy(view);

    if(R_FAILED(res)) {
        error_display_res(info, ui_draw_title_info, res, "Failed to delete secure value.");
    } else {
        prompt_display("Success", "Secure value deleted.", COLOR_TEXT, false, info, ui_draw_title_info, NULL);
    }
}
Exemplo n.º 6
0
static void action_delete_title_update(ui_view* view, void* data, float* progress, char* text) {
    delete_title_data* deleteData = (delete_title_data*) data;

    Result res = AM_DeleteTitle(deleteData->info->mediaType, deleteData->info->titleId);

    ui_pop();
    info_destroy(view);

    if(R_FAILED(res)) {
        error_display_res(NULL, deleteData->info, ui_draw_title_info, res, "Failed to delete title.");
    } else {
        *deleteData->populated = false;

        prompt_display("Success", "Title deleted.", COLOR_TEXT, false, deleteData->info, NULL, ui_draw_title_info, NULL);
    }

    free(data);
}
Exemplo n.º 7
0
static void action_delete_system_save_data_update(ui_view* view, void* data, float* progress, char* text) {
    delete_system_save_data_data* deleteData = (delete_system_save_data_data*) data;

    system_save_data_info* info = (system_save_data_info*) deleteData->selected->data;

    FS_SystemSaveDataInfo sysInfo = {.mediaType = MEDIATYPE_NAND, .saveId = info->systemSaveDataId};
    Result res = FSUSER_DeleteSystemSaveData(sysInfo);

    ui_pop();
    info_destroy(view);

    if(R_FAILED(res)) {
        error_display_res(info, ui_draw_system_save_data_info, res, "Failed to delete system save data.");
    } else {
        linked_list_remove(deleteData->items, deleteData->selected);
        task_free_system_save_data(deleteData->selected);

        prompt_display("Success", "System save data deleted.", COLOR_TEXT, false, NULL, NULL, NULL);
    }

    free(data);
}

static void action_delete_system_save_data_onresponse(ui_view* view, void* data, bool response) {
    if(response) {
        info_display("Deleting System Save Data", "", false, data, action_delete_system_save_data_update, action_delete_system_save_data_draw_top);
    } else {
        free(data);
    }
}

void action_delete_system_save_data(linked_list* items, list_item* selected) {
    delete_system_save_data_data* data = (delete_system_save_data_data*) calloc(1, sizeof(delete_system_save_data_data));
    if(data == NULL) {
        error_display(NULL, NULL, "Failed to allocate delete system save data data.");

        return;
    }

    data->items = items;
    data->selected = selected;

    prompt_display("Confirmation", "Delete the selected system save data?", COLOR_TEXT, true, data, action_delete_system_save_data_draw_top, action_delete_system_save_data_onresponse);
}
Exemplo n.º 8
0
static void action_install_tickets_update(ui_view* view, void* data, float* progress, char* text) {
    install_tickets_data* installData = (install_tickets_data*) data;

    if(installData->installInfo.finished) {
        ui_pop();
        info_destroy(view);

        if(!installData->installInfo.premature) {
            prompt_display("Success", "Install finished.", COLOR_TEXT, false, installData->base, NULL, ui_draw_file_info, NULL);
        }

        action_install_tickets_free_data(installData);

        return;
    }

    if(hidKeysDown() & KEY_B) {
        svcSignalEvent(installData->cancelEvent);
    }

    *progress = installData->installInfo.currTotal != 0 ? (float) ((double) installData->installInfo.currProcessed / (double) installData->installInfo.currTotal) : 0;
    snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f MB / %.2f MB", installData->installInfo.processed, installData->installInfo.total, installData->installInfo.currProcessed / 1024.0 / 1024.0, installData->installInfo.currTotal / 1024.0 / 1024.0);
}
Exemplo n.º 9
0
static void action_import_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
    import_twl_save_data* importData = (import_twl_save_data*) data;

    if(importData->importInfo.finished) {
        ui_pop();
        info_destroy(view);

        if(R_SUCCEEDED(importData->importInfo.result)) {
            prompt_display("Success", "Save imported.", COLOR_TEXT, false, importData->title, ui_draw_title_info, NULL);
        }

        free(data);

        return;
    }

    if(hidKeysDown() & KEY_B) {
        svcSignalEvent(importData->importInfo.cancelEvent);
    }

    *progress = importData->importInfo.currTotal != 0 ? (float) ((double) importData->importInfo.currProcessed / (double) importData->importInfo.currTotal) : 0;
    snprintf(text, PROGRESS_TEXT_MAX, "%.2f %s / %.2f %s", util_get_display_size(importData->importInfo.currProcessed), util_get_display_size_units(importData->importInfo.currProcessed), util_get_display_size(importData->importInfo.currTotal), util_get_display_size_units(importData->importInfo.currTotal));
}
Exemplo n.º 10
0
static void action_launch_title_update(ui_view* view, void* data, float* progress, char* text) {
    title_info* info = (title_info*) data;

    Result res = 0;

    aptOpenSession();

    if(R_SUCCEEDED(res = APT_PrepareToDoAppJump(0, info->titleId, info->mediaType))) {
        u8 buf0[0x300];
        u8 buf1[0x20];

        res = APT_DoAppJump(0x300, 0x20, buf0, buf1);
    }

    aptCloseSession();

    if(R_FAILED(res)) {
        ui_pop();
        info_destroy(view);

        error_display_res(NULL, info, ui_draw_title_info, res, "Failed to launch title.");
    }
}
Exemplo n.º 11
0
static void dumpnand_update(ui_view* view, void* data, float* progress, char* text) {
    data_op_data* dumpData = (data_op_data*) data;

    if(dumpData->finished) {
        ui_pop();
        info_destroy(view);

        if(R_SUCCEEDED(dumpData->result)) {
            prompt_display("Success", "NAND dumped.", COLOR_TEXT, false, NULL, NULL, NULL, NULL);
        }

        free(dumpData);

        return;
    }

    if(hidKeysDown() & KEY_B) {
        svcSignalEvent(dumpData->cancelEvent);
    }

    *progress = dumpData->currTotal != 0 ? (float) ((double) dumpData->currProcessed / (double) dumpData->currTotal) : 0;
    snprintf(text, PROGRESS_TEXT_MAX, "%.2f MiB / %.2f MiB", dumpData->currProcessed / 1024.0f / 1024.0f, dumpData->currTotal / 1024.0f / 1024.0f);
}
Exemplo n.º 12
0
static void backup_key_info_handler ()
{
	bk_nano.binfo = 1;
	
	NhelperTitleBarSetContent(_("Information"));
	TimerDisable(bk_nano.timer);	

	/* Create Info id */
	bk_nano.info_id = info_create();
	int* is_running = backup_get_ttsstate();

	/* Fill info item */
	char* backup_info[1];
	char present_info[128];
	snprintf(present_info, 128, "%s %f%% %s", _("Backup"), bk_nano.thiz->prog_val, _("completed."));	
	backup_info[0] = present_info;
	
	info_start (bk_nano.info_id, backup_info, 1, is_running);
	info_destroy (bk_nano.info_id);

	TimerEnable(bk_nano.timer);
	NhelperTitleBarSetContent(_("Backup"));
	NhelperStatusBarSetIcon(SRQST_SET_CATEGORY_ICON, SBAR_CATEGORY_ICON_BACKUP);
	switch(bk_nano.media)
	{
	case 0:
		NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_INTERNAL_MEM);
		break;
	case 1:
		NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_SD_CARD);
		break;
	case 2:
		NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_USB_MEM);
		break;
	}
	bk_nano.binfo = 0;
}
Exemplo n.º 13
0
static void action_install_cdn_update(ui_view* view, void* data, float* progress, char* text) {
    install_cdn_data* installData = (install_cdn_data*) data;

    if(installData->installInfo.finished) {
        ui_pop();
        info_destroy(view);

        Result res = 0;

        if(R_SUCCEEDED(installData->installInfo.result)) {
            if(R_SUCCEEDED(res = AM_InstallTitleFinish())
               && R_SUCCEEDED(res = AM_CommitImportTitles(((installData->ticket->titleId >> 32) & 0x8010) != 0 ? MEDIATYPE_NAND : MEDIATYPE_SD, 1, false, &installData->ticket->titleId))) {
                util_import_seed(installData->ticket->titleId);

                if(installData->ticket->titleId == 0x0004013800000002 || installData->ticket->titleId == 0x0004013820000002) {
                    res = AM_InstallFirm(installData->ticket->titleId);
                }
            }
        }

        if(R_SUCCEEDED(installData->installInfo.result) && R_SUCCEEDED(res)) {
            if(installData->finishedPrompt) {
                prompt_display("Success", "Install finished.", COLOR_TEXT, false, installData->ticket, NULL, ui_draw_ticket_info, NULL);
            }
        } else {
            AM_InstallTitleAbort();

            if(R_FAILED(res)) {
                error_display_res(NULL, installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title.");
            }
        }

        action_install_cdn_free_data(installData);

        return;
    }
Exemplo n.º 14
0
int stream_info(struct play_s *play)
{
	/*
	 Info uses following pipeline:

	 file -(uncompressed_buffer)->     reads data from stream file
	 unpack -(uncompressed_buffer)->   decompresses lzo/quicklz packets
	 info -(rgb)->              shows stream information
	*/

	ps_bufferattr_t attr;
	ps_buffer_t uncompressed_buffer, compressed_buffer;
	info_t info;
	unpack_t unpack;
	int ret = 0;

	if ((ret = ps_bufferattr_init(&attr)))
		goto err;

	/* initialize buffers */
	if ((ret = ps_bufferattr_setsize(&attr, play->compressed_size)))
		goto err;
	if ((ret = ps_buffer_init(&compressed_buffer, &attr)))
		goto err;

	if ((ret = ps_bufferattr_setsize(&attr, play->uncompressed_size)))
		goto err;
	if ((ret = ps_buffer_init(&uncompressed_buffer, &attr)))
		goto err;

	if ((ret = ps_bufferattr_destroy(&attr)))
		goto err;

	/* and filters */
	if ((ret = unpack_init(&unpack, &play->glc)))
		goto err;
	if ((ret = info_init(&info, &play->glc)))
		goto err;
	info_set_level(info, play->info_level);

	/* run it */
	if ((ret = unpack_process_start(unpack, &compressed_buffer, &uncompressed_buffer)))
		goto err;
	if ((ret = info_process_start(info, &uncompressed_buffer)))
		goto err;
	if ((ret = file_read(play->file, &compressed_buffer)))
		goto err;

	/* wait for threads and do cleanup */
	if ((ret = info_process_wait(info)))
		goto err;
	if ((ret = unpack_process_wait(unpack)))
		goto err;

	unpack_destroy(unpack);
	info_destroy(info);

	ps_buffer_destroy(&compressed_buffer);
	ps_buffer_destroy(&uncompressed_buffer);

	return 0;
err:
	fprintf(stderr, "extracting stream information failed: %s (%d)\n", strerror(ret), ret);
	return ret;
}