Bonjour/MYBonjourRegistration.h
author morrowa
Thu Jul 02 19:58:11 2009 -0700 (2009-07-02)
changeset 56 6c3b5372a307
child 59 46c7844cb592
permissions -rw-r--r--
Removed unnecessary files. Toned down logging. Added null logging handler to BLIP so client code doesn't have to use logging. Modified test drivers to work against Cocoa versions.
jens@31
     1
//
jens@31
     2
//  MYBonjourRegistration.h
jens@31
     3
//  MYNetwork
jens@31
     4
//
jens@31
     5
//  Created by Jens Alfke on 4/27/09.
jens@31
     6
//  Copyright 2009 Jens Alfke. All rights reserved.
jens@31
     7
//
jens@31
     8
jens@31
     9
#import "MYDNSService.h"
jens@31
    10
@class MYBonjourService;
jens@31
    11
jens@31
    12
jens@31
    13
/** Registers a local network service with Bonjour, so it can be browsed by other computers. */
jens@31
    14
@interface MYBonjourRegistration : MYDNSService
jens@31
    15
{
jens@31
    16
    NSString *_name, *_type, *_domain;
jens@31
    17
    UInt16 _port;
jens@31
    18
    BOOL _autoRename;
jens@31
    19
    BOOL _registered;
jens@31
    20
    NSMutableDictionary *_txtRecord;
jens@31
    21
}
jens@31
    22
jens@31
    23
/** Initializes a new registration.
jens@31
    24
    If you're also browsing for the same service type, you should instead get an instance of this via
jens@31
    25
    the MYBonjourBrowser's 'myRegistration' property -- that way the browser knows about the
jens@31
    26
    registration and won't echo it back to you.
jens@31
    27
    Either way, don't forget to call -start! */
jens@31
    28
- (id) initWithServiceType: (NSString*)serviceType port: (UInt16)port;
jens@31
    29
jens@31
    30
/** The name to register this service under.
jens@31
    31
    This is often left nil, in which case the user's chosen "Computer Name" (from the Sharing system
jens@31
    32
    pref pane) will be used.
jens@31
    33
    This can only be set before calling -start! */
jens@31
    34
@property (copy) NSString *name;
jens@31
    35
jens@31
    36
/** The registration's service type. */
jens@31
    37
@property (readonly) NSString *type;
jens@31
    38
jens@31
    39
/** The registration's IP port number.
jens@31
    40
    You'll need to set this if you got this object from MYBonjourBrowser's 'myRegistration' property,
jens@31
    41
    as that object doesn't have a pre-set port number yet.
jens@31
    42
    This can only be set before calling -start!  */
jens@31
    43
@property UInt16 port;
jens@31
    44
jens@31
    45
/** The registration's full name -- the name, type and domain concatenated together. */
jens@31
    46
@property (readonly) NSString *fullName;
jens@31
    47
jens@31
    48
/** Is the registration currently active? */
jens@31
    49
@property (readonly) BOOL registered;
jens@31
    50
jens@31
    51
/** The service's metadata dictionary, stored in its DNS TXT record */
jens@31
    52
@property (copy) NSDictionary *txtRecord;
jens@31
    53
jens@31
    54
/** Convenience to store a string value in a single TXT record key. */
jens@31
    55
- (void) setString: (NSString*)value forTxtKey: (NSString*)key;
jens@31
    56
jens@31
    57
jens@31
    58
/** @name Expert
jens@31
    59
 *  Advanced methods you likely won't need
jens@31
    60
 */
jens@31
    61
//@{
jens@31
    62
jens@31
    63
/** The registration's domain name.
jens@31
    64
    This is almost always left nil, in which case the default registration domain is used
jens@31
    65
    (usually ".local".)
jens@31
    66
    This can only be set before calling -start!  */
jens@31
    67
@property (copy) NSString *domain;
jens@31
    68
jens@31
    69
/** Determines what to do if there's a name conflict with an already-registered service on the
jens@31
    70
    network.
jens@31
    71
    If set to YES (the default), a number will be appended to the name to make it unique.
jens@31
    72
    If set to NO, the registration will fail, and you can choose a different name and try again.
jens@31
    73
    This can only be set before calling -start!  */
jens@31
    74
@property BOOL autoRename;
jens@31
    75
jens@31
    76
/** Is this browsed service an echo of this local registration? (Compares fullNames.) */
jens@31
    77
- (BOOL) isSameAsService: (MYBonjourService*)service;
jens@31
    78
jens@31
    79
//@}
jens@31
    80
jens@31
    81
@end