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 | ␊ |
11 | static SmbiosController *gInstance = NULL;␊ |
12 | ␊ |
13 | @implementation SmbiosController␊ |
14 | //--------------------------------------------------------------------------␊ |
15 | - (id) init␊ |
16 | {␊ |
17 | ␉self = [super init];␊ |
18 | ␉return (gInstance = self);␊ |
19 | }␉␊ |
20 | ␊ |
21 | //--------------------------------------------------------------------------␊ |
22 | - (void) addOptionsDesc␊ |
23 | {␊ |
24 | ␉// Add future smbios options here␊ |
25 | ␉// BootProp::instance().addOptionDesc(mEfiInject, mEfiInjectText, OptionString, "device-properties", "");␊ |
26 | }␊ |
27 | ␊ |
28 | //--------------------------------------------------------------------------␊ |
29 | -(void) setDefaultsValues: (NSMutableDictionary*) dict␊ |
30 | {␊ |
31 | }␊ |
32 | ␊ |
33 | //--------------------------------------------------------------------------␊ |
34 | - (void) refreshLockStates␊ |
35 | {␊ |
36 | ␉[PreferencesControllerBase refreshLockState: mEditSmbios];␊ |
37 | // [PreferencesControllerBase refreshLockState: mExtractACPITables ];␊ |
38 | }␊ |
39 | ␊ |
40 | //--------------------------------------------------------------------------␊ |
41 | -(void) loadOptionsFromPreferencesFile: (NSMutableDictionary*) dict␊ |
42 | {␊ |
43 | ␉␊ |
44 | }␊ |
45 | - (const char *) getSmbiosFilePath␊ |
46 | {␊ |
47 | ␉static std::string path;␊ |
48 | ␉if (fileExists("/Extra/smbios.plist"))␊ |
49 | ␉␉return "/Extra/smbios.plist";␊ |
50 | ␉else if (fileExists("/smbios.plist"))␊ |
51 | ␉␉return "/smbios.plist";␊ |
52 | ␉␊ |
53 | ␉return ""; //not found␊ |
54 | }␊ |
55 | //--------------------------------------------------------------------------␊ |
56 | -(IBAction) onCheckButtonChange: (NSButton*) sender␊ |
57 | {␊ |
58 | ␉if(sender == mEditSmbios)␊ |
59 | ␉{␊ |
60 | ␉␉// IMPROVE ME find the associated editor path and call it then wait for its termination␊ |
61 | ␉␉std::string smbiosPath = [self getSmbiosFilePath ];␊ |
62 | ␉␉AuthorizationRef auth = [[self chameleon] auth ];␊ |
63 | ␉␉if (smbiosPath.length()==0 || auth==nil) return;␊ |
64 | ␉␉␊ |
65 | ␉␉// give write temporary write rights to the file␊ |
66 | ␉␉//␉␉std::string args = " 0777 "+ smbiosPath;␊ |
67 | ␉␉//␉␉if(!executePrivilegedCmd(auth, "/bin/chmod", args.c_str())) return;␊ |
68 | ␉␉␊ |
69 | ␉␉// edit the file␊ |
70 | ␉␉std::string cmd = "/usr/bin/open " + smbiosPath;␊ |
71 | ␉␉system(cmd.c_str());␊ |
72 | ␉␉␊ |
73 | ␉ // [ self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:cmd.c_str()] ];␊ |
74 | ␉␉␊ |
75 | ␉␉// Remove temporary write␊ |
76 | ␉␉//␉␉args = " 0644 "+ smbiosPath;␊ |
77 | ␉␉//␉␉if(!executePrivilegedCmd(auth, "/bin/chmod", args.c_str())) return;␊ |
78 | ␉}␊ |
79 | ␉else if(sender == mExtractACPITables)␊ |
80 | ␉{␊ |
81 | ␉␉std::string cmd = "/bin/bash ";␊ |
82 | ␉␉␊ |
83 | ␉␉std::string path = [[self getResourcePath:@"extractAcpi" ofType:@"sh"] UTF8String];␊ |
84 | ␉␉cmd += path;␊ |
85 | //␉␉[self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:path.c_str()] ];␊ |
86 | ␉␉cmd += " && /usr/bin/open ${HOME}/Desktop/ACPI";␊ |
87 | ␉␉system(cmd.c_str());␊ |
88 | ␉}␊ |
89 | ␉else␊ |
90 | ␉␉[self handleSender: sender];␊ |
91 | }␊ |
92 | ␊ |
93 | //--------------------------------------------------------------------------␊ |
94 | -(IBAction) onTextFiedChange: (NSTextField*) sender␊ |
95 | {␊ |
96 | ␉[self handleSender: sender];␊ |
97 | }␊ |
98 | ␊ |
99 | + (SmbiosController *)instance { return(gInstance);}␊ |
100 | ␊ |
101 | @end␊ |
102 | |