1 | //␊ |
2 | // StartupPrefPanePref.m␊ |
3 | //␊ |
4 | // Created by Rekursor on 1/16/10.␊ |
5 | //␊ |
6 | ␊ |
7 | #import "ChameleonPrefPane.h"␊ |
8 | ␊ |
9 | #include <process.h>␊ |
10 | #include <property_list.h>␊ |
11 | #include <string>␊ |
12 | ␊ |
13 | //--------------------------------------------------------------------------␊ |
14 | // Constants␊ |
15 | //--------------------------------------------------------------------------␊ |
16 | static const char * const szBootPaths[]= {␊ |
17 | ␉"/",␊ |
18 | ␉"/Extra/",␊ |
19 | ␉"/Volumes/EFI/Extra/",␊ |
20 | ␉"/Volumes/Cham/Extra/",␊ |
21 | ␉"/Volumes/BootLoaders/Extra/",␊ |
22 | ␉"/Volumes/RX0/Extra/",␊ |
23 | ␉"/Library/Preferences/SystemConfiguration/",␊ |
24 | ␉NULL␊ |
25 | };␊ |
26 | ␊ |
27 | static const char* const szPropFileName = "com.apple.Boot.plist";␊ |
28 | static const char* const kDefaultPartition = "Default Partition";␊ |
29 | static const char* const kHidePartition = "Hide Partition";␊ |
30 | static const char* const kRenamePartition = "Rename Partition";␊ |
31 | ␊ |
32 | static const NSString* const kPreferencesFilePath = @"/Library/Preferences/com.chameleon.prefPane.plist";␊ |
33 | static const NSString* const keyPreferencesFileVersion = @"version"; // for future back compatibility␊ |
34 | static const int CurrentPreferencesFileVersion = 0x01; // for future back compatibility␊ |
35 | static const NSString* const keyForceBootConfigPath = @"forceBootConfigPath";␊ |
36 | static const NSString* const keySwapHD01 = @"swapHD01";␊ |
37 | static const NSString* const keySwapHD02 = @"swapHD02";␊ |
38 | static const NSString* const keyUseFrozenParts = @"useFrozenParts";␊ |
39 | static const NSString* const keyPartitionsList = @"partitionsList";␊ |
40 | //--------------------------------------------------------------------------␊ |
41 | // Static file variables␊ |
42 | //--------------------------------------------------------------------------␊ |
43 | static std::string sCurrentDefaultPartition;␊ |
44 | ␊ |
45 | static PartitionExtractor * partExtractor=NULL;␊ |
46 | static PropertyList * prop = NULL;␊ |
47 | static int currentRowSel = -1;␊ |
48 | //--------------------------------------------------------------------------␊ |
49 | ␊ |
50 | @implementation ChameleonPrefPane␊ |
51 | ␊ |
52 | //--------------------------------------------------------------------------␊ |
53 | /**␊ |
54 | * SFAuthorization delegates␊ |
55 | */␊ |
56 | - (void)authorizationViewDidAuthorize:(SFAuthorizationView *)view {␊ |
57 | [self selectDefaultPartition];␊ |
58 | ␉[self refreshLockStates];␊ |
59 | ␊ |
60 | } ␊ |
61 | ␊ |
62 | //--------------------------------------------------------------------------␊ |
63 | - (void)authorizationViewDidDeauthorize:(SFAuthorizationView *)view {␊ |
64 | [self refreshLockStates];␊ |
65 | }␊ |
66 | ␊ |
67 | //--------------------------------------------------------------------------␊ |
68 | - (void) refreshLockStates␊ |
69 | {␊ |
70 | [mPartitionsTable setEnabled:[self isUnlocked]];␊ |
71 | [mSwapHD01 setEnabled:[self isUnlocked]];␊ |
72 | [mSwapHD02 setEnabled:[self isUnlocked]];␊ |
73 | [mStatusText setEnabled:[self isUnlocked]];␊ |
74 | [mFreezeParts setEnabled:[self isUnlocked]];␊ |
75 | [mInjectFrozenParts setEnabled:[self isUnlocked]];␊ |
76 | }␊ |
77 | ␊ |
78 | ␊ |
79 | //--------------------------------------------------------------------------␊ |
80 | - (bool)isUnlocked ␊ |
81 | {␊ |
82 | return [authView authorizationState] == SFAuthorizationViewUnlockedState;␊ |
83 | }␊ |
84 | ␊ |
85 | //--------------------------------------------------------------------------␊ |
86 | - (id) getImageResource: (NSString *) str ofType: (NSString*) sType␊ |
87 | {␊ |
88 | ␉NSImage * img=nil;␊ |
89 | ␉if(!str) return nil;␊ |
90 | ␉NSBundle * b = [NSBundle bundleForClass:[self class]];␊ |
91 | ␉NSString* sRes = [b pathForResource: str ofType:sType ];␊ |
92 | ␉img = [[NSImage alloc] initWithContentsOfFile: sRes];␊ |
93 | ␉return img;␊ |
94 | }␊ |
95 | ␊ |
96 | //--------------------------------------------------------------------------␊ |
97 | -(bool) savePreferences: (NSDictionary*) dict␊ |
98 | {␊ |
99 | ␉std::string sPath = [kPreferencesFilePath UTF8String];␊ |
100 | ␉␊ |
101 | ␉if(dict==nil || sPath.length()==0) return false;␊ |
102 | ␉␊ |
103 | ␉AuthorizationRef auth = [self isUnlocked] ? [[authView authorization] authorizationRef] : NULL;␊ |
104 | ␉␊ |
105 | ␉PropertyList::chmodFile(sPath.c_str(), "0777", auth);␊ |
106 | ␉[dict writeToFile:kPreferencesFilePath atomically:YES];␊ |
107 | ␉PropertyList::chmodFile(sPath.c_str(), "0644", auth);␊ |
108 | ␉return true;␊ |
109 | }␊ |
110 | ␊ |
111 | //--------------------------------------------------------------------------␊ |
112 | - (void) loadPreferences␊ |
113 | ␊ |
114 | {␊ |
115 | ␉id oldGlobalPreferences = [ [NSDictionary dictionaryWithContentsOfFile: ␊ |
116 | ␉␉␉␉␉␉␉␉kPreferencesFilePath ] retain];␊ |
117 | if (oldGlobalPreferences!=nil)␊ |
118 | ␉{␊ |
119 | ␉␉mPreferenceFileVersion= [[oldGlobalPreferences objectForKey: keyPreferencesFileVersion] intValue ];␊ |
120 | ␉␉[mSwapHD01 setIntValue: [[oldGlobalPreferences objectForKey:␉keySwapHD01] intValue]];␊ |
121 | ␉␉[mSwapHD02 setIntValue: [[oldGlobalPreferences objectForKey:␉keySwapHD02] intValue]];␊ |
122 | ␉␉[mFreezeParts setIntValue: [[oldGlobalPreferences objectForKey: keyUseFrozenParts] intValue] ];␊ |
123 | ␉␉mPartitionsList = [oldGlobalPreferences objectForKey: keyUseFrozenParts];␊ |
124 | ␉}␊ |
125 | ␉else ␊ |
126 | ␉{ // Create a preference plist file with Defaults values␊ |
127 | ␉␉[mSwapHD01 setIntValue: 0];␊ |
128 | ␉␉[mSwapHD02 setIntValue: 0];␊ |
129 | ␉␉[mFreezeParts setIntValue: 0];␊ |
130 | ␉␉// Initialize defaults␊ |
131 | ␉␉oldGlobalPreferences = [[NSMutableDictionary alloc] init];␊ |
132 | ␉␉[oldGlobalPreferences setObject: [[NSNumber alloc] initWithInt: CurrentPreferencesFileVersion] ␊ |
133 | ␉␉␉␉␉␉␉␉ forKey: keyPreferencesFileVersion];␊ |
134 | ␉␉[oldGlobalPreferences setObject: [[NSNumber alloc] initWithBool: false] forKey: keySwapHD01];␊ |
135 | ␉␉[oldGlobalPreferences setObject: [[NSNumber alloc] initWithBool: false] forKey: keySwapHD02];␊ |
136 | ␉␉[oldGlobalPreferences setObject:[[NSNumber alloc] initWithBool: false] forKey: keyUseFrozenParts];␊ |
137 | ␉␉[oldGlobalPreferences setObject: [[NSMutableDictionary alloc] initWithCapacity:64] forKey: keyPartitionsList];␊ |
138 | ␉␉␊ |
139 | ␉␉// Save the preferences file␊ |
140 | ␉␉[ self savePreferences:oldGlobalPreferences ];␊ |
141 | ␉}␊ |
142 | ␊ |
143 | ␉mOptionsDict = [[NSMutableDictionary alloc] init];␊ |
144 | [mOptionsDict addEntriesFromDictionary:oldGlobalPreferences];␊ |
145 | ␉[mOptionsDict retain];␊ |
146 | ␉if (mPartitionsList!=nil) [mPartitionsList retain];␊ |
147 | [oldGlobalPreferences release];␊ |
148 | ␉␊ |
149 | }␊ |
150 | ␊ |
151 | //--------------------------------------------------------------------------␊ |
152 | - (id) init␊ |
153 | {␊ |
154 | ␉self = [super init];␊ |
155 | ␊ |
156 | ␉// set the image to display the current file being played␊ |
157 | ␉mMacOSXImage = [self getImageResource: @"MacOSX" ofType: @"png"];␊ |
158 | ␉mWindowsImage = [self getImageResource: @"Windows" ofType: @"png"];␊ |
159 | ␉mLinuxImage = [self getImageResource: @"Linux" ofType: @"png"];␊ |
160 | ␉mCDROMImage = [self getImageResource: @"CDROM" ofType: @"png"];␊ |
161 | ␉mUnknownImage = [self getImageResource: @"Chameleon" ofType: @"tiff"];␊ |
162 | ␉␊ |
163 | ␉␊ |
164 | ␉// Retrieve the com.chameleon.prefPane.plist config␊ |
165 | ␉return self;␊ |
166 | }␊ |
167 | ␊ |
168 | //--------------------------------------------------------------------------␊ |
169 | /** When called here, all outlets references are initialized */␊ |
170 | - (void)awakeFromNib␊ |
171 | { // called more than once, we only need one resource init␊ |
172 | ␉static bool ft=true;␊ |
173 | ␉if(ft)␊ |
174 | ␉{␊ |
175 | ␉␉ft=false;␊ |
176 | ␉␉[self loadPreferences];␊ |
177 | ␉␉[self initBootConfig];␊ |
178 | ␉}␊ |
179 | }␊ |
180 | ␊ |
181 | //--------------------------------------------------------------------------␊ |
182 | - (void) initBootConfig␊ |
183 | {␊ |
184 | ␉static bool ft=true;␊ |
185 | ␉␊ |
186 | ␉// Cosmetics setup␊ |
187 | ␉// Setup security for changing boot options␊ |
188 | AuthorizationItem items = {kAuthorizationRightExecute, 0, NULL, 0};␊ |
189 | AuthorizationRights rights = {1, &items};␊ |
190 | ␊ |
191 | ␉[authView setAuthorizationRights:&rights];␊ |
192 | authView.delegate = self;␊ |
193 | [authView updateStatus:nil];␊ |
194 | ␊ |
195 | ␉// create the propertylist object that will handle com.apple.Boot.plist␊ |
196 | ␉if(!prop) prop = new PropertyList();␊ |
197 | ␊ |
198 | ␉// create the process that will extract the diskutil list infos␊ |
199 | ␉if(!partExtractor) partExtractor = new PartitionExtractor();␊ |
200 | ␉␊ |
201 | ␉if (!prop->isValid())␊ |
202 | ␉{␊ |
203 | ␉␉std::string sPath;␊ |
204 | ␉␉AuthorizationRef auth = [self isUnlocked] ? [[authView authorization] authorizationRef] : NULL;␊ |
205 | ␉␉CFStringRef errorString=NULL;␊ |
206 | ␉␉bool cont =true;␊ |
207 | ␉␉␊ |
208 | ␉␉id sForcedPath = [mOptionsDict valueForKey: keyForceBootConfigPath];␊ |
209 | ␉␉const char * szForcedPath = sForcedPath!=nil ? [sForcedPath UTF8String] : NULL;␊ |
210 | ␉␉if (szForcedPath && *szForcedPath)␊ |
211 | ␉␉{␊ |
212 | ␉␉␉cont = !prop->open(szForcedPath, &errorString, auth);␊ |
213 | ␉␉}␊ |
214 | ␉␉else {␊ |
215 | ␉␉␉for(int i=0; szBootPaths[i] && cont; i++)␊ |
216 | ␉␉␉{␊ |
217 | ␉␉␉␉sPath = szBootPaths[i];␊ |
218 | ␉␉␉␉sPath += szPropFileName;␊ |
219 | ␉␉␉␉cont = !prop->open(sPath.c_str(), &errorString, auth);␊ |
220 | ␉␉␉}␊ |
221 | ␉␉}␊ |
222 | ␉␉if (cont)␊ |
223 | ␉␉{␊ |
224 | ␉␉␉if(!ft) return;␊ |
225 | ␉␉␉ft=false;␊ |
226 | ␉␉␉[mStatusText setTextColor: [NSColor redColor] ];␊ |
227 | ␉␉␉if (errorString)␊ |
228 | ␉␉␉␉[mStatusText setStringValue:[NSString stringWithFormat: @"Error while parsing com.apple.Boot.plist : %@",␊ |
229 | ␉␉␉␉␉␉␉␉␉␉␉ errorString] ];␊ |
230 | ␉␉␉else␊ |
231 | ␉␉␉␉[mStatusText setStringValue: @"Error while searching for com.apple.Boot.plist"];␊ |
232 | ␉␉␉␊ |
233 | ␉␉}␊ |
234 | ␉␉else␊ |
235 | ␉␉{ ␊ |
236 | ␉␉␉[mStatusText setTextColor: [NSColor grayColor] ];␊ |
237 | ␉␉␉NSString* ns = [ [NSString alloc] initWithUTF8String:prop->bootConfigPath() ];␊ |
238 | ␉␉␉[mStatusText setStringValue: [NSString stringWithFormat: @"bootConfig: %@", ns] ];␊ |
239 | ␉␉}␊ |
240 | ␉␉if (prop->isValid())␊ |
241 | ␉␉{␊ |
242 | ␉␉␉// read options in the plist file␊ |
243 | ␉␉␉␊ |
244 | ␉␉␉partExtractor->hidePartitions(prop->getStringForKey(kHidePartition));␊ |
245 | ␉␉␉partExtractor->renamedPartitions(prop->getStringForKey(kRenamePartition));␊ |
246 | ␉␉␉␊ |
247 | ␉␉␉// partExtractor->resetSwapping();␊ |
248 | ␉␉␉id val = [mOptionsDict valueForKey: keySwapHD01];␊ |
249 | ␉␉␉[mSwapHD01 setIntValue: [val intValue] ];␊ |
250 | ␉␉␉[self doSwapHD: [val boolValue] save: false src:0 dst:1];␊ |
251 | ␉␉␉␊ |
252 | ␉␉␉val = [mOptionsDict valueForKey: keySwapHD02];␊ |
253 | ␉␉␉[mSwapHD02 setIntValue: [val intValue] ];␊ |
254 | ␉␉␉[self doSwapHD: [val boolValue] save: false src:0 dst:2];␊ |
255 | ␉␉␉␊ |
256 | ␉␉␉[self selectDefaultPartition];␊ |
257 | ␉␉}␊ |
258 | ␉␉␊ |
259 | ␉}␉␊ |
260 | }␊ |
261 | //--------------------------------------------------------------------------␊ |
262 | - (void) selectDefaultPartition␊ |
263 | {␊ |
264 | if(!authView) return;␊ |
265 | ␉␊ |
266 | ␉[self refreshLockStates];␊ |
267 | ␉␊ |
268 | ␉// try to get the current default partition if any␊ |
269 | ␉if(partExtractor && prop && prop->isValid())␊ |
270 | ␉{␊ |
271 | ␉␉const char *sdp = prop->getStringForKey(kDefaultPartition);␊ |
272 | ␉␉sCurrentDefaultPartition = sdp ? sdp : ""; ␊ |
273 | ␉␉if (sCurrentDefaultPartition.size())␊ |
274 | ␉␉{␊ |
275 | ␉␉␉int index = partExtractor->getIndexFromHdStringSpec(sCurrentDefaultPartition.c_str());␊ |
276 | ␉␉␉if (index>=0)␊ |
277 | ␉␉␉{␊ |
278 | ␉␉␉␉[mPartitionsTable selectRowIndexes:␊ |
279 | ␉␉␉␉ [NSIndexSet indexSetWithIndex:index] byExtendingSelection:NO];␊ |
280 | ␉␉␉␉currentRowSel = index;␊ |
281 | ␉␉␉}␊ |
282 | ␉␉}␊ |
283 | ␉}␊ |
284 | ␉␊ |
285 | }␊ |
286 | ␊ |
287 | //--------------------------------------------------------------------------␊ |
288 | - (void) swapDisks: (bool) bSwap src: (int) iSrc dst: (int) iDst;␊ |
289 | {␊ |
290 | ␉if(!partExtractor || !prop || !prop->isValid()) return;␊ |
291 | ␉if (bSwap)␊ |
292 | ␉{␊ |
293 | ␉␉partExtractor->swapHD(iSrc, iDst);␉␊ |
294 | ␉}␊ |
295 | ␉partExtractor->extractPartitions();␊ |
296 | ␉[ self selectDefaultPartition];␊ |
297 | ␊ |
298 | }␊ |
299 | ␊ |
300 | //--------------------------------------------------------------------------␊ |
301 | - (void) doSwapHD: (int) val save: (bool) doSave src: (int) isrc dst: (int) idst␊ |
302 | {␊ |
303 | ␉␊ |
304 | ␉if( val>0) //on␊ |
305 | ␉{␊ |
306 | ␉␉[self swapDisks: true src:isrc dst:idst ];␊ |
307 | ␉}␊ |
308 | ␉else␊ |
309 | ␉{␊ |
310 | ␉␉[self swapDisks: false src:isrc dst:idst ];␊ |
311 | ␉}␊ |
312 | ␉␊ |
313 | ␉if(doSave)␊ |
314 | ␉{␊ |
315 | ␉␉if (isrc==0 && idst==1)␊ |
316 | ␉␉␉[mOptionsDict setObject: [NSNumber numberWithBool: val ? true : false] forKey: keySwapHD01];␊ |
317 | ␉␉if (isrc==0 && idst==2)␊ |
318 | ␉␉␉[mOptionsDict setObject: [NSNumber numberWithBool: val ? true : false] forKey: keySwapHD02];␊ |
319 | ␉␉[ self savePreferences:mOptionsDict ];␊ |
320 | ␉}␊ |
321 | ␉␊ |
322 | ␉[mPartitionsTable reloadData];␊ |
323 | ␉[mPartitionsTable scrollRowToVisible: 0];␊ |
324 | ␉//[self tableViewSelectionDidChange: nil];␊ |
325 | ␉␊ |
326 | }␊ |
327 | //--------------------------------------------------------------------------␊ |
328 | - (IBAction)onSwapHD: (id)sender␊ |
329 | {␊ |
330 | ␉partExtractor->resetSwapping();␊ |
331 | ␉[self doSwapHD: [mSwapHD01 intValue] save:true src:0 dst:1];␊ |
332 | ␉[self doSwapHD: [mSwapHD02 intValue] save:true src:0 dst:2];␊ |
333 | }␊ |
334 | //--------------------------------------------------------------------------␊ |
335 | - (IBAction)onUseFrozenParts: (id)sender␊ |
336 | {␊ |
337 | ␉bool val = !![sender intValue];␊ |
338 | ␉[mOptionsDict setObject: [NSNumber numberWithBool: val] forKey: keyUseFrozenParts];␊ |
339 | ␉[self savePreferences :mOptionsDict];␊ |
340 | }␊ |
341 | ␊ |
342 | //--------------------------------------------------------------------------␊ |
343 | - (IBAction)onInjectPartsToFreeze: (id)sender␊ |
344 | {␊ |
345 | ␉// TODO generate the parts list in preferences proplist␊ |
346 | ␉NSInteger n = NSRunAlertPanel(@"Inject Partitions to Freeze Configuration", ␊ |
347 | ␉␉␉␉␉␉␉␉ @"Are you sure you want to overwrite your Freeze settings with current partition list ?",␊ |
348 | ␉␉␉␉␉␉␉␉ @"OK", @"Cancel",nil);␊ |
349 | ␉if (n==1)␊ |
350 | ␉{␊ |
351 | ␉}␊ |
352 | }␊ |
353 | //--------------------------------------------------------------------------␊ |
354 | // following DieBuch recommendation : using applescript and system events (thanks!):␊ |
355 | - (IBAction)onRestart: (id)sender␊ |
356 | {␊ |
357 | ␉NSInteger n = NSRunAlertPanel(@"Restarting OS X", ␊ |
358 | ␉␉␉␉␉␉␉␉ @"Are you sure you want to restart your computer now ?",␊ |
359 | ␉␉␉␉␉␉␉␉ @"OK", @"Cancel", nil);␊ |
360 | ␉if (n==1)␊ |
361 | ␉{␊ |
362 | ␉␉AuthorizationRef auth = [[authView authorization] authorizationRef];␊ |
363 | ␉␉executePrivilegedCmd(auth,"/usr/bin/osascript","-e 'tell app \"System Events\" to restart'");␊ |
364 | ␉}␊ |
365 | ␉␊ |
366 | }␊ |
367 | - (IBAction)onShutdown: (id)sender␊ |
368 | {␊ |
369 | ␉NSInteger n = NSRunAlertPanel(@"Shutting Down OS X", ␊ |
370 | ␉␉␉␉␉␉␉␉ @"Are you sure you want to shut down your computer now ?",␊ |
371 | ␉␉␉␉␉␉␉␉ @"OK", @"Cancel", /*ThirdButtonHere:*/nil␊ |
372 | ␉␉␉␉␉␉␉␉ /*, args for a printf-style msg go here */);␊ |
373 | ␉if (n==1)␊ |
374 | ␉{␊ |
375 | ␉␉system("/usr/bin/osascript -e 'tell app \"System Events\" to shut down'");␊ |
376 | ␉}␊ |
377 | }␊ |
378 | ␊ |
379 | - (IBAction)onSleep: (id)sender␊ |
380 | {␊ |
381 | ␉system("/usr/bin/osascript -e 'tell app \"System Events\" to sleep'");␊ |
382 | }␊ |
383 | ␊ |
384 | //--------------------------------------------------------------------------␊ |
385 | - (void)tableViewSelectionDidChange:(NSNotification *)notification {␊ |
386 | ␊ |
387 | ␉NSTableView* tv= mPartitionsTable;␊ |
388 | ␉if ([tv selectedRow] != currentRowSel)␊ |
389 | ␉{␊ |
390 | ␉␉currentRowSel = [tv selectedRow];␊ |
391 | ␉␉if (currentRowSel>=0)␊ |
392 | ␉␉{␊ |
393 | ␉␉␉const std::vector<PartitionInfo>& partInfo = partExtractor->partList();␊ |
394 | ␉␉␉char hd[7+1]="hd(n,m)";␊ |
395 | ␉␉␉hd[3]= ('0'+partInfo[currentRowSel].disk());␊ |
396 | ␉␉␉hd[5]= ('0'+partInfo[currentRowSel].partition());␉␊ |
397 | ␉␉␉AuthorizationRef auth= [self isUnlocked] ? [[authView authorization] authorizationRef] : NULL;␊ |
398 | ␉␉␉if(prop->setStringForKey(kDefaultPartition, hd))␊ |
399 | ␉␉␉ prop->save(auth);␊ |
400 | ␉␉}␊ |
401 | ␉}␊ |
402 | ␉␉␊ |
403 | }␊ |
404 | ␊ |
405 | //--------------------------------------------------------------------------␊ |
406 | - (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView␊ |
407 | {␊ |
408 | ␉int size = partExtractor ? partExtractor->partList().size() : 0;␊ |
409 | ␉return size;␊ |
410 | }␊ |
411 | ␊ |
412 | //--------------------------------------------------------------------------␊ |
413 | - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row␊ |
414 | {␊ |
415 | ␉id ret=nil;␊ |
416 | ␉␊ |
417 | ␉const std::vector<PartitionInfo>& partInfo = partExtractor->partList();␊ |
418 | ␊ |
419 | ␉if (tableColumn == mPartitionImgColumn) ␊ |
420 | ␉{␊ |
421 | ␉␉switch(partInfo[row].imageIndexFromFs())␊ |
422 | ␉␉{␊ |
423 | ␉␉␉case 0:␊ |
424 | ␉␉␉␉ret = mMacOSXImage;␊ |
425 | ␉␉␉␉break;␊ |
426 | ␉␉␉case 1:␊ |
427 | ␉␉␉␉ret = mWindowsImage;␊ |
428 | ␉␉␉␉break;␊ |
429 | ␉␉␉case 2:␊ |
430 | ␉␉␉␉ret = mLinuxImage;␊ |
431 | ␉␉␉␉break;␊ |
432 | ␉␉␉defualt:␊ |
433 | ␉␉␉␉ret = mUnknownImage;␊ |
434 | ␉␉␉␉break;␊ |
435 | ␉␉␉␉␊ |
436 | ␉␉}␊ |
437 | ␉}␊ |
438 | ␉else if (tableColumn == mFileSystemColumn) ␊ |
439 | ␉{␊ |
440 | ␉␉ret = [NSString stringWithFormat: @"%s", partInfo[row].fsType().c_str() ];␊ |
441 | ␉}␊ |
442 | ␉else if (tableColumn == mPartitionNameColumn) ␊ |
443 | ␉{␊ |
444 | ␉␉ret = [NSString stringWithFormat: @"%s", ␊ |
445 | ␉␉␉␉partInfo[row].label().c_str()␊ |
446 | ␉␉␉␉];␊ |
447 | ␉}␊ |
448 | ␉else if (tableColumn == mPartitionIDColumn) ␊ |
449 | ␉{␊ |
450 | ␉␉ret= [NSString stringWithFormat: @"hd(%d,%d)", ␊ |
451 | ␉␉␉␉partInfo[row].disk(),␊ |
452 | ␉␉␉␉partInfo[row].partition()␊ |
453 | ␉␉␉␉];␊ |
454 | ␉} ␊ |
455 | ␉␊ |
456 | ␉return ret;␊ |
457 | }␊ |
458 | //--------------------------------------------------------------------------␊ |
459 | ␊ |
460 | @end␊ |
461 | |