Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/Sources/SmbiosController.mm

1//
2// EfiInject.mm
3// ChameleonPrefPane
4//
5// Created by Rekursor on 1/26/10.
6//
7
8#import "SmbiosController.h"
9
10
11static SmbiosController *gInstance = NULL;
12
13@implementation SmbiosController
14//--------------------------------------------------------------------------
15- (id) init
16{
17self = [super init];
18return (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{
46static std::string path;
47if (fileExists("/Extra/smbios.plist"))
48return "/Extra/smbios.plist";
49else if (fileExists("/smbios.plist"))
50return "/smbios.plist";
51
52return ""; //not found
53}
54//--------------------------------------------------------------------------
55-(IBAction) onCheckButtonChange: (NSButton*) sender
56{
57if(sender == mEditSmbios)
58{
59// IMPROVE ME find the associated editor path and call it then wait for its termination
60std::string smbiosPath = [self getSmbiosFilePath ];
61AuthorizationRef auth = [[self chameleon] auth ];
62if (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
69std::string cmd = "/usr/bin/open " + smbiosPath;
70system(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}
78else
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

Archive Download this file

Revision: 67