From ccde4d69f4e7dfc5e412915bfe00e77d70af8986 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 15 Jun 2026 20:05:46 +0200 Subject: [PATCH] Move cloud transfer helpers to legacy cloud services --- docs/modernization/debt.md | 9 ++- docs/modernization/roadmap.md | 6 ++ docs/modernization/tasks.md | 42 ++++++++++- src/app.cpp | 121 ------------------------------- src/app.h | 4 -- src/legacy_cloud_services.cpp | 131 +++++++++++++++++++++++++++++++++- 6 files changed, 183 insertions(+), 130 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 455fbeae..16f8a9e5 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,13 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-15: `DEBT-0038` was narrowed again. Retained upload/download CURL + execution, TLS-bypass policy consumption, and progress callback dispatch now + live in `src/legacy_cloud_services.*` instead of `App::upload` and + `App::download`; the remaining cloud bridge debt is now concentrated in + save-before-upload execution, upload form/response handling, retained + prompt/progress lifetime, OpenGL context guarding, downloaded-project open, + layer refresh, and action-history reset. - 2026-06-15: `DEBT-0038`/`DEBT-0063` were narrowed again. The cloud browser dialog in `src/legacy_cloud_services.cpp` now opens through `src/legacy_ui_overlay_services.*` and participates in the checked overlay @@ -1844,7 +1851,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0035 | Open | Modernization | Main toolbar/status command planning and execution dispatch now consume pure `pp_app_core` through `App::init_toolbar_main`, `pano_cli plan-main-toolbar`, and the `MainToolbarServices` boundary; toolbar test-message dialog metadata now lives in `pp_app_core` through `plan_main_toolbar_message_dialog`, retained message-box creation and settings-dialog opening now route through `src/legacy_ui_overlay_services.*`, history/canvas commands now hand off through `HistoryUiServices` and `DocumentCanvasClearServices`, and live execution is centralized in `src/legacy_app_shell_services.*`, but the bridge still opens legacy open/save flows, stores raw compatibility pointers, and delegates to legacy history/canvas adapters | Preserve reachable toolbar/status behavior while app shell commands move toward app/document/UI services | `pp_app_core_main_toolbar_tests`; `pano_cli plan-main-toolbar --command undo --undo-count 2`; `pano_cli plan-main-toolbar --command message-box`; `pano_cli plan-main-toolbar --command clear-canvas --no-canvas`; `ctest --preset desktop-fast --build-config Debug` | Open/save/settings/message-box routing, undo/redo/clear-history execution, and canvas-clear execution are owned by injected app/document/UI services with `App::init_toolbar_main` acting only as a UI adapter and no legacy toolbar adapter | | DEBT-0036 | Open | Modernization | `pp_renderer_api`, `pp_paint_renderer`, `pano_cli plan-paint-feedback`, and `pano_cli plan-stroke-composite` can choose backend-neutral complex paint feedback strategies for fixed-function blending, framebuffer-fetch-capable renderers, or ping-pong render targets. OpenGL extension detection now stores `pp::renderer::RenderDeviceFeatures` through `ShaderManager`, using `pp_renderer_gl::query_opengl_capability_detection`, `detect_opengl_feature_state`, and `render_device_features` as the backend conversion point; that feature snapshot now includes float32-linear filtering, so canvas stroke texture format selection, renderer diagnostics, grid lightmap render planning, and grid bake target selection no longer read `ShaderManager::ext_*` flags directly. `pp_paint_renderer::plan_canvas_blend_gate` owns the compatibility mapping from persisted layer/brush blend indices to the extracted stroke-composite planner, and live `Canvas::draw_merge` plus `NodeCanvas` panorama rendering both call it with the stored renderer-neutral feature set for their existing shader-blend gates and destination-copy versus framebuffer-fetch decisions. `pp_paint_renderer::plan_canvas_stroke_feedback` also owns the current destination-feedback decision, and live `Canvas::stroke_draw`, thumbnail layer blending, and `NodeStrokePreview` brush-preview rendering use it for framebuffer-fetch versus destination-copy decisions. Pure document-frame compositing, renderer-neutral six-face texture upload, recorded upload-command reporting, pure six-face PNG encoding, pure equirectangular PNG/JPEG+XMP encoding, and pure layer/animation-frame collection PNG encoding are now covered by `simulate-document-render`, payload-complete `plan-canvas-document-snapshot` automation, and the shared `pp_paint_renderer::prepare_document_frame_export_readiness` helper consumed by live export before retained writer fallback. The retained `copy_framebuffer_to_texture_2d` utility bridge now routes 2D framebuffer-to-texture copies through tested `pp_renderer_gl` dispatch, retained `RTT::create`/`RTT::destroy` render-target texture parameter setup, optional depth renderbuffer allocation, framebuffer allocation/attachment/status checks, binding restore, and resource deletion now route through tested `pp_renderer_gl` dispatch, retained RTT clear, masked clear with color-write-mask restore, texture bind/unbind, and RGBA8 dirty-region texture writes now route through tested `pp_renderer_gl` dispatch, retained Canvas, NodeCanvas, and NodeStrokePreview texture-unit switches now route through tested active-texture dispatch, retained Canvas, NodeCanvas, NodeStrokePreview, and desktop HMD viewport/scissor/capability execution now route through tested `pp_renderer_gl` dispatch adapters, retained NodeCanvas, CanvasMode, and NodePanelGrid capability-state snapshots now route through tested `pp_renderer_gl` query dispatch, CanvasLayer cube/equirect generation plus frame clears now share `legacy_ui_gl_dispatch` for active-texture selection, cube texture binding, viewport execution, blend capability execution, clear-color query/restore, and color-buffer clear adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, while the cube-face framebuffer-to-texture copy now uses the shared retained `copy_framebuffer_to_texture_target` utility bridge backed by tested `pp_renderer_gl` dispatch and remains tracked by DEBT-0036 until renderer services own copy execution, `NodePanelGrid` live heightmap draw and bake setup now route depth/blend state, depth clears, color-write-mask toggles, active texture selection, bake viewport execution, sun-overlay viewport query, and desktop texture-resize readback through tested `pp_renderer_gl` dispatch adapters; its active-texture, depth/blend capability query/apply, viewport query/execution, depth-clear, and color-write-mask adapter endpoints now share `legacy_ui_gl_dispatch`, retained CanvasMode overlay/mask/transform paths now route active texture, depth/blend state, transform/cut viewport execution, paint-mode blend/depth state snapshots, and canvas-tip pick framebuffer readback through tested `pp_renderer_gl` dispatch adapters; their active-texture, capability query/apply, viewport, read-framebuffer query, and RGBA8 pixel-readback adapter endpoints now share `legacy_ui_gl_dispatch`, retained simple UI draw paths now share `legacy_ui_gl_dispatch` for blend-state execution, fallback 2D texture unbinds, `NodeViewport` viewport query/restore, color-buffer clears, and clear-color restore, retained `NodeCanvas` plus `NodeStrokePreview` draw-state paths now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color queries, color-buffer clears, clear-color restore, and capability query/apply adapter endpoints backed by tested `pp_renderer_gl` dispatch helpers, retained `Canvas` stroke/object/thumbnail/export/frame-clear state endpoints now share `legacy_ui_gl_dispatch` for active-texture selection, fallback texture unbind, viewport/scissor execution, viewport and clear-color query, clear-color restore, and capability query/apply adapter endpoints, retained Canvas and RTT depth renderbuffer allocation/attachment/delete now share `legacy_gl_renderbuffer_dispatch` while renderer-resource ownership remains retained, retained `Texture2D`, `TextureCube`, and RTT texture allocation/delete/bind/parameter/update/mipmap dispatch now share `legacy_gl_texture_dispatch` while renderer-resource ownership remains retained, retained `Texture2D` readback plus RTT framebuffer allocation/delete/bind/restore/blit/readback and PBO readback dispatch now share `legacy_gl_framebuffer_dispatch` while renderer-resource ownership remains retained, retained Sampler create/parameter/border/bind dispatch shares `legacy_gl_sampler_dispatch` and retained PBO allocation/readback/map/unmap/delete dispatch shares `legacy_gl_pixel_buffer_dispatch` while renderer-resource ownership remains retained, retained `Shape`, `TextMesh`, and `NodeColorWheel` mesh buffer/VAO creation/upload/draw/delete dispatch now share `legacy_gl_mesh_dispatch` while renderer-resource ownership remains retained, retained shader source compilation/deletion, program attach/link/use/delete, attribute rebinding/location lookup, active-uniform enumeration, uniform-location discovery, and uniform writes now share `legacy_gl_shader_dispatch` while shader-program ownership remains retained, retained `gl_state` save/restore and `copy_framebuffer_to_texture_target` now reuse shared retained UI/framebuffer/shader/sampler bridge callbacks while renderer state and framebuffer-copy execution remain retained, retained app startup, app clear, app UI viewport/scissor, command-convert renderer state, and desktop VR draw-state endpoints now share `legacy_ui_gl_dispatch` while app/VR renderer execution remains retained, retained RTT clear and masked-clear endpoints now share `legacy_ui_gl_dispatch` while RTT render-target execution remains retained, retained app startup logging, Windows early context logging/window-title detection, and shader capability detection now share `legacy_gl_runtime_dispatch` while runtime/capability probing remains retained, and retained `CanvasLayer` frame-clear draw-state paths route saved clear-color query and restore through the same tested helpers, but actual live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, grid lightmap/heightmap mesh rendering, Web/incomplete-readback collection handoff, depth export writer execution, progress/threading parity, exact GPU filtering parity, and the retained `ShaderManager::ext_*` compatibility fields still use legacy OpenGL canvas/UI execution | Preserve current painting behavior while the renderer boundary matures for OpenGL parity and later Vulkan/Metal experiments | `pp_renderer_api_tests`; `pp_renderer_gl_capabilities_tests`; `pp_paint_renderer_compositor_tests`; `pano_cli plan-paint-feedback --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-paint-feedback --texture-copy`; `pano_cli plan-stroke-composite --stroke-blend 10 --framebuffer-fetch --explicit-transitions --render-only`; `pano_cli plan-stroke-composite --layer-blend 4 --dual-blend --texture-copy`; `pano_cli plan-canvas-document-snapshot --captured-face-payloads-per-layer 1`; `ctest --preset desktop-fast --build-config Debug`; `cmake --build --preset windows-msvc-default --config Debug --target PanoPainter` | Live stroke/layer/export compositing chooses its feedback path through `pp_paint_renderer` and renderer services, with OpenGL golden parity and Vulkan/Metal lab tests covering framebuffer-fetch and ping-pong behavior | | DEBT-0037 | Open | Modernization | Recording lifecycle/export planning, export progress-dialog metadata, and execution dispatch now consume pure `pp_app_core` through `App::rec_start`, `App::rec_stop`, `App::rec_clear`, `App::rec_export`, `pano_cli plan-recording-session`, and the `RecordingServices` boundary; live execution is centralized in `src/legacy_recording_services.*`, retained MP4 export progress bar creation routes through `src/legacy_app_dialog_services.*`, and retained `PBO` allocation/readback/map/unmap/delete operations now route through tested `pp_renderer_gl` dispatch, but the bridge still owns legacy recording thread startup/shutdown, platform recorded-file cleanup, progress lifetime, retained `App::rec_loop` readback call sites, and `MP4Encoder::write_mp4` execution | Preserve current timelapse/MP4 behavior while recording moves toward app/document/renderer/video services | `pp_app_core_document_recording_tests`; `pp_renderer_gl_capabilities_tests`; `pano_cli plan-recording-session --running --frame-count 12`; `pano_cli plan-recording-session --platform-deletes-recorded-files`; `ctest --preset desktop-fast --build-config Debug` | Recording thread lifecycle, frame readback scheduling, platform cleanup, progress reporting, and MP4 writing are owned by injected app/renderer/video services with `App` methods acting only as adapters | -| DEBT-0038 | Open | Modernization | Cloud upload/browse/bulk planning, cloud prompt/progress metadata, and execution dispatch now consume pure `pp_app_core` through `App::cloud_upload`, `App::cloud_upload_all`, `App::cloud_browse`, `pano_cli plan-cloud-upload`, `pano_cli plan-cloud-upload-all`, `pano_cli plan-cloud-browse`, `pano_cli plan-cloud-transfer`, and the `CloudServices` boundary; live execution is centralized in `src/legacy_cloud_services.*`, cloud-browser dialog opening now routes through `src/legacy_ui_overlay_services.*`, the app-owned `upload`/`download` CURL helpers now consume `pp_app_core` cloud transfer request/progress planning and the platform TLS-verification bypass policy before retained CURL setup, upload warning/publish/success prompts, upload/bulk progress dialog titles, download-progress prompt metadata, and formatted download progress text come from tested app-core plans, retained cloud prompt/progress creation routes through `src/legacy_app_dialog_services.*` via `App::message_box`/`App::show_progress` or direct bridge calls, and retained `Asset::open_url`, `LogRemote::net_init`, and `NodeDialogCloud::load_thumbs_thread` curl sites consume the `pp_platform_api` default TLS policy helper instead of spelling Android branches locally, but the bridge still uses legacy save-before-upload, app-owned curl helpers instead of an injected network service, upload form construction, response/error handling, retained prompt/progress lifetime, OpenGL context guarding, `NodeDialogCloud`, `Canvas` project open, layer refresh, and `ActionManager` reset | Preserve current cloud behavior while cloud/network/document import flows move toward app/document/platform services | `pp_app_core_document_cloud_tests`; `pp_platform_api_tests`; `pano_cli plan-cloud-upload --new-document --unsaved`; `pano_cli plan-cloud-browse --selected-file demo.ppi`; `pano_cli plan-cloud-upload-all --file-count 3`; `pano_cli plan-cloud-transfer --direction download --progress --disable-tls-verification`; `ctest --preset desktop-fast --build-config Debug` | Cloud upload/download, TLS policy, save-before-upload, progress reporting, cloud browse dialog, downloaded project opening, layer refresh, OpenGL context ownership, and action-history reset are owned by injected app/document/network/platform/renderer services with `App` methods acting only as adapters | +| DEBT-0038 | Open | Modernization | Cloud upload/browse/bulk planning, cloud prompt/progress metadata, and execution dispatch now consume pure `pp_app_core` through `App::cloud_upload`, `App::cloud_upload_all`, `App::cloud_browse`, `pano_cli plan-cloud-upload`, `pano_cli plan-cloud-upload-all`, `pano_cli plan-cloud-browse`, `pano_cli plan-cloud-transfer`, and the `CloudServices` boundary; live execution is centralized in `src/legacy_cloud_services.*`, cloud-browser dialog opening now routes through `src/legacy_ui_overlay_services.*`, retained upload/download CURL setup, progress callback dispatch, and TLS-verification bypass policy consumption now also live in `src/legacy_cloud_services.*` instead of `App::upload`/`App::download`, upload warning/publish/success prompts, upload/bulk progress dialog titles, download-progress prompt metadata, and formatted download progress text come from tested app-core plans, retained cloud prompt/progress creation routes through `src/legacy_app_dialog_services.*` via `App::message_box`/`App::show_progress` or direct bridge calls, and retained `Asset::open_url`, `LogRemote::net_init`, and `NodeDialogCloud::load_thumbs_thread` curl sites consume the `pp_platform_api` default TLS policy helper instead of spelling Android branches locally, but the bridge still uses legacy save-before-upload, upload form construction, response/error handling, retained prompt/progress lifetime, OpenGL context guarding, `NodeDialogCloud`, `Canvas` project open, layer refresh, and `ActionManager` reset | Preserve current cloud behavior while cloud/network/document import flows move toward app/document/platform services | `pp_app_core_document_cloud_tests`; `pp_platform_api_tests`; `pano_cli plan-cloud-upload --new-document --unsaved`; `pano_cli plan-cloud-browse --selected-file demo.ppi`; `pano_cli plan-cloud-upload-all --file-count 3`; `pano_cli plan-cloud-transfer --direction download --progress --disable-tls-verification`; `ctest --preset desktop-fast --build-config Debug` | Cloud upload/download, TLS policy, save-before-upload, progress reporting, cloud browse dialog, downloaded project opening, layer refresh, OpenGL context ownership, and action-history reset are owned by injected app/document/network/platform/renderer services with `App` methods acting only as adapters | | DEBT-0039 | Open | Modernization | Document-open planning and execution dispatch now consume pure `pp_app_core` through `App::open_document`, `pano_cli plan-open-route`, `DocumentOpenServices`, and `src/legacy_document_open_services.*`; document-open history clearing is now an explicit app-core output, but the bridge still opens ABR/PPBR import prompts before delegating import execution to `src/legacy_brush_package_import_services.*`, applies unsaved-project discard prompts, calls legacy project-open execution, refreshes layer UI, updates the app title, and executes retained history services locally | Preserve current file-open/import behavior while document loading and brush import move toward app/document/asset/UI services | `pp_app_core_document_route_tests`; `pp_app_core_document_session_tests`; `pano_cli plan-open-route --path D:/Paint/Scenes/demo.ppi --unsaved`; `pano_cli plan-open-route --path D:/Paint/Brushes/clouds.ABR --unsaved`; `ctest --preset desktop-fast --build-config Debug` | Brush import prompting, project-open execution, unsaved-project discard prompting, layer refresh, title updates, and history clearing are owned by injected app/document/asset/UI services with `App::open_document` acting only as an adapter | | DEBT-0040 | Open | Modernization | Close request, document save, save-before-workflow planning/execution dispatch, close/save-before/save-error prompt metadata, and close/save/save-before history effects now consume pure `pp_app_core` through `App::request_close`, `App::save_document`, `App::continue_document_workflow_after_optional_save`, `pano_cli simulate-app-session`, `pano_cli plan-document-session-prompt`, `DocumentSaveServices`, `CloseRequestServices`, `DocumentWorkflowServices`, and `src/legacy_document_session_services.*`; close/save-before prompt creation now uses `src/legacy_app_dialog_services.*`, Save dialog working-directory picker visibility/path formatting now dispatches through `PlatformServices`, and existing-project save/save-before-workflow execution prepares a payload-bearing canvas snapshot report before retained saving, but the bridge still opens retained save dialogs, wires prompt callbacks directly, delegates actual writing to `Canvas::project_save`, mutates the unsaved flag on close confirmation, invokes native app close, and routes save-version through the retained legacy dialog | Preserve current close/save/dirty-workflow behavior while document session execution moves toward app/document/UI/platform services | `pp_app_core_document_session_tests`; `pp_platform_api_tests`; `pano_cli plan-document-session-prompt --kind close-unsaved`; `pano_cli plan-document-session-prompt --kind save-before-workflow`; `pano_cli simulate-app-session --unsaved --save-intent save-dirty-version`; `pano_cli simulate-app-session --no-canvas`; `pano_cli plan-document-file --work-dir D:/Paint --name demo --target-exists`; `pano_cli plan-document-version --directory D:/Paint --doc-name demo.01 --existing-path D:/Paint/demo.02.ppi`; `ctest --preset desktop-fast --build-config Debug` | Close prompt execution, native close requests, dirty-workflow save prompts, existing-project saves, save dialogs, save-version execution, and unsaved-flag mutation are owned by injected app/document/UI/platform services with `App` methods acting only as adapters | | DEBT-0041 | Open | Modernization | Accepted new-document planning/execution dispatch and new-document overwrite prompt metadata now consume pure `pp_app_core` through `App::dialog_newdoc`, `pano_cli plan-new-document`, `pano_cli plan-document-session-prompt`, `NewDocumentServices`, and `src/legacy_document_session_services.*`; new-document overwrite prompt creation now uses `src/legacy_app_dialog_services.*`, and New Document dialog working-directory picker visibility/path formatting now dispatches through `PlatformServices`, but the bridge still mutates legacy app document fields, clears legacy layer UI, resizes legacy `Canvas`, clears legacy history, creates the default layer through legacy UI, mutates unsaved/new-document flags, updates the title, wires overwrite callbacks directly, and handles keyboard/dialog cleanup directly | Preserve current New Document dialog behavior while document creation moves toward app/document/UI services | `pp_app_core_document_session_tests`; `pp_platform_api_tests`; `pano_cli plan-new-document --work-dir D:/Paint --name demo --resolution-index 3`; `pano_cli plan-new-document --work-dir D:/Paint --name demo --resolution-index 3 --target-exists`; `pano_cli plan-document-session-prompt --kind new-document-overwrite`; `pano_cli simulate-app-session --save-intent save`; `ctest --preset desktop-fast --build-config Debug` | New document creation, overwrite confirmation, canvas/document allocation, default layer creation, history clearing, title updates, dirty/new-document state, and keyboard/dialog cleanup are owned by injected app/document/UI services with `App::dialog_newdoc` acting only as a UI adapter | diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 32b1afc2..637a87a0 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -82,6 +82,12 @@ The cloud browser dialog now also opens through that seam from now concentrated in retained background worker threads, transfer helpers, project-open refresh, and dialog-internal legacy behavior instead of raw root insertion. +Retained upload/download CURL setup, TLS-bypass policy consumption, and +progress callback dispatch now also live in `src/legacy_cloud_services.*` +instead of `App::upload` and `App::download`, leaving the remaining cloud debt +focused on save-before-upload execution, upload form/response handling, +prompt/progress lifetime, OpenGL context guarding, downloaded-project open, +layer refresh, and action-history reset. Recent 2026-06-13 retained preview reductions continue to narrow DEBT-0036: `NodeStrokePreview::draw_stroke_immediate()` now also routes diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index f234bd39..fe101954 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -38,7 +38,7 @@ auditable steps rather than by subjective estimates. | Renderer boundary and OpenGL parity | 15 | 11 | Live render/export/readback paths execute through renderer interfaces with parity checks. | | Platform and package parity | 10 | 8 | Required platforms have root CMake/package validation and injected platform services. | | Hardening and future backend readiness | 10 | 4 | Edge, fuzz, golden, stress, and backend-lab gates exist for high-risk paths. | -| **Total** | **100** | **66** | Only completed tasks below may change this number. | +| **Total** | **100** | **67** | Only completed tasks below may change this number. | When updating `Current`, add a dated note under "Completed Task Log" with the task id, points moved, validation command, and commit hash. @@ -370,6 +370,46 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-15 | ADP-008 | +1 legacy adapter retirement | `ctest --preset desktop-fast --build-config Debug -R "pp_ui_core_node_lifetime\|pp_ui_core_overlay_lifetime" --output-on-failure`; `MSBuild.exe out\build\windows-msvc-default\tests\pp_app_core_document_cloud_tests.vcxproj /p:Configuration=Debug /p:Platform=x64`; `D:\Dev\panopainter\out\build\windows-msvc-default\tests\Debug\pp_app_core_document_cloud_tests.exe`; `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64` | `5bf0a4f6` | +### ADP-009 - Move Cloud Transfer Helpers To Legacy Cloud Services + +Status: Done +Score: +1 legacy adapter retirement +Debt: `DEBT-0038` +Scope: `src/legacy_cloud_services.*`, `src/app.cpp`, `src/app.h`, +cloud transfer helper path only + +Goal: + +Move the retained upload/download CURL execution off `App` ownership and into +`src/legacy_cloud_services.*` so the cloud bridge owns the live transfer helper +path directly without changing prompt flow, TLS policy, progress callbacks, or +downloaded-project refresh behavior. + +Done Checks: + +- Live cloud upload/download behavior stays unchanged for the retained adapter + path. +- `App::upload` and `App::download` no longer own the retained CURL setup and + progress callback execution. +- `src/legacy_cloud_services.*` owns the retained upload/download transfer + helpers directly, and `DEBT-0038` describes the reduced remaining cloud + bridge surface. + +Validation: + +```powershell +ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure +& 'C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\MSBuild.exe' out\build\windows-msvc-default\tests\pp_app_core_document_cloud_tests.vcxproj /p:Configuration=Debug /p:Platform=x64 +& 'C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\MSBuild.exe' out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64 +.\out\build\windows-msvc-default\tests\Debug\pp_app_core_document_cloud_tests.exe +``` + +Completed Task Log: + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-15 | ADP-009 | +1 legacy adapter retirement | `ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure`; `MSBuild.exe out\build\windows-msvc-default\tests\pp_app_core_document_cloud_tests.vcxproj /p:Configuration=Debug /p:Platform=x64`; `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64`; `.\out\build\windows-msvc-default\tests\Debug\pp_app_core_document_cloud_tests.exe` | `(pending)` | + Completed Task Log: | Date | Task | Score | Validation | Commit | diff --git a/src/app.cpp b/src/app.cpp index fa6eda1e..eebcb0f2 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -226,77 +226,6 @@ void App::initLog() LOG("load preferences failed"); } -#if WITH_CURL -int progress_callback_download(void *clientp, curl_off_t dltotal, - curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) -{ - (void)ultotal; - (void)ulnow; - auto* progress = static_cast*>(clientp); - const auto plan = pp::app::plan_cloud_transfer_progress( - static_cast(dltotal), - static_cast(dlnow)); - if (progress != nullptr && *progress && plan.notify) - (*progress)(plan.fraction); - return 0; -} - -int progress_callback_upload(void *clientp, curl_off_t dltotal, - curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) -{ - (void)dltotal; - (void)dlnow; - auto* progress = static_cast*>(clientp); - const auto plan = pp::app::plan_cloud_transfer_progress( - static_cast(ultotal), - static_cast(ulnow)); - if (progress != nullptr && *progress && plan.notify) - (*progress)(plan.fraction); - return 0; -} -#endif //CURL - -void App::download(std::string url, std::string dest_filepath, std::function progress) -{ -#if WITH_CURL - const auto plan = pp::app::plan_cloud_download_transfer( - url, - dest_filepath, - progress != nullptr, - disables_network_tls_verification()); - if (plan.action != pp::app::CloudTransferAction::start_transfer) { - LOG("download skipped: invalid transfer request"); - return; - } - - CURL *curl = curl_easy_init(); - if (curl) - { - FILE* fp = fopen(dest_filepath.c_str(), "wb"); - if (fp == nullptr) { - LOG("download failed to open destination %s", dest_filepath.c_str()); - curl_easy_cleanup(curl); - return; - } - LOG("download %s to %s", url.c_str(), dest_filepath.c_str()); - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_write); - if (plan.disable_tls_verification) - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); - if (plan.enable_progress) - { - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_download); - curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - } - auto err = curl_easy_perform(curl); - curl_easy_cleanup(curl); - fclose(fp); - } -#endif //CURL -} - bool App::check_license() { return true; // TODO: for distribuiton only @@ -331,56 +260,6 @@ bool App::check_license() return false; } -void App::upload(std::string filename, std::string name, std::function progress) -{ -#if WITH_CURL - const auto plan = pp::app::plan_cloud_upload_transfer( - filename, - progress != nullptr, - disables_network_tls_verification()); - if (plan.action != pp::app::CloudTransferAction::start_transfer) { - LOG("upload skipped: invalid transfer request"); - return; - } - - CURL *curl; - - struct curl_httppost *formpost = NULL; - struct curl_httppost *lastptr = NULL; - - //curl_global_init(CURL_GLOBAL_ALL); - - curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "fileToUpload", - CURLFORM_FILE, filename.c_str(), - CURLFORM_END); - - curl = curl_easy_init(); - std::string res; - - if (curl) - { - std::string url = "https://panopainter.com/cloud/cloud-upl.php?name=" + name; - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler); - if (plan.disable_tls_verification) - curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); - if (plan.enable_progress) - { - curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_upload); - curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - } - auto err = curl_easy_perform(curl); - std::cout << "\n\nUPLOAD RESULT\n" << res << "\n\n\n"; - curl_easy_cleanup(curl); - } -#endif //CURL -} - void App::init() { LOG("Screen Resolution: %dx%d", (int)width, (int)height); diff --git a/src/app.h b/src/app.h index f078ddb7..5a196573 100644 --- a/src/app.h +++ b/src/app.h @@ -319,10 +319,6 @@ public: void cloud_upload(); void cloud_upload_all(); void cloud_browse(); - void upload(std::string filename, std::string name = "", - std::function progress = nullptr); - void download(std::string url, std::string dest_filepath, - std::function progress = nullptr); bool check_license(); std::shared_ptr show_progress(const std::string& title, int total = 0); diff --git a/src/legacy_cloud_services.cpp b/src/legacy_cloud_services.cpp index b2766588..63b8d930 100644 --- a/src/legacy_cloud_services.cpp +++ b/src/legacy_cloud_services.cpp @@ -14,6 +14,131 @@ namespace pp::panopainter { namespace { +#if WITH_CURL +int progress_callback_download(void* clientp, curl_off_t dltotal, + curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +{ + (void)ultotal; + (void)ulnow; + auto* progress = static_cast*>(clientp); + const auto plan = pp::app::plan_cloud_transfer_progress( + static_cast(dltotal), + static_cast(dlnow)); + if (progress != nullptr && *progress && plan.notify) + (*progress)(plan.fraction); + return 0; +} + +int progress_callback_upload(void* clientp, curl_off_t dltotal, + curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) +{ + (void)dltotal; + (void)dlnow; + auto* progress = static_cast*>(clientp); + const auto plan = pp::app::plan_cloud_transfer_progress( + static_cast(ultotal), + static_cast(ulnow)); + if (progress != nullptr && *progress && plan.notify) + (*progress)(plan.fraction); + return 0; +} + +void execute_cloud_download_transfer( + App& app, + std::string url, + std::string dest_filepath, + std::function progress) +{ + const auto plan = pp::app::plan_cloud_download_transfer( + url, + dest_filepath, + progress != nullptr, + app.disables_network_tls_verification()); + if (plan.action != pp::app::CloudTransferAction::start_transfer) { + LOG("download skipped: invalid transfer request"); + return; + } + + CURL* curl = curl_easy_init(); + if (curl) + { + FILE* fp = fopen(dest_filepath.c_str(), "wb"); + if (fp == nullptr) { + LOG("download failed to open destination %s", dest_filepath.c_str()); + curl_easy_cleanup(curl); + return; + } + LOG("download %s to %s", url.c_str(), dest_filepath.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_write); + if (plan.disable_tls_verification) + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + if (plan.enable_progress) + { + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_download); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + } + auto err = curl_easy_perform(curl); + curl_easy_cleanup(curl); + fclose(fp); + } +} + +void execute_cloud_upload_transfer( + App& app, + std::string filename, + std::string name, + std::function progress) +{ + const auto plan = pp::app::plan_cloud_upload_transfer( + filename, + progress != nullptr, + app.disables_network_tls_verification()); + if (plan.action != pp::app::CloudTransferAction::start_transfer) { + LOG("upload skipped: invalid transfer request"); + return; + } + + CURL* curl; + + struct curl_httppost* formpost = NULL; + struct curl_httppost* lastptr = NULL; + + //curl_global_init(CURL_GLOBAL_ALL); + + curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "fileToUpload", + CURLFORM_FILE, filename.c_str(), + CURLFORM_END); + + curl = curl_easy_init(); + std::string res; + + if (curl) + { + std::string url = "https://panopainter.com/cloud/cloud-upl.php?name=" + name; + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &res); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_data_handler); + if (plan.disable_tls_verification) + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + if (plan.enable_progress) + { + curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback_upload); + curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &progress); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + } + auto err = curl_easy_perform(curl); + std::cout << "\n\nUPLOAD RESULT\n" << res << "\n\n\n"; + curl_easy_cleanup(curl); + } +} +#endif //WITH_CURL + class LegacyCloudServices final : public pp::app::CloudServices { public: explicit LegacyCloudServices(App& app) noexcept @@ -41,7 +166,7 @@ public: const auto progress_plan = pp::app::plan_cloud_upload_progress_dialog(); auto pb = app->show_progress(progress_plan.title, progress_plan.total); - app->upload(app->doc_path, app->doc_filename, [pb](float p) { + execute_cloud_upload_transfer(*app, app->doc_path, app->doc_filename, [pb](float p) { pb->set_progress(p); }); @@ -77,7 +202,7 @@ public: for (const auto& n : names) { std::string path = app_.data_path + "/" + n; - app_.upload(path); + execute_cloud_upload_transfer(app_, path, std::string(), std::function {}); if (bulk_progress_) { bulk_progress_->increment(); @@ -116,7 +241,7 @@ public: *app, pp::app::plan_cloud_download_progress_prompt()); std::string url = "https://panopainter.com/cloud/cloud-dwl.php?file=" + request.selected_file; - app->download(url, request.selected_path, [m](float p) { + execute_cloud_download_transfer(*app, url, request.selected_path, [m](float p) { const auto progress = pp::app::format_cloud_download_progress_message(p); m->m_message->set_text(progress.c_str()); });