Chameleon Applications

Chameleon Applications Commit Details

Date:2011-12-11 22:11:53 (6 years 2 days ago)
Author:Rekursor
Commit:460
Parents: 459
Message:Implemented Chameleon boot version tooltip new feature
Changes:
M/trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj
M/trunk/ChameleonPrefPane/Sources/TableViewsController.mm
M/trunk/ChameleonPrefPane/bin/OSX106/Chameleon.zip
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
M/trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm
M/trunk/ChameleonPrefPane/Sources/ShellProcess.cpp
M/trunk/ChameleonPrefPane/bin/version
M/trunk/ChameleonPrefPane/Sources/ShellProcess.h
M/trunk/ChameleonPrefPane/test_util/test_util.mm

File differences

trunk/ChameleonPrefPane/Sources/ShellProcess.cpp
1010
1111
1212
13
14
1315
1416
1517
......
2527
2628
2729
30
31
32
33
34
35
36
37
38
39
2840
2941
3042
#include <sys/stat.h>
#include "string_util.h"
#define MAX_LINESIZE 4096
//----------------------------------------------------------------
// portable open process:
FILE * ShellProcess::open(const char *cmd, const char *mode) {
}
//----------------------------------------------------------------
std::string ShellProcess::get_line(const char * matching)
{
char buffer[MAX_LINESIZE];
char* res = get_line(buffer, MAX_LINESIZE-1, matching);
std::string result = res ? res : "";
return result;
}
//----------------------------------------------------------------
char * ShellProcess::get_line(char * line, size_t s, const char *matching)
{
if (_fpt==NULL || line==NULL) return NULL;
trunk/ChameleonPrefPane/Sources/TableViewsController.mm
142142
143143
144144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
145164
146165
147166
}
//--------------------------------------------------------------------------
- (NSString *)tableView:
(NSTableView *) tv
toolTipForCell:(NSCell *)aCell
rect:(NSRectPointer)rect
tableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)row
mouseLocation:(NSPoint)mouseLocation
{
if (row<0) return nil;
if (tv == mPartitionsTable)
{
PartitionInfoElement* partInfo = [PartsInfoMgr objectAtIndex: row];
return [partInfo bootDescription];
}
return nil;
}
//--------------------------------------------------------------------------
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.h
1010
1111
1212
13
14
1315
1416
1517
16
1718
1819
1920
......
2829
2930
3031
32
3133
3234
3335
......
5254
5355
5456
57
58
5559
5660
5761
@interface PartitionInfoElement : NSObject {
NSString* bsdName;
NSString*vUUID, *vName, *vPath, *vKind, *mediaPath, *devProtocol;
NSString*vAliasName; // for rename partition purpose
NSString*bootInfo; // for displaying partition info
booldevInternal, mediaRemovable;
NSDictionary*descDict;
NSString*vAliasName; // for rename partition purpose
boolhidden; // for hide partition purpose
interr; // non zero if problem occurred during info extraction
intdiskNum, partNum;
@property (retain) NSString* vPath;
@property (retain) NSString* mediaPath;
@property (retain) NSString* devProtocol;
@property (retain) NSString* bootInfo;
@property (assign) bool devInternal;
@property (assign) bool mediaRemovable;
// Get any DA attribute from dict
-(NSString*) stringValueWithKey: (NSString*) key;
// Get the boot information string, for chameleon only for now ...
-(NSString*) bootDescription;
-(int) diskNumber;
-(int) partitionNumber;
trunk/ChameleonPrefPane/Sources/ShellProcess.h
3838
3939
4040
41
41
4242
4343
4444
/// Get the next line in the output, optionally skip lines until matching line is found
char * get_line(char * line, size_t s, const char *matching=NULL);
std::string get_line(const char * matching=NULL);
/// encapsulates seek to beginning of file with optional relative offset
bool seek_start(long offset=0L )
{
trunk/ChameleonPrefPane/Sources/PartitionInfoElement.mm
99
1010
1111
12
1213
1314
1415
1516
1617
1718
18
19
1920
2021
2122
......
4142
4243
4344
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
4472
4573
4674
#import "PartitionInfoElement.h"
#import "ShellProcess.h"
#include "string_util.h"
static NSUInteger sHdRedirTable[MAX_HD];
@implementation PartitionInfoElement
@synthesize descDict, bsdName, vUUID, vKind, vName, vPath, mediaPath, mediaRemovable, devInternal, devProtocol;
@synthesize vAliasName, hidden;
@synthesize vAliasName, hidden, bootInfo;
/// Create a list of all bsd partitions
+(NSArray*) createBSDPartitionList
return arr;
}
/// Get the boot information string, for chameleon only for now ...
-(NSString*) bootDescription
{
NSString* extractCmd = @"test -f \"%@boot\" && strings \"%@boot\" | sed -nE 's!^Darwin/x86 boot.+(Chameleon.+)!\\1!p'";
NSString* extractCmd2 = @"test -f \"%@mach_kernel\" && strings \"%@mach_kernel\" | sed -nE 's!^(Darwin Kernel Version.+)(\\: .*$)!\\1!p'";
NSString* localPath = [[self.vPath
stringByReplacingOccurrencesOfString: @"file://localhost"
withString:@""]
stringByReplacingOccurrencesOfString:@"%20" withString:@" "];
NSString* shellCmd = [NSString stringWithFormat:extractCmd, localPath, localPath ];
NSString* shellCmd2 = [NSString stringWithFormat:extractCmd2, localPath, localPath ];
std::string line = trim(ShellProcess([shellCmd UTF8String]).get_line(),"\n");
if (line.length()>0)
{
return [NSString stringWithUTF8String:line.c_str()];
}
else if ( (line=trim(ShellProcess([shellCmd2 UTF8String]).get_line(),"\n")).length()>0)
{
return [NSString stringWithUTF8String:line.c_str()];
}
else
return @"Unknown booter version";
}
/// redirection table for disk swapping
+(NSUInteger*) hdRedirTable
{
trunk/ChameleonPrefPane/bin/version
1
1
Revision: 458
Revision: 459
trunk/ChameleonPrefPane/ChameleonPrefPane.xcodeproj/project.pbxproj
278278
279279
280280
281
282281
283282
284283
......
302301
303302
304303
304
305305
306306
307307
01E314A9110FF91C0058F210 /* Controllers */,
01B0E80E1108B85A00ACF21B /* ChameleonPrefPane.h */,
01B0E80F1108B85A00ACF21B /* ChameleonPrefPane.mm */,
B3981D3F1113292A009E2520 /* CustomTableView.h */,
01A25D1B111108C80024EA7E /* CustomTableView.mm */,
);
name = GUI;
01B0E8121108B85A00ACF21B /* PropertyList.cpp */,
01993565110AA9FA003B056E /* ChameleonPropertyList.h */,
01993566110AA9FA003B056E /* ChameleonPropertyList.cpp */,
B3981D3F1113292A009E2520 /* CustomTableView.h */,
01A25D20111108C80024EA7E /* KernOptionsParser.cpp */,
01A25D21111108C80024EA7E /* KernOptionsParser.h */,
);
trunk/ChameleonPrefPane/test_util/test_util.mm
5353
5454
5555
56
5657
5758
5859
59
60
61
6062
6163
6264
6365
6466
67
6568
69
70
6671
6772
6873
......
7782
7883
7984
85
86
8087
8188
8289
......
9299
93100
94101
102
103
95104
96105
97106
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// smbios extractio testing
SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];
[smbe save:@"/tmp/chmIOreg.plist"];
NSLog(@"SMBIOS = \n%@", smbe);
// partitions extraction testing
#if 1
NSArray* arr = [PartitionInfoElement createBSDPartitionList];
NSLog(@"List of existing bsd disk partitions:\n %@", arr);
for (PartitionInfoElement* part in [PartsInfoMgr parts])
{
NSLog(@"PartionBootable = %i\n%@", (int) [part isBootable], part);
NSLog(@"boot info = %@", [part bootDescription] ) ;
}
/*
[PartsInfoMgr hideParts: @"\"Macintosh HD\" hd(0,3)"];
[PartsInfoMgr hideParts: @"disk0s2 hd(0,2) "];
testDiskInfoWith(@"disk0s2");
testDiskInfoWith(@"disk0s3");
#endif
// flag substitutions testing
fprintf(stderr, "String Test\n");
std::string options = "-v darkwake ab= a=0 =abc -f";
fprintf(stderr, "options = %s\n", options.c_str() );
<< std::endl;
}
[pool drain];
return 0;
}

Archive Download the corresponding diff file

Revision: 460