root/apps/iphone/superbook/trunk/DotTel_SDK/Classes/RecordNaptr.h
@
483
| Revision 382, 4.4 kB (checked in by henri, 4 years ago) |
|---|
| Line | |
|---|---|
| 1 | // |
| 2 | // RecordNaptr.h |
| 3 | // DotTel SDK |
| 4 | // |
| 5 | // Created by Henri Asseily on 9/12/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 | #import <UIKit/UIKit.h> |
| 30 | #import "ldns.h" |
| 31 | |
| 32 | // Shorthand for getting localized strings |
| 33 | #define LocTelStr(key) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:@"DotTel"] |
| 34 | |
| 35 | @interface RecordNaptr : NSObject { |
| 36 | |
| 37 | // All string tokens in a NAPTR |
| 38 | NSNumber *order; |
| 39 | NSNumber *preference; |
| 40 | NSString *flags; |
| 41 | NSString *services; |
| 42 | NSString *regexp; |
| 43 | NSString *replacement; |
| 44 | |
| 45 | // Parsed services string for .tel-specific tokens |
| 46 | NSMutableArray *serviceTypeArray; // e.g. "voice:tel", "web:http"... |
| 47 | NSMutableArray *labelArray; // x-lbl values |
| 48 | NSMutableArray *lihArray; // Location Indicator Hints (x-mobile, x-work, ...) |
| 49 | |
| 50 | // Useful properties of a NAPTR |
| 51 | BOOL isTerminal; |
| 52 | BOOL isPrivate; |
| 53 | BOOL isEncrypted; |
| 54 | BOOL isHidden; |
| 55 | BOOL isValid; |
| 56 | |
| 57 | // Derived attributes |
| 58 | NSString *serviceDescription; // descriptive services token element + LIH |
| 59 | NSString *labelDescription; // descriptive label |
| 60 | NSString *uriContent; // value of the NAPTR after regexp has been applied |
| 61 | NSDate *expiryDate; // Expiry date of the record, based on time-to-live |
| 62 | |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Class methods to initialize a NAPTR record from a ldns resource record |
| 67 | * This method calls recordWithRr:date: using the current date and time |
| 68 | * |
| 69 | * @return the record |
| 70 | */ |
| 71 | + (id)recordWithRr:(ldns_rr *)rr; |
| 72 | |
| 73 | /** |
| 74 | * Class methods to initialize a NAPTR record from a ldns resource record |
| 75 | * Sets property isValid=NO on error or if the provided ldns rr is not a NAPTR. |
| 76 | * |
| 77 | * @return the record |
| 78 | */ |
| 79 | + (id)recordWithRr:(ldns_rr *)rr date:(NSDate *)lookupDate; |
| 80 | |
| 81 | /** |
| 82 | * Initializer for a NAPTR record from a ldns resource record |
| 83 | * Sets property isValid=NO on error or if the provided ldns rr is not a NAPTR. |
| 84 | * You shouldn't need to call this directly. Instead call one of the class methods |
| 85 | * recordWithRr. |
| 86 | * |
| 87 | * @return the record |
| 88 | */ |
| 89 | - (id)initWithRr:(ldns_rr *)rr date:(NSDate *)lookupDate; |
| 90 | |
| 91 | /** |
| 92 | * Comparison selector for ordering NAPTR records. Use this to properly sort |
| 93 | * an array of RecordNaptr. Example usage: |
| 94 | * [naptrArray sortUsingSelector:@selector(comparator:)]; |
| 95 | * |
| 96 | * @return an NSComparisonResult |
| 97 | */ |
| 98 | - (NSComparisonResult)comparator:(RecordNaptr *)aNaptr; |
| 99 | |
| 100 | @property (readonly) BOOL isTerminal; |
| 101 | @property (readonly) BOOL isPrivate; |
| 102 | @property (readonly) BOOL isEncrypted; |
| 103 | @property (readonly) BOOL isHidden; |
| 104 | @property (readonly) BOOL isValid; |
| 105 | |
| 106 | @property (readonly, nonatomic, retain) NSMutableArray *serviceTypeArray; |
| 107 | @property (readonly, nonatomic, retain) NSMutableArray *labelArray; |
| 108 | @property (readonly, nonatomic, retain) NSMutableArray *lihArray; |
| 109 | |
| 110 | @property (readonly, nonatomic, retain) NSNumber *order; |
| 111 | @property (readonly, nonatomic, retain) NSNumber *preference; |
| 112 | @property (readonly, nonatomic, retain) NSString *serviceDescription; |
| 113 | @property (readonly, nonatomic, retain) NSString *labelDescription; |
| 114 | @property (readonly, nonatomic, retain) NSString *uriContent; |
| 115 | @property (readonly, nonatomic, retain) NSDate *expiryDate; |
| 116 | |
| 117 | @end |
Note: See TracBrowser
for help on using the browser.








