Changeset 442 for apps/iphone/superbook/trunk
- Timestamp:
- 07/07/09 16:22:41 (4 years ago)
- Location:
- apps/iphone/superbook/trunk/Classes
- Files:
-
- 4 modified
-
FriendsData.m (modified) (1 diff)
-
LocateThem_ViewController.m (modified) (2 diffs)
-
NaptrViewController.h (modified) (1 diff)
-
NaptrViewController.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/superbook/trunk/Classes/FriendsData.m
r408 r442 371 371 if (shouldRelease) { 372 372 CFRelease(recordRef); 373 //CFRelease(theBook); // TODO: why is this crashing?374 373 } 375 374 if (foundUrl) { 376 NS MutableString *cleanTelUrl = [NSMutableString stringWithString:(NSString *)telUrl];375 NSString *returnedTelUrl = [NSString stringWithString:(NSString *)telUrl]; 377 376 CFRelease(telUrl); 378 if ([cleanTelUrl hasSuffix:@".tel/"]) { 379 // Remove the trailing slash 380 [cleanTelUrl deleteCharactersInRange:NSMakeRange([cleanTelUrl length]-1, 1)]; 381 } 382 if ([cleanTelUrl hasPrefix:@"http://"]) { 383 NSString *retStr = [cleanTelUrl substringFromIndex:[@"http://" length]]; 384 return retStr; 385 } else if ([(NSString *)telUrl hasPrefix:@"https://"]) { 386 NSString *retStr = [cleanTelUrl substringFromIndex:[@"https://" length]]; 387 return retStr; 388 } else { 389 return cleanTelUrl; 390 } 377 return returnedTelUrl; 391 378 } 392 379 -
apps/iphone/superbook/trunk/Classes/LocateThem_ViewController.m
r418 r442 233 233 NaptrViewController *nVC = [[[NaptrViewController alloc] initWithNibName:@"TelView" bundle:[NSBundle mainBundle]] autorelease]; 234 234 if (aPersonId) { 235 [nVC setupWithPersonId:aPersonId]; 235 if (![nVC setupWithPersonId:aPersonId]) 236 return; 236 237 } else if (aTel) { 237 [nVC setupWithTel:aTel]; 238 if (![nVC setupWithTel:aTel]) 239 return; 238 240 } else { 239 241 return; … … 299 301 300 302 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { 301 NSMutableString *qry = [NSMutableString stringWithString:telSearch.text]; 303 //Must grab the text before resigning first responder 304 NSString *query = [NSString stringWithString:searchBar.text]; 302 305 [searchBar resignFirstResponder]; 303 if ([qry length] == 0) 304 return; 305 if ([qry hasPrefix:@"http://"]) { 306 [qry deleteCharactersInRange:NSMakeRange(0, [@"http://" length])]; 307 } else if ([qry hasPrefix:@"https://"]) { 308 [qry deleteCharactersInRange:NSMakeRange(0, [@"https://" length])]; 309 } 310 if ([qry hasPrefix:@"www."]) { 311 [qry deleteCharactersInRange:NSMakeRange(0, [@"www." length])]; 312 } 313 if ([qry hasPrefix:@"+"]) { 314 // Check if it's a phone number, try the sip version 315 BOOL isValidNumber = YES; 316 NSMutableString *enumStr = [NSMutableString stringWithCapacity:30]; 317 NSRange prefixR = NSMakeRange(0, 0); 318 for (int i = 1; i < [qry length]; i++) { 319 unichar aChar = [qry characterAtIndex:i]; 320 if ((aChar < 47) || (aChar > 58)) { // Not in range of Unicode digits 0-9 321 isValidNumber = NO; 322 break; 323 } 324 [enumStr replaceCharactersInRange:prefixR withString:[NSString stringWithFormat:@"%c.", aChar]]; 325 } 326 if (isValidNumber) { 327 [enumStr appendString:@"e164.arpa"]; 328 qry = enumStr; 329 } 330 } else if ([qry hasSuffix:@".tel"]) { 331 // .tel domain, do nothing 332 } else if ([qry hasSuffix:@".e164.arpa"]) { 333 // ENUM domain, let's add support for it, why not! 334 // Superbook will be the best ENUM client too! :) 335 } else { 336 qry = [NSString stringWithFormat:@"%@.tel", qry]; 337 } 338 [self launchNavControllerForTel:qry personId:nil]; 306 [self launchNavControllerForTel:query personId:nil]; 339 307 } 340 308 -
apps/iphone/superbook/trunk/Classes/NaptrViewController.h
r390 r442 77 77 } 78 78 79 - (void)setupWithPersonId:(NSNumber *)personId; 80 - (void)setupWithTel:(NSString *)telName; 79 - (BOOL)setupWithPersonId:(NSNumber *)personId; 80 - (BOOL)setupWithTel:(NSString *)telName; 81 - (NSString *)telFromQueryString:(NSString *)query; 81 82 - (void)getNaptrForTel:(NSString *)telName; 82 83 - (void)getTxtForTel:(NSString *)telName; -
apps/iphone/superbook/trunk/Classes/NaptrViewController.m
r416 r442 60 60 61 61 62 - ( void)setupWithPersonId:(NSNumber *)personId {62 - (BOOL)setupWithPersonId:(NSNumber *)personId { 63 63 NSString *telName = [[FriendsData sharedInstance] getTelForABRecordId:personId withABRecordRef:nil]; 64 [self setupWithTel:telName];65 64 self.abId = personId; 66 } 67 68 - (void) setupWithTel:(NSString *)telName { 65 return [self setupWithTel:telName]; 66 } 67 68 - (BOOL) setupWithTel:(NSString *)telName { 69 69 70 70 headerFont = [UIFont boldSystemFontOfSize:kHeaderTextFontSize]; 71 71 txtFont = [UIFont boldSystemFontOfSize:kTextFontSize]; 72 72 73 self.title = telName; 73 self.title = [self telFromQueryString:telName]; 74 if (!self.title) 75 return FALSE; 74 76 self.abId = [NSNumber numberWithInt:NSUIntegerMax]; 75 77 self.cleanTelName = [NSMutableString stringWithString:self.title]; … … 108 110 [self performSelectorInBackground:@selector(getTxtInBackgroundForTel:) withObject:self.title]; 109 111 [self performSelectorInBackground:@selector(getLocInBackgroundForTel:) withObject:self.title]; 112 return TRUE; 110 113 } 111 114 … … 469 472 470 473 #pragma mark ------ Custom Data Methods 474 475 - (NSString *)telFromQueryString:(NSString *)query { 476 if (!query) 477 return nil; 478 NSMutableString *qry = [NSMutableString stringWithString:query]; 479 if ([qry length] == 0) 480 return nil; 481 if ([qry hasPrefix:@"http://"]) { 482 [qry deleteCharactersInRange:NSMakeRange(0, [@"http://" length])]; 483 } else if ([qry hasPrefix:@"https://"]) { 484 [qry deleteCharactersInRange:NSMakeRange(0, [@"https://" length])]; 485 } 486 if ([qry hasPrefix:@"www."]) { 487 [qry deleteCharactersInRange:NSMakeRange(0, [@"www." length])]; 488 } 489 if ([qry hasPrefix:@"+"]) { 490 // Check if it's a phone number, try the sip version 491 BOOL isValidNumber = YES; 492 NSMutableString *enumStr = [NSMutableString stringWithCapacity:30]; 493 NSRange prefixR = NSMakeRange(0, 0); 494 for (int i = 1; i < [qry length]; i++) { 495 unichar aChar = [qry characterAtIndex:i]; 496 if ((aChar < 47) || (aChar > 58)) { // Not in range of Unicode digits 0-9 497 isValidNumber = NO; 498 break; 499 } 500 [enumStr replaceCharactersInRange:prefixR withString:[NSString stringWithFormat:@"%c.", aChar]]; 501 } 502 if (isValidNumber) { 503 [enumStr appendString:@"e164.arpa"]; 504 qry = enumStr; 505 } 506 } else if ([qry hasSuffix:@".tel"]) { 507 // .tel domain, do nothing 508 } else if ([qry hasSuffix:@".e164.arpa"]) { 509 // ENUM domain, let's add support for it, why not! 510 // Superbook will be the best ENUM client too! :) 511 } else { 512 qry = [NSString stringWithFormat:@"%@.tel", qry]; 513 } 514 return qry; 515 } 471 516 472 517 - (void)getNaptrForTel:(NSString *)telName {








