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#import <ApplicationServices/ApplicationServices.h>
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 // [PreferencesControllerBase refreshLockState: mExtractACPITables ];
38}
39
40//--------------------------------------------------------------------------
41-(void) loadOptionsFromPreferencesFile: (NSMutableDictionary*) dict
42{
43
44}
45- (const char *) getSmbiosFilePath
46{
47static std::string path;
48if (fileExists("/Extra/smbios.plist"))
49return "/Extra/smbios.plist";
50else if (fileExists("/smbios.plist"))
51return "/smbios.plist";
52
53return ""; //not found
54}
55//--------------------------------------------------------------------------
56-(IBAction) onCheckButtonChange: (NSButton*) sender
57{
58if(sender == mEditSmbios)
59{
60// IMPROVE ME find the associated editor path and call it then wait for its termination
61std::string smbiosPath = [self getSmbiosFilePath ];
62AuthorizationRef auth = [[self chameleon] auth ];
63if (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
70std::string cmd = "/usr/bin/open " + smbiosPath;
71system(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}
79else if(sender == mExtractACPITables)
80{
81std::string cmd = "/bin/bash ";
82
83std::string path = [[self getResourcePath:@"extractAcpi" ofType:@"sh"] UTF8String];
84cmd += path;
85//[self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:path.c_str()] ];
86cmd += " && /usr/bin/open ${HOME}/Desktop/ACPI";
87system(cmd.c_str());
88}
89else
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

Archive Download this file

Revision: 106