Fawkes API  Fawkes Development Version
browse_handler.h
1 
2 /***************************************************************************
3  * browse_handler.h - Avahi browse handler
4  *
5  * Created: Wed Nov 08 13:16:47 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_
25 #define __NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_
26 
27 #include <sys/types.h>
28 #include <sys/socket.h>
29 #include <stdint.h>
30 
31 #include <string>
32 #include <list>
33 
34 namespace fawkes {
35 
36 /** @class ServiceBrowseHandler <netcomm/service_discovery/browse_handler.h>
37  * Interface for class that process browse results.
38  * Implement this class if you want to browse for services on the network.
39  * Then register your handler and it will be informed of services that
40  * join or leave the network. This is also required for an active search.
41  *
42  * It is recommended that you read about mDNS, DNS-SD and Avahi.
43  *
44  * @author Tim Niemueller
45  */
47 {
48  public:
49  /** Virtual destructor */
50  virtual ~ServiceBrowseHandler() {};
51 
52  /** All results have been retrieved.
53  * If you read the DNS-SD specs you will see that there is no explicit
54  * "not existent" or "end of records" message - it cannot be. But after
55  * some time it is assumed that there are no more records. If that is
56  * the case this method is called.
57  */
58  virtual void all_for_now() = 0;
59 
60  /** Cache exhausted. */
61  virtual void cache_exhausted() = 0;
62 
63  /** Failed to browse for a given service.
64  * @param name name of the service
65  * @param type type of the service
66  * @param domain domain of the service
67  */
68  virtual void browse_failed(const char *name,
69  const char *type,
70  const char *domain) = 0;
71 
72  /** A service has been announced on the network.
73  * @param name name of the service
74  * @param type type of the service
75  * @param domain domain of the service
76  * @param host_name name of the host that provides the service
77  * @param interface name of network interface to reach service
78  * @param addr pointer to sockaddr struct of appropriate type for address
79  * @param addr_size size of addr struct
80  * @param port port of the service
81  * @param txt list of txt records.
82  * @param flags extra flags, see Avahi documentation
83  */
84  virtual void service_added(const char *name,
85  const char *type,
86  const char *domain,
87  const char *host_name,
88  const char *interface,
89  const struct sockaddr *addr,
90  const socklen_t addr_size,
91  uint16_t port,
92  std::list<std::string> &txt,
93  int flags
94  ) = 0;
95 
96  /** A service has been removed from the network.
97  * @param name name of the service
98  * @param type type of the service
99  * @param domain domain of the service
100  */
101  virtual void service_removed(const char *name,
102  const char *type,
103  const char *domain) = 0;
104 
105 };
106 
107 } // end namespace fawkes
108 
109 #endif
virtual ~ServiceBrowseHandler()
Virtual destructor.
Fawkes library namespace.
virtual void service_removed(const char *name, const char *type, const char *domain)=0
A service has been removed from the network.
virtual void browse_failed(const char *name, const char *type, const char *domain)=0
Failed to browse for a given service.
Interface for class that process browse results.
virtual void all_for_now()=0
All results have been retrieved.
virtual void service_added(const char *name, const char *type, const char *domain, const char *host_name, const char *interface, const struct sockaddr *addr, const socklen_t addr_size, uint16_t port, std::list< std::string > &txt, int flags)=0
A service has been announced on the network.
virtual void cache_exhausted()=0
Cache exhausted.