Merge branch 'dk_remote_devices'
This commit is contained in:
commit
494b7aa5f9
@ -27,7 +27,9 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
|
/* currently not used, left for possible future use
|
||||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
*/
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
m_current_drives.clear();
|
m_current_drives.clear();
|
||||||
@ -44,7 +46,7 @@ void RemovableDriveManager::search_for_drives()
|
|||||||
if (drive_type == DRIVE_REMOVABLE)
|
if (drive_type == DRIVE_REMOVABLE)
|
||||||
{
|
{
|
||||||
// get name of drive
|
// get name of drive
|
||||||
std::wstring wpath = boost::nowide::widen(path);//std::wstring(path.begin(), path.end());
|
std::wstring wpath = boost::nowide::widen(path);
|
||||||
std::wstring volume_name;
|
std::wstring volume_name;
|
||||||
volume_name.resize(1024);
|
volume_name.resize(1024);
|
||||||
std::wstring file_system_name;
|
std::wstring file_system_name;
|
||||||
@ -54,12 +56,6 @@ void RemovableDriveManager::search_for_drives()
|
|||||||
if(error != 0)
|
if(error != 0)
|
||||||
{
|
{
|
||||||
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
volume_name.erase(std::find(volume_name.begin(), volume_name.end(), '\0'), volume_name.end());
|
||||||
/*
|
|
||||||
if (volume_name == L"")
|
|
||||||
{
|
|
||||||
volume_name = L"REMOVABLE DRIVE";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (file_system_name != L"")
|
if (file_system_name != L"")
|
||||||
{
|
{
|
||||||
ULARGE_INTEGER free_space;
|
ULARGE_INTEGER free_space;
|
||||||
@ -147,6 +143,7 @@ void RemovableDriveManager::register_window()
|
|||||||
{
|
{
|
||||||
//creates new unvisible window that is recieving callbacks from system
|
//creates new unvisible window that is recieving callbacks from system
|
||||||
// structure to register
|
// structure to register
|
||||||
|
/* currently not used, left for possible future use
|
||||||
WNDCLASSEX wndClass;
|
WNDCLASSEX wndClass;
|
||||||
wndClass.cbSize = sizeof(WNDCLASSEX);
|
wndClass.cbSize = sizeof(WNDCLASSEX);
|
||||||
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||||
@ -182,13 +179,15 @@ void RemovableDriveManager::register_window()
|
|||||||
}
|
}
|
||||||
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
//ShowWindow(hWnd, SW_SHOWNORMAL);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
/* currently not used, left for possible future use
|
||||||
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// here we need to catch messeges about device removal
|
// here we need to catch messeges about device removal
|
||||||
// problem is that when ejecting usb (how is it implemented above) there is no messege dispached. Only after physical removal of the device.
|
// problem is that when ejecting usb (how is it implemented above) there is no messege dispached. Only after physical removal of the device.
|
||||||
//uncomment register_window() in init() to register and comment update() in GUI_App.cpp (only for windows!) to stop recieving periodical updates
|
//uncomment register_window() in init() to register and comment update() in GUI_App.cpp (only for windows!) to stop recieving periodical updates
|
||||||
|
|
||||||
LRESULT lRet = 1;
|
LRESULT lRet = 1;
|
||||||
static HDEVNOTIFY hDeviceNotify;
|
static HDEVNOTIFY hDeviceNotify;
|
||||||
|
|
||||||
@ -221,8 +220,9 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return lRet;
|
return lRet;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#else
|
#else
|
||||||
void RemovableDriveManager::search_for_drives()
|
void RemovableDriveManager::search_for_drives()
|
||||||
{
|
{
|
||||||
@ -370,7 +370,7 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
|
||||||
{
|
{
|
||||||
std::size_t found = path.find_last_of("/");
|
std::size_t found = path.find_last_of("/");
|
||||||
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
|
||||||
@ -440,7 +440,7 @@ bool RemovableDriveManager::update(const long time,const bool check)
|
|||||||
return !m_current_drives.empty();
|
return !m_current_drives.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
bool RemovableDriveManager::is_drive_mounted(const std::string &path) const
|
||||||
{
|
{
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -451,7 +451,7 @@ bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_path()
|
std::string RemovableDriveManager::get_drive_path()
|
||||||
{
|
{
|
||||||
if (m_current_drives.size() == 0)
|
if (m_current_drives.size() == 0)
|
||||||
{
|
{
|
||||||
@ -462,17 +462,17 @@ std::string RemovableDriveManager::get_drive_path()
|
|||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
return m_current_drives.back().path;
|
return m_current_drives.back().path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_path()
|
std::string RemovableDriveManager::get_last_save_path() const
|
||||||
{
|
{
|
||||||
if (!m_last_save_path_verified)
|
if (!m_last_save_path_verified)
|
||||||
return "";
|
return "";
|
||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_name()
|
std::string RemovableDriveManager::get_last_save_name() const
|
||||||
{
|
{
|
||||||
return m_last_save_name;
|
return m_last_save_name;
|
||||||
}
|
}
|
||||||
std::vector<DriveData> RemovableDriveManager::get_all_drives()
|
std::vector<DriveData> RemovableDriveManager::get_all_drives() const
|
||||||
{
|
{
|
||||||
return m_current_drives;
|
return m_current_drives;
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ void RemovableDriveManager::check_and_notify()
|
|||||||
{
|
{
|
||||||
m_drive_count_changed_callback(m_plater_ready_to_slice);
|
m_drive_count_changed_callback(m_plater_ready_to_slice);
|
||||||
}
|
}
|
||||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() /*&& m_last_save_path_verified */&& !is_drive_mounted(m_last_save_path))
|
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && !is_drive_mounted(m_last_save_path))
|
||||||
{
|
{
|
||||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ void RemovableDriveManager::verify_last_save_path()
|
|||||||
reset_last_save_path();
|
reset_last_save_path();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
std::string RemovableDriveManager::get_drive_name(const std::string& path) const
|
||||||
{
|
{
|
||||||
if (m_current_drives.size() == 0)
|
if (m_current_drives.size() == 0)
|
||||||
return "";
|
return "";
|
||||||
@ -546,7 +546,7 @@ std::string RemovableDriveManager::get_drive_name(const std::string& path)
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::is_last_drive_removed()
|
bool RemovableDriveManager::is_last_drive_removed()
|
||||||
{
|
{
|
||||||
if(!m_last_save_path_verified)
|
if(!m_last_save_path_verified)
|
||||||
{
|
{
|
||||||
@ -578,27 +578,27 @@ void RemovableDriveManager::set_is_writing(const bool b)
|
|||||||
m_did_eject = false;
|
m_did_eject = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::get_is_writing()
|
bool RemovableDriveManager::get_is_writing() const
|
||||||
{
|
{
|
||||||
return m_is_writing;
|
return m_is_writing;
|
||||||
}
|
}
|
||||||
bool RemovableDriveManager::get_did_eject()
|
bool RemovableDriveManager::get_did_eject() const
|
||||||
{
|
{
|
||||||
return m_did_eject;
|
return m_did_eject;
|
||||||
}
|
}
|
||||||
void RemovableDriveManager::set_did_eject(const bool b)
|
void RemovableDriveManager::set_did_eject(const bool b)
|
||||||
{
|
{
|
||||||
m_did_eject = b;
|
m_did_eject = b;
|
||||||
}
|
}
|
||||||
size_t RemovableDriveManager::get_drives_count()
|
size_t RemovableDriveManager::get_drives_count() const
|
||||||
{
|
{
|
||||||
return m_current_drives.size();
|
return m_current_drives.size();
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_ejected_path()
|
std::string RemovableDriveManager::get_ejected_path() const
|
||||||
{
|
{
|
||||||
return m_ejected_path;
|
return m_ejected_path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_ejected_name()
|
std::string RemovableDriveManager::get_ejected_name() const
|
||||||
{
|
{
|
||||||
return m_ejected_name;
|
return m_ejected_name;
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,14 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
//update() searches for removable devices, returns false if empty. /time = 0 is forced update, time expects wxGetLocalTime()
|
//update() searches for removable devices, returns false if empty. /time = 0 is forced update, time expects wxGetLocalTime()
|
||||||
bool update(const long time = 0,const bool check = false);
|
bool update(const long time = 0,const bool check = false);
|
||||||
bool is_drive_mounted(const std::string &path);
|
bool is_drive_mounted(const std::string &path) const;
|
||||||
void eject_drive(const std::string &path);
|
void eject_drive(const std::string &path);
|
||||||
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
//returns path to last drive which was used, if none was used, returns device that was enumerated last
|
||||||
std::string get_last_save_path();
|
std::string get_last_save_path() const;
|
||||||
std::string get_last_save_name();
|
std::string get_last_save_name() const;
|
||||||
//returns path to last drive which was used, if none was used, returns empty string
|
//returns path to last drive which was used, if none was used, returns empty string
|
||||||
std::string get_drive_path();
|
std::string get_drive_path();
|
||||||
std::vector<DriveData> get_all_drives();
|
std::vector<DriveData> get_all_drives() const;
|
||||||
bool is_path_on_removable_drive(const std::string &path);
|
bool is_path_on_removable_drive(const std::string &path);
|
||||||
// callback will notify only if device with last save path was removed
|
// callback will notify only if device with last save path was removed
|
||||||
void add_remove_callback(std::function<void()> callback);
|
void add_remove_callback(std::function<void()> callback);
|
||||||
@ -59,13 +59,13 @@ public:
|
|||||||
// param as update()
|
// param as update()
|
||||||
bool is_last_drive_removed_with_update(const long time = 0);
|
bool is_last_drive_removed_with_update(const long time = 0);
|
||||||
void set_is_writing(const bool b);
|
void set_is_writing(const bool b);
|
||||||
bool get_is_writing();
|
bool get_is_writing() const;
|
||||||
bool get_did_eject();
|
bool get_did_eject() const;
|
||||||
void set_did_eject(const bool b);
|
void set_did_eject(const bool b);
|
||||||
std::string get_drive_name(const std::string& path);
|
std::string get_drive_name(const std::string& path) const;
|
||||||
size_t get_drives_count();
|
size_t get_drives_count() const;
|
||||||
std::string get_ejected_path();
|
std::string get_ejected_path() const;
|
||||||
std::string get_ejected_name();
|
std::string get_ejected_name() const;
|
||||||
private:
|
private:
|
||||||
RemovableDriveManager();
|
RemovableDriveManager();
|
||||||
void search_for_drives();
|
void search_for_drives();
|
||||||
|
Loading…
Reference in New Issue
Block a user