00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MANAGER_H
00025 #define MANAGER_H
00026
00027
00028 #include <string>
00029 #include <list>
00030 #include <map>
00031
00032
00033 #include "prthread.h"
00034 #include "prlog.h"
00035 #include "prmon.h"
00036 #include "prio.h"
00037
00038
00039 extern "C" {
00040 #include "c-api/mdnsd.h"
00041 }
00042
00043 #include "ServiceChangeListener.h"
00044 #include "RegistrationListener.h"
00045 #include "BrowseListener.h"
00046
00047 namespace dnssd {
00048
00055 class Manager
00056 {
00057 public:
00062 friend void PR_CALLBACK dnssd::responderThread(void* aUserData);
00063
00067 friend void dnssd::publishResources(Manager* aMngr,
00068 const std::string& aSrvNodeName,
00069 const std::map<std::string,std::string> aResources);
00070
00071
00072
00077 Manager();
00078
00084 Manager(PRBool aMulticast,
00085 PRUint32 aPort);
00086
00087 ~Manager();
00088
00089
00090
00101 PRStatus browse(int aIface,
00102 std::string& aSrvType,
00103 std::string& aRegType,
00104 std::string& aDomain,
00105 BrowseListener* aListener);
00106
00117 Service* resolve(int aIface,
00118 std::string& aSrvType,
00119 std::string& aDomain,
00120 std::string& aSrvName,
00121 const BrowseListener* aListener);
00122
00132 PRStatus registerService(const Service* aService,
00133 const RegistrationListener* aListener);
00134
00144 PRStatus registerService(Service* aService,
00145 const std::string& aTargetAddr,
00146 const PRUint32 aTargetPort,
00147 RegistrationListener* aListener);
00148
00149
00150
00159 void setMulticast(PRBool aMulticast);
00160
00166 PRBool isMulticast();
00167
00173 std::string toString();
00174
00175
00176
00177 private:
00178
00179
00185 PRUint32 mPort;
00186
00190 PRBool mMulticast;
00191
00197 PRFileDesc* mInSocket;
00198
00203 PRFileDesc* mOutSocket;
00204
00208 mdnsd mResponder;
00209
00213 PRThread* mThread;
00214
00219 PRMonitor* mMonitor;
00220
00223 PRInt32 mRefreshDelay;
00224
00229 std::list<void*> mRegWrappers;
00230
00235 std::list<void*> mBrowseWrappers;
00236
00241 std::map<std::string,mdnsdr> mRegistrations;
00242
00246 ServiceChangeListener* mChangeListener;
00247 };
00248 }
00249 #endif