Skip to content

Commit

Permalink
Use postDirective<DStatusUpdate> directly
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Nov 14, 2024
1 parent 8981075 commit d44a2e0
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/backend/src/command/c-download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ QString CDownload::name() const { return NAME; }
Qx::Error CDownload::perform()
{
QString playlistName = mParser.value(CL_OPTION_PLAYLIST).trimmed();
mCore.setStatus(STATUS_DOWNLOAD, playlistName);
postDirective<DStatusUpdate>(STATUS_DOWNLOAD, playlistName);

Fp::Db* db = mCore.fpInstall().database();
Fp::PlaylistManager* pm = mCore.fpInstall().playlistManager();
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/src/command/c-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Qx::Error CLink::perform()
if(Qx::Error ide = getTitleId(shortcutId); ide.isValid())
return ide;

mCore.setStatus(STATUS_LINK, shortcutId.toString(QUuid::WithoutBraces));
postDirective<DStatusUpdate>(STATUS_LINK, shortcutId.toString(QUuid::WithoutBraces));

// Get database
Fp::Db* database = mCore.fpInstall().database();
Expand Down
4 changes: 2 additions & 2 deletions lib/backend/src/command/c-play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Qx::Error CPlay::handleEntry(const Fp::AddApp& addApp)
QString platformName = parentResult.result.value(Fp::Db::Table_Game::COL_PLATFORM_NAME).toString();

// Enqueue
mCore.setStatus(STATUS_PLAY, addApp.name());
postDirective<DStatusUpdate>(STATUS_PLAY, addApp.name());

if(sError = enqueueAdditionalApp(addApp, platformName, Task::Stage::Primary); sError.isValid())
return sError;
Expand Down Expand Up @@ -292,7 +292,7 @@ Qx::Error CPlay::enqueueGame(const Fp::Game& game, const Fp::GameData& gameData,
gameTask->setProcessType(TExec::ProcessType::Blocking);

mCore.enqueueSingleTask(gameTask);
mCore.setStatus(STATUS_PLAY, game.title());
postDirective<DStatusUpdate>(STATUS_PLAY, game.title());

#ifdef _WIN32
// Add wait task if required
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/src/command/c-prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Qx::Error CPrepare::perform()
if(Qx::Error ee = mCore.enqueueDataPackTasks(titleGameData); ee.isValid())
return ee;

mCore.setStatus(STATUS_PREPARE, id.toString(QUuid::WithoutBraces));
postDirective<DStatusUpdate>(STATUS_PREPARE, id.toString(QUuid::WithoutBraces));
}
else
logError(Qx::GenericError(Qx::Warning, 12141, LOG_WRN_PREP_NOT_DATA_PACK.arg(id.toString(QUuid::WithoutBraces))));
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/src/command/c-run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Qx::Error CRun::perform()
runTask->setProcessType(TExec::ProcessType::Blocking);

mCore.enqueueSingleTask(runTask);
mCore.setStatus(STATUS_RUN, inputInfo.fileName());
postDirective<DStatusUpdate>(STATUS_RUN, inputInfo.fileName());

#ifdef _WIN32
// Add wait task if required
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/src/command/c-share.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Qx::Error CShare::perform()
if(Qx::Error ide = getTitleId(shareId); ide.isValid())
return ide;

mCore.setStatus(STATUS_SHARE, shareId.toString(QUuid::WithoutBraces));
postDirective<DStatusUpdate>(STATUS_SHARE, shareId.toString(QUuid::WithoutBraces));

// Generate URL
QString idStr = shareId.toString(QUuid::WithoutBraces);
Expand Down
4 changes: 2 additions & 2 deletions lib/backend/src/command/c-show.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Qx::Error CShow::perform()
messageTask->setText(mParser.value(CL_OPTION_MSG));

mCore.enqueueSingleTask(messageTask);
mCore.setStatus(STATUS_SHOW_MSG, messageTask->text());
postDirective<DStatusUpdate>(STATUS_SHOW_MSG, messageTask->text());
}
else if(mParser.isSet(CL_OPTION_EXTRA))
{
Expand All @@ -61,7 +61,7 @@ Qx::Error CShow::perform()
extraTask->setDirectory(QDir(mCore.fpInstall().extrasDirectory().absolutePath() + '/' + mParser.value(CL_OPTION_EXTRA)));

mCore.enqueueSingleTask(extraTask);
mCore.setStatus(STATUS_SHOW_EXTRA, extraTask->directory().dirName());
postDirective<DStatusUpdate>(STATUS_SHOW_EXTRA, extraTask->directory().dirName());
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions lib/backend/src/command/c-update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ CUpdateError CUpdate::checkAndPrepareUpdate() const
}

