MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / license_thread

Function license_thread

refresh.c:437–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437int license_thread(SceSize args, void *argp)
438{
439 SceUID thid = -1;
440 license_data_t license_data = { 0, 0, 0, 0, 0, 1, malloc(RIF_SIZE) };
441
442 if (license_data.rif == NULL)
443 goto EXIT;
444
445 // Lock power timers
446 powerLock();
447
448 // Set progress to 0%
449 sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 0);
450 sceKernelDelayThread(DIALOG_WAIT); // Needed to see the percentage
451
452 // NB: ux0:license access requires elevated permisions
453 if (parse_dir_with_callback(SCE_S_IFDIR, "ux0:license/app", license_dir_callback, &license_data) < 0)
454 goto EXIT;
455 license_data.max_depth++;
456 if (parse_dir_with_callback(SCE_S_IFDIR, "ux0:license/addcont", license_dir_callback, &license_data) < 0)
457 goto EXIT;
458
459 // Update thread
460 thid = createStartUpdateThread(license_data.count, 0);
461
462 // Create the DB if needed
463 SceUID fd = sceIoOpen(LICENSE_DB, SCE_O_RDONLY, 0777);
464 if (fd > 0) {
465 sceIoClose(fd);
466 } else if (create_db(LICENSE_DB, LICENSE_DB_SCHEMA) != 0) {
467 goto EXIT;
468 }
469
470 // Insert the licenses
471 license_data.copy_pass = 1;
472 license_data.max_depth = 1;
473 if (parse_dir_with_callback(SCE_S_IFDIR, "ux0:license/app", license_dir_callback, &license_data) < 0)
474 goto EXIT;
475 license_data.max_depth++;
476 if (parse_dir_with_callback(SCE_S_IFDIR, "ux0:license/addcont", license_dir_callback, &license_data) < 0)
477 goto EXIT;
478
479 // Set progress to 100%
480 sceMsgDialogProgressBarSetValue(SCE_MSG_DIALOG_PROGRESSBAR_TARGET_BAR_DEFAULT, 100);
481 sceKernelDelayThread(COUNTUP_WAIT);
482
483 // Close
484 closeWaitDialog();
485
486 infoDialog(language_container[IMPORTED_LICENSES], license_data.copied);
487
488EXIT:
489 if (thid >= 0)
490 sceKernelWaitThreadEnd(thid, NULL, NULL);
491
492 // Unlock power timers
493 powerUnlock();
494

Callers

nothing calls this directly

Calls 8

powerLockFunction · 0.85
parse_dir_with_callbackFunction · 0.85
createStartUpdateThreadFunction · 0.85
create_dbFunction · 0.85
closeWaitDialogFunction · 0.85
infoDialogFunction · 0.85
powerUnlockFunction · 0.85

Tested by

no test coverage detected