add printerhive cloud print host #1479

Open
opened 2026-04-05 17:58:09 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jakubfrasunek on 11/29/2025

Description

Summary

This PR adds support for Printerhive.com as a new print host option in OrcaSlicer. Users can now upload G-code files directly to Printerhive.com using their host URL and API key.

What this PR addresses

  • Adds Printerhive.com as a new print host type
  • Implements connection testing via GET request to user-provided host URL
  • Implements file upload via POST request to user-provided host URL
  • Supports automatic Device tab navigation after successful upload with custom URL display

New features

  • Printerhive Print Host: New print host option available in printer settings
  • Simple Configuration: Only requires host URL and API key (X-Api-Key header)
  • Dynamic URL Generation: After upload, automatically generates display URL by:
    • Replacing /orcaslicer/ with /orcaslicer-print/ in the host URL
    • Appending /file_uuid from upload response
    • Adding API key as query parameter (?api_key=...)
  • Device Tab Integration: When "Switch to Device tab after upload" is enabled, automatically:
    • Switches Device tab from MonitorPanel to PrinterWebView
    • Loads the generated Printerhive URL with API key

Technical details

  • Test endpoint: GET request to user-provided host URL (success if HTTP 200)
  • Upload endpoint: POST request to user-provided host URL with multipart form data
  • Authentication: Uses X-Api-Key header (same as OctoPrint)
  • Response parsing: Extracts file_uuid from JSON response after upload
  • Thread safety: Uses CallAfter() for GUI operations from HTTP callback thread

Files changed

  • src/libslic3r/PrintConfig.hpp - Added htPrinterhive enum value
  • src/libslic3r/PrintConfig.cpp - Registered printerhive in enum mapping and labels
  • src/slic3r/Utils/Printerhive.hpp - New header file with Printerhive class declaration
  • src/slic3r/Utils/Printerhive.cpp - New implementation file with test() and upload() methods
  • src/slic3r/Utils/PrintHost.cpp - Added Printerhive to print host factory
  • src/slic3r/CMakeLists.txt - Added Printerhive.cpp to build configuration

Breaking changes

None. This is a purely additive change that does not affect existing functionality.

Dependencies

  • Uses existing HTTP infrastructure (Http.hpp)
  • Uses existing GUI components (MainFrame, PrinterWebView)
  • Uses nlohmann/json for response parsing

Screenshots

Snímek obrazovky 2025-11-29 v 1 50 36 Snímek obrazovky 2025-11-29 v 1 50 52 Snímek obrazovky 2025-11-29 v 1 51 25 Snímek obrazovky 2025-11-29 v 1 51 34

Tests

Manual testing performed:

  1. Added Printerhive as print host with host URL and API key
  2. Tested connection using "Test" button - verified GET request returns HTTP 200
  3. Uploaded G-code file - verified POST request succeeds and receives file_uuid in response
  4. Verified URL generation: /orcaslicer//orcaslicer-print/ + /file_uuid + ?api_key=...
  5. Verified Device tab switch after upload when "Switch to Device tab after upload" is enabled
  6. Verified PrinterWebView loads with correct URL and API key in query parameter
  7. Tested with various host URL formats (with/without trailing spaces)
  8. Tested error handling for invalid JSON responses

Test cases:

  • Connection test: GET request to host URL, expects HTTP 200
  • File upload: POST request with multipart form data, expects JSON response with file_uuid
  • URL generation: Correctly transforms host URL and appends file_uuid and API key
  • Device tab navigation: Correctly switches to PrinterWebView and loads URL
  • Thread safety: GUI operations properly executed in main thread via CallAfter()

Edge cases handled:

  • Empty or missing file_uuid in response (URL generated without file_uuid)
  • Empty API key (URL generated without query parameter)
  • Host URL with trailing spaces (automatically trimmed)
  • Invalid JSON response (graceful error handling with warning log)
