1 | //␊ |
2 | // EfiInject.mm␊ |
3 | // ChameleonPrefPane␊ |
4 | //␊ |
5 | // Created by Rekursor on 1/26/10.␊ |
6 | //␊ |
7 | ␊ |
8 | #import "SmbiosController.h"␊ |
9 | #import <ApplicationServices/ApplicationServices.h>␊ |
10 | #import "SmbiosExtractor.h"␊ |
11 | #import "PreferencesControllerBase.h"␊ |
12 | static SmbiosController *gInstance = NULL;␊ |
13 | ␊ |
14 | @implementation SmbiosController␊ |
15 | //--------------------------------------------------------------------------␊ |
16 | - (id) init␊ |
17 | {␊ |
18 | ␉self = [super init];␊ |
19 | ␉return (gInstance = self);␊ |
20 | }␉␊ |
21 | ␊ |
22 | //--------------------------------------------------------------------------␊ |
23 | - (void) addOptionsDesc␊ |
24 | {␊ |
25 | ␉// Add future smbios options here␊ |
26 | ␉// BootProp::instance().addOptionDesc(mEfiInject, mEfiInjectText, OptionString, "device-properties", "");␊ |
27 | }␊ |
28 | ␊ |
29 | //--------------------------------------------------------------------------␊ |
30 | -(void) setDefaultsValues: (NSMutableDictionary*) dict␊ |
31 | {␊ |
32 | }␊ |
33 | ␊ |
34 | //--------------------------------------------------------------------------␊ |
35 | - (void) refreshLockStates␊ |
36 | {␊ |
37 | ␉[PreferencesControllerBase refreshLockState: mEditSmbios];␊ |
38 | // [PreferencesControllerBase refreshLockState: mExtractACPITables ];␊ |
39 | }␊ |
40 | ␊ |
41 | //--------------------------------------------------------------------------␊ |
42 | -(void) loadOptionsFromPreferencesFile: (NSMutableDictionary*) dict␊ |
43 | {␊ |
44 | ␉␊ |
45 | }␊ |
46 | - (const char *) getSmbiosFilePath␊ |
47 | {␊ |
48 | ␉static std::string path;␊ |
49 | ␉path = BootProp::instance().propFilePath();␊ |
50 | ␉if (fileExists(path.c_str()))␊ |
51 | ␉␉return path.c_str();␊ |
52 | ␉if (fileExists("/Extra/smbios.plist"))␊ |
53 | ␉␉return "/Extra/smbios.plist";␊ |
54 | ␉else if (fileExists("/smbios.plist"))␊ |
55 | ␉␉return "/smbios.plist";␊ |
56 | ␉␊ |
57 | ␉return ""; //not found␊ |
58 | }␊ |
59 | ␊ |
60 | - (const char *) getAppleSmbiosFilePath␊ |
61 | {␊ |
62 | ␉SmbiosExtractor* smbe = [[[SmbiosExtractor alloc] init] autorelease];␊ |
63 | ␉NSString* path = [NSString stringWithFormat:@"%@/%@", [kChameleonUserRootDir stringByExpandingTildeInPath],kAppleSmbiosFileName];␊ |
64 | ␉[smbe save:path ];␊ |
65 | ␉return [path UTF8String];␊ |
66 | }␊ |
67 | ␊ |
68 | //--------------------------------------------------------------------------␊ |
69 | -(IBAction) onCheckButtonChange: (NSButton*) sender␊ |
70 | {␊ |
71 | ␉if(sender == mEditSmbios)␊ |
72 | ␉{␊ |
73 | ␉␉std::string smbiosPath = [self getSmbiosFilePath ];␊ |
74 | ␉␉AuthorizationRef auth = [[self chameleon] auth ];␊ |
75 | ␉␉if (smbiosPath.length()==0 || auth==nil) return;␊ |
76 | ␉␉␊ |
77 | ␉␉std::string cmd = "/usr/bin/open \"" + smbiosPath +"\"";␊ |
78 | ␉␉system(cmd.c_str());␊ |
79 | ␉␉␊ |
80 | ␉}␊ |
81 | ␉else if(sender == mAppleSmbios)␊ |
82 | ␉{␊ |
83 | ␉␉std::string smbiosPath = [self getAppleSmbiosFilePath ];␊ |
84 | ␉␉if (smbiosPath.length()==0) return;␊ |
85 | ␉␉std::string cmd = "/usr/bin/open " + smbiosPath;␊ |
86 | ␉␉system(cmd.c_str());␊ |
87 | ␉␉␊ |
88 | ␉}␊ |
89 | ␉else if(sender == mExtractACPITables)␊ |
90 | ␉{␊ |
91 | ␉␉std::string cmd = "/bin/bash ";␊ |
92 | ␉␉␊ |
93 | ␉␉std::string path = [[self getResourcePath:@"extractAcpi" ofType:@"sh"] UTF8String];␊ |
94 | ␉␉cmd += path;␊ |
95 | //␉␉[self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:path.c_str()] ];␊ |
96 | ␉␉cmd += " && /usr/bin/open ${HOME}/Desktop/Chameleon/ACPI";␊ |
97 | ␉␉system(cmd.c_str());␊ |
98 | ␉}␊ |
99 | ␉else␊ |
100 | ␉␉[self handleSender: sender];␊ |
101 | }␊ |
102 | ␊ |
103 | //--------------------------------------------------------------------------␊ |
104 | -(IBAction) onTextFiedChange: (NSTextField*) sender␊ |
105 | {␊ |
106 | ␉[self handleSender: sender];␊ |
107 | }␊ |
108 | ␊ |
109 | + (SmbiosController *)instance { return(gInstance);}␊ |
110 | ␊ |
111 | @end␊ |
112 | |