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@28
|
36 |
@property (readonly, copy) NSString *hostname;
|
jens@28
|
37 |
|
jens@28
|
38 |
@property (readonly) UInt16 port;
|
jens@28
|
39 |
|
jens@28
|
40 |
@property (readonly) uint32_t interfaceIndex;
|
jens@28
|
41 |
|
jens@28
|
42 |
@property (readonly,copy) NSString* fullName;
|
jens@28
|
43 |
|
jens@26
|
44 |
/** The service's metadata dictionary, from its DNS TXT record */
|
jens@26
|
45 |
@property (readonly,copy) NSDictionary *txtRecord;
|
jens@26
|
46 |
|
jens@26
|
47 |
/** A convenience to access a single property from the TXT record. */
|
jens@26
|
48 |
- (NSString*) txtStringForKey: (NSString*)key;
|
jens@26
|
49 |
|
jens@28
|
50 |
/** Returns a MYDNSLookup object that resolves the IP address(es) of this service.
|
jens@28
|
51 |
Subsequent calls to this method will always return the same object. */
|
jens@28
|
52 |
- (MYAddressLookup*) addressLookup;
|
jens@26
|
53 |
|
jens@28
|
54 |
/** Starts a new MYBonjourQuery for the specified DNS record type of this service.
|
jens@28
|
55 |
@param recordType The DNS record type, e.g. kDNSServiceType_TXT; see the enum in <dns_sd.h>. */
|
jens@28
|
56 |
- (MYBonjourQuery*) queryForRecord: (UInt16)recordType;
|
jens@26
|
57 |
|
jens@26
|
58 |
|
jens@26
|
59 |
// Protected methods, for subclass use only:
|
jens@26
|
60 |
|
jens@28
|
61 |
// (for subclasses to override, but not call):
|
jens@28
|
62 |
- (id) initWithName: (NSString*)serviceName
|
jens@28
|
63 |
type: (NSString*)type
|
jens@28
|
64 |
domain: (NSString*)domain
|
jens@28
|
65 |
interface: (uint32_t)interfaceIndex;
|
jens@26
|
66 |
|
jens@26
|
67 |
- (void) added;
|
jens@26
|
68 |
- (void) removed;
|
jens@26
|
69 |
- (void) txtRecordChanged;
|
jens@26
|
70 |
|
jens@28
|
71 |
// Internal:
|
jens@28
|
72 |
|
jens@28
|
73 |
- (void) queryDidUpdate: (MYBonjourQuery*)query;
|
jens@28
|
74 |
|
jens@26
|
75 |
@end
|
jens@26
|
76 |
|
jens@26
|
77 |
|
jens@26
|
78 |
|
jens@26
|
79 |
@interface MYBonjourResolveOperation : ConcurrentOperation
|
jens@26
|
80 |
{
|
jens@26
|
81 |
MYBonjourService *_service;
|
jens@26
|
82 |
NSSet *_addresses;
|
jens@26
|
83 |
}
|
jens@26
|
84 |
|
jens@26
|
85 |
@property (readonly) MYBonjourService *service;
|
jens@26
|
86 |
@property (readonly,retain) NSSet *addresses;
|
jens@26
|
87 |
|
jens@26
|
88 |
@end
|