Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
message pass by value
Browse files Browse the repository at this point in the history
had switch message args to pass by ref; switch back to by value
  • Loading branch information
PilotMatt committed Mar 12, 2024
1 parent 15b1b6f commit 92924bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
31 changes: 13 additions & 18 deletions src/slic3r/Utils/PrintagoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ PrintagoDirector::~PrintagoDirector()
delete m_select_machine_dlg;
}

void PrintagoDirector::PostErrorMessage(const wxString& printer_id,
const wxString& localCommand,
const json& command,
const wxString& errorDetail,
void PrintagoDirector::PostErrorMessage(const wxString printer_id,
const wxString localCommand,
const json command,
const wxString errorDetail,
const bool shouldUnblock)
{
if (!PBJob::CanProcessJob() && shouldUnblock) {
Expand Down Expand Up @@ -216,7 +216,7 @@ void PrintagoDirector::PostJobUpdateMessage()
_PostResponse(*resp);
}

void PrintagoDirector::PostResponseMessage(const wxString& printer_id, const json& responseData, const json& command)
void PrintagoDirector::PostResponseMessage(const wxString printer_id, const json responseData, const json command)
{
auto resp = std::make_unique<PrintagoResponse>();
resp->SetMessageType("status");
Expand All @@ -227,10 +227,10 @@ void PrintagoDirector::PostResponseMessage(const wxString& printer_id, const jso
_PostResponse(*resp);
}

void PrintagoDirector::PostSuccessMessage(const wxString& printer_id,
const wxString& localCommand,
const json& command,
const wxString& localCommandDetail)
void PrintagoDirector::PostSuccessMessage(const wxString printer_id,
const wxString localCommand,
const json command,
const wxString localCommandDetail)
{
json responseData;
responseData["local_command"] = localCommand.ToStdString();
Expand All @@ -246,7 +246,7 @@ void PrintagoDirector::PostSuccessMessage(const wxString& printer_id,
_PostResponse(*resp);
}

void PrintagoDirector::PostStatusMessage(const wxString& printer_id, const json& statusData, const json& command)
void PrintagoDirector::PostStatusMessage(const wxString printer_id, const json statusData, const json command)
{
auto resp = std::make_unique<PrintagoResponse>();
resp->SetMessageType("status");
Expand All @@ -257,7 +257,7 @@ void PrintagoDirector::PostStatusMessage(const wxString& printer_id, const json&
_PostResponse(*resp);
}
//if it's the special ones and we're blocking then send a PrintagoError, and unblock the UI.
void PrintagoDirector::PostDialogMessage(const wxString& dialogType, const wxString& dialogHeadline, const wxString& dialogMessage)
void PrintagoDirector::PostDialogMessage(const wxString dialogType, const wxString dialogHeadline, const wxString dialogMessage)
{
if (!server || !server->get_session()) {
return;
Expand Down Expand Up @@ -291,7 +291,7 @@ void PrintagoDirector::PostDialogMessage(const wxString& dialogType, const wxStr
_PostResponse(*resp);
}

void PrintagoDirector::_PostResponse(const PrintagoResponse& response) const
void PrintagoDirector::_PostResponse(const PrintagoResponse response) const
{
wxDateTime now = wxDateTime::Now();
now.MakeUTC();
Expand Down Expand Up @@ -503,12 +503,7 @@ bool PrintagoDirector::ProcessPrintagoCommand(const PrintagoCommand& cmd)
if (!commandType.compare("meta")) {
if (!action.compare("init")) {
std::string token = parameters["token"];
std::string url_base(PRINTAGO_TOKEN_ENDPOINT);

// ONLY FOR DEV USE - DISABLE FOR PRODUCTION
// if (parameters.find("url_base") != parameters.end() && !parameters["url_base"].empty()) {
// url_base = Http::url_decode(parameters["url_base"]);
// }
std::string url_base(PRINTAGO_BASE_URL);

if (token.empty()) {
PostErrorMessage("", "", cmd.GetOriginalCommand(), "Unauthorized: No Token");
Expand Down
27 changes: 13 additions & 14 deletions src/slic3r/Utils/PrintagoServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace Slic3r {

static constexpr short PRINTAGO_PORT = 33647;

// DEV // static constexpr std::string_view PRINTAGO_TOKEN_ENDPOINT = "https://dev.printago.io"; // DEV //
static constexpr std::string_view PRINTAGO_TOKEN_ENDPOINT = "https://app.printago.io"; //PRODUCTION//
static constexpr std::string_view PRINTAGO_BASE_URL = "https://app.printago.io";

void printago_ws_error(beefy::error_code ec, char const* what);

Expand Down Expand Up @@ -168,7 +167,7 @@ class PrintagoDirector
void RemoveMergedProcessOverrideConfig();

void PostJobUpdateMessage();
void PostDialogMessage(const wxString& dialogType, const wxString& dialogHeadline, const wxString& dialogMessage);
void PostDialogMessage(const wxString dialogType, const wxString dialogHeadline, const wxString dialogMessage);

void ResetMachineDialog()
{
Expand All @@ -188,19 +187,19 @@ class PrintagoDirector

GUI::SelectMachineDialog* m_select_machine_dlg = nullptr;

void PostStatusMessage(const wxString& printer_id, const json& statusData, const json& command = {});
void PostResponseMessage(const wxString& printer_id, const json& responseData, const json& command = {});
void PostSuccessMessage(const wxString& printer_id,
const wxString& localCommand,
const json& command = {},
const wxString& localCommandDetail = "");
void PostErrorMessage(const wxString& printer_id,
const wxString& localCommand,
const json& command = {},
const wxString& errorDetail = "",
void PostStatusMessage(const wxString printer_id, const json statusData, const json command = {});
void PostResponseMessage(const wxString printer_id, const json responseData, const json command = {});
void PostSuccessMessage(const wxString printer_id,
const wxString localCommand,
const json command = {},
const wxString localCommandDetail = "");
void PostErrorMessage(const wxString printer_id,
const wxString localCommand,
const json command = {},
const wxString errorDetail = "",
const bool shouldUnblock = false);

void _PostResponse(const PrintagoResponse& response) const;
void _PostResponse(const PrintagoResponse response) const;

bool ValidatePrintagoCommand(const PrintagoCommand& cmd);
bool ProcessPrintagoCommand(const PrintagoCommand& command);
Expand Down

0 comments on commit 92924bb

Please sign in to comment.