root/apps/iphone/superbook/trunk/DotTel_SDK/Classes/DnsResolver.h
@
507
| Revision 507, 4.2 kB (checked in by henri, 4 years ago) |
|---|
| 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 "RecordNaptr.h" |
| 42 | #import "RecordTxt.h" |
| 43 | #import "RecordLoc.h" |
| 44 | |
| 45 | |
| 46 | // Shorthand for getting localized strings |
| 47 | #define LocTelStr(key) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:@"DotTel"] |
| 48 | |
| 49 | // Error Codes |
| 50 | |
| 51 | enum dns_resolver_enum_status { |
| 52 | RESOLVER_STATUS_OK, |
| 53 | RESOLVER_STATUS_NO_CONNECTION, |
| 54 | RESOLVER_STATUS_INVALID_ANSWER, |
| 55 | RESOLVER_STATUS_NXDOMAIN, |
| 56 | RESOLVER_STATUS_BAD_DATA, |
| 57 | RESOLVER_STATUS_NO_NAME |
| 58 | }; |
| 59 | typedef enum dns_resolver_enum_status dns_resolver_status; |
| 60 | |
| 61 | @interface DnsResolver : NSObject { |
| 62 | |
| 63 | ldns_resolver *res; |
| 64 | |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Retrieves all NAPTR records in a domain and adds them to the provided |
| 69 | * array. NAPTR records are encapsulated in the RecordNaptr class. |
| 70 | * |
| 71 | * @param aDom the domain to query |
| 72 | * @param naptrArray the array to add the naptrs to |
| 73 | * @return the number of NAPTR records in the domain. 0 should mean error |
| 74 | * |
| 75 | */ |
| 76 | - (NSUInteger)getNAPTRForTel:(NSString *)aDom inArray:(NSMutableArray *)naptrArray withError:(NSError **)error; |
| 77 | |
| 78 | /** |
| 79 | * Retrieves all TXT records in a domain and adds them to the provided |
| 80 | * array. TXT records are encapsulated in the RecordTxt class. |
| 81 | * Also note that TXT records are returned in random order. |
| 82 | * |
| 83 | * @param domain the domain to query |
| 84 | * @param txtArray the array to add the txt records to |
| 85 | * |
| 86 | * @return the number of TXT records in the domain. 0 should mean error |
| 87 | * |
| 88 | */ |
| 89 | - (NSUInteger)getTXTForTel:(NSString *)domain inArray:(NSMutableArray *)txtArray withError:(NSError **)error; |
| 90 | |
| 91 | /** |
| 92 | * Retrieves a single LOC record in a domain and adds it to the provided |
| 93 | * array. The LOC record is converted to a standard CLLocation object. |
| 94 | * .tel specifications prohibit more than a single LOC record per (sub)domain |
| 95 | * Returns the actual count of LOC records in the domain, for the caller to |
| 96 | * catch counts over 1. |
| 97 | * |
| 98 | * @param domain the domain to query |
| 99 | * @param locArray the array to add the single loc record to |
| 100 | * |
| 101 | * @return the number of LOC records in the domain |
| 102 | * |
| 103 | */ |
| 104 | - (NSUInteger)getLOCForTel:(NSString *)domain inArray:(NSMutableArray *)locArray withError:(NSError **)error; |
| 105 | |
| 106 | @end |
Note: See TracBrowser
for help on using the browser.








