Chameleon Applications

Chameleon Applications Svn Source Tree

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

Archive Download this file

Revision: 396