Changeset 938

Show
Ignore:
Timestamp:
01/14/05 17:09:23 (4 years ago)
Author:
morris
Message:

Add Show Status In Menu Bar button

Use new WCDashboardController

Files:

Legend:

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

    r923 r938  
    2323                "_cannotBeKickedButton" = NSButton;  
    2424                "_clearNewsButton" = NSButton;  
     25                "_configController" = WCConfigController;  
    2526                "_createAccountsButton" = NSButton;  
    2627                "_createFoldersButton" = NSButton;  
     
    6263                selectLogFile = id;  
    6364                setBanner = id;  
     65                showStatusInMenuBar = id;  
    6466                touch = id;  
    6567            };  
     
    8183                "_controlPortTextField" = NSTextField;  
    8284                "_createCertificateButton" = NSButton;  
     85                "_dashboardController" = WCDashboardController;  
    8386                "_deleteTrackerButton" = NSButton;  
    8487                "_descriptionTextField" = NSTextField;  
     
    102105                "_showDotFilesButton" = NSButton;  
    103106                "_showInvisibleButton" = NSButton;  
     107                "_showStatusInMenuBar" = NSButton;  
    104108                "_syslogPopUpButton" = NSPopUpButton;  
    105109                "_terminateServerOnQuitButton" = NSButton;  
     
    117121        },  
    118122        { 
     123            ACTIONS = { 
     124                indexFiles = id;  
     125                registerWithTracker = id;  
     126                reload = id;  
     127                restart = id;  
     128                start = id;  
     129            };  
     130            CLASS = WCDashboardController;  
     131            LANGUAGE = ObjC;  
     132            OUTLETS = { 
     133                "_indexButton" = NSButton;  
     134                "_registerButton" = NSButton;  
     135                "_reloadButton" = NSButton;  
     136                "_restartButton" = NSButton;  
     137                "_startButton" = NSButton;  
     138                "_statusController" = WCStatusController;  
     139            };  
     140            SUPERCLASS = NSObject;  
     141        },  
     142        { 
    119143            ACTIONS = {filter = id; mark = id; reload = id; };  
    120144            CLASS = WCLogController;  
     
    124148        },  
    125149        { 
    126             ACTIONS = { 
    127                 indexFiles = id;  
    128                 registerWithTracker = id;  
    129                 reload = id;  
    130                 restart = id;  
    131                 start = id;  
    132             };  
    133150            CLASS = WCStatusController;  
    134151            LANGUAGE = ObjC;  
    135152            OUTLETS = { 
    136                 "_bandwidthGraphView" = WCGraphView;  
     153                "_bandwidthGraphView" = ZAGraphView;  
    137154                "_currentDownloadsTextField" = NSTextField;  
    138155                "_currentUploadsTextField" = NSTextField;  
     
    142159                "_dataOutPerSecTextField" = NSTextField;  
    143160                "_dataOutTextField" = NSTextField;  
    144                 "_indexButton" = NSButton;  
    145                 "_registerButton" = NSButton;  
    146                 "_reloadButton" = NSButton;  
    147                 "_restartButton" = NSButton;  
    148                 "_startButton" = NSButton;  
    149161                "_statusTextField" = NSTextField;  
    150162                "_totalDownloadsTextField" = NSTextField;  
    151163                "_totalUploadsTextField" = NSTextField;  
    152164                "_totalUsersTextField" = NSTextField;  
    153                 "_transfersGraphView" = WCGraphView;  
    154                 "_usersGraphView" = WCGraphView;  
     165                "_transfersGraphView" = ZAGraphView;  
     166                "_usersGraphView" = ZAGraphView;  
    155167                "_versionTextField" = NSTextField;  
    156168            };  
     
    162174            LANGUAGE = ObjC;  
    163175            OUTLETS = { 
     176                "_accountsController" = WCAccountsController;  
    164177                "_authorizationStatusButton" = NSButton;  
    165178                "_authorizationStatusTextField" = NSTextField;  
     179                "_configController" = WCConfigController;  
     180                "_dashboardController" = WCDashboardController;  
     181                "_logController" = WCLogController;  
     182                "_statusController" = WCStatusController;  
    166183            };  
    167184            SUPERCLASS = NSPreferencePane;  
  • WiredServer/trunk/Panel/English.lproj/Wired.nib/info.nib

    r923 r938  
    2222        </array> 
    2323        <key>IBSystem Version</key> 
    24         <string>7S215</string> 
     24        <string>7R28</string> 
    2525</dict> 
    2626</plist> 
  • WiredServer/trunk/Panel/WPWired.h

    r923 r938  
    1 /* $Id: WPWired.h,v 1.1 2005/01/07 23:14:20 morris Exp $ */ 
     1/* $Id: WPWired.h,v 1.2 2005/01/14 16:09:23 morris Exp $ */ 
    22 
    33/* 
     
    2828 
    2929@interface WPWired : NSPreferencePane { 
     30        IBOutlet WCAccountsController   *_accountsController; 
     31        IBOutlet WCConfigController             *_configController; 
     32        IBOutlet WCDashboardController  *_dashboardController; 
     33        IBOutlet WCLogController                *_logController; 
     34        IBOutlet WCStatusController             *_statusController; 
     35 
    3036        IBOutlet NSButton                               *_authorizationStatusButton; 
    3137        IBOutlet NSTextField                    *_authorizationStatusTextField; 
  • WiredServer/trunk/Panel/WPWired.m

    r923 r938  
    1 /* $Id: WPWired.m,v 1.1 2005/01/07 23:14:20 morris Exp $ */ 
     1/* $Id: WPWired.m,v 1.2 2005/01/14 16:09:23 morris Exp $ */ 
    22 
    33/* 
     
    2727 */ 
    2828 
    29 #import "WPSettings.h" 
    3029#import "WPWired.h" 
    3130 
     
    3635 
    3736- (void)                        update; 
     37- (void)                        save; 
    3838 
    3939@end 
     
    6060                [[self bundle] pathForResource:@"Unlocked" ofType:@"tiff"]]; 
    6161 
    62         [[WCAccountsController accountsController] setRequiresAuthorization:YES]; 
    63         [[WCConfigController configController] setRequiresAuthorization:YES]; 
    64         [[WCStatusController statusController] setRequiresAuthorization:YES]; 
     62        [_accountsController setRequiresAuthorization:YES]; 
     63        [_configController setRequiresAuthorization:YES]; 
     64        [_dashboardController setRequiresAuthorization:YES]; 
    6565         
    66         [[WCAccountsController accountsController] awakeFromController]; 
    67         [[WCConfigController configController] awakeFromController]; 
    68         [[WCLogController logController] awakeFromController]; 
    69         [[WCStatusController statusController] awakeFromController]; 
     66        [_statusController awakeFromController]; 
     67        [_logController awakeFromController]; 
     68        [_dashboardController awakeFromController]; 
     69        [_configController awakeFromController]; 
     70        [_accountsController awakeFromController]; 
    7071         
    7172        [self update]; 
     
    8081 
    8182- (void)didUnselect { 
    82         BOOL    status = YES; 
    83          
    84         if(status) 
    85                 status = [[WCConfigController configController] saveFromController]; 
    86          
    87         if(status) 
    88                 status = [[WCAccountsController accountsController] saveFromController]; 
     83        [self save]; 
    8984} 
    9085 
     
    9489 
    9590- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem { 
    96         BOOL    status = YES; 
    97          
    98         if(status) 
    99                 status = [[WCConfigController configController] saveFromController]; 
    100          
    101         if(status) 
    102                 status = [[WCAccountsController accountsController] saveFromController]; 
     91        [self save]; 
    10392} 
    10493 
     
    117106                        NSLS(@"Click the lock to make changes.", @"Authorization status")]; 
    118107        } 
     108} 
     109 
     110 
     111 
     112- (void)save { 
     113        BOOL    status = YES; 
     114         
     115        if(status) 
     116                status = [_configController saveFromController]; 
     117         
     118        if(status) 
     119                status = [_accountsController saveFromController]; 
    119120} 
    120121 
  • WiredServer/trunk/WCAccountsController.h

    r923 r938  
    1 /* $Id: WCAccountsController.h,v 1.1 2005/01/07 23:14:19 morris Exp $ */ 
     1/* $Id: WCAccountsController.h,v 1.2 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    3030 
    3131@interface WCAccountsController : NSObject { 
     32        IBOutlet WCConfigController             *_configController; 
     33         
    3234        IBOutlet NSTableView                    *_tableView; 
    3335        IBOutlet NSButton                               *_addButton; 
     
    7173         
    7274        BOOL                                                    _requiresAuthorization; 
     75        BOOL                                                    _authorized; 
    7376        BOOL                                                    _touched; 
    7477} 
  • WiredServer/trunk/WCAccountsController.m

    r931 r938  
    1 /* $Id: WCAccountsController.m,v 1.2 2005/01/09 18:40:04 morris Exp $ */ 
     1/* $Id: WCAccountsController.m,v 1.3 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    9090        [self readUsersFromFile:WCExpandWiredPath(@"users")]; 
    9191        [self readGroupsFromFile:WCExpandWiredPath(@"groups")]; 
     92         
     93        [self selectAccount:[self selectedAccount]]; 
    9294} 
    9395 
     
    128130 
    129131- (void)authorizationStatusDidChange:(NSNotification *)notification { 
     132        _authorized = [[notification object] boolValue]; 
     133 
    130134        [self validateAccount:[self selectedAccount]]; 
    131135} 
     
    166170        WCAccount               *group; 
    167171         
    168         if(!account) 
    169                 return; 
    170          
    171172        // --- populate menu 
    172173        [_groupPopUpButton removeAllItems]; 
     
    181182         
    182183        // --- update interface from account 
    183         [_typePopUpButton selectItemAtIndex: 
    184                 [_typePopUpButton indexOfItemWithTag:[account type]]]; 
    185         [_nameTextField setStringValue:[account name]]; 
    186         [_passwordTextField setStringValue:[account password]]; 
    187          
    188         if([[account group] length] == 0) { 
    189                 [_groupPopUpButton selectItemAtIndex:0]; 
    190         } else { 
    191                 [_groupPopUpButton selectItemWithTitle:[account group]]; 
    192                 account = [_groups accountWithName:[account group]]; 
    193         } 
    194          
    195         [_getUserInfoButton setState:[account getUserInfo]]; 
    196         [_broadcastButton setState:[account broadcast]]; 
    197         [_postNewsButton setState:[account postNews]]; 
    198         [_clearNewsButton setState:[account clearNews]]; 
    199         [_downloadButton setState:[account download]]; 
    200         [_uploadButton setState:[account upload]]; 
    201         [_uploadAnywhereButton setState:[account uploadAnywhere]]; 
    202         [_createFoldersButton setState:[account createFolders]]; 
    203         [_moveFilesButton setState:[account moveFiles]]; 
    204         [_deleteFilesButton setState:[account deleteFiles]]; 
    205         [_viewDropBoxesButton setState:[account viewDropBoxes]]; 
    206         [_createAccountsButton setState:[account createAccounts]]; 
    207         [_editAccountsButton setState:[account editAccounts]]; 
    208         [_deleteAccountsButton setState:[account deleteAccounts]]; 
    209         [_elevatePrivilegesButton setState:[account elevatePrivileges]]; 
    210         [_kickUsersButton setState:[account kickUsers]]; 
    211         [_banUsersButton setState:[account banUsers]]; 
    212         [_cannotBeKickedButton setState:[account cannotBeKicked]]; 
    213         [_setTopicButton setState:[account setTopic]]; 
    214          
    215         if([account downloads] > 0) 
    216                 [_downloadsTextField setIntValue:[account downloads]]; 
    217         else 
    218                 [_downloadsTextField setStringValue:@""]; 
    219          
    220         if([account downloadSpeed] > 0) 
    221                 [_downloadSpeedTextField setIntValue:[account downloadSpeed] / (double) 1024.0]; 
    222         else 
    223                 [_downloadSpeedTextField setStringValue:@""]; 
    224          
    225         if([account uploads] > 0) 
    226                 [_uploadsTextField setIntValue:[account uploads]]; 
    227         else 
    228                 [_uploadsTextField setStringValue:@""]; 
    229          
    230         if([account uploadSpeed] > 0) 
    231                 [_uploadSpeedTextField setIntValue:[account uploadSpeed] / (double) 1024.0]; 
    232         else 
    233                 [_uploadSpeedTextField setStringValue:@""]; 
     184        if(account) { 
     185                [_typePopUpButton selectItemAtIndex: 
     186                        [_typePopUpButton indexOfItemWithTag:[account type]]]; 
     187                [_nameTextField setStringValue:[account name]]; 
     188                [_passwordTextField setStringValue:[account password]]; 
     189                 
     190                if([[account group] length] == 0) { 
     191                        [_groupPopUpButton selectItemAtIndex:0]; 
     192                } else { 
     193                        [_groupPopUpButton selectItemWithTitle:[account group]]; 
     194                        account = [_groups accountWithName:[account group]]; 
     195                } 
     196                 
     197                [_getUserInfoButton setState:[account getUserInfo]]; 
     198                [_broadcastButton setState:[account broadcast]]; 
     199                [_postNewsButton setState:[account postNews]]; 
     200                [_clearNewsButton setState:[account clearNews]]; 
     201                [_downloadButton setState:[account download]]; 
     202                [_uploadButton setState:[account upload]]; 
     203                [_uploadAnywhereButton setState:[account uploadAnywhere]]; 
     204                [_createFoldersButton setState:[account createFolders]]; 
     205                [_moveFilesButton setState:[account moveFiles]]; 
     206                [_deleteFilesButton setState:[account deleteFiles]]; 
     207                [_viewDropBoxesButton setState:[account viewDropBoxes]]; 
     208                [_createAccountsButton setState:[account createAccounts]]; 
     209                [_editAccountsButton setState:[account editAccounts]]; 
     210                [_deleteAccountsButton setState:[account deleteAccounts]]; 
     211                [_elevatePrivilegesButton setState:[account elevatePrivileges]]; 
     212                [_kickUsersButton setState:[account kickUsers]]; 
     213                [_banUsersButton setState:[account banUsers]]; 
     214                [_cannotBeKickedButton setState:[account cannotBeKicked]]; 
     215                [_setTopicButton setState:[account setTopic]]; 
     216                 
     217                if([account downloads] > 0) 
     218                        [_downloadsTextField setIntValue:[account downloads]]; 
     219                else 
     220                        [_downloadsTextField setStringValue:@""]; 
     221                 
     222                if([account downloadSpeed] > 0) 
     223                        [_downloadSpeedTextField setIntValue:[account downloadSpeed] / (double) 1024.0]; 
     224                else 
     225                        [_downloadSpeedTextField setStringValue:@""]; 
     226                 
     227                if([account uploads] > 0) 
     228                        [_uploadsTextField setIntValue:[account uploads]]; 
     229                else 
     230                        [_uploadsTextField setStringValue:@""]; 
     231                 
     232                if([account uploadSpeed] > 0) 
     233                        [_uploadSpeedTextField setIntValue:[account uploadSpeed] / (double) 1024.0]; 
     234                else 
     235                        [_uploadSpeedTextField setStringValue:@""]; 
     236        } 
    234237} 
    235238 
     
    278281        BOOL    authorized; 
    279282         
    280         authorized = [self requiresAuthorization] 
    281                 ? [[WCStatusController statusController] isAuthorized] 
    282                 : YES; 
    283          
    284283        // --- enable/disable basics 
    285         enabled = authorized; 
     284        authorized = [self requiresAuthorization] ? _authorized : YES; 
     285        enabled = authorized && (account != NULL); 
    286286        [_addButton setEnabled:enabled]; 
    287287        [_deleteButton setEnabled:enabled]; 
     
    377377                 
    378378                if(status) { 
    379                         config = [[WCConfigController configController] config]; 
     379                        config = [_configController config]; 
    380380                        status = [authorization changeOwnerOfPath:path 
    381381                                                                                          toOwner:[config stringForKey:@"user"] 
     
    416416                 
    417417                if(status) { 
    418                         config = [[WCConfigController configController] config]; 
     418                        config = [_configController config]; 
    419419                        status = [authorization changeOwnerOfPath:path 
    420420                                                                                          toOwner:[config stringForKey:@"user"] 
  • WiredServer/trunk/WCAuthorization.m

    r923 r938  
    1 /* $Id: WCAuthorization.m,v 1.1 2005/01/07 23:14:19 morris Exp $ */ 
     1/* $Id: WCAuthorization.m,v 1.2 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    113113        [[NSNotificationCenter defaultCenter] 
    114114                postNotificationName:WCAuthorizationStatusDidChange 
    115                 object:self]; 
     115                object:[NSNumber numberWithBool:_authorized]]; 
    116116 
    117117        return YES; 
     
    140140        [[NSNotificationCenter defaultCenter] 
    141141                postNotificationName:WCAuthorizationStatusDidChange 
    142                 object:self]; 
     142                object:[NSNumber numberWithBool:_authorized]]; 
    143143} 
    144144 
     
    188188                [[NSNotificationCenter defaultCenter] 
    189189                        postNotificationName:WCAuthorizationStatusDidChange 
    190                         object:self]; 
     190                        object:[NSNumber numberWithBool:_authorized]]; 
    191191        } 
    192192         
  • WiredServer/trunk/WCConfigController.h

    r923 r938  
    1 /* $Id: WCConfigController.h,v 1.1 2005/01/07 23:14:19 morris Exp $ */ 
     1/* $Id: WCConfigController.h,v 1.2 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    2727 */ 
    2828 
    29 @class WCLogController; 
     29@class WCDashboardController; 
    3030 
    3131@interface WCConfigController : NSObject { 
     32        IBOutlet WCDashboardController  *_dashboardController; 
     33         
    3234        IBOutlet NSPanel                                *_certificatePanel; 
    3335        IBOutlet NSProgressIndicator    *_certificateProgressIndicator; 
     
    4244        IBOutlet NSButton                               *_terminateServerOnQuitButton; 
    4345        IBOutlet NSButton                               *_useRendezvousButton; 
    44         IBOutlet NSButton                               *_launchAtBootButton; 
    4546 
    4647        IBOutlet NSTextField                    *_totalDownloadsTextField; 
     
    7879        IBOutlet NSPopUpButton                  *_groupPopUpButton; 
    7980         
     81        IBOutlet NSButton                               *_launchAtBootButton; 
     82        IBOutlet NSButton                               *_showStatusInMenuBar; 
     83 
    8084        IBOutlet NSMatrix                               *_logMethodMatrix; 
    8185        IBOutlet NSPopUpButton                  *_syslogPopUpButton; 
     
    8993        NSImage                                                 *_okImage, *_errorImage; 
    9094 
     95        BOOL                                                    _requiresAuthorization; 
     96        BOOL                                                    _authorized; 
    9197        BOOL                                                    _touched; 
    9298        BOOL                                                    _logTouched; 
    93         BOOL                                                    _requiresAuthorization; 
    9499} 
    95100 
     
    109114- (BOOL)                                                        requiresAuthorization; 
    110115 
     116- (IBAction)                                            showStatusInMenuBar:(id)sender; 
    111117- (IBAction)                                            touch:(id)sender; 
    112118- (IBAction)                                            setBanner:(id)sender; 
  • WiredServer/trunk/WCConfigController.m

    r929 r938  
    1 /* $Id: WCConfigController.m,v 1.3 2005/01/08 19:30:21 morris Exp $ */ 
     1/* $Id: WCConfigController.m,v 1.4 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    4040- (void)                        readFromFile:(NSString *)path; 
    4141- (BOOL)                        writeToFile:(NSString *)path; 
     42- (void)                        setLaunchesAtBoot:(BOOL)value; 
    4243 
    4344@end 
     
    6364 
    6465- (void)awakeFromNib { 
     66        NSNumber                        *pid; 
    6567        NSComboBoxCell          *comboCell; 
    6668        NSMutableArray          *array; 
     
    7577                [[self bundle] pathForResource:@"Error" ofType:@"tiff"]]; 
    7678 
     79        // --- check if status item is running 
     80        pid = [[NSWorkspace sharedWorkspace] processIdentifierOfCommand:@"Wired Status"]; 
     81        [_showStatusInMenuBar setState:(pid != NULL)]; 
     82         
    7783        // --- load users 
    7884        array = [NSMutableArray array]; 
     
    159165 
    160166                if(status) { 
    161                         // --- note config changed 
    162167                        [[NSNotificationCenter defaultCenter] 
    163168                                postNotificationName:WCConfigDidChange 
    164169                                object:NULL]; 
    165170 
    166                         // --- note log changed 
    167171                        if(_logTouched) { 
    168172                                [[NSNotificationCenter defaultCenter] 
     
    174178                } 
    175179                 
    176                 [[WCStatusController statusController] setLaunchesAtBoot:[_launchAtBootButton state]]; 
     180                [self setLaunchesAtBoot:[_launchAtBootButton state]]; 
    177181        } 
    178182         
     
    196200 
    197201- (void)authorizationStatusDidChange:(NSNotification *)notification { 
     202        _authorized = [[notification object] boolValue]; 
     203 
    198204        [self update]; 
    199         [_trackersTableView setNeedsDisplay:YES]; 
    200205} 
    201206 
     
    265270        BOOL    enabled; 
    266271         
    267         enabled = [self requiresAuthorization] 
    268                 ? [[WCStatusController statusController] isAuthorized] 
    269                 : YES; 
     272        enabled = [self requiresAuthorization] ? _authorized : YES; 
    270273        method = [[_logMethodMatrix selectedCell] tag]; 
    271274 
     
    280283        [_clearBannerButton setEnabled:enabled]; 
    281284        [_useRendezvousButton setEnabled:enabled]; 
    282         [_launchAtBootButton setEnabled:enabled]; 
    283285        [_totalDownloadsTextField setEnabled:enabled]; 
    284286        [_clientDownloadsTextField setEnabled:enabled]; 
     
    303305        [_limitNewsButton setEnabled:enabled]; 
    304306        [_limitNewsTextField setEnabled:(enabled && [_limitNewsButton state] == NSOnState)]; 
    305          
     307        [_trackersTableView setNeedsDisplay:YES]; 
    306308        [_addTrackerButton setEnabled:enabled]; 
    307309        [_deleteTrackerButton setEnabled:(enabled && [_trackersTableView selectedRow] >= 0)]; 
     
    310312        [_userPopUpButton setEnabled:enabled]; 
    311313        [_groupPopUpButton setEnabled:enabled]; 
     314        [_showStatusInMenuBar setEnabled:enabled]; 
     315        [_launchAtBootButton setEnabled:enabled]; 
    312316        [_logMethodMatrix setEnabled:enabled]; 
    313317        [_syslogPopUpButton setEnabled:(enabled && method == WCLogMethodSyslog)]; 
     
    386390        _config = [[WCConfig alloc] initWithContentsOfFile:path]; 
    387391         
    388  
    389392        // --- config 
    390393        if(_terminateServerOnQuitButton) 
     
    640643 
    641644 
     645- (void)setLaunchesAtBoot:(BOOL)value { 
     646        NSFileManager           *fileManager; 
     647        NSString                        *path, *owner, *temp, *string; 
     648        WCAuthorization         *authorization; 
     649        WCConfig                        *config; 
     650        BOOL                            status; 
     651         
     652        authorization = [WCAuthorization authorization]; 
     653        fileManager = [NSFileManager defaultManager]; 
     654        path = WCExpandWiredPath(@"etc/wired.startup"); 
     655         
     656        if(value) { 
     657                string = [[_dashboardController launchArguments] componentsJoinedByString:@" "]; 
     658                owner = [fileManager ownerAtPath:path]; 
     659                 
     660                if(!owner) 
     661                        owner = [fileManager ownerAtPath:[path stringByDeletingLastPathComponent]]; 
     662                 
     663                if([owner isEqualToString:NSUserName()]) { 
     664                        [string writeToFile:path atomically:YES]; 
     665                } 
     666                else if([authorization isAuthorized]) { 
     667                        temp = [NSFileManager temporaryPathWithPrefix:@"wired" suffix:@"startup"]; 
     668                        status = [string writeToFile:temp atomically:YES]; 
     669                         
     670                        if(status) 
     671                                status = [authorization movePath:temp toPath:path]; 
     672                         
     673                        if(status) { 
     674                                config = [self config]; 
     675                                status = [authorization changeOwnerOfPath:path 
     676                                                                                                  toOwner:[config stringForKey:@"user"] 
     677                                                                                                        group:[config stringForKey:@"group"]]; 
     678                        } 
     679                } 
     680        } else { 
     681                if([[fileManager ownerAtPath:path] isEqualToString:NSUserName()]) 
     682                        [fileManager removeFileAtPath:path]; 
     683                else if([authorization isAuthorized]) 
     684                        [authorization removeFileAtPath:path]; 
     685        } 
     686} 
     687 
     688 
     689 
    642690#pragma mark - 
    643691 
     
    933981 
    934982 
     983- (IBAction)showStatusInMenuBar:(id)sender { 
     984        NSString        *path; 
     985        NSNumber        *pid; 
     986         
     987        path = [[self bundle] pathForResource:@"Wired Status" ofType:@"app"]; 
     988        pid = [[NSWorkspace sharedWorkspace] processIdentifierOfCommand:@"Wired Status"]; 
     989         
     990        if([sender state] == NSOnState && !pid) { 
     991                [[NSWorkspace sharedWorkspace] launchApplication:path]; 
     992                [[NSWorkspace sharedWorkspace] addAutoLaunchedApplication:path hide:NO]; 
     993        } 
     994        else if(pid && [pid intValue] > 0) { 
     995                kill([pid intValue], SIGTERM); 
     996                [[NSWorkspace sharedWorkspace] removeAutoLaunchedApplication:path]; 
     997        } 
     998} 
     999 
     1000 
     1001 
    9351002- (IBAction)selectLogFile:(id)sender { 
    9361003        NSOpenPanel             *openPanel; 
     
    10161083        BOOL    enabled; 
    10171084         
    1018         enabled = [self requiresAuthorization] ? [[WCStatusController statusController] isAuthorized] : YES; 
     1085        enabled = [self requiresAuthorization] ? _authorized : YES; 
    10191086        [cell setEnabled:enabled]; 
    10201087        [cell setEditable:enabled]; 
  • WiredServer/trunk/WCSettings.h

    r923 r938  
    1 /* $Id: WCSettings.h,v 1.1 2005/01/07 23:14:20 morris Exp $ */ 
     1/* $Id: WCSettings.h,v 1.2 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    6868+ (void)                                                        setBool:(BOOL)value forKey:(id)key; 
    6969+ (void)                                                        setInt:(int)value forKey:(id)key; 
     70+ (void)                                                        setDouble:(double)value forKey:(id)key; 
    7071 
    7172@end 
  • WiredServer/trunk/WCSettings.m

    r928 r938  
    1 /* $Id: WCSettings.m,v 1.2 2005/01/07 23:18:47 morris Exp $ */ 
     1/* $Id: WCSettings.m,v 1.3 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    4646 
    4747 
    48 #pragma mark - 
    49  
    50  
    5148+ (WCSettings *)settings { 
    5249        static id sharedSettings; 
     
    111108 
    112109        while((key = [enumerator nextObject])) { 
    113                 // --- does object exist in user defaults? 
    114110                object = [defaults objectForKey:key]; 
    115111 
    116112                if(!object) { 
    117                         // --- set default value in defaults 
    118113                        object = [defaultValues objectForKey:key]; 
    119114 
     
    125120 
    126121                if([object isKindOfClass:[NSData class]]) { 
    127                         // --- set unarchived value in settings cache 
    128122                        object = [NSUnarchiver unarchiveObjectWithData:object]; 
    129123 
     
    132126                } 
    133127                else { 
    134                         // --- set simple value in settings cache 
    135128                        [_settings setObject:object forKey:key]; 
    136129                } 
     
    170163        [_lock unlock]; 
    171164 
    172         [NSObject cancelPreviousPerformRequestsWithTarget:defaults selector:@selector(synchronize) object:NULL]; 
    173         [defaults performSelector:@selector(synchronize) withObject:NULL afterDelay:0.1]; 
     165        [defaults performSelectorOnce:@selector(synchronize) withObject:NULL afterDelay:0.1]; 
    174166} 
    175167 
     
    224216} 
    225217 
     218 
     219 
     220+ (void)setDouble:(double)value forKey:(id)key { 
     221        [[self settings] setObject:[NSNumber numberWithDouble:value] forKey:key]; 
     222} 
     223 
    226224@end 
  • WiredServer/trunk/WiredCommon.h

    r929 r938  
    1 /* $Id: WiredCommon.h,v 1.2 2005/01/08 19:30:21 morris Exp $ */ 
     1/* $Id: WiredCommon.h,v 1.3 2005/01/14 16:09:22 morris Exp $ */ 
    22 
    33/* 
     
    3333#import "WCConfig.h" 
    3434#import "WCConfigController.h" 
     35#import "WCDashboardController.h" 
    3536#import "WCLogController.h" 
    3637#import "WCSettings.h"