Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ProcessBider cross platform #80

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ set(CLIFP_SOURCE
tools/mounter_qmp.cpp
tools/mounter_router.h
tools/mounter_router.cpp
tools/processbider_p.h
tools/processbider.h
tools/processbider.cpp
frontend/message.h
frontend/statusrelay.h
frontend/statusrelay.cpp
Expand Down Expand Up @@ -90,8 +93,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
task/t-exec_win.cpp
task/t-bideprocess.h
task/t-bideprocess.cpp
tools/processbider.h
tools/processbider.cpp
tools/processbider_p_win.cpp
)

list(APPEND CLIFP_LINKS
Expand All @@ -106,6 +108,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
task/t-awaitdocker.h
task/t-awaitdocker.cpp
task/t-exec_linux.cpp
tools/processbider_p_linux.cpp
)
list(APPEND CLIFP_LINKS
PRIVATE
Expand Down
33 changes: 6 additions & 27 deletions app/src/task/t-bideprocess.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
// Unit Include
#include "t-bideprocess.h"

//===============================================================================================================
// TBideProcessError
//===============================================================================================================

//-Constructor-------------------------------------------------------------
//Private:
TBideProcessError::TBideProcessError(Type t, const QString& s) :
mType(t),
mSpecific(s)
{}

//-Instance Functions-------------------------------------------------------------
//Public:
bool TBideProcessError::isValid() const { return mType != NoError; }
QString TBideProcessError::specific() const { return mSpecific; }
TBideProcessError::Type TBideProcessError::type() const { return mType; }

//Private:
Qx::Severity TBideProcessError::deriveSeverity() const { return Qx::Err; }
quint32 TBideProcessError::deriveValue() const { return mType; }
QString TBideProcessError::derivePrimary() const { return ERR_STRINGS.value(mType); }
QString TBideProcessError::deriveSecondary() const { return mSpecific; }

//===============================================================================================================
// TBideProcess
//===============================================================================================================
Expand All @@ -32,9 +9,10 @@ QString TBideProcessError::deriveSecondary() const { return mSpecific; }
//Public:
TBideProcess::TBideProcess(QObject* parent) :
Task(parent),
mProcessBider(nullptr, STANDARD_GRACE)
mProcessBider(nullptr)
{
// Setup bider
mProcessBider.setRespawnGrace(STANDARD_GRACE);
connect(&mProcessBider, &ProcessBider::statusChanged, this, [this](QString statusMessage){
emit eventOccurred(NAME, statusMessage);
});
Expand All @@ -61,16 +39,17 @@ void TBideProcess::setProcessName(QString processName) { mProcessName = processN
void TBideProcess::perform()
{
// Start bide
mProcessBider.start(mProcessName);
mProcessBider.setProcessName(mProcessName);
mProcessBider.start();
}

void TBideProcess::stop()
{
if(mProcessBider.isRunning())
{
emit eventOccurred(NAME, LOG_EVENT_STOPPING_BIDE_PROCESS);
if(!mProcessBider.closeProcess())
emit errorOccurred(NAME, TBideProcessError(TBideProcessError::CantClose));
if(ProcessBiderError err = mProcessBider.closeProcess(); err.isValid())
emit errorOccurred(NAME, err);
}
}

Expand Down
43 changes: 0 additions & 43 deletions app/src/task/t-bideprocess.h
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
#ifndef TBIDEPROCESS_H
#define TBIDEPROCESS_H

// Qx Includes
#include <qx/utility/qx-macros.h>

// Project Includes
#include "task/task.h"
#include "tools/processbider.h"

class QX_ERROR_TYPE(TBideProcessError, "TBideProcessError", 1251)
{
friend class TBideProcess;
//-Class Enums-------------------------------------------------------------
public:
enum Type
{
NoError = 0,
CantClose = 1,
};

//-Class Variables-------------------------------------------------------------
private:
static inline const QHash<Type, QString> ERR_STRINGS{
{NoError, u""_s},
{CantClose, u"Could not automatically end the running title! It will have to be closed manually."_s},
};

//-Instance Variables-------------------------------------------------------------
private:
Type mType;
QString mSpecific;

//-Constructor-------------------------------------------------------------
private:
TBideProcessError(Type t = NoError, const QString& s = {});

//-Instance Functions-------------------------------------------------------------
public:
bool isValid() const;
Type type() const;
QString specific() const;

private:
Qx::Severity deriveSeverity() const override;
quint32 deriveValue() const override;
QString derivePrimary() const override;
QString deriveSecondary() const override;
};

class TBideProcess : public Task
{
Q_OBJECT;
Expand Down
Loading