PrusaSlicer-NonPlainar/src/slic3r/GUI/RemovableDriveManagerMM.mm

78 lines
2.3 KiB
Plaintext
Raw Normal View History

#import "RemovableDriveManager.hpp"
2019-12-10 10:17:12 +00:00
#import "RemovableDriveManagerMM.h"
2019-12-10 09:08:57 +00:00
#import <AppKit/AppKit.h>
@implementation RemovableDriveManagerMM
2019-12-10 10:17:12 +00:00
2019-12-10 09:08:57 +00:00
-(instancetype) init
{
2019-12-10 09:08:57 +00:00
self = [super init];
if(self)
{
2019-12-10 10:17:12 +00:00
[self add_unmount_observer];
2019-12-10 09:08:57 +00:00
}
return self;
}
-(void) on_device_unmount: (NSNotification*) notification
{
NSLog(@"on device change");
2019-12-10 10:17:12 +00:00
Slic3r::GUI::RemovableDriveManager::get_instance().update();
}
2019-12-10 09:08:57 +00:00
-(void) add_unmount_observer
{
2019-12-10 10:17:12 +00:00
NSLog(@"add unmount observer");
2019-12-10 09:08:57 +00:00
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
}
2019-12-10 10:35:39 +00:00
-(void) list_dev
{
NSLog(@"---");
NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
for (NSString* volumePath in devices)
{
NSLog(@"@", volumePath);
}
NSLog(@"--");
//removable here means CD not USB :/
NSArray* listOfMedia = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
NSLog(@"%@", listOfMedia);
for (NSString* volumePath in listOfMedia)
{
BOOL isRemovable = NO;
BOOL isWritable = NO;
BOOL isUnmountable = NO;
NSString* description = [NSString string];
NSString* type = [NSString string];
BOOL result = [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:volumePath
isRemovable:&isRemovable
isWritable:&isWritable
isUnmountable:&isUnmountable
description:&description
type:&type];
NSLog(@"Result:%i Volume: %@, Removable:%i, W:%i, Unmountable:%i, Desc:%@, type:%@", result, volumePath, isRemovable, isWritable, isUnmountable, description, type);
}
}
2019-12-10 10:17:12 +00:00
namespace Slic3r {
namespace GUI {
2019-12-10 09:08:57 +00:00
void RemovableDriveManager::register_window()
{
m_rdmmm = nullptr;
m_rdmmm = [[RemovableDriveManagerMM alloc] init];
}
2019-12-10 10:35:39 +00:00
void RemovableDriveManager::list_devices()
{
if(m_rdmmm == nullptr)
return;
[m_rdmmm list_dev];
}
2019-12-10 10:17:12 +00:00
}}//namespace Slicer::GUI
2019-12-10 09:08:57 +00:00
/*
2019-12-10 09:08:57 +00:00
*/
2019-12-10 10:17:12 +00:00
@end