Changeset 3675

Show
Ignore:
Timestamp:
02/06/06 00:39:52 (3 years ago)
Author:
morris
Message:

Clean up a bit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/classes.nib

    r3408 r3675  
    3131                "_downloadButton" = NSButton;  
    3232                "_downloadSpeedTextField" = NSTextField;  
    33                 "_downloadsTextField" = NSTextField;  
    3433                "_editAccountsButton" = NSButton;  
    3534                "_elevatePrivilegesButton" = NSButton;  
     
    4746                "_uploadButton" = NSButton;  
    4847                "_uploadSpeedTextField" = NSTextField;  
    49                 "_uploadsTextField" = NSTextField;  
    5048                "_viewDropBoxesButton" = NSButton;  
    5149            };  
  • WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/info.nib

    r3408 r3675  
    1212        </array> 
    1313        <key>IBSystem Version</key> 
    14         <string>8F46</string> 
     14        <string>8G32</string> 
    1515</dict> 
    1616</plist> 
  • WiredServer/trunk/PreferencePane/prefix.pch

    r3403 r3675  
    3232#import <Security/Authorization.h> 
    3333#import <Security/AuthorizationTags.h> 
     34#import <SecurityInterface/SFAuthorizationView.h> 
    3435#import <WiredAdditions/WiredAdditions.h> 
    3536 
  • WiredServer/trunk/WCAccountsController.h

    r3011 r3675  
    6161        IBOutlet NSButton                               *_setTopicButton; 
    6262         
    63       IBOutlet NSTextField                    *_downloadsTextField; 
     63//    IBOutlet NSTextField                    *_downloadsTextField; 
    6464        IBOutlet NSTextField                    *_downloadSpeedTextField; 
    65       IBOutlet NSTextField                    *_uploadsTextField; 
     65//    IBOutlet NSTextField                    *_uploadsTextField; 
    6666        IBOutlet NSTextField                    *_uploadSpeedTextField; 
    6767 
  • WiredServer/trunk/WCAccountsController.m

    r3403 r3675  
    3434#import "WCSettings.h" 
    3535 
     36static WCAccountsController                     *sharedAccountsController; 
     37 
     38 
    3639@interface WCAccountsController(Private) 
    3740 
    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; 
    4951 
    5052@end 
    5153 
    5254 
    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 { 
    16358        int             row; 
    16459         
     
    17368 
    17469 
    175 - (void)selectAccount:(WCAccount *)account { 
     70#pragma mark - 
     71 
     72- (void)_selectAccount:(WCAccount *)account { 
    17673        NSEnumerator    *enumerator; 
    17774        WCAccount               *group; 
    17875         
    179         // --- populate menu 
    18076        [_groupPopUpButton removeAllItems]; 
    18177        [_groupPopUpButton addItemWithTitle:WCLS(@"none", "Group menu item")]; 
     
    18581                [_groupPopUpButton addItemWithTitle:[group name]]; 
    18682         
    187         // --- validate interface 
    188         [self validateAccount:account]; 
    189          
    190         // --- update interface from account 
     83        [self _validateAccount:account]; 
     84         
    19185        if(account) { 
    19286                [_typePopUpButton selectItemAtIndex: 
     
    222116                [_setTopicButton setState:[account setTopic]]; 
    223117                 
    224               if([account downloads] > 0) 
     118/*            if([account downloads] > 0) 
    225119                        [_downloadsTextField setIntValue:[account downloads]]; 
    226120                else 
    227                         [_downloadsTextField setStringValue:@""]; 
     121                        [_downloadsTextField setStringValue:@""];*/ 
    228122                 
    229123                if([account downloadSpeed] > 0) 
     
    232126                        [_downloadSpeedTextField setStringValue:@""]; 
    233127                 
    234               if([account uploads] > 0) 
     128/*            if([account uploads] > 0) 
    235129                        [_uploadsTextField setIntValue:[account uploads]]; 
    236130                else 
    237                         [_uploadsTextField setStringValue:@""]; 
     131                        [_uploadsTextField setStringValue:@""];*/ 
    238132                 
    239133                if([account uploadSpeed] > 0) 
     
    248142 
    249143 
    250 - (void)unselectAccount:(WCAccount *)account { 
     144- (void)_unselectAccount:(WCAccount *)account { 
    251145        if(!_selected) 
    252146                return; 
    253147         
    254         // --- update account from interface 
    255148        [account setName:[_nameTextField stringValue]]; 
    256149        [account setPassword:[_passwordTextField stringValue]]; 
     
    281174        [account setSetTopic:[_setTopicButton state]]; 
    282175         
    283       [account setDownloads:[_downloadsTextField intValue]]; 
     176//    [account setDownloads:[_downloadsTextField intValue]]; 
    284177        [account setDownloadSpeed:[_downloadSpeedTextField intValue] * 1024]; 
    285       [account setUploads:[_uploadsTextField intValue]]; 
     178//    [account setUploads:[_uploadsTextField intValue]]; 
    286179        [account setUploadSpeed:[_uploadSpeedTextField intValue] * 1024]; 
    287180         
     
    291184 
    292185 
    293 - (void)validateAccount:(WCAccount *)account { 
     186- (void)_validateAccount:(WCAccount *)account { 
    294187        BOOL    enabled; 
    295188        BOOL    authorized; 
    296189         
    297         // --- enable/disable basics 
    298190        authorized = [self requiresAuthorization] ? _authorized : YES; 
    299191        enabled = authorized && (account != NULL); 
     
    303195        [_nameTextField setEnabled:enabled]; 
    304196         
    305         // --- enable/disable user controls 
    306197        enabled = (authorized && [account type] == WCAccountUser); 
    307198        [_passwordTextField setEnabled:enabled]; 
    308199        [_groupPopUpButton setEnabled:enabled]; 
    309200         
    310         // --- enable/disable privileges 
    311201        enabled = (authorized && [[account group] length] == 0); 
    312202        [_getUserInfoButton setEnabled:enabled]; 
     
    329219        [_cannotBeKickedButton setEnabled:enabled]; 
    330220        [_setTopicButton setEnabled:enabled]; 
    331       [_downloadsTextField setEnabled:enabled]; 
     221//    [_downloadsTextField setEnabled:enabled]; 
    332222        [_downloadSpeedTextField setEnabled:enabled]; 
    333       [_uploadsTextField setEnabled:enabled]; 
     223//    [_uploadsTextField setEnabled:enabled]; 
    334224        [_uploadSpeedTextField setEnabled:enabled]; 
    335225} 
     
    339229#pragma mark - 
    340230 
    341 - (void)readUsersFromFile:(NSString *)path { 
     231- (void)_readUsersFromFile:(NSString *)path { 
    342232        [_accounts removeObjectsInArray:[_users accounts]]; 
    343233        [_users release]; 
     
    348238 
    349239        [_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 { 
    356247        [_accounts removeObjectsInArray:[_groups accounts]]; 
    357248        [_groups release]; 
     
    362253 
    363254        [_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 { 
    370262        NSString                *temp; 
    371263        WCAuthorization *authorization; 
     
    373265        BOOL                    status = YES; 
    374266         
    375         [self unselectAccount:[self selectedAccount]]; 
     267        [self _unselectAccount:[self _selectedAccount]]; 
    376268         
    377269        if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 
    378                 // --- write directly to file 
    379270                status = [_users writeToFile:path]; 
    380271        } else { 
    381                 // --- write users to temporary file 
    382272                authorization = [WCAuthorization authorization]; 
    383273                 
     
    406296 
    407297 
    408 - (BOOL)writeGroupsToFile:(NSString *)path { 
     298- (BOOL)_writeGroupsToFile:(NSString *)path { 
    409299        NSString                *temp; 
    410300        WCAuthorization *authorization; 
     
    412302        BOOL                    status = YES; 
    413303         
    414         [self unselectAccount:[self selectedAccount]]; 
     304        [self _unselectAccount:[self _selectedAccount]]; 
    415305 
    416306        if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 
    417                 // --- write directly to file 
    418307                status = [_groups writeToFile:path]; 
    419308        } else { 
    420                 // --- write groups to temporary file 
    421309                authorization = [WCAuthorization authorization]; 
    422310 
     
    443331} 
    444332 
     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 
    445441 
    446442 
     
    495491        WCAccount               *account, *user; 
    496492         
    497         account = [self selectedAccount]; 
     493        account = [self _selectedAccount]; 
    498494         
    499495        if([account type] == WCAccountGroup) { 
     
    523519        WCAccount   *account; 
    524520         
    525         account = [self selectedAccount]; 
     521        account = [self _selectedAccount]; 
    526522        [account setType:[[_typePopUpButton selectedItem] tag]]; 
    527523         
     
    545541         
    546542        [_tableView reloadData]; 
    547         [self selectAccount:account]; 
     543         
     544        [self _selectAccount:account]; 
    548545} 
    549546 
     
    553550        WCAccount   *account; 
    554551         
    555         account = [self selectedAccount]; 
     552        account = [self _selectedAccount]; 
    556553         
    557554        if([_groupPopUpButton indexOfSelectedItem] == 0) 
     
    562559        _touched = YES; 
    563560         
    564         [self selectAccount:account]; 
     561        [self _selectAccount:account]; 
    565562} 
    566563 
     
    591588 
    592589- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row { 
    593         [self unselectAccount:[self selectedAccount]]; 
     590        [self _unselectAccount:[self _selectedAccount]]; 
    594591         
    595592        return YES; 
     
    599596 
    600597- (void)tableViewSelectionDidChange:(NSNotification *)notification { 
    601         [self selectAccount:[self selectedAccount]]; 
     598        [self _selectAccount:[self _selectedAccount]]; 
    602599} 
    603600 
  • WiredServer/trunk/WCConfigController.m

    r3403 r3675  
    3838#import "WCStatusController.h" 
    3939 
     40static WCConfigController               *sharedConfigController; 
     41 
    4042@interface WCConfigController(Private) 
    4143 
    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; 
    5151 
    5252@end 
    5353 
    5454 
    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 { 
    27258        int             method; 
    27359        BOOL    enabled; 
     
    27662        method = [[_logMethodMatrix selectedCell] tag]; 
    27763 
    278         // --- enable/disable settings 
    27964        [_nameTextField setEnabled:enabled]; 
    28065        [_controlPortTextField setEnabled:enabled]; 
     
    29681        [_createCertificateButton setEnabled:enabled]; 
    29782         
    298         // --- enable/disable advanced 
    29983        [_registerWithTrackersButton setEnabled:enabled]; 
    30084        [_urlTextField setEnabled:enabled]; 
     
    31498        [_limitNewsTextField setEnabled:(enabled && [_limitNewsButton state] == NSOnState)]; 
    31599 
    316         // --- enable/disable system 
    317100        [_userPopUpButton setEnabled:enabled]; 
    318101        [_groupPopUpButton setEnabled:enabled]; 
     
    328111 
    329112 
    330 - (void)updateCertificate { 
     113- (void)_updateCertificate { 
    331114         NSString               *type = NULL; 
    332115         FILE                   *fp; 
     
    343126                  
    344127                 if(x509) { 
    345                          // --- get host name 
    346128                         X509_NAME_get_text_by_NID(X509_get_subject_name(x509), 
    347129                                                                           NID_commonName, hostname, sizeof(hostname)); 
     
    350132                         size = 8 * EVP_PKEY_size(key); 
    351133                          
    352                          // --- get type 
    353134                         switch(EVP_PKEY_type(key->type)) { 
    354135                                 case EVP_PKEY_RSA: 
     
    390171#pragma mark - 
    391172 
    392 - (void)readFromFile:(NSString *)path { 
     173- (void)_readFromFile:(NSString *)path { 
    393174        [_config release]; 
    394175        _config = [[WCConfig alloc] initWithContentsOfFile:path]; 
     
    470251 
    471252 
    472 - (BOOL)writeToFile:(NSString *)path { 
     253- (BOOL)_writeToFile:(NSString *)path { 
    473254        NSString                *temp; 
    474255        WCAuthorization *authorization; 
     
    549330         
    550331        if([[[NSFileManager defaultManager] ownerAtPath:path] isEqualToString:NSUserName()]) { 
    551                 // --- write directly to file 
    552332                status = [_config writeToFile:path]; 
    553333        } else { 
    554                 // --- write to temporary file 
    555334                authorization = [WCAuthorization authorization]; 
    556335 
     
    580359#pragma mark - 
    581360 
    582 - (void)setLaunchesAtBoot:(BOOL)value { 
     361- (void)_setLaunchesAtBoot:(BOOL)value { 
    583362        NSFileManager           *fileManager; 
    584363        NSString                        *path, *owner, *temp, *string; 
     
    623402} 
    624403 
     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 
    &