TBonjourResolver.h

Go to the documentation of this file.
00001 // @(#)root/bonjour:$Id: TBonjourResolver.h 34481 2010-07-19 14:51:45Z 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_TBonjourResolver
00013 #define ROOT_TBonjourResolver
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TBonjourResolver                                                     //
00019 //                                                                      //
00020 // This class consists of one main member function,                     //
00021 // ResolveBonjourRecord(), that resolves the service to an actual       //
00022 // IP address and port number. The rest of the class wraps the various  //
00023 // bits of Bonjour service resolver. 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 //////////////////////////////////////////////////////////////////////////
00028 
00029 #ifndef ROOT_TObject
00030 #include "TObject.h"
00031 #endif
00032 #ifndef ROOT_TQObject
00033 #include "TQObject.h"
00034 #endif
00035 #ifndef ROOT_TInetAddress
00036 #include "TInetAddress.h"
00037 #endif
00038 
00039 #if !defined(__CINT__)
00040 #include <dns_sd.h>
00041 #else
00042 typedef ULong_t DNSServiceRef;
00043 typedef UInt_t  DNSServiceFlags;
00044 typedef Int_t   DNSServiceErrorType;
00045 #endif
00046 
00047 class TFileHandler;
00048 class TBonjourRecord;
00049 
00050 
00051 class TBonjourResolver : public TObject, public TQObject {
00052 
00053 private:
00054    DNSServiceRef    fDNSRef;
00055    TFileHandler    *fBonjourSocketHandler;
00056    TInetAddress     fHostAddress;
00057    Int_t            fPort;
00058    TString          fTXTRecord;
00059 
00060    void *GetSender() { return this; }  // used to get gTQSender
00061 
00062 #if !defined(__CINT__)
00063    static void DNSSD_API BonjourResolveReply(DNSServiceRef, DNSServiceFlags, UInt_t,
00064                                              DNSServiceErrorType,
00065                                              const char *, const char *,
00066                                              UShort_t, UShort_t, const char *, void *);
00067 #else
00068    static void BonjourResolveReply(DNSServiceRef, DNSServiceFlags, UInt_t,
00069                                    DNSServiceErrorType,
00070                                    const char *, const char *,
00071                                    UShort_t, UShort_t, const char *, void *);
00072 #endif
00073 
00074 public:
00075    TBonjourResolver();
00076    virtual ~TBonjourResolver();
00077 
00078    TInetAddress GetInetAddress() const { return fHostAddress; }
00079    Int_t GetPort() const { return fPort; }
00080    const char * GetTXTRecord() const { return fTXTRecord; }
00081 
00082    Int_t ResolveBonjourRecord(const TBonjourRecord &record);
00083 
00084    void RecordResolved(const TInetAddress *hostInfo, Int_t port);  //*SIGNAL*
00085 
00086    void BonjourSocketReadyRead();  // private slot
00087 
00088    ClassDef(TBonjourResolver,0)  // Resolve Bonjour to actual IP address and port
00089 };
00090 
00091 #endif

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