Developer Area

root/apps/iphone/superbook/trunk/DotTel_SDK/Classes/DnsResolver.h @ 719

Revision 546, 5.2 kB (checked in by henri, 5 years ago)

Significant update to 1.4.
Long labels, subdomain IDNs, Google MapKit?. Required OS Version 3.0.

Line 
1//
2//  DnsResolver.h
3//  DotTel SDK
4//
5//  Created by Henri Asseily on 9/14/08.
6/*
7 Copyright (c) 2008-2009, Telnic Ltd. All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without modification,
10 are permitted provided that the following conditions are met:
11 
12 Redistributions of source code must retain the above copyright notice, this list of conditions
13 and the following disclaimer. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the documentation and/or other
15 materials provided with the distribution.
16 Neither the name of the Telnic Ltd. nor the names of its contributors may be used to endorse or
17 promote products derived from this software without specific prior written permission.
18 THIS DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
19 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27//
28//
29//  This class is the entry point for handling the .tel DNS record classes
30//  (RecordNatpr, RecordTxt and RecordLoc).
31//  Simply allocate and initialize an instance of DnsResolver, and
32//  call the get[Type]ForTel methods to populate your arrays.
33//  Then iterate through those arrays, and ensure you check the isValid property
34//  of each record.
35//  Note that getNAPTRForTel, getTXTForTel and getLocForTel have different return
36//  value types and are thus used in slightly different manners.
37
38#import <UIKit/UIKit.h>
39#import <ldns/ldns.h>
40#import "NetworkUtility.h"
41#import "idna.h"
42#import "RecordNaptr.h"
43#import "RecordTxt.h"
44#import "RecordLoc.h"
45
46
47// Shorthand for getting localized strings
48#define LocTelStr(key) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:@"DotTel"]
49
50// Error Codes
51
52enum dns_resolver_enum_status {
53        RESOLVER_STATUS_OK,     
54        RESOLVER_STATUS_NO_CONNECTION,
55        RESOLVER_STATUS_INVALID_ANSWER,
56        RESOLVER_STATUS_NXDOMAIN,
57        RESOLVER_STATUS_BAD_DATA,
58        RESOLVER_STATUS_NO_NAME
59};
60typedef enum dns_resolver_enum_status dns_resolver_status;
61
62@interface DnsResolver : NSObject {
63
64        ldns_resolver *res;
65
66}
67
68/**
69 * Retrieves all NAPTR records in a domain and adds them to the provided
70 * array. NAPTR records are encapsulated in the RecordNaptr class.
71 *
72 * @param aDom       the domain to query
73 * @param naptrArray the array to add the naptrs to
74 *
75 * @return           the number of NAPTR records in the domain. 0 should mean error
76 *
77 */
78- (NSUInteger)getNAPTRForTel:(NSString *)aDom inArray:(NSMutableArray *)naptrArray withError:(NSError **)error;
79
80/**
81 * Retrieves all TXT records in a domain and adds them to the provided
82 * array. TXT records are encapsulated in the RecordTxt class.
83 * Also note that TXT records are returned in random order.
84 *
85 * @param domain     the domain to query
86 * @param txtArray   the array to add the txt records to
87 *
88 * @return         the number of TXT records in the domain. 0 should mean error
89 *
90 */
91- (NSUInteger)getTXTForTel:(NSString *)domain inArray:(NSMutableArray *)txtArray withError:(NSError **)error;
92
93/**
94 * Retrieves a single LOC record in a domain and adds it to the provided
95 * array. The LOC record is converted to a standard CLLocation object.
96 * .tel specifications prohibit more than a single LOC record per (sub)domain
97 * Returns the actual count of LOC records in the domain, for the caller to
98 * catch counts over 1.
99 *
100 * @param domain     the domain to query
101 * @param locArray   the array to add the single loc record to
102 *
103 * @return           the number of LOC records in the domain
104 *
105 */
106- (NSUInteger)getLOCForTel:(NSString *)domain inArray:(NSMutableArray *)locArray withError:(NSError **)error;
107
108/**
109 * Updates naptr records given an array of txt records
110 * At this time the only items that this method will use are labels (.tlb)
111 * .tlb records will be matched to their respective naptr records and will be
112 * used to modify the naptr records' label property
113 * Returns an array of int indexes of all modified naptr records in naptrArray
114 *
115 * @param naptrArray    the array of naptrs to be updated
116 * @param txtArray              the array of txt records from which to extract the additional info
117 *
118 * @return           a set of indexes of NAPTR records modified
119 *
120 */
121- (NSIndexSet *)updateNaptrArray:(NSMutableArray *)naptrArray withTxtArray:(NSArray *)txtArray;
122
123/**
124 * Converts a fully qualified domain name into its IDN equivalent
125 * The output may be an unmodified string
126 * On error, returns the unmodified string (i.e. silently discards errors)
127 *
128 * @param domain        the domain to convert
129 *
130 * @return          the IDN string
131 *
132 */
133- (NSString *)idnStringFromDomain:(NSString *)domain;
134@end
Note: See TracBrowser for help on using the browser.
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us