TBonjourRegistrar.h

Go to the documentation of this file.
00001 // @(#)root/bonjour:$Id: TBonjourRegistrar.h 29385 2009-07-07 15:27:23Z rdm $
00002 // Author: Fons Rademakers   29/05/2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TBonjourRegistrar
00013 #define ROOT_TBonjourRegistrar
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TBonjourRegistrar                                                    //
00019 //                                                                      //
00020 // This class consists of one main member function, RegisterService(),  //
00021 // that registers the service. As long as the object is alive, the      //
00022 // service stays registered. The rest of the class wraps the various    //
00023 // bits of Bonjour service registration. The static callback function   //
00024 // is marked with the DNSSD_API macro to make sure that the callback    //
00025 // has the correct calling convention on Windows.                       //
00026 //                                                                      //
00027 // Bonjour works out-of-the-box on MacOS X. On Linux you have to        //
00028 // install the Avahi package and run the avahi-daemon. To compile       //
00029 // these classes and run Avahi on Linux you need to install the:        //
00030 //    avahi                                                             //
00031 //    avahi-compat-libdns_sd-devel                                      //
00032 //    nss-mdns                                                          //
00033 // packages. After installation make sure the avahi-daemon is started.  //
00034 //                                                                      //
00035 //////////////////////////////////////////////////////////////////////////
00036 
00037 #ifndef ROOT_TObject
00038 #include "TObject.h"
00039 #endif
00040 #ifndef ROOT_TQObject
00041 #include "TQObject.h"
00042 #endif
00043 #ifndef ROOT_TBonjourRecord
00044 #include "TBonjourRecord.h"
00045 #endif
00046 
00047 #if !defined(__CINT__)
00048 #include <dns_sd.h>
00049 #else
00050 typedef ULong_t DNSServiceRef;
00051 typedef UInt_t  DNSServiceFlags;
00052 typedef Int_t   DNSServiceErrorType;
00053 #endif
00054 
00055 class TFileHandler;
00056 
00057 
00058 class TBonjourRegistrar : public TObject, public TQObject {
00059 
00060 private:
00061    DNSServiceRef    fDNSRef;
00062    TFileHandler    *fBonjourSocketHandler;
00063    TBonjourRecord   fFinalRecord;
00064 
00065    void *GetSender() { return this; }  // used to get gTQSender
00066 
00067 #if !defined(__CINT__)
00068    static void DNSSD_API BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
00069                                                 const char *, const char *, const char *, void *);
00070 #else
00071    static void BonjourRegisterService(DNSServiceRef, DNSServiceFlags, DNSServiceErrorType,
00072                                       const char *, const char *, const char *, void *);
00073 #endif
00074 
00075 public:
00076    TBonjourRegistrar();
00077    virtual ~TBonjourRegistrar();
00078 
00079    Int_t RegisterService(const TBonjourRecord &record, UShort_t servicePort);
00080    TBonjourRecord RegisteredRecord() const { return fFinalRecord; }
00081 
00082    void ServiceRegistered(TBonjourRecord *record);  //*SIGNAL*
00083 
00084    void BonjourSocketReadyRead();  // private slot
00085 
00086    ClassDef(TBonjourRegistrar,0)  // Register Bonjour service
00087 };
00088 
00089 #endif

Generated on Tue Jul 5 14:45:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1