Changeset 3675
- Timestamp:
- 02/06/06 00:39:52 (3 years ago)
- Files:
-
- WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/classes.nib (modified) (2 diffs)
- WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/info.nib (modified) (1 diff)
- WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/keyedobjects.nib (modified) (previous)
- WiredServer/trunk/PreferencePane/prefix.pch (modified) (1 diff)
- WiredServer/trunk/WCAccountsController.h (modified) (1 diff)
- WiredServer/trunk/WCAccountsController.m (modified) (24 diffs)
- WiredServer/trunk/WCConfigController.m (modified) (25 diffs)
- WiredServer/trunk/WCDashboardController.h (modified) (1 diff)
- WiredServer/trunk/WCDashboardController.m (modified) (2 diffs)
- WiredServer/trunk/WCLogController.m (modified) (12 diffs)
- WiredServer/trunk/WCStatusController.m (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/classes.nib
r3408 r3675 31 31 "_downloadButton" = NSButton; 32 32 "_downloadSpeedTextField" = NSTextField; 33 "_downloadsTextField" = NSTextField;34 33 "_editAccountsButton" = NSButton; 35 34 "_elevatePrivilegesButton" = NSButton; … … 47 46 "_uploadButton" = NSButton; 48 47 "_uploadSpeedTextField" = NSTextField; 49 "_uploadsTextField" = NSTextField;50 48 "_viewDropBoxesButton" = NSButton; 51 49 }; WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/info.nib
r3408 r3675 12 12 </array> 13 13 <key>IBSystem Version</key> 14 <string>8 F46</string>14 <string>8G32</string> 15 15 </dict> 16 16 </plist> WiredServer/trunk/PreferencePane/prefix.pch
r3403 r3675 32 32 #import <Security/Authorization.h> 33 33 #import <Security/AuthorizationTags.h> 34 #import <SecurityInterface/SFAuthorizationView.h> 34 35 #import <WiredAdditions/WiredAdditions.h> 35 36 WiredServer/trunk/WCAccountsController.h
r3011 r3675 61 61 IBOutlet NSButton *_setTopicButton; 62 62 63 IBOutlet NSTextField *_downloadsTextField;63 // IBOutlet NSTextField *_downloadsTextField; 64 64 IBOutlet NSTextField *_downloadSpeedTextField; 65 IBOutlet NSTextField *_uploadsTextField;65 // IBOutlet NSTextField *_uploadsTextField; 66 66 IBOutlet NSTextField *_uploadSpeedTextField; 67 67 WiredServer/trunk/WCAccountsController.m
r3403 r3675 34 34 #import "WCSettings.h" 35 35 36 static WCAccountsController *sharedAccountsController; 37 38 36 39 @interface WCAccountsController(Private) 37 40 38 static id sharedAccountsController; 39 40 - (WCAccount *)selectedAccount; 41 - (void)selectAccount:(WCAccount *)account; 42 - (void)unselectAccount:(WCAccount *)account; 43 - (void)validateAccount:(WCAccount *)account; 44 45 - (void)readUsersFromFile:(NSString *)path; 46 - (void)readGroupsFromFile:(NSString *)path; 47 - (BOOL)writeUsersToFile:(NSString *)path; 48 - (BOOL)writeGroupsToFile:(NSString *)path; 41 - (WCAccount *)_selectedAccount; 42 43 - (void)_selectAccount:(WCAccount *)account; 44 - (void)_unselectAccount:(WCAccount *)account; 45 - (void)_validateAccount:(WCAccount *)account; 46 47 - (void)_readUsersFromFile:(NSString *)path; 48 - (void)_readGroupsFromFile:(NSString *)path; 49 - (BOOL)_writeUsersToFile:(NSString *)path; 50 - (BOOL)_writeGroupsToFile:(NSString *)path; 49 51 50 52 @end 51 53 52 54 53 @implementation WCAccountsController 54 55 + (WCAccountsController *)accountsController { 56 return sharedAccountsController; 57 } 58 59 60 61 - (id)init { 62 self = [super init]; 63 64 sharedAccountsController = self; 65 66 return self; 67 } 68 69 70 71 - (void)awakeFromNib { 72 WIIconCell *cell; 73 74 _accounts = [[NSMutableArray alloc] init]; 75 76 cell = [[WIIconCell alloc] init]; 77 [cell setImageWidth:16.0]; 78 [cell setDrawsWhitespace:YES]; 79 [[_tableView tableColumnWithIdentifier:@"Name"] setDataCell:cell]; 80 [cell release]; 81 82 _userImage = [[NSImage alloc] initWithContentsOfFile: 83 [[self bundle] pathForResource:@"User" ofType:@"tiff"]]; 84 _groupImage = [[NSImage alloc] initWithContentsOfFile: 85 [[self bundle] pathForResource:@"Group" ofType:@"tiff"]]; 86 87 [[NSNotificationCenter defaultCenter] 88 addObserver:self 89 selector:@selector(authorizationStatusDidChange:) 90 name:WCAuthorizationStatusDidChange 91 object:NULL]; 92 } 93 94 95 96 - (void)awakeFromController { 97 [self readUsersFromFile:WCExpandWiredPath(@"users")]; 98 [self readGroupsFromFile:WCExpandWiredPath(@"groups")]; 99 100 [self selectAccount:[self selectedAccount]]; 101 } 102 103 104 105 - (BOOL)saveFromController { 106 BOOL status = YES; 107 108 if(_touched) { 109 if(status) 110 status = [self writeUsersToFile:WCExpandWiredPath(@"users")]; 111 112 if(status) 113 status = [self writeGroupsToFile:WCExpandWiredPath(@"groups")]; 114 } 115 116 return status; 117 } 118 119 120 121 - (void)dealloc { 122 [[NSNotificationCenter defaultCenter] removeObserver:self]; 123 124 [_accounts release]; 125 [_users release]; 126 [_groups release]; 127 128 [_userImage release]; 129 [_groupImage release]; 130 131 [super dealloc]; 132 } 133 134 135 136 #pragma mark - 137 138 - (void)authorizationStatusDidChange:(NSNotification *)notification { 139 _authorized = [[notification object] boolValue]; 140 141 [self validateAccount:[self selectedAccount]]; 142 } 143 144 145 146 - (void)controlTextDidChange:(NSNotification *)notification { 147 WCAccount *account; 148 149 _touched = YES; 150 151 if([notification object] == _nameTextField) { 152 account = [self selectedAccount]; 153 [account setName:[_nameTextField stringValue]]; 154 [_tableView reloadData]; 155 } 156 } 157 158 159 160 #pragma mark - 161 162 - (WCAccount *)selectedAccount { 55 @implementation WCAccountsController(Private) 56 57 - (WCAccount *)_selectedAccount { 163 58 int row; 164 59 … … 173 68 174 69 175 - (void)selectAccount:(WCAccount *)account { 70 #pragma mark - 71 72 - (void)_selectAccount:(WCAccount *)account { 176 73 NSEnumerator *enumerator; 177 74 WCAccount *group; 178 75 179 // --- populate menu180 76 [_groupPopUpButton removeAllItems]; 181 77 [_groupPopUpButton addItemWithTitle:WCLS(@"none", "Group menu item")]; … … 185 81 [_groupPopUpButton addItemWithTitle:[group name]]; 186 82 187 // --- validate interface 188 [self validateAccount:account]; 189 190 // --- update interface from account 83 [self _validateAccount:account]; 84 191 85 if(account) { 192 86 [_typePopUpButton selectItemAtIndex: … … 222 116 [_setTopicButton setState:[account setTopic]]; 223 117 224 if([account downloads] > 0)118 /* if([account downloads] > 0) 225 119 [_downloadsTextField setIntValue:[account downloads]]; 226 120 else 227 [_downloadsTextField setStringValue:@""]; 121 [_downloadsTextField setStringValue:@""];*/ 228 122 229 123 if([account downloadSpeed] > 0) … … 232 126 [_downloadSpeedTextField setStringValue:@""]; 233 127 234 if([account uploads] > 0)128 /* if([account uploads] > 0) 235 129 [_uploadsTextField setIntValue:[account uploads]]; 236 130 else 237 [_uploadsTextField setStringValue:@""]; 131 [_uploadsTextField setStringValue:@""];*/ 238 132 239 133 if([account uploadSpeed] > 0) … … 248 142 249 143 250 - (void) unselectAccount:(WCAccount *)account {144 - (void)_unselectAccount:(WCAccount *)account { 251 145 if(!_selected) 252 146 return; 253 147 254 // --- update account from interface255 148 [account setName:[_nameTextField stringValue]]; 256 149 [account setPassword:[_passwordTextField stringValue]]; … … 281 174 [account setSetTopic:[_setTopicButton state]]; 282 175 283 [account setDownloads:[_downloadsTextField intValue]];176 // [account setDownloads:[_downloadsTextField intValue]]; 284 177 [account setDownloadSpeed:[_downloadSpeedTextField intValue] * 1024]; 285 [account setUploads:[_uploadsTextField intValue]];178 // [account setUploads:[_uploadsTextField intValue]]; 286 179 [account setUploadSpeed:[_uploadSpeedTextField intValue] * 1024]; 287 180 … … 291 184 292 185 293 - (void) validateAccount:(WCAccount *)account {186 - (void)_validateAccount:(WCAccount *)account { 294 187 BOOL enabled; 295 188 BOOL authorized; 296 189 297 // --- enable/disable basics298 190 authorized = [self requiresAuthorization] ? _authorized : YES; 299 191 enabled = authorized && (account != NULL); … … 303 195 [_nameTextField setEnabled:enabled]; 304 196 305 // --- enable/disable user controls306 197 enabled = (authorized && [account type] == WCAccountUser); 307 198 [_passwordTextField setEnabled:enabled]; 308 199 [_groupPopUpButton setEnabled:enabled]; 309 200 310 // --- enable/disable privileges311 201 enabled = (authorized && [[account group] length] == 0); 312 202 [_getUserInfoButton setEnabled:enabled]; … … 329 219 [_cannotBeKickedButton setEnabled:enabled]; 330 220 [_setTopicButton setEnabled:enabled]; 331 [_downloadsTextField setEnabled:enabled];221 // [_downloadsTextField setEnabled:enabled]; 332 222 [_downloadSpeedTextField setEnabled:enabled]; 333 [_uploadsTextField setEnabled:enabled];223 // [_uploadsTextField setEnabled:enabled]; 334 224 [_uploadSpeedTextField setEnabled:enabled]; 335 225 } … … 339 229 #pragma mark - 340 230 341 - (void) readUsersFromFile:(NSString *)path {231 - (void)_readUsersFromFile:(NSString *)path { 342 232 [_accounts removeObjectsInArray:[_users accounts]]; 343 233 [_users release]; … … 348 238 349 239 [_tableView reloadData]; 350 [self selectAccount:[self selectedAccount]]; 351 } 352 353 354 355 - (void)readGroupsFromFile:(NSString *)path { 240 241 [self _selectAccount:[self _selectedAccount]]; 242 } 243 244 245 246 - (void)_readGroupsFromFile:(NSString *)path { 356 247 [_accounts removeObjectsInArray:[_groups accounts]]; 357 248 [_groups release]; … … 362 253 363 254 [_tableView reloadData]; 364 [self selectAccount:[self selectedAccount]]; 365 } 366 367 368 369 - (BOOL)writeUsersToFile:(NSString *)path { 255 256 [self _selectAccount:[self _selectedAccount]]; 257 } 258 259 260 261 - (BOOL)_writeUsersToFile:(NSString *)path { 370 262 NSString *temp; 371 263 WCAuthorization *authorization; … … 373 265 BOOL status = YES; 374 266 375 [self unselectAccount:[selfselectedAccount]];267 [self _unselectAccount:[self _selectedAccount]]; 376 268 377 269 if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 378 // --- write directly to file379 270 status = [_users writeToFile:path]; 380 271 } else { 381 // --- write users to temporary file382 272 authorization = [WCAuthorization authorization]; 383 273 … … 406 296 407 297 408 - (BOOL) writeGroupsToFile:(NSString *)path {298 - (BOOL)_writeGroupsToFile:(NSString *)path { 409 299 NSString *temp; 410 300 WCAuthorization *authorization; … … 412 302 BOOL status = YES; 413 303 414 [self unselectAccount:[selfselectedAccount]];304 [self _unselectAccount:[self _selectedAccount]]; 415 305 416 306 if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 417 // --- write directly to file418 307 status = [_groups writeToFile:path]; 419 308 } else { 420 // --- write groups to temporary file421 309 authorization = [WCAuthorization authorization]; 422 310 … … 443 331 } 444 332 333 @end 334 335 336 @implementation WCAccountsController 337 338 + (WCAccountsController *)accountsController { 339 return sharedAccountsController; 340 } 341 342 343 344 - (id)init { 345 self = [super init]; 346 347 sharedAccountsController = self; 348 349 return self; 350 } 351 352 353 354 - (void)awakeFromNib { 355 WIIconCell *cell; 356 357 _accounts = [[NSMutableArray alloc] init]; 358 359 cell = [[WIIconCell alloc] init]; 360 [cell setImageWidth:16.0]; 361 [cell setDrawsWhitespace:YES]; 362 [[_tableView tableColumnWithIdentifier:@"Name"] setDataCell:cell]; 363 [cell release]; 364 365 _userImage = [[NSImage alloc] initWithContentsOfFile: 366 [[self bundle] pathForResource:@"User" ofType:@"tiff"]]; 367 _groupImage = [[NSImage alloc] initWithContentsOfFile: 368 [[self bundle] pathForResource:@"Group" ofType:@"tiff"]]; 369 370 [[NSNotificationCenter defaultCenter] 371 addObserver:self 372 selector:@selector(authorizationStatusDidChange:) 373 name:WCAuthorizationStatusDidChange 374 object:NULL]; 375 } 376 377 378 379 - (void)awakeFromController { 380 [self _readUsersFromFile:WCExpandWiredPath(@"users")]; 381 [self _readGroupsFromFile:WCExpandWiredPath(@"groups")]; 382 383 [self _selectAccount:[self _selectedAccount]]; 384 } 385 386 387 388 - (BOOL)saveFromController { 389 BOOL status = YES; 390 391 if(_touched) { 392 if(status) 393 status = [self _writeUsersToFile:WCExpandWiredPath(@"users")]; 394 395 if(status) 396 status = [self _writeGroupsToFile:WCExpandWiredPath(@"groups")]; 397 } 398 399 return status; 400 } 401 402 403 404 - (void)dealloc { 405 [[NSNotificationCenter defaultCenter] removeObserver:self]; 406 407 [_accounts release]; 408 [_users release]; 409 [_groups release]; 410 411 [_userImage release]; 412 [_groupImage release]; 413 414 [super dealloc]; 415 } 416 417 418 419 #pragma mark - 420 421 - (void)authorizationStatusDidChange:(NSNotification *)notification { 422 _authorized = [[notification object] boolValue]; 423 424 [self _validateAccount:[self _selectedAccount]]; 425 } 426 427 428 429 - (void)controlTextDidChange:(NSNotification *)notification { 430 WCAccount *account; 431 432 _touched = YES; 433 434 if([notification object] == _nameTextField) { 435 account = [self _selectedAccount]; 436 [account setName:[_nameTextField stringValue]]; 437 [_tableView reloadData]; 438 } 439 } 440 445 441 446 442 … … 495 491 WCAccount *account, *user; 496 492 497 account = [self selectedAccount];493 account = [self _selectedAccount]; 498 494 499 495 if([account type] == WCAccountGroup) { … … 523 519 WCAccount *account; 524 520 525 account = [self selectedAccount];521 account = [self _selectedAccount]; 526 522 [account setType:[[_typePopUpButton selectedItem] tag]]; 527 523 … … 545 541 546 542 [_tableView reloadData]; 547 [self selectAccount:account]; 543 544 [self _selectAccount:account]; 548 545 } 549 546 … … 553 550 WCAccount *account; 554 551 555 account = [self selectedAccount];552 account = [self _selectedAccount]; 556 553 557 554 if([_groupPopUpButton indexOfSelectedItem] == 0) … … 562 559 _touched = YES; 563 560 564 [self selectAccount:account];561 [self _selectAccount:account]; 565 562 } 566 563 … … 591 588 592 589 - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row { 593 [self unselectAccount:[selfselectedAccount]];590 [self _unselectAccount:[self _selectedAccount]]; 594 591 595 592 return YES; … … 599 596 600 597 - (void)tableViewSelectionDidChange:(NSNotification *)notification { 601 [self selectAccount:[selfselectedAccount]];598 [self _selectAccount:[self _selectedAccount]]; 602 599 } 603 600 WiredServer/trunk/WCConfigController.m
r3403 r3675 38 38 #import "WCStatusController.h" 39 39 40 static WCConfigController *sharedConfigController; 41 40 42 @interface WCConfigController(Private) 41 43 42 static id sharedConfigController; 43 44 - (void)update; 45 - (void)updateCertificate; 46 47 - (void)readFromFile:(NSString *)path; 48 - (BOOL)writeToFile:(NSString *)path; 49 50 - (void)setLaunchesAtBoot:(BOOL)value; 44 - (void)_update; 45 - (void)_updateCertificate; 46 47 - (void)_readFromFile:(NSString *)path; 48 - (BOOL)_writeToFile:(NSString *)path; 49 50 - (void)_setLaunchesAtBoot:(BOOL)value; 51 51 52 52 @end 53 53 54 54 55 @implementation WCConfigController 56 57 + (WCConfigController *)configController { 58 return sharedConfigController; 59 } 60 61 62 63 - (id)init { 64 self = [super init]; 65 66 sharedConfigController = self; 67 68 return self; 69 } 70 71 72 73 - (void)awakeFromNib { 74 NSComboBoxCell *comboCell; 75 NSMutableArray *array; 76 struct passwd *user; 77 struct group *group; 78 int i; 79 80 // --- load images 81 _okImage = [[NSImage alloc] initWithContentsOfFile: 82 [[self bundle] pathForResource:@"OK" ofType:@"tiff"]]; 83 _errorImage = [[NSImage alloc] initWithContentsOfFile: 84 [[self bundle] pathForResource:@"Error" ofType:@"tiff"]]; 85 86 // --- load users 87 array = [NSMutableArray array]; 88 [_userPopUpButton removeAllItems]; 89 90 while((user = getpwent())) 91 [array addObject:[NSString stringWithCString:user->pw_name]]; 92 93 [array sortUsingSelector:@selector(compare:)]; 94 [_userPopUpButton addItemsWithTitles:array]; 95 96 // --- load groups 97 array = [NSMutableArray array]; 98 [_groupPopUpButton removeAllItems]; 99 100 while((group = getgrent())) 101 [array addObject:[NSString stringWithCString:group->gr_name]]; 102 103 [array sortUsingSelector:@selector(compare:)]; 104 [_groupPopUpButton addItemsWithTitles:array]; 105 106 // --- load syslog facilities 107 array = [NSMutableArray array]; 108 [_syslogPopUpButton removeAllItems]; 109 110 for(i = 0; facilitynames[i].c_name != NULL; i++) 111 [array addObject:[NSString stringWithCString:facilitynames[i].c_name]]; 112 113 [array sortUsingSelector:@selector(compare:)]; 114 [_syslogPopUpButton addItemsWithTitles:array]; 115 116 // --- set table view cells 117 comboCell = [[NSComboBoxCell alloc] init]; 118 [comboCell setControlSize:NSSmallControlSize]; 119 [comboCell addItemsWithObjectValues:[NSArray arrayWithObjects: 120 @"Chat", 121 @"Movies", 122 @"Music", 123 @"Regional/Asia", 124 @"Regional/Europe", 125 @"Regional/Oceania", 126 @"Regional/North America", 127 @"Regional/South America", 128 @"Software", 129 NULL]]; 130 [comboCell setNumberOfVisibleItems:[comboCell numberOfItems]]; 131 [comboCell setEditable:YES]; 132 [_categoryTableColumn setDataCell:comboCell]; 133 [comboCell release]; 134 135 // --- thread progress indicator 136 [_certificateProgressIndicator setUsesThreadedAnimation:YES]; 137 138 // --- subscribe to these 139 [[NSNotificationCenter defaultCenter] 140 addObserver:self 141 selector:@selector(authorizationStatusDidChange:) 142 name:WCAuthorizationStatusDidChange 143 object:NULL]; 144 145 [[NSNotificationCenter defaultCenter] 146 addObserver:self 147 selector:@selector(wiredStatusDidChange:) 148 name:WCWiredStatusDidChange 149 object:NULL]; 150 } 151 152 153 154 - (void)awakeFromController { 155 [self readFromFile:WCExpandWiredPath(@"etc/wired.conf")]; 156 157 [self update]; 158 [self updateCertificate]; 159 } 160 161 162 163 - (BOOL)saveFromController { 164 BOOL status = YES; 165 166 if(_touched) { 167 status = [self writeToFile:WCExpandWiredPath(@"etc/wired.conf")]; 168 169 if(status) { 170 [[NSNotificationCenter defaultCenter] 171 postNotificationName:WCConfigDidChange 172 object:NULL]; 173 174 if(_logTouched) { 175 [[NSNotificationCenter defaultCenter] 176 postNotificationName:WCLogConfigDidChange 177 object:NULL]; 178 179 _logTouched = YES; 180 } 181 } 182 183 [self setLaunchesAtBoot:[_launchAtBootButton state]]; 184 } 185 186 return status; 187 } 188 189 190 191 - (void)dealloc { 192 [[NSNotificationCenter defaultCenter] removeObserver:self]; 193 194 [_okImage release]; 195 [_errorImage release]; 196 197 [super dealloc]; 198 } 199 200 201 202 #pragma mark - 203 204 - (void)authorizationStatusDidChange:(NSNotification *)notification { 205 _authorized = [[notification object] boolValue]; 206 207 [self update]; 208 } 209 210 211 212 - (void)wiredStatusDidChange:(NSNotification *)notification { 213 [self update]; 214 } 215 216 217 218 - (void)controlTextDidChange:(NSNotification *)notification { 219 NSControl *control; 220 221 control = [notification object]; 222 223 if(control == _controlPortTextField) { 224 if([_controlPortTextField intValue] > 0) 225 [_transferPortTextField setIntValue:[_controlPortTextField intValue] + 1]; 226 } 227 else if(control == _logFileTextField) { 228 _logTouched = YES; 229 } 230 231 _touched = YES; 232 } 233 234 235 236 - (void)bannerPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void *)contextInfo { 237 if(returnCode == NSOKButton) { 238 [_bannerImageView setImage:[[[NSImage alloc] initWithContentsOfFile: 239 [[openPanel filenames] objectAtIndex:0]] autorelease]]; 240 [self setBanner:self]; 241 242 _touched = YES; 243 } 244 } 245 246 247 248 - (void)filesPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void *)contextInfo { 249 if(returnCode == NSOKButton) { 250 [_filesTextField setStringValue:[[openPanel filenames] objectAtIndex:0]]; 251 252 _touched = YES; 253 } 254 } 255 256 257 258 - (void)logFilePanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void *)contextInfo { 259 if(returnCode == NSOKButton) { 260 [_logFileTextField setStringValue:[[openPanel filenames] objectAtIndex:0]]; 261 262 _touched = YES; 263 _logTouched = YES; 264 } 265 } 266 267 268 269 #pragma mark - 270 271 - (void)update { 55 @implementation WCConfigController(Private) 56 57 - (void)_update { 272 58 int method; 273 59 BOOL enabled; … … 276 62 method = [[_logMethodMatrix selectedCell] tag]; 277 63 278 // --- enable/disable settings279 64 [_nameTextField setEnabled:enabled]; 280 65 [_controlPortTextField setEnabled:enabled]; … … 296 81 [_createCertificateButton setEnabled:enabled]; 297 82 298 // --- enable/disable advanced299 83 [_registerWithTrackersButton setEnabled:enabled]; 300 84 [_urlTextField setEnabled:enabled]; … … 314 98 [_limitNewsTextField setEnabled:(enabled && [_limitNewsButton state] == NSOnState)]; 315 99 316 // --- enable/disable system317 100 [_userPopUpButton setEnabled:enabled]; 318 101 [_groupPopUpButton setEnabled:enabled]; … … 328 111 329 112 330 - (void) updateCertificate {113 - (void)_updateCertificate { 331 114 NSString *type = NULL; 332 115 FILE *fp; … … 343 126 344 127 if(x509) { 345 // --- get host name346 128 X509_NAME_get_text_by_NID(X509_get_subject_name(x509), 347 129 NID_commonName, hostname, sizeof(hostname)); … … 350 132 size = 8 * EVP_PKEY_size(key); 351 133 352 // --- get type353 134 switch(EVP_PKEY_type(key->type)) { 354 135 case EVP_PKEY_RSA: … … 390 171 #pragma mark - 391 172 392 - (void) readFromFile:(NSString *)path {173 - (void)_readFromFile:(NSString *)path { 393 174 [_config release]; 394 175 _config = [[WCConfig alloc] initWithContentsOfFile:path]; … … 470 251 471 252 472 - (BOOL) writeToFile:(NSString *)path {253 - (BOOL)_writeToFile:(NSString *)path { 473 254 NSString *temp; 474 255 WCAuthorization *authorization; … … 549 330 550 331 if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 551 // --- write directly to file552 332 status = [_config writeToFile:path]; 553 333 } else { 554 // --- write to temporary file555 334 authorization = [WCAuthorization authorization]; 556 335 … … 580 359 #pragma mark - 581 360 582 - (void) setLaunchesAtBoot:(BOOL)value {361 - (void)_setLaunchesAtBoot:(BOOL)value { 583 362 NSFileManager *fileManager; 584 363 NSString *path, *owner, *temp, *string; … … 623 402 } 624 403 404 @end 405 406 407 @implementation WCConfigController 408 409 + (WCConfigController *)configController { 410 return sharedConfigController; 411 } 412 413 414 415 - (id)init { 416 self = [super init]; 417 418 sharedConfigController = self; 419 420 return self; 421 } 422 423 424 425 - (void)awakeFromNib { 426 NSComboBoxCell *comboCell; 427 NSMutableArray *array; 428 struct passwd *user; 429 struct group *group; 430 int i; 431 432 _okImage = [[NSImage alloc] initWithContentsOfFile: 433 [[self bundle] pathForResource:@"OK" ofType:@"tiff"]]; 434 _errorImage = [[NSImage alloc] initWithContentsOfFile: 435 [[self bundle] pathForResource:@"Error" ofType:@"tiff"]]; 436 437 array = [NSMutableArray array]; 438 [_userPopUpButton removeAllItems]; 439 440 while((user = getpwent())) 441 [array addObject:[NSString stringWithCString:user->pw_name]]; 442 443 [array sortUsingSelector:@selector(compare:)]; 444 [_userPopUpButton addItemsWithTitles:array]; 445 446 [array removeAllObjects]; 447 [_groupPopUpButton removeAllItems]; 448 449 while((group = getgrent())) 450 [array addObject:[NSString stringWithCString:group->gr_name]]; 451 452 [array sortUsingSelector:@selector(compare:)]; 453 [_groupPopUpButton addItemsWithTitles:array]; 454 455 [array removeAllObjects]; 456 [_syslogPopUpButton removeAllItems]; 457 458 for(i = 0; facilitynames[i].c_name != NULL; i++) 459 [array addObject:[NSString stringWithCString:facilitynames[i].c_name]]; 460 461 [array sortUsingSelector:@selector(compare:)]; 462 [_syslogPopUpButton addItemsWithTitles:array]; 463 464 comboCell = [[NSComboBoxCell alloc] init]; 465 [comboCell setControlSize:NSSmallControlSize]; 466 [comboCell addItemsWithObjectValues:[NSArray arrayWithObjects: 467 @"Chat", 468 @"Movies", 469 @"Music", 470 @"Regional/Asia", 471 @"Regional/Europe", 472 @"Regional/Oceania", 473 @"Regional/North America", 474 @"Regional/South America", 475 @"Software", 476 NULL]]; 477 [comboCell setNumberOfVisibleItems:[comboCell numberOfItems]]; 478 [comboCell setEditable:YES]; 479 [_categoryTableColumn setDataCell:comboCell]; 480 [comboCell release]; 481 482 [_certificateProgressIndicator setUsesThreadedAnimation:YES]; 483 484 [[NSNotificationCenter defaultCenter] 485 addObserver:self 486 selector:@selector(authorizationStatusDidChange:) 487 name:WCAuthorizationStatusDidChange 488 object:NULL]; 489 490 [[NSNotificationCenter defaultCenter] 491 addObserver:self 492 selector:@selector(wiredStatusDidChange:) 493 name:WCWiredStatusDidChange 494 object:NULL]; 495 } 496 497 498 499 - (void)awakeFromController { 500 [self _readFromFile:WCExpandWiredPath(@"etc/wired.conf")]; 501 502 [self _update]; 503 [self _updateCertificate]; 504 } 505 506 507 508 - (BOOL)saveFromController { 509 BOOL status = YES; 510 511 if(_touched) { 512 status = [self _writeToFile:WCExpandWiredPath(@"etc/wired.conf")]; 513 514 if(status) { 515 [[NSNotificationCenter defaultCenter] 516 postNotificationName:WCConfigDidChange 517 object:NULL]; 518 519 if(_logTouched) { 520 [[NSNotificationCenter defaultCenter] 521 postNotificationName:WCLogConfigDidChange 522 object:NULL]; 523 524 _logTouched = YES; 525 } 526 } 527 528 [self _setLaunchesAtBoot:[_launchAtBootButton state]]; 529 } 530 531 return status; 532 } 533 534 535 536 - (void)dealloc { 537 [[NSNotificationCenter defaultCenter] removeObserver:self]; 538 539 [_okImage release]; 540 [_errorImage release]; 541 542 [super dealloc]; 543 } 544 545 546 547 #pragma mark - 548 &
