ROOT  6.06/09
Reference Guide
TBonjourRegistrar.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_TBonjourRegistrar
13 #define ROOT_TBonjourRegistrar
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBonjourRegistrar //
19 // //
20 // This class consists of one main member function, RegisterService(), //
21 // that registers the service. As long as the object is alive, the //
22 // service stays registered. The rest of the class wraps the various //
23 // bits of Bonjour service registration. The static callback function //
24 // is marked with the DNSSD_API macro to make sure that the callback //
25 // has the correct calling 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 #ifndef ROOT_TObject
38 #include "TObject.h"
39 #endif
40 #ifndef ROOT_TQObject
41 #include "TQObject.h"
42 #endif
43 #ifndef ROOT_TBonjourRecord
44 #include "TBonjourRecord.h"
45 #endif
46 
47 #if !defined(__CINT__)
48 #include <dns_sd.h>
49 #else
50 typedef ULong_t DNSServiceRef;
51 typedef UInt_t DNSServiceFlags;
52 typedef Int_t DNSServiceErrorType;
53 #endif
54 
55 class TFileHandler;
56 
57 
58 class TBonjourRegistrar : public TObject, public TQObject {
59 
60 private:
61  DNSServiceRef fDNSRef;
64 
65  void *GetSender() { return this; } // used to get gTQSender
66 
67 #if !defined(__CINT__)
68  static void DNSSD_API BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
69  const char *, const char *, const char *, void *);
70 #else
71  static void BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
72  const char *, const char *, const char *, void *);
73 #endif
74 
75 public:
77  virtual ~TBonjourRegistrar();
78 
79  Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort);
81 
82  void ServiceRegistered(TBonjourRecord *record); //*SIGNAL*
83 
84  void BonjourSocketReadyRead(); // private slot
85 
86  ClassDef(TBonjourRegistrar,0) // Register Bonjour service
87 };
88 
89 #endif
unsigned short UShort_t
Definition: RtypesCore.h:36
Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort)
Register Bonjour service.
TBonjourRecord RegisteredRecord() const
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
TFileHandler * fBonjourSocketHandler
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:254
DNSServiceRef fDNSRef
void BonjourSocketReadyRead()
The Bonjour socket is ready for reading.
virtual ~TBonjourRegistrar()
Cleanup.
unsigned int UInt_t
Definition: RtypesCore.h:42
unsigned long ULong_t
Definition: RtypesCore.h:51
TBonjourRecord fFinalRecord
Mother of all ROOT objects.
Definition: TObject.h:58
static void DNSSD_API BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType, const char *, const char *, const char *, void *)
Static Bonjour register callback function.
void ServiceRegistered(TBonjourRecord *record)
Emit ServiceRegistered signal.