1 | //␊ |
2 | // EfiInject.mm␊ |
3 | // ChameleonPrefPane␊ |
4 | //␊ |
5 | // Created by Rekursor on 1/26/10.␊ |
6 | //␊ |
7 | ␊ |
8 | #import "SmbiosController.h"␊ |
9 | ␊ |
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 | }␊ |
38 | ␊ |
39 | //--------------------------------------------------------------------------␊ |
40 | -(void) loadOptionsFromPreferencesFile: (NSMutableDictionary*) dict␊ |
41 | {␊ |
42 | ␉␊ |
43 | }␊ |
44 | - (const char *) getSmbiosFilePath␊ |
45 | {␊ |
46 | ␉static std::string path;␊ |
47 | ␉if (fileExists("/Extra/smbios.plist"))␊ |
48 | ␉␉return "/Extra/smbios.plist";␊ |
49 | ␉else if (fileExists("/smbios.plist"))␊ |
50 | ␉␉return "/smbios.plist";␊ |
51 | ␉␊ |
52 | ␉return ""; //not found␊ |
53 | }␊ |
54 | //--------------------------------------------------------------------------␊ |
55 | -(IBAction) onCheckButtonChange: (NSButton*) sender␊ |
56 | {␊ |
57 | ␉if(sender == mEditSmbios)␊ |
58 | ␉{␊ |
59 | ␉␉// IMPROVE ME find the associated editor path and call it then wait for its termination␊ |
60 | ␉␉std::string smbiosPath = [self getSmbiosFilePath ];␊ |
61 | ␉␉AuthorizationRef auth = [[self chameleon] auth ];␊ |
62 | ␉␉if (smbiosPath.length()==0 || auth==nil) return;␊ |
63 | ␉␉␊ |
64 | ␉␉// give write temporary write rights to the file␊ |
65 | //␉␉std::string args = " 0777 "+ smbiosPath;␊ |
66 | //␉␉if(!executePrivilegedCmd(auth, "/bin/chmod", args.c_str())) return;␊ |
67 | ␉␉␊ |
68 | ␉␉// edit the file␊ |
69 | ␉␉std::string cmd = "/usr/bin/open " + smbiosPath;␊ |
70 | ␉␉system(cmd.c_str());␊ |
71 | ␉␉␉ ␊ |
72 | ␉ // [ self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:cmd.c_str()] ];␊ |
73 | ␉␉␊ |
74 | ␉␉// Remove temporary write␊ |
75 | //␉␉args = " 0644 "+ smbiosPath;␊ |
76 | //␉␉if(!executePrivilegedCmd(auth, "/bin/chmod", args.c_str())) return;␊ |
77 | ␉}␊ |
78 | ␉else␊ |
79 | ␉␉[self handleSender: sender];␊ |
80 | }␊ |
81 | ␊ |
82 | //--------------------------------------------------------------------------␊ |
83 | -(IBAction) onTextFiedChange: (NSTextField*) sender␊ |
84 | {␊ |
85 | ␉[self handleSender: sender];␊ |
86 | }␊ |
87 | ␊ |
88 | + (SmbiosController *)instance { return(gInstance);}␊ |
89 | ␊ |
90 | @end␊ |
91 | |