Updating ignore patterns.
5 // Created by Jens Alfke on 4/23/09.
6 // Copyright 2009 Jens Alfke. All rights reserved.
9 #import <Foundation/Foundation.h>
10 #import <CoreFoundation/CFSocket.h>
11 @class MYDNSConnection;
14 /** Abstract superclass for services based on DNSServiceRefs, such as MYPortMapper. */
15 @interface MYDNSService : NSObject
18 BOOL _usePrivateConnection;
19 MYDNSConnection *_connection;
20 struct _DNSServiceRef_t *_serviceRef;
22 CFRunLoopSourceRef _socketSource;
24 BOOL _continuous, _gotResponse;
27 /** If NO (the default), the service will stop after it gets a result.
28 If YES, it will continue to run until stopped. */
29 @property BOOL continuous;
31 /** Starts the service.
32 Returns immediately; you can find out when the service actually starts (or fails to)
33 by observing the isOpen and error properties.
34 It's very unlikely that this call itself will fail (return NO). If it does, it
35 probably means that the mDNSResponder process isn't working. */
38 /** Stops the service. */
42 /** The error status, a DNSServiceErrorType enum; nonzero if something went wrong.
43 This property is KV observable. */
44 @property int32_t error;
47 /** Utility to construct a service's full name. */
48 + (NSString*) fullNameOfService: (NSString*)serviceName
49 ofType: (NSString*)type
50 inDomain: (NSString*)domain;
54 * Methods for use only by subclasses
58 /** Normally, all DNSService objects use a shared IPC connection to the mDNSResponder daemon.
59 If an instance wants to use its own connection instead, it can set this property to YES before
60 it starts. If it does so, it must NOT set the kDNSServiceFlagsShareConnection flag when creating
61 its underlying DNSService.
62 This functionality is only provided because MYBonjourRegistration needs it -- there's a bug
63 that prevents DNSServiceUpdateRecord from working with a shared connection. */
64 @property BOOL usePrivateConnection;
66 /** Subclass must implement this abstract method to create a new DNSServiceRef.
67 This method is called by -open.
68 The implementation MUST pass the given sdRefPtr directly to the DNSService function
69 that creates the new ref, without setting it to NULL first.
70 It MUST also set the kDNSServiceFlagsShareConnection flag, unless it's already set the
71 usePrivateConnection property. */
72 - (int32_t/*DNSServiceErrorType*/) createServiceRef: (struct _DNSServiceRef_t**)sdRefPtr;
74 /** Subclass's callback must call this method after doing its own work.
75 This method will update the error state, and will stop the service if it's not set to be
77 - (void) gotResponse: (int32_t/*DNSServiceErrorType*/)errorCode;
79 /** The underlying DNSServiceRef. This will be NULL except while the service is running. */
80 @property (readonly) struct _DNSServiceRef_t* serviceRef;
82 /** Same as -stop, but does not clear the error property.
83 (The stop method actually calls this first.) */
86 /** Block until a message is received from the daemon.
87 This will cause the service's callback (defined by the subclass) to be invoked.
88 @return YES if a message is received, NO on error (or if the service isn't started) */
89 - (BOOL) waitForReply;
98 @interface MYDNSConnection : NSObject
100 struct _DNSServiceRef_t* _connectionRef;
102 CFRunLoopSourceRef _runLoopSource;
105 + (MYDNSConnection*) sharedConnection;
106 - (id) initWithServiceRef: (struct _DNSServiceRef_t *)serviceRef;
107 @property (readonly) struct _DNSServiceRef_t* connectionRef;
108 - (BOOL) processResult;