QTfrontend/NSWorkspace_RBAdditions.m
changeset 6479 4f08821cbff5
parent 3697 d5b30d6373fc
equal deleted inserted replaced
6478:752d4fb5e376 6479:4f08821cbff5
     7 //
     7 //
     8 
     8 
     9 #import "NSWorkspace_RBAdditions.h"
     9 #import "NSWorkspace_RBAdditions.h"
    10 #include <IOKit/IOKitLib.h>
    10 #include <IOKit/IOKitLib.h>
    11 #include <sys/mount.h>
    11 #include <sys/mount.h>
       
    12 #include <mach/mach.h>
    12 
    13 
    13 NSString* NSWorkspace_RBfstypename = @"NSWorkspace_RBfstypename";
    14 NSString* NSWorkspace_RBfstypename = @"NSWorkspace_RBfstypename";
    14 NSString* NSWorkspace_RBmntonname = @"NSWorkspace_RBmntonname";
    15 NSString* NSWorkspace_RBmntonname = @"NSWorkspace_RBmntonname";
    15 NSString* NSWorkspace_RBmntfromname = @"NSWorkspace_RBmntfromname";
    16 NSString* NSWorkspace_RBmntfromname = @"NSWorkspace_RBmntfromname";
    16 NSString* NSWorkspace_RBdeviceinfo = @"NSWorkspace_RBdeviceinfo";
    17 NSString* NSWorkspace_RBdeviceinfo = @"NSWorkspace_RBdeviceinfo";
    64 				partition = [props objectForKey:@"Content Mask"];
    65 				partition = [props objectForKey:@"Content Mask"];
    65 			} else if (IOObjectConformsTo(nextParent,"IOMedia")) {
    66 			} else if (IOObjectConformsTo(nextParent,"IOMedia")) {
    66 				partition = [props objectForKey:@"Content"];
    67 				partition = [props objectForKey:@"Content"];
    67 			} else if (IOObjectConformsTo(nextParent,"IODiskImageBlockStorageDeviceOutKernel")) {
    68 			} else if (IOObjectConformsTo(nextParent,"IODiskImageBlockStorageDeviceOutKernel")) {
    68 				NSData* data = nil;
    69 				NSData* data = nil;
    69 				if (data = [[props objectForKey:@"Protocol Characteristics"] objectForKey:@"Virtual Interface Location Path"]) {
    70                                 if ((data = [[props objectForKey:@"Protocol Characteristics"] objectForKey:@"Virtual Interface Location Path"])) {
    70 					image = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding] autorelease];
    71 					image = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding] autorelease];
    71 				}
    72 				}
    72 			} else if (IOObjectConformsTo(nextParent,"IOHDIXHDDriveInKernel")) {
    73 			} else if (IOObjectConformsTo(nextParent,"IOHDIXHDDriveInKernel")) {
    73 				image = [props objectForKey:@"KDIURLPath"];
    74 				image = [props objectForKey:@"KDIURLPath"];
    74 			}
    75 			}
    75 			NSDictionary* subdict;
    76 			NSDictionary* subdict;
    76 			if (subdict = [props objectForKey:@"Protocol Characteristics"]) {
    77                         if ((subdict = [props objectForKey:@"Protocol Characteristics"])) {
    77 				connection = [subdict objectForKey:@"Physical Interconnect"];
    78 				connection = [subdict objectForKey:@"Physical Interconnect"];
    78 			} else {
    79 			} else {
    79 				connection = [props objectForKey:@"Physical Interconnect"];
    80 				connection = [props objectForKey:@"Physical Interconnect"];
    80 			}
    81 			}
    81 			if (connection) {
    82 			if (connection) {
    86 			}
    87 			}
    87 			if (image) {
    88 			if (image) {
    88 				[dict setObject:image forKey:NSWorkspace_RBimagefilepath];
    89 				[dict setObject:image forKey:NSWorkspace_RBimagefilepath];
    89 			}
    90 			}
    90 			NSString* value;
    91 			NSString* value;
    91 			if (subdict = [props objectForKey:@"Device Characteristics"]) {
    92                         if ((subdict = [props objectForKey:@"Device Characteristics"])) {
    92 				if (value = [subdict objectForKey:@"Product Name"]) {
    93                                 if ((value = [subdict objectForKey:@"Product Name"])) {
    93 					result = AddPart(result,value);
    94 					result = AddPart(result,value);
    94 				}
    95 				}
    95 				if (value = [subdict objectForKey:@"Product Revision Level"]) {
    96                                 if ((value = [subdict objectForKey:@"Product Revision Level"])) {
    96 					result = AddPart(result,value);
    97 					result = AddPart(result,value);
    97 				}
    98 				}
    98 				if (value = [subdict objectForKey:@"Vendor Name"]) {
    99                                 if ((value = [subdict objectForKey:@"Vendor Name"])) {
    99 					result = AddPart(result,value);
   100 					result = AddPart(result,value);
   100 				}
   101 				}
   101 			}
   102 			}
   102 			if (value = [props objectForKey:@"USB Serial Number"]) {
   103                         if ((value = [props objectForKey:@"USB Serial Number"])) {
   103 				result = AddPart(result,value);
   104 				result = AddPart(result,value);
   104 			}
   105 			}
   105 			if (value = [props objectForKey:@"USB Vendor Name"]) {
   106                         if ((value = [props objectForKey:@"USB Vendor Name"])) {
   106 				result = AddPart(result,value);
   107 				result = AddPart(result,value);
   107 			}
   108 			}
   108 			NSString* cls = [(NSString*)IOObjectCopyClass(nextParent) autorelease];
   109 			NSString* cls = [(NSString*)IOObjectCopyClass(nextParent) autorelease];
   109 			if (![cls isEqualToString:@"IOPCIDevice"]) {
   110 			if (![cls isEqualToString:@"IOPCIDevice"]) {
   110 
   111 
   122 	return result;
   123 	return result;
   123 }
   124 }
   124 
   125 
   125 // This formats the (partially undocumented) AFPXMountInfo info into a string.
   126 // This formats the (partially undocumented) AFPXMountInfo info into a string.
   126 
   127 
       
   128 /*
   127 static NSString* FormatAFPURL(AFPXVolMountInfoPtr mountInfo,NSString** devdesc) {
   129 static NSString* FormatAFPURL(AFPXVolMountInfoPtr mountInfo,NSString** devdesc) {
   128 	UInt8* work = ((UInt8*)mountInfo)+mountInfo->serverNameOffset;
   130 	UInt8* work = ((UInt8*)mountInfo)+mountInfo->serverNameOffset;
   129 	if (devdesc) {
   131 	if (devdesc) {
   130 		*devdesc = [[[NSString alloc] initWithBytes:&work[1] length:work[0] encoding:NSUTF8StringEncoding] autorelease];
   132 		*devdesc = [[[NSString alloc] initWithBytes:&work[1] length:work[0] encoding:NSUTF8StringEncoding] autorelease];
   131 	}
   133 	}
   160 		}
   162 		}
   161 		afpta = (AFPTagData*)((char*)afpta+afpta->fLength);
   163 		afpta = (AFPTagData*)((char*)afpta+afpta->fLength);
   162 	}
   164 	}
   163 	return [NSString stringWithFormat:@"afp://%@/%@",dns?:(ip?:@""),volname];
   165 	return [NSString stringWithFormat:@"afp://%@/%@",dns?:(ip?:@""),volname];
   164 }
   166 }
       
   167 */
   165 
   168 
   166 @implementation NSWorkspace (NSWorkspace_RBAdditions)
   169 @implementation NSWorkspace (NSWorkspace_RBAdditions)
   167 
   170 
   168 // Returns a NSDictionary with properties for the path. See details in the .h file.
   171 // Returns a NSDictionary with properties for the path. See details in the .h file.
   169 // This assumes that the length of path is less than PATH_MAX (currently 1024 characters).
   172 // This assumes that the length of path is less than PATH_MAX (currently 1024 characters).