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