linux downloader executable

This commit is contained in:
David Kocik 2022-06-13 16:23:02 +02:00
parent 3b13add8a0
commit 8a617fd8f7
4 changed files with 23 additions and 9 deletions

View File

@ -1,7 +1,8 @@
#cmake_minimum_required(VERSION 3.13)
#project(PrusaSlicer_Downloader)
add_executable(PrusaSlicer_Downloader WIN32
#add_executable(PrusaSlicer_Downloader WIN32
add_executable(PrusaSlicer_Downloader
DownloaderApp.cpp
DownloaderApp.hpp
Download.cpp

View File

@ -125,10 +125,10 @@ bool DownloadApp::OnCmdLineParsed(wxCmdLineParser& parser)
m_frame->Close(true);
return false;
} else {
if (!url.empty() && m_frame != nullptr)
if (!url.empty() && m_frame != nullptr) {
m_frame->start_download(std::move(url));
//m_frame->start_download("open?file=https%3A%2F%2Fmedia.printables.com%2Fmedia%2Fprints%2F152208%2Fstls%2F1431590_8b8287b3-03b1-4cbe-82d0-268a0affa171%2Ff1_logo.stl");
//m_frame->start_download("prusaslicer://open?file=https%3A%2F%2Fmedia.printables.com%2Fmedia%2Fprints%2F152208%2Fstls%2F1431590_8b8287b3-03b1-4cbe-82d0-268a0affa171%2Ff1_logo.stl");
}
return wxApp::OnCmdLineParsed(parser);
}
@ -207,10 +207,12 @@ DownloadFrame::DownloadFrame(const wxString& title, const wxPoint& pos, const wx
void DownloadFrame::start_download(wxString url)
{
printf("start_download %s \n", boost::nowide::narrow(url).c_str());
// prusaslicer://open?file=https%3A%2F%2Fmedia.printables.com%2Fmedia%2Fprints%2F152208%2Fstls%2F1431590_8b8287b3-03b1-4cbe-82d0-268a0affa171%2Ff1_logo.stl
if (url.starts_with("prusaslicer://open/?file=")) {
if (url.starts_with("prusaslicer://open?file=")) {
int id = get_next_id();
std::string escaped_url = FileGet::escape_url(boost::nowide::narrow(url.substr(25)));
std::string escaped_url = FileGet::escape_url(boost::nowide::narrow(url.substr(24)));
printf("escaped url %s \n", escaped_url.c_str());
//log(std::to_string(id) + ": start " + escaped_url);
//escaped_url = "https://media.printables.com/media/prints/216267/gcodes/1974221_32d21613-b567-4328-8261-49b46d9dd249/01_big_trex_skull_with_threads_015mm_pla_mk3_2d.gcode";
m_downloads.emplace_back(std::make_unique<Download>(id, std::move(escaped_url), this, m_dest_folder));
@ -229,11 +231,17 @@ void DownloadFrame::start_download(wxString url)
break;
}
}
printf("can start %d \n", can_start);
if (can_start)
m_downloads.back()->start();
} else {
//log("wrong url: " + url);
printf("Did not parse \n");
if (url.size() > 24)
{
printf("%s\n", boost::nowide::narrow(url.substr(0,24)).c_str());
printf("prusaslicer://open?file=\n");
}
}
}

View File

@ -1,5 +1,8 @@
#include "Http.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/format.hpp"
#include <cstdlib>
#include <functional>
#include <thread>

View File

@ -423,16 +423,18 @@ void DesktopIntegrationDialog::perform_desktop_integration()
bool url_destop_file = true;
if (url_destop_file)
{
boost::filesystem::path path(excutable_path);
std::string downloader_path = (path.parent_path() / "downloader/prusa-slicer-downloader").string();
// no need for icon right?
std::string desktop_file = GUI::format(
"[Desktop Entry]\n"
"Name=PrusaSlicer URL Protocol%1%\n"
"Exec=\"%3%\" %%u\n"
"Exec=\"%3%\" -u %%u\n"
"Terminal=false\n"
"Type=Application\n"
"MimeType=x-scheme-handler/prusaslicer;\n"
"StartupNotify=false\n"
, name_suffix, version_suffix, excutable_path);
, name_suffix, version_suffix, downloader_path);
std::string desktop_path = GUI::format("%1%/applications/PrusaSlicerURLProtocol%2%.desktop", target_dir_desktop, version_suffix);
if (create_desktop_file(desktop_path, desktop_file)) {