Mercurial > projects > dstep
comparison dstep/foundation/NSNetServices.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
comparison
equal
deleted
inserted
replaced
13:4f583f7e242e | 14:89f3c3ef1fd2 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSNetServices; | |
8 | |
9 import dstep.foundation.NSArray; | |
10 import dstep.foundation.NSData; | |
11 import dstep.foundation.NSDate; | |
12 import dstep.foundation.NSDictionary; | |
13 import dstep.foundation.NSInputStream; | |
14 import dstep.foundation.NSObject; | |
15 import dstep.foundation.NSOutputStream; | |
16 import dstep.foundation.NSRunLoop; | |
17 import dstep.foundation.NSString; | |
18 import dstep.objc.bridge.Bridge; | |
19 import dstep.objc.objc : id; | |
20 | |
21 import bindings = dstep.foundation.NSNetServices_bindings; | |
22 | |
23 alias NSInteger NSNetServicesError; | |
24 alias NSUInteger NSNetServiceOptions; | |
25 | |
26 const NSString NSNetServicesErrorCode; | |
27 const NSString NSNetServicesErrorDomain; | |
28 | |
29 enum | |
30 { | |
31 NSNetServicesUnknownError = -72000, | |
32 NSNetServicesCollisionError = -72001, | |
33 NSNetServicesNotFoundError = -72002, | |
34 NSNetServicesActivityInProgress = -72003, | |
35 NSNetServicesBadArgumentError = -72004, | |
36 NSNetServicesCancelledError = -72005, | |
37 NSNetServicesInvalidError = -72006, | |
38 NSNetServicesTimeoutError = -72007 | |
39 } | |
40 | |
41 enum | |
42 { | |
43 NSNetServiceNoAutoRename = 1 << 0 | |
44 } | |
45 | |
46 static this () | |
47 { | |
48 NSNetServicesErrorCode = new NSString(bindings.NSNetServicesErrorCode); | |
49 NSNetServicesErrorDomain = new NSString(bindings.NSNetServicesErrorDomain); | |
50 } | |
51 | |
52 class NSNetService : NSObject | |
53 { | |
54 mixin ObjcWrap; | |
55 | |
56 Object initWithDomain (NSString domain, NSString type, NSString name, int port) | |
57 { | |
58 return invokeObjcSelf!(Object, "initWithDomain:type:name:port:", NSString, NSString, NSString, int)(domain, type, name, port); | |
59 } | |
60 | |
61 this (NSString domain, NSString type, NSString name, int port) | |
62 { | |
63 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
64 id result = Bridge.invokeObjcMethod!(id, "initWithDomain:type:name:port:", NSString, NSString, NSString, int)(objcObject, domain, type, name, port); | |
65 | |
66 if (result) | |
67 objcObject = ret; | |
68 | |
69 dObject = this; | |
70 } | |
71 | |
72 Object initWithDomain (NSString domain, NSString type, NSString name) | |
73 { | |
74 return invokeObjcSelf!(Object, "initWithDomain:type:name:", NSString, NSString, NSString)(domain, type, name); | |
75 } | |
76 | |
77 this (NSString domain, NSString type, NSString name) | |
78 { | |
79 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
80 id result = Bridge.invokeObjcMethod!(id, "initWithDomain:type:name:", NSString, NSString, NSString)(objcObject, domain, type, name); | |
81 | |
82 if (result) | |
83 objcObject = ret; | |
84 | |
85 dObject = this; | |
86 } | |
87 | |
88 Object delegate_ () | |
89 { | |
90 return invokeObjcSelf!(Object, "delegate"); | |
91 } | |
92 | |
93 void setDelegate (Object delegate_) | |
94 { | |
95 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
96 } | |
97 | |
98 void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode) | |
99 { | |
100 return invokeObjcSelf!(void, "scheduleInRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
101 } | |
102 | |
103 void removeFromRunLoop (NSRunLoop aRunLoop, NSString mode) | |
104 { | |
105 return invokeObjcSelf!(void, "removeFromRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
106 } | |
107 | |
108 NSString domain () | |
109 { | |
110 return invokeObjcSelf!(NSString, "domain"); | |
111 } | |
112 | |
113 NSString type () | |
114 { | |
115 return invokeObjcSelf!(NSString, "type"); | |
116 } | |
117 | |
118 NSString name () | |
119 { | |
120 return invokeObjcSelf!(NSString, "name"); | |
121 } | |
122 | |
123 NSArray addresses () | |
124 { | |
125 return invokeObjcSelf!(NSArray, "addresses"); | |
126 } | |
127 | |
128 NSInteger port () | |
129 { | |
130 return invokeObjcSelf!(NSInteger, "port"); | |
131 } | |
132 | |
133 void publish () | |
134 { | |
135 return invokeObjcSelf!(void, "publish"); | |
136 } | |
137 | |
138 void publishWithOptions (uint options) | |
139 { | |
140 return invokeObjcSelf!(void, "publishWithOptions:", uint)(options); | |
141 } | |
142 | |
143 void resolve () | |
144 { | |
145 return invokeObjcSelf!(void, "resolve"); | |
146 } | |
147 | |
148 void stop () | |
149 { | |
150 return invokeObjcSelf!(void, "stop"); | |
151 } | |
152 | |
153 static NSDictionary dictionaryFromTXTRecordData (NSData txtData) | |
154 { | |
155 return invokeObjcSelfClass!(NSDictionary, "dictionaryFromTXTRecordData:", NSData)(txtData); | |
156 } | |
157 | |
158 static NSData dataFromTXTRecordDictionary (NSDictionary txtDictionary) | |
159 { | |
160 return invokeObjcSelfClass!(NSData, "dataFromTXTRecordDictionary:", NSDictionary)(txtDictionary); | |
161 } | |
162 | |
163 NSString hostName () | |
164 { | |
165 return invokeObjcSelf!(NSString, "hostName"); | |
166 } | |
167 | |
168 void resolveWithTimeout (double timeout) | |
169 { | |
170 return invokeObjcSelf!(void, "resolveWithTimeout:", double)(timeout); | |
171 } | |
172 | |
173 bool getInputStream (NSInputStream** inputStream, NSOutputStream** outputStream) | |
174 { | |
175 return invokeObjcSelf!(bool, "getInputStream:outputStream:", NSInputStream**, NSOutputStream**)(inputStream, outputStream); | |
176 } | |
177 | |
178 bool setTXTRecordData (NSData recordData) | |
179 { | |
180 return invokeObjcSelf!(bool, "setTXTRecordData:", NSData)(recordData); | |
181 } | |
182 | |
183 NSData TXTRecordData () | |
184 { | |
185 return invokeObjcSelf!(NSData, "TXTRecordData"); | |
186 } | |
187 | |
188 void startMonitoring () | |
189 { | |
190 return invokeObjcSelf!(void, "startMonitoring"); | |
191 } | |
192 | |
193 void stopMonitoring () | |
194 { | |
195 return invokeObjcSelf!(void, "stopMonitoring"); | |
196 } | |
197 } | |
198 | |
199 class NSNetServiceBrowser : NSObject | |
200 { | |
201 mixin ObjcWrap; | |
202 mixin TNSDeprecated; | |
203 | |
204 Object init () | |
205 { | |
206 return invokeObjcSelf!(Object, "init"); | |
207 } | |
208 | |
209 this () | |
210 { | |
211 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); | |
212 id result = Bridge.invokeObjcMethod!(id, "init")(objcObject); | |
213 | |
214 if (result) | |
215 objcObject = ret; | |
216 | |
217 dObject = this; | |
218 } | |
219 | |
220 Object delegate_ () | |
221 { | |
222 return invokeObjcSelf!(Object, "delegate"); | |
223 } | |
224 | |
225 void setDelegate (Object delegate_) | |
226 { | |
227 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
228 } | |
229 | |
230 void scheduleInRunLoop (NSRunLoop aRunLoop, NSString mode) | |
231 { | |
232 return invokeObjcSelf!(void, "scheduleInRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
233 } | |
234 | |
235 void removeFromRunLoop (NSRunLoop aRunLoop, NSString mode) | |
236 { | |
237 return invokeObjcSelf!(void, "removeFromRunLoop:forMode:", NSRunLoop, NSString)(aRunLoop, mode); | |
238 } | |
239 | |
240 void searchForBrowsableDomains () | |
241 { | |
242 return invokeObjcSelf!(void, "searchForBrowsableDomains"); | |
243 } | |
244 | |
245 void searchForRegistrationDomains () | |
246 { | |
247 return invokeObjcSelf!(void, "searchForRegistrationDomains"); | |
248 } | |
249 | |
250 void searchForServicesOfType (NSString type, NSString domainString) | |
251 { | |
252 return invokeObjcSelf!(void, "searchForServicesOfType:inDomain:", NSString, NSString)(type, domainString); | |
253 } | |
254 | |
255 void stop () | |
256 { | |
257 return invokeObjcSelf!(void, "stop"); | |
258 } | |
259 } | |
260 | |
261 template TNSDeprecated () | |
262 { | |
263 void searchForAllDomains () | |
264 { | |
265 return invokeObjcSelf!(void, "searchForAllDomains"); | |
266 } | |
267 } | |
268 | |
269 template TNSNetServiceDelegateMethods () | |
270 { | |
271 void netServiceWillPublish (NSNetService sender); | |
272 void netServiceDidPublish (NSNetService sender); | |
273 void netService (NSNetService sender, NSDictionary errorDict); | |
274 void netServiceWillResolve (NSNetService sender); | |
275 void netServiceDidResolveAddress (NSNetService sender); | |
276 void netService (NSNetService sender, NSDictionary errorDict); | |
277 void netServiceDidStop (NSNetService sender); | |
278 void netService (NSNetService sender, NSData data); | |
279 } | |
280 | |
281 template TNSNetServiceBrowserDelegateMethods () | |
282 { | |
283 void netServiceBrowserWillSearch (NSNetServiceBrowser aNetServiceBrowser); | |
284 void netServiceBrowserDidStopSearch (NSNetServiceBrowser aNetServiceBrowser); | |
285 void netServiceBrowser (NSNetServiceBrowser aNetServiceBrowser, NSDictionary errorDict); | |
286 void netServiceBrowser (NSNetServiceBrowser aNetServiceBrowser, NSString domainString, bool moreComing); | |
287 void netServiceBrowser (NSNetServiceBrowser aNetServiceBrowser, NSNetService aNetService, bool moreComing); | |
288 void netServiceBrowser (NSNetServiceBrowser aNetServiceBrowser, NSString domainString, bool moreComing); | |
289 void netServiceBrowser (NSNetServiceBrowser aNetServiceBrowser, NSNetService aNetService, bool moreComing); | |
290 } | |
291 |