Changeset 382 for apps/iphone/superbook/trunk/DotTel_SDK/Classes
- Timestamp:
- 06/07/09 11:21:46 (4 years ago)
- Location:
- apps/iphone/superbook/trunk/DotTel_SDK/Classes
- Files:
-
- 5 modified
-
DnsResolver.m (modified) (1 diff)
-
RecordNaptr.h (modified) (1 diff)
-
RecordNaptr.m (modified) (2 diffs)
-
RecordTxt.h (modified) (2 diffs)
-
RecordTxt.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/superbook/trunk/DotTel_SDK/Classes/DnsResolver.m
r363 r382 245 245 } 246 246 @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; 251 256 rrlist = NULL; 252 257 } -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordNaptr.h
r363 r382 104 104 @property (readonly) BOOL isValid; 105 105 106 @property (readonly, nonatomic, retain) NSMutableArray *serviceTypeArray; 107 @property (readonly, nonatomic, retain) NSMutableArray *labelArray; 108 @property (readonly, nonatomic, retain) NSMutableArray *lihArray; 109 106 110 @property (readonly, nonatomic, retain) NSNumber *order; 107 111 @property (readonly, nonatomic, retain) NSNumber *preference; -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordNaptr.m
r366 r382 45 45 @implementation RecordNaptr 46 46 47 @synthesize serviceTypeArray; 48 @synthesize labelArray; 49 @synthesize lihArray; 50 47 51 @synthesize order; 48 52 @synthesize preference; … … 95 99 expiryDate = [lookupDate addTimeInterval:ttl]; 96 100 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]; 100 104 101 105 order = [[self numberFromIntRdf:ldns_rr_rdf(rr,0)] retain]; -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordTxt.h
r363 r382 42 42 43 43 // Derived attributes 44 NSString *typeDescription; // keyword type(s) string 44 NSString *primaryDescription; // primary keyword type description (nl, pa, ...) 45 NSString *primaryValue; // primary keyword value 45 46 NSString *textValue; // string value of the TXT record 47 NSMutableArray *keysAndValues; // all keys and values of the TXT record (including primary key/value) 46 48 NSDate *expiryDate; // Expiry date of the record, based on time-to-live 47 49 … … 80 82 @property (readonly) BOOL isSystemMessage; 81 83 82 @property (readonly, nonatomic, retain) NSString *typeDescription; 84 @property (readonly, nonatomic, retain) NSString *primaryDescription; 85 @property (readonly, nonatomic, retain) NSString *primaryValue; 83 86 @property (readonly, nonatomic, retain) NSString *textValue; 87 @property (readonly, nonatomic, retain) NSMutableArray *keysAndValues; 84 88 @property (readonly, nonatomic, retain) NSDate *expiryDate; 85 89 -
apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordTxt.m
r363 r382 29 29 #import "RecordTxt.h" 30 30 31 static NSCharacterSet *trimCharacterSet; 32 31 33 @interface RecordTxt (PrivateMethods) 32 34 … … 45 47 @synthesize expiryDate; 46 48 47 @synthesize typeDescription; 49 @synthesize primaryDescription; 50 @synthesize primaryValue; 48 51 @synthesize textValue; 52 @synthesize keysAndValues; 49 53 50 54 + (id)recordWithRr:(ldns_rr *)rr { … … 69 73 - (id)initWithRr:(ldns_rr *)rr date:(NSDate *)lookupDate { 70 74 self = [super init]; 75 trimCharacterSet = [[NSCharacterSet whitespaceCharacterSet] retain]; 71 76 isValid = NO; 72 77 isKeyword = NO; 78 73 79 if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_TXT) 74 80 return self; … … 80 86 if ([firstString isEqualToString:@".tkw"]) { 81 87 // parse keywords 88 isKeyword = YES; 82 89 isValid = [self parseKeywordsFromRecord:rr]; 83 90 } else if ([firstString isEqualToString:@".tsm"]) { 84 91 // system message, do nothing 85 92 return self; 93 } else if ([firstString isEqualToString:@".tad"]) { 94 // advert, do nothing for now 95 return self; 86 96 } else { 87 97 // header 88 98 isHeader = YES; 89 typeDescription= [@"" retain]; 99 primaryDescription = [@"" retain]; 100 primaryValue = NULL; 90 101 // Could have multiple strings in one record, they need to be joined together 91 102 NSMutableArray *stringComponents = [NSMutableArray arrayWithCapacity:2]; 92 // TODO: concatenate all the strings in that rr93 103 for (NSUInteger i=0; i < ldns_rr_rd_count(rr); i++) { 94 104 [stringComponents addObject:[self stringFromStringRdf:ldns_rr_rdf(rr,i)]]; 95 105 } 96 106 97 textValue = [stringComponents componentsJoinedByString:@" ,"];107 textValue = [stringComponents componentsJoinedByString:@" "]; 98 108 isValid = YES; 99 109 } … … 108 118 // will have more. Here we opt to concatenate all the values for these compound keywords 109 119 // 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. 110 122 111 123 // Check version 112 124 if ([[self stringFromStringRdf:ldns_rr_rdf(rr,1)] isEqualToString:@"1"]) { 113 125 // 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 [key ValueComponents 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)]]; 118 130 } 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 } 120 144 return TRUE; 121 145 } else { … … 137 161 } 138 162 163 #pragma mark ---- cleanup ---- 164 165 - (void)dealloc { 166 [trimCharacterSet release]; 167 [super dealloc]; 168 } 139 169 140 170 @end








