macos: update AFS prefs pane
[openafs.git] / src / platform / DARWIN / AFSPreference / AFSBackgrounder / AFSMenuCredentialContoller.m
1 //
2 //  AFSMenuCredentialContoller.m
3 //  AFSCommander
4 //
5 //  Created by Claudio on 14/07/07.
6 //  Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
7 //
8
9 #import "AFSMenuCredentialContoller.h"
10 #import "CredentialWindowController.h"
11 #import "global.h"
12 #import "AFSPropertyManager.h"
13
14 @implementation AFSMenuCredentialContoller
15
16 -(id) initWhitRec:(NSRect)rect  afsPropManager:(AFSPropertyManager*)afsPropManager;
17 {
18         viewRect = rect;
19         credentialWindow = nil;
20         afsPropMngr = [afsPropManager retain];
21         return  [self init];
22 }
23
24 - (void)dealloc {
25         if(credentialWindow) [credentialWindow release];
26     [super dealloc];
27         
28 } // dealloc
29
30 -(void) showWindow
31 {       
32         // calculate the point where show the window
33         NSPoint topLeft = {viewRect.origin.x-160,[[NSScreen mainScreen] frame].size.height-kMenuBarHeight};
34         // load the bundle for
35         [NSBundle loadNibNamed:@"CredentialWindow.nib" owner:self];
36
37         credentialWindow = [[NSWindow alloc] initWithContentRect:[((NSView*) credentialView) frame]
38                                                                                                    styleMask:NSTitledWindowMask /*| NSUtilityWindowMask*/
39                                                                                                          backing:NSBackingStoreBuffered
40                                                                                                            defer:YES screen:[NSScreen mainScreen]];
41         [credentialWindow setTitle:@"Klog"];
42         [credentialWindow setFrameTopLeftPoint:topLeft];
43         [credentialWindow setContentView:credentialView];
44         [credentialWindow makeKeyAndOrderFront:self];
45 }
46
47 -(void) closeWindow
48 {
49         if([(CredentialWindowController*)credWinController takenToken] && afsPropMngr) {
50                 [afsPropMngr getTokens:true 
51                                                    usr:[(CredentialWindowController*)credWinController uName] 
52                                                    pwd:[(CredentialWindowController*)credWinController uPwd]];
53                 [afsPropMngr release];
54                 afsPropMngr = nil;
55         }
56         [credentialWindow close];
57         credentialWindow = nil;
58 }
59 @end