*Originally created by @jakubfrasunek on 11/29/2025* # Description ## Summary This PR adds support for Printerhive.com as a new print host option in OrcaSlicer. Users can now upload G-code files directly to Printerhive.com using their host URL and API key. ## What this PR addresses - Adds Printerhive.com as a new print host type - Implements connection testing via GET request to user-provided host URL - Implements file upload via POST request to user-provided host URL - Supports automatic Device tab navigation after successful upload with custom URL display ## New features - **Printerhive Print Host**: New print host option available in printer settings - **Simple Configuration**: Only requires host URL and API key (X-Api-Key header) - **Dynamic URL Generation**: After upload, automatically generates display URL by: - Replacing `/orcaslicer/` with `/orcaslicer-print/` in the host URL - Appending `/file_uuid` from upload response - Adding API key as query parameter (`?api_key=...`) - **Device Tab Integration**: When "Switch to Device tab after upload" is enabled, automatically: - Switches Device tab from MonitorPanel to PrinterWebView - Loads the generated Printerhive URL with API key ## Technical details - **Test endpoint**: GET request to user-provided host URL (success if HTTP 200) - **Upload endpoint**: POST request to user-provided host URL with multipart form data - **Authentication**: Uses `X-Api-Key` header (same as OctoPrint) - **Response parsing**: Extracts `file_uuid` from JSON response after upload - **Thread safety**: Uses `CallAfter()` for GUI operations from HTTP callback thread ## Files changed - `src/libslic3r/PrintConfig.hpp` - Added `htPrinterhive` enum value - `src/libslic3r/PrintConfig.cpp` - Registered printerhive in enum mapping and labels - `src/slic3r/Utils/Printerhive.hpp` - New header file with Printerhive class declaration - `src/slic3r/Utils/Printerhive.cpp` - New implementation file with test() and upload() methods - `src/slic3r/Utils/PrintHost.cpp` - Added Printerhive to print host factory - `src/slic3r/CMakeLists.txt` - Added Printerhive.cpp to build configuration ## Breaking changes None. This is a purely additive change that does not affect existing functionality. ## Dependencies - Uses existing HTTP infrastructure (Http.hpp) - Uses existing GUI components (MainFrame, PrinterWebView) - Uses nlohmann/json for response parsing # Screenshots <img width="642" height="391" alt="Snímek obrazovky 2025-11-29 v 1 50 36" src="https://github.com/user-attachments/assets/b0a1a2d7-1821-4b2e-ae3f-1273971ff3dc" /> <img width="438" height="178" alt="Snímek obrazovky 2025-11-29 v 1 50 52" src="https://github.com/user-attachments/assets/a32d1954-8799-418e-a634-96fe3bef97b7" /> <img width="1794" height="1054" alt="Snímek obrazovky 2025-11-29 v 1 51 25" src="https://github.com/user-attachments/assets/dc48276b-9aee-438f-b1a0-211c64b98109" /> <img width="1800" height="1056" alt="Snímek obrazovky 2025-11-29 v 1 51 34" src="https://github.com/user-attachments/assets/1479a4b0-0b8d-4caf-8f4e-6cdc59478601" /> ## Tests ### Manual testing performed: 1. ✅ Added Printerhive as print host with host URL and API key 2. ✅ Tested connection using "Test" button - verified GET request returns HTTP 200 3. ✅ Uploaded G-code file - verified POST request succeeds and receives file_uuid in response 4. ✅ Verified URL generation: `/orcaslicer/` → `/orcaslicer-print/` + `/file_uuid` + `?api_key=...` 5. ✅ Verified Device tab switch after upload when "Switch to Device tab after upload" is enabled 6. ✅ Verified PrinterWebView loads with correct URL and API key in query parameter 7. ✅ Tested with various host URL formats (with/without trailing spaces) 8. ✅ Tested error handling for invalid JSON responses ### Test cases: - **Connection test**: GET request to host URL, expects HTTP 200 - **File upload**: POST request with multipart form data, expects JSON response with `file_uuid` - **URL generation**: Correctly transforms host URL and appends file_uuid and API key - **Device tab navigation**: Correctly switches to PrinterWebView and loads URL - **Thread safety**: GUI operations properly executed in main thread via CallAfter() ### Edge cases handled: - Empty or missing `file_uuid` in response (URL generated without file_uuid) - Empty API key (URL generated without query parameter) - Host URL with trailing spaces (automatically trimmed) - Invalid JSON response (graceful error handling with warning log)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#1479