1 |
/* -*- Mode: C; tab-width: 4 -*- |
2 |
* |
3 |
* Copyright (c) 2009 Apple Computer, Inc. All rights reserved. |
4 |
* |
5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
6 |
* you may not use this file except in compliance with the License. |
7 |
* You may obtain a copy of the License at |
8 |
* |
9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
10 |
* |
11 |
* Unless required by applicable law or agreed to in writing, software |
12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 |
* See the License for the specific language governing permissions and |
15 |
* limitations under the License. |
16 |
*/ |
17 |
|
18 |
|
19 |
#ifndef _CDNSSDSERVICE_H |
20 |
#define _CDNSSDSERVICE_H |
21 |
|
22 |
#include "IDNSSDService.h" |
23 |
#include "nsCOMPtr.h" |
24 |
#include "nsComponentManagerUtils.h" |
25 |
#include "nsIThread.h" |
26 |
#include "nsIRunnable.h" |
27 |
#include "prtpool.h" |
28 |
#include <dns_sd.h> |
29 |
#include <stdio.h> |
30 |
#include <string> |
31 |
|
32 |
|
33 |
#define CDNSSDSERVICE_CONTRACTID "@apple.com/DNSSDService;1" |
34 |
#define CDNSSDSERVICE_CLASSNAME "CDNSSDService" |
35 |
#define CDNSSDSERVICE_CID { 0x944ED267, 0x465A, 0x4989, { 0x82, 0x72, 0x7E, 0xE9, 0x28, 0x6C, 0x99, 0xA5 } } |
36 |
|
37 |
|
38 |
/* Header file */ |
39 |
class CDNSSDService : public IDNSSDService, nsIRunnable |
40 |
{ |
41 |
public: |
42 |
NS_DECL_ISUPPORTS |
43 |
NS_DECL_IDNSSDSERVICE |
44 |
NS_DECL_NSIRUNNABLE |
45 |
|
46 |
CDNSSDService(); |
47 |
CDNSSDService( DNSServiceRef mainRef, nsISupports * listener ); |
48 |
|
49 |
virtual ~CDNSSDService(); |
50 |
|
51 |
private: |
52 |
|
53 |
static void DNSSD_API |
54 |
BrowseReply |
55 |
( |
56 |
DNSServiceRef sdRef, |
57 |
DNSServiceFlags flags, |
58 |
uint32_t interfaceIndex, |
59 |
DNSServiceErrorType errorCode, |
60 |
const char * serviceName, |
61 |
const char * regtype, |
62 |
const char * replyDomain, |
63 |
void * context |
64 |
); |
65 |
|
66 |
static void DNSSD_API |
67 |
ResolveReply |
68 |
( |
69 |
DNSServiceRef sdRef, |
70 |
DNSServiceFlags flags, |
71 |
uint32_t interfaceIndex, |
72 |
DNSServiceErrorType errorCode, |
73 |
const char * fullname, |
74 |
const char * hosttarget, |
75 |
uint16_t port, |
76 |
uint16_t txtLen, |
77 |
const unsigned char * txtRecord, |
78 |
void * context |
79 |
); |
80 |
|
81 |
static void |
82 |
Read |
83 |
( |
84 |
void * arg |
85 |
); |
86 |
|
87 |
nsresult |
88 |
SetupNotifications(); |
89 |
|
90 |
void |
91 |
Cleanup(); |
92 |
|
93 |
char m_master; |
94 |
PRThreadPool * m_threadPool; |
95 |
DNSServiceRef m_mainRef; |
96 |
DNSServiceRef m_subRef; |
97 |
nsISupports * m_listener; |
98 |
PRFileDesc * m_fileDesc; |
99 |
PRJobIoDesc m_iod; |
100 |
PRJob * m_job; |
101 |
}; |
102 |
|
103 |
|
104 |
#endif |