OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
RemovableDriveManagerMM Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/RemovableDriveManagerMM.h>

Inheritance diagram for RemovableDriveManagerMM:
Collaboration diagram for RemovableDriveManagerMM:

Instance Methods

(instancetype) - init
(void) - add_unmount_observer
(void) - on_device_unmount:
(NSArray *) - list_dev
(void) - eject_drive:

Detailed Description

Method Documentation

◆ add_unmount_observer

- (void) add_unmount_observer
37{
38 //NSLog(@"add unmount observer");
39 [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidUnmountNotification object:nil];
40 [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector: @selector(on_device_unmount:) name:NSWorkspaceDidMountNotification object:nil];
41}

References add_unmount_observer.

Referenced by add_unmount_observer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eject_drive:

- (void) eject_drive: (NSString *) path
98 :(NSString *)path
99{
100 NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
101 DASessionRef session = DASessionCreate(nullptr);
102 int err = 0;
103 if (session == nullptr)
104 err = EINVAL;
105 DADiskRef disk = nullptr;
106 if (err == 0)
107 disk = DADiskCreateFromVolumePath(nullptr, session, (CFURLRef)url);
108 if (err == 0)
109 //DADiskUnmount(disk, kDADiskUnmountOptionDefault, nullptr, nullptr);
110 DADiskUnmount(disk, kDADiskUnmountOptionWhole | kDADiskUnmountOptionForce, unmount_callback, nullptr);
111 if (disk != nullptr)
112 CFRelease(disk);
113 if (session != nullptr)
114 CFRelease(session);
115}
static void unmount_callback(DADiskRef disk, DADissenterRef dissenter, void *context)
Definition RemovableDriveManagerMM.mm:12

References unmount_callback().

Here is the call graph for this function:

◆ init

- (instancetype) init
24{
25 self = [super init];
26 //if(self){}
27 return self;
28}

References init.

Referenced by init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_dev

- (NSArray *) list_dev

CFEqual(deviceModelKey, CFSTR("Disk Image"));

44{
45 // DEPRICATED:
46 //NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
47 //return devices;
48
49 NSArray *mountedRemovableMedia = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:nil options:NSVolumeEnumerationSkipHiddenVolumes];
50 NSMutableArray *result = [NSMutableArray array];
51 for(NSURL *volURL in mountedRemovableMedia)
52 {
53 int err = 0;
54 DADiskRef disk;
55 CFDictionaryRef descDict = nullptr;
56 DASessionRef session = DASessionCreate(nullptr);
57 if (session == nullptr)
58 err = EINVAL;
59 if (err == 0) {
60 disk = DADiskCreateFromVolumePath(nullptr,session,(CFURLRef)volURL);
61 if (session == nullptr)
62 err = EINVAL;
63 }
64 if (err == 0) {
65 descDict = DADiskCopyDescription(disk);
66 if (descDict == nullptr)
67 err = EINVAL;
68 }
69 if (err == 0) {
70 CFTypeRef mediaEjectableKey = CFDictionaryGetValue(descDict,kDADiskDescriptionMediaEjectableKey);
71 BOOL ejectable = [(id)mediaEjectableKey boolValue];
72 CFTypeRef deviceProtocolName = CFDictionaryGetValue(descDict,kDADiskDescriptionDeviceProtocolKey);
73
74 CFTypeRef deviceModelKey = CFDictionaryGetValue(descDict, kDADiskDescriptionDeviceModelKey);
75 //debug logging
76 /*
77 if (deviceProtocolName)
78 NSLog(@"%@",(CFStringRef)deviceProtocolName);
79 if (deviceModelKey)
80 NSLog(@"-%@",(CFStringRef)deviceModelKey);
81 */
82 if (mediaEjectableKey != nullptr) {
83 BOOL op = ejectable &&
84 ( (deviceProtocolName != nullptr && (CFEqual(deviceProtocolName, CFSTR("USB")) || CFEqual(deviceProtocolName, CFSTR("Secure Digital")))) ||
85 (deviceModelKey != nullptr && CFEqual(deviceModelKey, CFSTR("SD Card Reader"))) );
87 if (op)
88 [result addObject:volURL.path];
89 }
90 }
91 if (descDict != nullptr)
92 CFRelease(descDict);
93 }
94 return result;
95}

References list_dev.

Referenced by list_dev.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_device_unmount:

- (void) on_device_unmount: (NSNotification*) notification
30 : (NSNotification*) notification
31{
32 //NSLog(@"on device change");
33 Slic3r::GUI::wxGetApp().removable_drive_manager()->update();
34}

The documentation for this class was generated from the following files: