Developer Area

Show
Ignore:
Timestamp:
09/16/11 16:55:43 (3 years ago)
Author:
henri
Message:

Added support for removing contacts from Superbook

Location:
apps/iphone/superbook/trunk/Classes
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/superbook/trunk/Classes/FriendsData.h

    r885 r902  
    8080- (NSNumber *) getABRecordIdForTel:(NSString *)telname; 
    8181- (ABRecordRef)getABRecordRefForABRecordId:(NSNumber *)theId withAddressBook:(ABRecordRef)theBook; 
    82 - (NSString *)getTelForABRecordId:(NSNumber *)theId withABRecordRef:(ABRecordRef)recordRef; 
     82- (NSString *) getTelForABRecordId:(NSNumber *)theId withABRecordRef:(ABRecordRef)recordRef; 
     83- (void)removeTelAtIndexPath:(NSIndexPath *)indexPath; 
    8384- (NSInteger)getTelIndexForABRecordId:(NSNumber *)theId withABRecordRef:(ABRecordRef)recordRef; 
    8485 
  • apps/iphone/superbook/trunk/Classes/FriendsData.m

    r883 r902  
    280280} 
    281281 
     282- (void)removeTelAtIndexPath:(NSIndexPath *)indexPath { 
     283    ABMultiValueRef allUrls; 
     284        BOOL foundUrl = NO; 
     285    NSNumber *thePersonId = [sortedPeopleArray objectAtIndex:indexPath.row]; 
     286    ABRecordRef recordRef = ABAddressBookGetPersonWithRecordID(book, (ABRecordID)[thePersonId intValue]); 
     287    allUrls = ABRecordCopyValue(recordRef, kABPersonURLProperty); 
     288    CFRelease(allUrls); 
     289    ABMutableMultiValueRef allUrlsMutable = ABMultiValueCreateMutableCopy(allUrls); 
     290    CFStringRef telUrl; 
     291        for (CFIndex j = 0; j < ABMultiValueGetCount(allUrlsMutable); j++) { 
     292                telUrl = ABMultiValueCopyValueAtIndex(allUrlsMutable, j); 
     293                if ([(NSString *)telUrl hasSuffix:@".tel"]) { 
     294                        foundUrl = YES; 
     295                } 
     296                if ([(NSString *)telUrl hasSuffix:@".tel/"]) { 
     297                        foundUrl = YES; 
     298                } 
     299        if (foundUrl) { 
     300            ABMultiValueRemoveValueAndLabelAtIndex(allUrlsMutable, j); 
     301            NSError *err = nil; 
     302            ABRecordSetValue(recordRef, kABPersonURLProperty, allUrlsMutable, (CFErrorRef *)&err); 
     303            ABAddressBookSave(book, (CFErrorRef *)&err); 
     304            [peopleCurrentList removeObjectForKey:thePersonId]; 
     305            self.sortedPeopleArray = [peopleCurrentList keysSortedByValueUsingSelector:@selector(compositeNameSortAlgorithm:)]; 
     306            if (self.delegate) 
     307                [self.delegate friendsDataDidLoad]; 
     308            break; 
     309        } 
     310                CFRelease(telUrl); 
     311        //              CFRelease(recordRef); 
     312        } 
     313} 
     314 
    282315// Get .tel ABMultiValue index for a record 
    283316// given any url that ends with .tel 
  • apps/iphone/superbook/trunk/Classes/LocateThem_ViewController.m

    r899 r902  
    480480 
    481481- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
    482     if (indexPath.section == LTSectionVisited) 
    483         return YES; 
    484     return NO; 
     482    return YES; 
    485483} 
    486484 
    487485- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 
    488     NSInteger maxRows = [domainsLastVisited numberOfCachedLookups]; 
    489     if ((indexPath.row == lastVisitedRowCount) && (lastVisitedRowCount < maxRows)) { 
    490         return UITableViewCellEditingStyleNone;     // See More row 
     486    if (indexPath.section == LTSectionVisited) { 
     487        NSInteger maxRows = [domainsLastVisited numberOfCachedLookups]; 
     488        if ((indexPath.row == lastVisitedRowCount) && (lastVisitedRowCount < maxRows)) { 
     489            return UITableViewCellEditingStyleNone;     // See More row 
     490        } 
    491491    } 
    492492    return UITableViewCellEditingStyleDelete; 
     
    494494 
    495495- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    496     if ([domainsLastVisited deleteCachedDataForRow:[indexPath row]]) { 
    497         lastVisitedRowCount--; 
    498         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    499         if ([tableView numberOfRowsInSection:indexPath.section] == 0) { 
    500             [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 
    501         } 
     496    [tableView beginUpdates]; 
     497    if (indexPath.section == LTSectionVisited) { 
     498        if ([domainsLastVisited deleteCachedDataForRow:[indexPath row]]) { 
     499            lastVisitedRowCount--; 
     500        } 
     501    } else if (indexPath.section == LTSectionContacts) { 
     502        [[FriendsData sharedInstance] removeTelAtIndexPath:indexPath]; 
     503    } 
     504    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
     505    [tableView endUpdates]; 
     506    if ([tableView numberOfRowsInSection:indexPath.section] == 0) { 
     507        [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; 
    502508    } 
    503509} 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us