-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy pathGSNetServices.h
150 lines (128 loc) · 3.84 KB
/
GSNetServices.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* Interface for concrete subclasses of NSNetServices on GNUstep
Copyright (C) 2010 Free Software Foundation, Inc.
Written by: Niels Grewe <niels.grewe@halbordnung.de>
Date: March 2010
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
*/
#import "common.h"
#define EXPOSE_NSNetService_IVARS 1
#define EXPOSE_NSNetServiceBrowser_IVARS 1
#import "Foundation/NSNetServices.h"
#import "GNUstepBase/NSNetServices+GNUstepBase.h"
#if GS_USE_AVAHI==1
// Subclasses using Avahi:
/** Convenience macro to create NSStrings if possible or return nil otherwise */
#define NSStringIfNotNull(x) x ? [NSString stringWithUTF8String: x] : nil
/**
* Possible types of Avahi browsers.
*/
typedef enum
{
GSAvahiUnknownBrowser,
GSAvahiDomainBrowser,
GSAvahiServiceBrowser,
GSAvahiBrowserMax
} GSAvahiBrowserType;
/**
* States of an Avahi service.
*/
typedef enum
{
GSNetServiceIdle,
GSNetServiceResolving,
GSNetServiceResolved,
GSNetServiceRecordBrowsing,
GSNetServicePublishing,
GSNetServicePublished,
GSNetServiceStateMax
} GSNetServiceState;
/**
* Turns a string into an NSString, adding a trailing "." if neccessary.
*/
NSString* GSNetServiceDotTerminatedNSStringFromString(const char* string);
@class GSAvahiRunLoopContext;
@class NSTimer;
@class NSRecursiveLock;
@class NSMutableDictionary;
@class NSMapTable;
/**
* NSNetService using the avahi-client API.
*/
@interface GSAvahiNetService : NSNetService <NSNetServiceDelegate>
{
// GSAvahiClient behaviour ivars:
// From superclass: id _delegate;
GSAvahiRunLoopContext *ctx;
void *_client;
NSRecursiveLock *_lock;
// Ivars for this class:
NSMutableDictionary *_info;
NSRecursiveLock *_infoLock;
NSUInteger _infoSeq;
GSNetServiceState _serviceState;
int _ifIndex;
int _protocol;
void *_entryGroup;
void *_resolver;
NSMapTable *_browsers;
NSMapTable *_browserTimeouts;
NSTimer *_timer;
}
/**
* Intializer that passes interface index and protocol information
* alongside the usual information for a mDNS service. This is used by
* GSNetServiceBrowser which already knows about these.
*/
- (id) initWithDomain: (NSString*)domain
type: (NSString*)type
name: (NSString*)name
avahiIfIndex: (int)anIfIndex
avahiProtocol: (int)aProtocol;
#if GS_USE_AVAHI==1
- (id<NSObject,GSNetServiceDelegate>)delegate;
#else
- (id<NSObject>)delegate;
#endif
@end
/**
* NSNetServiceBrowser using the avahi-client API.
*/
@interface GSAvahiNetServiceBrowser
: NSNetServiceBrowser <NSNetServiceBrowserDelegate>
{
// GSAvahiClient behaviour ivars:
// from superclass: id _delegate;
GSAvahiRunLoopContext *ctx;
void *_client;
NSRecursiveLock *_lock;
// Ivars for this class:
void* _browser;
GSAvahiBrowserType _type;
BOOL _hasFirstEvent;
NSMutableDictionary *_services;
}
@end
#else // GS_USE_MDNS
// Subclasses using mDNSResponder:
/**
* NSNetService using the mDNSResponder API.
*/
@interface GSMDNSNetService : NSNetService <NSNetServiceDelegate>
@end
/**
* NSNetServiceBrowser using the mDNSResponder API.
*/
@interface GSMDNSNetServiceBrowser : NSNetServiceBrowser <NSNetServiceBrowserDelegate>
@end
#endif // GS_USE_AVAHI