11 #import "CredentialsInputController.h"
12 #import "RDPSession.h"
17 - (id)initWithNibName:(NSString *)nibNameOrNil
18 bundle:(NSBundle *)nibBundleOrNil
20 params:(NSMutableDictionary *)params
22 self = [
super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
27 [
self setModalPresentationStyle:UIModalPresentationFormSheet];
34 [[NSNotificationCenter defaultCenter] addObserver:self
35 selector:@selector(keyboardWillShow:)
36 name:UIKeyboardWillShowNotification
38 [[NSNotificationCenter defaultCenter] addObserver:self
39 selector:@selector(keyboardWillHide:)
40 name:UIKeyboardWillHideNotification
53 setText:NSLocalizedString(
54 @"Please provide the missing user information in order to proceed and login.",
55 @"Credentials input view message")];
57 setPlaceholder:NSLocalizedString(@"Username", @"Credentials Input Username hint")];
59 setPlaceholder:NSLocalizedString(@"Password", @"Credentials Input Password hint")];
61 setPlaceholder:NSLocalizedString(@"Domain", @"Credentials Input Domain hint")];
62 [_btn_login setTitle:NSLocalizedString(@"Login", @"Login Button")
63 forState:UIControlStateNormal];
64 [_btn_cancel setTitle:NSLocalizedString(@"Cancel", @"Cancel Button")
65 forState:UIControlStateNormal];
68 [_scroll_view setContentSize:[_scroll_view frame].size];
71 [_textfield_username setText:[_params valueForKey:@"username"]];
72 [_textfield_password setText:[_params valueForKey:@"password"]];
73 [_textfield_domain setText:[_params valueForKey:@"domain"]];
78 [
super viewDidUnload];
81 - (void)viewDidDisappear:(BOOL)animated
83 [
super viewDidDisappear:animated];
85 [[_session uiRequestCompleted] signal];
88 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
96 [[NSNotificationCenter defaultCenter] removeObserver:self];
100 #pragma mark iOS Keyboard Notification Handlers
102 - (void)keyboardWillShow:(NSNotification *)notification
104 CGRect keyboardEndFrame =
105 [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
106 CGRect keyboardFrame = [[
self view] convertRect:keyboardEndFrame toView:nil];
108 [UIView beginAnimations:nil context:NULL];
109 [UIView setAnimationCurve:[[[notification userInfo]
110 objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
112 setAnimationDuration:[[[notification userInfo]
113 objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
114 CGRect frame = [_scroll_view frame];
115 frame.size.height -= keyboardFrame.size.height;
116 [_scroll_view setFrame:frame];
117 [UIView commitAnimations];
120 - (void)keyboardWillHide:(NSNotification *)notification
122 CGRect keyboardEndFrame =
123 [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
124 CGRect keyboardFrame = [[
self view] convertRect:keyboardEndFrame toView:nil];
126 [UIView beginAnimations:nil context:NULL];
127 [UIView setAnimationCurve:[[[notification userInfo]
128 objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
130 setAnimationDuration:[[[notification userInfo]
131 objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
132 CGRect frame = [_scroll_view frame];
133 frame.size.height += keyboardFrame.size.height;
134 [_scroll_view setFrame:frame];
135 [UIView commitAnimations];
138 #pragma mark - Action handlers
140 - (IBAction)loginPressed:(
id)sender
143 [_params setValue:[_textfield_username text] forKey:@"username"];
144 [_params setValue:[_textfield_password text] forKey:@"password"];
145 [_params setValue:[_textfield_domain text] forKey:@"domain"];
146 [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
149 [
self dismissModalViewControllerAnimated:YES];
152 - (IBAction)cancelPressed:(
id)sender
154 [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
157 [
self dismissModalViewControllerAnimated:YES];