Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * browse_handler.h - Avahi browse handler 00004 * 00005 * Created: Wed Nov 08 13:16:47 2006 00006 * Copyright 2006 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_ 00025 #define __NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_ 00026 00027 #include <sys/types.h> 00028 #include <sys/socket.h> 00029 #include <stdint.h> 00030 00031 #include <string> 00032 #include <list> 00033 00034 namespace fawkes { 00035 00036 /** @class ServiceBrowseHandler <netcomm/service_discovery/browse_handler.h> 00037 * Interface for class that process browse results. 00038 * Implement this class if you want to browse for services on the network. 00039 * Then register your handler and it will be informed of services that 00040 * join or leave the network. This is also required for an active search. 00041 * 00042 * It is recommended that you read about mDNS, DNS-SD and Avahi. 00043 * 00044 * @author Tim Niemueller 00045 */ 00046 class ServiceBrowseHandler 00047 { 00048 public: 00049 /** Virtual destructor */ 00050 virtual ~ServiceBrowseHandler() {}; 00051 00052 /** All results have been retrieved. 00053 * If you read the DNS-SD specs you will see that there is no explicit 00054 * "not existent" or "end of records" message - it cannot be. But after 00055 * some time it is assumed that there are no more records. If that is 00056 * the case this method is called. 00057 */ 00058 virtual void all_for_now() = 0; 00059 00060 /** Cache exhausted. */ 00061 virtual void cache_exhausted() = 0; 00062 00063 /** Failed to browse for a given service. 00064 * @param name name of the service 00065 * @param type type of the service 00066 * @param domain domain of the service 00067 */ 00068 virtual void browse_failed(const char *name, 00069 const char *type, 00070 const char *domain) = 0; 00071 00072 /** A service has been announced on the network. 00073 * @param name name of the service 00074 * @param type type of the service 00075 * @param domain domain of the service 00076 * @param host_name name of the host that provides the service 00077 * @param addr pointer to sockaddr struct of appropriate type for address 00078 * @param addr_size size of addr struct 00079 * @param port port of the service 00080 * @param txt list of txt records. 00081 * @param flags extra flags, see Avahi documentation 00082 */ 00083 virtual void service_added(const char *name, 00084 const char *type, 00085 const char *domain, 00086 const char *host_name, 00087 const struct sockaddr *addr, 00088 const socklen_t addr_size, 00089 uint16_t port, 00090 std::list<std::string> &txt, 00091 int flags 00092 ) = 0; 00093 00094 /** A service has been removed from the network. 00095 * @param name name of the service 00096 * @param type type of the service 00097 * @param domain domain of the service 00098 */ 00099 virtual void service_removed(const char *name, 00100 const char *type, 00101 const char *domain) = 0; 00102 00103 }; 00104 00105 } // end namespace fawkes 00106 00107 #endif