This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to the way handling menu events works.
- Menu events now dont have to iterate through the map rather finding the correct key. - Continued work on implimenting the Payload Loader.
- Loading branch information
Showing
20 changed files
with
301 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#include "Common.h" | ||
#include "Daemons.h" | ||
|
||
#include "SysfileUtilWrapper.h" | ||
#include "LncUtil.h" | ||
|
||
bool Start_Daemon(char* TitleId) | ||
{ | ||
if (!Is_Daemon_Running(TitleId)) | ||
{ | ||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; | ||
LncUtil::LaunchApp(TitleId, 0, 0, &p); | ||
|
||
if (!Is_Daemon_Running(TitleId)) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool Stop_Daemon(char* TitleId) | ||
{ | ||
int AppId = LncUtil::GetAppId(TitleId); | ||
if (AppId > 0) | ||
{ | ||
LncUtil::KillApp(AppId); | ||
|
||
if (Is_Daemon_Running(TitleId)) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool Is_Daemon_Running(char* TitleId) | ||
{ | ||
return (LncUtil::GetAppId(TitleId) > 0); | ||
} | ||
|
||
/* | ||
Will start or stop a Daemon depending on its state. | ||
TitleId - A string representing the Daemons title Index usually in form of XXXX##### | ||
Restart - If the Daemon is already running will stop and restart it. | ||
*/ | ||
bool Start_Stop_Daemon(char* TitleId, bool Restart) | ||
{ | ||
int AppId = LncUtil::GetAppId(TitleId); | ||
if (AppId > 0) | ||
{ | ||
LncUtil::KillApp(AppId); | ||
|
||
if ((LncUtil::GetAppId(TitleId) <= 0) && Restart) | ||
return Start_Stop_Daemon(TitleId, false); | ||
else if (LncUtil::GetAppId(TitleId) <= 0) | ||
return true; | ||
else | ||
return false; | ||
} | ||
else | ||
{ | ||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; | ||
LncUtil::LaunchApp(TitleId, 0, 0, &p); | ||
|
||
return (LncUtil::GetAppId(TitleId) > 0); | ||
} | ||
} | ||
|
||
void Add_Daemon(char* dent) | ||
{ | ||
char TitleId[10]; | ||
strcpy(TitleId, dent); | ||
|
||
char Id_Name[0x100]; | ||
sprintf(Id_Name, "id_%s", TitleId); | ||
klog("%s\n", Id_Name); | ||
|
||
char Icon_Path[PATH_MAX]; | ||
sprintf(Icon_Path, "file://system/vsh/app/%s/sce_sys/icon0.png", TitleId); | ||
klog("%s\n", Icon_Path); | ||
|
||
char SFO_Path[PATH_MAX]; | ||
sprintf(SFO_Path, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId); | ||
klog("%s\n", SFO_Path); | ||
|
||
UI::Utilities::AddMenuItem(UI::Utilities::ElementData(Id_Name, SysfileUtilWrapper::GetTitle(SFO_Path), SysfileUtilWrapper::GetDescription(SFO_Path), Icon_Path)); | ||
|
||
Menu::Add_Option(Id_Name, [TitleId, Id_Name]() -> void { | ||
|
||
int AppId = LncUtil::GetAppId(TitleId); | ||
if (AppId > 0) //App is Currently Running. | ||
{ | ||
UI::Utilities::Set_Value(Id_Name, "Stopping"); | ||
UI::Utilities::ResetMenuItem(Id_Name); | ||
|
||
//Kill the app. | ||
LncUtil::KillApp(AppId); | ||
|
||
//Check to see if it worked. | ||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); | ||
UI::Utilities::ResetMenuItem(Id_Name); | ||
} | ||
else | ||
{ | ||
UI::Utilities::Set_Value(Id_Name, "Starting"); | ||
UI::Utilities::ResetMenuItem(Id_Name); | ||
|
||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; | ||
LncUtil::LaunchApp(TitleId, 0, 0, &p); | ||
|
||
//Check to see if it worked. | ||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); | ||
UI::Utilities::ResetMenuItem(Id_Name); | ||
} | ||
|
||
}); | ||
|
||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); | ||
UI::Utilities::ResetMenuItem(Id_Name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
bool Start_Daemon(char* TitleId); | ||
bool Stop_Daemon(char* TitleId); | ||
bool Is_Daemon_Running(char* TitleId); | ||
bool Start_Stop_Daemon(char* TitleId, bool Restart = false); | ||
|
||
void Add_Daemon(char* dent); |
Oops, something went wrong.