diff --git a/apps/solidcraft/src/main.rs b/apps/solidcraft/src/main.rs
index ef5e3ad9ff2..b70c1b6b6c6 100644
--- a/apps/solidcraft/src/main.rs
+++ b/apps/solidcraft/src/main.rs
@@ -506,6 +506,7 @@ fn services(cc: &eframe::CreationContext<'_>, folder: &DialogFolder) -> Services
let chooser_ctx = cc.egui_ctx.clone();
let open_parent = parent.clone();
let program_parent = parent.clone();
+ let folder_parent = parent.clone();
let file_parent = parent.clone();
let (open_folder, file_folder, save_folder) = (folder.clone(), folder.clone(), folder.clone());
Services {
@@ -553,6 +554,10 @@ fn services(cc: &eframe::CreationContext<'_>, folder: &DialogFolder) -> Services
let future = dialog.pick_file();
Box::pin(async move { future.await.map(|p| p.path().to_string_lossy().into_owned()) })
})),
+ pick_folder: Some(Box::new(move || {
+ let future = folder_parent.clone().set_title("Choose the network folder").pick_folder();
+ Box::pin(async move { future.await.map(|p| p.path().to_string_lossy().into_owned()) })
+ })),
pick_save: Some(Box::new(move |name: &str, exts: &[&str]| {
let dialog = save_folder.start(parent.clone()).set_file_name(name);
let dialog = if exts == [io::DESIGN_EXT, "json"] {
diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt
index 07bc4681f40..6ff548b8966 100644
--- a/assets/icons/ui/design/requested_icons.txt
+++ b/assets/icons/ui/design/requested_icons.txt
@@ -164,6 +164,7 @@ mirror false
motion_link false
move false
nav_settings false
+network_folder false
new false
normal false
offset false
diff --git a/assets/icons/ui/design/svg/model/network_folder.svg b/assets/icons/ui/design/svg/model/network_folder.svg
new file mode 100644
index 00000000000..17a7d856256
--- /dev/null
+++ b/assets/icons/ui/design/svg/model/network_folder.svg
@@ -0,0 +1,8 @@
+
diff --git a/assets/locales/pending/slicer-network-folder.json b/assets/locales/pending/slicer-network-folder.json
new file mode 100644
index 00000000000..fc4e8c006ef
--- /dev/null
+++ b/assets/locales/pending/slicer-network-folder.json
@@ -0,0 +1,317 @@
+{
+ "en": {
+ "cmd.file_slicers_add_remote": "Add Network Folder",
+ "cmd.file_slicers_remove_remote": "Remove Network Folder",
+ "cmd.file_slicers_test": "Test Network Folder",
+ "ui.mesh_format_stl_binary": "STL (binary)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "Network folder…",
+ "ui.network_folder_tip": "Add a folder that a slicer on another computer reads, such as a mounted SMB or NFS share",
+ "ui.network_folder_delete_tip": "{folder}\nPress Delete to remove it from the list",
+ "ui.network_folder_title": "Add Network Folder",
+ "ui.network_folder_edit_title": "Edit Network Folder",
+ "ui.network_folder_note": "Send to Slicer copies the file into this folder and starts no program. Choose a shared folder mounted on this computer, such as an SMB or NFS share that a slicer on your server reads. A file already there is never replaced.",
+ "ui.network_folder_name": "Name",
+ "ui.network_folder_name_hint": "Orca on the server",
+ "ui.network_folder_folder": "Folder",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "Browse…",
+ "ui.network_folder_test": "Test",
+ "ui.network_folder_testing": "Writing a test file…",
+ "ui.network_folder_test_ok": "A file can be written there.",
+ "ui.network_folder_test_stopped": "The test stopped unexpectedly.",
+ "ui.network_folder_name_taken": "A network folder already has this name.",
+ "ui.network_folder_add": "Add",
+ "ui.network_folder_save": "Save",
+ "ui.network_folder_added": "Network folder {name} saved: {folder}",
+ "ui.network_folder_sending": "Copying to {target}…",
+ "ui.network_folder_still_sending": "Still copying to {target}. Nothing else was sent.",
+ "ui.sent_to_network_folder": "Sent to {target}: {path}",
+ "ui.network_folder_send_failed": "Couldn't send to {target}: {error}. The file is saved at {path}",
+ "ui.network_folders": "Network folders",
+ "ui.network_folders_none": "None yet. Add a folder that a slicer on another computer reads; it appears at the top of the Send to Slicer list.",
+ "ui.network_folder_edit": "Edit",
+ "ui.network_folder_remove": "Remove",
+ "ui.network_folder_add_button": "Add network folder…"
+ },
+ "de": {
+ "cmd.file_slicers_add_remote": "Netzwerkordner hinzufügen",
+ "cmd.file_slicers_remove_remote": "Netzwerkordner entfernen",
+ "cmd.file_slicers_test": "Netzwerkordner testen",
+ "ui.mesh_format_stl_binary": "STL (binär)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "Netzwerkordner…",
+ "ui.network_folder_tip": "Einen Ordner hinzufügen, den ein Slicer auf einem anderen Computer liest, etwa eine eingebundene SMB- oder NFS-Freigabe",
+ "ui.network_folder_delete_tip": "{folder}\nMit Entf aus der Liste entfernen",
+ "ui.network_folder_title": "Netzwerkordner hinzufügen",
+ "ui.network_folder_edit_title": "Netzwerkordner bearbeiten",
+ "ui.network_folder_note": "An Slicer senden kopiert die Datei in diesen Ordner und startet kein Programm. Wählen Sie einen auf diesem Computer eingebundenen freigegebenen Ordner, etwa eine SMB- oder NFS-Freigabe, die ein Slicer auf Ihrem Server liest. Eine vorhandene Datei wird nie ersetzt.",
+ "ui.network_folder_name": "Name",
+ "ui.network_folder_name_hint": "Orca auf dem Server",
+ "ui.network_folder_folder": "Ordner",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "Durchsuchen…",
+ "ui.network_folder_test": "Testen",
+ "ui.network_folder_testing": "Testdatei wird geschrieben…",
+ "ui.network_folder_test_ok": "Dort kann eine Datei geschrieben werden.",
+ "ui.network_folder_test_stopped": "Der Test wurde unerwartet beendet.",
+ "ui.network_folder_name_taken": "Ein Netzwerkordner mit diesem Namen existiert bereits.",
+ "ui.network_folder_add": "Hinzufügen",
+ "ui.network_folder_save": "Speichern",
+ "ui.network_folder_added": "Netzwerkordner {name} gespeichert: {folder}",
+ "ui.network_folder_sending": "Wird nach {target} kopiert…",
+ "ui.network_folder_still_sending": "Es wird noch nach {target} kopiert. Sonst wurde nichts gesendet.",
+ "ui.sent_to_network_folder": "An {target} gesendet: {path}",
+ "ui.network_folder_send_failed": "Senden an {target} nicht möglich: {error}. Die Datei ist unter {path} gespeichert",
+ "ui.network_folders": "Netzwerkordner",
+ "ui.network_folders_none": "Noch keine. Fügen Sie einen Ordner hinzu, den ein Slicer auf einem anderen Computer liest; er erscheint oben in der Liste von An Slicer senden.",
+ "ui.network_folder_edit": "Bearbeiten",
+ "ui.network_folder_remove": "Entfernen",
+ "ui.network_folder_add_button": "Netzwerkordner hinzufügen…"
+ },
+ "ar": {
+ "cmd.file_slicers_add_remote": "إضافة مجلد شبكة",
+ "cmd.file_slicers_remove_remote": "إزالة مجلد شبكة",
+ "cmd.file_slicers_test": "اختبار مجلد شبكة",
+ "ui.mesh_format_stl_binary": "STL (ثنائي)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "مجلد شبكة…",
+ "ui.network_folder_tip": "أضف مجلدًا يقرؤه برنامج تقطيع على حاسوب آخر، مثل مشاركة SMB أو NFS مركّبة",
+ "ui.network_folder_delete_tip": "{folder}\nاضغط Delete لإزالته من القائمة",
+ "ui.network_folder_title": "إضافة مجلد شبكة",
+ "ui.network_folder_edit_title": "تعديل مجلد الشبكة",
+ "ui.network_folder_note": "ينسخ «إرسال إلى برنامج التقطيع» الملف إلى هذا المجلد ولا يشغّل أي برنامج. اختر مجلدًا مشتركًا مركّبًا على هذا الحاسوب، مثل مشاركة SMB أو NFS يقرؤها برنامج تقطيع على خادمك. لا يُستبدل أي ملف موجود فيه.",
+ "ui.network_folder_name": "الاسم",
+ "ui.network_folder_name_hint": "Orca على الخادم",
+ "ui.network_folder_folder": "المجلد",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "استعراض…",
+ "ui.network_folder_test": "اختبار",
+ "ui.network_folder_testing": "جارٍ كتابة ملف اختبار…",
+ "ui.network_folder_test_ok": "يمكن كتابة ملف هناك.",
+ "ui.network_folder_test_stopped": "توقف الاختبار على نحو غير متوقع.",
+ "ui.network_folder_name_taken": "يوجد مجلد شبكة بهذا الاسم بالفعل.",
+ "ui.network_folder_add": "إضافة",
+ "ui.network_folder_save": "حفظ",
+ "ui.network_folder_added": "حُفظ مجلد الشبكة {name}: {folder}",
+ "ui.network_folder_sending": "جارٍ النسخ إلى {target}…",
+ "ui.network_folder_still_sending": "لا يزال النسخ إلى {target} جاريًا. لم يُرسل أي شيء آخر.",
+ "ui.sent_to_network_folder": "أُرسل إلى {target}: {path}",
+ "ui.network_folder_send_failed": "تعذّر الإرسال إلى {target}: {error}. الملف محفوظ في {path}",
+ "ui.network_folders": "مجلدات الشبكة",
+ "ui.network_folders_none": "لا يوجد أي مجلد بعد. أضف مجلدًا يقرؤه برنامج تقطيع على حاسوب آخر؛ وسيظهر في أعلى قائمة «إرسال إلى برنامج التقطيع».",
+ "ui.network_folder_edit": "تعديل",
+ "ui.network_folder_remove": "إزالة",
+ "ui.network_folder_add_button": "إضافة مجلد شبكة…"
+ },
+ "he": {
+ "cmd.file_slicers_add_remote": "הוספת תיקיית רשת",
+ "cmd.file_slicers_remove_remote": "הסרת תיקיית רשת",
+ "cmd.file_slicers_test": "בדיקת תיקיית רשת",
+ "ui.mesh_format_stl_binary": "STL (בינארי)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "תיקיית רשת…",
+ "ui.network_folder_tip": "הוספת תיקייה שסלייסר במחשב אחר קורא ממנה, כמו שיתוף SMB או NFS מחובר",
+ "ui.network_folder_delete_tip": "{folder}\nיש ללחוץ על Delete כדי להסיר מהרשימה",
+ "ui.network_folder_title": "הוספת תיקיית רשת",
+ "ui.network_folder_edit_title": "עריכת תיקיית רשת",
+ "ui.network_folder_note": "שליחה לסלייסר מעתיקה את הקובץ לתיקייה הזו ולא מפעילה שום תוכנה. יש לבחור תיקייה משותפת שמחוברת למחשב הזה, כמו שיתוף SMB או NFS שסלייסר בשרת קורא ממנו. קובץ שכבר נמצא שם אף פעם לא מוחלף.",
+ "ui.network_folder_name": "שם",
+ "ui.network_folder_name_hint": "Orca בשרת",
+ "ui.network_folder_folder": "תיקייה",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "עיון…",
+ "ui.network_folder_test": "בדיקה",
+ "ui.network_folder_testing": "כותב קובץ בדיקה…",
+ "ui.network_folder_test_ok": "אפשר לכתוב קובץ לשם.",
+ "ui.network_folder_test_stopped": "הבדיקה נעצרה באופן בלתי צפוי.",
+ "ui.network_folder_name_taken": "כבר קיימת תיקיית רשת בשם הזה.",
+ "ui.network_folder_add": "הוספה",
+ "ui.network_folder_save": "שמירה",
+ "ui.network_folder_added": "תיקיית הרשת {name} נשמרה: {folder}",
+ "ui.network_folder_sending": "מעתיק אל {target}…",
+ "ui.network_folder_still_sending": "עדיין מעתיק אל {target}. שום דבר נוסף לא נשלח.",
+ "ui.sent_to_network_folder": "נשלח ל־{target}: {path}",
+ "ui.network_folder_send_failed": "לא ניתן היה לשלוח ל־{target}: {error}. הקובץ שמור ב־{path}",
+ "ui.network_folders": "תיקיות רשת",
+ "ui.network_folders_none": "עדיין אין. יש להוסיף תיקייה שסלייסר במחשב אחר קורא ממנה; היא תופיע בראש הרשימה של שליחה לסלייסר.",
+ "ui.network_folder_edit": "עריכה",
+ "ui.network_folder_remove": "הסרה",
+ "ui.network_folder_add_button": "הוספת תיקיית רשת…"
+ },
+ "ja": {
+ "cmd.file_slicers_add_remote": "ネットワークフォルダーを追加",
+ "cmd.file_slicers_remove_remote": "ネットワークフォルダーを削除",
+ "cmd.file_slicers_test": "ネットワークフォルダーをテスト",
+ "ui.mesh_format_stl_binary": "STL(バイナリ)",
+ "ui.mesh_format_stl_ascii": "STL(ASCII)",
+ "ui.network_folder_row": "ネットワークフォルダー…",
+ "ui.network_folder_tip": "別のコンピューターのスライサーが読み込むフォルダー(マウントした SMB や NFS の共有など)を追加",
+ "ui.network_folder_delete_tip": "{folder}\nDelete キーでリストから削除",
+ "ui.network_folder_title": "ネットワークフォルダーを追加",
+ "ui.network_folder_edit_title": "ネットワークフォルダーを編集",
+ "ui.network_folder_note": "スライサーに送ると、ファイルをこのフォルダーにコピーします。プログラムは起動しません。このコンピューターにマウントされた共有フォルダー(サーバーのスライサーが読み込む SMB や NFS の共有など)を選んでください。既にあるファイルは置き換えません。",
+ "ui.network_folder_name": "名前",
+ "ui.network_folder_name_hint": "サーバーの Orca",
+ "ui.network_folder_folder": "フォルダー",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "参照…",
+ "ui.network_folder_test": "テスト",
+ "ui.network_folder_testing": "テストファイルを書き込んでいます…",
+ "ui.network_folder_test_ok": "このフォルダーにファイルを書き込めます。",
+ "ui.network_folder_test_stopped": "テストが予期せず停止しました。",
+ "ui.network_folder_name_taken": "この名前のネットワークフォルダーは既にあります。",
+ "ui.network_folder_add": "追加",
+ "ui.network_folder_save": "保存",
+ "ui.network_folder_added": "ネットワークフォルダー {name} を保存しました: {folder}",
+ "ui.network_folder_sending": "{target} にコピーしています…",
+ "ui.network_folder_still_sending": "まだ {target} にコピーしています。他には何も送信していません。",
+ "ui.sent_to_network_folder": "{target} に送信しました: {path}",
+ "ui.network_folder_send_failed": "{target} に送信できませんでした: {error}。ファイルは {path} に保存されています",
+ "ui.network_folders": "ネットワークフォルダー",
+ "ui.network_folders_none": "まだありません。別のコンピューターのスライサーが読み込むフォルダーを追加すると、「スライサーに送る」のリストの先頭に表示されます。",
+ "ui.network_folder_edit": "編集",
+ "ui.network_folder_remove": "削除",
+ "ui.network_folder_add_button": "ネットワークフォルダーを追加…"
+ },
+ "ko": {
+ "cmd.file_slicers_add_remote": "네트워크 폴더 추가",
+ "cmd.file_slicers_remove_remote": "네트워크 폴더 제거",
+ "cmd.file_slicers_test": "네트워크 폴더 테스트",
+ "ui.mesh_format_stl_binary": "STL(바이너리)",
+ "ui.mesh_format_stl_ascii": "STL(ASCII)",
+ "ui.network_folder_row": "네트워크 폴더…",
+ "ui.network_folder_tip": "다른 컴퓨터의 슬라이서가 읽는 폴더(마운트된 SMB 또는 NFS 공유 등)를 추가",
+ "ui.network_folder_delete_tip": "{folder}\nDelete 키로 목록에서 제거",
+ "ui.network_folder_title": "네트워크 폴더 추가",
+ "ui.network_folder_edit_title": "네트워크 폴더 편집",
+ "ui.network_folder_note": "슬라이서로 보내기는 파일을 이 폴더에 복사하며 프로그램을 시작하지 않습니다. 서버의 슬라이서가 읽는 SMB 또는 NFS 공유처럼 이 컴퓨터에 마운트된 공유 폴더를 선택하세요. 이미 있는 파일은 절대 바꾸지 않습니다.",
+ "ui.network_folder_name": "이름",
+ "ui.network_folder_name_hint": "서버의 Orca",
+ "ui.network_folder_folder": "폴더",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "찾아보기…",
+ "ui.network_folder_test": "테스트",
+ "ui.network_folder_testing": "테스트 파일을 쓰는 중…",
+ "ui.network_folder_test_ok": "이 폴더에 파일을 쓸 수 있습니다.",
+ "ui.network_folder_test_stopped": "테스트가 예기치 않게 중지되었습니다.",
+ "ui.network_folder_name_taken": "같은 이름의 네트워크 폴더가 이미 있습니다.",
+ "ui.network_folder_add": "추가",
+ "ui.network_folder_save": "저장",
+ "ui.network_folder_added": "네트워크 폴더 {name} 저장됨: {folder}",
+ "ui.network_folder_sending": "{target}(으)로 복사하는 중…",
+ "ui.network_folder_still_sending": "아직 {target}(으)로 복사하는 중입니다. 다른 것은 보내지 않았습니다.",
+ "ui.sent_to_network_folder": "{target}(으)로 보냈습니다: {path}",
+ "ui.network_folder_send_failed": "{target}(으)로 보낼 수 없습니다: {error}. 파일은 {path}에 저장되어 있습니다",
+ "ui.network_folders": "네트워크 폴더",
+ "ui.network_folders_none": "아직 없습니다. 다른 컴퓨터의 슬라이서가 읽는 폴더를 추가하면 슬라이서로 보내기 목록 맨 위에 표시됩니다.",
+ "ui.network_folder_edit": "편집",
+ "ui.network_folder_remove": "제거",
+ "ui.network_folder_add_button": "네트워크 폴더 추가…"
+ },
+ "pt-BR": {
+ "cmd.file_slicers_add_remote": "Adicionar pasta de rede",
+ "cmd.file_slicers_remove_remote": "Remover pasta de rede",
+ "cmd.file_slicers_test": "Testar pasta de rede",
+ "ui.mesh_format_stl_binary": "STL (binário)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "Pasta de rede…",
+ "ui.network_folder_tip": "Adicionar uma pasta que um fatiador em outro computador lê, como um compartilhamento SMB ou NFS montado",
+ "ui.network_folder_delete_tip": "{folder}\nPressione Delete para removê-la da lista",
+ "ui.network_folder_title": "Adicionar pasta de rede",
+ "ui.network_folder_edit_title": "Editar pasta de rede",
+ "ui.network_folder_note": "Enviar ao fatiador copia o arquivo para esta pasta e não abre nenhum programa. Escolha uma pasta compartilhada montada neste computador, como um compartilhamento SMB ou NFS que um fatiador no seu servidor lê. Um arquivo que já está lá nunca é substituído.",
+ "ui.network_folder_name": "Nome",
+ "ui.network_folder_name_hint": "Orca no servidor",
+ "ui.network_folder_folder": "Pasta",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "Procurar…",
+ "ui.network_folder_test": "Testar",
+ "ui.network_folder_testing": "Gravando um arquivo de teste…",
+ "ui.network_folder_test_ok": "Dá para gravar arquivos ali.",
+ "ui.network_folder_test_stopped": "O teste parou inesperadamente.",
+ "ui.network_folder_name_taken": "Já existe uma pasta de rede com esse nome.",
+ "ui.network_folder_add": "Adicionar",
+ "ui.network_folder_save": "Salvar",
+ "ui.network_folder_added": "Pasta de rede {name} salva: {folder}",
+ "ui.network_folder_sending": "Copiando para {target}…",
+ "ui.network_folder_still_sending": "Ainda copiando para {target}. Nada mais foi enviado.",
+ "ui.sent_to_network_folder": "Enviado para {target}: {path}",
+ "ui.network_folder_send_failed": "Não foi possível enviar para {target}: {error}. O arquivo está salvo em {path}",
+ "ui.network_folders": "Pastas de rede",
+ "ui.network_folders_none": "Nenhuma ainda. Adicione uma pasta que um fatiador em outro computador lê; ela aparece no topo da lista de Enviar ao fatiador.",
+ "ui.network_folder_edit": "Editar",
+ "ui.network_folder_remove": "Remover",
+ "ui.network_folder_add_button": "Adicionar pasta de rede…"
+ },
+ "vi": {
+ "cmd.file_slicers_add_remote": "Thêm thư mục mạng",
+ "cmd.file_slicers_remove_remote": "Xóa thư mục mạng",
+ "cmd.file_slicers_test": "Kiểm tra thư mục mạng",
+ "ui.mesh_format_stl_binary": "STL (nhị phân)",
+ "ui.mesh_format_stl_ascii": "STL (ASCII)",
+ "ui.network_folder_row": "Thư mục mạng…",
+ "ui.network_folder_tip": "Thêm một thư mục mà phần mềm cắt lớp trên máy tính khác đọc, chẳng hạn thư mục chia sẻ SMB hoặc NFS đã gắn kết",
+ "ui.network_folder_delete_tip": "{folder}\nNhấn Delete để xóa khỏi danh sách",
+ "ui.network_folder_title": "Thêm thư mục mạng",
+ "ui.network_folder_edit_title": "Sửa thư mục mạng",
+ "ui.network_folder_note": "Gửi sang phần mềm cắt lớp sẽ sao chép tệp vào thư mục này và không khởi động chương trình nào. Hãy chọn một thư mục chia sẻ đã gắn kết trên máy tính này, chẳng hạn thư mục chia sẻ SMB hoặc NFS mà phần mềm cắt lớp trên máy chủ của bạn đọc. Tệp đã có ở đó sẽ không bao giờ bị thay thế.",
+ "ui.network_folder_name": "Tên",
+ "ui.network_folder_name_hint": "Orca trên máy chủ",
+ "ui.network_folder_folder": "Thư mục",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "Duyệt…",
+ "ui.network_folder_test": "Kiểm tra",
+ "ui.network_folder_testing": "Đang ghi tệp kiểm tra…",
+ "ui.network_folder_test_ok": "Có thể ghi tệp vào đó.",
+ "ui.network_folder_test_stopped": "Quá trình kiểm tra dừng đột ngột.",
+ "ui.network_folder_name_taken": "Đã có thư mục mạng mang tên này.",
+ "ui.network_folder_add": "Thêm",
+ "ui.network_folder_save": "Lưu",
+ "ui.network_folder_added": "Đã lưu thư mục mạng {name}: {folder}",
+ "ui.network_folder_sending": "Đang sao chép sang {target}…",
+ "ui.network_folder_still_sending": "Vẫn đang sao chép sang {target}. Chưa có dữ liệu nào khác được gửi.",
+ "ui.sent_to_network_folder": "Đã gửi sang {target}: {path}",
+ "ui.network_folder_send_failed": "Không thể gửi sang {target}: {error}. Tệp đã được lưu tại {path}",
+ "ui.network_folders": "Thư mục mạng",
+ "ui.network_folders_none": "Chưa có thư mục nào. Hãy thêm một thư mục mà phần mềm cắt lớp trên máy tính khác đọc; thư mục đó sẽ xuất hiện ở đầu danh sách Gửi sang phần mềm cắt lớp.",
+ "ui.network_folder_edit": "Sửa",
+ "ui.network_folder_remove": "Xóa",
+ "ui.network_folder_add_button": "Thêm thư mục mạng…"
+ },
+ "zh": {
+ "cmd.file_slicers_add_remote": "添加网络文件夹",
+ "cmd.file_slicers_remove_remote": "移除网络文件夹",
+ "cmd.file_slicers_test": "测试网络文件夹",
+ "ui.mesh_format_stl_binary": "STL(二进制)",
+ "ui.mesh_format_stl_ascii": "STL(ASCII)",
+ "ui.network_folder_row": "网络文件夹…",
+ "ui.network_folder_tip": "添加另一台计算机上的切片软件读取的文件夹,例如已挂载的 SMB 或 NFS 共享",
+ "ui.network_folder_delete_tip": "{folder}\n按 Delete 键从列表中移除",
+ "ui.network_folder_title": "添加网络文件夹",
+ "ui.network_folder_edit_title": "编辑网络文件夹",
+ "ui.network_folder_note": "“发送到切片软件”会将文件复制到此文件夹,不会启动任何程序。请选择已挂载到本机的共享文件夹,例如服务器上的切片软件读取的 SMB 或 NFS 共享。已有的文件永远不会被替换。",
+ "ui.network_folder_name": "名称",
+ "ui.network_folder_name_hint": "服务器上的 Orca",
+ "ui.network_folder_folder": "文件夹",
+ "ui.network_folder_folder_hint": "/mnt/printer-share",
+ "ui.network_folder_browse": "浏览…",
+ "ui.network_folder_test": "测试",
+ "ui.network_folder_testing": "正在写入测试文件…",
+ "ui.network_folder_test_ok": "可以在此处写入文件。",
+ "ui.network_folder_test_stopped": "测试意外停止。",
+ "ui.network_folder_name_taken": "已有同名的网络文件夹。",
+ "ui.network_folder_add": "添加",
+ "ui.network_folder_save": "保存",
+ "ui.network_folder_added": "已保存网络文件夹 {name}:{folder}",
+ "ui.network_folder_sending": "正在复制到 {target}…",
+ "ui.network_folder_still_sending": "仍在复制到 {target}。未发送其他内容。",
+ "ui.sent_to_network_folder": "已发送到 {target}:{path}",
+ "ui.network_folder_send_failed": "无法发送到 {target}:{error}。文件已保存在 {path}",
+ "ui.network_folders": "网络文件夹",
+ "ui.network_folders_none": "暂无。添加另一台计算机上的切片软件读取的文件夹后,它会显示在“发送到切片软件”列表的顶部。",
+ "ui.network_folder_edit": "编辑",
+ "ui.network_folder_remove": "移除",
+ "ui.network_folder_add_button": "添加网络文件夹…"
+ }
+}
diff --git a/attribution/pending/slicer-network-folder.md b/attribution/pending/slicer-network-folder.md
new file mode 100644
index 00000000000..55d650ec82c
--- /dev/null
+++ b/attribution/pending/slicer-network-folder.md
@@ -0,0 +1 @@
+| assets/icons/ui/design/svg/model/network_folder.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index feda485b644..07cd8c2eb26 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -32,7 +32,7 @@ use crate::schema::new_design::{NewDesignParams, NewDesignResult};
use crate::schema::save::{SaveAsParams, SaveParams, SaveResult};
#[cfg(not(target_arch = "wasm32"))]
use crate::schema::save_mesh::{SaveMeshResult, SlicerDelivery};
-use crate::schema::slicers::{SlicerInfo, SlicersParams, SlicersResult};
+use crate::schema::slicers::{SlicerEntry, SlicerInfo, SlicersParams, SlicersResult};
use crate::schema::{TypedContract, output_schema_for};
use crate::{EngineError, Result, Session};
@@ -138,13 +138,13 @@ pub static COMMANDS: &[CommandSpec] = &[
.noundo()
.contract(&SAVE_MESH_CONTRACT)
.output(crate::schema::output_schema_for::)
- .params("path; format?: stl|3mf|3mf-tagged (default from the extension, else stl; 3mf-tagged: docs/formats/3mf-face-tags.md); bodies?: [names] (default: all); ascii?: bool (STL); slicer?: id or name from file.slicers, the program path it lists, or a program the user added under Custom… (send the saved file there, through the same steps as file.send_to_slicer: a slicer that has to be started first is waited for; may be deprecated later in favour of file.send_to_slicer or a Send to App workflow, kept for scripts); single_instance?: bool (default true; see file.send_to_slicer); quality?: standard|fine|finest (STL, OBJ and 3MF: how closely the mesh follows curved faces, a chord tolerance of 2e-4, 5e-5 or 1e-5 of each body's size; default standard); objects?: body|component (3MF only: one object per body, the default, or one object for each placed component with two or more bodies, with those bodies as its parts, so a slicer loads them as one object with parts)"),
+ .params("path; format?: stl|3mf|3mf-tagged (default from the extension, else stl; 3mf-tagged: docs/formats/3mf-face-tags.md); bodies?: [names] (default: all); ascii?: bool (STL); slicer?: id or name from file.slicers, the program path it lists, a program the user added under Custom…, or a network folder the user added (a copy of the file goes there, under the file's name, numbered rather than replacing one) (send the saved file there, through the same steps as file.send_to_slicer: a slicer that has to be started first is waited for; may be deprecated later in favour of file.send_to_slicer or a Send to App workflow, kept for scripts); single_instance?: bool (default true; see file.send_to_slicer); quality?: standard|fine|finest (STL, OBJ and 3MF: how closely the mesh follows curved faces, a chord tolerance of 2e-4, 5e-5 or 1e-5 of each body's size; default standard); objects?: body|component (3MF only: one object per body, the default, or one object for each placed component with two or more bodies, with those bodies as its parts, so a slicer loads them as one object with parts)"),
CommandSpec::new("file.send_to_slicer", "Send to Slicer", send_to_slicer)
.enabled(starts_programs)
.at("INSERT", "FILES")
.icon("mesh_export")
.noundo()
- .params("slicer: id or name from file.slicers, or a program the user added under Custom…; bodies?: [names] (default: the selected bodies); wait?: block|return|no (default block: a slicer that drops a file at a cold start is started alone and the call waits up to 10 s for it to be ready, then sends; return: start it and answer {starting}; no: send now); single_instance?: bool (default true: PrusaSlicer, SuperSlicer and Cura load the file in the window that is open); format?: 3mf|stl|3mf-tagged (default 3mf, in millimetres; STL if that can't be written) → saves the bodies in this user's slicer folder and opens the file in the slicer. The file name stays the same for the same design and bodies, so sending again replaces it (use the slicer's Reload from disk)"),
+ .params("slicer: id or name from file.slicers: a slicer found on this machine, a program the user added under Custom…, or a network folder the user added (remote:, or its name); bodies?: [names] (default: the selected bodies); wait?: block|return|no (default block: a slicer that drops a file at a cold start is started alone and the call waits up to 10 s for it to be ready, then sends; return: start it and answer {starting}; no: send now); single_instance?: bool (default true: PrusaSlicer, SuperSlicer and Cura load the file in the window that is open); format?: 3mf|stl|3mf-tagged (default 3mf, in millimetres; STL if that can't be written); ascii?: bool (STL; default binary); quality?: standard|fine|finest (how closely the mesh follows curved faces, as file.save_mesh; default standard) → saves the bodies in this user's slicer folder and opens the file in the slicer. The file name stays the same for the same design and bodies, so sending again replaces it (use the slicer's Reload from disk). A network folder starts no program: the file is copied there under the design's name (and the body's, for one body), with (2), (3)… added rather than replacing a file → remote: true, target (its name), sent_to, renamed, or slicer_error; with wait: return the copy goes on in the background and the answer has sending (a ticket) instead"),
CommandSpec::new("file.open_in_easyprint", "Open with EasyPrint", easyprint::open_in_easyprint)
.icon("mesh_export")
.noundo()
@@ -154,7 +154,7 @@ pub static COMMANDS: &[CommandSpec] = &[
.noundo()
.contract(&SLICERS_CONTRACT)
.output(output_schema_for::)
- .params("→ the slicers found on this machine: [{id, name, program, icon?}]; pass an id, a name or the program path as file.send_to_slicer's or file.save_mesh's `slicer`"),
+ .params("→ the network folders the user added, then the slicers found on this machine: [{id, name, program, icon?}] for a slicer, [{id: remote:, name, remote: true, kind: folder, folder}] for a network folder (file.slicers.add_remote); pass an id, a name or the program path as file.send_to_slicer's or file.save_mesh's `slicer`"),
];
fn new_doc(s: &mut Session, p: &Value) -> Result {
@@ -1400,8 +1400,9 @@ fn starts_programs(_: &Session) -> std::result::Result<(), String> {
if cfg!(target_arch = "wasm32") { Err("a slicer can't be started from the browser".into()) } else { Ok(()) }
}
-/// Save the bodies to this user's slicer folder and start the slicer with the file. The file
-/// name stays the same for the same design and bodies, so sending again replaces it.
+/// Save the bodies to this user's slicer folder and start the slicer with the file, or copy it to a
+/// network folder. The file name stays the same for the same design and bodies, so sending again
+/// replaces it.
fn send_to_slicer(s: &mut Session, p: &Value) -> Result {
let cmd = "file.send_to_slicer";
#[cfg(target_arch = "wasm32")]
@@ -1413,10 +1414,12 @@ fn send_to_slicer(s: &mut Session, p: &Value) -> Result {
{
let format = match str_(p, "format").map(str::to_ascii_lowercase).as_deref() {
None | Some("3mf") => Format::ThreeMf,
+ Some("stl") if bool_(p, "ascii").unwrap_or(false) => Format::StlAscii,
Some("stl") => Format::StlBinary,
Some("3mf-tagged") => Format::ThreeMfTagged,
Some(other) => return Err(bad(cmd, format!("unknown mesh format `{other}` (stl, 3mf, 3mf-tagged)"))),
};
+ let quality = mesh_quality(p, cmd)?;
let spec = str_(p, "slicer").ok_or_else(|| bad(cmd, "give `slicer` (see file.slicers)"))?;
let wait = send::Wait::parse(str_(p, "wait")).ok_or_else(|| bad(cmd, "`wait` is block, return or no"))?;
send::send(
@@ -1428,7 +1431,7 @@ fn send_to_slicer(s: &mut Session, p: &Value) -> Result {
bodies: string_list(cmd, p, "bodies")?,
parts: Vec::new(),
format,
- quality: Default::default(),
+ quality,
dest: send::Dest::Folder,
single_instance: bool_(p, "single_instance").unwrap_or(true),
wait,
@@ -1437,16 +1440,17 @@ fn send_to_slicer(s: &mut Session, p: &Value) -> Result {
}
}
-fn slicers(_: &mut Session, _: &Value) -> Result {
- let slicers = crate::slicers::detect()
- .iter()
- .map(|d| SlicerInfo {
+fn slicers(s: &mut Session, _: &Value) -> Result {
+ // The network folders first, as the Send to Slicer list shows them.
+ let mut slicers: Vec = s.network_folders.iter().map(|t| SlicerEntry::Folder(t.listing())).collect();
+ slicers.extend(crate::slicers::detect().iter().map(|d| {
+ SlicerEntry::Slicer(SlicerInfo {
id: d.id.clone(),
name: d.name.clone(),
program: d.command.first().cloned(),
icon: d.icon.as_ref().map(|i| i.path().to_string_lossy().into_owned()),
})
- .collect();
+ }));
serde_json::to_value(SlicersResult { slicers, param_warnings: Vec::new() }).map_err(|e| bad("file.slicers", e.to_string()))
}
diff --git a/crates/engine/src/cmd/file_easyprint.rs b/crates/engine/src/cmd/file_easyprint.rs
index ec9bcc959df..37009bc9bad 100644
--- a/crates/engine/src/cmd/file_easyprint.rs
+++ b/crates/engine/src/cmd/file_easyprint.rs
@@ -25,9 +25,9 @@ pub(super) struct Exported {
pub laid: super::print_face::Laid,
}
-/// Export the bodies (the selected ones when none are named), each laid on its print face. A
-/// 3MF that can't be written is written as an STL, and `fell_back` says so.
-pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Format) -> Result {
+/// Export the bodies (the selected ones when none are named), each laid on its print face and
+/// meshed at `quality`. A 3MF that can't be written is written as an STL, and `fell_back` says so.
+pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Format, quality: solidcraft_io::MeshQuality) -> Result {
let mut bodies = named.to_vec();
if bodies.is_empty() {
bodies = s.selection.iter().filter_map(|x| if let crate::Sel::Body { name } = x { Some(name.clone()) } else { None }).collect();
@@ -37,10 +37,10 @@ pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Fo
}
let mut doc = s.doc.painted(&*s.world_state()?);
let laid = super::print_face::lay_on_print_faces(s, &mut doc, &bodies, &[]);
- let write = |format| solidcraft_io::export_with_metadata(&doc, &bodies, format, &s.doc.name, &s.doc.metadata);
+ let write = |format| solidcraft_io::export_with_quality(&doc, &bodies, format, &s.doc.name, &s.doc.metadata, quality);
let mut fell_back = false;
let (bytes, ext) = match (format, write(format)) {
- (_, Ok(b)) => (b, if format == Format::StlBinary { "stl" } else { "3mf" }),
+ (_, Ok(b)) => (b, if matches!(format, Format::StlBinary | Format::StlAscii) { "stl" } else { "3mf" }),
(Format::ThreeMf, Err(_)) => {
fell_back = true;
(write(Format::StlBinary)?, "stl")
@@ -61,7 +61,7 @@ pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result {
if !bool_(p, "consent").unwrap_or(false) {
return Err(bad(cmd, "this uploads the model to Printables' servers: ask the user, then pass `consent: true`"));
}
- let Exported { bytes, ext, fell_back, laid, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format)?;
+ let Exported { bytes, ext, fell_back, laid, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format, Default::default())?;
if bytes.len() > MAX_BYTES {
let mb = bytes.len().div_ceil(1_000_000);
return Err(bad(cmd, format!("the model is {mb} MB and EasyPrint takes {} MB at most: send fewer bodies", MAX_BYTES / 1_000_000)));
diff --git a/crates/engine/src/cmd/file_remote.rs b/crates/engine/src/cmd/file_remote.rs
new file mode 100644
index 00000000000..6c9f373c8c7
--- /dev/null
+++ b/crates/engine/src/cmd/file_remote.rs
@@ -0,0 +1,105 @@
+//! Network folders for Send to Slicer (#2304): add, remove and test the folders a mesh can be
+//! sent to (`crate::remote_slicers`). They are the session's (`Session::network_folders`); the
+//! desktop app stores them in the user's preferences when these commands succeed and puts them back
+//! at the next start. Run without an app (CLI, scripts), a folder lasts as long as the session.
+
+use serde_json::{Value, json};
+
+use super::CommandSpec;
+use crate::params::{bad, str_};
+use crate::remote_slicers::{self, RemoteTarget};
+use crate::schema::file_remote::{AddRemoteParams, RemoteFolderReply, RemoveRemoteParams, RemoveRemoteReply, TestRemoteParams, TestRemoteReply};
+use crate::schema::{TypedContract, output_schema_for};
+use crate::{Result, Session};
+
+pub static COMMANDS: &[CommandSpec] = &[
+ CommandSpec::new("file.slicers.add_remote", "Add Network Folder", crate::checked!("file.slicers.add_remote", add_remote))
+ .icon("network_folder")
+ .noundo()
+ .doc_only()
+ .enabled(reaches_folders)
+ .contract(&ADD_CONTRACT)
+ .output(output_schema_for::)
+ .params("name: 1..64 characters (shown in the Send to Slicer list); folder: the folder's whole path, such as a mounted SMB or NFS share that a slicer on another computer reads → {id: remote:, name, kind: folder, folder, replaced}: adds a network folder to Send to Slicer, replacing one of the same name. Nothing is written until a mesh is sent; file.slicers.test checks the folder. The app keeps it in the user's preferences; without an app it lasts as long as the session"),
+ CommandSpec::new("file.slicers.remove_remote", "Remove Network Folder", crate::checked!("file.slicers.remove_remote", remove_remote))
+ .icon("delete")
+ .noundo()
+ .doc_only()
+ .enabled(reaches_folders)
+ .contract(&REMOVE_CONTRACT)
+ .output(output_schema_for::)
+ .params("name: a network folder's name or id (file.slicers) → {name, removed: true}; the files sent there stay"),
+ CommandSpec::new("file.slicers.test", "Test Network Folder", crate::checked!("file.slicers.test", test))
+ .icon("inspect")
+ .noundo()
+ .doc_only()
+ .enabled(reaches_folders)
+ .contract(&TEST_CONTRACT)
+ .output(output_schema_for::)
+ .params("name?: a network folder's name or id, or folder?: a folder's whole path (one of the two) → {ok, folder, name?, error?}: writes a small file in the folder and deletes it again, giving up after 30 s; error says what went wrong (not there, no permission, full, no answer)"),
+];
+
+const ADD_CONTRACT: TypedContract = TypedContract::new();
+const REMOVE_CONTRACT: TypedContract = TypedContract::new();
+const TEST_CONTRACT: TypedContract = TypedContract::new();
+
+/// The browser build has no folders to write to.
+fn reaches_folders(_: &Session) -> std::result::Result<(), String> {
+ if cfg!(target_arch = "wasm32") { Err("network folders can't be reached from the browser".into()) } else { Ok(()) }
+}
+
+/// A folder an agent's commands may use: one in the folders it was allowed (`--allow-path`). The
+/// app's own calls have no such limit.
+fn allowed(cmd: &str, folder: &str) -> Result<()> {
+ solidcraft_io::vfs::check(folder).map_err(|e| bad(cmd, e.to_string()))
+}
+
+fn add_remote(s: &mut Session, p: &Value) -> Result {
+ let cmd = "file.slicers.add_remote";
+ reaches_folders(s).map_err(|e| bad(cmd, e))?;
+ let name = remote_slicers::check_name(str_(p, "name").unwrap_or_default()).map_err(|e| bad(cmd, e))?;
+ let folder = remote_slicers::check_folder(str_(p, "folder").unwrap_or_default()).map_err(|e| bad(cmd, e))?;
+ allowed(cmd, folder)?;
+ let target = RemoteTarget::folder_target(name, folder);
+ let replaced = remote_slicers::add(&mut s.network_folders, target.clone()).map_err(|e| bad(cmd, e))?;
+ Ok(json!({"id": target.id(), "name": target.name, "kind": target.kind(), "folder": target.folder(), "replaced": replaced}))
+}
+
+fn remove_remote(s: &mut Session, p: &Value) -> Result {
+ let cmd = "file.slicers.remove_remote";
+ reaches_folders(s).map_err(|e| bad(cmd, e))?;
+ let spec = str_(p, "name").filter(|n| !n.trim().is_empty()).ok_or_else(|| bad(cmd, "give `name` (see file.slicers)"))?;
+ let gone =
+ remote_slicers::remove(&mut s.network_folders, spec).ok_or_else(|| bad(cmd, format!("no network folder `{spec}` (see file.slicers)")))?;
+ Ok(json!({"name": gone.name, "removed": true}))
+}
+
+fn test(s: &mut Session, p: &Value) -> Result {
+ let cmd = "file.slicers.test";
+ reaches_folders(s).map_err(|e| bad(cmd, e))?;
+ let (name, folder) = match (str_(p, "name"), str_(p, "folder")) {
+ (Some(spec), None) => {
+ let target = remote_slicers::resolve(&s.network_folders, spec)
+ .ok_or_else(|| bad(cmd, format!("no network folder `{spec}` (see file.slicers)")))?;
+ if let Some(folder) = target.on_this_computer() {
+ allowed(cmd, folder)?;
+ }
+ (Some(target.name.clone()), target.folder().to_string())
+ }
+ (None, Some(folder)) => {
+ let folder = remote_slicers::check_folder(folder).map_err(|e| bad(cmd, e))?;
+ allowed(cmd, folder)?;
+ (None, folder.to_string())
+ }
+ _ => return Err(bad(cmd, "give `name` or `folder`, one of the two")),
+ };
+ let mut out = json!({"ok": true, "folder": folder});
+ if let Some(name) = name {
+ out["name"] = json!(name);
+ }
+ if let Err(e) = remote_slicers::probe(&folder) {
+ out["ok"] = json!(false);
+ out["error"] = json!(e);
+ }
+ Ok(out)
+}
diff --git a/crates/engine/src/cmd/file_send.rs b/crates/engine/src/cmd/file_send.rs
index 01b2a4b69f3..1939c738a01 100644
--- a/crates/engine/src/cmd/file_send.rs
+++ b/crates/engine/src/cmd/file_send.rs
@@ -6,6 +6,10 @@
//!
//! It takes a [`TargetKind`], and slicers are the only kind there is; a later Send to App would add
//! one (see `slicers::TargetKind`) and send through this same function.
+//!
+//! A network folder the user added (`crate::remote_slicers`, #2304) is a target too: the file is
+//! written as for any slicer, then copied into the folder under the design's (and body's) name,
+//! numbered rather than replacing a file there, and no program is started.
use serde_json::{Value, json};
use solidcraft_io::Format;
@@ -13,6 +17,7 @@ use solidcraft_io::Format;
use super::easyprint::{Exported, export_bodies};
use super::export_laid_to;
use crate::params::bad;
+use crate::remote_slicers::{self, RemoteTarget};
use crate::schema::save_mesh::SlicerDelivery;
use crate::slicers::{self, Slicer, TargetKind};
use crate::{EngineError, Result, Session};
@@ -57,7 +62,7 @@ pub(super) struct Send<'a> {
/// 3MF objects with parts (`objects: "component"`, #8139). Only for [`Dest::Path`].
pub parts: Vec<(String, Vec)>,
pub format: Format,
- /// Only for [`Dest::Path`]; the slicer folder's file is always standard.
+ /// How closely the mesh follows curved faces.
pub quality: solidcraft_io::MeshQuality,
pub dest: Dest<'a>,
pub single_instance: bool,
@@ -75,6 +80,13 @@ fn format_name(f: Format) -> &'static str {
/// Send the bodies to the target named by `r.spec`.
pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result {
// The target is found before anything is written, so a name that matches nothing writes nothing.
+ // A network folder's name comes first: the user gave it, so a script naming it means it.
+ if let Some(folder) = remote_slicers::resolve(&s.network_folders, r.spec).cloned() {
+ return send_to_folder(s, &r, &folder);
+ }
+ if remote_slicers::is_id(r.spec) {
+ return Err(bad(r.cmd, format!("no network folder `{}` (see file.slicers)", r.spec)));
+ }
let target = slicers::resolve_for(r.kind, r.spec).ok_or_else(|| {
bad(r.cmd, format!("no slicer `{}` (see file.slicers; a program works only once the user has added it under Custom…)", r.spec))
})?;
@@ -83,23 +95,77 @@ pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result {
}
let mut out = match r.dest {
Dest::Path(path) => export_laid_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?,
- Dest::Folder => write_in_folder(s, &r)?,
+ Dest::Folder => write_in_folder(s, &r)?.0,
};
let path = out.get("path").and_then(Value::as_str).unwrap_or_default().to_string();
deliver(&target, &path, r.single_instance, r.wait, &mut out);
Ok(out)
}
-/// Write the bodies into the slicer folder.
-fn write_in_folder(s: &mut Session, r: &Send<'_>) -> Result {
+/// Send the bodies to a network folder: write the file as for a slicer, then copy it into the
+/// folder. The name there is the design's (and the body's, for one body) for the slicer folder, and
+/// the file's own name for a path the caller gave.
+fn send_to_folder(s: &mut Session, r: &Send<'_>, folder: &RemoteTarget) -> Result {
+ // An agent limited to folders (`--allow-path`) sends only into one it was allowed, checked
+ // here, before anything is written or a copy starts in the background.
+ if let Some(dir) = folder.on_this_computer() {
+ solidcraft_io::vfs::check(dir).map_err(|e| bad(r.cmd, e.to_string()))?;
+ }
+ let (mut out, stem) = match r.dest {
+ Dest::Path(path) => {
+ let out = export_laid_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?;
+ let stem = std::path::Path::new(path).file_stem().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default();
+ (out, remote_slicers::safe_stem(&stem))
+ }
+ Dest::Folder => write_in_folder(s, r)?,
+ };
+ let path = out.get("path").and_then(Value::as_str).unwrap_or_default().to_string();
+ let ext = std::path::Path::new(&path)
+ .extension()
+ .map(|e| e.to_string_lossy().to_ascii_lowercase())
+ .filter(|e| !e.is_empty())
+ .unwrap_or_else(|| if matches!(r.format, Format::StlBinary | Format::StlAscii) { "stl".into() } else { "3mf".into() });
+ deliver_to_folder(folder, &path, &stem, &ext, r.wait == Wait::Return, &mut out);
+ Ok(out)
+}
+
+/// Copy the file at `path` into a network folder and say what happened in `out`: `slicer` (the
+/// folder's name), `sent_to` and `renamed` when it went, `slicer_error` when it didn't; `remote` either way.
+/// In the background, the answer is `sending`: the ticket to ask `remote_slicers::poll` about.
+fn deliver_to_folder(folder: &RemoteTarget, path: &str, stem: &str, ext: &str, background: bool, out: &mut Value) {
+ let Some(obj) = out.as_object_mut() else { return };
+ let at = SlicerDelivery { remote: true, target: Some(folder.name.clone()), ..Default::default() };
+ let delivery = if background {
+ SlicerDelivery { sending: Some(remote_slicers::deliver_in_background(folder, std::path::Path::new(path), stem, ext)), ..at }
+ } else {
+ // The file is saved either way; a folder that can't be written is reported, not fatal.
+ match remote_slicers::deliver(folder, std::path::Path::new(path), stem, ext) {
+ Ok(sent) => SlicerDelivery {
+ slicer: Some(folder.name.clone()),
+ sent_to: Some(sent.path.to_string_lossy().into_owned()),
+ renamed: Some(sent.numbered),
+ ..at
+ },
+ Err(e) => SlicerDelivery { slicer_error: Some(format!("couldn't send to {}: {e}; the file is saved at {path}", folder.name)), ..at },
+ }
+ };
+ // What happened, as the typed value the reply's schema describes.
+ if let Ok(Value::Object(keys)) = serde_json::to_value(delivery) {
+ obj.extend(keys);
+ }
+}
+
+/// Write the bodies into the slicer folder; the reply, and the readable name for a network folder.
+fn write_in_folder(s: &mut Session, r: &Send<'_>) -> Result<(Value, String)> {
use crate::slicer_files;
- let Exported { bytes, ext, fell_back, bodies, laid } = export_bodies(s, r.cmd, &r.bodies, r.format)?;
+ let Exported { bytes, ext, fell_back, bodies, laid } = export_bodies(s, r.cmd, &r.bodies, r.format, r.quality)?;
+ let readable = remote_slicers::readable_stem(&s.doc.name, &bodies);
let dir = slicer_files::dir().ok_or_else(|| bad(r.cmd, "no per-user folder on this system"))?;
let stem = slicer_files::stem(&s.doc.name, s.path.as_deref(), s.uid, &bodies);
let (file, numbered) = slicer_files::write(&dir, &stem, ext, &bytes).map_err(|e| EngineError::Other(format!("{}: {e}", dir.display())))?;
let mut out = json!({"path": file.to_string_lossy(), "bytes": bytes.len(), "format": ext, "numbered": numbered, "stl_fallback": fell_back});
laid.report(&mut out);
- Ok(out)
+ Ok((out, readable))
}
/// Hand the file at `path` to `target`, starting it first if it has to be, and say what happened in
diff --git a/crates/engine/src/cmd/mod.rs b/crates/engine/src/cmd/mod.rs
index 6e6385c838b..a16bf1123cd 100644
--- a/crates/engine/src/cmd/mod.rs
+++ b/crates/engine/src/cmd/mod.rs
@@ -70,6 +70,7 @@ pub use component_link::resolve_design_links;
mod config;
mod design_link;
mod file;
+mod file_remote;
mod frame;
mod frame_end_cap;
pub(crate) mod inspect;
@@ -370,6 +371,7 @@ pub fn command_specs() -> Vec<&'static CommandSpec> {
v.extend(parameters::COMMANDS.iter());
v.extend(parameter_sweep::COMMANDS.iter());
v.extend(file::COMMANDS.iter());
+ v.extend(file_remote::COMMANDS.iter());
v.extend(print_face::COMMANDS.iter());
v.extend(metadata::COMMANDS.iter());
v.extend(inspect::COMMANDS.iter());
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index b073b42e509..dcd5d456a1b 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -26,6 +26,7 @@ pub mod panels;
pub mod params;
pub mod product_scene;
pub mod recovery;
+pub mod remote_slicers;
pub mod render_jobs;
pub mod render_lights;
pub mod render_preparation;
@@ -530,6 +531,9 @@ pub struct Session {
/// How the host uploads a model to EasyPrint (`file.open_in_easyprint`); `None`: it can't. It
/// belongs to the session like `param_check`, so it survives opening and starting designs.
pub easyprint_upload: Option,
+ /// Send to Slicer's network folders (#2304): the user's, which the app keeps in its preferences.
+ /// They belong to the session like `param_check`, so they survive opening and starting designs.
+ pub network_folders: Vec,
/// After a live frame: its sketch, the document it left and the revision. Its links were
/// brought up to date by that frame, so the gesture's next frame needn't project them again
/// while nothing else has run (#3222).
@@ -835,6 +839,7 @@ impl Session {
project_construction: false,
param_check: schema::ParamCheck::Off,
easyprint_upload: None,
+ network_folders: Vec::new(),
live_links: None,
active_component: 0,
active_occurrence_path: None,
@@ -901,6 +906,7 @@ impl Session {
let single_surface_analysis = self.single_surface_analysis;
let param_check = self.param_check;
let easyprint_upload = self.easyprint_upload.take();
+ let network_folders = std::mem::take(&mut self.network_folders);
let render_viewport = self.render_viewport.clone();
let render_jobs = self.render_jobs.scratch();
let checkpoints = std::mem::take(&mut self.checkpoints);
@@ -921,6 +927,7 @@ impl Session {
self.set_single_surface_analysis(single_surface_analysis);
self.param_check = param_check;
self.easyprint_upload = easyprint_upload;
+ self.network_folders = network_folders;
self.render_viewport = render_viewport;
self.render_jobs = render_jobs;
self.checkpoints = checkpoints;
@@ -1977,6 +1984,7 @@ impl Session {
project_construction: self.project_construction,
param_check: self.param_check,
easyprint_upload: self.easyprint_upload.clone(),
+ network_folders: self.network_folders.clone(),
live_links: None,
active_component: self.active_component,
active_occurrence_path: self.active_occurrence_path.clone(),
diff --git a/crates/engine/src/remote_slicers.rs b/crates/engine/src/remote_slicers.rs
new file mode 100644
index 00000000000..f2b71a089f0
--- /dev/null
+++ b/crates/engine/src/remote_slicers.rs
@@ -0,0 +1,685 @@
+//! Network folders for Send to Slicer (#2304): a folder the user picked once, usually a mounted
+//! SMB or NFS share that a slicer on another computer reads (OrcaSlicer in a container on a home
+//! server, say). Sending to one copies the mesh there under a name a person can read, never
+//! replacing a file that is already there, and starts no program.
+//!
+//! The list belongs to the session (`Session::network_folders`), like the parameter checks: the
+//! application keeps it in the user's preferences and puts it there, the
+//! `file.slicers.add_remote` and `file.slicers.remove_remote` commands change it, and the
+//! application stores the result. Run without an app (CLI, scripts), a folder lasts as long as
+//! the session. Nothing here scans the network or talks to it: the operating system
+//! does the share, and SolidCraft writes files.
+
+#[cfg(not(target_arch = "wasm32"))]
+use std::io::{self, ErrorKind};
+use std::path::{Path, PathBuf};
+use std::time::Duration;
+
+use serde::{Deserialize, Serialize};
+
+/// Most network folders kept.
+pub const MAX_TARGETS: usize = 32;
+/// Most characters in a network folder's name.
+pub const MAX_NAME: usize = 64;
+/// Most bytes in a folder's path.
+pub const MAX_FOLDER: usize = 4096;
+/// Largest file copied to a network folder.
+pub const MAX_BYTES: u64 = 1 << 30;
+/// Longest a copy to a network folder may take before the command answers without it: a share
+/// whose server has gone can keep a file call waiting for minutes.
+pub const TIME_LIMIT: Duration = Duration::from_secs(30);
+/// Most numbered names (`Part (2).3mf`, …) tried before giving up.
+#[cfg(not(target_arch = "wasm32"))]
+const MAX_NUMBERED: u32 = 999;
+/// Most characters of a file name taken from the design and body names.
+const MAX_STEM: usize = 80;
+/// At most this many bytes of a readable name: with ` (999)` and an extension it stays within
+/// the 255 bytes a file name may have, in any language.
+const MAX_STEM_BYTES: usize = 200;
+/// What a network folder's id starts with in `file.slicers`.
+pub const ID_PREFIX: &str = "remote:";
+
+/// A network folder a mesh can be sent to.
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
+pub struct RemoteTarget {
+ /// The name the user gave it, shown in the slicer list.
+ pub name: String,
+ /// Where the file goes.
+ #[serde(flatten)]
+ pub dest: Dest,
+}
+
+/// Where a network folder's files go.
+#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
+#[serde(tag = "kind", rename_all = "lowercase")]
+pub enum Dest {
+ /// A folder on this computer, usually a mounted share.
+ Folder { folder: String },
+}
+
+impl RemoteTarget {
+ /// A folder target.
+ pub fn folder_target(name: &str, folder: &str) -> RemoteTarget {
+ RemoteTarget { name: name.to_string(), dest: Dest::Folder { folder: folder.to_string() } }
+ }
+
+ /// Its id in `file.slicers`: `remote:`.
+ pub fn id(&self) -> String {
+ format!("{ID_PREFIX}{}", self.name)
+ }
+
+ /// The kind, as `file.slicers` names it.
+ pub fn kind(&self) -> &'static str {
+ match self.dest {
+ Dest::Folder { .. } => "folder",
+ }
+ }
+
+ /// The folder the files go to.
+ pub fn folder(&self) -> &str {
+ match &self.dest {
+ Dest::Folder { folder } => folder,
+ }
+ }
+
+ /// Its entry in `file.slicers`.
+ pub fn listing(&self) -> crate::schema::slicers::NetworkFolderInfo {
+ crate::schema::slicers::NetworkFolderInfo {
+ id: self.id(),
+ name: self.name.clone(),
+ remote: true,
+ kind: self.kind().to_string(),
+ folder: self.folder().to_string(),
+ }
+ }
+
+ /// The folder on this computer the files go to: what an agent limited to folders
+ /// (`--allow-path`) must be allowed before sending there or testing it.
+ pub fn on_this_computer(&self) -> Option<&str> {
+ match &self.dest {
+ Dest::Folder { folder } => Some(folder),
+ }
+ }
+}
+
+/// A network folder's name as given: trimmed, 1 to [`MAX_NAME`] characters, no control characters.
+pub fn check_name(name: &str) -> Result<&str, String> {
+ let name = name.trim();
+ if name.is_empty() {
+ Err("give the network folder a name".into())
+ } else if name.chars().count() > MAX_NAME {
+ Err(format!("a network folder's name has {MAX_NAME} characters at most"))
+ } else if name.chars().any(char::is_control) {
+ Err("a network folder's name can't hold control characters".into())
+ } else {
+ Ok(name)
+ }
+}
+
+/// A folder's path as given: trimmed, whole (absolute), at most [`MAX_FOLDER`] bytes, no control
+/// characters. Whether it is there is not looked at: a share may be mounted later.
+pub fn check_folder(folder: &str) -> Result<&str, String> {
+ let folder = folder.trim();
+ if folder.is_empty() {
+ Err("give the folder".into())
+ } else if folder.len() > MAX_FOLDER {
+ Err(format!("a folder's path has {MAX_FOLDER} bytes at most"))
+ } else if folder.chars().any(char::is_control) {
+ Err("a folder's path can't hold control characters".into())
+ } else if !Path::new(folder).is_absolute() {
+ Err(format!("{folder}: give the folder's whole path"))
+ } else {
+ Ok(folder)
+ }
+}
+
+fn same_name(a: &str, b: &str) -> bool {
+ a.trim().to_lowercase() == b.trim().to_lowercase()
+}
+
+/// The network folders of `list` the commands may use (the application's preferences, which a
+/// person can edit): one that is not valid, or repeats a name, is left out, and so is any past
+/// [`MAX_TARGETS`].
+pub fn sanitized(list: &[RemoteTarget]) -> Vec {
+ let mut kept: Vec = Vec::new();
+ for t in list {
+ let (Ok(name), Ok(folder)) = (check_name(&t.name), check_folder(t.folder())) else { continue };
+ if kept.len() < MAX_TARGETS && !kept.iter().any(|k| same_name(&k.name, name)) {
+ kept.push(RemoteTarget::folder_target(name, folder));
+ }
+ }
+ kept
+}
+
+/// Add a network folder to `list`, replacing the one of the same name (true when it did).
+pub fn add(list: &mut Vec, target: RemoteTarget) -> Result {
+ if let Some(old) = list.iter_mut().find(|t| same_name(&t.name, &target.name)) {
+ *old = target;
+ return Ok(true);
+ }
+ if list.len() >= MAX_TARGETS {
+ return Err(format!("there are {MAX_TARGETS} network folders already: remove one first"));
+ }
+ list.push(target);
+ Ok(false)
+}
+
+/// Remove the network folder `spec` names (its name or id) from `list`; the one removed.
+pub fn remove(list: &mut Vec, spec: &str) -> Option {
+ let name = spec.trim().strip_prefix(ID_PREFIX).unwrap_or(spec);
+ let at = list.iter().position(|t| same_name(&t.name, name))?;
+ Some(list.remove(at))
+}
+
+/// The network folder of `list` that `spec` names: its id (`remote:`) or its name, in any case.
+pub fn resolve<'a>(list: &'a [RemoteTarget], spec: &str) -> Option<&'a RemoteTarget> {
+ let name = spec.trim().strip_prefix(ID_PREFIX).unwrap_or(spec);
+ list.iter().find(|t| same_name(&t.name, name))
+}
+
+/// Whether `spec` is written as a network folder's id, so it names nothing else.
+pub fn is_id(spec: &str) -> bool {
+ spec.trim().starts_with(ID_PREFIX)
+}
+
+/// A file name (no extension) a person can read for `bodies` of a design: the design's name, and
+/// the body's after it when one body other than the design's namesake is sent.
+pub fn readable_stem(design: &str, bodies: &[String]) -> String {
+ let design = design.trim();
+ let name = match bodies {
+ [one] if !one.trim().is_empty() && one.trim() != design => {
+ if design.is_empty() {
+ one.trim().to_string()
+ } else {
+ format!("{design} - {}", one.trim())
+ }
+ }
+ _ => design.to_string(),
+ };
+ safe_stem(&name)
+}
+
+/// `name` as a file name every system takes: the characters Windows and SMB refuse and control
+/// characters become `_`, leading and trailing dots and spaces go (no hidden files), at most
+/// [`MAX_STEM`] characters, `design` when nothing is left, and an `_` after a Windows device name.
+pub fn safe_stem(name: &str) -> String {
+ let mut bytes = 0;
+ let cleaned: String = name
+ .chars()
+ .take(MAX_STEM)
+ .map(|c| if c.is_control() || "<>:\"/\\|?*".contains(c) { '_' } else { c })
+ .take_while(|c| {
+ bytes += c.len_utf8();
+ bytes <= MAX_STEM_BYTES
+ })
+ .collect();
+ let stem = cleaned.trim_matches(|c: char| c == '.' || c.is_whitespace());
+ let stem = if stem.is_empty() { "design" } else { stem };
+ let device = stem.split('.').next().unwrap_or_default().trim().to_ascii_uppercase();
+ let numbered_device = (device.starts_with("COM") || device.starts_with("LPT"))
+ && device.len() == 4
+ && device.as_bytes().get(3).is_some_and(|b| (b'1'..=b'9').contains(b));
+ if matches!(device.as_str(), "CON" | "PRN" | "AUX" | "NUL") || numbered_device { format!("{stem}_") } else { stem.to_string() }
+}
+
+/// `.` for the first name, then ` (2).` and so on.
+#[cfg(not(target_arch = "wasm32"))]
+fn numbered(stem: &str, ext: &str, n: u32) -> String {
+ if n <= 1 { format!("{stem}.{ext}") } else { format!("{stem} ({n}).{ext}") }
+}
+
+/// Where a file went.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Delivered {
+ pub path: PathBuf,
+ /// A file of the first name was there, so a number was added.
+ pub numbered: bool,
+}
+
+/// Copy the file at `src` into the network folder as `.` (numbered when that name is
+/// taken), within [`copy_limit`] and [`MAX_BYTES`]. The error says what went wrong in words.
+pub fn deliver(target: &RemoteTarget, src: &Path, stem: &str, ext: &str) -> Result {
+ let size = std::fs::metadata(src).map(|m| m.len()).unwrap_or_default();
+ deliver_within(Path::new(target.folder()), src, stem, ext, max_bytes(), copy_limit(size))
+}
+
+/// The slowest a share may copy, in bytes a second, before it is given up on.
+pub const MIN_RATE: u64 = 64 * 1024;
+
+/// How long copying `size` bytes may take: [`TIME_LIMIT`] for a share that doesn't answer, and
+/// more for a large file, at [`MIN_RATE`]. A large mesh on a slow share was reported as failed
+/// while it still arrived, and sending it again left a second copy.
+pub fn copy_limit(size: u64) -> Duration {
+ TIME_LIMIT.saturating_add(Duration::from_secs(size / MIN_RATE))
+}
+
+/// The size cap of [`deliver`]; tests of the commands make it small.
+fn max_bytes() -> u64 {
+ #[cfg(test)]
+ if let Some(made_up) = *TEST_MAX_BYTES.lock().unwrap_or_else(std::sync::PoisonError::into_inner) {
+ return made_up;
+ }
+ MAX_BYTES
+}
+
+/// Tests of the commands set the size cap to one they made up.
+#[cfg(test)]
+pub(crate) static TEST_MAX_BYTES: std::sync::Mutex