| jens@26 |      1 | //
 | 
| jens@26 |      2 | //  MYBonjourService.h
 | 
| jens@26 |      3 | //  MYNetwork
 | 
| jens@26 |      4 | //
 | 
| jens@26 |      5 | //  Created by Jens Alfke on 1/22/08.
 | 
| jens@26 |      6 | //  Copyright 2008 Jens Alfke. All rights reserved.
 | 
| jens@26 |      7 | //
 | 
| jens@26 |      8 | 
 | 
| jens@28 |      9 | #import "MYDNSService.h"
 | 
| jens@26 |     10 | #import "ConcurrentOperation.h"
 | 
| jens@28 |     11 | @class MYBonjourQuery, MYAddressLookup;
 | 
| jens@26 |     12 | 
 | 
| jens@26 |     13 | 
 | 
| jens@26 |     14 | /** Represents a Bonjour service discovered by a BonjourBrowser. */
 | 
| jens@28 |     15 | @interface MYBonjourService : MYDNSService 
 | 
| jens@26 |     16 | {
 | 
| jens@26 |     17 |     @private
 | 
| jens@28 |     18 |     NSString *_name, *_fullName, *_type, *_domain, *_hostname;
 | 
| jens@28 |     19 |     uint32_t _interfaceIndex;
 | 
| jens@28 |     20 |     BOOL _startedResolve;
 | 
| jens@28 |     21 |     UInt16 _port;
 | 
| jens@26 |     22 |     NSDictionary *_txtRecord;
 | 
| jens@28 |     23 |     MYBonjourQuery *_txtQuery;
 | 
| jens@28 |     24 |     MYAddressLookup *_addressLookup;
 | 
| jens@26 |     25 | }
 | 
| jens@26 |     26 | 
 | 
| jens@26 |     27 | /** The service's name. */
 | 
| jens@26 |     28 | @property (readonly) NSString *name;
 | 
| jens@26 |     29 | 
 | 
| jens@28 |     30 | /** The service's type. */
 | 
| jens@28 |     31 | @property (readonly) NSString *type;
 | 
| jens@28 |     32 | 
 | 
| jens@28 |     33 | /** The service's domain. */
 | 
| jens@28 |     34 | @property (readonly) NSString *domain;
 | 
| jens@28 |     35 | 
 | 
| jens@31 |     36 | /** The service's full name -- the name, type and domain concatenated together. */
 | 
| jens@31 |     37 | @property (readonly,copy) NSString* fullName;
 | 
| jens@31 |     38 | 
 | 
| jens@31 |     39 | /** The index of the network interface on which this service was found. */
 | 
| jens@31 |     40 | @property (readonly) uint32_t interfaceIndex;
 | 
| jens@31 |     41 | 
 | 
| jens@31 |     42 | 
 | 
| jens@31 |     43 | /** @name Addressing
 | 
| jens@31 |     44 |  *  Getting the IP address of the service
 | 
| jens@31 |     45 |  */
 | 
| jens@31 |     46 | //@{
 | 
| jens@31 |     47 | 
 | 
| jens@31 |     48 | /** The hostname of the machine providing this service. */
 | 
| jens@28 |     49 | @property (readonly, copy) NSString *hostname;
 | 
| jens@28 |     50 | 
 | 
| jens@31 |     51 | /** The IP port number of this service on its host. */
 | 
| jens@28 |     52 | @property (readonly) UInt16 port;
 | 
| jens@28 |     53 | 
 | 
| jens@31 |     54 | /** Returns a MYDNSLookup object that resolves the raw IP address(es) of this service.
 | 
| jens@31 |     55 |     Subsequent calls to this method will always return the same object. */
 | 
| jens@31 |     56 | - (MYAddressLookup*) addressLookup;
 | 
| jens@28 |     57 | 
 | 
| jens@31 |     58 | //@}
 | 
| jens@31 |     59 | 
 | 
| jens@31 |     60 | 
 | 
| jens@31 |     61 | /** @name TXT and other DNS records
 | 
| jens@31 |     62 |  */
 | 
| jens@31 |     63 | //@{
 | 
| jens@28 |     64 | 
 | 
| jens@26 |     65 | /** The service's metadata dictionary, from its DNS TXT record */
 | 
| jens@26 |     66 | @property (readonly,copy) NSDictionary *txtRecord;
 | 
| jens@26 |     67 | 
 | 
| jens@26 |     68 | /** A convenience to access a single property from the TXT record. */
 | 
| jens@26 |     69 | - (NSString*) txtStringForKey: (NSString*)key;
 | 
| jens@26 |     70 | 
 | 
| jens@28 |     71 | /** Starts a new MYBonjourQuery for the specified DNS record type of this service.
 | 
| jens@28 |     72 |     @param recordType  The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
 | 
| jens@28 |     73 | - (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
 | 
| jens@26 |     74 | 
 | 
| jens@31 |     75 | //@}
 | 
| jens@26 |     76 | 
 | 
| jens@26 |     77 | 
 | 
| jens@31 |     78 | /** @name Protected
 | 
| jens@31 |     79 |  *  Advanced methods that may be overridden by subclasses, but should not be called directly.
 | 
| jens@31 |     80 |  */
 | 
| jens@31 |     81 | //@{
 | 
| jens@31 |     82 | 
 | 
| jens@31 |     83 | /** Designated initializer. You probably don't want to create MYBonjourService instances yourself,
 | 
| jens@31 |     84 |     but if you subclass you might need to override this initializer. */
 | 
| jens@28 |     85 | - (id) initWithName: (NSString*)serviceName
 | 
| jens@28 |     86 |                type: (NSString*)type
 | 
| jens@28 |     87 |              domain: (NSString*)domain
 | 
| jens@31 |     88 |           interface: (UInt32)interfaceIndex;
 | 
| jens@26 |     89 | 
 | 
| jens@31 |     90 | /** Called when this service is officially added to its browser's service set.
 | 
| jens@31 |     91 |     You can override this, but be sure to call the superclass method. */
 | 
| jens@26 |     92 | - (void) added;
 | 
| jens@31 |     93 | 
 | 
| jens@31 |     94 | /** Called when this service is officially removed to its browser's service set.
 | 
| jens@31 |     95 |     You can override this, but be sure to call the superclass method. */
 | 
| jens@26 |     96 | - (void) removed;
 | 
| jens@31 |     97 | 
 | 
| jens@31 |     98 | /** Called when this service's TXT record changes.
 | 
| jens@31 |     99 |     You can override this, but be sure to call the superclass method. */
 | 
| jens@26 |    100 | - (void) txtRecordChanged;
 | 
| jens@26 |    101 | 
 | 
| jens@31 |    102 | /** Called when a query started by this service updates.
 | 
| jens@31 |    103 |     You can override this, but be sure to call the superclass method. */
 | 
| jens@28 |    104 | - (void) queryDidUpdate: (MYBonjourQuery*)query;
 | 
| jens@28 |    105 | 
 | 
| jens@31 |    106 | //@}
 | 
| jens@26 |    107 | 
 | 
| jens@26 |    108 | @end
 |