diff --git a/lib/pclsync/pcloudcrypto.c b/lib/pclsync/pcloudcrypto.c index ce950ab..44b8369 100644 --- a/lib/pclsync/pcloudcrypto.c +++ b/lib/pclsync/pcloudcrypto.c @@ -617,9 +617,6 @@ int psync_cloud_crypto_stop(){ debug(D_NOTICE, "stopped crypto"); psync_cloud_crypto_clean_cache(); psync_fs_refresh_crypto_folders(); -#ifdef P_OS_WINDOWS - psync_refresh_explorer_crypto_folder(); -#endif return PSYNC_CRYPTO_STOP_SUCCESS; } diff --git a/lib/pclsync/pcompression.c b/lib/pclsync/pcompression.c index f6e46da..0985ee4 100644 --- a/lib/pclsync/pcompression.c +++ b/lib/pclsync/pcompression.c @@ -30,9 +30,6 @@ */ //#include "miniz.h" -#if defined(P_OS_WINDOWS) -#define ZLIB_WINAPI -#endif #include "zlib.h" #include "plibs.h" #include "pcompression.h" diff --git a/lib/pclsync/pdevice_monitor.c b/lib/pclsync/pdevice_monitor.c index f5abac8..d2d9a81 100644 --- a/lib/pclsync/pdevice_monitor.c +++ b/lib/pclsync/pdevice_monitor.c @@ -366,273 +366,3 @@ void psync_devmon_init(){ psync_run_thread("libusb handle events completed thread", device_monitor_thread); } #endif //P_OS_LINUX - -#ifdef P_OS_WINDOWS -#define WIN32_LEAN_AND_MEAN -#define _WIN32_WINNT 0x0601 - -#include -#include -#include -#include -#include -#include -#include - -#define CLS_NAME "DUMMY_CLASS" -#define HWND_MESSAGE ((HWND)-3) -#define WM_USER_MEDIACHANGED WM_USER+88 -#define MAX_LOADSTRING 100 - -static GUID WusbGUID = { 0x88BAE032, 0x5A81, 0x49f0, 0xBC,0x3D,0xA4,0xFF,0x13,0x82,0x16,0xD6 }; -static HDEVNOTIFY hDeviceNotify; -static HWND hWnd = NULL; - -static pdevice_types dev_decode_type(STORAGE_BUS_TYPE bustype, DWORD drivetype) { - switch (bustype) { - case BusTypeScsi: - case BusTypeiScsi: - case BusTypeUsb: - case BusTypeSata: - if (drivetype == DRIVE_REMOVABLE) - return Dev_Types_UsbRemovableDisk; - else - return Dev_Types_UsbFixedDisk; - break; - case BusTypeSd: - return Dev_Types_AndroidDevice; - break; - case BusTypeMmc: - return Dev_Types_CameraDevice; - default: - return Dev_Types_Unknown; - } -} - -BOOL DoRegisterDeviceInterfaceToHwnd( - IN GUID InterfaceClassGuid, - IN HWND hWnd, - OUT HDEVNOTIFY *hDeviceNotify -) -{ - DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; - ZeroMemory(&NotificationFilter, sizeof(NotificationFilter)); - NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); - NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; //DBT_DEVTYP_DEVICEINTERFACE, DBT_DEVTYP_DEVNODE, DBT_DEVTYP_OEM, DBT_DEVTYP_VOLUME; - NotificationFilter.dbcc_classguid = InterfaceClassGuid; - *hDeviceNotify = RegisterDeviceNotification( - hWnd, // events recipient - &NotificationFilter, // type of device - DEVICE_NOTIFY_WINDOW_HANDLE|DEVICE_NOTIFY_ALL_INTERFACE_CLASSES // type of recipient handle - ); - if (NULL == *hDeviceNotify){ - debug(D_NOTICE, "RegisterDeviceNotification failed"); - return FALSE; - } - return TRUE; -} - - -static DWORD GetPhysicalDriveParams(char *strdrivepath IN, DWORD drivetype, char *fspath) -{ - DWORD dwRet = NO_ERROR; - STORAGE_PROPERTY_QUERY storagePropertyQuery; - - HANDLE hDevice = CreateFileA(strdrivepath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - - if (INVALID_HANDLE_VALUE == hDevice) { - return GetLastError(); - } - - ZeroMemory(&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY)); - storagePropertyQuery.PropertyId = StorageDeviceProperty; - storagePropertyQuery.QueryType = PropertyStandardQuery; - STORAGE_DESCRIPTOR_HEADER storageDescriptorHeader = { 0 }; - DWORD dwBytesReturned = 0; - if (!DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, - &storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY), - &storageDescriptorHeader, sizeof(STORAGE_DESCRIPTOR_HEADER), - &dwBytesReturned, NULL)){ - dwRet = GetLastError(); - CloseHandle(hDevice); - return dwRet; - } - // Alloc the output buffer - const DWORD dwOutBufferSize = storageDescriptorHeader.Size; - BYTE* pOutBuffer = (BYTE*)psync_malloc(dwOutBufferSize); - ZeroMemory(pOutBuffer, dwOutBufferSize); - // Get the storage device descriptor - if (!DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, - &storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY), - pOutBuffer, dwOutBufferSize, - &dwBytesReturned, NULL)) - { - dwRet = GetLastError(); - free(pOutBuffer); - CloseHandle(hDevice); - return dwRet; - } - STORAGE_DEVICE_DESCRIPTOR* pDeviceDescriptor = (STORAGE_DEVICE_DESCRIPTOR*)pOutBuffer; - free (pOutBuffer); - CloseHandle(hDevice); - return dwRet; -} - - -typedef struct { - DWORD dwItem1; // dwItem1 contains the previous PIDL or name of the folder. - DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder. -} SHNOTIFYSTRUCT; - -static LRESULT message_handler(HWND *hwnd, UINT uint, WPARAM wparam, LPARAM lparam) -{ - switch (uint) - { - case WM_NCCREATE: - return 1; - break; - case WM_CREATE: - return 0; - break; - case WM_DEVICECHANGE: - devmon_activity_timer_start(); - //switch (wparam) - //{ - //case DBT_DEVICEARRIVAL: - // debug(D_NOTICE, "Message %d: DBT_DEVICEARRIVAL\n"); - // break; - //case DBT_DEVICEREMOVECOMPLETE: - // debug(D_NOTICE, "Message %d: DBT_DEVICEREMOVECOMPLETE\n"); - // break; - //case DBT_DEVNODES_CHANGED: - // debug(D_NOTICE, "Message %d: DBT_DEVNODES_CHANGED\n"); - // break; - //default: - // debug(D_NOTICE, "Message %d: WM_DEVICECHANGE message received, value %d unhandled.\n"); - //break; - //} - break; - case WM_USER_MEDIACHANGED: - { - SHNOTIFYSTRUCT *shns = (SHNOTIFYSTRUCT *)wparam; - char szPath[MAX_PATH]; - ZeroMemory(&szPath, MAX_PATH); - switch (lparam) - { - case SHCNE_MEDIAINSERTED: // media inserted event - { - devmon_activity_timer_start(); - break; - } - case SHCNE_MEDIAREMOVED: // media removed event - { - SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath); - devmon_activity_timer_start(); - break; - } - case SHCNE_DRIVEADD: // media added event - { - DWORD drivetype; - HANDLE hDevice; - PSTORAGE_DEVICE_DESCRIPTOR pDevDesc; - SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath); - // "X:\" -> for GetDriveType - char szRootPath[] = "X:\\"; - szRootPath[0] = szPath[0]; - // "X:" -> for QueryDosDevice - char szDevicePath[] = "X:"; - szDevicePath[0] = szPath[0]; - // "\\.\X:" -> to open the volume - char szVolumeAccessPath[] = "\\\\.\\X:"; - szVolumeAccessPath[4] = szPath[0]; - drivetype = GetDriveTypeA(szRootPath); - switch (drivetype) - { - case 0: // The drive type cannot be determined. - debug(D_NOTICE, "The drive type cannot be determined!"); - break; - case 1: // The root directory does not exist. - debug(D_NOTICE, "The root directory does not exist!"); - break; - case DRIVE_CDROM: // The drive is a CD-ROM drive. - debug(D_NOTICE, "The drive is a CD-ROM drive."); - case DRIVE_REMOVABLE: // The drive can be removed from the drive. - case DRIVE_FIXED: // The disk cannot be removed from the drive. - case DRIVE_REMOTE: // The drive is a remote (network) drive. - devmon_activity_timer_start(); - break; - case DRIVE_RAMDISK: // The drive is a RAM disk. - break; - } - break; - } - case SHCNE_DRIVEREMOVED: // media removed event - { - DWORD drivetype; - SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath); - drivetype = GetDriveTypeA(szPath); - devmon_activity_timer_start(); - break; - } - } - break; - } - } - return 0; - -} - -void device_monitor_thread() { - WNDCLASSEXA wx; -// debug_execute(D_NOTICE, psync_add_device_monitor_callback(psync_devmon_arivalmonitor)); - HINSTANCE hExe = GetModuleHandleA(0); - ZeroMemory(&wx, sizeof(wx)); - wx.cbSize = sizeof(WNDCLASSEXA); - wx.lpfnWndProc = (WNDPROC) (message_handler); - wx.hInstance = (HINSTANCE) (hExe); - wx.style = CS_HREDRAW|CS_VREDRAW; - wx.hbrBackground = (HBRUSH)(COLOR_WINDOW); - wx.lpszClassName = CLS_NAME; - if (RegisterClassExA(&wx)){ - hWnd=CreateWindowA(CLS_NAME, L"DevNotifWnd", WS_ICONIC, 0, 0, - CW_USEDEFAULT, 0, HWND_MESSAGE, NULL, hExe, NULL); - } - if (hWnd==NULL){ - debug(D_ERROR, "Could not create message window. Error: %d", GetLastError()); - return; - } - if (!DoRegisterDeviceInterfaceToHwnd(WusbGUID, hWnd, &hDeviceNotify)){ - debug(D_ERROR, "DoRegisterDeviceInterfaceToHwnd failed. Error: %d", GetLastError()); - return; - } - //ULONG m_ulSHChangeNotifyRegister; - //LPITEMIDLIST ppidl; - //if (SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, &ppidl) == NOERROR) - //{ - // SHChangeNotifyEntry shCNE; - // shCNE.pidl = ppidl; - // shCNE.fRecursive = TRUE; - // m_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd, - // SHCNE_DISKEVENTS, - // SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_DRIVEREMOVED | SHCNE_DRIVEADD, - // WM_USER_MEDIACHANGED, - // 1, - // &shCNE); - // if (m_ulSHChangeNotifyRegister == 0) { - // debug(D_NOTICE, "Shell Device Notify registration CD failed with error %d", GetLastError()); - // return 2; - // } - //} - //else - // debug(D_NOTICE, "Shell Device Notify registration CD failed with error %d ", GetLastError()); - debug(D_NOTICE, "Device monitor - waiting for device arrival/removal"); - MSG msg; - while (GetMessage(&msg, NULL, 0, 0)){ - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} -void psync_devmon_init(){ - psync_run_thread("Device monitor main thread", device_monitor_thread); -} -#endif //P_OS_WINDOWS