Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
NanoTech
2010-06-17 15:49:54 -0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c8fb0aba99d36bfcdc631ad844351571e9dfa54b
c8fb0aba
1 parent
e305f0b9
Don't disable the auth dialog login button, but ensure username and password are never nil.
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
39 deletions
Classes/ASIAuthenticationDialog.h
Classes/ASIAuthenticationDialog.m
Classes/ASIAuthenticationDialog.h
View file @
c8fb0ab
...
...
@@ -17,12 +17,11 @@ typedef enum _ASIAuthenticationType {
@interface
ASIAutorotatingViewController
:
UIViewController
@end
@interface
ASIAuthenticationDialog
:
ASIAutorotatingViewController
<
UIActionSheetDelegate
,
UITableViewDelegate
,
UITableViewDataSource
,
UITextFieldDelegate
>
{
@interface
ASIAuthenticationDialog
:
ASIAutorotatingViewController
<
UIActionSheetDelegate
,
UITableViewDelegate
,
UITableViewDataSource
>
{
ASIHTTPRequest
*
request
;
ASIAuthenticationType
type
;
UITableView
*
tableView
;
UIViewController
*
presentingController
;
UIBarButtonItem
*
loginButton
;
}
+
(
void
)
presentAuthenticationDialogForRequest
:
(
ASIHTTPRequest
*
)
request
;
+
(
void
)
presentProxyAuthenticationDialogForRequest
:(
ASIHTTPRequest
*
)
request
;
...
...
Classes/ASIAuthenticationDialog.m
View file @
c8fb0ab
...
...
@@ -39,7 +39,6 @@ static const NSUInteger kDomainSection = 1;
@interface
ASIAuthenticationDialog
()
-
(
void
)
show
;
@property
(
retain
)
UITableView
*
tableView
;
@property
(
retain
)
UIBarButtonItem
*
loginButton
;
@end
@implementation
ASIAuthenticationDialog
...
...
@@ -95,7 +94,6 @@ static const NSUInteger kDomainSection = 1;
[
request
release
];
[
tableView
release
];
[
loginButton
release
];
[
presentingController
.
view
removeFromSuperview
];
[
presentingController
release
];
[
super
dealloc
];
...
...
@@ -209,10 +207,8 @@ static const NSUInteger kDomainSection = 1;
[
navItem
setTitle
:[[[
self
request
]
url
]
host
]];
}
[
self
setLoginButton
:[[
UIBarButtonItem
alloc
]
initWithTitle
:
@"Login"
style
:
UIBarButtonItemStyleDone
target
:
self
action
:
@selector
(
loginWithCredentialsFromDialog
:
)]];
[
navItem
setLeftBarButtonItem
:[[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemCancel
target
:
self
action
:
@selector
(
cancelAuthenticationFromDialog
:)]
autorelease
]];
[
navItem
setRightBarButtonItem
:
loginButton
];
loginButton
.
enabled
=
NO
;
[
navItem
setRightBarButtonItem
:[[[
UIBarButtonItem
alloc
]
initWithTitle
:
@"Login"
style
:
UIBarButtonItemStyleDone
target
:
self
action
:
@selector
(
loginWithCredentialsFromDialog
:)]
autorelease
]];
// We show the login form in a table view, similar to Safari's authentication dialog
[
bar
sizeToFit
];
...
...
@@ -252,6 +248,9 @@ static const NSUInteger kDomainSection = 1;
NSString
*
username
=
[[
self
usernameField
]
text
];
NSString
*
password
=
[[
self
passwordField
]
text
];
if
(
username
==
nil
)
{
username
=
@""
;
}
if
(
password
==
nil
)
{
password
=
@""
;
}
if
([
self
type
]
==
ASIProxyAuthenticationType
)
{
[[
self
request
]
setProxyUsername
:
username
];
[[
self
request
]
setProxyPassword
:
password
];
...
...
@@ -329,7 +328,6 @@ static const NSUInteger kDomainSection = 1;
[
textField
setAutoresizingMask
:
UIViewAutoresizingFlexibleWidth
|
UIViewAutoresizingFlexibleHeight
];
[
textField
setAutocapitalizationType
:
UITextAutocapitalizationTypeNone
];
[
textField
setAutocorrectionType
:
UITextAutocorrectionTypeNo
];
[
textField
setDelegate
:
self
];
NSUInteger
s
=
[
indexPath
section
];
NSUInteger
r
=
[
indexPath
row
];
...
...
@@ -370,40 +368,9 @@ static const NSUInteger kDomainSection = 1;
return
nil
;
}
#pragma mark text field delegates
-
(
BOOL
)
textField
:
(
UITextField
*
)
textField
shouldChangeCharactersInRange
:
(
NSRange
)
range
replacementString
:
(
NSString
*
)
string
{
NSString
*
newString
=
[[
textField
text
]
stringByReplacingCharactersInRange
:
range
withString
:
string
];
NSArray
*
fields
=
[
NSArray
arrayWithObjects
:
[
self
usernameField
],
[
self
passwordField
],
[
self
domainField
],
// ends the array early if not set
nil
];
BOOL
allFilled
=
YES
;
for
(
UITextField
*
field
in
fields
)
{
NSString
*
text
=
nil
;
if
(
field
==
textField
)
{
text
=
newString
;
}
else
{
text
=
[
field
text
];
}
if
([
text
length
]
==
0
)
{
allFilled
=
NO
;
break
;
}
}
loginButton
.
enabled
=
allFilled
;
return
YES
;
}
#pragma mark -
@synthesize
request
;
@synthesize
type
;
@synthesize
tableView
;
@synthesize
loginButton
;
@end
...
...
Please
register
or
login
to post a comment