Main Page | Namespace List | Class List | File List | Class Members | Related Pages

src/Manager.h

00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: GPL 2.0
00004  *
00005  * K-10 Distributed Processing - Lium, Le Mans
00006  * Copyright (C) 2006 Cedric CHANTEPIE
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021  *
00022  * ***** END LICENSE BLOCK ***** */
00023 
00024 #ifndef MANAGER_H
00025 #define MANAGER_H
00026 
00027 // stl
00028 #include <string>
00029 #include <list>
00030 #include <map>
00031 
00032 // nspr
00033 #include "prthread.h"
00034 #include "prlog.h"
00035 #include "prmon.h"
00036 #include "prio.h"
00037 
00038 // c-api
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     // --- Ctor/Dtor ---
00072          
00077     Manager();
00078 
00084     Manager(PRBool aMulticast,
00085             PRUint32 aPort);
00086 
00087     ~Manager();
00088 
00089     // --- Business logic ---
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     // --- Properties accessors ---
00150     
00159     void setMulticast(PRBool aMulticast);
00160   
00166     PRBool isMulticast();
00167 
00173     std::string toString();
00174 
00175     // --- Friends ---
00176    
00177   private:
00178     // --- Properties ---
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

Generated on Fri May 19 23:27:33 2006 for Tiny DNSSD by  doxygen 1.4.4