// Check for update
mCore.setStatus(STATUS, STATUS_CHECKING);
postDirective<DStatusUpdate>(STATUS, STATUS_CHECKING);
logEvent(LOG_EVENT_CHECKING_FOR_NEWER_VERSION);

// Get new release data
Expand Down Expand Up @@ -363,7 +363,7 @@ CUpdateError CUpdate::checkAndPrepareUpdate() const

Qx::Error CUpdate::installUpdate(const QFileInfo& existingAppInfo) const
{
mCore.setStatus(STATUS, STATUS_INSTALLING);
postDirective<DStatusUpdate>(STATUS, STATUS_INSTALLING);

// Wait for previous process to close, lock instance afterwards
static const int totalGrace = 2000;
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/src/command/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void Command::showHelp()
static QString helpStr;

// Update status
mCore.setStatus(Core::STATUS_DISPLAY, Core::STATUS_DISPLAY_HELP);
postDirective<DStatusUpdate>(Core::STATUS_DISPLAY, Core::STATUS_DISPLAY_HELP);

// One time setup
if(helpStr.isNull())
Expand Down
23 changes: 6 additions & 17 deletions lib/backend/src/kernel/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ QString CoreError::deriveSecondary() const { return mSpecific; }
//Public:
Core::Core() :
Directorate(&mDirector),
mServicesMode(ServicesMode::Standalone),
mStatusHeading(u"Initializing"_s),
mStatusMessage(u"..."_s)
mServicesMode(ServicesMode::Standalone)
{}

//-Instance Functions-------------------------------------------------------------
Expand All @@ -82,7 +80,7 @@ void Core::showHelp()
static QString helpStr;

// Update status
setStatus(STATUS_DISPLAY, STATUS_DISPLAY_HELP);
postDirective<DStatusUpdate>(STATUS_DISPLAY, STATUS_DISPLAY_HELP);

// One time setup
if(helpStr.isNull())
Expand Down Expand Up @@ -116,7 +114,7 @@ void Core::showHelp()

void Core::showVersion()
{
setStatus(STATUS_DISPLAY, STATUS_DISPLAY_VERSION);
postDirective<DStatusUpdate>(STATUS_DISPLAY, STATUS_DISPLAY_VERSION);
postDirective<DMessage>(CL_VERSION_MESSAGE);
}

Expand Down Expand Up @@ -230,6 +228,9 @@ void Core::logTask(const Task* task) { logEvent(LOG_EVENT_TASK_ENQ.arg(task->nam
//Public:
Qx::Error Core::initialize(QStringList& commandLine)
{
// Send initial status
postDirective<DStatusUpdate>(u"Initializing"_s, u"..."_s);

// Setup CLI Parser
QCommandLineParser clParser;
clParser.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments);
Expand Down Expand Up @@ -821,18 +822,6 @@ bool Core::hasTasks() const { return mTaskQueue.size() > 0; }
Task* Core::frontTask() { return mTaskQueue.front(); }
void Core::removeFrontTask() { mTaskQueue.pop(); }

QString Core::statusHeading() { return mStatusHeading; }
QString Core::statusMessage() { return mStatusMessage;}
void Core::setStatus(QString heading, QString message)
{
/* TODO: Probably can do away with this and just use postDirective<DStatusUpdate>() where it's needed.
* The stored status is never used currently and I can't think of any reason it would b
*/
mStatusHeading = heading;
mStatusMessage = message;
postDirective<DStatusUpdate>(heading, message);
}

BuildInfo Core::buildInfo() const
{
constexpr auto sysOpt = magic_enum::enum_cast<BuildInfo::System>(BUILDINFO_SYSTEM);
Expand Down
9 changes: 0 additions & 9 deletions lib/backend/src/kernel/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ class Core : public QObject, public Directorate
ServicesMode mServicesMode;
std::queue<Task*> mTaskQueue;

// Info
QString mStatusHeading;
QString mStatusMessage;

// Other
QProcessEnvironment mChildTitleProcEnv;
Qx::ProcessBider mLauncherWatcher;
Expand Down Expand Up @@ -265,11 +261,6 @@ class Core : public QObject, public Directorate
Task* frontTask();
void removeFrontTask();

// Status
QString statusHeading();
QString statusMessage();
void setStatus(QString heading, QString message);

// Other
BuildInfo buildInfo() const;

Expand Down

0 comments on commit d44a2e0

Please sign in to comment.