Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 addr pointer to sockaddr struct of appropriate type for address
78  * @param addr_size size of addr struct
79  * @param port port of the service
80  * @param txt list of txt records.
81  * @param flags extra flags, see Avahi documentation
82  */
83  virtual void service_added(const char *name,
84  const char *type,
85  const char *domain,
86  const char *host_name,
87  const struct sockaddr *addr,
88  const socklen_t addr_size,
89  uint16_t port,
90  std::list<std::string> &txt,
91  int flags
92  ) = 0;
93 
94  /** A service has been removed from the network.
95  * @param name name of the service
96  * @param type type of the service
97  * @param domain domain of the service
98  */
99  virtual void service_removed(const char *name,
100  const char *type,
101  const char *domain) = 0;
102 
103 };
104 
105 } // end namespace fawkes
106 
107 #endif
virtual ~ServiceBrowseHandler()
Virtual destructor.
virtual void service_added(const char *name, const char *type, const char *domain, const char *host_name, 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 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 cache_exhausted()=0
Cache exhausted.