hyperion.ng
bonjourservicebrowser.h
1 /*
2 Copyright (c) 2007, Trenton Schulz
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7  1. Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14  3. The name of the author may not be used to endorse or promote products
15  derived from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef BONJOURSERVICEBROWSER_H
30 #define BONJOURSERVICEBROWSER_H
31 
32 #include <QtCore/QObject>
33 #ifndef PLATFORM_AMLOGIC
34 #include <dns_sd.h>
35 #else
36 #include <avahi-compat-libdns_sd/dns_sd.h>
37 #endif
38 #include "bonjour/bonjourrecord.h"
39 
40 
41 class QSocketNotifier;
42 class BonjourServiceBrowser : public QObject
43 {
44  Q_OBJECT
45 public:
46  BonjourServiceBrowser(QObject *parent = 0);
48  void browseForServiceType(const QString &serviceType);
49  inline QList<BonjourRecord> currentRecords() const { return bonjourRecords; }
50  inline QString serviceType() const { return browsingType; }
51 
52 signals:
53  void currentBonjourRecordsChanged(const QList<BonjourRecord> &list);
54  void error(DNSServiceErrorType err);
55 
56 private slots:
57  void bonjourSocketReadyRead();
58 
59 private:
60  static void DNSSD_API bonjourBrowseReply(DNSServiceRef , DNSServiceFlags flags, quint32,
61  DNSServiceErrorType errorCode, const char *serviceName,
62  const char *regType, const char *replyDomain, void *context);
63  DNSServiceRef dnssref;
64  QSocketNotifier *bonjourSocket;
65  QList<BonjourRecord> bonjourRecords;
66  QString browsingType;
67 };
68 
69 #endif // BONJOURSERVICEBROWSER_H
Definition: bonjourservicebrowser.h:42