Developer Area

Show
Ignore:
Timestamp:
06/07/09 11:21:46 (5 years ago)
Author:
henri
Message:

Major update: save .tel data to AddressBook?, with many other small fixes

Location:
apps/iphone/superbook/trunk/DotTel_SDK/Classes
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/DnsResolver.m

    r363 r382  
    245245                        } 
    246246                        @catch (NSException * e) { 
    247                                 dict = [NSDictionary dictionaryWithObject:@"Network Error: Bad data returned" forKey:NSLocalizedDescriptionKey]; 
    248                                 err2 = [NSError errorWithDomain:@"org.telnic.tel.sdk" code:RESOLVER_STATUS_BAD_DATA userInfo:dict]; 
    249                                 if (error) 
    250                                         *error = err2; 
     247                                // Exception is caught if there's no data in the rrlist, 
     248                                // i.e. if there are no records. That's BAD. 
     249                                // TODO: See in ldns rr.c source why ldns_rr_list_rr_count() fails and doesn't return 0 
     250                                // In the meantime, disable the error 
     251                                 
     252//                              dict = [NSDictionary dictionaryWithObject:@"Network Error: Bad data returned" forKey:NSLocalizedDescriptionKey]; 
     253//                              err2 = [NSError errorWithDomain:@"org.telnic.tel.sdk" code:RESOLVER_STATUS_BAD_DATA userInfo:dict]; 
     254//                              if (error) 
     255//                                      *error = err2; 
    251256                                rrlist = NULL; 
    252257                        } 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordNaptr.h

    r363 r382  
    104104@property (readonly) BOOL isValid; 
    105105 
     106@property (readonly, nonatomic, retain) NSMutableArray *serviceTypeArray; 
     107@property (readonly, nonatomic, retain) NSMutableArray *labelArray; 
     108@property (readonly, nonatomic, retain) NSMutableArray *lihArray; 
     109 
    106110@property (readonly, nonatomic, retain) NSNumber *order;  
    107111@property (readonly, nonatomic, retain) NSNumber *preference;  
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordNaptr.m

    r366 r382  
    4545@implementation RecordNaptr 
    4646 
     47@synthesize serviceTypeArray; 
     48@synthesize labelArray; 
     49@synthesize lihArray; 
     50 
    4751@synthesize order; 
    4852@synthesize preference; 
     
    9599        expiryDate = [lookupDate addTimeInterval:ttl]; 
    96100         
    97         serviceTypeArray = [NSMutableArray arrayWithCapacity:2]; 
    98         labelArray = [NSMutableArray arrayWithCapacity:2]; 
    99         lihArray = [NSMutableArray arrayWithCapacity:2]; 
     101        serviceTypeArray = [[NSMutableArray arrayWithCapacity:2] retain]; 
     102        labelArray = [[NSMutableArray arrayWithCapacity:2] retain]; 
     103        lihArray = [[NSMutableArray arrayWithCapacity:2] retain]; 
    100104         
    101105        order = [[self numberFromIntRdf:ldns_rr_rdf(rr,0)] retain]; 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordTxt.h

    r363 r382  
    4242         
    4343        // Derived attributes 
    44         NSString *typeDescription;                      // keyword type(s) string 
     44        NSString *primaryDescription;           // primary keyword type description (nl, pa, ...) 
     45        NSString *primaryValue;                         // primary keyword value 
    4546        NSString *textValue;                            // string value of the TXT record 
     47        NSMutableArray *keysAndValues;          // all keys and values of the TXT record (including primary key/value) 
    4648        NSDate *expiryDate;                                     // Expiry date of the record, based on time-to-live 
    4749 
     
    8082@property (readonly) BOOL isSystemMessage; 
    8183 
    82 @property (readonly, nonatomic, retain) NSString *typeDescription; 
     84@property (readonly, nonatomic, retain) NSString *primaryDescription; 
     85@property (readonly, nonatomic, retain) NSString *primaryValue; 
    8386@property (readonly, nonatomic, retain) NSString *textValue; 
     87@property (readonly, nonatomic, retain) NSMutableArray *keysAndValues; 
    8488@property (readonly, nonatomic, retain) NSDate *expiryDate; 
    8589 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordTxt.m

    r363 r382  
    2929#import "RecordTxt.h" 
    3030 
     31static NSCharacterSet *trimCharacterSet; 
     32 
    3133@interface RecordTxt (PrivateMethods) 
    3234 
     
    4547@synthesize expiryDate; 
    4648 
    47 @synthesize typeDescription; 
     49@synthesize primaryDescription; 
     50@synthesize primaryValue; 
    4851@synthesize textValue; 
     52@synthesize keysAndValues; 
    4953 
    5054+ (id)recordWithRr:(ldns_rr *)rr { 
     
    6973- (id)initWithRr:(ldns_rr *)rr date:(NSDate *)lookupDate { 
    7074        self = [super init]; 
     75        trimCharacterSet = [[NSCharacterSet whitespaceCharacterSet] retain]; 
    7176        isValid = NO; 
    72          
     77        isKeyword = NO; 
     78 
    7379        if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_TXT) 
    7480                return self; 
     
    8086        if ([firstString isEqualToString:@".tkw"]) { 
    8187                // parse keywords 
     88                isKeyword = YES; 
    8289                isValid = [self parseKeywordsFromRecord:rr]; 
    8390        } else if ([firstString isEqualToString:@".tsm"]) { 
    8491                // system message, do nothing 
    8592                return self; 
     93        } else if ([firstString isEqualToString:@".tad"]) { 
     94                // advert, do nothing for now 
     95                return self; 
    8696        } else { 
    8797                // header 
    8898                isHeader = YES; 
    89                 typeDescription= [@"" retain]; 
     99                primaryDescription = [@"" retain]; 
     100                primaryValue = NULL; 
    90101                // Could have multiple strings in one record, they need to be joined together 
    91102                NSMutableArray *stringComponents = [NSMutableArray arrayWithCapacity:2]; 
    92                 // TODO: concatenate all the strings in that rr 
    93103                for (NSUInteger i=0; i < ldns_rr_rd_count(rr); i++) { 
    94104                        [stringComponents addObject:[self stringFromStringRdf:ldns_rr_rdf(rr,i)]]; 
    95105                } 
    96106 
    97                 textValue = [stringComponents componentsJoinedByString:@", "]; 
     107                textValue = [stringComponents componentsJoinedByString:@" "]; 
    98108                isValid = YES; 
    99109        } 
     
    108118        // will have more. Here we opt to concatenate all the values for these compound keywords 
    109119        // and only keep the first type string, discarding all other type strings if they exist 
     120        // However, we also keep a full array of type+value in case the user wants to store that 
     121        // info into the address book. 
    110122         
    111123        // Check version 
    112124        if ([[self stringFromStringRdf:ldns_rr_rdf(rr,1)] isEqualToString:@"1"]) { 
    113125                // Version 1 
    114                 typeDescription = [LocTelStr([self stringFromStringRdf:ldns_rr_rdf(rr,2)]) retain]; 
    115                 NSMutableArray *keyValueComponents = [NSMutableArray arrayWithCapacity:2]; 
    116                 for (NSUInteger i=3; i < ldns_rr_rd_count(rr); i=i+2) { 
    117                         [keyValueComponents addObject:[self stringFromStringRdf:ldns_rr_rdf(rr,i)]]; 
     126                keysAndValues = [[NSMutableArray arrayWithCapacity:ldns_rr_rd_count(rr)] retain]; 
     127                for (NSUInteger i=2; i < ldns_rr_rd_count(rr); i=i+2) { 
     128                        [keysAndValues addObject:[self stringFromStringRdf:ldns_rr_rdf(rr,i)]]; 
     129                        [keysAndValues addObject:[self stringFromStringRdf:ldns_rr_rdf(rr,i+1)]]; 
    118130                } 
    119                 textValue = [[keyValueComponents componentsJoinedByString:@" "] retain]; 
     131                primaryDescription = [LocTelStr([keysAndValues objectAtIndex:0]) retain]; 
     132                if ([keysAndValues count] < 3) {        // Only a single primary keyword/value 
     133                        primaryValue = NULL; 
     134                        textValue = [keysAndValues objectAtIndex:1]; 
     135                } else { 
     136                        primaryValue = [keysAndValues objectAtIndex:1]; 
     137                        NSMutableArray *keyValueComponents = [NSMutableArray arrayWithCapacity:2]; 
     138                        for (NSUInteger i=1; i < [keysAndValues count]; i=i+2) { 
     139                                [keyValueComponents addObject:[keysAndValues objectAtIndex:i]]; 
     140                        } 
     141                        textValue = [[[keyValueComponents componentsJoinedByString:@" "] 
     142                                                  stringByTrimmingCharactersInSet:trimCharacterSet] retain]; 
     143                } 
    120144                return TRUE; 
    121145        } else { 
     
    137161} 
    138162 
     163#pragma mark ---- cleanup ---- 
     164 
     165- (void)dealloc { 
     166        [trimCharacterSet release]; 
     167        [super dealloc]; 
     168} 
    139169 
    140170@end 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us