AFS Backgrounder implementation & warirng clean
[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         NSLog(@"init AFSMenuCredentialContoller");
22         return  [self init];
23 }
24
25 - (void)dealloc {
26         NSLog(@"dealloc AFSMenuCredentialContoller");
27         if(credentialWindow) [credentialWindow release];
28     [super dealloc];
29         
30 } // dealloc
31
32 -(void) showWindow
33 {       
34         // calculate the point where show the window
35         NSPoint topLeft = {viewRect.origin.x-160,[[NSScreen mainScreen] frame].size.height-kMenuBarHeight};
36         NSLog(@"viewRect.origin.x=%d, topLeft.x=%d", viewRect.origin.x, topLeft.x);
37         // load the bundle for
38         [NSBundle loadNibNamed:@"CredentialWindow.nib" owner:self];
39         NSLog(@"prepare to open window CredentialWindow");
40
41         credentialWindow = [[NSWindow alloc] initWithContentRect:[((NSView*) credentialView) frame]
42                                                                                                    styleMask:NSTitledWindowMask /*| NSUtilityWindowMask*/
43                                                                                                          backing:NSBackingStoreBuffered
44                                                                                                            defer:YES screen:[NSScreen mainScreen]];
45         NSLog(@"Finestra");
46         [credentialWindow setTitle:@"Klog"];
47         [credentialWindow setFrameTopLeftPoint:topLeft];
48         [credentialWindow setContentView:credentialView];
49         [credentialWindow makeKeyAndOrderFront:self];
50         NSLog(@"creata");
51         
52 }
53
54 -(void) closeWindow
55 {
56         NSLog(@"closeWindow");
57         if([(CredentialWindowController*)credWinController takenToken] && afsPropMngr) {
58                 [afsPropMngr getTokens:true 
59                                                    usr:[(CredentialWindowController*)credWinController uName] 
60                                                    pwd:[(CredentialWindowController*)credWinController uPwd]];
61                 [afsPropMngr release];
62                 afsPropMngr = nil;
63         }
64         [credentialWindow close];
65         credentialWindow = nil;
66 }
67 @end