Changeset 639
- Timestamp:
- 01/12/10 12:51:19 (2 months ago)
- Location:
- apps/iphone/my.tel/trunk
- Files:
-
- 5 modified
-
Classes/AccountEditController.m (modified) (3 diffs)
-
Classes/MyTelConnect.m (modified) (1 diff)
-
Classes/RootViewController.h (modified) (1 diff)
-
Classes/RootViewController.m (modified) (10 diffs)
-
VIP.tel.xcodeproj/project.pbxproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/Classes/AccountEditController.m
r626 r639 231 231 #pragma mark UITextFieldDelegate methods 232 232 233 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range 234 replacementString:(NSString *)string { 235 // Always reset the api root url if the domain name changes 236 if (textField == cellDomainName.textField) { 237 self.apiRootUrl = @""; 238 [cellApiRootUrl setNeedsDisplay]; 239 } 240 return YES; 241 } 242 233 243 - (void)textFieldDidEndEditing:(UITextField *)textField { 234 244 // Clean data entry as necessary … … 237 247 self.domainName = [self.domainName stringByAppendingString:@".tel"]; 238 248 } 239 if ( [self.accountLabel length] == 0) {249 if ((self.accountLabel == nil) || ([self.accountLabel length] == 0)) { 240 250 self.accountLabel = self.domainName; 241 251 } … … 260 270 [self performSelector:@selector(self) withObject:nil afterDelay:0.1]; 261 271 262 if ( [self.accountLabel length] == 0) {272 if ((self.accountLabel == nil) || ([self.accountLabel length] == 0)) { 263 273 self.accountLabel = self.domainName; 274 } 275 if (self.userName == nil) { 276 self.userName = @""; 277 } 278 if (self.password == nil) { 279 self.password = @""; 264 280 } 265 281 -
apps/iphone/my.tel/trunk/Classes/MyTelConnect.m
r612 r639 39 39 delegate:(id)aDelegate 40 40 selector:(SEL)aSel { 41 42 if ((aName == nil) || (aPassword == nil)) { 43 SBJSON *json = [[SBJSON new] autorelease]; 44 NSError *jsonError; 45 NSDictionary *parsedJSON = [json objectWithString:@"{\"success\":false;\"actionMessages\":\"bad username or password\"}" error:&jsonError]; 46 [aDelegate performSelector:aSel withObject:parsedJSON]; 47 return; 48 } 41 49 42 50 NSDictionary *loginInfo = [NSDictionary dictionaryWithObjectsAndKeys: -
apps/iphone/my.tel/trunk/Classes/RootViewController.h
r612 r639 29 29 NSString *dataFilePath; 30 30 NSMutableArray *accountsArray; 31 NSUInteger currentDomainIndex; // index of the current domain in the current account (set from the account view controller) 32 @private 33 BOOL mustLogin; 31 34 NSUInteger currentAccountIndex; // accountsArray index of the account being edited or viewed 32 NSUInteger currentDomainIndex; // index of the current domain in the current account (set from the account view controller)33 35 } 34 36 -
apps/iphone/my.tel/trunk/Classes/RootViewController.m
r626 r639 9 9 #import "RootViewController.h" 10 10 11 @interface RootViewController (PrivateMethods) 12 13 - (void)setCurrentAccountIndex:(NSUInteger)index; 14 15 @end 11 16 12 17 @implementation RootViewController … … 24 29 if (self = [super initWithStyle:style]) { 25 30 currentAccountIndex = NSUIntegerMax; 31 mustLogin = YES; 26 32 [self loadData]; 27 33 } … … 126 132 } 127 133 134 - (void)setCurrentAccountIndex:(NSUInteger)index { 135 if (index != currentAccountIndex) { 136 currentAccountIndex = index; 137 mustLogin = YES; 138 } 139 } 140 128 141 - (void)loginToCurrentAccount { 129 142 if (currentAccountIndex == NSUIntegerMax) { … … 132 145 return; 133 146 } 134 return [self loginToAccountAtIndex:currentAccountIndex forced: YES];147 return [self loginToAccountAtIndex:currentAccountIndex forced:mustLogin]; 135 148 } 136 149 137 150 - (void)loginToAccountAtIndex:(NSUInteger)accountIndex forced:(BOOL)forced{ 138 if (forced || (accountIndex != currentAccountIndex)) { 139 currentAccountIndex = accountIndex; 151 if (currentAccountIndex == NSUIntegerMax) 152 return; 153 [self setCurrentAccountIndex:accountIndex]; 154 if (forced || mustLogin) { 140 155 NSDictionary *selectedAccount = [self.accountsArray objectAtIndex:currentAccountIndex]; 141 156 [[[UIApplication sharedApplication] keyWindow] addSubview:[MyTelConnect sharedInstance].view]; … … 156 171 157 172 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 158 // Success. Go to account if there's no account, otherwise do nothing 173 // Success. Go to account if there's no account visible 174 mustLogin = NO; 159 175 if (self.navigationController.topViewController == self) { 160 176 [self displayControllerForAccountAtIndex:currentAccountIndex]; … … 163 179 } else { 164 180 // Failed. Get back to the root 165 currentAccountIndex = NSUIntegerMax; 181 NSDictionary *failedAccount = self.currentAccount; 182 [self setCurrentAccountIndex:NSUIntegerMax]; 166 183 [self.navigationController popToRootViewControllerAnimated:NO]; 184 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[failedAccount objectForKey:@"accountLabel"] 185 message:[[parsedJson valueForKey:@"actionErrors"] objectAtIndex:0] 186 delegate:nil 187 cancelButtonTitle:NSLocalizedString(@"OK", nil) 188 otherButtonTitles:nil]; 189 [alertView show]; 190 [alertView release]; 167 191 } 168 192 } … … 195 219 NSArray *indexPaths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:currentAccountIndex inSection:kKRootTableViewSectionAccounts]]; 196 220 [self.tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade]; 197 currentAccountIndex = NSUIntegerMax;221 [self setCurrentAccountIndex:NSUIntegerMax]; 198 222 [self saveData]; 199 223 } … … 272 296 case kKRootTableViewSectionAccounts: 273 297 if (self.tableView.editing) { // in edit mode, open the account edit view 274 [self editAccountAtIndex:indexPath.row]; 298 [self setCurrentAccountIndex:indexPath.row]; 299 [self objectWillGetEditedInController:self]; 275 300 } else { // in non-edit mode, login and move to the account 276 301 [self loginToAccountAtIndex:indexPath.row forced:NO]; … … 278 303 break; 279 304 case kKRootTableViewSectionAddAccount: 305 [self setCurrentAccountIndex:NSUIntegerMax]; 280 306 eVC = [[AccountEditController new] autorelease]; 281 307 eVC.delegate = self; … … 411 437 } 412 438 [self saveData]; 439 mustLogin = YES; 413 440 } 414 441 } -
apps/iphone/my.tel/trunk/VIP.tel.xcodeproj/project.pbxproj
r637 r639 1091 1091 GCC_WARN_UNUSED_VARIABLE = YES; 1092 1092 PREBINDING = NO; 1093 PROVISIONING_PROFILE = "8073E846-129F-4458-A198-31367F83CF72"; 1093 1094 SDKROOT = iphoneos3.0; 1094 1095 };








