Logo ROOT   6.12/07
Reference Guide
TBonjourBrowser.h
Go to the documentation of this file.
1 // @(#)root/bonjour:$Id$
2 // Author: Fons Rademakers 29/05/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TBonjourBrowser
13 #define ROOT_TBonjourBrowser
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBonjourBrowser //
19 // //
20 // This class consists of one main member function, //
21 // BrowseForServiceType(), that looks for the service. //
22 // The rest of the class wraps the various bits of Bonjour service //
23 // browser. The static callback function is marked with the DNSSD_API //
24 // macro to make sure that the callback has the correct calling //
25 // convention on Windows. //
26 // //
27 // Bonjour works out-of-the-box on MacOS X. On Linux you have to //
28 // install the Avahi package and run the avahi-daemon. To compile //
29 // these classes and run Avahi on Linux you need to install the: //
30 // avahi //
31 // avahi-compat-libdns_sd-devel //
32 // nss-mdns //
33 // packages. After installation make sure the avahi-daemon is started. //
34 // //
35 //////////////////////////////////////////////////////////////////////////
36 
37 #include "TObject.h"
38 #include "TQObject.h"
39 #include "TString.h"
40 
41 #if !defined(__CINT__)
42 #include <dns_sd.h>
43 #else
44 typedef ULong_t DNSServiceRef;
45 typedef UInt_t DNSServiceFlags;
46 typedef Int_t DNSServiceErrorType;
47 #endif
48 
49 class TFileHandler;
50 class TList;
51 
52 
53 class TBonjourBrowser : public TObject, public TQObject {
54 
55 private:
56  DNSServiceRef fDNSRef;
60 
61  void *GetSender() { return this; } // used to get gTQSender
62 
63 #if !defined(__CINT__)
64  static void DNSSD_API BonjourBrowseReply(DNSServiceRef,
65  DNSServiceFlags, UInt_t, DNSServiceErrorType,
66  const char *, const char *, const char *, void *);
67 #else
68  static void BonjourBrowseReply(DNSServiceRef,
69  DNSServiceFlags, Int_t, DNSServiceErrorType,
70  const char *, const char *, const char *, void *);
71 #endif
72 
73 public:
75  virtual ~TBonjourBrowser();
76 
77  Int_t BrowseForServiceType(const char *serviceType);
78  TList *CurrentRecords() const { return fBonjourRecords; }
79  const char *ServiceType() const { return fBrowsingType; }
80 
81  void CurrentBonjourRecordsChanged(TList *bonjourRecords); //*SIGNAL*
82 
83  void BonjourSocketReadyRead(); // private slot
84 
85  ClassDef(TBonjourBrowser,0) // Browse hosts for specific bonjour service type
86 };
87 
88 #endif
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:49
const char * ServiceType() const
void BonjourSocketReadyRead()
The Bonjour socket is ready for reading.
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
TList * CurrentRecords() const
static void DNSSD_API BonjourBrowseReply(DNSServiceRef, DNSServiceFlags, UInt_t, DNSServiceErrorType, const char *, const char *, const char *, void *)
Static Bonjour browser callback function.
TList * fBonjourRecords
#define ClassDef(name, id)
Definition: Rtypes.h:320
void CurrentBonjourRecordsChanged(TList *bonjourRecords)
Emit CurrentBonjourRecordsChanged signal.
A doubly linked list.
Definition: TList.h:44
TBonjourBrowser()
Default ctor.
DNSServiceRef fDNSRef
TFileHandler * fBonjourSocketHandler
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual ~TBonjourBrowser()
Cleanup.
unsigned long ULong_t
Definition: RtypesCore.h:51
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t BrowseForServiceType(const char *serviceType)
Tell Bonjour to start browsing for a specific type of service.