Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
qa_avahi_browser.cpp
1
2
/***************************************************************************
3
* qa_avahi_browser.cpp - QA for AvahiBrowser
4
*
5
* Created: Fri Nov 10 10:19:39 2006 (recreated after stupid delete)
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
/// @cond QA
25
26
#include <netcomm/dns-sd/avahi_thread.h>
27
#include <netcomm/service_discovery/browse_handler.h>
28
29
#include <core/exception.h>
30
#include <utils/system/signal.h>
31
32
#include <cstdio>
33
34
using namespace
fawkes;
35
36
class
QAAvahiBrowserMain :
public
SignalHandler
,
public
ServiceBrowseHandler
37
{
38
public
:
39
QAAvahiBrowserMain()
40
{
41
at =
new
AvahiThread
();;
42
at->watch_service(
"_fawkes._udp"
,
this
);
43
}
44
45
~QAAvahiBrowserMain()
46
{
47
delete
at;
48
}
49
50
void
handle_signal(
int
signum)
51
{
52
at->cancel();
53
}
54
55
void
run()
56
{
57
at->start();
58
at->join();
59
}
60
61
virtual
void
all_for_now()
62
{
63
printf(
"ALL_FOR_NOW\n"
);
64
}
65
66
virtual
void
cache_exhausted()
67
{
68
printf(
"CACHE_EXHAUSTED\n"
);
69
}
70
71
virtual
void
browse_failed(
const
char
*name,
72
const
char
*type,
73
const
char
*domain)
74
{
75
printf(
"FAILED: name=%s type=%s domain=%s\n"
, name, type, domain);
76
}
77
78
virtual
void
service_added(
const
char
*name,
79
const
char
*type,
80
const
char
*domain,
81
const
char
*host_name,
82
const
struct
sockaddr *addr,
83
const
socklen_t addr_size,
84
uint16_t port,
85
std::list<std::string> &txt,
86
int
flags
87
)
88
{
89
printf(
"SERVICE_ADDED: name=%s type=%s domain=%s hostname=%s\n"
,
90
name, type, domain, host_name);
91
}
92
93
virtual
void
service_removed(
const
char
*name,
94
const
char
*type,
95
const
char
*domain)
96
{
97
printf(
"SERVICE_REMOVED: name=%s type=%s domain=%s\n"
, name, type, domain);
98
}
99
100
private
:
101
AvahiThread
*at;
102
103
};
104
105
int
106
main(
int
argc,
char
**argv)
107
{
108
try
{
109
110
QAAvahiBrowserMain m;
111
SignalManager::register_handler
(SIGINT, &m);
112
113
m.run();
114
115
}
catch
(
Exception
&e) {
116
e.
print_trace
();
117
}
118
119
SignalManager::finalize
();
120
}
121
122
/// @endcond
src
libs
netcomm
qa
qa_avahi_browser.cpp
Generated by
1.8.1.2