1 /* Copyright (c) Mark Harmstone 2017 2 * 3 * This file is part of WinBtrfs. 4 * 5 * WinBtrfs is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public Licence as published by 7 * the Free Software Foundation, either version 3 of the Licence, or 8 * (at your option) any later version. 9 * 10 * WinBtrfs is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public Licence for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public Licence 16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */ 17 18 #pragma once 19 20 #include <shlobj.h> 21 #ifndef __REACTOS__ 22 #include "../btrfs.h" 23 #else 24 #include "btrfs.h" 25 #endif 26 27 extern LONG objs_loaded; 28 29 typedef struct { 30 BTRFS_UUID uuid; 31 uint64_t transid; 32 wstring path; 33 } subvol_cache; 34 35 class BtrfsRecv { 36 public: 37 BtrfsRecv() { 38 thread = nullptr; 39 master = INVALID_HANDLE_VALUE; 40 dir = INVALID_HANDLE_VALUE; 41 running = false; 42 cancelling = false; 43 stransid = 0; 44 num_received = 0; 45 hwnd = nullptr; 46 cache.clear(); 47 } 48 49 virtual ~BtrfsRecv() { 50 cache.clear(); 51 } 52 53 void Open(HWND hwnd, const wstring& file, const wstring& path, bool quiet); 54 DWORD recv_thread(); 55 INT_PTR CALLBACK RecvProgressDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 56 57 private: 58 void cmd_subvol(HWND hwnd, btrfs_send_command* cmd, uint8_t* data, const win_handle& parent); 59 void cmd_snapshot(HWND hwnd, btrfs_send_command* cmd, uint8_t* data, const win_handle& parent); 60 void cmd_mkfile(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 61 void cmd_rename(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 62 void cmd_link(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 63 void cmd_unlink(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 64 void cmd_rmdir(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 65 void cmd_setxattr(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 66 void cmd_removexattr(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 67 void cmd_write(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 68 void cmd_clone(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 69 void cmd_truncate(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 70 void cmd_chmod(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 71 void cmd_chown(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 72 void cmd_utimes(HWND hwnd, btrfs_send_command* cmd, uint8_t* data); 73 void add_cache_entry(BTRFS_UUID* uuid, uint64_t transid, const wstring& path); 74 bool find_tlv(uint8_t* data, ULONG datalen, uint16_t type, void** value, ULONG* len); 75 void do_recv(const win_handle& f, uint64_t* pos, uint64_t size, const win_handle& parent); 76 77 HANDLE dir, master, thread, lastwritefile; 78 HWND hwnd; 79 wstring streamfile, dirpath, subvolpath, lastwritepath; 80 DWORD lastwriteatt; 81 ULONG num_received; 82 uint64_t stransid; 83 BTRFS_UUID subvol_uuid; 84 bool running, cancelling; 85 vector<subvol_cache> cache; 86 }; 87