diff -r cb9cdf247239 -r 59689fbdcf77 Bonjour/MYBonjourService.h --- a/Bonjour/MYBonjourService.h Wed Apr 22 16:45:39 2009 -0700 +++ b/Bonjour/MYBonjourService.h Tue Apr 28 10:36:28 2009 -0700 @@ -6,54 +6,72 @@ // Copyright 2008 Jens Alfke. All rights reserved. // -#import +#import "MYDNSService.h" #import "ConcurrentOperation.h" -@class MYBonjourResolveOperation; +@class MYBonjourQuery, MYAddressLookup; /** Represents a Bonjour service discovered by a BonjourBrowser. */ -@interface MYBonjourService : NSObject +@interface MYBonjourService : MYDNSService { @private - NSNetService *_netService; + NSString *_name, *_fullName, *_type, *_domain, *_hostname; + uint32_t _interfaceIndex; + BOOL _startedResolve; + UInt16 _port; NSDictionary *_txtRecord; - NSSet *_addresses; - CFAbsoluteTime _addressesExpireAt; - MYBonjourResolveOperation *_resolveOp; + MYBonjourQuery *_txtQuery; + MYAddressLookup *_addressLookup; } /** The service's name. */ @property (readonly) NSString *name; +/** The service's type. */ +@property (readonly) NSString *type; + +/** The service's domain. */ +@property (readonly) NSString *domain; + +@property (readonly, copy) NSString *hostname; + +@property (readonly) UInt16 port; + +@property (readonly) uint32_t interfaceIndex; + +@property (readonly,copy) NSString* fullName; + /** The service's metadata dictionary, from its DNS TXT record */ @property (readonly,copy) NSDictionary *txtRecord; /** A convenience to access a single property from the TXT record. */ - (NSString*) txtStringForKey: (NSString*)key; -/** Returns a set of IPAddress objects; may be the empty set if address resolution failed, - or nil if addresses have not been resolved yet (or expired). - In the latter case, call -resolve and wait for the returned Operation to finish. */ -@property (readonly,copy) NSSet* addresses; +/** Returns a MYDNSLookup object that resolves the IP address(es) of this service. + Subsequent calls to this method will always return the same object. */ +- (MYAddressLookup*) addressLookup; -/** Starts looking up the IP address(es) of this service. - @return The NSOperation representing the lookup; you can observe this to see when it - completes, or you can observe the service's 'addresses' property. */ -- (MYBonjourResolveOperation*) resolve; - -/** The underlying NSNetSerice object. */ -@property (readonly) NSNetService *netService; +/** Starts a new MYBonjourQuery for the specified DNS record type of this service. + @param recordType The DNS record type, e.g. kDNSServiceType_TXT; see the enum in . */ +- (MYBonjourQuery*) queryForRecord: (UInt16)recordType; // Protected methods, for subclass use only: -- (id) initWithNetService: (NSNetService*)netService; +// (for subclasses to override, but not call): +- (id) initWithName: (NSString*)serviceName + type: (NSString*)type + domain: (NSString*)domain + interface: (uint32_t)interfaceIndex; -// (for subclasses to override, but not call): - (void) added; - (void) removed; - (void) txtRecordChanged; +// Internal: + +- (void) queryDidUpdate: (MYBonjourQuery*)query; + @end