- Timestamp:
- 07/27/09 16:15:47 (4 years ago)
- Location:
- apps/iphone/superbook/trunk/Classes
- Files:
-
- 4 modified
-
FriendsData.h (modified) (1 diff)
-
FriendsData.m (modified) (2 diffs)
-
NaptrViewController.h (modified) (1 diff)
-
NaptrViewController.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/superbook/trunk/Classes/FriendsData.h
r408 r470 78 78 - (void)loadFriendsDataFromAB:(ABAddressBookRef)aBook; 79 79 80 - (NSString *)telFromQueryString:(NSString *)query; 81 80 82 - (ABAddressBookRef)getAddressBookRef; 81 83 -
apps/iphone/superbook/trunk/Classes/FriendsData.m
r461 r470 285 285 #pragma mark ---- utility methods ---- 286 286 287 //Make sure a .tel is properly filtered 288 - (NSString *)telFromQueryString:(NSString *)query { 289 if (!query) 290 return nil; 291 NSMutableString *qry = [NSMutableString stringWithString:query]; 292 if ([qry length] == 0) 293 return nil; 294 if ([qry hasPrefix:@"http://"]) { 295 [qry deleteCharactersInRange:NSMakeRange(0, [@"http://" length])]; 296 } else if ([qry hasPrefix:@"https://"]) { 297 [qry deleteCharactersInRange:NSMakeRange(0, [@"https://" length])]; 298 } 299 if ([qry hasPrefix:@"www."]) { 300 [qry deleteCharactersInRange:NSMakeRange(0, [@"www." length])]; 301 } 302 if ([qry hasPrefix:@"+"]) { 303 // Check if it's a phone number, try the sip version 304 BOOL isValidNumber = YES; 305 NSMutableString *enumStr = [NSMutableString stringWithCapacity:30]; 306 NSRange prefixR = NSMakeRange(0, 0); 307 for (int i = 1; i < [qry length]; i++) { 308 unichar aChar = [qry characterAtIndex:i]; 309 if ((aChar < 47) || (aChar > 58)) { // Not in range of Unicode digits 0-9 310 isValidNumber = NO; 311 break; 312 } 313 [enumStr replaceCharactersInRange:prefixR withString:[NSString stringWithFormat:@"%c.", aChar]]; 314 } 315 if (isValidNumber) { 316 [enumStr appendString:@"e164.arpa"]; 317 qry = enumStr; 318 } 319 } else if ([qry hasSuffix:@".tel"]) { 320 // .tel domain, do nothing 321 } else if ([qry hasSuffix:@".e164.arpa"]) { 322 // ENUM domain, let's add support for it, why not! 323 // Superbook will be the best ENUM client too! :) 324 } else { 325 qry = [NSString stringWithFormat:@"%@.tel", qry]; 326 } 327 return qry; 328 } 329 287 330 // Get AddressBook 288 331 - (ABAddressBookRef) getAddressBookRef { … … 373 416 } 374 417 if (foundUrl) { 375 NSString *returnedTelUrl = [ NSString stringWithString:(NSString *)telUrl];418 NSString *returnedTelUrl = [[FriendsData sharedInstance] telFromQueryString:(NSString *)telUrl]; 376 419 CFRelease(telUrl); 377 420 return returnedTelUrl; -
apps/iphone/superbook/trunk/Classes/NaptrViewController.h
r442 r470 79 79 - (BOOL)setupWithPersonId:(NSNumber *)personId; 80 80 - (BOOL)setupWithTel:(NSString *)telName; 81 - (NSString *)telFromQueryString:(NSString *)query;82 81 - (void)getNaptrForTel:(NSString *)telName; 83 82 - (void)getTxtForTel:(NSString *)telName; -
apps/iphone/superbook/trunk/Classes/NaptrViewController.m
r461 r470 71 71 txtFont = [UIFont boldSystemFontOfSize:kTextFontSize]; 72 72 73 self.title = [ selftelFromQueryString:telName];73 self.title = [[FriendsData sharedInstance] telFromQueryString:telName]; 74 74 if (!self.title) 75 75 return FALSE; … … 473 473 474 474 #pragma mark ------ Custom Data Methods 475 476 - (NSString *)telFromQueryString:(NSString *)query {477 if (!query)478 return nil;479 NSMutableString *qry = [NSMutableString stringWithString:query];480 if ([qry length] == 0)481 return nil;482 if ([qry hasPrefix:@"http://"]) {483 [qry deleteCharactersInRange:NSMakeRange(0, [@"http://" length])];484 } else if ([qry hasPrefix:@"https://"]) {485 [qry deleteCharactersInRange:NSMakeRange(0, [@"https://" length])];486 }487 if ([qry hasPrefix:@"www."]) {488 [qry deleteCharactersInRange:NSMakeRange(0, [@"www." length])];489 }490 if ([qry hasPrefix:@"+"]) {491 // Check if it's a phone number, try the sip version492 BOOL isValidNumber = YES;493 NSMutableString *enumStr = [NSMutableString stringWithCapacity:30];494 NSRange prefixR = NSMakeRange(0, 0);495 for (int i = 1; i < [qry length]; i++) {496 unichar aChar = [qry characterAtIndex:i];497 if ((aChar < 47) || (aChar > 58)) { // Not in range of Unicode digits 0-9498 isValidNumber = NO;499 break;500 }501 [enumStr replaceCharactersInRange:prefixR withString:[NSString stringWithFormat:@"%c.", aChar]];502 }503 if (isValidNumber) {504 [enumStr appendString:@"e164.arpa"];505 qry = enumStr;506 }507 } else if ([qry hasSuffix:@".tel"]) {508 // .tel domain, do nothing509 } else if ([qry hasSuffix:@".e164.arpa"]) {510 // ENUM domain, let's add support for it, why not!511 // Superbook will be the best ENUM client too! :)512 } else {513 qry = [NSString stringWithFormat:@"%@.tel", qry];514 }515 return qry;516 }517 475 518 476 - (void)getNaptrForTel:(NSString *)telName {








