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#import "SmbiosExtractor.h"
11#import "PreferencesControllerBase.h"
12static SmbiosController *gInstance = NULL;
13
14@implementation SmbiosController
15//--------------------------------------------------------------------------
16- (id) init
17{
18self = [super init];
19return (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{
48static std::string path;
49path = BootProp::instance().propFilePath();
50if (fileExists(path.c_str()))
51{
52path = string_dir_from(path) + "smbios.plist";
53if (fileExists(path.c_str()))
54return path.c_str();
55}
56
57if (fileExists("/Extra/smbios.plist"))
58return "/Extra/smbios.plist";
59else if (fileExists("/smbios.plist"))
60return "/smbios.plist";
61
62return ""; //not found
63}
64
65- (const char *) getAppleSmbiosFilePath
66{
67SmbiosExtractor* smbe = [[[SmbiosExtractor alloc] init] autorelease];
68NSString* path = [NSString stringWithFormat:@"%@/%@", [kChameleonUserRootDir stringByExpandingTildeInPath],kAppleSmbiosFileName];
69[smbe save:path ];
70return [path UTF8String];
71}
72
73//--------------------------------------------------------------------------
74-(IBAction) onCheckButtonChange: (NSButton*) sender
75{
76if(sender == mEditSmbios)
77{
78std::string smbiosPath = [self getSmbiosFilePath ];
79AuthorizationRef auth = [[self chameleon] auth ];
80if (smbiosPath.length()==0 || auth==nil) return;
81
82std::string cmd = "/usr/bin/open \"" + smbiosPath +"\"";
83system(cmd.c_str());
84
85}
86else if(sender == mAppleSmbios)
87{
88std::string smbiosPath = [self getAppleSmbiosFilePath ];
89if (smbiosPath.length()==0) return;
90std::string cmd = "/usr/bin/open " + smbiosPath;
91system(cmd.c_str());
92
93}
94else if(sender == mExtractACPITables)
95{
96std::string cmd = "/bin/bash ";
97
98std::string path = [[self getResourcePath:@"extractAcpi" ofType:@"sh"] UTF8String];
99cmd += path;
100//[self executeTaskAndWaitForTermination: [[NSString alloc] initWithUTF8String:path.c_str()] ];
101cmd += " && /usr/bin/open ${HOME}/Desktop/Chameleon/ACPI";
102system(cmd.c_str());
103}
104else
105[self handleSender: sender];
106}
107
108//--------------------------------------------------------------------------
109-(IBAction) onTextFiedChange: (NSTextField*) sender
110{
111[self handleSender: sender];
112}
113
114+ (SmbiosController *)instance { return(gInstance);}
115
116@end
117

Archive Download this file

Revision: 447